diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/doom/am_map.c | 3 | ||||
-rw-r--r-- | src/doom/d_main.c | 5 | ||||
-rw-r--r-- | src/doom/g_game.c | 42 | ||||
-rw-r--r-- | src/doom/hu_stuff.c | 2 | ||||
-rw-r--r-- | src/doom/m_menu.c | 7 | ||||
-rw-r--r-- | src/doom/p_saveg.c | 16 | ||||
-rw-r--r-- | src/doom/s_sound.c | 2 | ||||
-rw-r--r-- | src/doom/st_stuff.c | 12 |
8 files changed, 47 insertions, 42 deletions
diff --git a/src/doom/am_map.c b/src/doom/am_map.c index 31f42df9..b7bfd3bd 100644 --- a/src/doom/am_map.c +++ b/src/doom/am_map.c @@ -689,7 +689,8 @@ AM_Responder } else if (key == key_map_mark) { - sprintf(buffer, "%s %d", DEH_String(AMSTR_MARKEDSPOT), markpointnum); + snprintf(buffer, sizeof(buffer), "%s %d", + DEH_String(AMSTR_MARKEDSPOT), markpointnum); plr->message = buffer; AM_addMark(); } diff --git a/src/doom/d_main.c b/src/doom/d_main.c index 6d37e455..0cdb83d4 100644 --- a/src/doom/d_main.c +++ b/src/doom/d_main.c @@ -384,7 +384,7 @@ void D_BindVariables(void) { char buf[12]; - sprintf(buf, "chatmacro%i", i); + snprintf(buf, sizeof(buf), "chatmacro%i", i); M_BindVariable(buf, &chat_macros[i]); } } @@ -669,7 +669,8 @@ static char *GetGameName(char *gamename) gamename_size = strlen(deh_sub) + 10; gamename = Z_Malloc(gamename_size, PU_STATIC, 0); version = G_VanillaVersionCode(); - sprintf(gamename, deh_sub, version / 100, version % 100); + snprintf(gamename, gamename_size, deh_sub, + version / 100, version % 100); while (gamename[0] != '\0' && isspace(gamename[0])) { diff --git a/src/doom/g_game.c b/src/doom/g_game.c index c6b71e01..034bb3ef 100644 --- a/src/doom/g_game.c +++ b/src/doom/g_game.c @@ -909,17 +909,18 @@ void G_Ticker (void) turbodetected[i] = true; } - if ((gametic & 31) == 0 + if ((gametic & 31) == 0 && ((gametic >> 5) % MAXPLAYERS) == i && turbodetected[i]) - { - static char turbomessage[80]; - extern char *player_names[4]; - sprintf (turbomessage, "%s is turbo!",player_names[i]); - players[consoleplayer].message = turbomessage; + { + static char turbomessage[80]; + extern char *player_names[4]; + snprintf(turbomessage, sizeof(turbomessage), + "%s is turbo!", player_names[i]); + players[consoleplayer].message = turbomessage; turbodetected[i] = false; - } - + } + if (netgame && !netdemo && !(gametic%ticdup) ) { if (gametic > BACKUPTICS @@ -1937,16 +1938,18 @@ void G_WriteDemoTiccmd (ticcmd_t* cmd) // -// G_RecordDemo -// -void G_RecordDemo (char *name) -{ - int i; - int maxsize; - - usergame = false; - demoname = Z_Malloc(strlen(name) + 5, PU_STATIC, NULL); - sprintf(demoname, "%s.lmp", name); +// G_RecordDemo +// +void G_RecordDemo (char *name) +{ + size_t demoname_size; + int i; + int maxsize; + + usergame = false; + demoname_size = strlen(name) + 5; + demoname = Z_Malloc(demoname_size, PU_STATIC, NULL); + snprintf(demoname, demoname_size, "%s.lmp", name); maxsize = 0x20000; //! @@ -2073,7 +2076,8 @@ static char *DemoVersionDescription(int version) } else { - sprintf(resultbuf, "%i.%i (unknown)", version / 100, version % 100); + snprintf(resultbuf, sizeof(resultbuf), + "%i.%i (unknown)", version / 100, version % 100); return resultbuf; } } diff --git a/src/doom/hu_stuff.c b/src/doom/hu_stuff.c index 1dda6e8a..8ea3912e 100644 --- a/src/doom/hu_stuff.c +++ b/src/doom/hu_stuff.c @@ -627,7 +627,7 @@ boolean HU_Responder(event_t *ev) // static unsigned char buf[20]; // DEBUG HU_queueChatChar(c); - // sprintf(buf, "KEY: %d => %d", ev->data1, c); + // snprintf(buf, sizeof(buf), "KEY: %d => %d", ev->data1, c); // plr->message = buf; } if (c == KEY_ENTER) diff --git a/src/doom/m_menu.c b/src/doom/m_menu.c index 1fde34ba..a0581579 100644 --- a/src/doom/m_menu.c +++ b/src/doom/m_menu.c @@ -1192,10 +1192,9 @@ static char *M_SelectEndMessage(void) void M_QuitDOOM(int choice) { - sprintf(endstring, - DEH_String("%s\n\n" DOSY), - DEH_String(M_SelectEndMessage())); - + DEH_snprintf(endstring, sizeof(endstring), "%s\n\n" DOSY, + DEH_String(M_SelectEndMessage())); + M_StartMessage(endstring,M_QuitResponse,true); } diff --git a/src/doom/p_saveg.c b/src/doom/p_saveg.c index 7dd386a3..5fa70fea 100644 --- a/src/doom/p_saveg.c +++ b/src/doom/p_saveg.c @@ -38,6 +38,7 @@ // State. #include "doomstat.h" #include "g_game.h" +#include "m_misc.h" #include "r_state.h" #define SAVEGAME_EOF 0x1d @@ -57,11 +58,9 @@ char *P_TempSaveGameFile(void) if (filename == NULL) { - filename = malloc(strlen(savegamedir) + 32); + filename = M_StringJoin(savegamedir, "temp.dsg", NULL); } - sprintf(filename, "%stemp.dsg", savegamedir); - return filename; } @@ -70,16 +69,17 @@ char *P_TempSaveGameFile(void) char *P_SaveGameFile(int slot) { static char *filename = NULL; + static size_t filename_size = 0; char basename[32]; if (filename == NULL) { - filename = malloc(strlen(savegamedir) + 32); + filename_size = strlen(savegamedir) + 32; + filename = malloc(filename_size); } DEH_snprintf(basename, 32, SAVEGAMENAME "%d.dsg", slot); - - sprintf(filename, "%s%s", savegamedir, basename); + snprintf(filename, filename_size, "%s%s", savegamedir, basename); return filename; } @@ -1363,7 +1363,7 @@ void P_WriteSaveGameHeader(char *description) saveg_write8(0); memset(name, 0, sizeof(name)); - sprintf(name, "version %i", G_VanillaVersionCode()); + snprintf(name, sizeof(name), "version %i", G_VanillaVersionCode()); for (i=0; i<VERSIONSIZE; ++i) saveg_write8(name[i]); @@ -1400,7 +1400,7 @@ boolean P_ReadSaveGameHeader(void) read_vcheck[i] = saveg_read8(); memset(vcheck, 0, sizeof(vcheck)); - sprintf(vcheck, "version %i", G_VanillaVersionCode()); + snprintf(vcheck, sizeof(vcheck), "version %i", G_VanillaVersionCode()); if (strcmp(read_vcheck, vcheck) != 0) return false; // bad version diff --git a/src/doom/s_sound.c b/src/doom/s_sound.c index 7b000e94..4e81b016 100644 --- a/src/doom/s_sound.c +++ b/src/doom/s_sound.c @@ -638,7 +638,7 @@ void S_ChangeMusic(int musicnum, int looping) // get lumpnum if neccessary if (!music->lumpnum) { - sprintf(namebuf, "d_%s", DEH_String(music->name)); + snprintf(namebuf, sizeof(namebuf), "d_%s", DEH_String(music->name)); music->lumpnum = W_GetNumForName(namebuf); } diff --git a/src/doom/st_stuff.c b/src/doom/st_stuff.c index df8592a4..b9d9aefd 100644 --- a/src/doom/st_stuff.c +++ b/src/doom/st_stuff.c @@ -597,12 +597,12 @@ ST_Responder (event_t* ev) // 'mypos' for player position else if (cht_CheckCheat(&cheat_mypos, ev->data2)) { - static char buf[ST_MSGWIDTH]; - sprintf(buf, "ang=0x%x;x,y=(0x%x,0x%x)", - players[consoleplayer].mo->angle, - players[consoleplayer].mo->x, - players[consoleplayer].mo->y); - plyr->message = buf; + static char buf[ST_MSGWIDTH]; + snprintf(buf, sizeof(buf), "ang=0x%x;x,y=(0x%x,0x%x)", + players[consoleplayer].mo->angle, + players[consoleplayer].mo->x, + players[consoleplayer].mo->y); + plyr->message = buf; } } |