[Fix] minor mem leak.
This commit is contained in:
		
							parent
							
								
									697876409e
								
							
						
					
					
						commit
						127e76c542
					
				
							
								
								
									
										47
									
								
								bin/conf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								bin/conf
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,47 @@ | |||||||
|  | --WINDOW. | ||||||
|  | width       = 800 | ||||||
|  | height      = 640 | ||||||
|  | fullscreen  = 0 | ||||||
|  | 
 | ||||||
|  | -- SCREEN. | ||||||
|  | fps = 0 | ||||||
|  | 
 | ||||||
|  | -- SOUND. | ||||||
|  | nosound = 0 | ||||||
|  | sound 	= 0.7 | ||||||
|  | music 	= 0.5 | ||||||
|  | 
 | ||||||
|  | -- JOYSTICK. | ||||||
|  | -- Can be number or substring of joystick name. | ||||||
|  | joystick = "Precision" | ||||||
|  | 
 | ||||||
|  | -- KEYBINDINGS. | ||||||
|  | -- Type can be keyboard, jaxis or jbutton. | ||||||
|  | -- | ||||||
|  | -- If left is an axis, it will automatically set right to the same axis. | ||||||
|  | -- setting both to the same axis (key). | ||||||
|  | -- You can use reverse = 1 option to reverse them. | ||||||
|  | -- Currently keybindings work with the number of the key only (when doing | ||||||
|  | -- keyboard). Would be cool to have a gui to do this for you at some point. | ||||||
|  | 
 | ||||||
|  | -- Movement. | ||||||
|  | accel           = { type = "jbutton",   key = 0   } | ||||||
|  | left            = { type = "jaxis",     key = 0   } | ||||||
|  | right           = { type = "jaxis",     key = 0   } | ||||||
|  | 
 | ||||||
|  | -- Combat. | ||||||
|  | primary         = { type = "jbutton",   key = 1   } | ||||||
|  | target          = { type = "jbutton",   key = 4   } | ||||||
|  | target_nearest  = { type = "jbutton",   key = 3   } | ||||||
|  | face            = { type = "keyboard",  key = 38  } | ||||||
|  | board           = { type = "keyboard",  key = 57  } | ||||||
|  | secondary       = { type = "jbutton",   key = 7   } | ||||||
|  | secondary_next  = { type = "jbutton",   key = 5   } | ||||||
|  | 
 | ||||||
|  | -- Space. | ||||||
|  | 
 | ||||||
|  | -- Gui. | ||||||
|  | mapzoomin       = { type = "jbutton",   key = 4   } | ||||||
|  | mapzoomout      = { type = "jbutton",   key = 6   } | ||||||
|  | screenshot      = { type = "keyboard",  key = 82  } | ||||||
|  | 
 | ||||||
							
								
								
									
										43
									
								
								src/land.c
									
									
									
									
									
								
							
							
						
						
									
										43
									
								
								src/land.c
									
									
									
									
									
								
							| @ -39,8 +39,9 @@ | |||||||
| int landed = 0; | int landed = 0; | ||||||
| 
 | 
 | ||||||
| static int land_wid = 0; // Primary land window.
 | static int land_wid = 0; // Primary land window.
 | ||||||
| // For the second opened land window (We can only have 2 max).
 | // For the second opened land window
 | ||||||
| static int secondary_wid = 0; | static int secondary_wid = 0; | ||||||
|  | static int terciary_wid = 0; // For fancy things like news, your ship etc..
 | ||||||
| Planet* land_planet = NULL; | Planet* land_planet = NULL; | ||||||
| 
 | 
 | ||||||
| // Commodity excahnge.
 | // Commodity excahnge.
 | ||||||
| @ -63,6 +64,9 @@ static void shipyard_close(char* str); | |||||||
| static void shipyard_update(char* str); | static void shipyard_update(char* str); | ||||||
| static void shipyard_info(char* str); | static void shipyard_info(char* str); | ||||||
| static void shipyard_buy(char* str); | static void shipyard_buy(char* str); | ||||||
|  | // Your ship.
 | ||||||
|  | static void shipyard_yours(char* str); | ||||||
|  | static void shipyard_yoursClose(char* str); | ||||||
| // Spaceport bar.
 | // Spaceport bar.
 | ||||||
