converting sprintf to snprintf, fixing compiling issues

master
Steffen Pohle 4 years ago
parent bc6404789c
commit 5387d04721

38
.gitignore vendored

@ -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

@ -174,7 +174,7 @@ extern void playerinput_keyb_read (int pk_offset, int pl_nr);
extern void playernamemenu (); extern void playernamemenu ();
extern void playermenu (); extern void playermenu ();
extern int playermenu_selgfx (int pl_nr); 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 int teammenu_select (_player *pl);
extern void teammenu (); extern void teammenu ();

@ -75,8 +75,7 @@ chat_drawbox ()
SDL_Rect src; SDL_Rect src;
int i; int i;
if (gfx_locksurface (gfx.screen)) if (gfx_locksurface (gfx.screen)) return;
return;
src = chat.window; src = chat.window;
SDL_BlitSurface (chat.oldscreen, NULL, gfx.screen, &src); SDL_BlitSurface (chat.oldscreen, NULL, gfx.screen, &src);
@ -137,8 +136,7 @@ chat_drawlines ()
if (i < 0) i = 0; if (i < 0) i = 0;
for (nr = 0; i <= chat.curline; i++, nr++) 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);
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.w = chat.window.x + chat.window.w - 4;
src.h = chat.window.y + chat.window.h - 4; src.h = chat.window.y + chat.window.h - 4;
if (chat.active) if (chat.active) draw_shadefield (gfx.screen, &src, CHAT_BG_SHADE_BRIGHT);
draw_shadefield (gfx.screen, &src, CHAT_BG_SHADE_BRIGHT); else draw_shadefield (gfx.screen, &src, CHAT_BG_SHADE_DARK);
else
draw_shadefield (gfx.screen, &src, CHAT_BG_SHADE_DARK);
gfx_blitupdaterectadd (&chat.window); gfx_blitupdaterectadd (&chat.window);
start = strlen (chat.input.text) - maxlen; 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 * 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 void
chat_loop (SDL_Event * event) chat_loop (SDL_Event * event)
{ {
@ -227,21 +228,19 @@ chat_loop (SDL_Event * event)
char text[255]; char text[255];
if (chat.active) { /* the chat mode is active */ if (chat.active) { /* the chat mode is active */
if (event != NULL) if (event != NULL) i = keybinput_loop (&chat.input, event);
i = keybinput_loop (&chat.input, event);
else { else {
i = 0; i = 0;
chat.input.changed = 1; chat.input.changed = 1;
} }
if (i == 1 && chat.input.text[0] != 0) { 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); net_send_chat (text, 1);
chat_addline (text, CHAT_TEXTCOLOR); chat_addline (text, CHAT_TEXTCOLOR);
keybinput_new (&chat.input, KEYBI_text, 255); keybinput_new (&chat.input, KEYBI_text, 255);
i = 0; i = 0;
if (!chat.keepactive) if (!chat.keepactive) chat.active = 0;
chat.active = 0;
chat.changed = 1; chat.changed = 1;
} }
} }
@ -251,12 +250,11 @@ chat_loop (SDL_Event * event)
/* /*
* check if we have to redraw the input line * check if we have to redraw the input line
*/ */
if (chat.changed) if (chat.changed) chat_draw ();
chat_draw ();
if (chat.input.changed) if (chat.input.changed) chat_drawinput ();
chat_drawinput ();
}; };
#pragma GCC diagnostic pop
/* /*

@ -14,6 +14,10 @@
#include "keyb.h" #include "keyb.h"
#include "player.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 * 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; return res;
}; };
#pragma GCC diagnostic pop

@ -33,35 +33,37 @@ void d_printf (char *fmt,...) {
va_end (args); 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) { void d_playerstat (char *head) {
int i, j; int i, j;
char text[255]; char text1[TEXTLEN];
char text2[TEXTLEN];
d_printf ("---------------> %s nb play: %d\n", head, bman.playnum); 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++) for (i = 0; i < MAX_PLAYERS; i++)
if (players[i].gamestats.isaplayer == 1) if (players[i].gamestats.isaplayer == 1)
sprintf(text, "%s %02d", text, i); snprintf(text2, TEXTLEN, "%s %02d", text1, i);
sprintf(text, "%s\n", text); strncat(text2, "\n", TEXTLEN);
d_printf (text); d_printf (text2);
for (i = 0; i < MAX_PLAYERS; i++){ for (i = 0; i < MAX_PLAYERS; i++){
if (players[i].gamestats.isaplayer == 1 ) { 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++) for (j = 0; j < MAX_PLAYERS; j++)
if (players[j].gamestats.isaplayer == 1 ) if (players[j].gamestats.isaplayer == 1 )
sprintf(text, "%s %2d", text, players[i].gamestats.killedBy[j]); sprintf(text2, "%s %2d", text1, players[i].gamestats.killedBy[j]);
sprintf(text, "%s\n", text); strncat(text2, "\n", TEXTLEN);
d_printf (text); d_printf (text2);
} }
} }
}; };
#pragma GCC diagnostic pop
// int killed[MAX_PLAYERS];
void d_playerdetail (char *head) { void d_playerdetail (char *head) {

@ -180,8 +180,7 @@ draw_stone (int x, int y)
} }
// draw explosions if there is any // draw explosions if there is any
for (d = 0; d < 4; d++) for (d = 0; d < 4; d++) if (stone->ex[d].count > 0) {
if (stone->ex[d].count > 0) {
stone_drawfire (x, y, -1); stone_drawfire (x, y, -1);
break; break;
} }
@ -504,13 +503,10 @@ field_hurrysize ()
/* check if a bomb is at this position, if so let the bomb explode /* check if a bomb is at this position, if so let the bomb explode
and wait untill the explosion is over */ and wait untill the explosion is over */
for (i = 0, d = 0; d < 4; d++) for (i = 0, d = 0; d < 4; d++) if (map.field[fieldhurrypos.x][fieldhurrypos.y].ex[d].count > 0) i++;
if (map.field[fieldhurrypos.x][fieldhurrypos.y].ex[d].count > 0)
i++;
get_bomb_on (fieldhurrypos.x, fieldhurrypos.y, bombs); get_bomb_on (fieldhurrypos.x, fieldhurrypos.y, bombs);
if (i) if (i) fieldhurrypos = old;
fieldhurrypos = old;
else if (bombs[0].y != -1 && bombs[0].x != -1) { else if (bombs[0].y != -1 && bombs[0].x != -1) {
fieldhurrypos = old; fieldhurrypos = old;
bomb_explode (&players[bombs[0].x].bombs[bombs[0].y], 1); bomb_explode (&players[bombs[0].x].bombs[bombs[0].y], 1);

@ -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 () { void font_load () {
int c,i,r,g,b; int c,i,r,g,b;
char filename[LEN_PATHFILENAME]; char filename[FNSIZE];
SDL_Surface *raw, *tmp; SDL_Surface *raw, *tmp;
/* load the font */ /* load the font */
for (i = 0; i < 3; i++) { 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); tmp = IMG_Load (filename);
if (tmp == NULL) { if (tmp == NULL) {
printf ("Could not load font.\n"); printf ("Could not load font.\n");

@ -224,13 +224,11 @@ game_loop ()
int done = 0, int done = 0,
eventstate; eventstate;
if (GT_MP) if (GT_MP) net_game_fillsockaddr ();
net_game_fillsockaddr (); if ( SDL_InitSubSystem ( SDL_INIT_JOYSTICK ) < 0 ) {
if ( SDL_InitSubSystem ( SDL_INIT_JOYSTICK ) < 0 )
{
fprintf ( stderr, "Unable to initialize Joystick: %s\n", SDL_GetError() ); 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; menu = NULL;
bman.updatestatusbar = 1; // force an update bman.updatestatusbar = 1; // force an update

@ -13,17 +13,18 @@ static void gfx_load_fieldtype_menu ();
/* /*
* count all playergfx * count all playergfx
*/ */
#define FNSIZE (LEN_PATHFILENAME+LEN_PATHFILENAME)
int gfx_get_nr_of_playergfx () { int gfx_get_nr_of_playergfx () {
int i = 0; int i = 0;
FILE *f = NULL; FILE *f = NULL;
char filename[255]; char filename[FNSIZE];
do { do {
if (f) { if (f) {
fclose (f); fclose (f);
i++; 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"); f = fopen (filename, "r");
} while (f); } while (f);
@ -51,7 +52,7 @@ gfx_load_players (int sx, int sy)
/* loading the player images */ /* loading the player images */
for (i = 0; i < gfx.player_gfx_count; i++) { 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); tmpimage = IMG_Load (filename);
if (tmpimage == NULL) { if (tmpimage == NULL) {
printf ("Can't load image: %s\n", SDL_GetError ()); printf ("Can't load image: %s\n", SDL_GetError ());
@ -78,7 +79,7 @@ gfx_load_players (int sx, int sy)
} }
/* load the death image */ /* 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); tmpimage = IMG_Load (filename);
if (tmpimage == NULL) { if (tmpimage == NULL) {
/* no image found - set field clear */ /* no image found - set field clear */
@ -95,7 +96,7 @@ gfx_load_players (int sx, int sy)
SDL_FreeSurface (tmpimage); SDL_FreeSurface (tmpimage);
/* load the illnessthing */ /* load the illnessthing */
sprintf (filename, "%s/player/playersick.png", bman.datapath); snprintf (filename, FNSIZE, "%s/player/playersick.png", bman.datapath);
tmpimage = IMG_Load (filename); tmpimage = IMG_Load (filename);
if (tmpimage == NULL) { if (tmpimage == NULL) {
printf ("Can't load image: %s\n", SDL_GetError ()); printf ("Can't load image: %s\n", SDL_GetError ());
@ -110,7 +111,7 @@ gfx_load_players (int sx, int sy)
SDL_FreeSurface (tmpimage1); SDL_FreeSurface (tmpimage1);
/* load the respawn gfx */ /* 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); tmpimage = IMG_Load (filename);
if (tmpimage == NULL) { if (tmpimage == NULL) {
printf ("Can't load image: %s\n", SDL_GetError ()); printf ("Can't load image: %s\n", SDL_GetError ());
@ -188,7 +189,7 @@ gfx_loaddata ()
*tmpimage1; *tmpimage1;
/* load the logo */ /* load the logo */
sprintf (filename, "%s/gfx/logo.png", bman.datapath); snprintf (filename, FNSIZE, "%s/gfx/logo.png", bman.datapath);
tmpimage = IMG_Load (filename); tmpimage = IMG_Load (filename);
if (tmpimage == NULL) { if (tmpimage == NULL) {
printf ("Can't load image: %s\n", SDL_GetError ()); printf ("Can't load image: %s\n", SDL_GetError ());
@ -204,7 +205,7 @@ gfx_loaddata ()
/* load the menugraphics */ /* load the menugraphics */
for (i = 0; i < 9; i++) { 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); menuimages[i] = IMG_Load (filename);
if (menuimages[i] == NULL) { if (menuimages[i] == NULL) {
printf ("Can't load image: %s\n", SDL_GetError ()); printf ("Can't load image: %s\n", SDL_GetError ());
@ -215,7 +216,7 @@ gfx_loaddata ()
/* load menu buttongraphic */ /* load menu buttongraphic */
for (j = 0; j < 3; j++) for (j = 0; j < 3; j++)
for (i = 0; i < 3; i++) { 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); tmpimage = IMG_Load (filename);
if (tmpimage == NULL) { if (tmpimage == NULL) {
printf ("Can't load image: %s\n", SDL_GetError ()); printf ("Can't load image: %s\n", SDL_GetError ());
@ -229,7 +230,7 @@ gfx_loaddata ()
/* load menu buttongraphic */ /* load menu buttongraphic */
for (j = 0; j < 2; j++) for (j = 0; j < 2; j++)
for (i = 0; i < 3; i++) { 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); tmpimage = IMG_Load (filename);
if (tmpimage == NULL) { if (tmpimage == NULL) {
printf ("Can't load image: %s\n", SDL_GetError ()); printf ("Can't load image: %s\n", SDL_GetError ());
@ -243,7 +244,7 @@ gfx_loaddata ()
/* load menu listgraphic */ /* load menu listgraphic */
for (j = 0; j < 2; j++) for (j = 0; j < 2; j++)
for (i = 0; i < 9; i++) { 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); tmpimage = IMG_Load (filename);
if (tmpimage == NULL) { if (tmpimage == NULL) {
printf ("Can't load image: %s\n", SDL_GetError ()); printf ("Can't load image: %s\n", SDL_GetError ());
@ -255,7 +256,7 @@ gfx_loaddata ()
} }
/* load menuselect animation */ /* 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); gfx.menuselect.image = IMG_Load (filename);
if (gfx.menuselect.image == NULL) { if (gfx.menuselect.image == NULL) {
printf ("Can't load image: %s\n", SDL_GetError ()); printf ("Can't load image: %s\n", SDL_GetError ());
@ -282,7 +283,7 @@ static void gfx_load_menusmall_players () {
SDL_Surface *img; SDL_Surface *img;
SDL_Rect rect; 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); orgimg = IMG_Load (filename);
if (orgimg == NULL) { if (orgimg == NULL) {
printf ("Can't load image: %s\n", SDL_GetError ()); printf ("Can't load image: %s\n", SDL_GetError ());
@ -319,7 +320,7 @@ static void gfx_load_menusmall_players () {
} }
/* load the ghost player */ /* 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); orgimg = IMG_Load (filename);
sfkt = (float)(((float)(GFX_MENUPLAYERIMGSIZE_X * 2)) / ((float)orgimg->h)); sfkt = (float)(((float)(GFX_MENUPLAYERIMGSIZE_X * 2)) / ((float)orgimg->h));
gfx.ghost = scale_image (orgimg, (int)(((float)orgimg->w)*sfkt), GFX_MENUPLAYERIMGSIZE_X * 2); 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 (ft == 0) {
if (background != NULL) SDL_FreeSurface (background); 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); orgimg = IMG_Load (filename);
if (!orgimg) { if (!orgimg) {
printf ("Can't load image. :%s\n", SDL_GetError ()); printf ("Can't load image. :%s\n", SDL_GetError ());
@ -377,7 +378,7 @@ static void gfx_load_fieldtype_menu () {
if (ft == FT_death) { if (ft == FT_death) {
if (background != NULL) SDL_FreeSurface (background); 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); orgimg = IMG_Load (filename);
if (!orgimg) { if (!orgimg) {
printf ("Can't load image. :%s\n", SDL_GetError ()); printf ("Can't load image. :%s\n", SDL_GetError ());
@ -394,7 +395,7 @@ static void gfx_load_fieldtype_menu () {
if (ft == FT_fire) { if (ft == FT_fire) {
if (background != NULL) SDL_FreeSurface (background); 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); orgimg = IMG_Load (filename);
if (!orgimg) { if (!orgimg) {
printf ("Can't load image. :%s\n", SDL_GetError ()); 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 (ft == FT_sp_trigger) {
if (background != NULL) SDL_FreeSurface (background); 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); orgimg = IMG_Load (filename);
if (!orgimg) { if (!orgimg) {
printf ("Can't load image. :%s\n", SDL_GetError ()); printf ("Can't load image. :%s\n", SDL_GetError ());
@ -430,7 +431,7 @@ static void gfx_load_fieldtype_menu () {
* load fieldgfx for the menu * load fieldgfx for the menu
*/ */
gfx.menu_field[ft] = gfx_copyfrom (background, NULL); 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); orgimg = IMG_Load (filename);
if (!orgimg) { if (!orgimg) {

@ -310,7 +310,7 @@ makegray_image (SDL_Surface * org)
fprintf (stderr, "Can't lock screen: %s\n", SDL_GetError ()); fprintf (stderr, "Can't lock screen: %s\n", SDL_GetError ());
return NULL; return NULL;
} }
if (SDL_MUSTLOCK (org)) if (SDL_MUSTLOCK (org)) {
if (SDL_LockSurface (org) < 0) { if (SDL_LockSurface (org) < 0) {
fprintf (stderr, "Can't lock screen: %s\n", SDL_GetError ()); fprintf (stderr, "Can't lock screen: %s\n", SDL_GetError ());
if (SDL_MUSTLOCK (dest)) { if (SDL_MUSTLOCK (dest)) {
@ -318,7 +318,7 @@ makegray_image (SDL_Surface * org)
} }
return NULL; return NULL;
} }
}
switch (bpp) { switch (bpp) {
case (2): case (2):
for (x = 0; x < org->w; x++) for (x = 0; x < org->w; x++)

@ -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) { void keyb_config_joypad (int key) {
unsigned int n = 0; unsigned int n = 0;
SDL_Event event; int done = 0, reorder = 0, i, j;
int done = 0, eventstate = 0, reorder = 0, i, j;
if (joy[0] == NULL || key < 0 || key >= BCK_max) return; 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_JoystickEventState ( SDL_QUERY ); // js
SDL_JoystickUpdate (); SDL_JoystickUpdate ();
for ( j = 0; j < 2; j++) for ( j = 0; j < 2; j++) for ( i=0; i < SDL_JoystickNumButtons ( joy[j] ); ++i ) {
for ( i=0; i < SDL_JoystickNumButtons ( joy[j] ); ++i ) {
n = SDL_JoystickGetButton ( joy[j], i ); n = SDL_JoystickGetButton ( joy[j], i );
// 2 .. bomb // 2 .. bomb
/* Sadly every other controller enumberates different */ /* Sadly every other controller enumberates different */
@ -213,19 +211,10 @@ void keyb_config_joypad (int key) {
joy_keys[j].drop = i; joy_keys[j].drop = i;
if (key == BCPK_special || key == BCPK_special + BCPK_max + BCPK_max) if (key == BCPK_special || key == BCPK_special + BCPK_max + BCPK_max)
joy_keys[j].special = i; joy_keys[j].special = i;
eventstate = 1;
done = 1; done = 1;
} }
} }
if (eventstate >= 1) {
switch (event.type) {
case (SDL_QUIT):
bman.state = GS_quit;
done = 1;
break;
}
}
s_calctimesync (); s_calctimesync ();
} }

@ -214,8 +214,7 @@ map_genmorerandom ()
if (map.size.x > MAX_FIELDSIZE_X) if (map.size.x > MAX_FIELDSIZE_X)
map.size.x = MAX_FIELDSIZE_X; map.size.x = MAX_FIELDSIZE_X;
for (x = 0; x < map.size.x; x++) for (x = 0; x < map.size.x; x++) for (y = 0; y < map.size.y; y++) {
for (y = 0; y < map.size.y; y++) {
if ((y == 0) || (y == map.size.y - 1)) if ((y == 0) || (y == map.size.y - 1))
map.field[x][y].type = FT_block; map.field[x][y].type = FT_block;
else if ((x == 0) || (x == map.size.x - 1)) else if ((x == 0) || (x == map.size.x - 1))
@ -268,6 +267,10 @@ map_set_playerposition (int usermap)
} }
/* load a random map */ /* 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 void
map_random () map_random ()
{ {
@ -278,7 +281,7 @@ map_random ()
int max, int max,
sel; sel;
sprintf (path, "%s/maps", bman.datapath); snprintf (path, LEN_PATHFILENAME, "%s/maps", bman.datapath);
desel = destart = s_getdir (path); desel = destart = s_getdir (path);
for (max = 0, de = destart; de != NULL; de = de->next) 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); d_printf ("Random Map %s (%d on %d)\n", desel->name, sel, max);
if (desel != NULL) 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 // Init the game according to options

@ -4,6 +4,11 @@
#include "bomberclone.h" #include "bomberclone.h"
#include "menu.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 */ /* launch the map options menu */
void void
mapmenu () mapmenu ()
@ -112,18 +117,18 @@ mapmenu ()
menuselect = -1; menuselect = -1;
break; break;
case (2): // Select Map 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); mapname = menu_dir_select ("Select Map", pathname, DF_file);
if (mapname == NULL) { if (mapname == NULL) {
map.map[0] = 0; map.map[0] = 0;
map.map_selection = 2; map.map_selection = 2;
} }
else else
sprintf (map.map, "%s/maps/%s", bman.datapath, mapname); snprintf (map.map, LEN_PATHFILENAME, "%s/maps/%s", bman.datapath, mapname);
break; break;
case (5): // Selected Tileset 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); mapname = menu_dir_select ("Select Tileset", pathname, DF_dir);
if (mapname == NULL) { if (mapname == NULL) {
map.tileset[0] = 0; map.tileset[0] = 0;
@ -149,15 +154,11 @@ mapmenu ()
map.map_selection = selmt - &maptypes[0]; map.map_selection = selmt - &maptypes[0];
} }
map.size.x = map.size.x | 1; map.size.x = map.size.x | 1;
if (map.size.x < MIN_FIELDSIZE_X) if (map.size.x < MIN_FIELDSIZE_X) 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 > MAX_FIELDSIZE_X)
map.size.x = MAX_FIELDSIZE_X;
map.size.y = map.size.y | 1; map.size.y = map.size.y | 1;
if (map.size.y < MIN_FIELDSIZE_Y) if (map.size.y < MIN_FIELDSIZE_Y) 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 > MAX_FIELDSIZE_Y)
map.size.y = MAX_FIELDSIZE_Y;
config_write (); config_write ();
if (GT_MP_PTPM) net_send_servermode (); if (GT_MP_PTPM) net_send_servermode ();
@ -169,6 +170,7 @@ mapmenu ()
*/ */
#define WIN_X 500 #define WIN_X 500
#define WIN_Y 350 #define WIN_Y 350
#define TEXTLEN 255
void void
mapinfo () mapinfo ()
{ {
@ -177,7 +179,7 @@ mapinfo ()
int y, int y,
eventstate, eventstate,
done = 0; done = 0;
char text[255]; char text[TEXTLEN];
// draw_menubox (WIN_X, WIN_Y); // draw_menubox (WIN_X, WIN_Y);
@ -203,7 +205,7 @@ mapinfo ()
if (map.random_tileset) if (map.random_tileset)
sprintf (text, "Random Tileset"); sprintf (text, "Random Tileset");
else else
sprintf (text, "Tileset: %s", map.tileset); snprintf (text, TEXTLEN, "Tileset: %s", map.tileset);
// font_setcolor (128,128,128,0); // font_setcolor (128,128,128,0);
// font_draw (2 + x - (WIN_X / 2), y, text, 0); // font_draw (2 + x - (WIN_X / 2), y, text, 0);
// font_setcolor (255,255,255,0); // font_setcolor (255,255,255,0);
@ -211,7 +213,7 @@ mapinfo ()
/* Mapselection */ /* Mapselection */
if (map.map_selection == 0) 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) else if (map.map_selection == 1)
sprintf (text, "Random Map"); sprintf (text, "Random Map");
else else
@ -223,14 +225,14 @@ mapinfo ()
y = y + 2 + (font[0].size.y << 1); y = y + 2 + (font[0].size.y << 1);
/* Bomb Powerups */ /* Bomb Powerups */
sprintf (text, "Bomb Powerup: %d", map.bombs); snprintf (text, TEXTLEN, "Bomb Powerup: %d", map.bombs);
// font_setcolor (128,128,128,0); // font_setcolor (128,128,128,0);
// font_draw (2 + x - (WIN_X / 2), y, text, 0); // font_draw (2 + x - (WIN_X / 2), y, text, 0);
// font_setcolor (255,255,255,0); // font_setcolor (255,255,255,0);
// font_draw (3 + x - (WIN_X / 2) ,1 + y, text, 0); // font_draw (3 + x - (WIN_X / 2) ,1 + y, text, 0);
/* Trigger */ /* 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_setcolor (128,128,128,0);
// font_draw (x , y, text, 0); // font_draw (x , y, text, 0);
// font_setcolor (255,255,255,0); // font_setcolor (255,255,255,0);
@ -238,14 +240,14 @@ mapinfo ()
y = y + 2 + font[0].size.y; y = y + 2 + font[0].size.y;
/* Fire Powerups */ /* Fire Powerups */
sprintf (text, "Fire Powerup: %d", map.fire); snprintf (text, TEXTLEN, "Fire Powerup: %d", map.fire);
// font_setcolor (128,128,128,0); // font_setcolor (128,128,128,0);
// font_draw (2 + x - (WIN_X / 2), y, text, 0); // font_draw (2 + x - (WIN_X / 2), y, text, 0);
// font_setcolor (255,255,255,0); // font_setcolor (255,255,255,0);
// font_draw (3 + x - (WIN_X / 2) ,1 + y, text, 0); // font_draw (3 + x - (WIN_X / 2) ,1 + y, text, 0);
/* Push */ /* 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_setcolor (128,128,128,0);
// font_draw (x , y, text, 0); // font_draw (x , y, text, 0);
// font_setcolor (255,255,255,0); // font_setcolor (255,255,255,0);
@ -253,14 +255,14 @@ mapinfo ()
y = y + 2 + font[0].size.y; y = y + 2 + font[0].size.y;
/* Shoe Powerups */ /* Shoe Powerups */
sprintf (text, "Shoe Powerup: %d", map.shoes); snprintf (text, TEXTLEN, "Shoe Powerup: %d", map.shoes);
// font_setcolor (128,128,128,0); // font_setcolor (128,128,128,0);
// font_draw (2 + x - (WIN_X / 2), y, text, 0); // font_draw (2 + x - (WIN_X / 2), y, text, 0);
// font_setcolor (255,255,255,0); // font_setcolor (255,255,255,0);
// font_draw (3 + x - (WIN_X / 2) ,1 + y, text, 0); // font_draw (3 + x - (WIN_X / 2) ,1 + y, text, 0);
/* Row */ /* 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_setcolor (128,128,128,0);
// font_draw (x , y, text, 0); // font_draw (x , y, text, 0);
// font_setcolor (255,255,255,0); // font_setcolor (255,255,255,0);
@ -269,7 +271,7 @@ mapinfo ()
/* Mixed Powerups */ /* Mixed Powerups */
sprintf (text, "Mixed Powerup: %d", map.mixed); snprintf (text, TEXTLEN, "Mixed Powerup: %d", map.mixed);
// font_setcolor (128,128,128,0); // font_setcolor (128,128,128,0);
// font_draw (2 + x - (WIN_X / 2), y, text, 0); // font_draw (2 + x - (WIN_X / 2), y, text, 0);
// font_setcolor (255,255,255,0); // font_setcolor (255,255,255,0);
@ -284,7 +286,7 @@ mapinfo ()
y = y + 2 + font[0].size.y; y = y + 2 + font[0].size.y;
/* Death Powerups */ /* Death Powerups */
sprintf (text, "Death Powerup: %d", map.death); snprintf (text, TEXTLEN, "Death Powerup: %d", map.death);
// font_setcolor (128,128,128,0); // font_setcolor (128,128,128,0);
// font_draw (2 + x - (WIN_X / 2), y, text, 0); // font_draw (2 + x - (WIN_X / 2), y, text, 0);
// font_setcolor (255,255,255,0); // font_setcolor (255,255,255,0);
@ -323,6 +325,8 @@ mapinfo ()
#undef WIN_X #undef WIN_X
#undef WIN_Y #undef WIN_Y
#pragma GCC diagnostic pop
/* change start settings for the game */ /* change start settings for the game */

@ -219,8 +219,7 @@ menu_draw_menuitem (_menuitem * m)
{ {
_menu *menu; _menu *menu;
if (m == NULL) if (m == NULL) return;
return;
menu = (_menu *) m->menu; menu = (_menu *) m->menu;

@ -164,13 +164,11 @@ void host_multiplayer_game () {
bman.p_nr = bman.p_servnr = 0; bman.p_nr = bman.p_servnr = 0;
team_choose (&players[0]); team_choose (&players[0]);
players[0].state = PSF_used; players[0].state = PSF_used;
if (bman.notifygamemaster) if (bman.notifygamemaster) send_ogc_update (); /* send the information that we started an server */
send_ogc_update (); /* send the information that we started an server */
multiplayer_game (); multiplayer_game ();
if (bman.notifygamemaster) if (bman.notifygamemaster) send_ogc_update (); /* send the information that we started an server */
send_ogc_update (); /* send the information that we started an server */
network_shutdown (); network_shutdown ();
}; };

@ -10,8 +10,13 @@
#include "ogcache-client.h" #include "ogcache-client.h"
#include "broadcast.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]; _charlist srvlst_text[MAX_SRVLIST];
struct __srvlst_entry { struct __srvlst_entry {
char host[LEN_SERVERNAME]; char host[LEN_SERVERNAME];
@ -28,11 +33,12 @@ int srvlst_cnt = 0;
/* will build up our srvlst list with /* will build up our srvlst list with
* all servers we have in there */ * all servers we have in there */
#define TEXTLEN 255
void srvlist_rebuildlist () { void srvlist_rebuildlist () {
int ogclst, i, j; int ogclst, i, j;
char txt1[255]; char txt1[TEXTLEN];
char txt2[255]; char txt2[TEXTLEN];
char txt3[255]; char txt3[TEXTLEN];
/* delete the whole list */ /* delete the whole list */
for (i = 0; i < MAX_SRVLIST; i++) { 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].maxplayers = broadcast_list[i].maxplayers;
srvlst_dat[srvlst_cnt].ai_family = bman.net_ai_family; srvlst_dat[srvlst_cnt].ai_family = bman.net_ai_family;
if (broadcast_list[i].lan) if (broadcast_list[i].lan)
sprintf (srvlst_dat[srvlst_cnt].comment, "LAN"); snprintf (srvlst_dat[srvlst_cnt].comment, SRVLST_LENCOMMENT, "LAN");
else else
sprintf (srvlst_dat[srvlst_cnt].comment, "Inet"); snprintf (srvlst_dat[srvlst_cnt].comment, SRVLST_LENCOMMENT, "Inet");
srvlst_cnt++; 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].port,ogc_array[ogclst].port, LEN_PORT);
strncpy (srvlst_dat[srvlst_cnt].gamename,ogc_array[ogclst].gamename, LEN_GAMENAME); strncpy (srvlst_dat[srvlst_cnt].gamename,ogc_array[ogclst].gamename, LEN_GAMENAME);
strncpy (srvlst_dat[srvlst_cnt].version,ogc_array[ogclst].version, LEN_VERSION); 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++; srvlst_cnt++;
} }
@ -99,15 +105,15 @@ void srvlist_rebuildlist () {
if (srvlst_dat[i].ping == -2) if (srvlst_dat[i].ping == -2)
txt2[0] = 0; txt2[0] = 0;
else if (srvlst_dat[i].ping == -1) else if (srvlst_dat[i].ping == -1)
sprintf (txt2, "NoCon"); snprintf (txt2, TEXTLEN, "NoCon");
else 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 */ 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 { else {
sprintf (txt1, "%s:%s", srvlst_dat[i].host, srvlst_dat[i].port); snprintf (txt3, TEXTLEN, "%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 (txt1, TEXTLEN, "%-20s %5s %-11s %-4s", txt3,txt2, srvlst_dat[i].version, srvlst_dat[i].comment);
} }
strncpy (srvlst_text[i].text, txt1, LEN_CHARENTRY); strncpy (srvlst_text[i].text, txt1, LEN_CHARENTRY);
} }
@ -210,3 +216,6 @@ void net_getserver () {
ogc_browsestop (); ogc_browsestop ();
menu_delete (menu); menu_delete (menu);
}; };
#pragma GCC diagnostic pop

@ -7,6 +7,11 @@
#include "udp.h" #include "udp.h"
#include "ogcache-client.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; int ogc_sock = -1;
struct game_entry ogc_array[MAX_OGC_ENTRYS]; struct game_entry ogc_array[MAX_OGC_ENTRYS];
char ogc_host[LEN_OGCHOST+1]; 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 */ /* send the status of the curent game to the game cache */
int ogc_sendgamestatus (int sock, char *game, char *version, char *gamename, int ogc_sendgamestatus (int sock, char *game, char *version, char *gamename,
int curplayers, int maxplayers, char *status) { 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; if (sock <= 0 || ogc_sock <= 0) return 0;
sprintf (data, "GAME:%s\t%s\t%s", game, version, gamename); snprintf (data1, BUF_SIZE, "GAME:%s\t%s\t%s", game, version, gamename);
if (ogc_ai_family == PF_INET) if (ogc_ai_family == PF_INET) {
sprintf (data, "%s\tIPv4", data); snprintf (data2, BUF_SIZE, "%s\tIPv4", data1);
else }
sprintf (data, "%s\tIPv6", data); else {
sprintf (data, "%s\t%d\t%d\t%s", data, curplayers, maxplayers, status); 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; return 1;
}; };
@ -296,3 +304,5 @@ void ogc_browsestop () {
udp_send (ogc_sock, data, strlen (data), &ogc_addr, ogc_ai_family); udp_send (ogc_sock, data, strlen (data), &ogc_addr, ogc_ai_family);
}; };
#pragma GCC diagnostic pop

@ -9,9 +9,6 @@
#include "sound.h" #include "sound.h"
#include "menu.h" #include "menu.h"
extern _point debug_field;
extern int debug_lastping;
static short int pkg_lastid; /* the packet id, this will only counted static short int pkg_lastid; /* the packet id, this will only counted
* up nothing more.. if we are at 0x10000 * up nothing more.. if we are at 0x10000
* we will start at 0 */ * we will start at 0 */
@ -1009,8 +1006,9 @@ void do_bombdata (struct pkg_bombdata *b_dat, _net_addr * addr) {
return; 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 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", 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)); 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,11 +1166,13 @@ 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, 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); q_dat->new_server);
if (addr->pl_nr == -1) if (addr->pl_nr == -1) {
return; return;
}
if (q_dat->pl_nr == -1) if (q_dat->pl_nr == -1) {
q_dat->pl_nr = addr->pl_nr; q_dat->pl_nr = addr->pl_nr;
}
bman.updatestatusbar = 1; bman.updatestatusbar = 1;
player_delete (q_dat->pl_nr); 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 *** 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 void
send_mapinfo (_net_addr * addr) send_mapinfo (_net_addr * addr)
{ {
@ -1615,6 +1619,7 @@ send_mapinfo (_net_addr * addr)
printf ("Addr after send: %p\n", addr); printf ("Addr after send: %p\n", addr);
#endif #endif
}; };
#pragma GCC diagnostic pop
void void

@ -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. /* 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 * If the timeout is up resend the packet again until RESENDCACHE_RETRY
* has reached then delete the packet. */ * has reached then delete the packet. */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
void rscache_loop () { void rscache_loop () {
int i; int i;
int timeout; int timeout;
@ -111,3 +116,4 @@ void rscache_loop () {
} }
} }
}; };
#pragma GCC diagnostic pop

@ -43,7 +43,7 @@ draw_player (_player * player)
/* if the player is ill, draw this image above him */ /* if the player is ill, draw this image above him */
for (i = PI_max - 1; (i >= 0) && (player->ill[i].to <= 0.0f); i--); for (i = PI_max - 1; (i >= 0) && (player->ill[i].to <= 0.0f); i--);
if (i >= 0) { if (i >= 0) {
player->illframe += timefactor; player->illframe += timefactor;
while (player->illframe >= gfx.ill.frames) while (player->illframe >= gfx.ill.frames)
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 check_exfield (short int x, short int y) {
int res = 1, i; int res = 1, i;
if (map.field[x][y].type == FT_stone || map.field[x][y].type == FT_block) if (map.field[x][y].type == FT_stone || map.field[x][y].type == FT_block) res = 0;
res = 0;
for (i = 0; (i < 4 && res == 1); i++) for (i = 0; (i < 4 && res == 1); i++)
if (map.field[x][y].ex[i].count > 0) if (map.field[x][y].ex[i].count > 0)
@ -835,8 +834,7 @@ player_set_ilness (_player * p, int t, float new_to)
void void
player_clear_ilness (_player * p, int type) player_clear_ilness (_player * p, int type)
{ {
if (type < 0 || type >= PI_max) if (type < 0 || type >= PI_max) return;
return;
d_printf ("player_clear_ilness Player: %s Type: %d\n", p->name, type); 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); net_game_send_delplayer (pl_nr);
} }
if (GT_MP_PTPM && bman.notifygamemaster) if (GT_MP_PTPM && bman.notifygamemaster) send_ogc_update ();
send_ogc_update ();
if (bman.p_nr == pl_nr) if (bman.p_nr == pl_nr) bman.p_nr = -1;
bman.p_nr = -1; if (bman.p2_nr == pl_nr) bman.p2_nr = -1;
if (bman.p2_nr == pl_nr)
bman.p2_nr = -1;
d_playerdetail (" Player Left ... Playerlist\n"); d_playerdetail (" Player Left ... Playerlist\n");
}; };

@ -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_Addr->label, "%-32s:%s",players[pl_nr].net.addr.host, players[pl_nr].net.addr.port);
sprintf (detail_Flags->label, "FIX ME"); 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; sel_pl_nr = pl_nr;
} }
@ -368,16 +368,14 @@ void playermenu () {
* put all flags into the givin text like: * put all flags into the givin text like:
* NET_FW, NET_2P, AI... * 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; text[0] = 0;
if (player->net.flags & NETF_firewall)
sprintf (text, "%sNET_FW ", text); if (player->net.flags & NETF_firewall) strncat (text, "NET_FW ", txtlen);
if (player->net.flags & NETF_local2) if (player->net.flags & NETF_local2) strncat (text, "NET_2P ", txtlen);
sprintf (text, "%sNET_2P ", text); if (player->state & PSF_net) strncat (text, "%sPSF_NET ", txtlen);
if (player->state & PSF_net) if (player->state & PSF_ai) strncat (text, "%sPSF_AI ", txtlen);
sprintf (text, "%sPSF_NET ", text);
if (player->state & PSF_ai)
sprintf (text, "%sPSF_AI ", text);
}; };

@ -570,9 +570,9 @@ single_playergame (int second_player, int ai_players)
} }
done = 0; done = 0;
for (bman.p_nr = -1, p = 0; (bman.p_nr == -1 && p < MAX_PLAYERS); p++) for (bman.p_nr = -1, p = 0; (bman.p_nr == -1 && p < MAX_PLAYERS); p++) {
if (!(PS_IS_used (players[p].state))) if (!(PS_IS_used (players[p].state))) bman.p_nr = p;
bman.p_nr = p; }
players[bman.p_nr].team_nr = 0; players[bman.p_nr].team_nr = 0;
if (bman.p_nr >= MAX_PLAYERS) { if (bman.p_nr >= MAX_PLAYERS) {

@ -23,6 +23,10 @@ const char *ft_filenames[] = {
"spkick" "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 */ /* load a random tileset */
void void
@ -35,7 +39,7 @@ tileset_random ()
int max, int max,
sel; sel;
sprintf (path, "%s/tileset", bman.datapath); snprintf (path, LEN_PATHFILENAME, "%s/tileset", bman.datapath);
desel = destart = s_getdir (path); desel = destart = s_getdir (path);
for (max = 0, de = destart; de != NULL; de = de->next) 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); gfx.offset.y = gfx.res.y - (gfx.block.y * map.size.y);
/* load the fire */ /* 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); tmpimage = IMG_Load (fullname);
if (tmpimage == NULL) { if (tmpimage == NULL) {
/* file could not be load, so load teh default tileset */ /* 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); tmpimage = IMG_Load (fullname);
if (tmpimage == NULL) { if (tmpimage == NULL) {
printf ("default tileset could not be loaded. [%s]\n", fullname); 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); SDL_FreeSurface (tmpimage1);
/* load the bomb */ /* 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); tmpimage = IMG_Load (fullname);
if (tmpimage == NULL) { if (tmpimage == NULL) {
/* file could not be load, so load teh default tileset */ /* file could not be load, so load teh default tileset */
@ -163,11 +167,11 @@ tileset_load (char *tilesetname, int dx, int dy)
break; 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); tmpimage = IMG_Load (fullname);
if (tmpimage == NULL) { if (tmpimage == NULL) {
/* file could not be load, so load teh default tileset */ /* 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); tmpimage = IMG_Load (fullname);
if (tmpimage == NULL) { if (tmpimage == NULL) {
printf ("default tileset could not be loaded. [%s]\n", fullname); 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 */ /* loading the field images */
for (i = 0; i < FT_max; i++) { for (i = 0; i < FT_max; i++) {
if (i != FT_mixed) { 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].w = GFX_IMGSIZE;
gfx.field[i].h = GFX_IMGSIZE; gfx.field[i].h = GFX_IMGSIZE;
tmpimage = IMG_Load (fullname); tmpimage = IMG_Load (fullname);
if (tmpimage == NULL) { 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; gfx.field[i].h = GFX_IMGBIGSIZE;
tmpimage = IMG_Load (fullname); tmpimage = IMG_Load (fullname);
if (tmpimage == NULL) { 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; gfx.field[i].h = GFX_IMGSIZE;
tmpimage = IMG_Load (fullname); tmpimage = IMG_Load (fullname);
if (tmpimage == NULL) { if (tmpimage == NULL) {

Loading…
Cancel
Save