- adapted game code.

This commit is contained in:
Christoph Oelckers 2023-08-20 02:25:12 +02:00
parent b95a5a4b2b
commit f2740e434a
7 changed files with 26 additions and 26 deletions

View file

@ -106,7 +106,7 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
size_t index; size_t index;
for(index = 0; index < folderdata.size(); index++) for(index = 0; index < folderdata.size(); index++)
{ {
if (infpath.CompareNoCase(folderdata[i].name) == 0) break; if (infpath.CompareNoCase(folderdata[index].name) == 0) break;
} }
if (index < folderdata.size()) if (index < folderdata.size())

View file

@ -1979,7 +1979,7 @@ void loaddefinitionsfile(TilesetBuildInfo& info, const char* fn, bool cumulative
while ((lump = fileSystem.FindLumpFullName(fn, &lastlump)) >= 0) while ((lump = fileSystem.FindLumpFullName(fn, &lastlump)) >= 0)
{ {
if (maingame && fileSystem.GetFileContainer(lump) > fileSystem.GetMaxIwadNum()) break; if (maingame && fileSystem.GetFileContainer(lump) > fileSystem.GetMaxIwadNum()) break;
Printf(PRINT_NONOTIFY, "Loading \"%s\"\n", fileSystem.GetFileFullPath(lump).GetChars()); Printf(PRINT_NONOTIFY, "Loading \"%s\"\n", fileSystem.GetFileFullPath(lump).c_str());
deftimer.Clock(); deftimer.Clock();
parseit(lump); parseit(lump);
printtimer(fn); printtimer(fn);

View file

@ -145,7 +145,7 @@ FILE* hashfile;
InputState inputState; InputState inputState;
int ShowStartupWindow(TArray<GrpEntry> &); int ShowStartupWindow(TArray<GrpEntry> &);
TArray<FString> GetGameFronUserFiles(); std::vector<std::string> GetGameFronUserFiles();
void InitFileSystem(TArray<GrpEntry>&); void InitFileSystem(TArray<GrpEntry>&);
void I_SetWindowTitle(const char* caption); void I_SetWindowTitle(const char* caption);
void S_ParseSndInfo(); void S_ParseSndInfo();
@ -732,7 +732,7 @@ static TArray<GrpEntry> SetupGame()
int g = 0; int g = 0;
for (auto& grp : groups) for (auto& grp : groups)
{ {
if (grp.FileInfo.gameid.CompareNoCase(str) == 0) if (grp.FileInfo.gameid.CompareNoCase(str.c_str()) == 0)
{ {
userConfig.gamegrp = grp.FileName; userConfig.gamegrp = grp.FileName;
groupno = g; groupno = g;

View file

@ -60,10 +60,10 @@ static const char* validexts[] = { "*.grp", "*.zip", "*.pk3", "*.pk4", "*.7z", "
// //
//========================================================================== //==========================================================================
static TArray<FString> ParseGameInfo(TArray<FString>& pwads, const char* fn, const char* data, int size) static std::vector<std::string> ParseGameInfo(std::vector<std::string>& pwads, const char* fn, const char* data, int size)
{ {
FScanner sc; FScanner sc;
TArray<FString> bases; std::vector<std::string> bases;
int pos = 0; int pos = 0;
const char* lastSlash = strrchr(fn, '/'); const char* lastSlash = strrchr(fn, '/');
@ -78,7 +78,7 @@ static TArray<FString> ParseGameInfo(TArray<FString>& pwads, const char* fn, con
if (!nextKey.CompareNoCase("GAME")) if (!nextKey.CompareNoCase("GAME"))
{ {
sc.MustGetString(); sc.MustGetString();
bases.Push(sc.String); bases.push_back(sc.String);
} }
else if (!nextKey.CompareNoCase("LOAD")) else if (!nextKey.CompareNoCase("LOAD"))
{ {
@ -149,17 +149,17 @@ static TArray<FString> ParseGameInfo(TArray<FString>& pwads, const char* fn, con
// //
//========================================================================== //==========================================================================
static TArray<FString> CheckGameInfo(TArray<FString>& pwads) static std::vector<std::string> CheckGameInfo(std::vector<std::string>& pwads)
{ {
// scan the list of WADs backwards to find the last one that contains a GAMEINFO lump // scan the list of WADs backwards to find the last one that contains a GAMEINFO lump
for (int i = pwads.Size() - 1; i >= 0; i--) for (int i = (int)pwads.size() - 1; i >= 0; i--)
{ {
bool isdir = false; bool isdir = false;
FResourceFile* resfile; FResourceFile* resfile;
const char* filename = pwads[i]; const char* filename = pwads[i].c_str();
// Does this exist? If so, is it a directory? // Does this exist? If so, is it a directory?
if (!DirEntryExists(pwads[i], &isdir)) if (!DirEntryExists(pwads[i].c_str(), &isdir))
{ {
Printf(TEXTCOLOR_RED "Could not find %s\n", filename); Printf(TEXTCOLOR_RED "Could not find %s\n", filename);
continue; continue;
@ -197,7 +197,7 @@ static TArray<FString> CheckGameInfo(TArray<FString>& pwads)
delete resfile; delete resfile;
} }
} }
return TArray<FString>(); return std::vector<std::string>();
} }
//========================================================================== //==========================================================================
@ -206,9 +206,9 @@ static TArray<FString> CheckGameInfo(TArray<FString>& pwads)
// //
//========================================================================== //==========================================================================
TArray<FString> GetGameFronUserFiles() std::vector<std::string> GetGameFronUserFiles()
{ {
TArray<FString> Files; std::vector<std::string> Files;
if (userConfig.AddFilesPre) for (auto& file : *userConfig.AddFilesPre) if (userConfig.AddFilesPre) for (auto& file : *userConfig.AddFilesPre)
{ {
@ -229,13 +229,13 @@ TArray<FString> GetGameFronUserFiles()
if (DirEntryExists(fn, &isdir) && isdir) if (DirEntryExists(fn, &isdir) && isdir)
{ {
// Insert the GRPs before this entry itself. // Insert the GRPs before this entry itself.
FString lastfn; std::string lastfn = std::move(Files.back());
Files.Pop(lastfn); Files.pop_back();
for (auto ext : validexts) for (auto ext : validexts)
{ {
D_AddDirectory(Files, fn, ext, GameConfig); D_AddDirectory(Files, fn, ext, GameConfig);
} }
Files.Push(lastfn); Files.push_back(std::move(lastfn));
} }
} }
} }
@ -324,7 +324,7 @@ static int FileSystemPrintf(FSMessageLevel level, const char* fmt, ...)
void InitFileSystem(TArray<GrpEntry>& groups) void InitFileSystem(TArray<GrpEntry>& groups)
{ {
TArray<int> dependencies; TArray<int> dependencies;
TArray<FString> Files; std::vector<std::string> Files;
// First comes the engine's own stuff. // First comes the engine's own stuff.
const char* baseres = BaseFileSearch(ENGINERES_FILE, nullptr, true, GameConfig); const char* baseres = BaseFileSearch(ENGINERES_FILE, nullptr, true, GameConfig);
@ -369,7 +369,7 @@ void InitFileSystem(TArray<GrpEntry>& groups)
i--; i--;
} }
fileSystem.SetIwadNum(1); fileSystem.SetIwadNum(1);
fileSystem.SetMaxIwadNum(Files.Size() - 1); fileSystem.SetMaxIwadNum((int)Files.size() - 1);
D_AddConfigFiles(Files, "Global.Autoload", "*.grp", GameConfig); D_AddConfigFiles(Files, "Global.Autoload", "*.grp", GameConfig);
@ -402,13 +402,13 @@ void InitFileSystem(TArray<GrpEntry>& groups)
if (DirEntryExists(fname, &isdir) && isdir) if (DirEntryExists(fname, &isdir) && isdir)
{ {
// Insert the GRPs before this entry itself. // Insert the GRPs before this entry itself.
FString lastfn; std::string lastfn = std::move(Files.back());
Files.Pop(lastfn); Files.pop_back();
for (auto ext : validexts) for (auto ext : validexts)
{ {
D_AddDirectory(Files, fname, ext, GameConfig); D_AddDirectory(Files, fname, ext, GameConfig);
} }
Files.Push(lastfn); Files.push_back(std::move(lastfn));
} }
} }
} }

View file

@ -166,7 +166,7 @@ FileReader OpenMusic(const char* musicname)
{ {
Printf(TEXTCOLOR_RED "Unable to play music " TEXTCOLOR_WHITE "\"%s\"\n", musicname); Printf(TEXTCOLOR_RED "Unable to play music " TEXTCOLOR_WHITE "\"%s\"\n", musicname);
} }
else if (printmusicinfo) Printf("Playing music from file system %s:%s\n", fileSystem.GetResourceFileFullName(fileSystem.GetFileContainer(lumpnum)), fileSystem.GetFileFullPath(lumpnum).GetChars()); else if (printmusicinfo) Printf("Playing music from file system %s:%s\n", fileSystem.GetResourceFileFullName(fileSystem.GetFileContainer(lumpnum)), fileSystem.GetFileFullPath(lumpnum).c_str());
} }
} }
} }

View file

@ -102,7 +102,7 @@ void LoadVoxelModels()
if (voxmodels[i]) if (voxmodels[i])
voxmodels[i]->scale = voxscale[i]; voxmodels[i]->scale = voxscale[i];
else else
Printf("Unable to load voxel from %s\n", fileSystem.GetFileFullPath(lumpnum).GetChars()); Printf("Unable to load voxel from %s\n", fileSystem.GetFileFullPath(lumpnum).c_str());
} }
else else
{ {

View file

@ -65,12 +65,12 @@ void ParseScripts()
if (FScriptPosition::ErrorCounter > 0) if (FScriptPosition::ErrorCounter > 0)
{ {
// Abort if the compiler produced any errors. Also do not compile further lumps, because they very likely miss some stuff. // Abort if the compiler produced any errors. Also do not compile further lumps, because they very likely miss some stuff.
I_Error("%d errors, %d warnings while compiling %s", FScriptPosition::ErrorCounter, FScriptPosition::WarnCounter, fileSystem.GetFileFullPath(lump).GetChars()); I_Error("%d errors, %d warnings while compiling %s", FScriptPosition::ErrorCounter, FScriptPosition::WarnCounter, fileSystem.GetFileFullPath(lump).c_str());
} }
else if (FScriptPosition::WarnCounter > 0) else if (FScriptPosition::WarnCounter > 0)
{ {
// If we got warnings, but no errors, print the information but continue. // If we got warnings, but no errors, print the information but continue.
Printf(TEXTCOLOR_ORANGE "%d warnings while compiling %s\n", FScriptPosition::WarnCounter, fileSystem.GetFileFullPath(lump).GetChars()); Printf(TEXTCOLOR_ORANGE "%d warnings while compiling %s\n", FScriptPosition::WarnCounter, fileSystem.GetFileFullPath(lump).c_str());
} }
} }