diff --git a/src/command.c b/src/command.c index d70fbc198..834b32dbc 100644 --- a/src/command.c +++ b/src/command.c @@ -1625,7 +1625,7 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth) const char *overridestr = valstr; - if (mainwads == 0 && var->PossibleValue == Color_cons_t) + if (numwadfiles == 0 && var->PossibleValue == Color_cons_t) { override = true; if (!strcmp(valstr, "Blue")) diff --git a/src/d_main.cpp b/src/d_main.cpp index d92c496a8..f93eca1ed 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -1482,41 +1482,30 @@ void D_SRB2Main(void) W_InitMultipleFiles(startupiwads, false); D_CleanFile(startupiwads); - mainwads = 0; - #ifndef DEVELOP // Check MD5s of autoloaded files // Note: Do not add any files that ignore MD5! - W_VerifyFileMD5(mainwads, ASSET_HASH_SRB2_SRB); // srb2.srb - wadfiles[mainwads]->compatmode = true; - mainwads++; W_VerifyFileMD5(mainwads, ASSET_HASH_GFX_KART); // gfx.kart - wadfiles[mainwads]->compatmode = true; - mainwads++; W_VerifyFileMD5(mainwads, ASSET_HASH_TEXTURES_KART); // textures.kart - wadfiles[mainwads]->compatmode = true; - mainwads++; W_VerifyFileMD5(mainwads, ASSET_HASH_CHARS_KART); // chars.kart - wadfiles[mainwads]->compatmode = true; - mainwads++; W_VerifyFileMD5(mainwads, ASSET_HASH_MAPS_KART); // maps.kart - wadfiles[mainwads]->compatmode = true; - mainwads++; W_VerifyFileMD5(mainwads, ASSET_HASH_MAIN_PK3); // main.pk3 + W_VerifyFileMD5(MAINWAD_SRB2, ASSET_HASH_SRB2_SRB); + W_VerifyFileMD5(MAINWAD_GFX, ASSET_HASH_GFX_KART); + W_VerifyFileMD5(MAINWAD_TEXTURES, ASSET_HASH_TEXTURES_KART); + W_VerifyFileMD5(MAINWAD_CHARS, ASSET_HASH_CHARS_KART); + W_VerifyFileMD5(MAINWAD_MAPS, ASSET_HASH_MAPS_KART); + W_VerifyFileMD5(MAINWAD_MAIN, ASSET_HASH_MAIN_PK3); #ifdef USE_PATCH_FILE - mainwads++; W_VerifyFileMD5(mainwads, ASSET_HASH_PATCH_PK3); // patch.pk3 + W_VerifyFileMD5(MAINWAD_PATCH, ASSET_HASH_PATCH_PK3); #endif -#else - mainwads++; // gfx.kart - wadfiles[mainwads]->compatmode = true; - mainwads++; // textures.kart - wadfiles[mainwads]->compatmode = true; - mainwads++; // chars.kart - wadfiles[mainwads]->compatmode = true; - mainwads++; // maps.kart - wadfiles[mainwads]->compatmode = true; - mainwads++; // main.pk3 -#ifdef USE_PATCH_FILE - mainwads++; // patch.pk3 -#endif - #endif //ifndef DEVELOP + wadfiles[MAINWAD_SRB2]->compatmode = true; + wadfiles[MAINWAD_GFX]->compatmode = true; + wadfiles[MAINWAD_TEXTURES]->compatmode = true; + wadfiles[MAINWAD_CHARS]->compatmode = true; + wadfiles[MAINWAD_MAPS]->compatmode = true; + wadfiles[MAINWAD_MAIN]->compatmode = false; +#ifdef USE_PATCH_FILE + wadfiles[MAINWAD_PATCH]->compatmode = false; +#endif + R_InitPaletteRemap(); // now do it again for the SOC colors in main.pk3! @@ -1558,7 +1547,10 @@ void D_SRB2Main(void) timelimits[GT_BATTLE] = 2; CON_SetLoadingProgress(LOADED_HUINIT); - + + if (modifiedgame) + I_Error("modifiedgame set during startup!"); + CONS_Printf("W_InitMultipleFiles(): Adding external PWADs.\n"); // HACK: Refer to https://git.do.srb2.org/KartKrew/RingRacers/-/merge_requests/29#note_61574 diff --git a/src/d_main.h b/src/d_main.h index df163deea..de7a9356f 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -32,6 +32,20 @@ extern "C" { #define GRAPHICSNAME "gfx.kart" #define SOUNDSNAME "sounds.kart" +typedef enum +{ + MAINWAD_SRB2, + MAINWAD_GFX, + MAINWAD_TEXTURES, + MAINWAD_CHARS, + MAINWAD_MAPS, + MAINWAD_MAIN, +#ifdef USE_PATCH_FILE + MAINWAD_PATCH, +#endif + NUMMAINWADS +} mainwad_t; + // make sure not to write back the config until it's been correctly loaded extern tic_t rendergametic; diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 7d830ae48..b1e32db62 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -4782,7 +4782,7 @@ static void Command_ListWADS_f(void) nameonly(tempname = va("%s", wadfiles[i]->filename)); if (!i) CONS_Printf("\x82 IWAD\x80: %s\n", tempname); - else if (i <= mainwads) + else if (i < NUMMAINWADS) CONS_Printf("\x82 * %.2d\x80: %s\n", i, tempname); else if (!wadfiles[i]->important) CONS_Printf("\x86 %.2d: %s\n", i, tempname); diff --git a/src/d_netfil.c b/src/d_netfil.c index 7bd213e6b..cd3cbb91c 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -158,13 +158,13 @@ UINT8 *PutFileNeeded(UINT16 firstfile) #ifdef DEVELOP i = 0; #else - i = mainwads + 1; + i = NUMMAINWADS; #endif for (; i < numwadfiles; i++) //mainwads+1, otherwise we start on the first mainwad { // If it has only music/sound lumps, don't put it in the list - if (i > mainwads && !wadfiles[i]->important) + if (i >= NUMMAINWADS && !wadfiles[i]->important) continue; if (firstfile) @@ -190,7 +190,7 @@ UINT8 *PutFileNeeded(UINT16 firstfile) /* don't send mainwads!! */ #ifdef DEVELOP - if (i <= mainwads) + if (i < NUMMAINWADS) filestatus += (2 << 4); #endif @@ -555,7 +555,7 @@ INT32 CL_CheckFiles(void) #ifdef DEVELOP j = 0; #else - j = mainwads + 1; + j = NUMMAINWADS; #endif for (i = 0; i < fileneedednum || j < numwadfiles;) { @@ -605,7 +605,7 @@ INT32 CL_CheckFiles(void) #ifdef DEVELOP j = 0; #else - j = mainwads + 1; + j = NUMMAINWADS; #endif for (; wadfiles[j]; j++) { diff --git a/src/deh_soc.c b/src/deh_soc.c index f2a98a806..c7856f602 100644 --- a/src/deh_soc.c +++ b/src/deh_soc.c @@ -1133,7 +1133,7 @@ void readlevelheader(MYFILE *f, char * name) { P_AllocMapHeader((INT16)(num = nummapheaders)); } - else if (f->wad > mainwads) + else if (f->wad >= NUMMAINWADS) { // only mark as a major mod if it replaces an already-existing mapheaderinfo G_SetGameModified(multiplayer, true); diff --git a/src/dehacked.c b/src/dehacked.c index 7a7604f85..9f081ffc3 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -325,7 +325,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, boolean mainfile) i = get_mobjtype(word2); // find a thing by name if (i < NUMMOBJTYPES && i >= 0) { - if (i < (MT_FIRSTFREESLOT+freeslotusage[1][1])) + if (!mainfile && i < (MT_FIRSTFREESLOT+freeslotusage[1][1])) { G_SetGameModified(multiplayer, true); // Only a major mod if editing stuff that isn't your own! } @@ -444,7 +444,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, boolean mainfile) i = get_state(word2); // find a state by name if (i < NUMSTATES && i >= 0) { - if (i < (S_FIRSTFREESLOT+freeslotusage[0][1])) + if (!mainfile && i < (S_FIRSTFREESLOT+freeslotusage[0][1])) { G_SetGameModified(multiplayer, true); // Only a major mod if editing stuff that isn't your own! } @@ -529,7 +529,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, boolean mainfile) while (cup) { - if (hash == cup->namehash && fastcmp(cup->name, word2)) + if (!mainfile && hash == cup->namehash && fastcmp(cup->name, word2)) { // Only a major mod if editing stuff that isn't your own! G_SetGameModified(multiplayer, true); diff --git a/src/doomstat.h b/src/doomstat.h index b560cbbe3..90ec96e2e 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -127,7 +127,6 @@ struct recorddata_t // Set if homebrew PWAD stuff has been added. extern boolean modifiedgame; extern boolean majormods; -extern UINT16 mainwads; extern boolean savemoddata; // This mod saves time/emblem data. extern boolean imcontinuing; // Temporary flag while continuing extern boolean metalrecording; diff --git a/src/g_demo.c b/src/g_demo.c index 5a12d785e..10ffb3fef 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -2149,7 +2149,7 @@ void G_BeginRecording(void) demobuf.p += 1; totalfiles = 0; - for (i = mainwads; ++i < numwadfiles; ) + for (i = NUMMAINWADS-1; ++i < numwadfiles; ) if (wadfiles[i]->important) { nameonly(( filename = va("%s", wadfiles[i]->filename) )); @@ -2516,7 +2516,7 @@ static UINT8 G_CheckDemoExtraFiles(UINT8 **pp, boolean quick) for (j = 0; j < numwadfiles; ++j) { - if (wadfiles[j]->important && j > mainwads) + if (wadfiles[j]->important && j >= NUMMAINWADS) nmusfilecount++; else continue; @@ -2552,7 +2552,7 @@ static UINT8 G_CheckDemoExtraFiles(UINT8 **pp, boolean quick) nmusfilecount = 0; for (j = 0; j < numwadfiles; ++j) - if (wadfiles[j]->important && j > mainwads) + if (wadfiles[j]->important && j >= NUMMAINWADS) nmusfilecount++; if (!error && filesloaded < nmusfilecount) diff --git a/src/g_game.c b/src/g_game.c index 4c54eb314..62876415b 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -126,7 +126,6 @@ tic_t marathontime = 0; UINT8 numgameovers = 0; // for startinglives balance SINT8 startinglivesbalance[maxgameovers+1] = {3, 5, 7, 9, 12, 15, 20, 25, 30, 40, 50, 75, 99, 0x7F}; -UINT16 mainwads = 0; boolean modifiedgame = false; // Set if homebrew PWAD stuff has been added. boolean majormods = false; // Set if Lua/Gameplay SOC/replacement map has been added. boolean savemoddata = false; @@ -632,7 +631,7 @@ static void G_SetSaveGameModified(void) // for consistency among messages: this modifies the game and removes savemoddata. void G_SetGameModified(boolean silent, boolean major) { - if ((majormods && modifiedgame) || !mainwads || (refreshdirmenu & REFRESHDIR_GAMEDATA)) // new gamedata amnesty? + if ((majormods && modifiedgame) || (refreshdirmenu & REFRESHDIR_GAMEDATA)) // new gamedata amnesty? return; modifiedgame = true; diff --git a/src/m_menu.c b/src/m_menu.c index 1c80d5318..0c119f10f 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3064,13 +3064,13 @@ void M_DrawAddons(void) else V_DrawCenteredString(BASEVIDWIDTH/2, 5, 0, (recommendedflags == V_SKYMAP ? LOCATIONSTRING2 : LOCATIONSTRING1)); - if (numwadfiles <= mainwads+1) + if (numwadfiles <= NUMMAINWADS) y = 0; else if (numwadfiles >= MAX_WADFILES) y = FRACUNIT; else { - y = FixedDiv(((ssize_t)(numwadfiles) - (ssize_t)(mainwads+1))< FRACUNIT) // happens because of how we're shrinkin' it a little y = FRACUNIT; } diff --git a/src/r_skins.c b/src/r_skins.c index 0ad38ae89..0571a06c4 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -27,6 +27,7 @@ #include "p_local.h" #include "dehacked.h" // get_number (for thok) #include "m_cond.h" +#include "d_main.h" // MAINWAD_CHARS #if 0 #include "k_kart.h" // K_KartResetPlayerColor #endif @@ -153,7 +154,7 @@ void R_InitSkins(void) for (i = 0; i < numwadfiles; i++) { - if (i == 3) // chars.kart + if (i == MAINWAD_CHARS) R_IHateThatHedgehog((UINT16)i); R_AddSkins((UINT16)i); if (!wadfiles[i]->compatmode) diff --git a/src/s_sound.c b/src/s_sound.c index 21369732a..c1b1cc201 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1667,7 +1667,7 @@ void S_InitMusicDefs(void) for (i = 0; i < numwadfiles; i++) { nameonly(tempname = va("%s", wadfiles[i]->filename)); - if (wadfiles[i]->filename && !stricmp(tempname, "music.kart")) + if (wadfiles[i]->filename && !stricmp(tempname, MUSICNAME)) { // Awful hack but what can you do? continue;