diff --git a/src/common/filesystem/filesystem.cpp b/src/common/filesystem/filesystem.cpp index f58fb51ac..55847e714 100644 --- a/src/common/filesystem/filesystem.cpp +++ b/src/common/filesystem/filesystem.cpp @@ -1095,14 +1095,6 @@ bool FileSystem::CheckFileName (int lump, const char *name) // //========================================================================== -void FileSystem::GetFileShortName (char *to, int lump) const -{ - if ((size_t)lump >= NumEntries) - *to = 0; - else - uppercopy (to, FileInfo[lump].shortName.String); -} - const char* FileSystem::GetFileShortName(int lump) const { if ((size_t)lump >= NumEntries) @@ -1111,16 +1103,6 @@ const char* FileSystem::GetFileShortName(int lump) const return FileInfo[lump].shortName.String; } -void FileSystem::GetFileShortName(FString &to, int lump) const -{ - if ((size_t)lump >= NumEntries) - to = FString(); - else { - to = FileInfo[lump].shortName.String; - to.ToUpper(); - } -} - //========================================================================== // // FileSystem :: GetFileFullName diff --git a/src/common/filesystem/filesystem.h b/src/common/filesystem/filesystem.h index 0eb06b2fb..5ccca0971 100644 --- a/src/common/filesystem/filesystem.h +++ b/src/common/filesystem/filesystem.h @@ -136,8 +136,6 @@ public: int FileLength (int lump) const; int GetFileOffset (int lump); // [RH] Returns offset of lump in the wadfile int GetFileFlags (int lump); // Return the flags for this lump - void GetFileShortName (char *to, int lump) const; // [RH] Copies the lump name to to using uppercopy - void GetFileShortName (FString &to, int lump) const; const char* GetFileShortName(int lump) const; const char *GetFileFullName (int lump, bool returnshort = true) const; // [RH] Returns the lump's full name FString GetFileFullPath (int lump) const; // [RH] Returns wad's name + lump's full name diff --git a/src/common/scripting/interface/vmnatives.cpp b/src/common/scripting/interface/vmnatives.cpp index 4dcd568e4..636c340ae 100644 --- a/src/common/scripting/interface/vmnatives.cpp +++ b/src/common/scripting/interface/vmnatives.cpp @@ -819,9 +819,7 @@ DEFINE_ACTION_FUNCTION(_Wads, GetLumpName) { PARAM_PROLOGUE; PARAM_INT(lump); - FString lumpname; - fileSystem.GetFileShortName(lumpname, lump); - ACTION_RETURN_STRING(lumpname); + ACTION_RETURN_STRING(fileSystem.GetFileShortName(lump)); } DEFINE_ACTION_FUNCTION(_Wads, GetLumpFullName) diff --git a/src/common/textures/formats/fontchars.cpp b/src/common/textures/formats/fontchars.cpp index add4f1f74..09fbd718e 100644 --- a/src/common/textures/formats/fontchars.cpp +++ b/src/common/textures/formats/fontchars.cpp @@ -164,9 +164,7 @@ PalettedPixels FFontChar2::CreatePalettedPixels(int) if (destSize < 0) { - char name[9]; - fileSystem.GetFileShortName(name, SourceLump); - name[8] = 0; + auto name = fileSystem.GetFileShortName(SourceLump); I_FatalError("The font %s is corrupt", name); } return Pixels; diff --git a/src/common/textures/formats/rawpagetexture.cpp b/src/common/textures/formats/rawpagetexture.cpp index d28714d81..337ca5520 100644 --- a/src/common/textures/formats/rawpagetexture.cpp +++ b/src/common/textures/formats/rawpagetexture.cpp @@ -155,9 +155,8 @@ FRawPageTexture::FRawPageTexture (int lumpnum) Height = 200; // Special case hack for Heretic's E2 end pic. This is not going to be exposed as an editing feature because the implications would be horrible. - FString Name; - fileSystem.GetFileShortName(Name, lumpnum); - if (Name.CompareNoCase("E2END") == 0) + auto Name = fileSystem.GetFileShortName(lumpnum); + if (stricmp(Name, "E2END") == 0) { mPaletteLump = fileSystem.CheckNumForName("E2PAL"); if (fileSystem.FileLength(mPaletteLump) < 768) mPaletteLump = -1; diff --git a/src/common/textures/texturemanager.cpp b/src/common/textures/texturemanager.cpp index c149d99b2..236b049bc 100644 --- a/src/common/textures/texturemanager.cpp +++ b/src/common/textures/texturemanager.cpp @@ -451,7 +451,7 @@ FTextureID FTextureManager::CreateTexture (int lumpnum, ETextureType usetype) { FString str; if (!usefullnames) - fileSystem.GetFileShortName(str, lumpnum); + str = fileSystem.GetFileShortName(lumpnum); else { auto fn = fileSystem.GetFileFullName(lumpnum); @@ -563,7 +563,6 @@ void FTextureManager::AddGroup(int wadnum, int ns, ETextureType usetype) { int firsttx = fileSystem.GetFirstEntry(wadnum); int lasttx = fileSystem.GetLastEntry(wadnum); - FString Name; if (!usefullnames) { @@ -574,10 +573,9 @@ void FTextureManager::AddGroup(int wadnum, int ns, ETextureType usetype) for (; firsttx <= lasttx; ++firsttx) { + auto Name = fileSystem.GetFileShortName(firsttx); if (fileSystem.GetFileNamespace(firsttx) == ns) { - fileSystem.GetFileShortName(Name, firsttx); - if (fileSystem.CheckNumForName(Name, ns) == firsttx) { CreateTexture(firsttx, usetype); @@ -618,7 +616,6 @@ void FTextureManager::AddHiresTextures (int wadnum) int firsttx = fileSystem.GetFirstEntry(wadnum); int lasttx = fileSystem.GetLastEntry(wadnum); - FString Name; TArray tlist; if (firsttx == -1 || lasttx == -1) @@ -630,7 +627,7 @@ void FTextureManager::AddHiresTextures (int wadnum) { if (fileSystem.GetFileNamespace(firsttx) == ns_hires) { - fileSystem.GetFileShortName (Name, firsttx); + auto Name = fileSystem.GetFileShortName(firsttx); if (fileSystem.CheckNumForName (Name, ns_hires) == firsttx) { @@ -964,8 +961,7 @@ void FTextureManager::AddTexturesForWad(int wadnum, FMultipatchTextureBuilder &b for (int i= firsttx; i <= lasttx; i++) { bool skin = false; - FString Name; - fileSystem.GetFileShortName(Name, i); + auto Name = fileSystem.GetFileShortName(i); // Ignore anything not in the global namespace int ns = fileSystem.GetFileNamespace(i); @@ -997,7 +993,7 @@ void FTextureManager::AddTexturesForWad(int wadnum, FMultipatchTextureBuilder &b if (iwad) { // We need to make an exception for font characters of the SmallFont coming from the IWAD to be able to construct the original font. - if (Name.IndexOf("STCFN") != 0 && Name.IndexOf("FONTA") != 0) continue; + if (strncmp(Name, "STCFN", 5) != 0 && strncmp(Name, "FONTA", 5) != 0) continue; force = true; } else continue; @@ -1013,7 +1009,7 @@ void FTextureManager::AddTexturesForWad(int wadnum, FMultipatchTextureBuilder &b if (iwad) { // We need to make an exception for font characters of the SmallFont coming from the IWAD to be able to construct the original font. - if (Name.IndexOf("STCFN") != 0 && Name.IndexOf("FONTA") != 0) continue; + if (strncmp(Name, "STCFN", 5) != 0 && strncmp(Name, "FONTA", 5) != 0) continue; } else continue; } @@ -1513,9 +1509,7 @@ void FTextureManager::AdjustSpriteOffsets() if (fileSystem.GetFileContainer(i) > fileSystem.GetMaxIwadNum()) break; // we are past the IWAD if (fileSystem.GetFileNamespace(i) == ns_sprites && fileSystem.GetFileContainer(i) >= fileSystem.GetIwadNum() && fileSystem.GetFileContainer(i) <= fileSystem.GetMaxIwadNum()) { - char str[9]; - fileSystem.GetFileShortName(str, i); - str[8] = 0; + const char *str = fileSystem.GetFileShortName(i); FTextureID texid = TexMan.CheckForTexture(str, ETextureType::Sprite, 0); if (texid.isValid() && fileSystem.GetFileContainer(GetGameTexture(texid)->GetSourceLump()) > fileSystem.GetMaxIwadNum()) { diff --git a/src/maploader/maploader.cpp b/src/maploader/maploader.cpp index 1bcd9c34f..56b1e23fe 100644 --- a/src/maploader/maploader.cpp +++ b/src/maploader/maploader.cpp @@ -2121,9 +2121,7 @@ void MapLoader::ProcessSideTextures(bool checktranmap, side_t *sd, sector_t *sec if (developer >= DMSG_NOTIFY) { - char lumpname[9]; - lumpname[8] = 0; - fileSystem.GetFileShortName(lumpname, lumpnum); + const char *lumpname = fileSystem.GetFileShortName(lumpnum); if (*alpha < 0) Printf("%s appears to be additive translucency %d (%d%%)\n", lumpname, -*alpha, -*alpha * 100 / 255); else Printf("%s appears to be translucency %d (%d%%)\n", lumpname, *alpha, *alpha * 100 / 255); } diff --git a/src/playsim/p_acs.cpp b/src/playsim/p_acs.cpp index 429fe1b69..17f6cc459 100644 --- a/src/playsim/p_acs.cpp +++ b/src/playsim/p_acs.cpp @@ -2277,8 +2277,7 @@ bool FBehavior::Init(FLevelLocals *Level, int lumpnum, FileReader * fr, int len, if (fr == NULL) { - fileSystem.GetFileShortName (ModuleName, lumpnum); - ModuleName[8] = 0; + strcpy(ModuleName, fileSystem.GetFileShortName (lumpnum)); } else { diff --git a/src/r_data/colormaps.cpp b/src/r_data/colormaps.cpp index 2ee96133a..ad1559c6b 100644 --- a/src/r_data/colormaps.cpp +++ b/src/r_data/colormaps.cpp @@ -106,9 +106,7 @@ void R_InitColormaps (bool allowCustomColormap) { if (fileSystem.GetFileNamespace(i) == ns_colormaps) { - char name[9]; - name[8] = 0; - fileSystem.GetFileShortName (name, i); + auto name = fileSystem.GetFileShortName(i); if (fileSystem.CheckNumForName (name, ns_colormaps) == (int)i) { diff --git a/src/r_data/sprites.cpp b/src/r_data/sprites.cpp index 07a106e65..97a5e2e46 100644 --- a/src/r_data/sprites.cpp +++ b/src/r_data/sprites.cpp @@ -351,13 +351,11 @@ void R_InitSpriteDefs () { if (fileSystem.GetFileNamespace(i) == ns_voxels) { - char name[9]; size_t namelen; int spin; int sign; - fileSystem.GetFileShortName(name, i); - name[8] = 0; + const char* name = fileSystem.GetFileShortName(i); namelen = strlen(name); if (namelen < 4) { // name is too short @@ -812,9 +810,7 @@ void R_InitSkins (void) // specified, use whatever immediately follows the specifier lump. if (intname == 0) { - char name[9]; - fileSystem.GetFileShortName (name, base+1); - memcpy(&intname, name, 4); + memcpy(&intname, fileSystem.GetFileShortName(base + 1), 4); } int basens = fileSystem.GetFileNamespace(base); @@ -845,9 +841,8 @@ void R_InitSkins (void) for (k = base + 1; fileSystem.GetFileNamespace(k) == basens; k++) { - char lname[9]; + const char* lname = fileSystem.GetFileShortName(k); uint32_t lnameint; - fileSystem.GetFileShortName (lname, k); memcpy(&lnameint, lname, 4); if (lnameint == intname) { @@ -866,7 +861,7 @@ void R_InitSkins (void) break; } - fileSystem.GetFileShortName (temp.name, base+1); + memcpy(temp.name, fileSystem.GetFileShortName (base+1), 4); temp.name[4] = 0; int sprno = (int)sprites.Push (temp); if (spr==0) Skins[i].sprite = sprno; diff --git a/src/sound/s_advsound.cpp b/src/sound/s_advsound.cpp index 928cdeba5..98d17bc88 100644 --- a/src/sound/s_advsound.cpp +++ b/src/sound/s_advsound.cpp @@ -1124,7 +1124,7 @@ static void S_AddSNDINFO (int lump) static void S_AddStrifeVoice (int lumpnum) { char name[16] = "svox/"; - fileSystem.GetFileShortName (name+5, lumpnum); + strcpy(name + 5, fileSystem.GetFileShortName (lumpnum)); S_AddSound (name, lumpnum); } diff --git a/src/sound/s_doomsound.cpp b/src/sound/s_doomsound.cpp index 9f000f4c7..f47666e4e 100644 --- a/src/sound/s_doomsound.cpp +++ b/src/sound/s_doomsound.cpp @@ -1242,9 +1242,8 @@ void DoomSoundEngine::NoiseDebug() color = (chan->ChanFlags & CHANF_LOOP) ? CR_BROWN : CR_GREY; // Name - fileSystem.GetFileShortName(temp, S_sfx[chan->SoundID.index()].lumpnum); - temp[8] = 0; - DrawText(twod, NewConsoleFont, color, 0, y, temp, TAG_DONE); + auto tname = fileSystem.GetFileShortName(S_sfx[chan->SoundID.index()].lumpnum); + DrawText(twod, NewConsoleFont, color, 0, y, tname, TAG_DONE); if (!(chan->ChanFlags & CHANF_IS3D)) { @@ -1337,10 +1336,8 @@ ADD_STAT(sounddebug) void DoomSoundEngine::PrintSoundList() { - char lumpname[9]; unsigned int i; - lumpname[8] = 0; for (i = 0; i < soundEngine->GetNumSounds(); i++) { const sfxinfo_t* sfx = soundEngine->GetSfx(FSoundID::fromInt(i)); @@ -1360,8 +1357,7 @@ void DoomSoundEngine::PrintSoundList() } else if (S_sfx[i].lumpnum != -1) { - fileSystem.GetFileShortName(lumpname, sfx->lumpnum); - Printf("%3d. %s (%s)\n", i, sfx->name.GetChars(), lumpname); + Printf("%3d. %s (%s)\n", i, sfx->name.GetChars(), fileSystem.GetFileShortName(sfx->lumpnum)); } else if (S_sfx[i].link != sfxinfo_t::NO_LINK) {