From 48ba63c0226640d886a7f1c408e59ba06746fa5f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 3 Oct 2023 15:55:08 +0200 Subject: [PATCH] added even more explicit GetChars() calls. --- src/common/2d/v_2ddrawer.cpp | 2 +- src/common/audio/music/i_soundfont.cpp | 4 +- src/common/audio/sound/s_soundinternal.h | 5 ++ src/common/console/c_console.cpp | 10 +-- src/common/console/c_cvars.cpp | 16 ++--- src/common/console/c_dispatch.cpp | 30 ++++----- src/common/console/c_enginecmds.cpp | 6 +- src/common/engine/date.cpp | 2 +- src/common/fonts/font.cpp | 6 +- src/common/fonts/v_font.cpp | 6 +- src/common/models/model.cpp | 10 +-- src/common/platform/win32/i_specialpaths.cpp | 10 +-- .../postprocessing/hw_postprocess.cpp | 2 +- src/common/scripting/backend/vmbuilder.cpp | 4 +- src/common/scripting/frontend/zcc_compile.cpp | 2 +- src/common/scripting/frontend/zcc_parser.cpp | 4 +- src/common/scripting/interface/vmnatives.cpp | 26 ++++---- src/common/scripting/vm/vmexec.h | 2 +- src/common/utility/cmdlib.h | 4 ++ src/console/c_cmds.cpp | 38 +++++------ src/d_defcvars.cpp | 12 ++-- src/d_defcvars.h | 2 +- src/d_iwad.cpp | 26 ++++---- src/d_main.cpp | 65 +++++++++---------- src/d_net.cpp | 8 +-- src/g_game.cpp | 2 +- src/gamedata/d_dehacked.cpp | 20 +++--- src/gamedata/decallib.cpp | 12 ++-- src/gamedata/umapinfo.cpp | 4 +- src/maploader/maploader.h | 4 ++ src/maploader/udmf.cpp | 2 +- src/menu/doommenu.cpp | 6 +- src/playsim/fragglescript/t_func.cpp | 8 +-- src/playsim/fragglescript/t_load.cpp | 2 +- src/playsim/fragglescript/t_oper.cpp | 2 +- src/playsim/fragglescript/t_prepro.cpp | 2 +- src/playsim/fragglescript/t_script.h | 2 +- src/playsim/fragglescript/t_variable.cpp | 10 +-- src/scripting/vmthunks.cpp | 16 ++--- src/scripting/zscript/zcc_compile_doom.cpp | 8 +-- src/sound/s_doomsound.h | 4 ++ src/wi_stuff.cpp | 38 +++++------ 42 files changed, 230 insertions(+), 214 deletions(-) diff --git a/src/common/2d/v_2ddrawer.cpp b/src/common/2d/v_2ddrawer.cpp index d6cf06af04..e12c5a61ca 100644 --- a/src/common/2d/v_2ddrawer.cpp +++ b/src/common/2d/v_2ddrawer.cpp @@ -1249,7 +1249,7 @@ public: FCanvas* GetTextureCanvas(const FString& texturename) { - FTextureID textureid = TexMan.CheckForTexture(texturename, ETextureType::Wall, FTextureManager::TEXMAN_Overridable); + FTextureID textureid = TexMan.CheckForTexture(texturename.GetChars(), ETextureType::Wall, FTextureManager::TEXMAN_Overridable); if (textureid.isValid()) { // Only proceed if the texture is a canvas texture. diff --git a/src/common/audio/music/i_soundfont.cpp b/src/common/audio/music/i_soundfont.cpp index bac39d3a1e..dd610e0b42 100644 --- a/src/common/audio/music/i_soundfont.cpp +++ b/src/common/audio/music/i_soundfont.cpp @@ -316,7 +316,7 @@ FileReader FLumpPatchSetReader::OpenFile(const char *name) FString path; if (IsAbsPath(name)) return FileReader(); // no absolute paths in the lump directory. path = mBasePath + name; - auto index = fileSystem.CheckNumForFullName(path); + auto index = fileSystem.CheckNumForFullName(path.GetChars()); if (index < 0) return FileReader(); return fileSystem.ReopenFileReader(index); } @@ -426,7 +426,7 @@ void FSoundFontManager::CollectSoundfonts() if (soundfonts.Size() == 0) { - ProcessOneFile(NicePath("$PROGDIR/soundfonts/" GAMENAMELOWERCASE ".sf2")); + ProcessOneFile(NicePath("$PROGDIR/soundfonts/" GAMENAMELOWERCASE ".sf2").GetChars()); } } diff --git a/src/common/audio/sound/s_soundinternal.h b/src/common/audio/sound/s_soundinternal.h index d8c07742cd..cb38386a32 100644 --- a/src/common/audio/sound/s_soundinternal.h +++ b/src/common/audio/sound/s_soundinternal.h @@ -426,4 +426,9 @@ inline FSoundID S_FindSound(const char* name) return soundEngine->FindSound(name); } +inline FSoundID S_FindSound(const FString& name) +{ + return soundEngine->FindSound(name.GetChars()); +} + int SoundEnabled(); diff --git a/src/common/console/c_console.cpp b/src/common/console/c_console.cpp index c909592a5d..44c8ffacf6 100644 --- a/src/common/console/c_console.cpp +++ b/src/common/console/c_console.cpp @@ -295,7 +295,7 @@ void C_DeinitConsole () while (cmd != NULL) { GameAtExit *next = cmd->Next; - AddCommandString (cmd->Command); + AddCommandString (cmd->Command.GetChars()); delete cmd; cmd = next; } @@ -661,11 +661,11 @@ void C_DrawConsole () { if (textScale == 1) { - DrawText(twod, CurrentConsoleFont, CR_TAN, LEFTMARGIN, offset + lines * CurrentConsoleFont->GetHeight(), p->Text, TAG_DONE); + DrawText(twod, CurrentConsoleFont, CR_TAN, LEFTMARGIN, offset + lines * CurrentConsoleFont->GetHeight(), p->Text.GetChars(), TAG_DONE); } else { - DrawText(twod, CurrentConsoleFont, CR_TAN, LEFTMARGIN, offset + lines * CurrentConsoleFont->GetHeight(), p->Text, + DrawText(twod, CurrentConsoleFont, CR_TAN, LEFTMARGIN, offset + lines * CurrentConsoleFont->GetHeight(), p->Text.GetChars(), DTA_VirtualWidth, twod->GetWidth() / textScale, DTA_VirtualHeight, twod->GetHeight() / textScale, DTA_KeepRatio, true, TAG_DONE); @@ -1012,7 +1012,7 @@ static bool C_HandleKey (event_t *ev, FCommandBuffer &buffer) } HistPos = NULL; buffer.SetString(""); - AddCommandString(bufferText); + AddCommandString(bufferText.GetChars()); TabbedLast = false; TabbedList = false; break; @@ -1060,7 +1060,7 @@ static bool C_HandleKey (event_t *ev, FCommandBuffer &buffer) { // copy to clipboard if (buffer.TextLength() > 0) { - I_PutInClipboard(buffer.GetText()); + I_PutInClipboard(buffer.GetText().GetChars()); } } else diff --git a/src/common/console/c_cvars.cpp b/src/common/console/c_cvars.cpp index 0f92791b2c..e8d94acea3 100644 --- a/src/common/console/c_cvars.cpp +++ b/src/common/console/c_cvars.cpp @@ -209,12 +209,12 @@ FBaseCVar::~FBaseCVar () { FBaseCVar *var, *prev; - var = FindCVar (VarName, &prev); + var = FindCVar (VarName.GetChars(), &prev); if (var == this) { cvarMap.Remove(var->VarName); - C_RemoveTabCommand(VarName); + C_RemoveTabCommand(VarName.GetChars()); } } } @@ -864,27 +864,27 @@ ECVarType FStringCVar::GetRealType () const UCVarValue FStringCVar::GetGenericRep (ECVarType type) const { - return FromString (mValue, type); + return FromString (mValue.GetChars(), type); } UCVarValue FStringCVar::GetFavoriteRep (ECVarType *type) const { UCVarValue ret; *type = CVAR_String; - ret.String = mValue; + ret.String = mValue.GetChars(); return ret; } UCVarValue FStringCVar::GetGenericRepDefault (ECVarType type) const { - return FromString (mDefaultValue, type); + return FromString (mDefaultValue.GetChars(), type); } UCVarValue FStringCVar::GetFavoriteRepDefault (ECVarType *type) const { UCVarValue ret; *type = CVAR_String; - ret.String = mDefaultValue; + ret.String = mDefaultValue.GetChars(); return ret; } @@ -969,7 +969,7 @@ int FColorCVar::ToInt2 (UCVarValue value, ECVarType type) if (string.IsNotEmpty()) { - ret = V_GetColorFromString (string); + ret = V_GetColorFromString (string.GetChars()); } else { @@ -1394,7 +1394,7 @@ void C_RestoreCVars (void) { for (unsigned int i = 0; i < CVarBackups.Size(); ++i) { - cvar_set(CVarBackups[i].Name, CVarBackups[i].String); + cvar_set(CVarBackups[i].Name.GetChars(), CVarBackups[i].String.GetChars()); } C_ForgetCVars(); } diff --git a/src/common/console/c_dispatch.cpp b/src/common/console/c_dispatch.cpp index 7bac0b6987..8b6d738a02 100644 --- a/src/common/console/c_dispatch.cpp +++ b/src/common/console/c_dispatch.cpp @@ -79,7 +79,7 @@ public: if (--TicsLeft == 0) { UnsafeExecutionScope scope(IsUnsafe); - AddCommandString(Command); + AddCommandString(Command.GetChars()); return true; } return false; @@ -101,7 +101,7 @@ public: { if (Text.IsNotEmpty() && Command != nullptr) { - FCommandLine args(Text); + FCommandLine args(Text.GetChars()); Command->Run(args, 0); } return true; @@ -301,7 +301,7 @@ void C_DoCommand (const char *cmd, int keynum) } else { // Get the variable's value - if (var->GetDescription().Len()) Printf("%s\n", GStrings.localize(var->GetDescription())); + if (var->GetDescription().Len()) Printf("%s\n", GStrings.localize(var->GetDescription().GetChars())); Printf ("\"%s\" is \"%s\" ", var->GetName(), var->GetHumanString()); Printf ("(default: \"%s\")\n", var->GetHumanStringDefault()); } @@ -400,7 +400,7 @@ static FConsoleCommand *ScanChainForName (FConsoleCommand *start, const char *na *prev = NULL; while (start) { - comp = strnicmp (start->m_Name, name, namelen); + comp = start->m_Name.CompareNoCase(name, namelen); if (comp > 0) return NULL; else if (comp == 0 && start->m_Name[namelen] == 0) @@ -424,10 +424,10 @@ bool FConsoleCommand::AddToHash (FConsoleCommand **table) unsigned int key; FConsoleCommand *insert, **bucket; - key = MakeKey (m_Name); + key = MakeKey (m_Name.GetChars()); bucket = &table[key % HASH_SIZE]; - if (ScanChainForName (*bucket, m_Name, strlen (m_Name), &insert)) + if (ScanChainForName (*bucket, m_Name.GetChars(), m_Name.Len(), &insert)) { return false; } @@ -477,7 +477,7 @@ FConsoleCommand::~FConsoleCommand () *m_Prev = m_Next; if (m_Next) m_Next->m_Prev = m_Prev; - C_RemoveTabCommand (m_Name); + C_RemoveTabCommand (m_Name.GetChars()); } void FConsoleCommand::Run(FCommandLine &argv, int key) @@ -530,7 +530,7 @@ FString BuildString (int argc, FString *argv) { // It's an empty argument, we need to convert it to '""' buf << "\"\" "; } - else if (strchr(argv[arg], '"')) + else if (strchr(argv[arg].GetChars(), '"')) { // If it contains one or more quotes, we need to escape them. buf << '"'; ptrdiff_t substr_start = 0, quotepos; @@ -545,7 +545,7 @@ FString BuildString (int argc, FString *argv) } buf << argv[arg].Mid(substr_start) << "\" "; } - else if (strchr(argv[arg], ' ')) + else if (strchr(argv[arg].GetChars(), ' ')) { // If it contains a space, it needs to be quoted. buf << '"' << argv[arg] << "\" "; } @@ -674,7 +674,7 @@ static int DumpHash (FConsoleCommand **table, bool aliases, const char *pattern= cmd = table[bucket]; while (cmd) { - if (CheckWildcards (pattern, cmd->m_Name)) + if (CheckWildcards (pattern, cmd->m_Name.GetChars())) { if (cmd->IsAlias()) { @@ -712,8 +712,8 @@ void FConsoleAlias::Archive (FConfigFile *f) { if (f != NULL && !m_Command[0].IsEmpty()) { - f->SetValueForKey ("Name", m_Name, true); - f->SetValueForKey ("Command", m_Command[0], true); + f->SetValueForKey ("Name", m_Name.GetChars(), true); + f->SetValueForKey ("Command", m_Command[0].GetChars(), true); } } @@ -923,7 +923,7 @@ void FConsoleAlias::Run (FCommandLine &args, int key) } bRunning = true; - AddCommandString (mycommand, key); + AddCommandString (mycommand.GetChars(), key); bRunning = false; if (m_Command[index].IsEmpty()) { // The alias is unchanged, so put the command back so it can be used again. @@ -999,7 +999,7 @@ void FExecList::ExecCommands() const { for (unsigned i = 0; i < Commands.Size(); ++i) { - AddCommandString(Commands[i]); + AddCommandString(Commands[i].GetChars()); } } @@ -1007,7 +1007,7 @@ void FExecList::AddPullins(std::vector& wads, FConfigFile *config) { for (unsigned i = 0; i < Pullins.Size(); ++i) { - D_AddFile(wads, Pullins[i], true, -1, config); + D_AddFile(wads, Pullins[i].GetChars(), true, -1, config); } } diff --git a/src/common/console/c_enginecmds.cpp b/src/common/console/c_enginecmds.cpp index f6b8732de5..4911b9f444 100644 --- a/src/common/console/c_enginecmds.cpp +++ b/src/common/console/c_enginecmds.cpp @@ -189,11 +189,11 @@ UNSAFE_CCMD (dir) { path = I_GetCWD();; } - auto base = ExtractFileBase(path, true); + auto base = ExtractFileBase(path.GetChars(), true); FString bpath; if (base.IndexOfAny("*?") >= 0) { - bpath = ExtractFilePath(path); + bpath = ExtractFilePath(path.GetChars()); } else { @@ -202,7 +202,7 @@ UNSAFE_CCMD (dir) } FileSys::FileList list; - if (!FileSys::ScanDirectory(list, bpath, base, true)) + if (!FileSys::ScanDirectory(list, bpath.GetChars(), base.GetChars(), true)) { Printf ("Nothing matching %s\n", path.GetChars()); } diff --git a/src/common/engine/date.cpp b/src/common/engine/date.cpp index c409416f84..63e3776b7b 100644 --- a/src/common/engine/date.cpp +++ b/src/common/engine/date.cpp @@ -224,7 +224,7 @@ static void FormatTime(const FString& timeForm, int timeVal, FString* result) if (timeinfo != nullptr) { char timeString[1024]; - if (strftime(timeString, sizeof(timeString), timeForm, timeinfo)) + if (strftime(timeString, sizeof(timeString), timeForm.GetChars(), timeinfo)) *result = timeString; } } diff --git a/src/common/fonts/font.cpp b/src/common/fonts/font.cpp index 8b15428989..c12d254b1e 100644 --- a/src/common/fonts/font.cpp +++ b/src/common/fonts/font.cpp @@ -97,7 +97,7 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla FStringf path("fonts/%s/", filetemplate); // If a name template is given, collect data from all resource files. // For anything else, each folder is being treated as an atomic, self-contained unit and mixing from different glyph sets is blocked. - fileSystem.GetFilesInFolder(path, folderdata, nametemplate == nullptr); + fileSystem.GetFilesInFolder(path.GetChars(), folderdata, nametemplate == nullptr); //if (nametemplate == nullptr) { @@ -231,8 +231,8 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla // provide STCFN120 (x) and STCFN122 (z) for STCFN121 to load as a 'y'. FStringf c120(nametemplate, 120); FStringf c122(nametemplate, 122); - if (!TexMan.CheckForTexture(c120, ETextureType::MiscPatch).isValid() || - !TexMan.CheckForTexture(c122, ETextureType::MiscPatch).isValid()) + if (!TexMan.CheckForTexture(c120.GetChars(), ETextureType::MiscPatch).isValid() || + !TexMan.CheckForTexture(c122.GetChars(), ETextureType::MiscPatch).isValid()) { // insert the incorrectly named '|' graphic in its correct position. position = 124; diff --git a/src/common/fonts/v_font.cpp b/src/common/fonts/v_font.cpp index 591edb2089..f516a20911 100644 --- a/src/common/fonts/v_font.cpp +++ b/src/common/fonts/v_font.cpp @@ -113,7 +113,7 @@ FFont *V_GetFont(const char *name, const char *fontlumpname) FStringf path("fonts/%s/", name); // Use a folder-based font only if it comes from a later file than the single lump version. - if (fileSystem.GetFilesInFolder(path, folderdata, true)) + if (fileSystem.GetFilesInFolder(path.GetChars(), folderdata, true)) { // This assumes that any custom font comes in one piece and not distributed across multiple resource files. folderfile = fileSystem.GetFileContainer(folderdata[0].lumpnum); @@ -300,7 +300,7 @@ void V_InitCustomFonts() } if (format == 1) { - FFont *fnt = new FFont (namebuffer, templatebuf, nullptr, first, count, start, llump, spacewidth, donttranslate); + FFont *fnt = new FFont(namebuffer.GetChars(), templatebuf.GetChars(), nullptr, first, count, start, llump, spacewidth, donttranslate); fnt->SetCursor(cursor); fnt->SetKerning(kerning); if (ignoreoffsets) fnt->ClearOffsets(); @@ -326,7 +326,7 @@ void V_InitCustomFonts() if (count > 0) { FFont *CreateSpecialFont (const char *name, int first, int count, FGameTexture **lumplist, const bool *notranslate, int lump, bool donttranslate); - FFont *fnt = CreateSpecialFont (namebuffer, first, count, &lumplist[first], notranslate, llump, donttranslate); + FFont *fnt = CreateSpecialFont(namebuffer.GetChars(), first, count, &lumplist[first], notranslate, llump, donttranslate); fnt->SetCursor(cursor); fnt->SetKerning(kerning); if (spacewidth >= 0) fnt->SpaceWidth = spacewidth; diff --git a/src/common/models/model.cpp b/src/common/models/model.cpp index f8eb12febe..2df92a3700 100644 --- a/src/common/models/model.cpp +++ b/src/common/models/model.cpp @@ -89,7 +89,7 @@ void FModel::DestroyVertexBuffer() static int FindGFXFile(FString & fn) { - int lump = fileSystem.CheckNumForFullName(fn); // if we find something that matches the name plus the extension, return it and do not enter the substitution logic below. + int lump = fileSystem.CheckNumForFullName(fn.GetChars()); // if we find something that matches the name plus the extension, return it and do not enter the substitution logic below. if (lump != -1) return lump; int best = -1; @@ -101,7 +101,7 @@ static int FindGFXFile(FString & fn) for (const char ** extp=extensions; *extp; extp++) { - lump = fileSystem.CheckNumForFullName(fn + *extp); + lump = fileSystem.CheckNumForFullName((fn + *extp).GetChars()); if (lump >= best) best = lump; } return best; @@ -149,7 +149,7 @@ unsigned FindModel(const char * path, const char * modelfile, bool silent) if (path) fullname.Format("%s%s", path, modelfile); else fullname = modelfile; - int lump = fileSystem.CheckNumForFullName(fullname); + int lump = fileSystem.CheckNumForFullName(fullname.GetChars()); if (lump<0) { @@ -170,7 +170,7 @@ unsigned FindModel(const char * path, const char * modelfile, bool silent) { FString anivfile = fullname.GetChars(); anivfile.Substitute("_d.3d","_a.3d"); - if ( fileSystem.CheckNumForFullName(anivfile) > 0 ) + if ( fileSystem.CheckNumForFullName(anivfile.GetChars()) > 0 ) { model = new FUE1Model; } @@ -179,7 +179,7 @@ unsigned FindModel(const char * path, const char * modelfile, bool silent) { FString datafile = fullname.GetChars(); datafile.Substitute("_a.3d","_d.3d"); - if ( fileSystem.CheckNumForFullName(datafile) > 0 ) + if ( fileSystem.CheckNumForFullName(datafile.GetChars()) > 0 ) { model = new FUE1Model; } diff --git a/src/common/platform/win32/i_specialpaths.cpp b/src/common/platform/win32/i_specialpaths.cpp index 62e1766d47..8862024b78 100644 --- a/src/common/platform/win32/i_specialpaths.cpp +++ b/src/common/platform/win32/i_specialpaths.cpp @@ -91,7 +91,7 @@ bool IsPortable() // A portable INI means that this storage location should also be portable if the file can be written to. FStringf path("%s" GAMENAMELOWERCASE "_portable.ini", progdir.GetChars()); - if (FileExists(path.GetChars())) + if (FileExists(path)) { file = CreateFile(path.WideString().c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); @@ -217,7 +217,7 @@ FString M_GetOldConfigPath(int& type) } path << GAMENAMELOWERCASE "-" << FString(uname) << ".ini"; type = 0; - if (FileExists(path.GetChars())) + if (FileExists(path)) return path; } @@ -226,7 +226,7 @@ FString M_GetOldConfigPath(int& type) path = GetKnownFolder(CSIDL_APPDATA, FOLDERID_RoamingAppData, true); path += "/" GAME_DIR "/" GAMENAMELOWERCASE ".ini"; type = 1; - if (FileExists(path.GetChars())) + if (FileExists(path)) return path; return ""; @@ -285,7 +285,7 @@ FString M_GetConfigPath(bool for_reading) path += "/My Games/" GAME_DIR; CreatePath(path.GetChars()); path += "/" GAMENAMELOWERCASE ".ini"; - if (!for_reading || FileExists(path.GetChars())) + if (!for_reading || FileExists(path)) return path; // No config was found in the accepted locations. @@ -314,7 +314,7 @@ FString M_GetConfigPath(bool for_reading) // If we are reading the config file, check if it exists. If not, fallback to base version. if (for_reading) { - if (!FileExists(path.GetChars())) + if (!FileExists(path)) { path = progdir; path << GAMENAMELOWERCASE ".ini"; diff --git a/src/common/rendering/hwrenderer/postprocessing/hw_postprocess.cpp b/src/common/rendering/hwrenderer/postprocessing/hw_postprocess.cpp index 9cf1badb77..e339f92678 100644 --- a/src/common/rendering/hwrenderer/postprocessing/hw_postprocess.cpp +++ b/src/common/rendering/hwrenderer/postprocessing/hw_postprocess.cpp @@ -1013,7 +1013,7 @@ void PPCustomShaderInstance::SetTextures(PPRenderState *renderstate) while (it.NextPair(pair)) { FString name = pair->Value; - auto gtex = TexMan.GetGameTexture(TexMan.CheckForTexture(name, ETextureType::Any), true); + auto gtex = TexMan.GetGameTexture(TexMan.CheckForTexture(name.GetChars(), ETextureType::Any), true); if (gtex && gtex->isValid()) { // Why does this completely circumvent the normal way of handling textures? diff --git a/src/common/scripting/backend/vmbuilder.cpp b/src/common/scripting/backend/vmbuilder.cpp index ae34ea4c56..ffd29d4ddf 100644 --- a/src/common/scripting/backend/vmbuilder.cpp +++ b/src/common/scripting/backend/vmbuilder.cpp @@ -790,7 +790,7 @@ VMFunction *FFunctionBuildList::AddFunction(PNamespace *gnspc, const VersionInfo it.PrintableName = name; it.Function = new VMScriptFunction; it.Function->Name = functype->SymbolName; - it.Function->QualifiedName = it.Function->PrintableName = ClassDataAllocator.Strdup(name); + it.Function->QualifiedName = it.Function->PrintableName = ClassDataAllocator.Strdup(name.GetChars()); it.Function->ImplicitArgs = functype->GetImplicitArgs(); it.Proto = nullptr; it.FromDecorate = fromdecorate; @@ -1148,7 +1148,7 @@ void VMDisassemblyDumper::Write(VMScriptFunction *sfunc, const FString &fname) assert(sfunc != nullptr); - DumpFunction(dump, sfunc, fname, (int)fname.Len()); + DumpFunction(dump, sfunc, fname.GetChars(), (int)fname.Len()); codesize += sfunc->CodeSize; datasize += sfunc->LineInfoCount * sizeof(FStatementInfo) + sfunc->ExtraSpace + sfunc->NumKonstD * sizeof(int) + sfunc->NumKonstA * sizeof(void*) + sfunc->NumKonstF * sizeof(double) + sfunc->NumKonstS * sizeof(FString); diff --git a/src/common/scripting/frontend/zcc_compile.cpp b/src/common/scripting/frontend/zcc_compile.cpp index fb21526f1d..db69835f83 100644 --- a/src/common/scripting/frontend/zcc_compile.cpp +++ b/src/common/scripting/frontend/zcc_compile.cpp @@ -662,7 +662,7 @@ void ZCCCompiler::MessageV(ZCC_TreeNode *node, const char *txtcolor, const char composed.Format("%s%s, line %d: ", txtcolor, node->SourceName->GetChars(), node->SourceLoc); composed.VAppendFormat(msg, argptr); composed += '\n'; - PrintString(PRINT_HIGH, composed); + PrintString(PRINT_HIGH, composed.GetChars()); } //========================================================================== diff --git a/src/common/scripting/frontend/zcc_parser.cpp b/src/common/scripting/frontend/zcc_parser.cpp index 978006054a..6ba675744d 100644 --- a/src/common/scripting/frontend/zcc_parser.cpp +++ b/src/common/scripting/frontend/zcc_parser.cpp @@ -471,7 +471,7 @@ PNamespace *ParseOneScript(const int baselump, ZCCParseState &state) ParseSingleFile(&sc, nullptr, lumpnum, parser, state); for (unsigned i = 0; i < Includes.Size(); i++) { - lumpnum = fileSystem.CheckNumForFullName(Includes[i], true); + lumpnum = fileSystem.CheckNumForFullName(Includes[i].GetChars(), true); if (lumpnum == -1) { IncludeLocs[i].Message(MSG_ERROR, "Include script lump %s not found", Includes[i].GetChars()); @@ -518,7 +518,7 @@ PNamespace *ParseOneScript(const int baselump, ZCCParseState &state) FString filename = fileSystem.GetFileFullPath(baselump).c_str(); filename.ReplaceChars(":\\/?|", '.'); filename << ".ast"; - FileWriter *ff = FileWriter::Open(filename); + FileWriter *ff = FileWriter::Open(filename.GetChars()); if (ff != NULL) { ff->Write(ast.GetChars(), ast.Len()); diff --git a/src/common/scripting/interface/vmnatives.cpp b/src/common/scripting/interface/vmnatives.cpp index 350bf5ce33..daed2f091d 100644 --- a/src/common/scripting/interface/vmnatives.cpp +++ b/src/common/scripting/interface/vmnatives.cpp @@ -148,7 +148,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DStatusBarCore, DrawTexture, SBar_DrawTexture) void SBar_DrawImage(DStatusBarCore* self, const FString& texid, double x, double y, int flags, double alpha, double w, double h, double scaleX, double scaleY, int style, int color, int translation, double clipwidth) { if (!twod->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function"); - self->DrawGraphic(TexMan.CheckForTexture(texid, ETextureType::Any), x, y, flags, alpha, w, h, scaleX, scaleY, ERenderStyle(style), color, translation, clipwidth); + self->DrawGraphic(TexMan.CheckForTexture(texid.GetChars(), ETextureType::Any), x, y, flags, alpha, w, h, scaleX, scaleY, ERenderStyle(style), color, translation, clipwidth); } DEFINE_ACTION_FUNCTION_NATIVE(DStatusBarCore, DrawImage, SBar_DrawImage) @@ -174,7 +174,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DStatusBarCore, DrawImage, SBar_DrawImage) void SBar_DrawImageRotated(DStatusBarCore* self, const FString& texid, double x, double y, int flags, double angle, double alpha, double scaleX, double scaleY, int style, int color, int translation) { if (!twod->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function"); - self->DrawRotated(TexMan.CheckForTexture(texid, ETextureType::Any), x, y, flags, angle, alpha, scaleX, scaleY, color, translation, (ERenderStyle)style); + self->DrawRotated(TexMan.CheckForTexture(texid.GetChars(), ETextureType::Any), x, y, flags, angle, alpha, scaleX, scaleY, color, translation, (ERenderStyle)style); } DEFINE_ACTION_FUNCTION_NATIVE(DStatusBarCore, DrawImageRotated, SBar_DrawImageRotated) @@ -433,7 +433,7 @@ DEFINE_ACTION_FUNCTION(_TexMan, GetName) static int CheckForTexture(const FString& name, int type, int flags) { - return TexMan.CheckForTexture(name, static_cast(type), flags).GetIndex(); + return TexMan.CheckForTexture(name.GetChars(), static_cast(type), flags).GetIndex(); } DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, CheckForTexture, CheckForTexture) @@ -560,7 +560,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, CheckRealHeight, CheckRealHeight) static int OkForLocalization_(int index, const FString& substitute) { - return sysCallbacks.OkForLocalization? sysCallbacks.OkForLocalization(FSetTextureID(index), substitute) : false; + return sysCallbacks.OkForLocalization? sysCallbacks.OkForLocalization(FSetTextureID(index), substitute.GetChars()) : false; } DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, OkForLocalization, OkForLocalization_) @@ -788,14 +788,14 @@ DEFINE_ACTION_FUNCTION(_Wads, CheckNumForName) PARAM_INT(ns); PARAM_INT(wadnum); PARAM_BOOL(exact); - ACTION_RETURN_INT(fileSystem.CheckNumForName(name, ns, wadnum, exact)); + ACTION_RETURN_INT(fileSystem.CheckNumForName(name.GetChars(), ns, wadnum, exact)); } DEFINE_ACTION_FUNCTION(_Wads, CheckNumForFullName) { PARAM_PROLOGUE; PARAM_STRING(name); - ACTION_RETURN_INT(fileSystem.CheckNumForFullName(name)); + ACTION_RETURN_INT(fileSystem.CheckNumForFullName(name.GetChars())); } DEFINE_ACTION_FUNCTION(_Wads, FindLump) @@ -805,7 +805,7 @@ DEFINE_ACTION_FUNCTION(_Wads, FindLump) PARAM_INT(startlump); PARAM_INT(ns); const bool isLumpValid = startlump >= 0 && startlump < fileSystem.GetNumEntries(); - ACTION_RETURN_INT(isLumpValid ? fileSystem.FindLump(name, &startlump, 0 != ns) : -1); + ACTION_RETURN_INT(isLumpValid ? fileSystem.FindLump(name.GetChars(), &startlump, 0 != ns) : -1); } DEFINE_ACTION_FUNCTION(_Wads, FindLumpFullName) @@ -815,7 +815,7 @@ DEFINE_ACTION_FUNCTION(_Wads, FindLumpFullName) PARAM_INT(startlump); PARAM_BOOL(noext); const bool isLumpValid = startlump >= 0 && startlump < fileSystem.GetNumEntries(); - ACTION_RETURN_INT(isLumpValid ? fileSystem.FindLumpFullName(name, &startlump, noext) : -1); + ACTION_RETURN_INT(isLumpValid ? fileSystem.FindLumpFullName(name.GetChars(), &startlump, noext) : -1); } DEFINE_ACTION_FUNCTION(_Wads, GetLumpName) @@ -1023,7 +1023,7 @@ DEFINE_ACTION_FUNCTION(FKeyBindings, SetBind) } - self->SetBind(k, cmd); + self->SetBind(k, cmd.GetChars()); return 0; } @@ -1062,7 +1062,7 @@ DEFINE_ACTION_FUNCTION(FKeyBindings, GetAllKeysForCommand) PARAM_SELF_STRUCT_PROLOGUE(FKeyBindings); PARAM_POINTER(array, TArray); PARAM_STRING(cmd); - *array = self->GetKeysForCommand(cmd); + *array = self->GetKeysForCommand(cmd.GetChars()); return 0; } @@ -1084,7 +1084,7 @@ DEFINE_ACTION_FUNCTION(FKeyBindings, UnbindACommand) I_FatalError("Attempt to unbind key bindings for '%s' outside of menu code", cmd.GetChars()); } - self->UnbindACommand(cmd); + self->UnbindACommand(cmd.GetChars()); return 0; } @@ -1102,7 +1102,7 @@ DEFINE_ACTION_FUNCTION(DOptionMenuItemCommand, DoCommand) } UnsafeExecutionScope scope(unsafe); - AddCommandString(cmd); + AddCommandString(cmd.GetChars()); return 0; } @@ -1147,7 +1147,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_System, StopAllSounds, StopAllSounds) static int PlayMusic(const FString& musname, int order, int looped) { - return S_ChangeMusic(musname, order, !!looped, true); + return S_ChangeMusic(musname.GetChars(), order, !!looped, true); } DEFINE_ACTION_FUNCTION_NATIVE(_System, PlayMusic, PlayMusic) diff --git a/src/common/scripting/vm/vmexec.h b/src/common/scripting/vm/vmexec.h index 5ddac8bd45..f1e0cb2350 100644 --- a/src/common/scripting/vm/vmexec.h +++ b/src/common/scripting/vm/vmexec.h @@ -2117,7 +2117,7 @@ static void DoCast(const VMRegisters ®, const VMFrame *f, int a, int b, int c case CAST_S2Co: ASSERTD(a); ASSERTS(b); - reg.d[a] = V_GetColor(reg.s[b]); + reg.d[a] = V_GetColor(reg.s[b].GetChars()); break; case CAST_Co2S: diff --git a/src/common/utility/cmdlib.h b/src/common/utility/cmdlib.h index 6f40c184c6..6f5c6b584b 100644 --- a/src/common/utility/cmdlib.h +++ b/src/common/utility/cmdlib.h @@ -34,6 +34,10 @@ char(&_ArraySizeHelper(T(&array)[N]))[N]; #define myoffsetof(type,identifier) ((size_t)&((type *)alignof(type))->identifier - alignof(type)) bool FileExists (const char *filename); +inline bool FileExists(const FString& filename) +{ + return FileExists(filename.GetChars()); +} bool FileReadable (const char *filename); bool DirExists(const char *filename); bool DirEntryExists (const char *pathname, bool *isdir = nullptr); diff --git a/src/console/c_cmds.cpp b/src/console/c_cmds.cpp index 7743997d9e..71f9a40b5c 100644 --- a/src/console/c_cmds.cpp +++ b/src/console/c_cmds.cpp @@ -309,12 +309,12 @@ CCMD (idclev) // Catch invalid maps. mapname = CalcMapName (epsd, map); - if (!P_CheckMapData(mapname)) + if (!P_CheckMapData(mapname.GetChars())) return; // So be it. Printf ("%s\n", GStrings("STSTR_CLEV")); - G_DeferedInitNew (mapname); + G_DeferedInitNew (mapname.GetChars()); //players[0].health = 0; // Force reset } } @@ -334,11 +334,11 @@ CCMD (hxvisit) { // Just because it's in MAPINFO doesn't mean it's in the wad. - if (P_CheckMapData(mapname)) + if (P_CheckMapData(mapname.GetChars())) { // So be it. Printf ("%s\n", GStrings("STSTR_CLEV")); - G_DeferedInitNew (mapname); + G_DeferedInitNew (mapname.GetChars()); return; } } @@ -686,8 +686,8 @@ UNSAFE_CCMD (load) return; } #endif - fname = G_BuildSaveName(fname); - G_LoadGame (fname); + fname = G_BuildSaveName(fname.GetChars()); + G_LoadGame (fname.GetChars()); } //========================================================================== @@ -725,8 +725,8 @@ UNSAFE_CCMD(save) return; } #endif - fname = G_BuildSaveName(fname); - G_SaveGame (fname, argv.argc() > 2 ? argv[2] : argv[1]); + fname = G_BuildSaveName(fname.GetChars()); + G_SaveGame (fname.GetChars(), argv.argc() > 2 ? argv[2] : argv[1]); } @@ -971,7 +971,7 @@ CCMD(nextmap) if (primaryLevel->NextMap.Len() > 0 && primaryLevel->NextMap.Compare("enDSeQ", 6)) { - G_DeferedInitNew(primaryLevel->NextMap); + G_DeferedInitNew(primaryLevel->NextMap.GetChars()); } else { @@ -995,7 +995,7 @@ CCMD(nextsecret) if (primaryLevel->NextSecretMap.Len() > 0 && primaryLevel->NextSecretMap.Compare("enDSeQ", 6)) { - G_DeferedInitNew(primaryLevel->NextSecretMap); + G_DeferedInitNew(primaryLevel->NextSecretMap.GetChars()); } else { @@ -1085,7 +1085,7 @@ static void PrintSecretString(const char *string, bool thislevel) CCMD(secret) { const char *mapname = argv.argc() < 2? primaryLevel->MapName.GetChars() : argv[1]; - bool thislevel = !stricmp(mapname, primaryLevel->MapName); + bool thislevel = !stricmp(mapname, primaryLevel->MapName.GetChars()); bool foundsome = false; int lumpno=fileSystem.CheckNumForName("SECRETS"); @@ -1105,13 +1105,13 @@ CCMD(secret) { if (readbuffer[0] == '[') { - inlevel = !strnicmp(readbuffer, maphdr, maphdr.Len()); + inlevel = !strnicmp(readbuffer, maphdr.GetChars(), maphdr.Len()); if (!foundsome) { FString levelname; level_info_t *info = FindLevelInfo(mapname); - const char* ln = info->LookupLevelName(); - levelname.Format("%s - %s", mapname, ln); + FString ln = info->LookupLevelName(); + levelname.Format("%s - %s", mapname, ln.GetChars()); Printf(TEXTCOLOR_YELLOW "%s\n", levelname.GetChars()); size_t llen = levelname.Len(); levelname = ""; @@ -1132,7 +1132,7 @@ CCMD(secret) // line complete so print it. linebuild.Substitute("\r", ""); linebuild.StripRight(" \t\n"); - PrintSecretString(linebuild, thislevel); + PrintSecretString(linebuild.GetChars(), thislevel); linebuild = ""; } } @@ -1209,11 +1209,11 @@ CCMD(idmus) map = CalcMapName(argv[1][0] - '0', argv[1][1] - '0'); } - if ((info = FindLevelInfo(map))) + if ((info = FindLevelInfo(map.GetChars()))) { if (info->Music.IsNotEmpty()) { - S_ChangeMusic(info->Music, info->musicorder); + S_ChangeMusic(info->Music.GetChars(), info->musicorder); Printf("%s\n", GStrings("STSTR_MUS")); } } @@ -1310,7 +1310,7 @@ CCMD (mapinfo) Printf(" LevelName: %s\n", myLevel->LookupLevelName().GetChars()); if (myLevel->AuthorName.IsNotEmpty()) - Printf(" AuthorName: %s\n", testlocalised(myLevel->AuthorName)); + Printf(" AuthorName: %s\n", testlocalised(myLevel->AuthorName.GetChars())); if (myLevel->levelnum) Printf(" LevelNum: %i\n", myLevel->levelnum); @@ -1322,7 +1322,7 @@ CCMD (mapinfo) Printf(" SecretNext: %s\n", myLevel->NextSecretMap.GetChars()); if (myLevel->Music.IsNotEmpty()) - Printf(" Music: %s%s\n", myLevel->Music[0] == '$'? "D_" : "", testlocalised(myLevel->Music)); + Printf(" Music: %s%s\n", myLevel->Music[0] == '$'? "D_" : "", testlocalised(myLevel->Music.GetChars())); Printf(" PixelStretch: %f\n", myLevel->pixelstretch); diff --git a/src/d_defcvars.cpp b/src/d_defcvars.cpp index d066647b2b..bcd8ad1940 100644 --- a/src/d_defcvars.cpp +++ b/src/d_defcvars.cpp @@ -81,17 +81,17 @@ void D_GrabCVarDefaults() CurrentFindCVar.ToLower(); // these two got renamed - if (strcmp(CurrentFindCVar, "gamma") == 0) + if (CurrentFindCVar.Compare("gamma") == 0) { CurrentFindCVar = "vid_gamma"; } - if (strcmp(CurrentFindCVar, "fullscreen") == 0) + if (CurrentFindCVar.Compare("fullscreen") == 0) { CurrentFindCVar = "vid_fullscreen"; } // this was removed - if (strcmp(CurrentFindCVar, "cd_drive") == 0) + if (CurrentFindCVar.Compare("cd_drive") == 0) break; } if (lumpversion < 221) @@ -100,9 +100,9 @@ void D_GrabCVarDefaults() // this one doesn't matter as much, since it depended on platform-specific values, // and is something the user should change anyhow, so, let's just throw this value // out. - if (strcmp(CurrentFindCVar, "mouse_sensitivity") == 0) + if (CurrentFindCVar.Compare("mouse_sensitivity") == 0) break; - if (strcmp(CurrentFindCVar, "m_noprescale") == 0) + if (CurrentFindCVar.Compare("m_noprescale") == 0) break; } @@ -132,7 +132,7 @@ void D_GrabCVarDefaults() SHOULD_BLACKLIST(anonstats_host) SHOULD_BLACKLIST(sentstats_hwr_done) - var = FindCVar(CurrentFindCVar, NULL); + var = FindCVar(CurrentFindCVar.GetChars(), NULL); if (blacklisted) { diff --git a/src/d_defcvars.h b/src/d_defcvars.h index 8bf3d7c185..caaca508ba 100644 --- a/src/d_defcvars.h +++ b/src/d_defcvars.h @@ -23,6 +23,6 @@ #define SHOULD_BLACKLIST(name) \ if (#name[0]==CurrentFindCVar[0]) \ - if (strcmp(CurrentFindCVar, #name) == 0) \ + if (CurrentFindCVar.Compare(#name) == 0) \ blacklisted = true; diff --git a/src/d_iwad.cpp b/src/d_iwad.cpp index ab562f283a..6cbde02f78 100644 --- a/src/d_iwad.cpp +++ b/src/d_iwad.cpp @@ -360,7 +360,7 @@ int FIWadManager::ScanIWAD (const char *iwad) if (full && strnicmp(full, "maps/", 5) == 0) { FString mapname(&full[5], strcspn(&full[5], ".")); - CheckFileName(mapname); + CheckFileName(mapname.GetChars()); } } } @@ -490,7 +490,7 @@ void FIWadManager::AddIWADCandidates(const char *dir) } for (auto &name : mIWadNames) { - if (!stricmp(name, entry.FileName.c_str())) + if (!name.CompareNoCase(entry.FileName.c_str())) { mFoundWads.Push(FFoundWadInfo{ entry.FilePath.c_str(), "", -1 }); } @@ -515,14 +515,14 @@ void FIWadManager::ValidateIWADs() for (auto &p : mFoundWads) { int index; - auto x = strrchr(p.mFullPath, '.'); + auto x = strrchr(p.mFullPath.GetChars(), '.'); if (x != nullptr && (!stricmp(x, ".iwad") || !stricmp(x, ".ipk3") || !stricmp(x, ".ipk7"))) { - index = CheckIWADInfo(p.mFullPath); + index = CheckIWADInfo(p.mFullPath.GetChars()); } else { - index = ScanIWAD(p.mFullPath); + index = ScanIWAD(p.mFullPath.GetChars()); } p.mInfoIndex = index; } @@ -561,7 +561,7 @@ int FIWadManager::IdentifyVersion (std::vector&wadfiles, const char // Collect all IWADs in the search path for (auto &dir : mSearchPaths) { - AddIWADCandidates(dir); + AddIWADCandidates(dir.GetChars()); } unsigned numFoundWads = mFoundWads.Size(); @@ -608,7 +608,7 @@ int FIWadManager::IdentifyVersion (std::vector&wadfiles, const char // Check for symbolic links leading to non-existent files and for files that are unreadable. for (unsigned int i = 0; i < mFoundWads.Size(); i++) { - if (!FileExists(mFoundWads[i].mFullPath) || !FileReadable(mFoundWads[i].mFullPath)) mFoundWads.Delete(i--); + if (!FileExists(mFoundWads[i].mFullPath) || !FileReadable(mFoundWads[i].mFullPath.GetChars())) mFoundWads.Delete(i--); } // Now check if what got collected actually is an IWAD. @@ -729,7 +729,7 @@ int FIWadManager::IdentifyVersion (std::vector&wadfiles, const char for (unsigned i = 0; i < picks.Size(); ++i) { FString &basename = mIWadInfos[picks[i].mInfoIndex].Name; - if (stricmp(basename, defaultiwad) == 0) + if (basename.CompareNoCase(defaultiwad) == 0) { pick = i; break; @@ -745,7 +745,7 @@ int FIWadManager::IdentifyVersion (std::vector&wadfiles, const char { WadStuff stuff; stuff.Name = mIWadInfos[found.mInfoIndex].Name; - stuff.Path = ExtractFileBase(found.mFullPath); + stuff.Path = ExtractFileBase(found.mFullPath.GetChars()); wads.Push(stuff); } int flags = 0;; @@ -764,7 +764,7 @@ int FIWadManager::IdentifyVersion (std::vector&wadfiles, const char autoloadwidescreen = !!(flags & 8); // The newly selected IWAD becomes the new default - defaultiwad = mIWadInfos[picks[pick].mInfoIndex].Name; + defaultiwad = mIWadInfos[picks[pick].mInfoIndex].Name.GetChars(); } else { @@ -789,10 +789,10 @@ int FIWadManager::IdentifyVersion (std::vector&wadfiles, const char fileSystem.SetIwadNum(iwadnum); if (picks[pick].mRequiredPath.IsNotEmpty()) { - D_AddFile (wadfiles, picks[pick].mRequiredPath, true, -1, GameConfig); + D_AddFile (wadfiles, picks[pick].mRequiredPath.GetChars(), true, -1, GameConfig); iwadnum++; } - D_AddFile (wadfiles, picks[pick].mFullPath, true, -1, GameConfig); + D_AddFile (wadfiles, picks[pick].mFullPath.GetChars(), true, -1, GameConfig); fileSystem.SetMaxIwadNum(iwadnum); auto info = mIWadInfos[picks[pick].mInfoIndex]; @@ -813,7 +813,7 @@ int FIWadManager::IdentifyVersion (std::vector&wadfiles, const char path = FString(picks[pick].mFullPath.GetChars(), lastslash + 1); } path += info.Load[i]; - D_AddFile(wadfiles, path, true, -1, GameConfig); + D_AddFile(wadfiles, path.GetChars(), true, -1, GameConfig); } else { diff --git a/src/d_main.cpp b/src/d_main.cpp index e34b59459c..cf1d7785ca 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -277,7 +277,7 @@ CUSTOM_CVAR (String, vid_cursor, "None", CVAR_ARCHIVE | CVAR_NOINITCALL) if (!stricmp(self, "None" ) && gameinfo.CursorPic.IsNotEmpty()) { - res = I_SetCursor(TexMan.GetGameTextureByName(gameinfo.CursorPic)); + res = I_SetCursor(TexMan.GetGameTextureByName(gameinfo.CursorPic.GetChars())); } else { @@ -1082,7 +1082,7 @@ void D_Display () } if ( !skip ) { - auto tex = TexMan.GetGameTextureByName(gameinfo.PauseSign, true); + auto tex = TexMan.GetGameTextureByName(gameinfo.PauseSign.GetChars(), true); double x = (SCREENWIDTH - tex->GetDisplayWidth() * CleanXfac)/2 + tex->GetDisplayLeftOffset() * CleanXfac; DrawTexture(twod, tex, x, 4, DTA_CleanNoMove, true, TAG_DONE); @@ -1093,7 +1093,7 @@ void D_Display () pstring.Substitute("%s", players[paused - 1].userinfo.GetName()); DrawText(twod, font, CR_RED, (twod->GetWidth() - font->StringWidth(pstring)*CleanXfac) / 2, - (tex->GetDisplayHeight() * CleanYfac) + 4, pstring, DTA_CleanNoMove, true, TAG_DONE); + (tex->GetDisplayHeight() * CleanYfac) + 4, pstring.GetChars(), DTA_CleanNoMove, true, TAG_DONE); } } } @@ -1515,7 +1515,7 @@ void D_DoAdvanceDemo (void) gamestate = GS_DEMOSCREEN; pagename = gameinfo.TitlePage; pagetic = (int)(gameinfo.titleTime * TICRATE); - if (!playedtitlemusic) S_ChangeMusic (gameinfo.titleMusic, gameinfo.titleOrder, false); + if (!playedtitlemusic) S_ChangeMusic (gameinfo.titleMusic.GetChars(), gameinfo.titleOrder, false); playedtitlemusic = true; demosequence = 3; pagecount = 0; @@ -1537,7 +1537,7 @@ void D_DoAdvanceDemo (void) if (pagename.IsNotEmpty()) { - Page = TexMan.CheckForTexture(pagename, ETextureType::MiscPatch); + Page = TexMan.CheckForTexture(pagename.GetChars(), ETextureType::MiscPatch); } } @@ -1716,7 +1716,7 @@ void ParseCVarInfo() } } // Now create the cvar. - cvar = customCVar ? C_CreateZSCustomCVar(cvarname, cvartype, cvarflags, customCVarClassName) : C_CreateCVar(cvarname, cvartype, cvarflags); + cvar = customCVar ? C_CreateZSCustomCVar(cvarname.GetChars(), cvartype, cvarflags, customCVarClassName) : C_CreateCVar(cvarname.GetChars(), cvartype, cvarflags); if (cvardefault != NULL) { UCVarValue val; @@ -1732,7 +1732,7 @@ void ParseCVarInfo() // clutter up the cvar space when not playing mods with custom cvars. if (addedcvars) { - GameConfig->DoModSetup (gameinfo.ConfigName); + GameConfig->DoModSetup (gameinfo.ConfigName.GetChars()); } } @@ -1753,8 +1753,8 @@ bool ConsiderPatches (const char *arg) argc = Args->CheckParmList(arg, &args); for (i = 0; i < argc; ++i) { - if ( (f = BaseFileSearch(args[i], ".deh", false, GameConfig)) || - (f = BaseFileSearch(args[i], ".bex", false, GameConfig)) ) + if ( (f = BaseFileSearch(args[i].GetChars(), ".deh", false, GameConfig)) || + (f = BaseFileSearch(args[i].GetChars(), ".bex", false, GameConfig)) ) { D_LoadDehFile(f); } @@ -1785,7 +1785,7 @@ static void GetCmdLineFiles(std::vector& wadfiles) argc = Args->CheckParmList("-file", &args); for (i = 0; i < argc; ++i) { - D_AddWildFile(wadfiles, args[i], ".wad", GameConfig); + D_AddWildFile(wadfiles, args[i].GetChars(), ".wad", GameConfig); } } @@ -1830,13 +1830,13 @@ static FString ParseGameInfo(std::vector &pwads, const char *fn, co { checkpath = sc.String; } - if (!DirEntryExists(checkpath, &isDir)) + if (!DirEntryExists(checkpath.GetChars(), &isDir)) { pos += D_AddFile(pwads, sc.String, true, pos, GameConfig); } else { - pos += D_AddFile(pwads, checkpath, true, pos, GameConfig); + pos += D_AddFile(pwads, checkpath.GetChars(), true, pos, GameConfig); } } while (sc.CheckToken(',')); @@ -2037,7 +2037,7 @@ static void AddAutoloadFiles(const char *autoname, std::vector& all file = progdir; #endif file += "skins"; - D_AddDirectory (allwads, file, "*.wad", GameConfig); + D_AddDirectory (allwads, file.GetChars(), "*.wad", GameConfig); #ifdef __unix__ file = NicePath("$HOME/" GAME_DIR "/skins"); @@ -2053,7 +2053,7 @@ static void AddAutoloadFiles(const char *autoname, std::vector& all while ((len = LumpFilterIWAD.IndexOf('.', lastpos+1)) > 0) { file = LumpFilterIWAD.Left(len) + ".Autoload"; - D_AddConfigFiles(allwads, file, "*.wad", GameConfig); + D_AddConfigFiles(allwads, file.GetChars(), "*.wad", GameConfig); lastpos = len; } } @@ -2140,7 +2140,7 @@ static void CheckCmdLine() FString mapvalue = Args->TakeValue("+map"); if (mapvalue.IsNotEmpty()) { - if (!P_CheckMapData(mapvalue)) + if (!P_CheckMapData(mapvalue.GetChars())) { Printf ("Can't find map %s\n", mapvalue.GetChars()); } @@ -2192,9 +2192,8 @@ static void CheckCmdLine() StartScreen->AppendStatusLine("Respawning..."); if (autostart) { - FString temp; - temp.Format ("Warp to map %s, Skill %d ", startmap.GetChars(), gameskill + 1); - StartScreen->AppendStatusLine(temp); + FStringf temp("Warp to map %s, Skill %d ", startmap.GetChars(), gameskill + 1); + StartScreen->AppendStatusLine(temp.GetChars()); } } @@ -3117,15 +3116,15 @@ static int D_InitGame(const FIWADInfo* iwad_info, std::vector& allw FRandom::StaticClearRandom (); FBaseCVar::DisableCallbacks(); - GameConfig->DoGameSetup (gameinfo.ConfigName); + GameConfig->DoGameSetup (gameinfo.ConfigName.GetChars()); - AddAutoloadFiles(iwad_info->Autoname, allwads); + AddAutoloadFiles(iwad_info->Autoname.GetChars(), allwads); // Process automatically executed files FExecList *exec; FArgs *execFiles = new FArgs; if (!(Args->CheckParm("-noautoexec"))) - GameConfig->AddAutoexec(execFiles, gameinfo.ConfigName); + GameConfig->AddAutoexec(execFiles, gameinfo.ConfigName.GetChars()); exec = D_MultiExec(execFiles, NULL); delete execFiles; @@ -3145,7 +3144,7 @@ static int D_InitGame(const FIWADInfo* iwad_info, std::vector& allw if (!batchrun) Printf ("W_Init: Init WADfiles.\n"); LumpFilterInfo lfi; - lfi.dotFilter = LumpFilterIWAD; + lfi.dotFilter = LumpFilterIWAD.GetChars(); static const struct { int match; const char* name; } blanket[] = { @@ -3208,7 +3207,7 @@ static int D_InitGame(const FIWADInfo* iwad_info, std::vector& allw StartScreen = nostartscreen? nullptr : GetGameStartScreen(per_shader_progress > 0 ? max_progress * 10 / 9 : max_progress + 3); - GameConfig->DoKeySetup(gameinfo.ConfigName); + GameConfig->DoKeySetup(gameinfo.ConfigName.GetChars()); // Now that wads are loaded, define mod-specific cvars. ParseCVarInfo(); @@ -3312,7 +3311,7 @@ static int D_InitGame(const FIWADInfo* iwad_info, std::vector& allw }, CheckForHacks, InitBuildTiles); PatchTextures(); TexAnim.Init(); - C_InitConback(TexMan.CheckForTexture(gameinfo.BorderFlat, ETextureType::Flat), true, 0.25); + C_InitConback(TexMan.CheckForTexture(gameinfo.BorderFlat.GetChars(), ETextureType::Flat), true, 0.25); FixWideStatusBar(); @@ -3521,7 +3520,7 @@ static int D_InitGame(const FIWADInfo* iwad_info, std::vector& allw { I_FatalError("Cannot find savegame %s", file.GetChars()); } - G_LoadGame(file); + G_LoadGame(file.GetChars()); } v = Args->CheckValue("-playdemo"); @@ -3550,11 +3549,11 @@ static int D_InitGame(const FIWADInfo* iwad_info, std::vector& allw } CheckWarpTransMap(startmap, true); if (demorecording) - G_BeginRecording(startmap); - G_InitNew(startmap, false); + G_BeginRecording(startmap.GetChars()); + G_InitNew(startmap.GetChars(), false); if (StoredWarp.IsNotEmpty()) { - AddCommandString(StoredWarp); + AddCommandString(StoredWarp.GetChars()); StoredWarp = ""; } } @@ -3670,7 +3669,7 @@ static int D_DoomMain_Internal (void) FString logfile = Args->TakeValue("+logfile"); if (logfile.IsNotEmpty()) { - execLogfile(logfile); + execLogfile(logfile.GetChars()); } else if (batchout != NULL && *batchout != 0) { @@ -3694,7 +3693,7 @@ static int D_DoomMain_Internal (void) FString optionalwad = BaseFileSearch(OPTIONALWAD, NULL, true, GameConfig); - iwad_man = new FIWadManager(basewad, optionalwad); + iwad_man = new FIWadManager(basewad.GetChars(), optionalwad.GetChars()); // Now that we have the IWADINFO, initialize the autoload ini sections. GameConfig->DoAutoloadSetup(iwad_man); @@ -3714,7 +3713,7 @@ static int D_DoomMain_Internal (void) if (iwad_man == NULL) { - iwad_man = new FIWadManager(basewad, optionalwad); + iwad_man = new FIWadManager(basewad.GetChars(), optionalwad.GetChars()); } // Load zdoom.pk3 alone so that we can get access to the internal gameinfos before @@ -3730,7 +3729,7 @@ static int D_DoomMain_Internal (void) std::vector allwads; - const FIWADInfo *iwad_info = iwad_man->FindIWAD(allwads, iwad, basewad, optionalwad); + const FIWADInfo *iwad_info = iwad_man->FindIWAD(allwads, iwad.GetChars(), basewad.GetChars(), optionalwad.GetChars()); if (!iwad_info) return 0; // user exited the selection popup via cancel button. if ((iwad_info->flags & GI_SHAREWARE) && pwads.size() > 0) { @@ -3955,7 +3954,7 @@ void I_UpdateWindowTitle() // Strip out any color escape sequences before setting a window title TArray copy(titlestr.Len() + 1); - const char* srcp = titlestr; + const char* srcp = titlestr.GetChars(); char* dstp = copy.Data(); while (*srcp != 0) diff --git a/src/d_net.cpp b/src/d_net.cpp index 4f86f0da40..c98f2b1e9d 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -1535,7 +1535,7 @@ bool DoArbitrate (void *userdata) netbuffer[1] = (uint8_t)doomcom.ticdup; netbuffer[2] = NetMode; stream = &netbuffer[3]; - WriteString (startmap, &stream); + WriteString (startmap.GetChars(), &stream); WriteLong (rngseed, &stream); C_WriteCVars (&stream, CVAR_SERVERINFO, true); @@ -2452,8 +2452,8 @@ void Net_DoCommand (int type, uint8_t **stream, int player) { // Paths sent over the network will be valid for the system that sent // the save command. For other systems, the path needs to be changed. - FString basename = ExtractFileBase(savegamefile, true); - savegamefile = G_BuildSaveName (basename); + FString basename = ExtractFileBase(savegamefile.GetChars(), true); + savegamefile = G_BuildSaveName (basename.GetChars()); } } gameaction = ga_savegame; @@ -2732,7 +2732,7 @@ static void RunScript(uint8_t **stream, AActor *pawn, int snum, int argn, int al arg[i] = argval; } } - P_StartScript(pawn->Level, pawn, NULL, snum, primaryLevel->MapName, arg, min(countof(arg), argn), ACS_NET | always); + P_StartScript(pawn->Level, pawn, NULL, snum, primaryLevel->MapName.GetChars(), arg, min(countof(arg), argn), ACS_NET | always); } void Net_SkipCommand (int type, uint8_t **stream) diff --git a/src/g_game.cpp b/src/g_game.cpp index f68fca2257..2d69009e8d 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1723,7 +1723,7 @@ void FLevelLocals::DoReborn (int playernum, bool freshbot) if (!multiplayer && !(flags2 & LEVEL2_ALLOWRESPAWN) && !sv_singleplayerrespawn && !G_SkillProperty(SKILLP_PlayerRespawn)) { - if (BackupSaveName.Len() > 0 && FileExists (BackupSaveName.GetChars())) + if (BackupSaveName.Len() > 0 && FileExists (BackupSaveName)) { // Load game from the last point it was saved savename = BackupSaveName; gameaction = ga_autoloadgame; diff --git a/src/gamedata/d_dehacked.cpp b/src/gamedata/d_dehacked.cpp index 3ba05e8335..31f2d7137f 100644 --- a/src/gamedata/d_dehacked.cpp +++ b/src/gamedata/d_dehacked.cpp @@ -154,7 +154,7 @@ static FSoundID DehFindSound(int index,bool mustexist = false) if (index < 0) return NO_SOUND; if (index < (int) SoundMap.Size()) return SoundMap[index]; FStringf name("~dsdhacked/#%d", index); - if (dsdhacked && !mustexist) return soundEngine->FindSoundTentative(name); + if (dsdhacked && !mustexist) return soundEngine->FindSoundTentative(name.GetChars()); return NO_SOUND; } @@ -165,7 +165,7 @@ static void ReplaceSoundName(int index, const char* newname) if (snd == NO_SOUND) return; auto sfx = soundEngine->GetWritableSfx(snd); FStringf dsname("ds%s", newname); - sfx->lumpnum = fileSystem.CheckNumForName(dsname, FileSys::ns_sounds); + sfx->lumpnum = fileSystem.CheckNumForName(dsname.GetChars(), FileSys::ns_sounds); sfx->bTentative = false; sfx->bRandomHeader = false; sfx->bLoadRAW = false; @@ -1118,7 +1118,7 @@ static void SetDehParams(FState *state, int codepointer, VMDisassemblyDumper &di sfunc->NumArgs = numargs; sfunc->ImplicitArgs = numargs; state->SetAction(sfunc); - sfunc->PrintableName = ClassDataAllocator.Strdup(FStringf("Dehacked.%s.%d.%d", MBFCodePointers[codepointer].name.GetChars(), value1, value2)); + sfunc->PrintableName = ClassDataAllocator.Strdup(FStringf("Dehacked.%s.%d.%d", MBFCodePointers[codepointer].name.GetChars(), value1, value2).GetChars()); disasmdump.Write(sfunc, sfunc->PrintableName); @@ -2939,7 +2939,7 @@ static int PatchSoundNames (int dummy) { stripwhite(Line2); FString newname = skipwhite (Line2); - ReplaceSoundName((int)strtoll(Line1, nullptr, 10), newname); + ReplaceSoundName((int)strtoll(Line1, nullptr, 10), newname.GetChars()); DPrintf (DMSG_SPAMMY, "Sound %d set to:\n%s\n", Line1, newname.GetChars()); } @@ -2972,7 +2972,7 @@ static int PatchSpriteNames (int dummy) OrgSprNames[o] = nulname; } } - int v = GetSpriteIndex(newname); + int v = GetSpriteIndex(newname.GetChars()); memcpy(OrgSprNames[line1val].c, sprites[v].name, 5); DPrintf (DMSG_SPAMMY, "Sprite %d set to:\n%s\n", Line1, newname.GetChars()); @@ -3028,15 +3028,15 @@ static int DoInclude (int dummy) // Try looking for the included file in the same directory // as the patch before looking in the current file. - const char *lastSlash = strrchr(savepatchname, '/'); + const char *lastSlash = strrchr(savepatchname.GetChars(), '/'); char *path = data; if (lastSlash != NULL) { - size_t pathlen = lastSlash - savepatchname + strlen (data) + 2; + size_t pathlen = lastSlash - savepatchname.GetChars() + strlen (data) + 2; path = new char[pathlen]; - strncpy (path, savepatchname, (lastSlash - savepatchname) + 1); - strcpy (path + (lastSlash - savepatchname) + 1, data); + strncpy (path, savepatchname.GetChars(), (lastSlash - savepatchname.GetChars()) + 1); + strcpy (path + (lastSlash - savepatchname.GetChars()) + 1, data); if (!FileExists (path)) { delete[] path; @@ -3171,7 +3171,7 @@ bool D_LoadDehFile(const char *patchfile) // some WAD may need it. Should be deleted if it can // be confirmed that nothing uses this case. FString filebase(ExtractFileBase(patchfile)); - lumpnum = fileSystem.CheckNumForName(filebase); + lumpnum = fileSystem.CheckNumForName(filebase.GetChars()); } if (lumpnum >= 0) { diff --git a/src/gamedata/decallib.cpp b/src/gamedata/decallib.cpp index 961b63f30d..cb906fc068 100644 --- a/src/gamedata/decallib.cpp +++ b/src/gamedata/decallib.cpp @@ -376,7 +376,7 @@ void FDecalLib::ParseDecal (FScanner &sc) sc.MustGetString (); if (sc.Compare ("}")) { - AddDecal (decalName, decalNum, newdecal); + AddDecal(decalName.GetChars(), decalNum, newdecal); break; } switch (sc.MustMatchString (DecalKeywords)) @@ -577,7 +577,7 @@ void FDecalLib::ParseFader (FScanner &sc) sc.MustGetString (); if (sc.Compare ("}")) { - FDecalFaderAnim *fader = new FDecalFaderAnim (faderName); + FDecalFaderAnim *fader = new FDecalFaderAnim (faderName.GetChars()); fader->DecayStart = startTime; fader->DecayTime = decayTime; Animators.Push (fader); @@ -617,7 +617,7 @@ void FDecalLib::ParseStretcher (FScanner &sc) { if (goalX >= 0 || goalY >= 0) { - FDecalStretcherAnim *stretcher = new FDecalStretcherAnim (stretcherName); + FDecalStretcherAnim *stretcher = new FDecalStretcherAnim (stretcherName.GetChars()); stretcher->StretchStart = startTime; stretcher->StretchTime = takeTime; stretcher->GoalX = goalX; @@ -668,7 +668,7 @@ void FDecalLib::ParseSlider (FScanner &sc) { if ((/*distX |*/ distY) != 0) { - FDecalSliderAnim *slider = new FDecalSliderAnim (sliderName); + FDecalSliderAnim *slider = new FDecalSliderAnim (sliderName.GetChars()); slider->SlideStart = startTime; slider->SlideTime = takeTime; /*slider->DistX = distX;*/ @@ -719,7 +719,7 @@ void FDecalLib::ParseColorchanger (FScanner &sc) sc.MustGetString (); if (sc.Compare ("}")) { - FDecalColorerAnim *fader = new FDecalColorerAnim (faderName); + FDecalColorerAnim *fader = new FDecalColorerAnim (faderName.GetChars()); fader->DecayStart = startTime; fader->DecayTime = decayTime; fader->GoalColor = goal; @@ -772,7 +772,7 @@ void FDecalLib::ParseCombiner (FScanner &sc) if (last > first) { - FDecalCombinerAnim *combiner = new FDecalCombinerAnim (combinerName); + FDecalCombinerAnim *combiner = new FDecalCombinerAnim (combinerName.GetChars()); combiner->FirstAnimator = (int)first; combiner->NumAnimators = (int)(last - first); Animators.Push (combiner); diff --git a/src/gamedata/umapinfo.cpp b/src/gamedata/umapinfo.cpp index 006e4629af..bb442f78d0 100644 --- a/src/gamedata/umapinfo.cpp +++ b/src/gamedata/umapinfo.cpp @@ -230,7 +230,7 @@ static int ParseStandardProperty(FScanner &scanner, UMapEntry *mape) if (split.Size() > 1) { - epi.mEpisodeName = strbin1(split[1]); + epi.mEpisodeName = strbin1(split[1].GetChars()); } if (split.Size() > 2 && split[2].IsNotEmpty()) { @@ -389,7 +389,7 @@ void CommitUMapinfo(level_info_t *defaultinfo) { for (auto &map : Maps) { - auto levelinfo = FindLevelInfo(map.MapName, false); + auto levelinfo = FindLevelInfo(map.MapName.GetChars(), false); if (levelinfo == nullptr) { // Map did not exist yet. diff --git a/src/maploader/maploader.h b/src/maploader/maploader.h index 6ea2e6121f..8390aca041 100644 --- a/src/maploader/maploader.h +++ b/src/maploader/maploader.h @@ -212,6 +212,10 @@ private: void Spawn3DFloors (); void SetTexture(side_t *side, int position, const char *name, FMissingTextureTracker &track); + void SetTexture(side_t* side, int position, const FString& name, FMissingTextureTracker& track) + { + SetTexture(side, position, name.GetChars(), track); + } void SetTexture(sector_t *sector, int index, int position, const char *name, FMissingTextureTracker &track, bool truncate); void SetTexture(side_t *side, int position, uint32_t *blend, const char *name); void SetTextureNoErr(side_t *side, int position, uint32_t *color, const char *name, bool *validcolor, bool isFog); diff --git a/src/maploader/udmf.cpp b/src/maploader/udmf.cpp index d02ee237e2..e51a82433d 100644 --- a/src/maploader/udmf.cpp +++ b/src/maploader/udmf.cpp @@ -279,7 +279,7 @@ const char *UDMFParserBase::CheckString(FName key) { sc.ScriptMessage("String value expected for key '%s'", key.GetChars()); } - return parsedString; + return parsedString.GetChars(); } //=========================================================================== diff --git a/src/menu/doommenu.cpp b/src/menu/doommenu.cpp index 200dc90fc8..50857f76ab 100644 --- a/src/menu/doommenu.cpp +++ b/src/menu/doommenu.cpp @@ -221,7 +221,7 @@ bool M_SetSpecialMenu(FName& menu, int param) NewGameStartupInfo.Skill = param; LastSkill = param; - const char *msg = AllSkills[param].MustConfirmText; + const char *msg = AllSkills[param].MustConfirmText.GetChars(); if (*msg==0) msg = GStrings("NIGHTMARE"); M_StartMessage (msg, 0, NAME_StartgameConfirmed); return false; @@ -287,7 +287,7 @@ bool M_SetSpecialMenu(FName& menu, int param) { if ((*desc)->mNetgameMessage.IsNotEmpty() && netgame && !demoplayback) { - M_StartMessage((*desc)->mNetgameMessage, 1); + M_StartMessage((*desc)->mNetgameMessage.GetChars(), 1); return false; } } @@ -389,7 +389,7 @@ CCMD (menu_quit) const size_t messageindex = static_cast(gametic) % gameinfo.quitmessages.Size(); FString EndString; - const char *msg = gameinfo.quitmessages[messageindex]; + const char *msg = gameinfo.quitmessages[messageindex].GetChars(); if (msg[0] == '$') { if (msg[1] == '*') diff --git a/src/playsim/fragglescript/t_func.cpp b/src/playsim/fragglescript/t_func.cpp index fc711eac9f..28ff091c61 100644 --- a/src/playsim/fragglescript/t_func.cpp +++ b/src/playsim/fragglescript/t_func.cpp @@ -559,7 +559,7 @@ void FParser::SF_Include(void) { if(t_argv[0].type == svt_string) { - strncpy(tempstr, t_argv[0].string, 8); + strncpy(tempstr, t_argv[0].string.GetChars(), 8); tempstr[8]=0; } else @@ -1869,7 +1869,7 @@ void FParser::SF_FloorTexture(void) if(t_argc > 1) { int i = -1; - FTextureID picnum = TexMan.GetTextureID(t_argv[1].string, ETextureType::Flat, FTextureManager::TEXMAN_Overridable); + FTextureID picnum = TexMan.GetTextureID(t_argv[1].string.GetChars(), ETextureType::Flat, FTextureManager::TEXMAN_Overridable); // set all sectors with tag auto itr = Level->GetSectorTagIterator(tagnum); @@ -1959,7 +1959,7 @@ void FParser::SF_CeilingTexture(void) if(t_argc > 1) { int i = -1; - FTextureID picnum = TexMan.GetTextureID(t_argv[1].string, ETextureType::Flat, FTextureManager::TEXMAN_Overridable); + FTextureID picnum = TexMan.GetTextureID(t_argv[1].string.GetChars(), ETextureType::Flat, FTextureManager::TEXMAN_Overridable); // set all sectors with tag auto itr = Level->GetSectorTagIterator(tagnum); @@ -2229,7 +2229,7 @@ void FParser::SF_SetLineTexture(void) } else // and an improved legacy version { - FTextureID picnum = TexMan.GetTextureID(t_argv[1].string, ETextureType::Wall, FTextureManager::TEXMAN_Overridable); + FTextureID picnum = TexMan.GetTextureID(t_argv[1].string.GetChars(), ETextureType::Wall, FTextureManager::TEXMAN_Overridable); side = !!intvalue(t_argv[2]); int sections = intvalue(t_argv[3]); diff --git a/src/playsim/fragglescript/t_load.cpp b/src/playsim/fragglescript/t_load.cpp index efd27a070d..32518aa196 100644 --- a/src/playsim/fragglescript/t_load.cpp +++ b/src/playsim/fragglescript/t_load.cpp @@ -137,7 +137,7 @@ void FScriptLoader::ParseInfoCmd(char *line, FString &scriptsrc) sc.MustGetString(); if (!FS_ChangeMusic(sc.String)) { - S_ChangeMusic(Level->Music, Level->musicorder); + S_ChangeMusic(Level->Music.GetChars(), Level->musicorder); } } else if (sc.Compare("skyname")) diff --git a/src/playsim/fragglescript/t_oper.cpp b/src/playsim/fragglescript/t_oper.cpp index 8b4368db77..beac99d0eb 100644 --- a/src/playsim/fragglescript/t_oper.cpp +++ b/src/playsim/fragglescript/t_oper.cpp @@ -167,7 +167,7 @@ void FParser::OPcmp(svalue_t &result, int start, int n, int stop) if(left.type == svt_string && right.type == svt_string) { - result.value.i = !strcmp(left.string, right.string); + result.value.i = !strcmp(left.string.GetChars(), right.string.GetChars()); return; } diff --git a/src/playsim/fragglescript/t_prepro.cpp b/src/playsim/fragglescript/t_prepro.cpp index 495092581f..f5a8cee454 100644 --- a/src/playsim/fragglescript/t_prepro.cpp +++ b/src/playsim/fragglescript/t_prepro.cpp @@ -284,7 +284,7 @@ char *DFsScript::ProcessFindChar(char *datap, char find) Printf(PRINT_BOLD,"Script %d: ':' encountrered in incorrect position!\n",scriptnum); } - DFsVariable *newlabel = NewVariable(labelname, svt_label); + DFsVariable *newlabel = NewVariable(labelname.GetChars(), svt_label); newlabel->value.i = MakeIndex(labelptr); } diff --git a/src/playsim/fragglescript/t_script.h b/src/playsim/fragglescript/t_script.h index a809870780..7677786282 100644 --- a/src/playsim/fragglescript/t_script.h +++ b/src/playsim/fragglescript/t_script.h @@ -273,7 +273,7 @@ public: CFsError(const FString &in) { - strncpy(msg, in, 2047); + strncpy(msg, in.GetChars(), 2047); msg[2047]=0; } }; diff --git a/src/playsim/fragglescript/t_variable.cpp b/src/playsim/fragglescript/t_variable.cpp index 4244908052..f3ab238839 100644 --- a/src/playsim/fragglescript/t_variable.cpp +++ b/src/playsim/fragglescript/t_variable.cpp @@ -54,7 +54,7 @@ int intvalue(const svalue_t &v) { - return (v.type == svt_string ? atoi(v.string) : + return (v.type == svt_string ? atoi(v.string.GetChars()) : v.type == svt_fixed ? (int)(v.value.f / 65536.) : v.type == svt_mobj ? -1 : v.value.i ); } @@ -68,7 +68,7 @@ int intvalue(const svalue_t &v) fsfix fixedvalue(const svalue_t &v) { return (v.type == svt_fixed ? v.value.f : - v.type == svt_string ? (fsfix)(atof(v.string) * 65536.) : + v.type == svt_string ? (fsfix)(atof(v.string.GetChars()) * 65536.) : v.type == svt_mobj ? -65536 : v.value.i * 65536 ); } @@ -81,7 +81,7 @@ fsfix fixedvalue(const svalue_t &v) double floatvalue(const svalue_t &v) { return - v.type == svt_string ? atof(v.string) : + v.type == svt_string ? atof(v.string.GetChars()) : v.type == svt_fixed ? v.value.f / 65536. : v.type == svt_mobj ? -1. : (double)v.value.i; } @@ -99,7 +99,7 @@ const char *stringvalue(const svalue_t & v) switch(v.type) { case svt_string: - return v.string; + return v.string.GetChars(); case svt_mobj: // return the class name @@ -349,7 +349,7 @@ DFsVariable *DFsScript::VariableForName(const char *name) while(current) { - if(!strcmp(name, current->Name)) // found it? + if(!strcmp(name, current->Name.GetChars())) // found it? return current; current = current->next; // check next in chain } diff --git a/src/scripting/vmthunks.cpp b/src/scripting/vmthunks.cpp index 0ece588e56..3b7a1898ed 100644 --- a/src/scripting/vmthunks.cpp +++ b/src/scripting/vmthunks.cpp @@ -80,7 +80,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, SetCameraToTexture, SetCameraToTexture) static void SetCameraTextureAspectRatio(const FString &texturename, double aspectScale, bool useTextureRatio) { - FTextureID textureid = TexMan.CheckForTexture(texturename, ETextureType::Wall, FTextureManager::TEXMAN_Overridable); + FTextureID textureid = TexMan.CheckForTexture(texturename.GetChars(), ETextureType::Wall, FTextureManager::TEXMAN_Overridable); if (textureid.isValid()) { // Only proceed if the texture actually has a canvas. @@ -1026,7 +1026,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, SetXOffset, SetXOffset) static void SetEnvironment(sector_t *self, const FString &env) { - self->Level->Zones[self->ZoneNumber].Environment = S_FindEnvironment(env); + self->Level->Zones[self->ZoneNumber].Environment = S_FindEnvironment(env.GetChars()); } DEFINE_ACTION_FUNCTION_NATIVE(_Sector, SetEnvironment, SetEnvironment) @@ -1723,7 +1723,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, SetXOffset, SetXOffset) // This is needed to convert the strings to char pointers. static void ReplaceTextures(FLevelLocals *self, const FString &from, const FString &to, int flags) { - self->ReplaceTextures(from, to, flags); + self->ReplaceTextures(from.GetChars(), to.GetChars(), flags); } DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, ReplaceTextures, ReplaceTextures) @@ -1732,7 +1732,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, ReplaceTextures, ReplaceTextures) PARAM_STRING(from); PARAM_STRING(to); PARAM_INT(flags); - self->ReplaceTextures(from, to, flags); + self->ReplaceTextures(from.GetChars(), to.GetChars(), flags); return 0; } @@ -2097,7 +2097,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DBaseStatusBar, Draw, SBar_Draw) static void SetMugshotState(DBaseStatusBar *self, const FString &statename, bool wait, bool reset) { - self->mugshot.SetState(statename, wait, reset); + self->mugshot.SetState(statename.GetChars(), wait, reset); } DEFINE_ACTION_FUNCTION_NATIVE(DBaseStatusBar, SetMugshotState, SetMugshotState) @@ -2106,7 +2106,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DBaseStatusBar, SetMugshotState, SetMugshotState) PARAM_STRING(statename); PARAM_BOOL(wait); PARAM_BOOL(reset); - self->mugshot.SetState(statename, wait, reset); + self->mugshot.SetState(statename.GetChars(), wait, reset); return 0; } @@ -2201,7 +2201,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DBaseStatusBar, ReceivedWeapon, ReceivedWeapon) static int GetMugshot(DBaseStatusBar *self, int accuracy, int stateflags, const FString &def_face) { - auto tex = self->mugshot.GetFace(self->CPlayer, def_face, accuracy, (FMugShot::StateFlags)stateflags); + auto tex = self->mugshot.GetFace(self->CPlayer, def_face.GetChars(), accuracy, (FMugShot::StateFlags)stateflags); return (tex ? tex->GetID().GetIndex() : -1); } @@ -2614,7 +2614,7 @@ DEFINE_ACTION_FUNCTION(DObject, S_ChangeMusic) PARAM_INT(order); PARAM_BOOL(looping); PARAM_BOOL(force); - ACTION_RETURN_BOOL(S_ChangeMusic(music, order, looping, force)); + ACTION_RETURN_BOOL(S_ChangeMusic(music.GetChars(), order, looping, force)); } diff --git a/src/scripting/zscript/zcc_compile_doom.cpp b/src/scripting/zscript/zcc_compile_doom.cpp index 642fac09f6..d6b8780f93 100644 --- a/src/scripting/zscript/zcc_compile_doom.cpp +++ b/src/scripting/zscript/zcc_compile_doom.cpp @@ -650,7 +650,7 @@ void ZCCDoomCompiler::ProcessDefaultProperty(PClassActor *cls, ZCC_PropertyStmt } - FPropertyInfo *property = FindProperty(propname); + FPropertyInfo *property = FindProperty(propname.GetChars()); if (property != nullptr && property->category != CAT_INFO) { @@ -987,7 +987,7 @@ void ZCCDoomCompiler::CompileStates() { auto sl = static_cast(st); statename = FName(sl->Label).GetChars(); - statedef.AddStateLabel(statename); + statedef.AddStateLabel(statename.GetChars()); break; } case AST_StateLine: @@ -1046,7 +1046,7 @@ void ZCCDoomCompiler::CompileStates() auto l = sl->Lights; do { - AddStateLight(&state, StringConstFromNode(l, c->Type())); + AddStateLight(&state, StringConstFromNode(l, c->Type()).GetChars()); l = static_cast(l->SiblingNext); } while (l != sl->Lights); } @@ -1097,7 +1097,7 @@ void ZCCDoomCompiler::CompileStates() statename.AppendFormat("+%d", offset); } } - if (!statedef.SetGotoLabel(statename)) + if (!statedef.SetGotoLabel(statename.GetChars())) { Error(sg, "GOTO before first state"); } diff --git a/src/sound/s_doomsound.h b/src/sound/s_doomsound.h index b6c6dc3367..3dab94ace8 100644 --- a/src/sound/s_doomsound.h +++ b/src/sound/s_doomsound.h @@ -20,6 +20,10 @@ inline void S_Sound(int channel, EChanFlags flags, const char* sfxid, float volu { S_Sound(channel, flags, S_FindSound(sfxid), volume, attenuation); } +inline void S_Sound(int channel, EChanFlags flags, const FString& sfxid, float volume, float attenuation) +{ + S_Sound(channel, flags, S_FindSound(sfxid), volume, attenuation); +} void S_SoundPitch(int channel, EChanFlags flags, FSoundID sfxid, float volume, float attenuation, float pitch, float startTime = 0.f); diff --git a/src/wi_stuff.cpp b/src/wi_stuff.cpp index a37073a43c..dddc37c310 100644 --- a/src/wi_stuff.cpp +++ b/src/wi_stuff.cpp @@ -281,20 +281,20 @@ bool DInterBackground::LoadBackground(bool isenterpic) if (!isenterpic) tilebackground = false; texture.SetInvalid(); - level_info_t* li = FindLevelInfo(wbs->current); + level_info_t* li = FindLevelInfo(wbs->current.GetChars()); if (li != nullptr) { - exitpic = li->ExitPic; + exitpic = li->ExitPic.GetChars(); if (li->ExitPic.IsNotEmpty()) tilebackground = false; } lumpname = exitpic; if (isenterpic) { - level_info_t* li = FindLevelInfo(wbs->next); + level_info_t* li = FindLevelInfo(wbs->next.GetChars()); if (li != NULL) { - lumpname = li->EnterPic; + lumpname = li->EnterPic.GetChars(); if (li->EnterPic.IsNotEmpty()) tilebackground = false; } } @@ -309,7 +309,7 @@ bool DInterBackground::LoadBackground(bool isenterpic) case GAME_Doom: if (!(gameinfo.flags & GI_MAPxx)) { - const char* levelname = isenterpic ? wbs->next : wbs->current; + const char* levelname = isenterpic ? wbs->next.GetChars() : wbs->current.GetChars(); if (IsExMy(levelname)) { mysnprintf(buffer, countof(buffer), "$IN_EPI%c", levelname[1]); @@ -331,10 +331,10 @@ bool DInterBackground::LoadBackground(bool isenterpic) if (!(gameinfo.flags & GI_MAPxx)) { // not if the last level is not from the first 3 episodes - if (!IsExMy(wbs->current)) return false; + if (!IsExMy(wbs->current.GetChars())) return false; // not if the next level is one of the first 3 episodes - if (IsExMy(wbs->next)) return false; + if (IsExMy(wbs->next.GetChars())) return false; } } lumpname = "INTERPIC"; @@ -345,7 +345,7 @@ bool DInterBackground::LoadBackground(bool isenterpic) case GAME_Heretic: if (isenterpic) { - if (IsExMy(wbs->next)) + if (IsExMy(wbs->next.GetChars())) { mysnprintf(buffer, countof(buffer), "$IN_HTC%c", wbs->next[1]); lumpname = buffer; @@ -369,7 +369,7 @@ bool DInterBackground::LoadBackground(bool isenterpic) default: // Strife doesn't have an intermission pic so choose something neutral. if (isenterpic) return false; - lumpname = gameinfo.BorderFlat; + lumpname = gameinfo.BorderFlat.GetChars(); tilebackground = true; break; } @@ -664,38 +664,38 @@ void DInterBackground::drawBackground(int state, bool drawsplat, bool snl_pointe switch (a->type & ANIM_CONDITION) { case ANIM_IFVISITED: - li = FindLevelInfo(a->LevelName); + li = FindLevelInfo(a->LevelName.GetChars()); if (li == NULL || !(li->flags & LEVEL_VISITED)) continue; break; case ANIM_IFNOTVISITED: - li = FindLevelInfo(a->LevelName); + li = FindLevelInfo(a->LevelName.GetChars()); if (li == NULL || (li->flags & LEVEL_VISITED)) continue; break; // StatCount means 'leaving' - everything else means 'entering'! case ANIM_IFENTERING: - if (state == StatCount || strnicmp(a->LevelName, wbs->next, 8)) continue; + if (state == StatCount || a->LevelName.CompareNoCase(wbs->next, 8)) continue; break; case ANIM_IFNOTENTERING: - if (state != StatCount && !strnicmp(a->LevelName, wbs->next, 8)) continue; + if (state != StatCount && !a->LevelName.CompareNoCase(wbs->next, 8)) continue; break; case ANIM_IFLEAVING: - if (state != StatCount || strnicmp(a->LevelName, wbs->current, 8)) continue; + if (state != StatCount || a->LevelName.CompareNoCase(wbs->current, 8)) continue; break; case ANIM_IFNOTLEAVING: - if (state == StatCount && !strnicmp(a->LevelName, wbs->current, 8)) continue; + if (state == StatCount && !a->LevelName.CompareNoCase(wbs->current, 8)) continue; break; case ANIM_IFTRAVELLING: - if (strnicmp(a->LevelName2, wbs->current, 8) || strnicmp(a->LevelName, wbs->next, 8)) continue; + if (a->LevelName2.CompareNoCase(wbs->current, 8) || a->LevelName.CompareNoCase(wbs->next, 8)) continue; break; case ANIM_IFNOTTRAVELLING: - if (!strnicmp(a->LevelName2, wbs->current, 8) && !strnicmp(a->LevelName, wbs->next, 8)) continue; + if (!a->LevelName2.CompareNoCase(wbs->current, 8) && !a->LevelName.CompareNoCase(wbs->next, 8)) continue; break; } if (a->ctr >= 0) @@ -707,7 +707,7 @@ void DInterBackground::drawBackground(int state, bool drawsplat, bool snl_pointe { for (i = 0; iflags & LEVEL_VISITED) drawOnLnode(i, &splat, 1, animwidth, animheight); // draw a splat on taken cities. } } @@ -715,7 +715,7 @@ void DInterBackground::drawBackground(int state, bool drawsplat, bool snl_pointe // draw flashing ptr if (snl_pointeron && yah.Size()) { - unsigned int v = MapToIndex(wbs->next); + unsigned int v = MapToIndex(wbs->next.GetChars()); // Draw only if it points to a valid level on the current screen! if (v