diff --git a/source/blood/src/barf.cpp b/source/blood/src/barf.cpp index a90233891..23316ee9c 100644 --- a/source/blood/src/barf.cpp +++ b/source/blood/src/barf.cpp @@ -459,9 +459,6 @@ void ParseScript(const char *scriptFileName) char inp[BMAX_PATH]; char zScriptDirectory[BMAX_PATH], zTemp1[BMAX_PATH], zTemp2[BMAX_PATH]; - int const bakpathsearchmode = pathsearchmode; - pathsearchmode = 1; - SplitPath(scriptFileName, zScriptDirectory, zTemp1, zTemp2); RFS rfs; @@ -469,7 +466,6 @@ void ParseScript(const char *scriptFileName) // AddExtension(name, ".RFS"); if (rfs.Open(scriptFileName)) { - pathsearchmode = bakpathsearchmode; return; } @@ -882,7 +878,6 @@ void ParseScript(const char *scriptFileName) //CreateHeader(); rfs.Close(); - pathsearchmode = bakpathsearchmode; } void sub_11C10(char *pzScriptDir, char *fileName, char flags, int ID) diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index 47939d478..fffc4746c 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -1253,17 +1253,11 @@ int app_main() bQuickStart = userConfig.nologo; ParseOptions(); -#ifdef STARTUP_SETUP_WINDOW - int const readSetup = -#endif CONFIG_ReadSetup(); if (enginePreInit()) { - wm_msgbox("Build Engine Initialization Error", - "There was a problem initializing the Build engine: %s", engineerrstr); - ERRprintf("app_main: There was a problem initializing the Build engine: %s\n", engineerrstr); - Bexit(2); + I_Error("app_main: There was a problem initializing the Build engine: %s\n", engineerrstr); } ScanINIFiles(); @@ -1784,20 +1778,10 @@ static int parsedefinitions_game(scriptfile *pScript, int firstPass) { char *fileName; - pathsearchmode = 1; if (!scriptfile_getstring(pScript,&fileName) && firstPass) { - if (initgroupfile(fileName) == -1) - initprintf("Could not find file \"%s\".\n", fileName); - else - { - initprintf("Using file \"%s\" as game data.\n", fileName); - if (G_AllowAutoload()) - G_DoAutoload(fileName); - } + fileSystem.AddAdditionalFile(fileName); } - - pathsearchmode = 0; } break; case T_CACHESIZE: diff --git a/source/blood/src/common.cpp b/source/blood/src/common.cpp index 145dada7c..217786b60 100644 --- a/source/blood/src/common.cpp +++ b/source/blood/src/common.cpp @@ -170,33 +170,6 @@ void G_LoadGroups() loaddefinitions_game(BLOODWIDESCREENDEF, TRUE); loaddefinitions_game(G_DefFile(), TRUE); - - struct strllist *s; - - int const bakpathsearchmode = pathsearchmode; - pathsearchmode = 1; - - while (CommandGrps) - { - int32_t j; - - s = CommandGrps->next; - - if ((j = initgroupfile(CommandGrps->str)) == -1) - initprintf("Could not find file \"%s\".\n", CommandGrps->str); - else - { - g_groupFileHandle = j; - initprintf("Using file \"%s\" as game data.\n", CommandGrps->str); - if (G_AllowAutoload()) - G_DoAutoload(CommandGrps->str); - } - - Bfree(CommandGrps->str); - Bfree(CommandGrps); - CommandGrps = s; - } - pathsearchmode = bakpathsearchmode; } ////////// diff --git a/source/blood/src/config.cpp b/source/blood/src/config.cpp index 6fea5fa4c..32fb9e2bb 100644 --- a/source/blood/src/config.cpp +++ b/source/blood/src/config.cpp @@ -50,7 +50,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_BLD_NS -int32_t setupread; int32_t mus_restartonload; int32_t gTurnSpeed; int32_t gDetail; @@ -127,15 +126,7 @@ void CONFIG_SetDefaults(void) int CONFIG_ReadSetup(void) { CONFIG_SetDefaults(); - - setupread = 1; - pathsearchmode = 1; - - pathsearchmode = 0; - if (ScreenBPP < 8) ScreenBPP = 32; - - setupread = 1; return 0; } diff --git a/source/blood/src/config.h b/source/blood/src/config.h index 7913c2f23..da8cf0efd 100644 --- a/source/blood/src/config.h +++ b/source/blood/src/config.h @@ -35,7 +35,6 @@ BEGIN_BLD_NS #define MAXPLAYERNAME 16 -extern int32_t setupread; extern int32_t gTurnSpeed; extern int32_t gDetail; extern int32_t gAutoRun; diff --git a/source/blood/src/db.cpp b/source/blood/src/db.cpp index 636a7d133..6b35d8f6f 100644 --- a/source/blood/src/db.cpp +++ b/source/blood/src/db.cpp @@ -645,9 +645,6 @@ unsigned int dbReadMapCRC(const char *pPath) byte_1A76C7 = 0; byte_1A76C8 = 0; - int const bakpathsearchmode = pathsearchmode; - pathsearchmode = 1; - Bstrncpy(name2, pPath, BMAX_PATH); Bstrupr(name2); DICTNODE* pNode; @@ -663,11 +660,9 @@ unsigned int dbReadMapCRC(const char *pPath) if (!pNode) { initprintf("Error opening map file %s", pPath); - pathsearchmode = bakpathsearchmode; return -1; } char *pData = (char*)gSysRes.Lock(pNode); - pathsearchmode = bakpathsearchmode; int nSize = pNode->Size(); MAPSIGNATURE header; @@ -712,9 +707,6 @@ int dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, short Polymost_prepare_loadboard(); #endif - int const bakpathsearchmode = pathsearchmode; - pathsearchmode = 1; - Bstrncpy(name2, pPath, BMAX_PATH); Bstrupr(name2); DICTNODE* pNode; @@ -731,11 +723,9 @@ int dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, short if (!pNode) { initprintf("Error opening map file %s", pPath); - pathsearchmode = bakpathsearchmode; return -1; } char *pData = (char*)gSysRes.Lock(pNode); - pathsearchmode = bakpathsearchmode; int nSize = pNode->Size(); MAPSIGNATURE header; IOBuffer IOBuffer1 = IOBuffer(nSize, pData); diff --git a/source/blood/src/demo.cpp b/source/blood/src/demo.cpp index 5ee218224..a42173af9 100644 --- a/source/blood/src/demo.cpp +++ b/source/blood/src/demo.cpp @@ -426,9 +426,7 @@ void CDemo::StopPlayback(void) void CDemo::LoadDemoInfo(void) { auto pDemo = &pFirstDemo; - const int opsm = pathsearchmode; at59ef = 0; - pathsearchmode = 0; char zFN[BMAX_PATH]; Bsnprintf(zFN, BMAX_PATH, "%s*.dem", BloodIniPre); auto pList = klistpath("/", zFN, BUILDVFS_FIND_FILE); @@ -455,7 +453,6 @@ void CDemo::LoadDemoInfo(void) pIterator = pIterator->next; } klistfree(pList); - pathsearchmode = opsm; pCurrentDemo = pFirstDemo; } diff --git a/source/common/filesystem/filesystem.h b/source/common/filesystem/filesystem.h index 32a50f5b2..273bd5054 100644 --- a/source/common/filesystem/filesystem.h +++ b/source/common/filesystem/filesystem.h @@ -82,6 +82,7 @@ public: int InitMultipleFiles (TArray &filenames, const TArray &todelete); void AddFile (const char *filename, FileReader *wadinfo = NULL); + void AddAdditionalFile(const char* filename, FileReader* wadinfo = NULL) {} int CheckIfResourceFileLoaded (const char *name) noexcept; const char *GetResourceFileName (int filenum) const noexcept; diff --git a/source/duke3d/src/common.cpp b/source/duke3d/src/common.cpp index f181ee8d1..864f06392 100644 --- a/source/duke3d/src/common.cpp +++ b/source/duke3d/src/common.cpp @@ -285,33 +285,6 @@ void G_LoadGroups() loaddefinitions_game(G_DefFile(), TRUE); - - struct strllist *s; - - int const bakpathsearchmode = pathsearchmode; - pathsearchmode = 1; - - while (CommandGrps) - { - int32_t j; - - s = CommandGrps->next; - - if ((j = initgroupfile(CommandGrps->str)) == -1) - initprintf("Could not find file \"%s\".\n", CommandGrps->str); - else - { - g_groupFileHandle = j; - initprintf("Using file \"%s\" as game data.\n", CommandGrps->str); - if (G_AllowAutoload()) - G_DoAutoload(CommandGrps->str); - } - - Xfree(CommandGrps->str); - Xfree(CommandGrps); - CommandGrps = s; - } - pathsearchmode = bakpathsearchmode; } diff --git a/source/duke3d/src/config.cpp b/source/duke3d/src/config.cpp index ca4e67534..7e4d9f34f 100644 --- a/source/duke3d/src/config.cpp +++ b/source/duke3d/src/config.cpp @@ -113,9 +113,6 @@ void CONFIG_SetDefaults(void) ud.m_player_skill = ud.player_skill = 2; memcpy(g_player[0].wchoice, "\3\4\5\7\0x8\6\0\2\0x9\1", 10); wchoice.Callback(); - - - VM_OnEvent(EVENT_SETDEFAULTS, g_player[myconnectindex].ps->i, myconnectindex); } @@ -124,13 +121,7 @@ void CONFIG_SetDefaults(void) int CONFIG_ReadSetup(void) { CONFIG_SetDefaults(); - - ud.config.setupread = 1; - pathsearchmode = 0; - if (ScreenBPP < 8) ScreenBPP = 32; - - ud.config.setupread = 1; return 0; } diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index 879810698..d3adf499a 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -45,6 +45,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "gamecvars.h" #include "gameconfigfile.h" #include "printf.h" +#include "filesystem/filesystem.h" #include "vfs.h" @@ -5297,20 +5298,10 @@ static int parsedefinitions_game(scriptfile *pScript, int firstPass) { char *fileName; - pathsearchmode = 1; if (!scriptfile_getstring(pScript,&fileName) && firstPass) { - if (initgroupfile(fileName) == -1) - initprintf("Could not find file \"%s\".\n", fileName); - else - { - initprintf("Using file \"%s\" as game data.\n", fileName); - if (G_AllowAutoload()) - G_DoAutoload(fileName); - } + fileSystem.AddAdditionalFile(fileName); } - - pathsearchmode = 0; } break; case T_CACHESIZE: @@ -5767,8 +5758,6 @@ void G_Shutdown(void) static void G_CompileScripts(void) { #if !defined LUNATIC - int32_t psm = pathsearchmode; - label = (char *)&sprite[0]; // V8: 16384*44/64 = 11264 V7: 4096*44/64 = 2816 labelcode = (int32_t *)§or[0]; // V8: 4096*40/4 = 40960 V7: 1024*40/4 = 10240 labeltype = (int32_t *)&wall[0]; // V8: 16384*32/4 = 131072 V7: 8192*32/4 = 65536 @@ -5778,15 +5767,12 @@ static void G_CompileScripts(void) Gv_Init(); C_InitProjectiles(); #else - // if we compile for a V7 engine wall[] should be used for label names since it's bigger - pathsearchmode = 1; - C_Compile(G_ConFile()); - if (g_loadFromGroupOnly) // g_loadFromGroupOnly is true only when compiling fails and internal defaults are utilized - C_Compile(G_ConFile()); + if (g_loadFromGroupOnly) // g_loadFromGroupOnly is true only when compiling fails and internal defaults are utilized + C_Compile(G_ConFile()); - if ((uint32_t)g_labelCnt > MAXSPRITES*sizeof(spritetype)/64) // see the arithmetic above for why + if ((uint32_t)g_labelCnt > MAXSPRITES*sizeof(spritetype)/64) // see the arithmetic above for why G_GameExit("Error: too many labels defined!"); auto newlabel = (char *)Xmalloc(g_labelCnt << 6); @@ -5806,7 +5792,6 @@ static void G_CompileScripts(void) Bmemset(wall, 0, MAXWALLS*sizeof(walltype)); VM_OnEvent(EVENT_INIT); - pathsearchmode = psm; #endif } @@ -6173,30 +6158,6 @@ void app_crashhandler(void) G_GameQuit(); } -#if defined(_WIN32) && defined(DEBUGGINGAIDS) -// See FILENAME_CASE_CHECK in cache1d.c -static int32_t check_filename_casing(void) -{ - return !(g_player[myconnectindex].ps->gm & MODE_GAME); -} -#endif - -#ifdef LUNATIC -const char *g_sizes_of_what[] = { - "sectortype", "walltype", "spritetype", "spriteext_t", - "actor_t", "DukePlayer_t", "playerdata_t", - "user_defs", "tiledata_t", "weapondata_t", - "projectile_t", -}; -int32_t g_sizes_of[] = { - sizeof(sectortype), sizeof(walltype), sizeof(spritetype), sizeof(spriteext_t), - sizeof(actor_t), sizeof(DukePlayer_t), sizeof(playerdata_t), - sizeof(user_defs), sizeof(tiledata_t), sizeof(weapondata_t), - sizeof(projectile_t) -}; - -DukePlayer_t *g_player_ps[MAXPLAYERS]; -#endif void G_MaybeAllocPlayer(int32_t pnum) { @@ -6204,11 +6165,6 @@ void G_MaybeAllocPlayer(int32_t pnum) g_player[pnum].ps = (DukePlayer_t *)Xcalloc(1, sizeof(DukePlayer_t)); if (g_player[pnum].input == NULL) g_player[pnum].input = (input_t *)Xcalloc(1, sizeof(input_t)); - -#ifdef LUNATIC - g_player_ps[pnum] = g_player[pnum].ps; - g_player[pnum].ps->wa.idx = pnum; -#endif } @@ -6237,20 +6193,11 @@ int app_main() G_CheckCommandLine(); - // This needs to happen afterwards, as G_CheckCommandLine() is where we set - // up the command-line-provided search paths (duh). - -#ifdef STARTUP_SETUP_WINDOW - int const readSetup = -#endif CONFIG_ReadSetup(); if (enginePreInit()) { - wm_msgbox("Build Engine Initialization Error", - "There was a problem initializing the Build engine: %s", engineerrstr); - ERRprintf("app_main: There was a problem initializing the Build engine: %s\n", engineerrstr); - Bexit(2); + I_Error("app_main: There was a problem initializing the Build engine: %s\n", engineerrstr); } @@ -6375,6 +6322,8 @@ int app_main() ud.last_level = -1; + VM_OnEvent(EVENT_SETDEFAULTS, g_player[myconnectindex].ps->i, myconnectindex); + initprintf("Initializing OSD...\n"); OSD_SetVersion(tempbuf, 10,0); diff --git a/source/duke3d/src/game.h b/source/duke3d/src/game.h index 5f87c03d9..8627c2137 100644 --- a/source/duke3d/src/game.h +++ b/source/duke3d/src/game.h @@ -203,7 +203,6 @@ typedef struct { struct { int32_t AutoAim; int32_t ShowWeapons; - int32_t setupread; } config; diff --git a/source/duke3d/src/gamedef.cpp b/source/duke3d/src/gamedef.cpp index e45a48e51..71853eadc 100644 --- a/source/duke3d/src/gamedef.cpp +++ b/source/duke3d/src/gamedef.cpp @@ -4603,8 +4603,8 @@ ifvar: if (n != i) { - swapptr(&tempscrptr[i], &tempscrptr[n]); - swapptr(&tempscrptr[i+1], &tempscrptr[n+1]); + std::swap(&tempscrptr[i], &tempscrptr[n]); + std::swap(&tempscrptr[i+1], &tempscrptr[n+1]); } } // for (j=3;j<3+tempscrptr[1]*2;j+=2)initprintf("%5d %8x\n",tempscrptr[j],tempscrptr[j+1]); @@ -6103,23 +6103,7 @@ void C_Compile(const char *fileName) if (!kFile.isOpen()) { - if (g_loadFromGroupOnly == 1 || numgroupfiles == 0) - { -#ifndef EDUKE32_STANDALONE - I_Error("Required game data was not found."); - G_GameExit(tempbuf); -#else - G_GameExit(" "); -#endif - } - else - { - Bsprintf(tempbuf,"CON file `%s' missing.", fileName); - G_GameExit(tempbuf); - } - - //g_loadFromGroupOnly = 1; - return; //Not there + I_Error(tempbuf,"CON file `%s' missing.", fileName); } int const kFileLen = kFile.GetLength(); diff --git a/source/rr/src/common.cpp b/source/rr/src/common.cpp index 92392a515..0030b6564 100644 --- a/source/rr/src/common.cpp +++ b/source/rr/src/common.cpp @@ -296,33 +296,6 @@ void G_LoadGroups() } loaddefinitions_game(G_DefFile(), TRUE); - - struct strllist *s; - - int const bakpathsearchmode = pathsearchmode; - pathsearchmode = 1; - - while (CommandGrps) - { - int32_t j; - - s = CommandGrps->next; - - if ((j = initgroupfile(CommandGrps->str)) == -1) - initprintf("Could not find file \"%s\".\n", CommandGrps->str); - else - { - g_groupFileHandle = j; - initprintf("Using file \"%s\" as game data.\n", CommandGrps->str); - if (G_AllowAutoload()) - G_DoAutoload(CommandGrps->str); - } - - Bfree(CommandGrps->str); - Bfree(CommandGrps); - CommandGrps = s; - } - pathsearchmode = bakpathsearchmode; } diff --git a/source/rr/src/config.cpp b/source/rr/src/config.cpp index 229cd234b..d4c68ea9b 100644 --- a/source/rr/src/config.cpp +++ b/source/rr/src/config.cpp @@ -102,16 +102,7 @@ void CONFIG_SetDefaults(void) int32_t CONFIG_ReadSetup(void) { CONFIG_SetDefaults(); - - ud.config.setupread = 1; - pathsearchmode = 1; - - pathsearchmode = 0; - - if (ScreenBPP < 8) ScreenBPP = 32; - - ud.config.setupread = 1; return 0; } diff --git a/source/rr/src/game.cpp b/source/rr/src/game.cpp index 83270e022..46cf11eac 100644 --- a/source/rr/src/game.cpp +++ b/source/rr/src/game.cpp @@ -45,7 +45,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "gamecvars.h" #include "gameconfigfile.h" #include "printf.h" - +#include "filesystem/filesystem.h" // Uncomment to prevent anything except mirrors from drawing. It is sensible to // also uncomment ENGINE_CLEAR_SCREEN in build/src/engine_priv.h. @@ -6788,20 +6788,10 @@ static int parsedefinitions_game(scriptfile *pScript, int firstPass) { char *fileName; - pathsearchmode = 1; if (!scriptfile_getstring(pScript,&fileName) && firstPass) { - if (initgroupfile(fileName) == -1) - initprintf("Could not find file \"%s\".\n", fileName); - else - { - initprintf("Using file \"%s\" as game data.\n", fileName); - if (G_AllowAutoload()) - G_DoAutoload(fileName); - } + fileSystem.AddAdditionalFile(fileName); } - - pathsearchmode = 0; } break; case T_CACHESIZE: @@ -7611,21 +7601,12 @@ int app_main() G_CheckCommandLine(); - // This needs to happen afterwards, as G_CheckCommandLine() is where we set - // up the command-line-provided search paths (duh). - -#ifdef STARTUP_SETUP_WINDOW - int const readSetup = -#endif CONFIG_ReadSetup(); if (enginePreInit()) { - wm_msgbox("Build Engine Initialization Error", - "There was a problem initializing the Build engine: %s", engineerrstr); - ERRprintf("app_main: There was a problem initializing the Build engine: %s\n", engineerrstr); - Bexit(2); + I_Error("app_main: There was a problem initializing the Build engine: %s\n", engineerrstr); } diff --git a/source/rr/src/game.h b/source/rr/src/game.h index bc44e8620..63e8b89b0 100644 --- a/source/rr/src/game.h +++ b/source/rr/src/game.h @@ -180,8 +180,6 @@ typedef struct { struct { int32_t AutoAim; int32_t ShowOpponentWeapons; - - int32_t setupread; } config; char overhead_on,last_overhead,showweapons; diff --git a/source/rr/src/gamedef.cpp b/source/rr/src/gamedef.cpp index 2d1ba85ce..34f1b238c 100644 --- a/source/rr/src/gamedef.cpp +++ b/source/rr/src/gamedef.cpp @@ -34,6 +34,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "osd.h" #include "crc32_.h" +#include "printf.h" BEGIN_RR_NS @@ -2378,22 +2379,11 @@ void C_Compile(const char *fileName) if (!kFile.isOpen()) { - if (g_loadFromGroupOnly == 1 || numgroupfiles == 0) - { - char const *gf = G_GrpFile(); - Bsprintf(tempbuf,"Required game data was not found. A valid copy of \"%s\" or other compatible data is needed to run EDuke32.\n\n" - "You must copy \"%s\" to your game directory before continuing!", gf, gf); - G_GameExit(tempbuf); - } - else - { - Bsprintf(tempbuf,"CON file `%s' missing.", fileName); - G_GameExit(tempbuf); - } - - //g_loadFromGroupOnly = 1; - return; //Not there - } + if (!kFile.isOpen()) + { + I_Error(tempbuf, "CON file `%s' missing.", fileName); + } + } int const kFileLen = kFile.GetLength(); diff --git a/source/sw/src/config.cpp b/source/sw/src/config.cpp index 695777834..c354c3994 100644 --- a/source/sw/src/config.cpp +++ b/source/sw/src/config.cpp @@ -123,14 +123,7 @@ void SetDefaultKeyDefinitions(int style) int32_t CONFIG_ReadSetup(void) { - //char ret; - extern char ds[]; - extern char PlayerNameArg[32]; - - char waveformtrackname[MAXWAVEFORMTRACKLENGTH] = {0}; - CONFIG_SetDefaults(); - return 0; } diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index c3ee8f95a..3d7e80322 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -3343,7 +3343,7 @@ int32_t app_main() SW_ExtInit(); - i = CONFIG_ReadSetup(); + CONFIG_ReadSetup(); if (enginePreInit()) {