[Fix] Some long time snprintf mistakes.
This commit is contained in:
parent
652d9352ad
commit
0231017e57
12
src/outfit.c
12
src/outfit.c
@ -616,7 +616,7 @@ static void outfit_parseSBeam(Outfit* tmp, const xmlNodePtr parent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} while(xml_nextNode(node));
|
} while(xml_nextNode(node));
|
||||||
|
|
||||||
#define MELEMENT(o,s) if(0) WARN("Outfit '%s' missing/invalid '"s"' element", tmp->name)
|
#define MELEMENT(o,s) if(0) WARN("Outfit '%s' missing/invalid '"s"' element", tmp->name)
|
||||||
MELEMENT(tmp->u.bem.gfx==NULL, "gfx");
|
MELEMENT(tmp->u.bem.gfx==NULL, "gfx");
|
||||||
MELEMENT(tmp->u.bem.spfx==-1, "spfx");
|
MELEMENT(tmp->u.bem.spfx==-1, "spfx");
|
||||||
@ -636,7 +636,7 @@ static void outfit_parseSBeam(Outfit* tmp, const xmlNodePtr parent) {
|
|||||||
/* Parse the specific area for a launcher and loads it into Outfit. */
|
/* Parse the specific area for a launcher and loads it into Outfit. */
|
||||||
static void outfit_parseSLauncher(Outfit* tmp, const xmlNodePtr parent) {
|
static void outfit_parseSLauncher(Outfit* tmp, const xmlNodePtr parent) {
|
||||||
xmlNodePtr node;
|
xmlNodePtr node;
|
||||||
|
|
||||||
node = parent->xmlChildrenNode;
|
node = parent->xmlChildrenNode;
|
||||||
do {
|
do {
|
||||||
/* Load the dataz. */
|
/* Load the dataz. */
|
||||||
@ -668,8 +668,7 @@ static void outfit_parseSAmmo(Outfit* tmp, const xmlNodePtr parent) {
|
|||||||
xmlr_float(node, "speed", tmp->u.amm.speed);
|
xmlr_float(node, "speed", tmp->u.amm.speed);
|
||||||
xmlr_float(node, "energy", tmp->u.amm.energy);
|
xmlr_float(node, "energy", tmp->u.amm.energy);
|
||||||
if(xml_isNode(node, "gfx")) {
|
if(xml_isNode(node, "gfx")) {
|
||||||
snprintf(str, strlen(xml_get(node))+sizeof(OUTFIT_GFX)+10,
|
snprintf(str, PATH_MAX, OUTFIT_GFX"space/%s.png", xml_get(node));
|
||||||
OUTFIT_GFX"space/%s.png", xml_get(node));
|
|
||||||
tmp->u.amm.gfx_space = gl_newSprite(str, 6, 6);
|
tmp->u.amm.gfx_space = gl_newSprite(str, 6, 6);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -680,7 +679,7 @@ static void outfit_parseSAmmo(Outfit* tmp, const xmlNodePtr parent) {
|
|||||||
else if(xml_isNode(node, "damage"))
|
else if(xml_isNode(node, "damage"))
|
||||||
outfit_parseDamage(&tmp->u.amm.dtype, &tmp->u.amm.damage, node);
|
outfit_parseDamage(&tmp->u.amm.dtype, &tmp->u.amm.damage, node);
|
||||||
} while((node = node->next));
|
} while((node = node->next));
|
||||||
|
|
||||||
/* Post-processing. */
|
/* Post-processing. */
|
||||||
tmp->u.amm.resist /= 100.; /* Set it in per one. */
|
tmp->u.amm.resist /= 100.; /* Set it in per one. */
|
||||||
|
|
||||||
@ -805,8 +804,7 @@ static Outfit* outfit_parse(const xmlNodePtr parent) {
|
|||||||
xmlr_int(cur, "price", tmp->price);
|
xmlr_int(cur, "price", tmp->price);
|
||||||
xmlr_strd(cur, "description", tmp->description);
|
xmlr_strd(cur, "description", tmp->description);
|
||||||
if(xml_isNode(cur, "gfx_store")) {
|
if(xml_isNode(cur, "gfx_store")) {
|
||||||
snprintf(str, strlen(xml_get(cur))+sizeof(OUTFIT_GFX)+10,
|
snprintf(str, PATH_MAX, OUTFIT_GFX"store/%s.png", xml_get(cur));
|
||||||
OUTFIT_GFX"store/%s.png", xml_get(cur));
|
|
||||||
tmp->gfx_store = gl_newImage(str);
|
tmp->gfx_store = gl_newImage(str);
|
||||||
}
|
}
|
||||||
} while((cur = cur->next));
|
} while((cur = cur->next));
|
||||||
|
41
src/player.c
41
src/player.c
@ -322,7 +322,7 @@ static void player_newMake(void) {
|
|||||||
player_new();
|
player_new();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
space_init(sysname);
|
space_init(sysname);
|
||||||
free(sysname);
|
free(sysname);
|
||||||
|
|
||||||
@ -499,7 +499,7 @@ void player_rmShip(char* shipname) {
|
|||||||
sizeof(char*) * (player_nstack-i-1));
|
sizeof(char*) * (player_nstack-i-1));
|
||||||
|
|
||||||
player_nstack--; /* Shrink stack. */
|
player_nstack--; /* Shrink stack. */
|
||||||
|
|
||||||
/* Realloc memory to smaller size. */
|
/* Realloc memory to smaller size. */
|
||||||
player_stack = realloc(player_stack,
|
player_stack = realloc(player_stack,
|
||||||
sizeof(Pilot*) * (player_nstack));
|
sizeof(Pilot*) * (player_nstack));
|
||||||
@ -539,7 +539,7 @@ void player_cleanup(void) {
|
|||||||
/* Nothing left. */
|
/* Nothing left. */
|
||||||
player_nstack = 0;
|
player_nstack = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clean up missions. */
|
/* Clean up missions. */
|
||||||
if(missions_done != NULL) {
|
if(missions_done != NULL) {
|
||||||
free(missions_done);
|
free(missions_done);
|
||||||
@ -824,12 +824,12 @@ void player_renderGUI(void) {
|
|||||||
}
|
}
|
||||||
/* Fancy cinematic scene borders. */
|
/* Fancy cinematic scene borders. */
|
||||||
spfx_cinematic();
|
spfx_cinematic();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(player == NULL) return;
|
if(player == NULL) return;
|
||||||
|
|
||||||
/* Lockon warning. */
|
/* Lockon warning. */
|
||||||
if(player->lockons > 0)
|
if(player->lockons > 0)
|
||||||
gl_printMid(NULL, SCREEN_W, 0., SCREEN_H-gl_defFont.h-25.,
|
gl_printMid(NULL, SCREEN_W, 0., SCREEN_H-gl_defFont.h-25.,
|
||||||
@ -1269,31 +1269,30 @@ static void rect_parse(const xmlNodePtr parent, double* x, double* y,
|
|||||||
{ (a).x += VX(gui.frame); (a).y = VY(gui.frame) + gui.gfx_frame->h-(a).y; }
|
{ (a).x += VX(gui.frame); (a).y = VY(gui.frame) + gui.gfx_frame->h-(a).y; }
|
||||||
static int gui_parse(const xmlNodePtr parent, const char* name) {
|
static int gui_parse(const xmlNodePtr parent, const char* name) {
|
||||||
xmlNodePtr cur, node;
|
xmlNodePtr cur, node;
|
||||||
char* tmp, *tmp2;
|
char* tmp, buf[PATH_MAX];
|
||||||
|
|
||||||
/* Gfx. */
|
/* Gfx. */
|
||||||
/* Set a property and not a node because it must be loaded first. */
|
/* Set a property and not a node because it must be loaded first. */
|
||||||
tmp2 = xml_nodeProp(parent, "gfx");
|
tmp = xml_nodeProp(parent, "gfx");
|
||||||
if(tmp2 == NULL) {
|
if(tmp == NULL) {
|
||||||
ERR("GUI '%s' has no gfx property", name);
|
ERR("GUI '%s' has no gfx property", name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* Load gfx. */
|
/* Load gfx. */
|
||||||
tmp = malloc((strlen(tmp2)+strlen(GUI_GFX)+12) * sizeof(char));
|
|
||||||
/* Frame. */
|
/* Frame. */
|
||||||
snprintf(tmp, strlen(tmp2)+strlen(GUI_GFX)+5, GUI_GFX"%s.png", tmp2);
|
snprintf(buf, PATH_MAX, GUI_GFX"%s.png", tmp);
|
||||||
if(gui.gfx_frame) gl_freeTexture(gui.gfx_frame); /* Free if needed. */
|
if(gui.gfx_frame) gl_freeTexture(gui.gfx_frame); /* Free if needed. */
|
||||||
gui.gfx_frame = gl_newImage(tmp);
|
gui.gfx_frame = gl_newImage(buf);
|
||||||
/* Pilot. */
|
/* Pilot. */
|
||||||
snprintf(tmp, strlen(tmp2)+strlen(GUI_GFX)+11, GUI_GFX"%s_pilot.png", tmp2);
|
snprintf(buf, PATH_MAX, GUI_GFX"%s_pilot.png", tmp);
|
||||||
if(gui.gfx_targetPilot) gl_freeTexture(gui.gfx_targetPilot); /* Free if needed. */
|
if(gui.gfx_targetPilot) gl_freeTexture(gui.gfx_targetPilot); /* Free if needed. */
|
||||||
gui.gfx_targetPilot = gl_newSprite(tmp, 2, 2);
|
gui.gfx_targetPilot = gl_newSprite(buf, 2, 2);
|
||||||
/* Planet. */
|
/* Planet. */
|
||||||
snprintf(tmp, strlen(tmp2)+strlen(GUI_GFX)+12, GUI_GFX"%s_planet.png", tmp2);
|
snprintf(buf, PATH_MAX, GUI_GFX"%s_planet.png", tmp);
|
||||||
if(gui.gfx_targetPlanet) gl_freeTexture(gui.gfx_targetPlanet); /* Free if needed. */
|
if(gui.gfx_targetPlanet) gl_freeTexture(gui.gfx_targetPlanet); /* Free if needed. */
|
||||||
gui.gfx_targetPlanet = gl_newSprite(tmp, 2, 2);
|
gui.gfx_targetPlanet = gl_newSprite(buf, 2, 2);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
free(tmp2);
|
|
||||||
|
|
||||||
/* Frame (based on gfx). */
|
/* Frame (based on gfx). */
|
||||||
vect_csetmin(&gui.frame,
|
vect_csetmin(&gui.frame,
|
||||||
@ -1477,7 +1476,7 @@ void player_think(Pilot* pplayer) {
|
|||||||
}
|
}
|
||||||
else if(player_isFlag(PLAYER_SECONDARY_L)) {
|
else if(player_isFlag(PLAYER_SECONDARY_L)) {
|
||||||
player_rmFlag(PLAYER_SECONDARY_L);
|
player_rmFlag(PLAYER_SECONDARY_L);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Afterburn! */
|
/* Afterburn! */
|
||||||
if(player_isFlag(PLAYER_AFTERBURNER)) {
|
if(player_isFlag(PLAYER_AFTERBURNER)) {
|
||||||
@ -1698,7 +1697,7 @@ void player_brokeHyperspace(void) {
|
|||||||
/* Set position, pilot_update will handle the lowering of velocity. */
|
/* Set position, pilot_update will handle the lowering of velocity. */
|
||||||
player_warp(-cos(player->solid->dir) * MIN_HYPERSPACE_DIST * 2.5,
|
player_warp(-cos(player->solid->dir) * MIN_HYPERSPACE_DIST * 2.5,
|
||||||
-sin(player->solid->dir) * MIN_HYPERSPACE_DIST * 2.5);
|
-sin(player->solid->dir) * MIN_HYPERSPACE_DIST * 2.5);
|
||||||
|
|
||||||
/* Reduce fuel. */
|
/* Reduce fuel. */
|
||||||
player->fuel -= HYPERSPACE_FUEL;
|
player->fuel -= HYPERSPACE_FUEL;
|
||||||
|
|
||||||
@ -2119,7 +2118,7 @@ static int player_parse(xmlNodePtr parent) {
|
|||||||
|
|
||||||
if(xml_isNode(node, "ship"))
|
if(xml_isNode(node, "ship"))
|
||||||
player_parseShip(node, 1);
|
player_parseShip(node, 1);
|
||||||
|
|
||||||
if(xml_isNode(node, "ships")) {
|
if(xml_isNode(node, "ships")) {
|
||||||
cur = node->xmlChildrenNode;
|
cur = node->xmlChildrenNode;
|
||||||
do {
|
do {
|
||||||
@ -2238,7 +2237,7 @@ static int player_parseShip(xmlNodePtr parent, int is_player) {
|
|||||||
/* Set fuel. */
|
/* Set fuel. */
|
||||||
if(fuel != 0)
|
if(fuel != 0)
|
||||||
ship->fuel = MIN(ship->fuel_max, fuel);
|
ship->fuel = MIN(ship->fuel_max, fuel);
|
||||||
|
|
||||||
/* Add it to the stack if it's not what the player is in. */
|
/* Add it to the stack if it's not what the player is in. */
|
||||||
if(is_player == 0) {
|
if(is_player == 0) {
|
||||||
player_stack = realloc(player_stack, sizeof(Pilot*)*(player_nstack+1));
|
player_stack = realloc(player_stack, sizeof(Pilot*)*(player_nstack+1));
|
||||||
@ -2247,7 +2246,7 @@ static int player_parseShip(xmlNodePtr parent, int is_player) {
|
|||||||
player_lstack[player_nstack] = strdup(loc);
|
player_lstack[player_nstack] = strdup(loc);
|
||||||
player_nstack++;
|
player_nstack++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
17
src/space.c
17
src/space.c
@ -313,7 +313,7 @@ char* space_getRndPlanet(void) {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return 1 if player can reach the system. */
|
/* Return 1 if player can reach the system. */
|
||||||
int space_sysReachable(StarSystem* sys) {
|
int space_sysReachable(StarSystem* sys) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -527,8 +527,7 @@ static Planet* planet_pull(const char* name) {
|
|||||||
do {
|
do {
|
||||||
if(xml_isNode(cur, "space")) {
|
if(xml_isNode(cur, "space")) {
|
||||||
/* Load space gfx. */
|
/* Load space gfx. */
|
||||||
snprintf(str, strlen(xml_get(cur))+sizeof(PLANET_GFX_SPACE),
|
snprintf(str, PATH_MAX, PLANET_GFX_SPACE"%s", xml_get(cur));
|
||||||
PLANET_GFX_SPACE"%s", xml_get(cur));
|
|
||||||
tmp->gfx_space = gl_newImage(str);
|
tmp->gfx_space = gl_newImage(str);
|
||||||
}
|
}
|
||||||
else if(xml_isNode(cur, "exterior")) {
|
else if(xml_isNode(cur, "exterior")) {
|
||||||
@ -860,7 +859,7 @@ void space_render(const double dt) {
|
|||||||
|
|
||||||
/* Render the overlay. */
|
/* Render the overlay. */
|
||||||
void space_renderOverlay(const double dt) {
|
void space_renderOverlay(const double dt) {
|
||||||
if(cur_system == NULL) return;
|
if(cur_system == NULL) return;
|
||||||
|
|
||||||
if(cur_system->nebu_density > 0.)
|
if(cur_system->nebu_density > 0.)
|
||||||
nebu_renderOverlay(dt);
|
nebu_renderOverlay(dt);
|
||||||
@ -911,7 +910,7 @@ static void space_renderStars(const double dt) {
|
|||||||
b = 13.-10.*stars[i].brightness;
|
b = 13.-10.*stars[i].brightness;
|
||||||
stars[i].x -= player->solid->vel.x/b*dt;
|
stars[i].x -= player->solid->vel.x/b*dt;
|
||||||
stars[i].y -= player->solid->vel.y/b*dt;
|
stars[i].y -= player->solid->vel.y/b*dt;
|
||||||
|
|
||||||
/* Check for boundaries. */
|
/* Check for boundaries. */
|
||||||
if(stars[i].x > SCREEN_W + STAR_BUF) stars[i].x = -STAR_BUF;
|
if(stars[i].x > SCREEN_W + STAR_BUF) stars[i].x = -STAR_BUF;
|
||||||
else if(stars[i].x < -STAR_BUF) stars[i].x = SCREEN_W + STAR_BUF;
|
else if(stars[i].x < -STAR_BUF) stars[i].x = SCREEN_W + STAR_BUF;
|
||||||
@ -952,13 +951,13 @@ void planets_render(void) {
|
|||||||
/* Clean up the system. */
|
/* Clean up the system. */
|
||||||
void space_exit(void) {
|
void space_exit(void) {
|
||||||
int i,j;
|
int i,j;
|
||||||
|
|
||||||
/* Free the names. */
|
/* Free the names. */
|
||||||
/*if(planetname_stack) free(planetname_stack); */
|
/*if(planetname_stack) free(planetname_stack); */
|
||||||
/*if(systemname_stack) free(systemname_stack); */
|
/*if(systemname_stack) free(systemname_stack); */
|
||||||
if(planetname_stack) {
|
if(planetname_stack) {
|
||||||
free(planetname_stack);
|
free(planetname_stack);
|
||||||
planetname_stack = NULL;
|
planetname_stack = NULL;
|
||||||
}
|
}
|
||||||
if(systemname_stack) {
|
if(systemname_stack) {
|
||||||
free(systemname_stack);
|
free(systemname_stack);
|
||||||
@ -1039,7 +1038,7 @@ int space_sysLoad(xmlNodePtr parent) {
|
|||||||
StarSystem* sys;
|
StarSystem* sys;
|
||||||
|
|
||||||
space_clearKnown();
|
space_clearKnown();
|
||||||
|
|
||||||
node = parent->xmlChildrenNode;
|
node = parent->xmlChildrenNode;
|
||||||
do {
|
do {
|
||||||
if(xml_isNode(node, "space")) {
|
if(xml_isNode(node, "space")) {
|
||||||
|
Loading…
Reference in New Issue
Block a user