[Fix] minor mem leak.

This commit is contained in:
Allanis 2013-03-22 18:35:11 +00:00
parent 697876409e
commit 127e76c542
5 changed files with 103 additions and 8 deletions

47
bin/conf Normal file
View 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 }

View File

@ -39,8 +39,9 @@
int landed = 0;
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 terciary_wid = 0; // For fancy things like news, your ship etc..
Planet* land_planet = NULL;
// Commodity excahnge.
@ -63,6 +64,9 @@ static void shipyard_close(char* str);
static void shipyard_update(char* str);
static void shipyard_info(char* str);
static void shipyard_buy(char* str);
// Your ship.
static void shipyard_yours(char* str);
static void shipyard_yoursClose(char* str);
// Spaceport bar.
static void spaceport_bar(void);
static void spaceport_bar_close(char* str);
@ -380,6 +384,10 @@ static void shipyard(void) {
BUTTON_WIDTH, BUTTON_HEIGHT, "btnCloseShipyard",
"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,
BUTTON_WIDTH, BUTTON_HEIGHT, "btnBuyShip",
"Buy", shipyard_buy);
@ -477,6 +485,30 @@ static void shipyard_buy(char* str) {
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.
static void spaceport_bar(void) {
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.
static void news(void) {
unsigned int news_wid;
news_wid = window_create("News Reports",
terciary_wid = window_create("News Reports",
-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,
0, "txtNews", &gl_smallFont, &cBlack,
"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,
"btnCloseNews", "Close", news_close);
}
static void news_close(char* str) {
if(strcmp(str, "btnCloseNews")==0)
window_destroy(window_get("News Reports"));
window_destroy(terciary_wid);
}
// Land the player.

View File

@ -161,9 +161,17 @@ void player_new(void) {
static void player_nameClose(char* str) {
(void)str;
unsigned int wid;
char* 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);
player_newMake();
@ -268,7 +276,12 @@ static void player_nameShipClose(char* str) {
wid = window_get("Ship Name");
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);
window_destroy(wid);

View File

@ -257,6 +257,7 @@ void ships_free(void) {
if((ship_stack+i)->name) free(ship_stack[i].name);
if((ship_stack+i)->description) free(ship_stack[i].description);
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;
while(so) { // free the ship outfit.
sot = so;

View File

@ -732,6 +732,9 @@ void space_exit(void) {
gl_freeTexture(systems_stack[i].planets[j].gfx_space);
if(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);
}