- various initialization related changes

* reroute several error conditions to I_Error.
* removed some soon-to-be obsolete GRP loading code.
* explicitly trigger the SetDefaults script events which depended on side effects from the config implementation.
* removed the nonsensical file system switch. All this does is create instabilities because it is non-obvious from where data is loaded. If a resource is mounted, it should be checked for content no matter what. While this may affect the stray weird mod out there it is a necessity if we want to allow transparent project repackaging.
This commit is contained in:
Christoph Oelckers 2019-11-01 09:30:28 +01:00
parent 39bfd64fe9
commit 8d5e665caa
20 changed files with 24 additions and 272 deletions

View file

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

View file

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

View file

@ -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;
}
//////////

View file

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

View file

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

View file

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

View file

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

View file

@ -82,6 +82,7 @@ public:
int InitMultipleFiles (TArray<FString> &filenames, const TArray<FString> &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;

View file

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

View file

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

View file

@ -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 *)&sector[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);

View file

@ -203,7 +203,6 @@ typedef struct {
struct {
int32_t AutoAim;
int32_t ShowWeapons;
int32_t setupread;
} config;

View file

@ -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();

View file

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

View file

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

View file

@ -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);
}

View file

@ -180,8 +180,6 @@ typedef struct {
struct {
int32_t AutoAim;
int32_t ShowOpponentWeapons;
int32_t setupread;
} config;
char overhead_on,last_overhead,showweapons;

View file

@ -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();

View file

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

View file

@ -3343,7 +3343,7 @@ int32_t app_main()
SW_ExtInit();
i = CONFIG_ReadSetup();
CONFIG_ReadSetup();
if (enginePreInit())
{