From c3772fe2036a8778d2e7198570a3ab0658e2e88e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 12 Aug 2021 00:45:59 +0200 Subject: [PATCH] - changed FString API to use ptrdiff_t instead of long for signed size arguments. --- src/common/console/c_commandbuffer.cpp | 2 +- src/common/console/c_dispatch.cpp | 2 +- src/common/engine/stringtable.cpp | 2 +- src/common/filesystem/filesystem.cpp | 2 +- src/common/filesystem/resourcefile.cpp | 4 +- src/common/models/model.cpp | 4 +- src/common/models/models_obj.cpp | 8 +-- .../hwrenderer/data/hw_shaderpatcher.cpp | 42 ++++++------ .../scripting/interface/stringformat.cpp | 12 ++-- src/common/utility/s_playlist.cpp | 2 +- src/common/utility/zstring.cpp | 68 +++++++++---------- src/common/utility/zstring.h | 34 +++++----- src/d_iwad.cpp | 2 +- src/d_main.cpp | 4 +- src/gameconfigfile.cpp | 2 +- src/m_misc.cpp | 2 +- src/maploader/glnodes.cpp | 4 +- src/scripting/backend/codegen_doom.cpp | 4 +- 18 files changed, 100 insertions(+), 100 deletions(-) diff --git a/src/common/console/c_commandbuffer.cpp b/src/common/console/c_commandbuffer.cpp index 0ca96ade3..bf459350f 100644 --- a/src/common/console/c_commandbuffer.cpp +++ b/src/common/console/c_commandbuffer.cpp @@ -291,7 +291,7 @@ void FCommandBuffer::AddString(FString clip) if (clip.IsNotEmpty()) { // Only paste the first line. - long brk = clip.IndexOfAny("\r\n\b"); + auto brk = clip.IndexOfAny("\r\n\b"); std::u32string build; if (brk >= 0) { diff --git a/src/common/console/c_dispatch.cpp b/src/common/console/c_dispatch.cpp index bcb52ba7e..ce9f2cef7 100644 --- a/src/common/console/c_dispatch.cpp +++ b/src/common/console/c_dispatch.cpp @@ -533,7 +533,7 @@ FString BuildString (int argc, FString *argv) else if (strchr(argv[arg], '"')) { // If it contains one or more quotes, we need to escape them. buf << '"'; - long substr_start = 0, quotepos; + ptrdiff_t substr_start = 0, quotepos; while ((quotepos = argv[arg].IndexOf('"', substr_start)) >= 0) { if (substr_start < quotepos) diff --git a/src/common/engine/stringtable.cpp b/src/common/engine/stringtable.cpp index a666a4d9c..b36e6e409 100644 --- a/src/common/engine/stringtable.cpp +++ b/src/common/engine/stringtable.cpp @@ -435,7 +435,7 @@ void FStringTable::InsertString(int lumpnum, int langid, FName label, const FStr { const char *strlangid = (const char *)&langid; TableElement te = { fileSystem.GetFileContainer(lumpnum), { string, string, string, string } }; - long index; + ptrdiff_t index; while ((index = te.strings[0].IndexOf("@[")) >= 0) { auto endindex = te.strings[0].IndexOf(']', index); diff --git a/src/common/filesystem/filesystem.cpp b/src/common/filesystem/filesystem.cpp index 8b14b1312..5a709726f 100644 --- a/src/common/filesystem/filesystem.cpp +++ b/src/common/filesystem/filesystem.cpp @@ -1546,7 +1546,7 @@ bool FileSystem::CreatePathlessCopy(const char *name, int id, int /*flags*/) if (lump < 0) return false; // Does not exist. auto oldlump = FileInfo[lump]; - int slash = oldlump.longName.LastIndexOf('/'); + ptrdiff_t slash = oldlump.longName.LastIndexOf('/'); if (slash == -1) { diff --git a/src/common/filesystem/resourcefile.cpp b/src/common/filesystem/resourcefile.cpp index 5fc484b23..cc2a27345 100644 --- a/src/common/filesystem/resourcefile.cpp +++ b/src/common/filesystem/resourcefile.cpp @@ -348,8 +348,8 @@ void FResourceFile::PostProcessArchive(void *lumps, size_t lumpsize, LumpFilterI uint32_t max = NumLumps; max -= FilterLumpsByGameType(filter, lumps, lumpsize, max); - long len; - int lastpos = -1; + ptrdiff_t len; + ptrdiff_t lastpos = -1; FString file; FString LumpFilter = filter->dotFilter; while ((len = LumpFilter.IndexOf('.', lastpos+1)) > 0) diff --git a/src/common/models/model.cpp b/src/common/models/model.cpp index 90dedc272..eea099045 100644 --- a/src/common/models/model.cpp +++ b/src/common/models/model.cpp @@ -90,8 +90,8 @@ static int FindGFXFile(FString & fn) if (lump != -1) return lump; int best = -1; - int dot = fn.LastIndexOf('.'); - int slash = fn.LastIndexOf('/'); + auto dot = fn.LastIndexOf('.'); + auto slash = fn.LastIndexOf('/'); if (dot > slash) fn.Truncate(dot); static const char * extensions[] = { ".png", ".jpg", ".tga", ".pcx", nullptr }; diff --git a/src/common/models/models_obj.cpp b/src/common/models/models_obj.cpp index 1af4fab7e..05d10b5cf 100644 --- a/src/common/models/models_obj.cpp +++ b/src/common/models/models_obj.cpp @@ -44,8 +44,8 @@ bool FOBJModel::Load(const char* fn, int lumpnum, const char* buffer, int length { // Ensure usemtl statements remain intact TArray mtlUsages; - TArray mtlUsageIdxs; - long bpos = 0, nlpos = 0, slashpos = 0; + TArray mtlUsageIdxs; + ptrdiff_t bpos = 0, nlpos = 0, slashpos = 0; while (1) { bpos = objBuf.IndexOf("\nusemtl", bpos); @@ -58,7 +58,7 @@ bool FOBJModel::Load(const char* fn, int lumpnum, const char* buffer, int length } if (nlpos == -1) { - nlpos = (long)objBuf.Len(); + nlpos = objBuf.Len(); } FString lineStr(objBuf.GetChars() + bpos, nlpos - bpos); mtlUsages.Push(lineStr); @@ -76,7 +76,7 @@ bool FOBJModel::Load(const char* fn, int lumpnum, const char* buffer, int length nlpos = objBuf.IndexOf('\n', bpos); if (nlpos == -1) { - nlpos = (long)objBuf.Len(); + nlpos = objBuf.Len(); } memcpy(wObjBuf + bpos, mtlUsages[i].GetChars(), nlpos - bpos); } diff --git a/src/common/rendering/hwrenderer/data/hw_shaderpatcher.cpp b/src/common/rendering/hwrenderer/data/hw_shaderpatcher.cpp index fb3b8a535..97420e0c2 100644 --- a/src/common/rendering/hwrenderer/data/hw_shaderpatcher.cpp +++ b/src/common/rendering/hwrenderer/data/hw_shaderpatcher.cpp @@ -52,15 +52,15 @@ static bool IsGlslWhitespace(char c) } } -static FString NextGlslToken(const char *chars, long len, long &pos) +static FString NextGlslToken(const char *chars, ptrdiff_t len, ptrdiff_t &pos) { // Eat whitespace - long tokenStart = pos; + ptrdiff_t tokenStart = pos; while (tokenStart != len && IsGlslWhitespace(chars[tokenStart])) tokenStart++; // Find token end - long tokenEnd = tokenStart; + ptrdiff_t tokenEnd = tokenStart; while (tokenEnd != len && !IsGlslWhitespace(chars[tokenEnd]) && chars[tokenEnd] != ';') tokenEnd++; @@ -82,13 +82,13 @@ FString RemoveLegacyUserUniforms(FString code) // The following code searches for legacy uniform declarations in the shader itself and replaces them with whitespace. - long len = (long)code.Len(); + ptrdiff_t len = code.Len(); char *chars = code.LockBuffer(); - long startIndex = 0; + ptrdiff_t startIndex = 0; while (true) { - long matchIndex = code.IndexOf("uniform", startIndex); + ptrdiff_t matchIndex = code.IndexOf("uniform", startIndex); if (matchIndex == -1) break; @@ -98,7 +98,7 @@ FString RemoveLegacyUserUniforms(FString code) bool isKeywordEnd = matchIndex + 7 == len || IsGlslWhitespace(chars[matchIndex + 7]); if (isKeywordStart && isKeywordEnd) { - long pos = matchIndex + 7; + ptrdiff_t pos = matchIndex + 7; FString type = NextGlslToken(chars, len, pos); FString identifier = NextGlslToken(chars, len, pos); @@ -107,10 +107,10 @@ FString RemoveLegacyUserUniforms(FString code) if (isLegacyUniformName) { - long statementEndIndex = code.IndexOf(';', matchIndex + 7); + ptrdiff_t statementEndIndex = code.IndexOf(';', matchIndex + 7); if (statementEndIndex == -1) statementEndIndex = len; - for (long i = matchIndex; i <= statementEndIndex; i++) + for (ptrdiff_t i = matchIndex; i <= statementEndIndex; i++) { if (!IsGlslWhitespace(chars[i])) chars[i] = ' '; @@ -127,7 +127,7 @@ FString RemoveLegacyUserUniforms(FString code) // Modern GLSL only allows use of 'texture'. while (true) { - long matchIndex = code.IndexOf("texture2d", startIndex); + ptrdiff_t matchIndex = code.IndexOf("texture2d", startIndex); if (matchIndex == -1) break; @@ -148,14 +148,14 @@ FString RemoveLegacyUserUniforms(FString code) FString RemoveSamplerBindings(FString code, TArray> &samplerstobind) { - long len = (long)code.Len(); + ptrdiff_t len = code.Len(); char *chars = code.LockBuffer(); - long startIndex = 0; - long startpos, endpos; + ptrdiff_t startIndex = 0; + ptrdiff_t startpos, endpos; while (true) { - long matchIndex = code.IndexOf("layout(binding", startIndex); + ptrdiff_t matchIndex = code.IndexOf("layout(binding", startIndex); if (matchIndex == -1) break; @@ -165,7 +165,7 @@ FString RemoveSamplerBindings(FString code, TArray> &sam bool isKeywordEnd = matchIndex + 14 == len || IsGlslWhitespace(chars[matchIndex + 14]) || chars[matchIndex + 14] == '='; if (isKeywordStart && isKeywordEnd) { - long pos = matchIndex + 14; + ptrdiff_t pos = matchIndex + 14; startpos = matchIndex; while (IsGlslWhitespace(chars[pos])) pos++; if (chars[pos] == '=') @@ -175,7 +175,7 @@ FString RemoveSamplerBindings(FString code, TArray> &sam auto val = strtol(&chars[pos], &p, 0); if (p != &chars[pos]) { - pos = long(p - chars); + pos = (p - chars); while (IsGlslWhitespace(chars[pos])) pos++; if (chars[pos] == ')') { @@ -216,17 +216,17 @@ FString RemoveSamplerBindings(FString code, TArray> &sam FString RemoveLayoutLocationDecl(FString code, const char *inoutkeyword) { - long len = (long)code.Len(); + ptrdiff_t len = code.Len(); char *chars = code.LockBuffer(); - long startIndex = 0; + ptrdiff_t startIndex = 0; while (true) { - long matchIndex = code.IndexOf("layout(location", startIndex); + ptrdiff_t matchIndex = code.IndexOf("layout(location", startIndex); if (matchIndex == -1) break; - long endIndex = matchIndex; + ptrdiff_t endIndex = matchIndex; // Find end of layout declaration while (chars[endIndex] != ')' && chars[endIndex] != 0) @@ -255,7 +255,7 @@ FString RemoveLayoutLocationDecl(FString code, const char *inoutkeyword) if (keywordFound && IsGlslWhitespace(chars[endIndex + i])) { // yes - replace declaration with spaces - for (long i = matchIndex; i < endIndex; i++) + for (auto i = matchIndex; i < endIndex; i++) chars[i] = ' '; } diff --git a/src/common/scripting/interface/stringformat.cpp b/src/common/scripting/interface/stringformat.cpp index 87bfbb415..4bfe34ff6 100644 --- a/src/common/scripting/interface/stringformat.cpp +++ b/src/common/scripting/interface/stringformat.cpp @@ -419,7 +419,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, Filter, StringFilter) static int StringIndexOf(FString *self, const FString &substr, int startIndex) { - return self->IndexOf(substr, startIndex); + return (int)self->IndexOf(substr, startIndex); } DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, IndexOf, StringIndexOf) @@ -427,12 +427,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, IndexOf, StringIndexOf) PARAM_SELF_STRUCT_PROLOGUE(FString); PARAM_STRING(substr); PARAM_INT(startIndex); - ACTION_RETURN_INT(self->IndexOf(substr, startIndex)); + ACTION_RETURN_INT(StringIndexOf(self, substr, startIndex)); } static int StringLastIndexOf(FString *self, const FString &substr, int endIndex) { - return self->LastIndexOfBroken(substr, endIndex); + return (int)self->LastIndexOfBroken(substr, endIndex); } DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, LastIndexOf, StringLastIndexOf) @@ -440,12 +440,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, LastIndexOf, StringLastIndexOf) PARAM_SELF_STRUCT_PROLOGUE(FString); PARAM_STRING(substr); PARAM_INT(endIndex); - ACTION_RETURN_INT(self->LastIndexOfBroken(substr, endIndex)); + ACTION_RETURN_INT(StringLastIndexOf(self, substr, endIndex)); } static int StringRightIndexOf(FString *self, const FString &substr, int endIndex) { - return self->LastIndexOf(substr, endIndex); + return (int)self->LastIndexOf(substr, endIndex); } DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, RightIndexOf, StringRightIndexOf) @@ -453,7 +453,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, RightIndexOf, StringRightIndexOf) PARAM_SELF_STRUCT_PROLOGUE(FString); PARAM_STRING(substr); PARAM_INT(endIndex); - ACTION_RETURN_INT(self->LastIndexOf(substr, endIndex)); + ACTION_RETURN_INT(StringRightIndexOf(self, substr, endIndex)); } static void StringToUpper(FString *self) diff --git a/src/common/utility/s_playlist.cpp b/src/common/utility/s_playlist.cpp index 49e6f2d81..d284a3e90 100644 --- a/src/common/utility/s_playlist.cpp +++ b/src/common/utility/s_playlist.cpp @@ -95,7 +95,7 @@ bool FPlayList::ChangeList (const char *path) } // Check for relative paths. - long slashpos = song.IndexOf('/'); + auto slashpos = song.IndexOf('/'); if (slashpos == 0) { diff --git a/src/common/utility/zstring.cpp b/src/common/utility/zstring.cpp index 2cd308596..8d4d4d119 100644 --- a/src/common/utility/zstring.cpp +++ b/src/common/utility/zstring.cpp @@ -422,7 +422,7 @@ void FString::Remove(size_t index, size_t remlen) { if (index + remlen >= Len()) { - Truncate((long)index); + Truncate(index); } else { @@ -500,12 +500,12 @@ void FString::DeleteLastCharacter() } -long FString::IndexOf (const FString &substr, long startIndex) const +ptrdiff_t FString::IndexOf (const FString &substr, ptrdiff_t startIndex) const { return IndexOf (substr.Chars, startIndex); } -long FString::IndexOf (const char *substr, long startIndex) const +ptrdiff_t FString::IndexOf (const char *substr, ptrdiff_t startIndex) const { if (startIndex > 0 && Len() <= (size_t)startIndex) { @@ -516,10 +516,10 @@ long FString::IndexOf (const char *substr, long startIndex) const { return -1; } - return long(str - Chars); + return str - Chars; } -long FString::IndexOf (char subchar, long startIndex) const +ptrdiff_t FString::IndexOf (char subchar, ptrdiff_t startIndex) const { if (startIndex > 0 && Len() <= (size_t)startIndex) { @@ -530,15 +530,15 @@ long FString::IndexOf (char subchar, long startIndex) const { return -1; } - return long(str - Chars); + return str - Chars; } -long FString::IndexOfAny (const FString &charset, long startIndex) const +ptrdiff_t FString::IndexOfAny (const FString &charset, ptrdiff_t startIndex) const { return IndexOfAny (charset.Chars, startIndex); } -long FString::IndexOfAny (const char *charset, long startIndex) const +ptrdiff_t FString::IndexOfAny (const char *charset, ptrdiff_t startIndex) const { if (startIndex > 0 && Len() <= (size_t)startIndex) { @@ -549,19 +549,19 @@ long FString::IndexOfAny (const char *charset, long startIndex) const { return -1; } - return long(brk - Chars); + return brk - Chars; } -long FString::LastIndexOf (char subchar) const +ptrdiff_t FString::LastIndexOf (char subchar) const { - return LastIndexOf (subchar, long(Len())); + return LastIndexOf (subchar, Len()); } -long FString::LastIndexOf (char subchar, long endIndex) const +ptrdiff_t FString::LastIndexOf (char subchar, ptrdiff_t endIndex) const { if ((size_t)endIndex > Len()) { - endIndex = long(Len()); + endIndex = Len(); } while (--endIndex >= 0) { @@ -573,16 +573,16 @@ long FString::LastIndexOf (char subchar, long endIndex) const return -1; } -long FString::LastIndexOfBroken (const FString &_substr, long endIndex) const +ptrdiff_t FString::LastIndexOfBroken (const FString &_substr, ptrdiff_t endIndex) const { const char *substr = _substr.GetChars(); size_t substrlen = _substr.Len(); if ((size_t)endIndex > Len()) { - endIndex = long(Len()); + endIndex = Len(); } substrlen--; - while (--endIndex >= long(substrlen)) + while (--endIndex >= ptrdiff_t(substrlen)) { if (strncmp (substr, Chars + endIndex - substrlen, substrlen + 1) == 0) { @@ -592,26 +592,26 @@ long FString::LastIndexOfBroken (const FString &_substr, long endIndex) const return -1; } -long FString::LastIndexOfAny (const FString &charset) const +ptrdiff_t FString::LastIndexOfAny (const FString &charset) const { - return LastIndexOfAny (charset.Chars, long(Len())); + return LastIndexOfAny (charset.Chars, Len()); } -long FString::LastIndexOfAny (const char *charset) const +ptrdiff_t FString::LastIndexOfAny (const char *charset) const { return LastIndexOfAny (charset, long(Len())); } -long FString::LastIndexOfAny (const FString &charset, long endIndex) const +ptrdiff_t FString::LastIndexOfAny (const FString &charset, ptrdiff_t endIndex) const { return LastIndexOfAny (charset.Chars, endIndex); } -long FString::LastIndexOfAny (const char *charset, long endIndex) const +ptrdiff_t FString::LastIndexOfAny (const char *charset, ptrdiff_t endIndex) const { if ((size_t)endIndex > Len()) { - endIndex = long(Len()); + endIndex = Len(); } while (--endIndex >= 0) { @@ -623,31 +623,31 @@ long FString::LastIndexOfAny (const char *charset, long endIndex) const return -1; } -long FString::LastIndexOf (const FString &substr) const +ptrdiff_t FString::LastIndexOf (const FString &substr) const { - return LastIndexOf(substr.Chars, long(Len() - substr.Len()), substr.Len()); + return LastIndexOf(substr.Chars, Len() - substr.Len(), substr.Len()); } -long FString::LastIndexOf (const FString &substr, long endIndex) const +ptrdiff_t FString::LastIndexOf (const FString &substr, ptrdiff_t endIndex) const { return LastIndexOf(substr.Chars, endIndex, substr.Len()); } -long FString::LastIndexOf (const char *substr) const +ptrdiff_t FString::LastIndexOf (const char *substr) const { - return LastIndexOf(substr, long(Len() - strlen(substr)), strlen(substr)); + return LastIndexOf(substr, Len() - strlen(substr), strlen(substr)); } -long FString::LastIndexOf (const char *substr, long endIndex) const +ptrdiff_t FString::LastIndexOf (const char *substr, ptrdiff_t endIndex) const { return LastIndexOf(substr, endIndex, strlen(substr)); } -long FString::LastIndexOf (const char *substr, long endIndex, size_t substrlen) const +ptrdiff_t FString::LastIndexOf (const char *substr, ptrdiff_t endIndex, size_t substrlen) const { if ((size_t)endIndex + substrlen > Len()) { - endIndex = long(Len() - substrlen); + endIndex = Len() - substrlen; } while (endIndex >= 0) { @@ -1256,15 +1256,15 @@ void FString::Split(TArray& tokens, const char *delimiter, EmptyTokenTy { assert(nullptr != delimiter); - const long selfLen = static_cast(Len()); - const long delimLen = static_cast(strlen(delimiter)); - long lastPos = 0; + const auto selfLen = static_cast(Len()); + const auto delimLen = static_cast(strlen(delimiter)); + ptrdiff_t lastPos = 0; if (selfLen == 0) return; // Empty strings do not contain tokens, even with TOK_KEEPEMPTY. while (lastPos <= selfLen) { - long pos = IndexOf(delimiter, lastPos); + auto pos = IndexOf(delimiter, lastPos); if (-1 == pos) { diff --git a/src/common/utility/zstring.h b/src/common/utility/zstring.h index a30458c3c..4640d5c28 100644 --- a/src/common/utility/zstring.h +++ b/src/common/utility/zstring.h @@ -215,28 +215,28 @@ public: void AppendCharacter(int codepoint); void DeleteLastCharacter(); - long IndexOf (const FString &substr, long startIndex=0) const; - long IndexOf (const char *substr, long startIndex=0) const; - long IndexOf (char subchar, long startIndex=0) const; + ptrdiff_t IndexOf (const FString &substr, ptrdiff_t startIndex=0) const; + ptrdiff_t IndexOf (const char *substr, ptrdiff_t startIndex=0) const; + ptrdiff_t IndexOf (char subchar, ptrdiff_t startIndex=0) const; - long IndexOfAny (const FString &charset, long startIndex=0) const; - long IndexOfAny (const char *charset, long startIndex=0) const; + ptrdiff_t IndexOfAny (const FString &charset, ptrdiff_t startIndex=0) const; + ptrdiff_t IndexOfAny (const char *charset, ptrdiff_t startIndex=0) const; // This is only kept for backwards compatibility with old ZScript versions that used this function and depend on its bug. - long LastIndexOf (char subchar) const; - long LastIndexOfBroken (const FString &substr, long endIndex) const; - long LastIndexOf (char subchar, long endIndex) const; + ptrdiff_t LastIndexOf (char subchar) const; + ptrdiff_t LastIndexOfBroken (const FString &substr, ptrdiff_t endIndex) const; + ptrdiff_t LastIndexOf (char subchar, ptrdiff_t endIndex) const; - long LastIndexOfAny (const FString &charset) const; - long LastIndexOfAny (const char *charset) const; - long LastIndexOfAny (const FString &charset, long endIndex) const; - long LastIndexOfAny (const char *charset, long endIndex) const; + ptrdiff_t LastIndexOfAny (const FString &charset) const; + ptrdiff_t LastIndexOfAny (const char *charset) const; + ptrdiff_t LastIndexOfAny (const FString &charset, ptrdiff_t endIndex) const; + ptrdiff_t LastIndexOfAny (const char *charset, ptrdiff_t endIndex) const; - long LastIndexOf (const FString &substr) const; - long LastIndexOf (const FString &substr, long endIndex) const; - long LastIndexOf (const char *substr) const; - long LastIndexOf (const char *substr, long endIndex) const; - long LastIndexOf (const char *substr, long endIndex, size_t substrlen) const; + ptrdiff_t LastIndexOf (const FString &substr) const; + ptrdiff_t LastIndexOf (const FString &substr, ptrdiff_t endIndex) const; + ptrdiff_t LastIndexOf (const char *substr) const; + ptrdiff_t LastIndexOf (const char *substr, ptrdiff_t endIndex) const; + ptrdiff_t LastIndexOf (const char *substr, ptrdiff_t endIndex, size_t substrlen) const; void ToUpper (); void ToLower (); diff --git a/src/d_iwad.cpp b/src/d_iwad.cpp index d147c8e7e..ca0f50f87 100644 --- a/src/d_iwad.cpp +++ b/src/d_iwad.cpp @@ -762,7 +762,7 @@ int FIWadManager::IdentifyVersion (TArray &wadfiles, const char *iwad, FString path; if (info.Load[i][0] != ':') { - long lastslash = picks[pick].mFullPath.LastIndexOf('/'); + auto lastslash = picks[pick].mFullPath.LastIndexOf('/'); if (lastslash == -1) { diff --git a/src/d_main.cpp b/src/d_main.cpp index 51f7fb5aa..1b77b57d8 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -2122,8 +2122,8 @@ static void AddAutoloadFiles(const char *autoname) // Add common (global) wads D_AddConfigFiles(allwads, "Global.Autoload", "*.wad", GameConfig); - long len; - int lastpos = -1; + ptrdiff_t len; + ptrdiff_t lastpos = -1; while ((len = LumpFilterIWAD.IndexOf('.', lastpos+1)) > 0) { diff --git a/src/gameconfigfile.cpp b/src/gameconfigfile.cpp index 830cef232..17898f3ae 100644 --- a/src/gameconfigfile.cpp +++ b/src/gameconfigfile.cpp @@ -255,7 +255,7 @@ void FGameConfigFile::DoAutoloadSetup (FIWadManager *iwad_man) { FString section = workname + ".Autoload"; CreateSectionAtStart(section.GetChars()); - long dotpos = workname.LastIndexOf('.'); + auto dotpos = workname.LastIndexOf('.'); if (dotpos < 0) break; workname.Truncate(dotpos); } diff --git a/src/m_misc.cpp b/src/m_misc.cpp index 40474c69e..6680911ac 100644 --- a/src/m_misc.cpp +++ b/src/m_misc.cpp @@ -635,7 +635,7 @@ void M_ScreenShot (const char *filename) if (!screenshot_quiet) { - int slash = -1; + ptrdiff_t slash = -1; if (!longsavemessages) slash = autoname.LastIndexOfAny(":/\\"); Printf ("Captured %s\n", autoname.GetChars()+slash+1); } diff --git a/src/maploader/glnodes.cpp b/src/maploader/glnodes.cpp index 216fb5784..843afeaa5 100644 --- a/src/maploader/glnodes.cpp +++ b/src/maploader/glnodes.cpp @@ -1001,13 +1001,13 @@ static FString CreateCacheName(MapData *map, bool create) { FString path = M_GetCachePath(create); FString lumpname = fileSystem.GetFileFullPath(map->lumpnum); - int separator = lumpname.IndexOf(':'); + auto separator = lumpname.IndexOf(':'); path << '/' << lumpname.Left(separator); if (create) CreatePath(path); lumpname.ReplaceChars('/', '%'); lumpname.ReplaceChars(':', '$'); - path << '/' << lumpname.Right(lumpname.Len() - separator - 1) << ".gzc"; + path << '/' << lumpname.Right((ptrdiff_t)lumpname.Len() - separator - 1) << ".gzc"; return path; } diff --git a/src/scripting/backend/codegen_doom.cpp b/src/scripting/backend/codegen_doom.cpp index 111147c2c..e10756354 100644 --- a/src/scripting/backend/codegen_doom.cpp +++ b/src/scripting/backend/codegen_doom.cpp @@ -808,12 +808,12 @@ FxMultiNameState::FxMultiNameState(const char *_statestring, const FScriptPositi { FName scopename = NAME_None; FString statestring = _statestring; - int scopeindex = statestring.IndexOf("::"); + auto scopeindex = statestring.IndexOf("::"); if (scopeindex >= 0) { scopename = FName(statestring, scopeindex, false); - statestring = statestring.Right(statestring.Len() - scopeindex - 2); + statestring = statestring.Right((ptrdiff_t)statestring.Len() - scopeindex - 2); } names = MakeStateNameList(statestring); names.Insert(0, scopename);