| static void spaceport_bar(void); | static void spaceport_bar(void); | ||||||
| static void spaceport_bar_close(char* str); | static void spaceport_bar_close(char* str); | ||||||
| @ -380,6 +384,10 @@ static void shipyard(void) { | |||||||
|                    BUTTON_WIDTH, BUTTON_HEIGHT, "btnCloseShipyard", |                    BUTTON_WIDTH, BUTTON_HEIGHT, "btnCloseShipyard", | ||||||
|                    "Close", shipyard_close); |                    "Close", shipyard_close); | ||||||
| 
 | 
 | ||||||
|  |   window_addButton(secondary_wid, -20, 40+BUTTON_HEIGHT, | ||||||
|  |                    BUTTON_WIDTH, BUTTON_HEIGHT, "btnYourShips", | ||||||
|  |                    "Your Ships", shipyard_yours); | ||||||
|  | 
 | ||||||
|   window_addButton(secondary_wid, -40-BUTTON_WIDTH, 20, |   window_addButton(secondary_wid, -40-BUTTON_WIDTH, 20, | ||||||
|                    BUTTON_WIDTH, BUTTON_HEIGHT, "btnBuyShip", |                    BUTTON_WIDTH, BUTTON_HEIGHT, "btnBuyShip", | ||||||
|                    "Buy", shipyard_buy); |                    "Buy", shipyard_buy); | ||||||
| @ -477,6 +485,30 @@ static void shipyard_buy(char* str) { | |||||||
|                  0., 0., player->solid->dir); |                  0., 0., player->solid->dir); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | static void shipyard_yours(char* str) { | ||||||
|  |   (void)str; | ||||||
|  |   char** ships; | ||||||
|  |   int nships; | ||||||
|  | 
 | ||||||
|  |   terciary_wid = window_create("Your Ships", | ||||||
|  |       -1, -1, SHIPYARD_WIDTH, SHIPYARD_HEIGHT); | ||||||
|  | 
 | ||||||
|  |   window_addButton(terciary_wid, -20, 20, | ||||||
|  |                    BUTTON_WIDTH, BUTTON_HEIGHT, "btnCloseYourShips", | ||||||
|  |                    "Shipyard", shipyard_yoursClose); | ||||||
|  | 
 | ||||||
|  |   ships = NULL; | ||||||
|  |   nships = 0; | ||||||
|  |   window_addList(terciary_wid, 20, 40, | ||||||
|  |                  200, SHIPYARD_HEIGHT-80, "lstYourShips", | ||||||
|  |                  ships, nships, 0, NULL); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static void shipyard_yoursClose(char* str) { | ||||||
|  |   (void)str; | ||||||
|  |   window_destroy(terciary_wid); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| // Spaceport bar.
 | // Spaceport bar.
 | ||||||
| static void spaceport_bar(void) { | static void spaceport_bar(void) { | ||||||
|   secondary_wid = window_create("SpacePort Bar", -1, -1, BAR_WIDTH, BAR_HEIGHT); |   secondary_wid = window_create("SpacePort Bar", -1, -1, BAR_WIDTH, BAR_HEIGHT); | ||||||
| @ -501,23 +533,22 @@ static void spaceport_bar_close(char* str) { | |||||||
| 
 | 
 | ||||||
| // Planet news reports.
 | // Planet news reports.
 | ||||||
| static void news(void) { | static void news(void) { | ||||||
|   unsigned int news_wid; |   terciary_wid = window_create("News Reports", | ||||||
|   news_wid = window_create("News Reports", |  | ||||||
|                            -1, -1, NEWS_WIDTH, NEWS_HEIGHT); |                            -1, -1, NEWS_WIDTH, NEWS_HEIGHT); | ||||||
| 
 | 
 | ||||||
|   window_addText(news_wid, 20, 20 + BUTTON_HEIGHT + 20, |   window_addText(terciary_wid, 20, 20 + BUTTON_HEIGHT + 20, | ||||||
|                  NEWS_WIDTH-40, NEWS_HEIGHT - 20 - BUTTON_HEIGHT - 20 - 20 -20, |                  NEWS_WIDTH-40, NEWS_HEIGHT - 20 - BUTTON_HEIGHT - 20 - 20 -20, | ||||||
|                  0, "txtNews", &gl_smallFont, &cBlack, |                  0, "txtNews", &gl_smallFont, &cBlack, | ||||||
|                  "News reporters report that they are on strike right now! D:"); |                  "News reporters report that they are on strike right now! D:"); | ||||||
| 
 | 
 | ||||||
|   window_addButton(news_wid, -20, 20, |   window_addButton(terciary_wid, -20, 20, | ||||||
|                    BUTTON_WIDTH, BUTTON_HEIGHT, |                    BUTTON_WIDTH, BUTTON_HEIGHT, | ||||||
|                    "btnCloseNews", "Close", news_close); |                    "btnCloseNews", "Close", news_close); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void news_close(char* str) { | static void news_close(char* str) { | ||||||
|   if(strcmp(str, "btnCloseNews")==0) |   if(strcmp(str, "btnCloseNews")==0) | ||||||
|     window_destroy(window_get("News Reports")); |     window_destroy(terciary_wid); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // Land the player.
 | // Land the player.
 | ||||||
|  | |||||||
							
								
								
									
										15
									
								
								src/player.c
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								src/player.c
									
									
									
									
									
								
							| @ -161,9 +161,17 @@ void player_new(void) { | |||||||
| static void player_nameClose(char* str) { | static void player_nameClose(char* str) { | ||||||
|   (void)str; |   (void)str; | ||||||
|   unsigned int wid; |   unsigned int wid; | ||||||
|  |   char* name; | ||||||
| 
 | 
 | ||||||
|   wid = window_get("Player Name"); |   wid = window_get("Player Name"); | ||||||
|   player_name = strdup(window_getInput(wid, "inpName")); |   name = window_getInput(wid, "inpName"); | ||||||
|  | 
 | ||||||
|  |   if(strlen(name) < 3) { | ||||||
|  |     toolkit_alert("Your name must be at least three characters long."); | ||||||
|  |     return; | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   player_name = strdup(name); | ||||||
|   window_destroy(wid); |   window_destroy(wid); | ||||||
| 
 | 
 | ||||||
|   player_newMake(); |   player_newMake(); | ||||||
| @ -269,6 +277,11 @@ static void player_nameShipClose(char* str) { | |||||||
|   wid = window_get("Ship Name"); |   wid = window_get("Ship Name"); | ||||||
|   ship_name = window_getInput(wid, "inpName"); |   ship_name = window_getInput(wid, "inpName"); | ||||||
|   |   | ||||||
|  |   if(strlen(ship_name) < 3) { | ||||||
|  |     toolkit_alert("Your ship's name must be at least three characters long."); | ||||||
|  |     return; | ||||||
|  |   } | ||||||
|  |    | ||||||
|   player_newShipMake(ship_name); |   player_newShipMake(ship_name); | ||||||
| 
 | 
 | ||||||
|   window_destroy(wid); |   window_destroy(wid); | ||||||
|  | |||||||
| @ -257,6 +257,7 @@ void ships_free(void) { | |||||||
|     if((ship_stack+i)->name) free(ship_stack[i].name); |     if((ship_stack+i)->name) free(ship_stack[i].name); | ||||||
|     if((ship_stack+i)->description) free(ship_stack[i].description); |     if((ship_stack+i)->description) free(ship_stack[i].description); | ||||||
|     if((ship_stack+i)->gui) free(ship_stack[i].gui); |     if((ship_stack+i)->gui) free(ship_stack[i].gui); | ||||||
|  |     if((ship_stack+i)->fabricator) free(ship_stack[i].fabricator); | ||||||
|     so = (ship_stack+i)->outfit; |     so = (ship_stack+i)->outfit; | ||||||
|     while(so) { // free the ship outfit.
 |     while(so) { // free the ship outfit.
 | ||||||
|       sot = so; |       sot = so; | ||||||
|  | |||||||
| @ -732,6 +732,9 @@ void space_exit(void) { | |||||||
|         gl_freeTexture(systems_stack[i].planets[j].gfx_space); |         gl_freeTexture(systems_stack[i].planets[j].gfx_space); | ||||||
|       if(systems_stack[i].planets[j].gfx_exterior) |       if(systems_stack[i].planets[j].gfx_exterior) | ||||||
|         gl_freeTexture(systems_stack[i].planets[j].gfx_exterior); |         gl_freeTexture(systems_stack[i].planets[j].gfx_exterior); | ||||||
|  | 
 | ||||||
|  |       // Commodities.
 | ||||||
|  |       free(systems_stack[i].planets[j].commodities); | ||||||
|     } |     } | ||||||
|     free(systems_stack[i].planets); |     free(systems_stack[i].planets); | ||||||
|   } |   } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Allanis
						Allanis