diff options
Diffstat (limited to 'src/doom')
-rw-r--r-- | src/doom/am_map.c | 6 | ||||
-rw-r--r-- | src/doom/d_main.c | 34 | ||||
-rw-r--r-- | src/doom/d_net.c | 10 | ||||
-rw-r--r-- | src/doom/f_finale.c | 2 | ||||
-rw-r--r-- | src/doom/g_game.c | 4 | ||||
-rw-r--r-- | src/doom/hu_stuff.c | 2 | ||||
-rw-r--r-- | src/doom/m_menu.c | 4 | ||||
-rw-r--r-- | src/doom/p_saveg.c | 24 | ||||
-rw-r--r-- | src/doom/p_saveg.h | 1 | ||||
-rw-r--r-- | src/doom/p_setup.c | 4 | ||||
-rw-r--r-- | src/doom/st_stuff.c | 22 | ||||
-rw-r--r-- | src/doom/wi_stuff.c | 47 |
12 files changed, 92 insertions, 68 deletions
diff --git a/src/doom/am_map.c b/src/doom/am_map.c index 89a5dffc..d957ea67 100644 --- a/src/doom/am_map.c +++ b/src/doom/am_map.c @@ -500,7 +500,7 @@ void AM_loadPics(void) for (i=0;i<10;i++) { - sprintf(namebuf, DEH_String("AMMNUM%d"), i); + DEH_snprintf(namebuf, 9, "AMMNUM%d", i); marknums[i] = W_CacheLumpName(namebuf, PU_STATIC); } @@ -513,7 +513,7 @@ void AM_unloadPics(void) for (i=0;i<10;i++) { - sprintf(namebuf, DEH_String("AMMNUM%d"), i); + DEH_snprintf(namebuf, 9, "AMMNUM%d", i); W_ReleaseLumpName(namebuf); } } @@ -1020,7 +1020,7 @@ AM_drawFline || fl->b.x < 0 || fl->b.x >= f_w || fl->b.y < 0 || fl->b.y >= f_h) { - fprintf(stderr, DEH_String("fuck %d \r"), fuck++); + DEH_fprintf(stderr, "fuck %d \r", fuck++); return; } diff --git a/src/doom/d_main.c b/src/doom/d_main.c index c6099da9..3fee8439 100644 --- a/src/doom/d_main.c +++ b/src/doom/d_main.c @@ -1068,7 +1068,7 @@ void D_DoomMain (void) I_PrintBanner(PACKAGE_STRING); - printf (DEH_String("Z_Init: Init zone memory allocation daemon. \n")); + DEH_printf("Z_Init: Init zone memory allocation daemon. \n"); Z_Init (); #ifdef FEATURE_MULTIPLAYER @@ -1187,7 +1187,7 @@ void D_DoomMain (void) deathmatch = 2; if (devparm) - printf(DEH_String(D_DEVSTR)); + DEH_printf(D_DEVSTR); // find which dir to use for config files @@ -1235,7 +1235,7 @@ void D_DoomMain (void) scale = 10; if (scale > 400) scale = 400; - printf (DEH_String("turbo scale: %i%%\n"),scale); + DEH_printf("turbo scale: %i%%\n", scale); forwardmove[0] = forwardmove[0]*scale/100; forwardmove[1] = forwardmove[1]*scale/100; sidemove[0] = sidemove[0]*scale/100; @@ -1243,11 +1243,11 @@ void D_DoomMain (void) } // init subsystems - printf(DEH_String("V_Init: allocate screens.\n")); - V_Init(); + DEH_printf("V_Init: allocate screens.\n"); + V_Init (); // Load configuration files before initialising other subsystems. - printf(DEH_String("M_LoadDefaults: Load system defaults.\n")); + DEH_printf("M_LoadDefaults: Load system defaults.\n"); M_SetConfigFilenames("default.cfg", PROGRAM_PREFIX "doom.cfg"); D_BindVariables(); M_LoadDefaults(); @@ -1255,7 +1255,7 @@ void D_DoomMain (void) // Save configuration at exit. I_AtExit(M_SaveDefaults, false); - printf (DEH_String("W_Init: Init WADfiles.\n")); + DEH_printf("W_Init: Init WADfiles.\n"); D_AddFile(iwadfile); modifiedgame = W_ParseCommandLine(); @@ -1451,8 +1451,8 @@ void D_DoomMain (void) if (p && p < myargc-1 && deathmatch) { - printf(DEH_String("Austin Virtual Gaming: Levels will end " - "after 20 minutes\n")); + DEH_printf("Austin Virtual Gaming: Levels will end " + "after 20 minutes\n"); timelimit = 20; } @@ -1534,16 +1534,16 @@ void D_DoomMain (void) I_PrintStartupBanner(gamedescription); PrintDehackedBanners(); - printf (DEH_String("M_Init: Init miscellaneous info.\n")); + DEH_printf("M_Init: Init miscellaneous info.\n"); M_Init (); - printf (DEH_String("R_Init: Init DOOM refresh daemon - ")); + DEH_printf("R_Init: Init DOOM refresh daemon - "); R_Init (); - printf (DEH_String("\nP_Init: Init Playloop state.\n")); + DEH_printf("\nP_Init: Init Playloop state.\n"); P_Init (); - printf (DEH_String("I_Init: Setting up machine state.\n")); + DEH_printf("I_Init: Setting up machine state.\n"); I_CheckIsScreensaver(); I_InitTimer(); I_InitJoystick(); @@ -1553,18 +1553,18 @@ void D_DoomMain (void) NET_Init (); #endif - printf (DEH_String("S_Init: Setting up sound.\n")); + DEH_printf("S_Init: Setting up sound.\n"); S_Init (sfxVolume * 8, musicVolume * 8); - printf (DEH_String("D_CheckNetGame: Checking network game status.\n")); + DEH_printf("D_CheckNetGame: Checking network game status.\n"); D_CheckNetGame (); PrintGameVersion(); - printf (DEH_String("HU_Init: Setting up heads up display.\n")); + DEH_printf("HU_Init: Setting up heads up display.\n"); HU_Init (); - printf (DEH_String("ST_Init: Init status bar.\n")); + DEH_printf("ST_Init: Init status bar.\n"); ST_Init (); // If Doom II without a MAP01 lump, this is a store demo. diff --git a/src/doom/d_net.c b/src/doom/d_net.c index e30ead83..464922d4 100644 --- a/src/doom/d_net.c +++ b/src/doom/d_net.c @@ -374,17 +374,17 @@ void D_CheckNetGame (void) ++num_players; } - printf (DEH_String("startskill %i deathmatch: %i startmap: %i startepisode: %i\n"), - startskill, deathmatch, startmap, startepisode); + DEH_printf("startskill %i deathmatch: %i startmap: %i startepisode: %i\n", + startskill, deathmatch, startmap, startepisode); - printf(DEH_String("player %i of %i (%i nodes)\n"), - consoleplayer+1, num_players, num_players); + DEH_printf("player %i of %i (%i nodes)\n", + consoleplayer+1, num_players, num_players); // Show players here; the server might have specified a time limit if (timelimit > 0) { - printf(DEH_String("Levels will end after %d minute"),timelimit); + DEH_printf("Levels will end after %d minute", timelimit); if (timelimit > 1) printf("s"); printf(".\n"); diff --git a/src/doom/f_finale.c b/src/doom/f_finale.c index ece82b43..dfbeafbe 100644 --- a/src/doom/f_finale.c +++ b/src/doom/f_finale.c @@ -663,7 +663,7 @@ void F_BunnyScroll (void) laststage = stage; } - sprintf (name, DEH_String("END%i"), stage); + DEH_snprintf(name, 10, "END%i", stage); V_DrawPatch((SCREENWIDTH - 13 * 8) / 2, (SCREENHEIGHT - 8 * 8) / 2, W_CacheLumpName (name,PU_CACHE)); diff --git a/src/doom/g_game.c b/src/doom/g_game.c index 8d0e4503..9b569594 100644 --- a/src/doom/g_game.c +++ b/src/doom/g_game.c @@ -1428,6 +1428,8 @@ void G_DoLoadGame (void) return; } + savegame_error = false; + if (!P_ReadSaveGameHeader()) { fclose(save_stream); @@ -1495,6 +1497,8 @@ void G_DoSaveGame (void) return; } + savegame_error = false; + P_WriteSaveGameHeader(savedescription); P_ArchivePlayers (); diff --git a/src/doom/hu_stuff.c b/src/doom/hu_stuff.c index ca74ce92..3337f978 100644 --- a/src/doom/hu_stuff.c +++ b/src/doom/hu_stuff.c @@ -302,7 +302,7 @@ void HU_Init(void) j = HU_FONTSTART; for (i=0;i<HU_FONTSIZE;i++) { - sprintf(buffer, DEH_String("STCFN%.3d"), j++); + DEH_snprintf(buffer, 9, "STCFN%.3d", j++); hu_font[i] = (patch_t *) W_CacheLumpName(buffer, PU_STATIC); } diff --git a/src/doom/m_menu.c b/src/doom/m_menu.c index a0d66dd4..a6f7bbfb 100644 --- a/src/doom/m_menu.c +++ b/src/doom/m_menu.c @@ -707,7 +707,7 @@ void M_QuickSave(void) quickSaveSlot = -2; // means to pick a slot now return; } - sprintf(tempstring,DEH_String(QSPROMPT),savegamestrings[quickSaveSlot]); + DEH_snprintf(tempstring, 80, QSPROMPT, savegamestrings[quickSaveSlot]); M_StartMessage(tempstring,M_QuickSaveResponse,true); } @@ -739,7 +739,7 @@ void M_QuickLoad(void) M_StartMessage(DEH_String(QSAVESPOT),NULL,false); return; } - sprintf(tempstring,DEH_String(QLPROMPT),savegamestrings[quickSaveSlot]); + DEH_snprintf(tempstring, 80, QLPROMPT, savegamestrings[quickSaveSlot]); M_StartMessage(tempstring,M_QuickLoadResponse,true); } diff --git a/src/doom/p_saveg.c b/src/doom/p_saveg.c index e557e494..968120c0 100644 --- a/src/doom/p_saveg.c +++ b/src/doom/p_saveg.c @@ -44,6 +44,7 @@ FILE *save_stream; int savegamelength; +boolean savegame_error; // Get the filename of a temporary file to write the savegame to. After // the file has been successfully saved, it will be renamed to the @@ -75,7 +76,7 @@ char *P_SaveGameFile(int slot) filename = malloc(strlen(savegamedir) + 32); } - sprintf(basename, DEH_String(SAVEGAMENAME "%d.dsg"), slot); + DEH_snprintf(basename, 32, SAVEGAMENAME "%d.dsg", slot); sprintf(filename, "%s%s", savegamedir, basename); @@ -88,14 +89,31 @@ static byte saveg_read8(void) { byte result; - fread(&result, 1, 1, save_stream); + if (fread(&result, 1, 1, save_stream) < 1) + { + if (!savegame_error) + { + fprintf(stderr, "saveg_read8: Unexpected end of file while " + "reading save game\n"); + + savegame_error = true; + } + } return result; } static void saveg_write8(byte value) { - fwrite(&value, 1, 1, save_stream); + if (fwrite(&value, 1, 1, save_stream) < 1) + { + if (!savegame_error) + { + fprintf(stderr, "saveg_write8: Error while writing save game\n"); + + savegame_error = true; + } + } } static short saveg_read16(void) diff --git a/src/doom/p_saveg.h b/src/doom/p_saveg.h index 3a96cc3e..5488289c 100644 --- a/src/doom/p_saveg.h +++ b/src/doom/p_saveg.h @@ -64,6 +64,7 @@ void P_ArchiveSpecials (void); void P_UnArchiveSpecials (void); extern FILE *save_stream; +extern boolean savegame_error; #endif diff --git a/src/doom/p_setup.c b/src/doom/p_setup.c index 58edc6fd..7d9d4318 100644 --- a/src/doom/p_setup.c +++ b/src/doom/p_setup.c @@ -774,9 +774,9 @@ P_SetupLevel if ( gamemode == commercial) { if (map<10) - sprintf (lumpname, DEH_String("map0%i"), map); + DEH_snprintf(lumpname, 9, "map0%i", map); else - sprintf (lumpname, DEH_String("map%i"), map); + DEH_snprintf(lumpname, 9, "map%i", map); } else { diff --git a/src/doom/st_stuff.c b/src/doom/st_stuff.c index 160244ce..7e5e225c 100644 --- a/src/doom/st_stuff.c +++ b/src/doom/st_stuff.c @@ -1085,10 +1085,10 @@ static void ST_loadUnloadGraphics(load_callback_t callback) // Load the numbers, tall and short for (i=0;i<10;i++) { - sprintf(namebuf, DEH_String("STTNUM%d"), i); + DEH_snprintf(namebuf, 9, "STTNUM%d", i); callback(namebuf, &tallnum[i]); - sprintf(namebuf, DEH_String("STYSNUM%d"), i); + DEH_snprintf(namebuf, 9, "STYSNUM%d", i); callback(namebuf, &shortnum[i]); } @@ -1100,7 +1100,7 @@ static void ST_loadUnloadGraphics(load_callback_t callback) // key cards for (i=0;i<NUMCARDS;i++) { - sprintf(namebuf, DEH_String("STKEYS%d"), i); + DEH_snprintf(namebuf, 9, "STKEYS%d", i); callback(namebuf, &keys[i]); } @@ -1110,7 +1110,7 @@ static void ST_loadUnloadGraphics(load_callback_t callback) // arms ownership widgets for (i=0; i<6; i++) { - sprintf(namebuf, DEH_String("STGNUM%d"), i+2); + DEH_snprintf(namebuf, 9, "STGNUM%d", i+2); // gray # callback(namebuf, &arms[i][0]); @@ -1120,7 +1120,7 @@ static void ST_loadUnloadGraphics(load_callback_t callback) } // face backgrounds for different color players - sprintf(namebuf, DEH_String("STFB%d"), consoleplayer); + DEH_snprintf(namebuf, 9, "STFB%d", consoleplayer); callback(namebuf, &faceback); // status bar background bits @@ -1132,23 +1132,23 @@ static void ST_loadUnloadGraphics(load_callback_t callback) { for (j=0; j<ST_NUMSTRAIGHTFACES; j++) { - sprintf(namebuf, DEH_String("STFST%d%d"), i, j); + DEH_snprintf(namebuf, 9, "STFST%d%d", i, j); callback(namebuf, &faces[facenum]); ++facenum; } - sprintf(namebuf, DEH_String("STFTR%d0"), i); // turn right + DEH_snprintf(namebuf, 9, "STFTR%d0", i); // turn right callback(namebuf, &faces[facenum]); ++facenum; - sprintf(namebuf, DEH_String("STFTL%d0"), i); // turn left + DEH_snprintf(namebuf, 9, "STFTL%d0", i); // turn left callback(namebuf, &faces[facenum]); ++facenum; - sprintf(namebuf, DEH_String("STFOUCH%d"), i); // ouch! + DEH_snprintf(namebuf, 9, "STFOUCH%d", i); // ouch! callback(namebuf, &faces[facenum]); ++facenum; - sprintf(namebuf, DEH_String("STFEVL%d"), i); // evil grin ;) + DEH_snprintf(namebuf, 9, "STFEVL%d", i); // evil grin ;) callback(namebuf, &faces[facenum]); ++facenum; - sprintf(namebuf, DEH_String("STFKILL%d"), i); // pissed off + DEH_snprintf(namebuf, 9, "STFKILL%d", i); // pissed off callback(namebuf, &faces[facenum]); ++facenum; } diff --git a/src/doom/wi_stuff.c b/src/doom/wi_stuff.c index 83f5052f..45c09343 100644 --- a/src/doom/wi_stuff.c +++ b/src/doom/wi_stuff.c @@ -1571,16 +1571,16 @@ static void WI_loadUnloadData(load_callback_t callback) if (gamemode == commercial) { for (i=0 ; i<NUMCMAPS ; i++) - { - sprintf(name, DEH_String("CWILV%2.2d"), i); + { + DEH_snprintf(name, 9, "CWILV%2.2d", i); callback(name, &lnames[i]); - } + } } else { for (i=0 ; i<NUMMAPS ; i++) { - sprintf(name, DEH_String("WILV%d%d"), wbs->epsd, i); + DEH_snprintf(name, 9, "WILV%d%d", wbs->epsd, i); callback(name, &lnames[i]); } @@ -1592,7 +1592,7 @@ static void WI_loadUnloadData(load_callback_t callback) // splat callback(DEH_String("WISPLAT"), &splat[0]); - + if (wbs->epsd < 3) { for (j=0;j<NUMANIMS[wbs->epsd];j++) @@ -1601,17 +1601,16 @@ static void WI_loadUnloadData(load_callback_t callback) for (i=0;i<a->nanims;i++) { // MONDO HACK! - if (wbs->epsd != 1 || j != 8) + if (wbs->epsd != 1 || j != 8) { // animations - sprintf(name, DEH_String("WIA%d%.2d%.2d"), - wbs->epsd, j, i); + DEH_snprintf(name, 9, "WIA%d%.2d%.2d", wbs->epsd, j, i); callback(name, &a->p[i]); } else { // HACK ALERT! - a->p[i] = anims[1][4].p[i]; + a->p[i] = anims[1][4].p[i]; } } } @@ -1624,7 +1623,7 @@ static void WI_loadUnloadData(load_callback_t callback) for (i=0;i<10;i++) { // numbers 0-9 - sprintf(name, DEH_String("WINUM%d"), i); + DEH_snprintf(name, 9, "WINUM%d", i); callback(name, &num[i]); } @@ -1665,13 +1664,13 @@ static void WI_loadUnloadData(load_callback_t callback) callback(DEH_String("WICOLON"), &colon); // "time" - callback(DEH_String("WITIME"), &timepatch); + callback(DEH_String("WITIME"), &timepatch); // "sucks" - callback(DEH_String("WISUCKS"), &sucks); + callback(DEH_String("WISUCKS"), &sucks); // "par" - callback(DEH_String("WIPAR"), &par); + callback(DEH_String("WIPAR"), &par); // "killers" (vertical) callback(DEH_String("WIKILRS"), &killers); @@ -1680,16 +1679,16 @@ static void WI_loadUnloadData(load_callback_t callback) callback(DEH_String("WIVCTMS"), &victims); // "total" - callback(DEH_String("WIMSTT"), &total); + callback(DEH_String("WIMSTT"), &total); for (i=0 ; i<MAXPLAYERS ; i++) { // "1,2,3,4" - sprintf(name, DEH_String("STPB%d"), i); + DEH_snprintf(name, 9, "STPB%d", i); callback(name, &p[i]); // "1,2,3,4" - sprintf(name, DEH_String("WIBP%d"), i+1); + DEH_snprintf(name, 9, "WIBP%d", i+1); callback(name, &bp[i]); } @@ -1697,19 +1696,21 @@ static void WI_loadUnloadData(load_callback_t callback) if (gamemode == commercial) { - strcpy(name, DEH_String("INTERPIC")); + strncpy(name, DEH_String("INTERPIC"), 9); + name[8] = '\0'; } else if (gamemode == retail && wbs->epsd == 3) { - strcpy(name, DEH_String("INTERPIC")); + strncpy(name, DEH_String("INTERPIC"), 9); + name[8] = '\0'; } - else + else { - sprintf(name, DEH_String("WIMAP%d"), wbs->epsd); + DEH_snprintf(name, 9, "WIMAP%d", wbs->epsd); } - + // Draw backdrop and save to a temporary buffer - + callback(name, &background); } @@ -1722,7 +1723,7 @@ void WI_loadData(void) { if (gamemode == commercial) { - NUMCMAPS = 32; + NUMCMAPS = 32; lnames = (patch_t **) Z_Malloc(sizeof(patch_t*) * NUMCMAPS, PU_STATIC, NULL); } |