From 5387d047210a308c449b8173596fd0740165722a Mon Sep 17 00:00:00 2001 From: Steffen Pohle Date: Sat, 5 Feb 2022 11:12:58 +0100 Subject: [PATCH] converting sprintf to snprintf, fixing compiling issues --- .gitignore | 38 +++++++++++++++++++++++++++++++++++ include/player.h | 2 +- src/chat.c | 32 ++++++++++++++--------------- src/configuration.c | 6 ++++++ src/debug.c | 30 ++++++++++++++------------- src/field.c | 10 +++------ src/font.c | 6 +++--- src/game.c | 10 ++++----- src/gfx.c | 39 +++++++++++++++++------------------ src/gfxpixelimage.c | 4 ++-- src/keyb.c | 19 ++++-------------- src/map.c | 12 +++++++---- src/mapmenu.c | 48 ++++++++++++++++++++++++-------------------- src/menu.c | 3 +-- src/netmenu.c | 8 +++----- src/netsrvlist.c | 33 +++++++++++++++++++----------- src/ogcache-client.c | 26 ++++++++++++++++-------- src/packets.c | 21 +++++++++++-------- src/pkgcache.c | 6 ++++++ src/player.c | 17 ++++++---------- src/playermenu.c | 18 ++++++++--------- src/single.c | 6 +++--- src/tileset.c | 22 +++++++++++--------- 23 files changed, 238 insertions(+), 178 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a582993 --- /dev/null +++ b/.gitignore @@ -0,0 +1,38 @@ +.cproject +.project +.settings/ +Makefile.in +aclocal.m4 +compile +config.guess +config.h.in +config.sub +configure +configure~ +data/Makefile.in +data/gfx/Makefile.in +data/maps/Makefile.in +data/music/Makefile.in +data/pixmaps/Makefile.in +data/player/Makefile.in +data/tileset/Makefile.in +data/tileset/cemetery/Makefile.in +data/tileset/classic/Makefile.in +data/tileset/cucumber/Makefile.in +data/tileset/default/Makefile.in +data/tileset/farm/Makefile.in +data/tileset/hell/Makefile.in +data/tileset/jungle/Makefile.in +data/tileset/modern/Makefile.in +data/tileset/radioactive/Makefile.in +data/tileset/sheep/Makefile.in +data/tileset/supermario/Makefile.in +data/tileset/tricked/Makefile.in +ata/tileset/uccia_garbage/Makefile.in +data/tileset/zbb_frog/Makefile.in +depcomp +include/Makefile.in +install-sh +missing +src/Makefile.in + diff --git a/include/player.h b/include/player.h index 1fefd99..edd75a9 100644 --- a/include/player.h +++ b/include/player.h @@ -174,7 +174,7 @@ extern void playerinput_keyb_read (int pk_offset, int pl_nr); extern void playernamemenu (); extern void playermenu (); extern int playermenu_selgfx (int pl_nr); -extern void playermenu_getflags (char *text, _player *player); +extern void playermenu_getflags (char *text, int txtlen, _player *player); extern int teammenu_select (_player *pl); extern void teammenu (); diff --git a/src/chat.c b/src/chat.c index c63808d..52f796d 100644 --- a/src/chat.c +++ b/src/chat.c @@ -75,8 +75,7 @@ chat_drawbox () SDL_Rect src; int i; - if (gfx_locksurface (gfx.screen)) - return; + if (gfx_locksurface (gfx.screen)) return; src = chat.window; SDL_BlitSurface (chat.oldscreen, NULL, gfx.screen, &src); @@ -137,8 +136,7 @@ chat_drawlines () if (i < 0) i = 0; - for (nr = 0; i <= chat.curline; i++, nr++) - font_gfxdraw (chat.window.x + 4, chat.window.y + 4 + font[0].size.y * nr, chat.lines[i].text, 0, chat.lines[i].color, 0x1000); + for (nr = 0; i <= chat.curline; i++, nr++) font_gfxdraw (chat.window.x + 4, chat.window.y + 4 + font[0].size.y * nr, chat.lines[i].text, 0, chat.lines[i].color, 0x1000); }; @@ -169,10 +167,8 @@ chat_drawinput () src.w = chat.window.x + chat.window.w - 4; src.h = chat.window.y + chat.window.h - 4; - if (chat.active) - draw_shadefield (gfx.screen, &src, CHAT_BG_SHADE_BRIGHT); - else - draw_shadefield (gfx.screen, &src, CHAT_BG_SHADE_DARK); + if (chat.active) draw_shadefield (gfx.screen, &src, CHAT_BG_SHADE_BRIGHT); + else draw_shadefield (gfx.screen, &src, CHAT_BG_SHADE_DARK); gfx_blitupdaterectadd (&chat.window); start = strlen (chat.input.text) - maxlen; @@ -220,6 +216,11 @@ chat_show (int x, int y, int w, int h) /* * loop through the chat and draw it */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-overflow" +#pragma GCC diagnostic ignored "-Wformat-truncation" +#pragma GCC diagnostic ignored "-Wstringop-overflow" + void chat_loop (SDL_Event * event) { @@ -227,21 +228,19 @@ chat_loop (SDL_Event * event) char text[255]; if (chat.active) { /* the chat mode is active */ - if (event != NULL) - i = keybinput_loop (&chat.input, event); + if (event != NULL) i = keybinput_loop (&chat.input, event); else { i = 0; chat.input.changed = 1; } if (i == 1 && chat.input.text[0] != 0) { - sprintf (text, "%s: %s", bman.playername, chat.input.text); + snprintf (text, 255, "%s: %s", bman.playername, chat.input.text); net_send_chat (text, 1); chat_addline (text, CHAT_TEXTCOLOR); keybinput_new (&chat.input, KEYBI_text, 255); i = 0; - if (!chat.keepactive) - chat.active = 0; + if (!chat.keepactive) chat.active = 0; chat.changed = 1; } } @@ -251,12 +250,11 @@ chat_loop (SDL_Event * event) /* * check if we have to redraw the input line */ - if (chat.changed) - chat_draw (); + if (chat.changed) chat_draw (); - if (chat.input.changed) - chat_drawinput (); + if (chat.input.changed) chat_drawinput (); }; +#pragma GCC diagnostic pop /* diff --git a/src/configuration.c b/src/configuration.c index d598c8a..0990f41 100644 --- a/src/configuration.c +++ b/src/configuration.c @@ -14,6 +14,10 @@ #include "keyb.h" #include "player.h" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-overflow" +#pragma GCC diagnostic ignored "-Wformat-truncation" +#pragma GCC diagnostic ignored "-Wstringop-overflow" /* * try to find the datapath and set the variable bman.datapath @@ -879,3 +883,5 @@ check_version (int ma, int mi, int su, char *ver) return res; }; + +#pragma GCC diagnostic pop diff --git a/src/debug.c b/src/debug.c index a82bced..d075b34 100644 --- a/src/debug.c +++ b/src/debug.c @@ -33,35 +33,37 @@ void d_printf (char *fmt,...) { va_end (args); }; - +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-overflow" +#pragma GCC diagnostic ignored "-Wformat-truncation" +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#define TEXTLEN 255 void d_playerstat (char *head) { int i, j; - char text[255]; + char text1[TEXTLEN]; + char text2[TEXTLEN]; d_printf ("---------------> %s nb play: %d\n", head, bman.playnum); - sprintf (text, "id Name killed Unknown"); + sprintf (text1, "id Name killed Unknown"); for (i = 0; i < MAX_PLAYERS; i++) if (players[i].gamestats.isaplayer == 1) - sprintf(text, "%s %02d", text, i); - sprintf(text, "%s\n", text); - d_printf (text); + snprintf(text2, TEXTLEN, "%s %02d", text1, i); + strncat(text2, "\n", TEXTLEN); + d_printf (text2); for (i = 0; i < MAX_PLAYERS; i++){ if (players[i].gamestats.isaplayer == 1 ) { - sprintf(text, "%02d %-16s %2d %d ", i, players[i].name, players[i].gamestats.killed, players[i].gamestats.unknown); + sprintf(text1, "%02d %-16s %2d %d ", i, players[i].name, players[i].gamestats.killed, players[i].gamestats.unknown); for (j = 0; j < MAX_PLAYERS; j++) if (players[j].gamestats.isaplayer == 1 ) - sprintf(text, "%s %2d", text, players[i].gamestats.killedBy[j]); - sprintf(text, "%s\n", text); - d_printf (text); + sprintf(text2, "%s %2d", text1, players[i].gamestats.killedBy[j]); + strncat(text2, "\n", TEXTLEN); + d_printf (text2); } } }; - - -// int killed[MAX_PLAYERS]; - +#pragma GCC diagnostic pop void d_playerdetail (char *head) { diff --git a/src/field.c b/src/field.c index 5077358..af8ec77 100644 --- a/src/field.c +++ b/src/field.c @@ -180,8 +180,7 @@ draw_stone (int x, int y) } // draw explosions if there is any - for (d = 0; d < 4; d++) - if (stone->ex[d].count > 0) { + for (d = 0; d < 4; d++) if (stone->ex[d].count > 0) { stone_drawfire (x, y, -1); break; } @@ -504,13 +503,10 @@ field_hurrysize () /* check if a bomb is at this position, if so let the bomb explode and wait untill the explosion is over */ - for (i = 0, d = 0; d < 4; d++) - if (map.field[fieldhurrypos.x][fieldhurrypos.y].ex[d].count > 0) - i++; + for (i = 0, d = 0; d < 4; d++) if (map.field[fieldhurrypos.x][fieldhurrypos.y].ex[d].count > 0) i++; get_bomb_on (fieldhurrypos.x, fieldhurrypos.y, bombs); - if (i) - fieldhurrypos = old; + if (i) fieldhurrypos = old; else if (bombs[0].y != -1 && bombs[0].x != -1) { fieldhurrypos = old; bomb_explode (&players[bombs[0].x].bombs[bombs[0].y], 1); diff --git a/src/font.c b/src/font.c index f583ae6..93b80f2 100644 --- a/src/font.c +++ b/src/font.c @@ -65,15 +65,15 @@ font_gfxdraw (int x, int y, char *text, int size, int color, int ypos) }; - +#define FNSIZE (16+LEN_PATHFILENAME) void font_load () { int c,i,r,g,b; - char filename[LEN_PATHFILENAME]; + char filename[FNSIZE]; SDL_Surface *raw, *tmp; /* load the font */ for (i = 0; i < 3; i++) { - sprintf (filename, "%s/gfx/font%d.png", bman.datapath, i); + snprintf (filename, FNSIZE, "%s/gfx/font%d.png", bman.datapath, i); tmp = IMG_Load (filename); if (tmp == NULL) { printf ("Could not load font.\n"); diff --git a/src/game.c b/src/game.c index 4eb7a5f..c5c92e7 100644 --- a/src/game.c +++ b/src/game.c @@ -224,13 +224,11 @@ game_loop () int done = 0, eventstate; - if (GT_MP) - net_game_fillsockaddr (); - if ( SDL_InitSubSystem ( SDL_INIT_JOYSTICK ) < 0 ) - { + if (GT_MP) net_game_fillsockaddr (); + if ( SDL_InitSubSystem ( SDL_INIT_JOYSTICK ) < 0 ) { fprintf ( stderr, "Unable to initialize Joystick: %s\n", SDL_GetError() ); - } - printf ( "%i joysticks found\n", SDL_NumJoysticks () ); + } + printf ( "%i joysticks found\n", SDL_NumJoysticks () ); menu = NULL; bman.updatestatusbar = 1; // force an update diff --git a/src/gfx.c b/src/gfx.c index 42a2051..82136c4 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -13,17 +13,18 @@ static void gfx_load_fieldtype_menu (); /* * count all playergfx */ +#define FNSIZE (LEN_PATHFILENAME+LEN_PATHFILENAME) int gfx_get_nr_of_playergfx () { int i = 0; FILE *f = NULL; - char filename[255]; + char filename[FNSIZE]; do { if (f) { fclose (f); i++; } - sprintf (filename, "%s/player/player%d.png", bman.datapath, i); + snprintf (filename, FNSIZE ,"%s/player/player%d.png", bman.datapath, i); f = fopen (filename, "r"); } while (f); @@ -51,7 +52,7 @@ gfx_load_players (int sx, int sy) /* loading the player images */ for (i = 0; i < gfx.player_gfx_count; i++) { - sprintf (filename, "%s/player/player%d.png", bman.datapath, i); + snprintf (filename, FNSIZE, "%s/player/player%d.png", bman.datapath, i); tmpimage = IMG_Load (filename); if (tmpimage == NULL) { printf ("Can't load image: %s\n", SDL_GetError ()); @@ -78,7 +79,7 @@ gfx_load_players (int sx, int sy) } /* load the death image */ - sprintf (filename, "%s/player/dead0.png", bman.datapath); + snprintf (filename, FNSIZE, "%s/player/dead0.png", bman.datapath); tmpimage = IMG_Load (filename); if (tmpimage == NULL) { /* no image found - set field clear */ @@ -95,7 +96,7 @@ gfx_load_players (int sx, int sy) SDL_FreeSurface (tmpimage); /* load the illnessthing */ - sprintf (filename, "%s/player/playersick.png", bman.datapath); + snprintf (filename, FNSIZE, "%s/player/playersick.png", bman.datapath); tmpimage = IMG_Load (filename); if (tmpimage == NULL) { printf ("Can't load image: %s\n", SDL_GetError ()); @@ -110,7 +111,7 @@ gfx_load_players (int sx, int sy) SDL_FreeSurface (tmpimage1); /* load the respawn gfx */ - sprintf (filename, "%s/player/respawn.png", bman.datapath); + snprintf (filename, FNSIZE, "%s/player/respawn.png", bman.datapath); tmpimage = IMG_Load (filename); if (tmpimage == NULL) { printf ("Can't load image: %s\n", SDL_GetError ()); @@ -188,7 +189,7 @@ gfx_loaddata () *tmpimage1; /* load the logo */ - sprintf (filename, "%s/gfx/logo.png", bman.datapath); + snprintf (filename, FNSIZE, "%s/gfx/logo.png", bman.datapath); tmpimage = IMG_Load (filename); if (tmpimage == NULL) { printf ("Can't load image: %s\n", SDL_GetError ()); @@ -204,7 +205,7 @@ gfx_loaddata () /* load the menugraphics */ for (i = 0; i < 9; i++) { - sprintf (filename, "%s/gfx/menu%d.png", bman.datapath, i); + snprintf (filename, FNSIZE, "%s/gfx/menu%d.png", bman.datapath, i); menuimages[i] = IMG_Load (filename); if (menuimages[i] == NULL) { printf ("Can't load image: %s\n", SDL_GetError ()); @@ -215,7 +216,7 @@ gfx_loaddata () /* load menu buttongraphic */ for (j = 0; j < 3; j++) for (i = 0; i < 3; i++) { - sprintf (filename, "%s/gfx/menubutton%d_%d.png", bman.datapath, j, i); + snprintf (filename, FNSIZE, "%s/gfx/menubutton%d_%d.png", bman.datapath, j, i); tmpimage = IMG_Load (filename); if (tmpimage == NULL) { printf ("Can't load image: %s\n", SDL_GetError ()); @@ -229,7 +230,7 @@ gfx_loaddata () /* load menu buttongraphic */ for (j = 0; j < 2; j++) for (i = 0; i < 3; i++) { - sprintf (filename, "%s/gfx/menuentry%d_%d.png", bman.datapath, j, i); + snprintf (filename, FNSIZE, "%s/gfx/menuentry%d_%d.png", bman.datapath, j, i); tmpimage = IMG_Load (filename); if (tmpimage == NULL) { printf ("Can't load image: %s\n", SDL_GetError ()); @@ -243,7 +244,7 @@ gfx_loaddata () /* load menu listgraphic */ for (j = 0; j < 2; j++) for (i = 0; i < 9; i++) { - sprintf (filename, "%s/gfx/menulist%d_%d.png", bman.datapath, j, i); + snprintf (filename, FNSIZE, "%s/gfx/menulist%d_%d.png", bman.datapath, j, i); tmpimage = IMG_Load (filename); if (tmpimage == NULL) { printf ("Can't load image: %s\n", SDL_GetError ()); @@ -255,7 +256,7 @@ gfx_loaddata () } /* load menuselect animation */ - sprintf (filename, "%s/gfx/menuselect.png", bman.datapath); + snprintf (filename, FNSIZE, "%s/gfx/menuselect.png", bman.datapath); gfx.menuselect.image = IMG_Load (filename); if (gfx.menuselect.image == NULL) { printf ("Can't load image: %s\n", SDL_GetError ()); @@ -282,7 +283,7 @@ static void gfx_load_menusmall_players () { SDL_Surface *img; SDL_Rect rect; - sprintf (filename, "%s/player/player%d.png", bman.datapath, i); + snprintf (filename, FNSIZE, "%s/player/player%d.png", bman.datapath, i); orgimg = IMG_Load (filename); if (orgimg == NULL) { printf ("Can't load image: %s\n", SDL_GetError ()); @@ -319,7 +320,7 @@ static void gfx_load_menusmall_players () { } /* load the ghost player */ - sprintf (filename, "%s/player/ghost.png", bman.datapath); + snprintf (filename, FNSIZE, "%s/player/ghost.png", bman.datapath); orgimg = IMG_Load (filename); sfkt = (float)(((float)(GFX_MENUPLAYERIMGSIZE_X * 2)) / ((float)orgimg->h)); gfx.ghost = scale_image (orgimg, (int)(((float)orgimg->w)*sfkt), GFX_MENUPLAYERIMGSIZE_X * 2); @@ -360,7 +361,7 @@ static void gfx_load_fieldtype_menu () { */ if (ft == 0) { if (background != NULL) SDL_FreeSurface (background); - sprintf (filename, "%s/tileset/default/background.png", bman.datapath); + snprintf (filename, FNSIZE, "%s/tileset/default/background.png", bman.datapath); orgimg = IMG_Load (filename); if (!orgimg) { printf ("Can't load image. :%s\n", SDL_GetError ()); @@ -377,7 +378,7 @@ static void gfx_load_fieldtype_menu () { if (ft == FT_death) { if (background != NULL) SDL_FreeSurface (background); - sprintf (filename, "%s/tileset/default/powerbad.png", bman.datapath); + snprintf (filename, FNSIZE, "%s/tileset/default/powerbad.png", bman.datapath); orgimg = IMG_Load (filename); if (!orgimg) { printf ("Can't load image. :%s\n", SDL_GetError ()); @@ -394,7 +395,7 @@ static void gfx_load_fieldtype_menu () { if (ft == FT_fire) { if (background != NULL) SDL_FreeSurface (background); - sprintf (filename, "%s/tileset/default/powerup.png", bman.datapath); + snprintf (filename, FNSIZE, "%s/tileset/default/powerup.png", bman.datapath); orgimg = IMG_Load (filename); if (!orgimg) { printf ("Can't load image. :%s\n", SDL_GetError ()); @@ -411,7 +412,7 @@ static void gfx_load_fieldtype_menu () { if (ft == FT_sp_trigger) { if (background != NULL) SDL_FreeSurface (background); - sprintf (filename, "%s/tileset/default/powersp.png", bman.datapath); + snprintf (filename, FNSIZE, "%s/tileset/default/powersp.png", bman.datapath); orgimg = IMG_Load (filename); if (!orgimg) { printf ("Can't load image. :%s\n", SDL_GetError ()); @@ -430,7 +431,7 @@ static void gfx_load_fieldtype_menu () { * load fieldgfx for the menu */ gfx.menu_field[ft] = gfx_copyfrom (background, NULL); - sprintf (filename, "%s/tileset/default/%s.png", bman.datapath, ft_filenames[ft]); + snprintf (filename, FNSIZE, "%s/tileset/default/%s.png", bman.datapath, ft_filenames[ft]); orgimg = IMG_Load (filename); if (!orgimg) { diff --git a/src/gfxpixelimage.c b/src/gfxpixelimage.c index 02b3426..d4d3961 100644 --- a/src/gfxpixelimage.c +++ b/src/gfxpixelimage.c @@ -310,7 +310,7 @@ makegray_image (SDL_Surface * org) fprintf (stderr, "Can't lock screen: %s\n", SDL_GetError ()); return NULL; } - if (SDL_MUSTLOCK (org)) + if (SDL_MUSTLOCK (org)) { if (SDL_LockSurface (org) < 0) { fprintf (stderr, "Can't lock screen: %s\n", SDL_GetError ()); if (SDL_MUSTLOCK (dest)) { @@ -318,7 +318,7 @@ makegray_image (SDL_Surface * org) } return NULL; } - + } switch (bpp) { case (2): for (x = 0; x < org->w; x++) diff --git a/src/keyb.c b/src/keyb.c index c0835c2..37236c3 100644 --- a/src/keyb.c +++ b/src/keyb.c @@ -179,8 +179,7 @@ void keyb_config_createkeymenu (_menu *menu, int key, int x, int y, int menu_nr) */ void keyb_config_joypad (int key) { unsigned int n = 0; - SDL_Event event; - int done = 0, eventstate = 0, reorder = 0, i, j; + int done = 0, reorder = 0, i, j; if (joy[0] == NULL || key < 0 || key >= BCK_max) return; @@ -202,8 +201,7 @@ void keyb_config_joypad (int key) { SDL_JoystickEventState ( SDL_QUERY ); // js SDL_JoystickUpdate (); - for ( j = 0; j < 2; j++) - for ( i=0; i < SDL_JoystickNumButtons ( joy[j] ); ++i ) { + for ( j = 0; j < 2; j++) for ( i=0; i < SDL_JoystickNumButtons ( joy[j] ); ++i ) { n = SDL_JoystickGetButton ( joy[j], i ); // 2 .. bomb /* Sadly every other controller enumberates different */ @@ -213,20 +211,11 @@ void keyb_config_joypad (int key) { joy_keys[j].drop = i; if (key == BCPK_special || key == BCPK_special + BCPK_max + BCPK_max) joy_keys[j].special = i; - eventstate = 1; done = 1; } } - - if (eventstate >= 1) { - switch (event.type) { - case (SDL_QUIT): - bman.state = GS_quit; - done = 1; - break; - } - } - + + s_calctimesync (); } }; diff --git a/src/map.c b/src/map.c index 706fdcf..36fdbdd 100644 --- a/src/map.c +++ b/src/map.c @@ -214,8 +214,7 @@ map_genmorerandom () if (map.size.x > MAX_FIELDSIZE_X) map.size.x = MAX_FIELDSIZE_X; - for (x = 0; x < map.size.x; x++) - for (y = 0; y < map.size.y; y++) { + for (x = 0; x < map.size.x; x++) for (y = 0; y < map.size.y; y++) { if ((y == 0) || (y == map.size.y - 1)) map.field[x][y].type = FT_block; else if ((x == 0) || (x == map.size.x - 1)) @@ -268,6 +267,10 @@ map_set_playerposition (int usermap) } /* load a random map */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-overflow" +#pragma GCC diagnostic ignored "-Wformat-truncation" +#pragma GCC diagnostic ignored "-Wstringop-overflow" void map_random () { @@ -278,7 +281,7 @@ map_random () int max, sel; - sprintf (path, "%s/maps", bman.datapath); + snprintf (path, LEN_PATHFILENAME, "%s/maps", bman.datapath); desel = destart = s_getdir (path); for (max = 0, de = destart; de != NULL; de = de->next) @@ -295,8 +298,9 @@ map_random () d_printf ("Random Map %s (%d on %d)\n", desel->name, sel, max); if (desel != NULL) - sprintf (map.map, "%s/maps/%s", bman.datapath, desel->name); + snprintf (map.map, LEN_PATHFILENAME, "%s/maps/%s", bman.datapath, desel->name); } +#pragma GCC diagnostic pop // Init the game according to options diff --git a/src/mapmenu.c b/src/mapmenu.c index ef61be3..1a3d93b 100644 --- a/src/mapmenu.c +++ b/src/mapmenu.c @@ -4,6 +4,11 @@ #include "bomberclone.h" #include "menu.h" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-overflow" +#pragma GCC diagnostic ignored "-Wformat-truncation" +#pragma GCC diagnostic ignored "-Wstringop-overflow" + /* launch the map options menu */ void mapmenu () @@ -112,18 +117,18 @@ mapmenu () menuselect = -1; break; case (2): // Select Map - sprintf (pathname, "%s/maps", bman.datapath); + snprintf (pathname, LEN_PATHFILENAME, "%s/maps", bman.datapath); mapname = menu_dir_select ("Select Map", pathname, DF_file); if (mapname == NULL) { map.map[0] = 0; map.map_selection = 2; } else - sprintf (map.map, "%s/maps/%s", bman.datapath, mapname); + snprintf (map.map, LEN_PATHFILENAME, "%s/maps/%s", bman.datapath, mapname); break; case (5): // Selected Tileset - sprintf (pathname, "%s/tileset", bman.datapath); + snprintf (pathname, LEN_PATHFILENAME, "%s/tileset", bman.datapath); mapname = menu_dir_select ("Select Tileset", pathname, DF_dir); if (mapname == NULL) { map.tileset[0] = 0; @@ -149,15 +154,11 @@ mapmenu () map.map_selection = selmt - &maptypes[0]; } map.size.x = map.size.x | 1; - if (map.size.x < MIN_FIELDSIZE_X) - map.size.x = MIN_FIELDSIZE_X; - if (map.size.x > MAX_FIELDSIZE_X) - map.size.x = MAX_FIELDSIZE_X; + if (map.size.x < MIN_FIELDSIZE_X) map.size.x = MIN_FIELDSIZE_X; + if (map.size.x > MAX_FIELDSIZE_X) map.size.x = MAX_FIELDSIZE_X; map.size.y = map.size.y | 1; - if (map.size.y < MIN_FIELDSIZE_Y) - map.size.y = MIN_FIELDSIZE_Y; - if (map.size.y > MAX_FIELDSIZE_Y) - map.size.y = MAX_FIELDSIZE_Y; + if (map.size.y < MIN_FIELDSIZE_Y) map.size.y = MIN_FIELDSIZE_Y; + if (map.size.y > MAX_FIELDSIZE_Y) map.size.y = MAX_FIELDSIZE_Y; config_write (); if (GT_MP_PTPM) net_send_servermode (); @@ -169,6 +170,7 @@ mapmenu () */ #define WIN_X 500 #define WIN_Y 350 +#define TEXTLEN 255 void mapinfo () { @@ -177,7 +179,7 @@ mapinfo () int y, eventstate, done = 0; - char text[255]; + char text[TEXTLEN]; // draw_menubox (WIN_X, WIN_Y); @@ -203,7 +205,7 @@ mapinfo () if (map.random_tileset) sprintf (text, "Random Tileset"); else - sprintf (text, "Tileset: %s", map.tileset); + snprintf (text, TEXTLEN, "Tileset: %s", map.tileset); // font_setcolor (128,128,128,0); // font_draw (2 + x - (WIN_X / 2), y, text, 0); // font_setcolor (255,255,255,0); @@ -211,7 +213,7 @@ mapinfo () /* Mapselection */ if (map.map_selection == 0) - sprintf (text, "Selected Map: %s", map.map); + snprintf (text, TEXTLEN, "Selected Map: %s", map.map); else if (map.map_selection == 1) sprintf (text, "Random Map"); else @@ -223,14 +225,14 @@ mapinfo () y = y + 2 + (font[0].size.y << 1); /* Bomb Powerups */ - sprintf (text, "Bomb Powerup: %d", map.bombs); + snprintf (text, TEXTLEN, "Bomb Powerup: %d", map.bombs); // font_setcolor (128,128,128,0); // font_draw (2 + x - (WIN_X / 2), y, text, 0); // font_setcolor (255,255,255,0); // font_draw (3 + x - (WIN_X / 2) ,1 + y, text, 0); /* Trigger */ - sprintf (text, "Trigger Specials: %d", map.sp_trigger); + snprintf (text, TEXTLEN, "Trigger Specials: %d", map.sp_trigger); // font_setcolor (128,128,128,0); // font_draw (x , y, text, 0); // font_setcolor (255,255,255,0); @@ -238,14 +240,14 @@ mapinfo () y = y + 2 + font[0].size.y; /* Fire Powerups */ - sprintf (text, "Fire Powerup: %d", map.fire); + snprintf (text, TEXTLEN, "Fire Powerup: %d", map.fire); // font_setcolor (128,128,128,0); // font_draw (2 + x - (WIN_X / 2), y, text, 0); // font_setcolor (255,255,255,0); // font_draw (3 + x - (WIN_X / 2) ,1 + y, text, 0); /* Push */ - sprintf (text, "Push Specials: %d", map.sp_push); + snprintf (text, TEXTLEN, "Push Specials: %d", map.sp_push); // font_setcolor (128,128,128,0); // font_draw (x , y, text, 0); // font_setcolor (255,255,255,0); @@ -253,14 +255,14 @@ mapinfo () y = y + 2 + font[0].size.y; /* Shoe Powerups */ - sprintf (text, "Shoe Powerup: %d", map.shoes); + snprintf (text, TEXTLEN, "Shoe Powerup: %d", map.shoes); // font_setcolor (128,128,128,0); // font_draw (2 + x - (WIN_X / 2), y, text, 0); // font_setcolor (255,255,255,0); // font_draw (3 + x - (WIN_X / 2) ,1 + y, text, 0); /* Row */ - sprintf (text, "Row Specials: %d", map.sp_row); + snprintf (text, TEXTLEN, "Row Specials: %d", map.sp_row); // font_setcolor (128,128,128,0); // font_draw (x , y, text, 0); // font_setcolor (255,255,255,0); @@ -269,7 +271,7 @@ mapinfo () /* Mixed Powerups */ - sprintf (text, "Mixed Powerup: %d", map.mixed); + snprintf (text, TEXTLEN, "Mixed Powerup: %d", map.mixed); // font_setcolor (128,128,128,0); // font_draw (2 + x - (WIN_X / 2), y, text, 0); // font_setcolor (255,255,255,0); @@ -284,7 +286,7 @@ mapinfo () y = y + 2 + font[0].size.y; /* Death Powerups */ - sprintf (text, "Death Powerup: %d", map.death); + snprintf (text, TEXTLEN, "Death Powerup: %d", map.death); // font_setcolor (128,128,128,0); // font_draw (2 + x - (WIN_X / 2), y, text, 0); // font_setcolor (255,255,255,0); @@ -323,6 +325,8 @@ mapinfo () #undef WIN_X #undef WIN_Y +#pragma GCC diagnostic pop + /* change start settings for the game */ diff --git a/src/menu.c b/src/menu.c index d493cae..d258915 100644 --- a/src/menu.c +++ b/src/menu.c @@ -219,8 +219,7 @@ menu_draw_menuitem (_menuitem * m) { _menu *menu; - if (m == NULL) - return; + if (m == NULL) return; menu = (_menu *) m->menu; diff --git a/src/netmenu.c b/src/netmenu.c index 56b134b..3893c09 100644 --- a/src/netmenu.c +++ b/src/netmenu.c @@ -164,13 +164,11 @@ void host_multiplayer_game () { bman.p_nr = bman.p_servnr = 0; team_choose (&players[0]); players[0].state = PSF_used; - if (bman.notifygamemaster) - send_ogc_update (); /* send the information that we started an server */ - + if (bman.notifygamemaster) send_ogc_update (); /* send the information that we started an server */ + multiplayer_game (); - if (bman.notifygamemaster) - send_ogc_update (); /* send the information that we started an server */ + if (bman.notifygamemaster) send_ogc_update (); /* send the information that we started an server */ network_shutdown (); }; diff --git a/src/netsrvlist.c b/src/netsrvlist.c index 5c69514..2e76fe4 100644 --- a/src/netsrvlist.c +++ b/src/netsrvlist.c @@ -10,8 +10,13 @@ #include "ogcache-client.h" #include "broadcast.h" -#define SRVLST_TIMEREBUILD 2000 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-overflow" +#pragma GCC diagnostic ignored "-Wformat-truncation" +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#define SRVLST_TIMEREBUILD 2000 +#define SRVLST_LENCOMMENT 32 _charlist srvlst_text[MAX_SRVLIST]; struct __srvlst_entry { char host[LEN_SERVERNAME]; @@ -28,11 +33,12 @@ int srvlst_cnt = 0; /* will build up our srvlst list with * all servers we have in there */ +#define TEXTLEN 255 void srvlist_rebuildlist () { int ogclst, i, j; - char txt1[255]; - char txt2[255]; - char txt3[255]; + char txt1[TEXTLEN]; + char txt2[TEXTLEN]; + char txt3[TEXTLEN]; /* delete the whole list */ for (i = 0; i < MAX_SRVLIST; i++) { @@ -60,9 +66,9 @@ void srvlist_rebuildlist () { srvlst_dat[srvlst_cnt].maxplayers = broadcast_list[i].maxplayers; srvlst_dat[srvlst_cnt].ai_family = bman.net_ai_family; if (broadcast_list[i].lan) - sprintf (srvlst_dat[srvlst_cnt].comment, "LAN"); + snprintf (srvlst_dat[srvlst_cnt].comment, SRVLST_LENCOMMENT, "LAN"); else - sprintf (srvlst_dat[srvlst_cnt].comment, "Inet"); + snprintf (srvlst_dat[srvlst_cnt].comment, SRVLST_LENCOMMENT, "Inet"); srvlst_cnt++; } } @@ -84,7 +90,7 @@ void srvlist_rebuildlist () { strncpy (srvlst_dat[srvlst_cnt].port,ogc_array[ogclst].port, LEN_PORT); strncpy (srvlst_dat[srvlst_cnt].gamename,ogc_array[ogclst].gamename, LEN_GAMENAME); strncpy (srvlst_dat[srvlst_cnt].version,ogc_array[ogclst].version, LEN_VERSION); - sprintf (srvlst_dat[srvlst_cnt].comment, "INet"); + snprintf (srvlst_dat[srvlst_cnt].comment, SRVLST_LENCOMMENT, "INet"); srvlst_cnt++; } @@ -99,15 +105,15 @@ void srvlist_rebuildlist () { if (srvlst_dat[i].ping == -2) txt2[0] = 0; else if (srvlst_dat[i].ping == -1) - sprintf (txt2, "NoCon"); + snprintf (txt2, TEXTLEN, "NoCon"); else - sprintf (txt2, "%dms", srvlst_dat[i].ping); + snprintf (txt2, TEXTLEN, "%dms", srvlst_dat[i].ping); if (srvlst_dat[i].gamename[0] != 0) /* gamename is present */ - sprintf (txt1, "%-15s %-5s %5s %-11s %-4s", srvlst_dat[i].gamename, txt3, txt2, srvlst_dat[i].version, srvlst_dat[i].comment); + snprintf (txt1, TEXTLEN, "%-15s %-5s %5s %-11s %-4s", srvlst_dat[i].gamename, txt3, txt2, srvlst_dat[i].version, srvlst_dat[i].comment); else { - sprintf (txt1, "%s:%s", srvlst_dat[i].host, srvlst_dat[i].port); - sprintf (txt1, "%-20s %5s %-11s %-4s", txt1,txt2, srvlst_dat[i].version, srvlst_dat[i].comment); + snprintf (txt3, TEXTLEN, "%s:%s", srvlst_dat[i].host, srvlst_dat[i].port); + snprintf (txt1, TEXTLEN, "%-20s %5s %-11s %-4s", txt3,txt2, srvlst_dat[i].version, srvlst_dat[i].comment); } strncpy (srvlst_text[i].text, txt1, LEN_CHARENTRY); } @@ -210,3 +216,6 @@ void net_getserver () { ogc_browsestop (); menu_delete (menu); }; + +#pragma GCC diagnostic pop + diff --git a/src/ogcache-client.c b/src/ogcache-client.c index 1bf4517..88fbbad 100644 --- a/src/ogcache-client.c +++ b/src/ogcache-client.c @@ -7,6 +7,11 @@ #include "udp.h" #include "ogcache-client.h" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-overflow" +#pragma GCC diagnostic ignored "-Wformat-truncation" +#pragma GCC diagnostic ignored "-Wstringop-overflow" + int ogc_sock = -1; struct game_entry ogc_array[MAX_OGC_ENTRYS]; char ogc_host[LEN_OGCHOST+1]; @@ -195,17 +200,20 @@ int ogc_init (char *localport, char *server, char *port, char *game, int ai_fami /* send the status of the curent game to the game cache */ int ogc_sendgamestatus (int sock, char *game, char *version, char *gamename, int curplayers, int maxplayers, char *status) { - char data[BUF_SIZE]; + char data1[BUF_SIZE]; + char data2[BUF_SIZE]; if (sock <= 0 || ogc_sock <= 0) return 0; - sprintf (data, "GAME:%s\t%s\t%s", game, version, gamename); - if (ogc_ai_family == PF_INET) - sprintf (data, "%s\tIPv4", data); - else - sprintf (data, "%s\tIPv6", data); - sprintf (data, "%s\t%d\t%d\t%s", data, curplayers, maxplayers, status); + snprintf (data1, BUF_SIZE, "GAME:%s\t%s\t%s", game, version, gamename); + if (ogc_ai_family == PF_INET) { + snprintf (data2, BUF_SIZE, "%s\tIPv4", data1); + } + else { + snprintf (data2, BUF_SIZE, "%s\tIPv6", data1); + } + snprintf (data1, BUF_SIZE, "%s\t%d\t%d\t%s", data2, curplayers, maxplayers, status); - udp_send (sock, data, strlen (data), &ogc_addr, ogc_ai_family); + udp_send (sock, data2, strlen (data2), &ogc_addr, ogc_ai_family); return 1; }; @@ -296,3 +304,5 @@ void ogc_browsestop () { udp_send (ogc_sock, data, strlen (data), &ogc_addr, ogc_ai_family); }; + +#pragma GCC diagnostic pop diff --git a/src/packets.c b/src/packets.c index b72e836..d979990 100644 --- a/src/packets.c +++ b/src/packets.c @@ -9,9 +9,6 @@ #include "sound.h" #include "menu.h" -extern _point debug_field; -extern int debug_lastping; - static short int pkg_lastid; /* the packet id, this will only counted * up nothing more.. if we are at 0x10000 * we will start at 0 */ @@ -1009,8 +1006,9 @@ void do_bombdata (struct pkg_bombdata *b_dat, _net_addr * addr) { return; } - if (b_dat->state == BS_off) + if (b_dat->state == BS_off) { return; // if there was a bomb let it explose don't delete the bomb + } d_printf ("do_bombdata [%f,%f] Player: %d PlayerIgnition: %d Bomb: %d, ex_nr:%d\n", I16TOF (NTOH16 (b_dat->x)), I16TOF (NTOH16 (b_dat->y)), b_dat->p_nr, b_dat->pi_nr, b_dat->b_nr, NTOH32 (b_dat->ex_nr)); @@ -1168,12 +1166,14 @@ do_quit (struct pkg_quit *q_dat, _net_addr * addr) d_printf ("do_quit (%s:%s) pl_nr=%d new_server=%d\n", addr->host, addr->port, q_dat->pl_nr, q_dat->new_server); - if (addr->pl_nr == -1) + if (addr->pl_nr == -1) { return; - - if (q_dat->pl_nr == -1) - q_dat->pl_nr = addr->pl_nr; + } + if (q_dat->pl_nr == -1) { + q_dat->pl_nr = addr->pl_nr; + } + bman.updatestatusbar = 1; player_delete (q_dat->pl_nr); @@ -1573,6 +1573,10 @@ send_special (_net_addr * addr, int p_nr, int typ, int ex_nr) /*** *** Packettype: mapinfo ***/ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-overflow" +#pragma GCC diagnostic ignored "-Wformat-truncation" +#pragma GCC diagnostic ignored "-Wstringop-overflow" void send_mapinfo (_net_addr * addr) { @@ -1615,6 +1619,7 @@ send_mapinfo (_net_addr * addr) printf ("Addr after send: %p\n", addr); #endif }; +#pragma GCC diagnostic pop void diff --git a/src/pkgcache.c b/src/pkgcache.c index 1b49746..b92b75f 100644 --- a/src/pkgcache.c +++ b/src/pkgcache.c @@ -74,6 +74,11 @@ int rscache_del (_net_addr *addr, unsigned char typ, short unsigned int id) { /* test for old packets where we haven't got a ackreq packet for. * If the timeout is up resend the packet again until RESENDCACHE_RETRY * has reached then delete the packet. */ + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Waddress-of-packed-member" + + void rscache_loop () { int i; int timeout; @@ -111,3 +116,4 @@ void rscache_loop () { } } }; +#pragma GCC diagnostic pop diff --git a/src/player.c b/src/player.c index 6f6c80e..d24ac66 100644 --- a/src/player.c +++ b/src/player.c @@ -43,7 +43,7 @@ draw_player (_player * player) /* if the player is ill, draw this image above him */ for (i = PI_max - 1; (i >= 0) && (player->ill[i].to <= 0.0f); i--); - if (i >= 0) { + if (i >= 0) { player->illframe += timefactor; while (player->illframe >= gfx.ill.frames) player->illframe -= gfx.ill.frames; @@ -271,8 +271,7 @@ check_field (short int x, short int y) int check_exfield (short int x, short int y) { int res = 1, i; - if (map.field[x][y].type == FT_stone || map.field[x][y].type == FT_block) - res = 0; + if (map.field[x][y].type == FT_stone || map.field[x][y].type == FT_block) res = 0; for (i = 0; (i < 4 && res == 1); i++) if (map.field[x][y].ex[i].count > 0) @@ -835,8 +834,7 @@ player_set_ilness (_player * p, int t, float new_to) void player_clear_ilness (_player * p, int type) { - if (type < 0 || type >= PI_max) - return; + if (type < 0 || type >= PI_max) return; d_printf ("player_clear_ilness Player: %s Type: %d\n", p->name, type); @@ -1026,13 +1024,10 @@ player_delete (int pl_nr) { net_game_send_delplayer (pl_nr); } - if (GT_MP_PTPM && bman.notifygamemaster) - send_ogc_update (); + if (GT_MP_PTPM && bman.notifygamemaster) send_ogc_update (); - if (bman.p_nr == pl_nr) - bman.p_nr = -1; - if (bman.p2_nr == pl_nr) - bman.p2_nr = -1; + if (bman.p_nr == pl_nr) bman.p_nr = -1; + if (bman.p2_nr == pl_nr) bman.p2_nr = -1; d_playerdetail (" Player Left ... Playerlist\n"); }; diff --git a/src/playermenu.c b/src/playermenu.c index 3007815..251d299 100644 --- a/src/playermenu.c +++ b/src/playermenu.c @@ -287,7 +287,7 @@ void playermenu () { sprintf (detail_Addr->label, "%-32s:%s",players[pl_nr].net.addr.host, players[pl_nr].net.addr.port); sprintf (detail_Flags->label, "FIX ME"); - playermenu_getflags (detail_Flags->label, &players[pl_nr]); + playermenu_getflags (detail_Flags->label, MENU_TITLELEN, &players[pl_nr]); sel_pl_nr = pl_nr; } @@ -368,16 +368,14 @@ void playermenu () { * put all flags into the givin text like: * NET_FW, NET_2P, AI... */ -void playermenu_getflags (char *text, _player *player) { +#define TXTLEN 512 +void playermenu_getflags (char *text, int txtlen, _player *player) { text[0] = 0; - if (player->net.flags & NETF_firewall) - sprintf (text, "%sNET_FW ", text); - if (player->net.flags & NETF_local2) - sprintf (text, "%sNET_2P ", text); - if (player->state & PSF_net) - sprintf (text, "%sPSF_NET ", text); - if (player->state & PSF_ai) - sprintf (text, "%sPSF_AI ", text); + + if (player->net.flags & NETF_firewall) strncat (text, "NET_FW ", txtlen); + if (player->net.flags & NETF_local2) strncat (text, "NET_2P ", txtlen); + if (player->state & PSF_net) strncat (text, "%sPSF_NET ", txtlen); + if (player->state & PSF_ai) strncat (text, "%sPSF_AI ", txtlen); }; diff --git a/src/single.c b/src/single.c index 766675b..6745312 100644 --- a/src/single.c +++ b/src/single.c @@ -570,9 +570,9 @@ single_playergame (int second_player, int ai_players) } done = 0; - for (bman.p_nr = -1, p = 0; (bman.p_nr == -1 && p < MAX_PLAYERS); p++) - if (!(PS_IS_used (players[p].state))) - bman.p_nr = p; + for (bman.p_nr = -1, p = 0; (bman.p_nr == -1 && p < MAX_PLAYERS); p++) { + if (!(PS_IS_used (players[p].state))) bman.p_nr = p; + } players[bman.p_nr].team_nr = 0; if (bman.p_nr >= MAX_PLAYERS) { diff --git a/src/tileset.c b/src/tileset.c index b732222..db4f16b 100644 --- a/src/tileset.c +++ b/src/tileset.c @@ -23,6 +23,10 @@ const char *ft_filenames[] = { "spkick" }; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-overflow" +#pragma GCC diagnostic ignored "-Wformat-truncation" +#pragma GCC diagnostic ignored "-Wstringop-overflow" /* load a random tileset */ void @@ -35,7 +39,7 @@ tileset_random () int max, sel; - sprintf (path, "%s/tileset", bman.datapath); + snprintf (path, LEN_PATHFILENAME, "%s/tileset", bman.datapath); desel = destart = s_getdir (path); for (max = 0, de = destart; de != NULL; de = de->next) @@ -106,11 +110,11 @@ tileset_load (char *tilesetname, int dx, int dy) gfx.offset.y = gfx.res.y - (gfx.block.y * map.size.y); /* load the fire */ - sprintf (fullname, "%s/tileset/%s/fire.png", bman.datapath, tileset); + snprintf (fullname, LEN_PATHFILENAME, "%s/tileset/%s/fire.png", bman.datapath, tileset); tmpimage = IMG_Load (fullname); if (tmpimage == NULL) { /* file could not be load, so load teh default tileset */ - sprintf (fullname, "%s/tileset/default/fire.png", bman.datapath); + snprintf (fullname, LEN_PATHFILENAME, "%s/tileset/default/fire.png", bman.datapath); tmpimage = IMG_Load (fullname); if (tmpimage == NULL) { printf ("default tileset could not be loaded. [%s]\n", fullname); @@ -128,7 +132,7 @@ tileset_load (char *tilesetname, int dx, int dy) SDL_FreeSurface (tmpimage1); /* load the bomb */ - sprintf (fullname, "%s/tileset/%s/bomb.png", bman.datapath, tileset); + snprintf (fullname, LEN_PATHFILENAME, "%s/tileset/%s/bomb.png", bman.datapath, tileset); tmpimage = IMG_Load (fullname); if (tmpimage == NULL) { /* file could not be load, so load teh default tileset */ @@ -163,11 +167,11 @@ tileset_load (char *tilesetname, int dx, int dy) break; } - sprintf (fullname, "%s/tileset/%s/%s", bman.datapath, tileset, filename); + snprintf (fullname, LEN_PATHFILENAME, "%s/tileset/%s/%s", bman.datapath, tileset, filename); tmpimage = IMG_Load (fullname); if (tmpimage == NULL) { /* file could not be load, so load teh default tileset */ - sprintf (fullname, "%s/tileset/default/%s", bman.datapath, filename); + snprintf (fullname, LEN_PATHFILENAME, "%s/tileset/default/%s", bman.datapath, filename); tmpimage = IMG_Load (fullname); if (tmpimage == NULL) { printf ("default tileset could not be loaded. [%s]\n", fullname); @@ -186,16 +190,16 @@ tileset_load (char *tilesetname, int dx, int dy) /* loading the field images */ for (i = 0; i < FT_max; i++) { if (i != FT_mixed) { - sprintf (fullname, "%s/tileset/%s/%s.png", bman.datapath, tileset, ft_filenames[i]); + snprintf (fullname, LEN_PATHFILENAME,"%s/tileset/%s/%s.png", bman.datapath, tileset, ft_filenames[i]); gfx.field[i].w = GFX_IMGSIZE; gfx.field[i].h = GFX_IMGSIZE; tmpimage = IMG_Load (fullname); if (tmpimage == NULL) { - sprintf (fullname, "%s/tileset/%s/%s96.png", bman.datapath, tileset, ft_filenames[i]); + snprintf (fullname, LEN_PATHFILENAME, "%s/tileset/%s/%s96.png", bman.datapath, tileset, ft_filenames[i]); gfx.field[i].h = GFX_IMGBIGSIZE; tmpimage = IMG_Load (fullname); if (tmpimage == NULL) { - sprintf (fullname, "%s/tileset/default/%s.png", bman.datapath, ft_filenames[i]); + snprintf (fullname, LEN_PATHFILENAME, "%s/tileset/default/%s.png", bman.datapath, ft_filenames[i]); gfx.field[i].h = GFX_IMGSIZE; tmpimage = IMG_Load (fullname); if (tmpimage == NULL) {