From ebb71cebf1313028ccff591e154541b5b2ff57d7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 22 Aug 2023 21:20:28 +0200 Subject: [PATCH] - put the entire filesystem code into a namespace and created some subdirectories. --- src/CMakeLists.txt | 41 ++++++++++--------- src/common/audio/music/i_music.cpp | 5 ++- src/common/audio/music/i_soundfont.cpp | 7 ++-- src/common/audio/music/music.cpp | 1 + src/common/audio/music/s_music.h | 2 +- src/common/audio/sound/i_sound.h | 2 +- src/common/console/c_enginecmds.cpp | 4 +- src/common/engine/files.h | 6 +++ src/common/engine/filesystem.h | 7 ++++ src/common/engine/palettecontainer.h | 3 +- src/common/engine/serializer.cpp | 2 + src/common/engine/serializer.h | 5 +-- .../{files.h => include/fs_files.h} | 11 +++-- .../{filesystem.h => include/fs_filesystem.h} | 40 +++++++++--------- .../filesystem/{ => include}/fs_findfile.h | 3 ++ src/common/filesystem/{ => include}/fs_swap.h | 7 ++-- .../filesystem/{ => include}/resourcefile.h | 7 ++-- .../filesystem/{ => source}/ancientzip.cpp | 4 ++ .../filesystem/{ => source}/ancientzip.h | 7 +++- .../filesystem/{ => source}/file_7z.cpp | 5 ++- .../{ => source}/file_directory.cpp | 3 ++ .../filesystem/{ => source}/file_grp.cpp | 4 +- .../filesystem/{ => source}/file_lump.cpp | 2 + .../filesystem/{ => source}/file_pak.cpp | 4 +- .../filesystem/{ => source}/file_rff.cpp | 5 ++- .../filesystem/{ => source}/file_ssi.cpp | 3 ++ .../filesystem/{ => source}/file_wad.cpp | 7 ++-- .../filesystem/{ => source}/file_whres.cpp | 6 ++- .../filesystem/{ => source}/file_zip.cpp | 5 ++- src/common/filesystem/{ => source}/file_zip.h | 2 + src/common/filesystem/{ => source}/files.cpp | 8 ++-- .../{ => source}/files_decompress.cpp | 8 +++- .../filesystem/{ => source}/filesystem.cpp | 34 +++++++-------- .../filesystem/{ => source}/fs_findfile.cpp | 4 +- .../filesystem/{ => source}/fs_stringpool.cpp | 4 ++ .../filesystem/{ => source}/fs_stringpool.h | 2 + src/common/filesystem/{ => source}/md5.hpp | 2 +- .../filesystem/{ => source}/resourcefile.cpp | 6 ++- src/common/filesystem/{ => source}/w_zip.h | 3 ++ src/common/fonts/font.cpp | 4 +- src/common/fonts/hexfont.cpp | 2 +- src/common/fonts/singlelumpfont.cpp | 4 +- src/common/fonts/v_font.cpp | 2 +- src/common/fonts/v_font.h | 2 +- src/common/menu/menudef.cpp | 2 +- src/common/menu/savegamemanager.cpp | 4 +- src/common/models/model.cpp | 2 +- src/common/models/models_iqm.cpp | 2 +- src/common/models/models_md2.cpp | 4 +- src/common/models/models_md3.cpp | 2 +- src/common/models/models_ue1.cpp | 4 +- src/common/models/voxels.cpp | 2 +- src/common/rendering/gles/gles_shader.cpp | 4 +- src/common/rendering/v_video.h | 2 +- .../rendering/vulkan/shaders/vk_shader.cpp | 2 +- .../startscreen/startscreen_generic.cpp | 2 +- src/common/startscreen/startscreen_hexen.cpp | 6 +-- src/common/startscreen/startscreen_strife.cpp | 2 +- src/common/textures/formats/anmtexture.cpp | 2 +- .../textures/formats/automaptexture.cpp | 2 +- src/common/textures/formats/imgztexture.cpp | 2 +- src/common/textures/formats/patchtexture.cpp | 4 +- .../textures/formats/rawpagetexture.cpp | 6 +-- .../textures/formats/startuptexture.cpp | 12 +++--- src/common/textures/gametexture.cpp | 4 +- src/common/textures/m_png.h | 9 ++-- .../textures/multipatchtexturebuilder.cpp | 4 +- src/common/textures/texturemanager.cpp | 1 + src/common/utility/cmdlib.cpp | 2 +- src/common/utility/cmdlib.h | 2 +- src/common/utility/filereadermusicinterface.h | 1 + src/common/utility/findfile.cpp | 8 ++-- src/common/utility/palette.cpp | 2 +- src/common/utility/s_playlist.h | 2 +- src/common/utility/zstring.h | 3 +- src/d_iwad.cpp | 8 ++-- src/d_main.cpp | 2 + src/g_game.cpp | 4 +- src/g_level.cpp | 2 +- src/g_level.h | 2 +- src/gameconfigfile.h | 1 + src/gamedata/decallib.cpp | 2 +- src/gamedata/doomfont.h | 10 ++--- src/gamedata/g_mapinfo.cpp | 6 +-- src/gamedata/g_mapinfo.h | 3 +- src/gamedata/keysections.cpp | 2 +- src/gamedata/textures/anim_switches.cpp | 2 +- src/gamedata/textures/animations.cpp | 2 +- src/gamedata/textures/buildloader.cpp | 4 +- src/maploader/edata.cpp | 2 +- src/maploader/glnodes.cpp | 10 ++--- src/maploader/maploader.cpp | 8 ++-- src/maploader/maploader.h | 2 +- src/menu/loadsavemenu.cpp | 6 +-- src/p_conversation.h | 2 - src/p_setup.h | 2 +- src/playsim/fragglescript/t_func.cpp | 2 + src/playsim/p_acs.cpp | 4 +- src/playsim/p_acs.h | 2 +- src/playsim/p_user.cpp | 8 ++-- src/r_data/colormaps.cpp | 4 +- src/r_data/r_translate.cpp | 4 +- src/r_data/sprites.cpp | 10 ++--- src/r_data/v_palette.cpp | 2 + src/r_data/voxeldef.cpp | 2 + src/rendering/swrenderer/r_swcolormaps.cpp | 4 +- src/sound/s_advsound.cpp | 2 + src/sound/s_doomsound.cpp | 2 +- 108 files changed, 306 insertions(+), 223 deletions(-) create mode 100644 src/common/engine/files.h create mode 100644 src/common/engine/filesystem.h rename src/common/filesystem/{files.h => include/fs_files.h} (98%) rename src/common/filesystem/{filesystem.h => include/fs_filesystem.h} (83%) rename src/common/filesystem/{ => include}/fs_findfile.h (97%) rename src/common/filesystem/{ => include}/fs_swap.h (97%) rename src/common/filesystem/{ => include}/resourcefile.h (99%) rename src/common/filesystem/{ => source}/ancientzip.cpp (99%) rename src/common/filesystem/{ => source}/ancientzip.h (94%) rename src/common/filesystem/{ => source}/file_7z.cpp (99%) rename src/common/filesystem/{ => source}/file_directory.cpp (99%) rename src/common/filesystem/{ => source}/file_grp.cpp (98%) rename src/common/filesystem/{ => source}/file_lump.cpp (99%) rename src/common/filesystem/{ => source}/file_pak.cpp (98%) rename src/common/filesystem/{ => source}/file_rff.cpp (99%) rename src/common/filesystem/{ => source}/file_ssi.cpp (99%) rename src/common/filesystem/{ => source}/file_wad.cpp (99%) rename src/common/filesystem/{ => source}/file_whres.cpp (98%) rename src/common/filesystem/{ => source}/file_zip.cpp (99%) rename src/common/filesystem/{ => source}/file_zip.h (97%) rename src/common/filesystem/{ => source}/files.cpp (99%) rename src/common/filesystem/{ => source}/files_decompress.cpp (99%) rename src/common/filesystem/{ => source}/filesystem.cpp (98%) rename src/common/filesystem/{ => source}/fs_findfile.cpp (99%) rename src/common/filesystem/{ => source}/fs_stringpool.cpp (99%) rename src/common/filesystem/{ => source}/fs_stringpool.h (96%) rename src/common/filesystem/{ => source}/md5.hpp (99%) rename src/common/filesystem/{ => source}/resourcefile.cpp (99%) rename src/common/filesystem/{ => source}/w_zip.h (98%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 681a92016a..35587dfa87 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -581,7 +581,8 @@ file( GLOB HEADER_FILES common/statusbar/*.h common/fonts/*.h common/objects/*.h - common/filesystem/*.h + common/filesystem/include/*.h + common/filesystem/source/*.h common/platform/posix/cocoa/*.h common/platform/posix/sdl/*.h common/platform/win32/*.h @@ -1206,23 +1207,23 @@ set( ZDOOM_SOURCES common/thirdparty/math/tanh.c common/thirdparty/math/fastsin.cpp - common/filesystem/filesystem.cpp - common/filesystem/ancientzip.cpp - common/filesystem/file_7z.cpp - common/filesystem/file_grp.cpp - common/filesystem/file_lump.cpp - common/filesystem/file_rff.cpp - common/filesystem/file_wad.cpp - common/filesystem/file_zip.cpp - common/filesystem/file_pak.cpp - common/filesystem/file_whres.cpp - common/filesystem/file_ssi.cpp - common/filesystem/file_directory.cpp - common/filesystem/resourcefile.cpp - common/filesystem/files.cpp - common/filesystem/files_decompress.cpp - common/filesystem/fs_findfile.cpp - common/filesystem/fs_stringpool.cpp + common/filesystem/source/filesystem.cpp + common/filesystem/source/ancientzip.cpp + common/filesystem/source/file_7z.cpp + common/filesystem/source/file_grp.cpp + common/filesystem/source/file_lump.cpp + common/filesystem/source/file_rff.cpp + common/filesystem/source/file_wad.cpp + common/filesystem/source/file_zip.cpp + common/filesystem/source/file_pak.cpp + common/filesystem/source/file_whres.cpp + common/filesystem/source/file_ssi.cpp + common/filesystem/source/file_directory.cpp + common/filesystem/source/resourcefile.cpp + common/filesystem/source/files.cpp + common/filesystem/source/files_decompress.cpp + common/filesystem/source/fs_findfile.cpp + common/filesystem/source/fs_stringpool.cpp ) @@ -1269,7 +1270,7 @@ include_directories( common/textures/hires common/textures common/models - common/filesystem + common/filesystem/include common/utility common/console common/engine @@ -1470,6 +1471,8 @@ source_group("Common\\Objects" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/ source_group("Common\\Menu" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/menu/.+") source_group("Common\\Fonts" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/fonts/.+") source_group("Common\\File System" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/filesystem/.+") +source_group("Common\\File System\\Include" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/filesystem/include/.+") +source_group("Common\\File System\\Source" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/filesystem/source/.+") source_group("Common\\Scripting" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/scripting/.+") source_group("Common\\Scripting\\Interface" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/scripting/interface/.+") source_group("Common\\Scripting\\Frontend" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/scripting/frontend/.+" FILES ${CMAKE_CURRENT_BINARY_DIR}/zcc-parse.c ${CMAKE_CURRENT_BINARY_DIR}/zcc-parse.h) diff --git a/src/common/audio/music/i_music.cpp b/src/common/audio/music/i_music.cpp index 19c8309162..2e0f83319b 100644 --- a/src/common/audio/music/i_music.cpp +++ b/src/common/audio/music/i_music.cpp @@ -53,6 +53,7 @@ #include "s_music.h" #include "filereadermusicinterface.h" +using namespace FileSys; void I_InitSoundFonts(); @@ -192,7 +193,7 @@ static void SetupWgOpn() { return; } - FileData data = fileSystem.ReadFile(lump); + auto data = fileSystem.ReadFile(lump); ZMusic_SetWgOpn(data.GetMem(), (uint32_t)data.GetSize()); } @@ -204,7 +205,7 @@ static void SetupDMXGUS() { return; } - FileData data = fileSystem.ReadFile(lump); + auto data = fileSystem.ReadFile(lump); ZMusic_SetDmxGus(data.GetMem(), (uint32_t)data.GetSize()); } diff --git a/src/common/audio/music/i_soundfont.cpp b/src/common/audio/music/i_soundfont.cpp index 72b8ab44d7..bac39d3a1e 100644 --- a/src/common/audio/music/i_soundfont.cpp +++ b/src/common/audio/music/i_soundfont.cpp @@ -40,10 +40,9 @@ #include "i_system.h" #include "filereadermusicinterface.h" #include -#include "resourcefile.h" +#include "fs_filesystem.h" #include "version.h" #include "fs_findfile.h" -#include "resourcefile.h" #include "i_interface.h" #include "configfile.h" #include "printf.h" @@ -402,7 +401,7 @@ void FSoundFontManager::CollectSoundfonts() { if (stricmp (key, "Path") == 0) { - FileList list; + FileSys::FileList list; FString dir; @@ -410,7 +409,7 @@ void FSoundFontManager::CollectSoundfonts() FixPathSeperator(dir); if (dir.IsNotEmpty()) { - if (ScanDirectory(list, dir.GetChars(), "*", true)) + if (FileSys::ScanDirectory(list, dir.GetChars(), "*", true)) { for(auto& entry : list) { diff --git a/src/common/audio/music/music.cpp b/src/common/audio/music/music.cpp index d9b99fc2b4..adffe332ff 100644 --- a/src/common/audio/music/music.cpp +++ b/src/common/audio/music/music.cpp @@ -55,6 +55,7 @@ #include "i_specialpaths.h" #include "configfile.h" #include "c_cvars.h" +#include "md5.h" // EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- diff --git a/src/common/audio/music/s_music.h b/src/common/audio/music/s_music.h index 1970a57daf..6ae4017c9e 100644 --- a/src/common/audio/music/s_music.h +++ b/src/common/audio/music/s_music.h @@ -5,9 +5,9 @@ #include "zstring.h" #include "tarray.h" #include "name.h" +#include "files.h" #include -class FileReader; class SoundStream; diff --git a/src/common/audio/sound/i_sound.h b/src/common/audio/sound/i_sound.h index 0805154946..e8e5a1a0e9 100644 --- a/src/common/audio/sound/i_sound.h +++ b/src/common/audio/sound/i_sound.h @@ -40,8 +40,8 @@ #include "i_soundinternal.h" #include "zstring.h" #include +#include "files.h" -class FileReader; struct FSoundChan; enum EStartSoundFlags diff --git a/src/common/console/c_enginecmds.cpp b/src/common/console/c_enginecmds.cpp index 40be686881..f6b8732de5 100644 --- a/src/common/console/c_enginecmds.cpp +++ b/src/common/console/c_enginecmds.cpp @@ -201,8 +201,8 @@ UNSAFE_CCMD (dir) bpath = path; } - FileList list; - if (!ScanDirectory(list, bpath, base, true)) + FileSys::FileList list; + if (!FileSys::ScanDirectory(list, bpath, base, true)) { Printf ("Nothing matching %s\n", path.GetChars()); } diff --git a/src/common/engine/files.h b/src/common/engine/files.h new file mode 100644 index 0000000000..af6694cf05 --- /dev/null +++ b/src/common/engine/files.h @@ -0,0 +1,6 @@ +#pragma once +#include "fs_files.h" + +using FileSys::FileReader; +using FileSys::FileWriter; +using FileSys::BufferWriter; \ No newline at end of file diff --git a/src/common/engine/filesystem.h b/src/common/engine/filesystem.h new file mode 100644 index 0000000000..53f4916771 --- /dev/null +++ b/src/common/engine/filesystem.h @@ -0,0 +1,7 @@ +#pragma once +#include "fs_filesystem.h" + +using FileSys::FileSystem; +using FileSys::FResourceFile; + +inline FileSys::FileSystem fileSystem; diff --git a/src/common/engine/palettecontainer.h b/src/common/engine/palettecontainer.h index a220873a6e..a761ae33c6 100644 --- a/src/common/engine/palettecontainer.h +++ b/src/common/engine/palettecontainer.h @@ -3,8 +3,7 @@ #include #include "memarena.h" #include "palentry.h" - -class FileReader; +#include "files.h" enum { diff --git a/src/common/engine/serializer.cpp b/src/common/engine/serializer.cpp index 571a314d0b..d0e6ac7c16 100644 --- a/src/common/engine/serializer.cpp +++ b/src/common/engine/serializer.cpp @@ -57,6 +57,8 @@ #include "base64.h" #include "vm.h" +using namespace FileSys; + extern DObject *WP_NOCHANGE; bool save_full = false; // for testing. Should be removed afterward. diff --git a/src/common/engine/serializer.h b/src/common/engine/serializer.h index c9cc26320f..a6f74c0371 100644 --- a/src/common/engine/serializer.h +++ b/src/common/engine/serializer.h @@ -4,7 +4,6 @@ #include #include #include "tarray.h" -#include "file_zip.h" #include "tflags.h" #include "vectors.h" #include "palentry.h" @@ -80,7 +79,7 @@ public: void SetUniqueSoundNames() { soundNamesAreUnique = true; } bool OpenWriter(bool pretty = true); bool OpenReader(const char *buffer, size_t length); - bool OpenReader(FCompressedBuffer *input); + bool OpenReader(FileSys::FCompressedBuffer *input); void Close(); void ReadObjects(bool hubtravel); bool BeginObject(const char *name); @@ -91,7 +90,7 @@ public: unsigned GetSize(const char *group); const char *GetKey(); const char *GetOutput(unsigned *len = nullptr); - FCompressedBuffer GetCompressedOutput(); + FileSys::FCompressedBuffer GetCompressedOutput(); // The sprite serializer is a special case because it is needed by the VM to handle its 'spriteid' type. virtual FSerializer &Sprite(const char *key, int32_t &spritenum, int32_t *def); // This is only needed by the type system. diff --git a/src/common/filesystem/files.h b/src/common/filesystem/include/fs_files.h similarity index 98% rename from src/common/filesystem/files.h rename to src/common/filesystem/include/fs_files.h index 99a3b133f4..e732824974 100644 --- a/src/common/filesystem/files.h +++ b/src/common/filesystem/include/fs_files.h @@ -45,6 +45,8 @@ #include "tarray.h" +namespace FileSys { + class FileSystemException : public std::exception { protected: @@ -271,7 +273,7 @@ public: { uint16_t v = 0; Read(&v, 2); - return fs_private::LittleShort(v); + return byteswap::LittleShort(v); } int16_t ReadInt16() @@ -283,7 +285,7 @@ public: { uint16_t v = 0; Read(&v, 2); - return fs_private::BigShort(v); + return byteswap::BigShort(v); } int16_t ReadInt16BE() @@ -295,7 +297,7 @@ public: { uint32_t v = 0; Read(&v, 4); - return fs_private::LittleLong(v); + return byteswap::LittleLong(v); } int32_t ReadInt32() @@ -307,7 +309,7 @@ public: { uint32_t v = 0; Read(&v, 4); - return fs_private::BigLong(v); + return byteswap::BigLong(v); } int32_t ReadInt32BE() @@ -394,5 +396,6 @@ public: TArray&& TakeBuffer() { return std::move(mBuffer); } }; +} #endif diff --git a/src/common/filesystem/filesystem.h b/src/common/filesystem/include/fs_filesystem.h similarity index 83% rename from src/common/filesystem/filesystem.h rename to src/common/filesystem/include/fs_filesystem.h index 7dcda2f09f..e976733143 100644 --- a/src/common/filesystem/filesystem.h +++ b/src/common/filesystem/include/fs_filesystem.h @@ -8,10 +8,11 @@ -#include "files.h" -#include "cmdlib.h" +#include "fs_files.h" #include "resourcefile.h" +namespace FileSys { + class FResourceFile; struct FResourceLump; @@ -92,31 +93,31 @@ public: int GetLastEntry(int wadnum) const noexcept; int GetEntryCount(int wadnum) const noexcept; - int CheckNumForName (const char *name, int namespc); - int CheckNumForName (const char *name, int namespc, int wadfile, bool exact = true); - int GetNumForName (const char *name, int namespc); + int CheckNumForName (const char *name, int namespc) const; + int CheckNumForName (const char *name, int namespc, int wadfile, bool exact = true) const; + int GetNumForName (const char *name, int namespc) const; - inline int CheckNumForName (const uint8_t *name) { return CheckNumForName ((const char *)name, ns_global); } - inline int CheckNumForName (const char *name) { return CheckNumForName (name, ns_global); } - inline int CheckNumForName (const uint8_t *name, int ns) { return CheckNumForName ((const char *)name, ns); } - inline int GetNumForName (const char *name) { return GetNumForName (name, ns_global); } - inline int GetNumForName (const uint8_t *name) { return GetNumForName ((const char *)name); } - inline int GetNumForName (const uint8_t *name, int ns) { return GetNumForName ((const char *)name, ns); } + inline int CheckNumForName (const uint8_t *name) const { return CheckNumForName ((const char *)name, ns_global); } + inline int CheckNumForName (const char *name) const { return CheckNumForName (name, ns_global); } + inline int CheckNumForName (const uint8_t *name, int ns) const { return CheckNumForName ((const char *)name, ns); } + inline int GetNumForName (const char *name) const { return GetNumForName (name, ns_global); } + inline int GetNumForName (const uint8_t *name) const { return GetNumForName ((const char *)name); } + inline int GetNumForName (const uint8_t *name, int ns) const { return GetNumForName ((const char *)name, ns); } - int CheckNumForFullName (const char *name, bool trynormal = false, int namespc = ns_global, bool ignoreext = false); - int CheckNumForFullName (const char *name, int wadfile); - int GetNumForFullName (const char *name); - int FindFile(const char* name) + int CheckNumForFullName (const char *cname, bool trynormal = false, int namespc = ns_global, bool ignoreext = false) const; + int CheckNumForFullName (const char *name, int wadfile) const; + int GetNumForFullName (const char *name) const; + int FindFile(const char* name) const { return CheckNumForFullName(name); } - bool FileExists(const char* name) + bool FileExists(const char* name) const { return FindFile(name) >= 0; } - bool FileExists(const std::string& name) + bool FileExists(const std::string& name) const { return FindFile(name.c_str()) >= 0; } @@ -140,7 +141,7 @@ public: int FindLumpFullName(const char* name, int* lastlump, bool noext = false); bool CheckFileName (int lump, const char *name); // [RH] True if lump's name == name - int FindFileWithExtensions(const char* name, const char* const* exts, int count); + int FindFileWithExtensions(const char* name, const char* const* exts, int count) const; int FindResource(int resid, const char* type, int filenum = -1) const noexcept; int GetResource(int resid, const char* type, int filenum = -1) const; @@ -212,5 +213,4 @@ private: }; -extern FileSystem fileSystem; - +} \ No newline at end of file diff --git a/src/common/filesystem/fs_findfile.h b/src/common/filesystem/include/fs_findfile.h similarity index 97% rename from src/common/filesystem/fs_findfile.h rename to src/common/filesystem/include/fs_findfile.h index 7b6d3e3d22..d845b7d142 100644 --- a/src/common/filesystem/fs_findfile.h +++ b/src/common/filesystem/include/fs_findfile.h @@ -5,6 +5,8 @@ #include #include +namespace FileSys { + struct FileListEntry { std::string FileName; // file name only @@ -34,3 +36,4 @@ inline void FixPathSeparator(char* path) } } +} diff --git a/src/common/filesystem/fs_swap.h b/src/common/filesystem/include/fs_swap.h similarity index 97% rename from src/common/filesystem/fs_swap.h rename to src/common/filesystem/include/fs_swap.h index 1e8bbef832..12b988585f 100644 --- a/src/common/filesystem/fs_swap.h +++ b/src/common/filesystem/include/fs_swap.h @@ -17,9 +17,9 @@ #include #endif -namespace fs_private -{ - +namespace FileSys { +namespace byteswap { + #ifdef __APPLE__ inline unsigned short LittleShort(unsigned short x) @@ -117,5 +117,6 @@ inline unsigned int BigLong (unsigned int x) #endif // __BIG_ENDIAN__ } +} #endif // __M_SWAP_H__ diff --git a/src/common/filesystem/resourcefile.h b/src/common/filesystem/include/resourcefile.h similarity index 99% rename from src/common/filesystem/resourcefile.h rename to src/common/filesystem/include/resourcefile.h index 4619bbeb0c..91d437d388 100644 --- a/src/common/filesystem/resourcefile.h +++ b/src/common/filesystem/include/resourcefile.h @@ -6,8 +6,10 @@ #include #include #include -#include "files.h" +#include "fs_files.h" +namespace FileSys { + class StringPool; std::string ExtractBaseName(const char* path, bool include_extension = false); void strReplace(std::string& str, const char* from, const char* to); @@ -246,7 +248,6 @@ struct FMemoryLump : public FResourceLump }; - - +} #endif diff --git a/src/common/filesystem/ancientzip.cpp b/src/common/filesystem/source/ancientzip.cpp similarity index 99% rename from src/common/filesystem/ancientzip.cpp rename to src/common/filesystem/source/ancientzip.cpp index 80f0c60935..4d1e6b9909 100644 --- a/src/common/filesystem/ancientzip.cpp +++ b/src/common/filesystem/source/ancientzip.cpp @@ -46,6 +46,8 @@ #include #include "ancientzip.h" +namespace FileSys { + /**************************************************************** Bit-I/O variables and routines/macros @@ -433,3 +435,5 @@ int ShrinkLoop(unsigned char *out, unsigned int outsize, FileReader &_In, unsign } return 0; } + +} diff --git a/src/common/filesystem/ancientzip.h b/src/common/filesystem/source/ancientzip.h similarity index 94% rename from src/common/filesystem/ancientzip.h rename to src/common/filesystem/source/ancientzip.h index 57b0f3584a..e25a75d3b4 100644 --- a/src/common/filesystem/ancientzip.h +++ b/src/common/filesystem/source/ancientzip.h @@ -1,6 +1,8 @@ #pragma once -#include "files.h" +#include "fs_files.h" +namespace FileSys { + class FZipExploder { unsigned int Hold, Bits; @@ -41,4 +43,5 @@ public: int Explode(unsigned char *out, unsigned int outsize, FileReader &in, unsigned int insize, int flags); }; -int ShrinkLoop(unsigned char *out, unsigned int outsize, FileReader &in, unsigned int insize); \ No newline at end of file +int ShrinkLoop(unsigned char *out, unsigned int outsize, FileReader &in, unsigned int insize); +} diff --git a/src/common/filesystem/file_7z.cpp b/src/common/filesystem/source/file_7z.cpp similarity index 99% rename from src/common/filesystem/file_7z.cpp rename to src/common/filesystem/source/file_7z.cpp index abf67fded2..c51a566b92 100644 --- a/src/common/filesystem/file_7z.cpp +++ b/src/common/filesystem/source/file_7z.cpp @@ -40,7 +40,8 @@ #include "fs_findfile.h" - +namespace FileSys { + //----------------------------------------------------------------------- // // Interface classes to 7z library @@ -374,4 +375,4 @@ FResourceFile *Check7Z(const char *filename, FileReader &file, LumpFilterInfo* f } - +} diff --git a/src/common/filesystem/file_directory.cpp b/src/common/filesystem/source/file_directory.cpp similarity index 99% rename from src/common/filesystem/file_directory.cpp rename to src/common/filesystem/source/file_directory.cpp index f9b24da3ad..8208e66346 100644 --- a/src/common/filesystem/file_directory.cpp +++ b/src/common/filesystem/source/file_directory.cpp @@ -40,6 +40,8 @@ #include "fs_findfile.h" #include "fs_stringpool.h" +namespace FileSys { + std::string FS_FullPath(const char* directory); #ifdef _WIN32 @@ -231,3 +233,4 @@ FResourceFile *CheckDir(const char *filename, bool nosubdirflag, LumpFilterInfo* return nullptr; } +} diff --git a/src/common/filesystem/file_grp.cpp b/src/common/filesystem/source/file_grp.cpp similarity index 98% rename from src/common/filesystem/file_grp.cpp rename to src/common/filesystem/source/file_grp.cpp index dd8099a2a2..bd543a5592 100644 --- a/src/common/filesystem/file_grp.cpp +++ b/src/common/filesystem/source/file_grp.cpp @@ -36,7 +36,8 @@ #include "resourcefile.h" #include "fs_swap.h" -using namespace fs_private; +namespace FileSys { + using namespace byteswap; //========================================================================== // @@ -152,3 +153,4 @@ FResourceFile *CheckGRP(const char *filename, FileReader &file, LumpFilterInfo* return NULL; } +} diff --git a/src/common/filesystem/file_lump.cpp b/src/common/filesystem/source/file_lump.cpp similarity index 99% rename from src/common/filesystem/file_lump.cpp rename to src/common/filesystem/source/file_lump.cpp index 85f41d7758..c9885a1269 100644 --- a/src/common/filesystem/file_lump.cpp +++ b/src/common/filesystem/source/file_lump.cpp @@ -34,6 +34,7 @@ #include "resourcefile.h" +namespace FileSys { //========================================================================== // // Single lump @@ -93,3 +94,4 @@ FResourceFile *CheckLump(const char *filename, FileReader &file, LumpFilterInfo* return NULL; } +} diff --git a/src/common/filesystem/file_pak.cpp b/src/common/filesystem/source/file_pak.cpp similarity index 98% rename from src/common/filesystem/file_pak.cpp rename to src/common/filesystem/source/file_pak.cpp index dfcc22ef4a..c8c039209c 100644 --- a/src/common/filesystem/file_pak.cpp +++ b/src/common/filesystem/source/file_pak.cpp @@ -34,8 +34,9 @@ #include "resourcefile.h" -using namespace fs_private; +namespace FileSys { + using namespace byteswap; //========================================================================== // // @@ -145,3 +146,4 @@ FResourceFile *CheckPak(const char *filename, FileReader &file, LumpFilterInfo* return NULL; } +} diff --git a/src/common/filesystem/file_rff.cpp b/src/common/filesystem/source/file_rff.cpp similarity index 99% rename from src/common/filesystem/file_rff.cpp rename to src/common/filesystem/source/file_rff.cpp index 5204d7f0ff..edb003810c 100644 --- a/src/common/filesystem/file_rff.cpp +++ b/src/common/filesystem/source/file_rff.cpp @@ -36,7 +36,8 @@ #include "resourcefile.h" #include "fs_swap.h" -using namespace fs_private; +namespace FileSys { + using namespace byteswap; //========================================================================== // @@ -260,4 +261,4 @@ FResourceFile *CheckRFF(const char *filename, FileReader &file, LumpFilterInfo* } - +} diff --git a/src/common/filesystem/file_ssi.cpp b/src/common/filesystem/source/file_ssi.cpp similarity index 99% rename from src/common/filesystem/file_ssi.cpp rename to src/common/filesystem/source/file_ssi.cpp index 0cfab8729b..0e48ef49d7 100644 --- a/src/common/filesystem/file_ssi.cpp +++ b/src/common/filesystem/source/file_ssi.cpp @@ -35,6 +35,7 @@ #include "resourcefile.h" +namespace FileSys { //========================================================================== // // Build GRP file @@ -152,3 +153,5 @@ FResourceFile* CheckSSI(const char* filename, FileReader& file, LumpFilterInfo* } return nullptr; } + +} diff --git a/src/common/filesystem/file_wad.cpp b/src/common/filesystem/source/file_wad.cpp similarity index 99% rename from src/common/filesystem/file_wad.cpp rename to src/common/filesystem/source/file_wad.cpp index 60392dfb76..13eb0b098a 100644 --- a/src/common/filesystem/file_wad.cpp +++ b/src/common/filesystem/source/file_wad.cpp @@ -35,11 +35,11 @@ #include #include "resourcefile.h" -#include "filesystem.h" +#include "fs_filesystem.h" #include "fs_swap.h" -using namespace fs_private; - +namespace FileSys { + using namespace byteswap; struct wadinfo_t { @@ -485,3 +485,4 @@ FResourceFile *CheckWad(const char *filename, FileReader &file, LumpFilterInfo* return NULL; } +} diff --git a/src/common/filesystem/file_whres.cpp b/src/common/filesystem/source/file_whres.cpp similarity index 98% rename from src/common/filesystem/file_whres.cpp rename to src/common/filesystem/source/file_whres.cpp index ba07945b3f..41e418773e 100644 --- a/src/common/filesystem/file_whres.cpp +++ b/src/common/filesystem/source/file_whres.cpp @@ -38,7 +38,8 @@ #include "fs_stringpool.h" #include "fs_swap.h" -using namespace fs_private; +namespace FileSys { + using namespace byteswap; //========================================================================== // @@ -140,4 +141,5 @@ FResourceFile *CheckWHRes(const char *filename, FileReader &file, LumpFilterInfo } return NULL; } - \ No newline at end of file + +} \ No newline at end of file diff --git a/src/common/filesystem/file_zip.cpp b/src/common/filesystem/source/file_zip.cpp similarity index 99% rename from src/common/filesystem/file_zip.cpp rename to src/common/filesystem/source/file_zip.cpp index f97f196566..c85788fe5c 100644 --- a/src/common/filesystem/file_zip.cpp +++ b/src/common/filesystem/source/file_zip.cpp @@ -41,7 +41,8 @@ #include "fs_findfile.h" #include "fs_swap.h" -using namespace fs_private; +namespace FileSys { + using namespace byteswap; #define BUFREADCOMMENT (0x400) @@ -720,3 +721,5 @@ bool WriteZip(const char* filename, const FCompressedBuffer* content, size_t con } return false; } + +} diff --git a/src/common/filesystem/file_zip.h b/src/common/filesystem/source/file_zip.h similarity index 97% rename from src/common/filesystem/file_zip.h rename to src/common/filesystem/source/file_zip.h index 5b49b714f3..8313c9eb2c 100644 --- a/src/common/filesystem/file_zip.h +++ b/src/common/filesystem/source/file_zip.h @@ -3,6 +3,7 @@ #include "resourcefile.h" +namespace FileSys { //========================================================================== // // Zip Lump @@ -45,5 +46,6 @@ public: virtual FResourceLump *GetLump(int no) { return ((unsigned)no < NumLumps)? &Lumps[no] : NULL; } }; +} #endif \ No newline at end of file diff --git a/src/common/filesystem/files.cpp b/src/common/filesystem/source/files.cpp similarity index 99% rename from src/common/filesystem/files.cpp rename to src/common/filesystem/source/files.cpp index 89983d87c6..4d92cc25cd 100644 --- a/src/common/filesystem/files.cpp +++ b/src/common/filesystem/source/files.cpp @@ -34,10 +34,10 @@ */ #include -#include "files.h" - -using namespace fs_private; +#include "fs_files.h" +namespace FileSys { + #ifdef _WIN32 std::wstring toWide(const char* str); #endif @@ -494,3 +494,5 @@ size_t BufferWriter::Write(const void *buffer, size_t len) memcpy(&mBuffer[ofs], buffer, len); return len; } + +} diff --git a/src/common/filesystem/files_decompress.cpp b/src/common/filesystem/source/files_decompress.cpp similarity index 99% rename from src/common/filesystem/files_decompress.cpp rename to src/common/filesystem/source/files_decompress.cpp index 8b8f4958aa..5948177cf5 100644 --- a/src/common/filesystem/files_decompress.cpp +++ b/src/common/filesystem/source/files_decompress.cpp @@ -41,7 +41,10 @@ #include #include -#include "files.h" +#include "fs_files.h" + +namespace FileSys { + using namespace byteswap; //========================================================================== // @@ -538,7 +541,7 @@ class DecompressorLZSS : public DecompressorBase return false; Stream.AvailIn -= 2; - uint16_t pos = fs_private::BigShort(*(uint16_t*)Stream.In); + uint16_t pos = BigShort(*(uint16_t*)Stream.In); uint8_t len = (pos & 0xF)+1; pos >>= 4; Stream.In += 2; @@ -752,3 +755,4 @@ bool FileReader::OpenDecompressor(FileReader &parent, Size length, int method, b } } +} diff --git a/src/common/filesystem/filesystem.cpp b/src/common/filesystem/source/filesystem.cpp similarity index 98% rename from src/common/filesystem/filesystem.cpp rename to src/common/filesystem/source/filesystem.cpp index 60a62697da..c8623765e1 100644 --- a/src/common/filesystem/filesystem.cpp +++ b/src/common/filesystem/source/filesystem.cpp @@ -41,11 +41,13 @@ #include #include -#include "filesystem.h" +#include "fs_filesystem.h" #include "fs_findfile.h" #include "md5.hpp" #include "fs_stringpool.h" +namespace FileSys { + // MACROS ------------------------------------------------------------------ #define NULL_INDEX (0xffffffff) @@ -72,7 +74,7 @@ static uint32_t MakeHash(const char* str, size_t length = SIZE_MAX) static void md5Hash(FileReader& reader, uint8_t* digest) { - using namespace fs_private::md5; + using namespace md5; md5_state_t state; md5_init(&state); @@ -187,8 +189,6 @@ static void PrintLastError (FileSystemMessageFunc Printf); // PUBLIC DATA DEFINITIONS ------------------------------------------------- -FileSystem fileSystem; - // CODE -------------------------------------------------------------------- FileSystem::FileSystem() @@ -511,7 +511,7 @@ int FileSystem::CheckIfResourceFileLoaded (const char *name) noexcept // and namespace parameter //========================================================================== -int FileSystem::CheckNumForName (const char *name, int space) +int FileSystem::CheckNumForName (const char *name, int space) const { union { @@ -556,7 +556,7 @@ int FileSystem::CheckNumForName (const char *name, int space) return i != NULL_INDEX ? i : -1; } -int FileSystem::CheckNumForName (const char *name, int space, int rfnum, bool exact) +int FileSystem::CheckNumForName (const char *name, int space, int rfnum, bool exact) const { union { @@ -594,7 +594,7 @@ int FileSystem::CheckNumForName (const char *name, int space, int rfnum, bool ex // //========================================================================== -int FileSystem::GetNumForName (const char *name, int space) +int FileSystem::GetNumForName (const char *name, int space) const { int i; @@ -617,7 +617,7 @@ int FileSystem::GetNumForName (const char *name, int space) // //========================================================================== -int FileSystem::CheckNumForFullName (const char *name, bool trynormal, int namespc, bool ignoreext) +int FileSystem::CheckNumForFullName (const char *name, bool trynormal, int namespc, bool ignoreext) const { uint32_t i; @@ -650,7 +650,7 @@ int FileSystem::CheckNumForFullName (const char *name, bool trynormal, int names return -1; } -int FileSystem::CheckNumForFullName (const char *name, int rfnum) +int FileSystem::CheckNumForFullName (const char *name, int rfnum) const { uint32_t i; @@ -678,7 +678,7 @@ int FileSystem::CheckNumForFullName (const char *name, int rfnum) // //========================================================================== -int FileSystem::GetNumForFullName (const char *name) +int FileSystem::GetNumForFullName (const char *name) const { int i; @@ -698,7 +698,7 @@ int FileSystem::GetNumForFullName (const char *name) // //========================================================================== -int FileSystem::FindFileWithExtensions(const char* name, const char *const *exts, int count) +int FileSystem::FindFileWithExtensions(const char* name, const char *const *exts, int count) const { uint32_t i; @@ -1254,7 +1254,7 @@ unsigned FileSystem::GetFilesInFolder(const char *inpath, std::vector maxfile) maxfile = thisfile; } // Delete everything from older files. for (int i = (int)result.size() - 1; i >= 0; i--) { - if (fileSystem.GetFileContainer(result[i].lumpnum) != maxfile) result.erase(result.begin() + i); + if (GetFileContainer(result[i].lumpnum) != maxfile) result.erase(result.begin() + i); } } qsort(result.data(), result.size(), sizeof(FolderEntry), folderentrycmp); @@ -1364,8 +1364,8 @@ FileReader FileSystem::ReopenFileReader(int lump, bool alwayscache) if (rl->RefCount == 0 && rd != nullptr && !rd->GetBuffer() && !alwayscache && !(rl->Flags & LUMPF_COMPRESSED)) { - int fileno = fileSystem.GetFileContainer(lump); - const char *filename = fileSystem.GetResourceFileFullName(fileno); + int fileno = GetFileContainer(lump); + const char *filename = GetResourceFileFullName(fileno); FileReader fr; if (fr.OpenFile(filename, rl->GetFileOffset(), rl->LumpSize)) { @@ -1579,3 +1579,5 @@ FResourceLump* FileSystem::GetFileAt(int no) { return FileInfo[no].lump; } + +} diff --git a/src/common/filesystem/fs_findfile.cpp b/src/common/filesystem/source/fs_findfile.cpp similarity index 99% rename from src/common/filesystem/fs_findfile.cpp rename to src/common/filesystem/source/fs_findfile.cpp index 9dde8fdcbc..39851ce088 100644 --- a/src/common/filesystem/fs_findfile.cpp +++ b/src/common/filesystem/source/fs_findfile.cpp @@ -35,7 +35,8 @@ #include "fs_findfile.h" #include - +namespace FileSys { + enum { ZPATH_MAX = 260 @@ -404,3 +405,4 @@ bool FS_DirEntryExists(const char* pathname, bool* isdir) return res; } +} diff --git a/src/common/filesystem/fs_stringpool.cpp b/src/common/filesystem/source/fs_stringpool.cpp similarity index 99% rename from src/common/filesystem/fs_stringpool.cpp rename to src/common/filesystem/source/fs_stringpool.cpp index 29a4723096..1e42311399 100644 --- a/src/common/filesystem/fs_stringpool.cpp +++ b/src/common/filesystem/source/fs_stringpool.cpp @@ -38,6 +38,8 @@ #include #include "fs_stringpool.h" +namespace FileSys { + struct StringPool::Block { Block *NextBlock; @@ -124,3 +126,5 @@ const char* StringPool::Strdup(const char* str) strcpy(p, str); return p; } + +} diff --git a/src/common/filesystem/fs_stringpool.h b/src/common/filesystem/source/fs_stringpool.h similarity index 96% rename from src/common/filesystem/fs_stringpool.h rename to src/common/filesystem/source/fs_stringpool.h index 331f768f7d..f72a180df6 100644 --- a/src/common/filesystem/fs_stringpool.h +++ b/src/common/filesystem/source/fs_stringpool.h @@ -1,5 +1,6 @@ #pragma once +namespace FileSys { // Storage for all the static strings the file system must hold. class StringPool { @@ -25,3 +26,4 @@ public: bool shared; }; +} diff --git a/src/common/filesystem/md5.hpp b/src/common/filesystem/source/md5.hpp similarity index 99% rename from src/common/filesystem/md5.hpp rename to src/common/filesystem/source/md5.hpp index 2027023ca0..1ecde05d41 100644 --- a/src/common/filesystem/md5.hpp +++ b/src/common/filesystem/source/md5.hpp @@ -69,7 +69,7 @@ #include #include -namespace fs_private { +namespace FileSys { /// Provides MD5 hashing functionality namespace md5 { diff --git a/src/common/filesystem/resourcefile.cpp b/src/common/filesystem/source/resourcefile.cpp similarity index 99% rename from src/common/filesystem/resourcefile.cpp rename to src/common/filesystem/source/resourcefile.cpp index 6e75255913..8a17c09a0a 100644 --- a/src/common/filesystem/resourcefile.cpp +++ b/src/common/filesystem/source/resourcefile.cpp @@ -39,6 +39,8 @@ #include "md5.hpp" #include "fs_stringpool.h" +namespace FileSys { + std::string ExtractBaseName(const char* path, bool include_extension) { const char* src, * dot; @@ -364,7 +366,7 @@ int lumpcmp(const void * a, const void * b) void FResourceFile::GenerateHash() { // hash the lump directory after sorting - using namespace fs_private::md5; + using namespace FileSys::md5; auto n = snprintf(Hash, 48, "%08X-%04X-", (unsigned)Reader.GetLength(), NumLumps); @@ -745,4 +747,4 @@ int FExternalLump::FillCache() } - +} diff --git a/src/common/filesystem/w_zip.h b/src/common/filesystem/source/w_zip.h similarity index 98% rename from src/common/filesystem/w_zip.h rename to src/common/filesystem/source/w_zip.h index c0905cd20c..d26d7f0039 100644 --- a/src/common/filesystem/w_zip.h +++ b/src/common/filesystem/source/w_zip.h @@ -7,6 +7,8 @@ #define FORCE_PACKED #endif +namespace FileSys { + #pragma pack(1) // FZipCentralInfo struct FZipEndOfCentralDirectory @@ -105,4 +107,5 @@ struct FZipLocalFileHeader // File header flags. #define ZF_ENCRYPTED 0x1 +} #endif diff --git a/src/common/fonts/font.cpp b/src/common/fonts/font.cpp index be02a8b590..1714d78b4f 100644 --- a/src/common/fonts/font.cpp +++ b/src/common/fonts/font.cpp @@ -91,7 +91,7 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla // Read the font's configuration. // This will not be done for the default fonts, because they are not atomic and the default content does not need it. - std::vector folderdata; + std::vector folderdata; if (filetemplate != nullptr) { FStringf path("fonts/%s/", filetemplate); @@ -398,7 +398,7 @@ public: } }; -void FFont::ReadSheetFont(std::vector &folderdata, int width, int height, const DVector2 &Scale) +void FFont::ReadSheetFont(std::vector &folderdata, int width, int height, const DVector2 &Scale) { TMap charMap; int minchar = INT_MAX; diff --git a/src/common/fonts/hexfont.cpp b/src/common/fonts/hexfont.cpp index 643b44d4de..52d723fa60 100644 --- a/src/common/fonts/hexfont.cpp +++ b/src/common/fonts/hexfont.cpp @@ -58,7 +58,7 @@ struct HexDataSource // //========================================================================== - void ParseDefinition(FResourceLump* font) + void ParseDefinition(FileSys::FResourceLump* font) { FScanner sc; diff --git a/src/common/fonts/singlelumpfont.cpp b/src/common/fonts/singlelumpfont.cpp index 72a3b18053..b40a86bff4 100644 --- a/src/common/fonts/singlelumpfont.cpp +++ b/src/common/fonts/singlelumpfont.cpp @@ -124,7 +124,7 @@ FSingleLumpFont::FSingleLumpFont (const char *name, int lump) : FFont(lump) FontName = name; - FileData data1 = fileSystem.ReadFile (lump); + auto data1 = fileSystem.ReadFile (lump); auto data = data1.GetBytes(); if (data[0] == 0xE1 && data[1] == 0xE6 && data[2] == 0xD5 && data[3] == 0x1A) @@ -474,7 +474,7 @@ void FSingleLumpFont::LoadBMF(int lump, const uint8_t *data) void FSingleLumpFont::CheckFON1Chars() { - FileData memLump = fileSystem.ReadFile(Lump); + auto memLump = fileSystem.ReadFile(Lump); auto data = memLump.GetBytes(); const uint8_t* data_p; diff --git a/src/common/fonts/v_font.cpp b/src/common/fonts/v_font.cpp index f6e4ef0dea..591edb2089 100644 --- a/src/common/fonts/v_font.cpp +++ b/src/common/fonts/v_font.cpp @@ -109,7 +109,7 @@ FFont *V_GetFont(const char *name, const char *fontlumpname) int lump = -1; int folderfile = -1; - std::vector folderdata; + std::vector folderdata; FStringf path("fonts/%s/", name); // Use a folder-based font only if it comes from a later file than the single lump version. diff --git a/src/common/fonts/v_font.h b/src/common/fonts/v_font.h index 9fdab02288..0b5ce1338a 100644 --- a/src/common/fonts/v_font.h +++ b/src/common/fonts/v_font.h @@ -175,7 +175,7 @@ protected: void FixXMoves(); - void ReadSheetFont(std::vector &folderdata, int width, int height, const DVector2 &Scale); + void ReadSheetFont(std::vector &folderdata, int width, int height, const DVector2 &Scale); EFontType Type = EFontType::Unknown; FName AltFontName = NAME_None; diff --git a/src/common/menu/menudef.cpp b/src/common/menu/menudef.cpp index e81bda2d2d..34ef1fc9d0 100644 --- a/src/common/menu/menudef.cpp +++ b/src/common/menu/menudef.cpp @@ -1519,7 +1519,7 @@ void M_ParseMenuDefs() DefaultOptionMenuSettings->Reset(); OptionSettings.mLinespacing = 17; - int IWADMenu = fileSystem.CheckNumForName("MENUDEF", ns_global, fileSystem.GetIwadNum()); + int IWADMenu = fileSystem.CheckNumForName("MENUDEF", FileSys::ns_global, fileSystem.GetIwadNum()); while ((lump = fileSystem.FindLump ("MENUDEF", &lastlump)) != -1) { diff --git a/src/common/menu/savegamemanager.cpp b/src/common/menu/savegamemanager.cpp index 7e948267d7..29b0f447b0 100644 --- a/src/common/menu/savegamemanager.cpp +++ b/src/common/menu/savegamemanager.cpp @@ -297,7 +297,7 @@ unsigned FSavegameManagerBase::ExtractSaveData(int index) !node->bOldVersion && (resf = FResourceFile::OpenResourceFile(node->Filename.GetChars(), true)) != nullptr) { - FResourceLump *info = resf->FindLump("info.json"); + auto info = resf->FindLump("info.json"); if (info == nullptr) { // this should not happen because the file has already been verified. @@ -315,7 +315,7 @@ unsigned FSavegameManagerBase::ExtractSaveData(int index) SaveCommentString = ExtractSaveComment(arc); - FResourceLump *pic = resf->FindLump("savepic.png"); + auto pic = resf->FindLump("savepic.png"); if (pic != nullptr) { FileReader picreader; diff --git a/src/common/models/model.cpp b/src/common/models/model.cpp index ceb77bcffd..a7dccfc09f 100644 --- a/src/common/models/model.cpp +++ b/src/common/models/model.cpp @@ -172,7 +172,7 @@ unsigned FindModel(const char * path, const char * modelfile, bool silent) } int len = fileSystem.FileLength(lump); - FileData lumpd = fileSystem.ReadFile(lump); + auto lumpd = fileSystem.ReadFile(lump); const char * buffer = lumpd.GetString(); if ( (size_t)fullname.LastIndexOf("_d.3d") == fullname.Len()-5 ) diff --git a/src/common/models/models_iqm.cpp b/src/common/models/models_iqm.cpp index 143c4334ad..a2bc656a1a 100644 --- a/src/common/models/models_iqm.cpp +++ b/src/common/models/models_iqm.cpp @@ -270,7 +270,7 @@ void IQMModel::LoadGeometry() { try { - FileData lumpdata = fileSystem.ReadFile(mLumpNum); + auto lumpdata = fileSystem.ReadFile(mLumpNum); IQMFileReader reader(lumpdata.GetMem(), (int)lumpdata.GetSize()); Vertices.Resize(NumVertices); diff --git a/src/common/models/models_md2.cpp b/src/common/models/models_md2.cpp index 0dd402cf91..d56d1e7c5c 100644 --- a/src/common/models/models_md2.cpp +++ b/src/common/models/models_md2.cpp @@ -177,7 +177,7 @@ bool FDMDModel::Load(const char * path, int lumpnum, const char * buffer, int le void FDMDModel::LoadGeometry() { static int axis[3] = { VX, VY, VZ }; - FileData lumpdata = fileSystem.ReadFile(mLumpNum); + auto lumpdata = fileSystem.ReadFile(mLumpNum); auto buffer = lumpdata.GetString(); texCoords = new FTexCoord[info.numTexCoords]; memcpy(texCoords, buffer + info.offsetTexCoords, info.numTexCoords * sizeof(FTexCoord)); @@ -501,7 +501,7 @@ void FMD2Model::LoadGeometry() { static int axis[3] = { VX, VY, VZ }; uint8_t *md2_frames; - FileData lumpdata = fileSystem.ReadFile(mLumpNum); + auto lumpdata = fileSystem.ReadFile(mLumpNum); auto buffer = lumpdata.GetString(); texCoords = new FTexCoord[info.numTexCoords]; diff --git a/src/common/models/models_md3.cpp b/src/common/models/models_md3.cpp index ea2083a8ba..65948d809e 100644 --- a/src/common/models/models_md3.cpp +++ b/src/common/models/models_md3.cpp @@ -189,7 +189,7 @@ bool FMD3Model::Load(const char * path, int lumpnum, const char * buffer, int le void FMD3Model::LoadGeometry() { - FileData lumpdata = fileSystem.ReadFile(mLumpNum); + auto lumpdata = fileSystem.ReadFile(mLumpNum); auto buffer = lumpdata.GetString(); md3_header_t * hdr = (md3_header_t *)buffer; md3_surface_t * surf = (md3_surface_t*)(buffer + LittleLong(hdr->Ofs_Surfaces)); diff --git a/src/common/models/models_ue1.cpp b/src/common/models/models_ue1.cpp index aa85678508..742ef4aafa 100644 --- a/src/common/models/models_ue1.cpp +++ b/src/common/models/models_ue1.cpp @@ -70,9 +70,9 @@ bool FUE1Model::Load( const char *filename, int lumpnum, const char *buffer, int void FUE1Model::LoadGeometry() { const char *buffer, *buffer2; - FileData lump = fileSystem.ReadFile(mDataLump); + auto lump = fileSystem.ReadFile(mDataLump); buffer = lump.GetString(); - FileData lump2 = fileSystem.ReadFile(mAnivLump); + auto lump2 = fileSystem.ReadFile(mAnivLump); buffer2 = lump2.GetString(); // map structures dhead = (const d3dhead*)(buffer); diff --git a/src/common/models/voxels.cpp b/src/common/models/voxels.cpp index 6c7867ccf2..9d2f1fdd6c 100644 --- a/src/common/models/voxels.cpp +++ b/src/common/models/voxels.cpp @@ -161,7 +161,7 @@ FVoxel *R_LoadKVX(int lumpnum) int mip, maxmipsize; int i, j, n; - FileData lump = fileSystem.ReadFile(lumpnum); // FileData adds an extra 0 byte to the end. + auto lump = fileSystem.ReadFile(lumpnum); // FileData adds an extra 0 byte to the end. auto rawvoxel = lump.GetBytes(); int voxelsize = (int)(lump.GetSize()-1); diff --git a/src/common/rendering/gles/gles_shader.cpp b/src/common/rendering/gles/gles_shader.cpp index 8f9103c610..4fffa8b90b 100644 --- a/src/common/rendering/gles/gles_shader.cpp +++ b/src/common/rendering/gles/gles_shader.cpp @@ -383,11 +383,11 @@ bool FShader::Load(const char * name, const char * vert_prog_lump_, const char * int vp_lump = fileSystem.CheckNumForFullName(vert_prog_lump, 0); if (vp_lump == -1) I_Error("Unable to load '%s'", vert_prog_lump.GetChars()); - FileData vp_data = fileSystem.ReadFile(vp_lump); + auto vp_data = fileSystem.ReadFile(vp_lump); int fp_lump = fileSystem.CheckNumForFullName(frag_prog_lump, 0); if (fp_lump == -1) I_Error("Unable to load '%s'", frag_prog_lump.GetChars()); - FileData fp_data = fileSystem.ReadFile(fp_lump); + auto fp_data = fileSystem.ReadFile(fp_lump); diff --git a/src/common/rendering/v_video.h b/src/common/rendering/v_video.h index bb3c8bb4d3..ed428ee671 100644 --- a/src/common/rendering/v_video.h +++ b/src/common/rendering/v_video.h @@ -45,6 +45,7 @@ #include "hw_shadowmap.h" #include "hw_levelmesh.h" #include "buffers.h" +#include "files.h" struct FPortalSceneState; @@ -90,7 +91,6 @@ EXTERN_CVAR(Int, win_h) EXTERN_CVAR(Bool, win_maximized) struct FColormap; -class FileWriter; enum FTextureFormat : uint32_t; class FModelRenderer; struct SamplerUniform; diff --git a/src/common/rendering/vulkan/shaders/vk_shader.cpp b/src/common/rendering/vulkan/shaders/vk_shader.cpp index 3784543b33..4ccfbd3029 100644 --- a/src/common/rendering/vulkan/shaders/vk_shader.cpp +++ b/src/common/rendering/vulkan/shaders/vk_shader.cpp @@ -473,7 +473,7 @@ FString VkShaderManager::LoadPrivateShaderLump(const char *lumpname) { int lump = fileSystem.CheckNumForFullName(lumpname, 0); if (lump == -1) I_Error("Unable to load '%s'", lumpname); - FileData data = fileSystem.ReadFile(lump); + auto data = fileSystem.ReadFile(lump); return GetStringFromLump(lump); } diff --git a/src/common/startscreen/startscreen_generic.cpp b/src/common/startscreen/startscreen_generic.cpp index c2af0bd505..3484e22009 100644 --- a/src/common/startscreen/startscreen_generic.cpp +++ b/src/common/startscreen/startscreen_generic.cpp @@ -72,7 +72,7 @@ FGenericStartScreen::FGenericStartScreen(int max_progress) : FStartScreen(max_progress) { // at this point we do not have a working texture manager yet, so we have to do the lookup via the file system - int startup_lump = fileSystem.CheckNumForName("GZDOOM", ns_graphics); + int startup_lump = fileSystem.CheckNumForName("GZDOOM", FileSys::ns_graphics); StartupBitmap.Create(640, 480); ClearBlock(StartupBitmap, { 0, 0, 0, 255 }, 0, 0, 640, 480); diff --git a/src/common/startscreen/startscreen_hexen.cpp b/src/common/startscreen/startscreen_hexen.cpp index 6eef735994..a82e21b351 100644 --- a/src/common/startscreen/startscreen_hexen.cpp +++ b/src/common/startscreen/startscreen_hexen.cpp @@ -81,9 +81,9 @@ FHexenStartScreen::FHexenStartScreen(int max_progress) : FStartScreen(max_progress) { // at this point we do not have a working texture manager yet, so we have to do the lookup via the file system - int startup_lump = fileSystem.CheckNumForName("STARTUP", ns_graphics); - int netnotch_lump = fileSystem.CheckNumForName("NETNOTCH", ns_graphics); - int notch_lump = fileSystem.CheckNumForName("NOTCH", ns_graphics); + int startup_lump = fileSystem.CheckNumForName("STARTUP", FileSys::ns_graphics); + int netnotch_lump = fileSystem.CheckNumForName("NETNOTCH", FileSys::ns_graphics); + int notch_lump = fileSystem.CheckNumForName("NOTCH", FileSys::ns_graphics); // For backwards compatibility we also need to look in the default namespace, because these were previously not handled as graphics. if (startup_lump == -1) startup_lump = fileSystem.CheckNumForName("STARTUP"); diff --git a/src/common/startscreen/startscreen_strife.cpp b/src/common/startscreen/startscreen_strife.cpp index b4490a921f..5b1d48bf4a 100644 --- a/src/common/startscreen/startscreen_strife.cpp +++ b/src/common/startscreen/startscreen_strife.cpp @@ -119,7 +119,7 @@ FStrifeStartScreen::FStrifeStartScreen(int max_progress) // Load the animated overlays. for (size_t i = 0; i < countof(StrifeStartupPicNames); ++i) { - int lumpnum = fileSystem.CheckNumForName(StrifeStartupPicNames[i], ns_graphics); + int lumpnum = fileSystem.CheckNumForName(StrifeStartupPicNames[i], FileSys::ns_graphics); if (lumpnum < 0) lumpnum = fileSystem.CheckNumForName(StrifeStartupPicNames[i]); if (lumpnum >= 0) diff --git a/src/common/textures/formats/anmtexture.cpp b/src/common/textures/formats/anmtexture.cpp index f57b0e31e6..9fc3290d6c 100644 --- a/src/common/textures/formats/anmtexture.cpp +++ b/src/common/textures/formats/anmtexture.cpp @@ -103,7 +103,7 @@ FAnmTexture::FAnmTexture (int lumpnum, int w, int h) void FAnmTexture::ReadFrame(uint8_t *pixels, uint8_t *palette) { - FileData lump = fileSystem.ReadFile (SourceLump); + auto lump = fileSystem.ReadFile (SourceLump); auto source = lump.GetBytes(); anim_t anim; diff --git a/src/common/textures/formats/automaptexture.cpp b/src/common/textures/formats/automaptexture.cpp index 6b660b1bac..5aade7730a 100644 --- a/src/common/textures/formats/automaptexture.cpp +++ b/src/common/textures/formats/automaptexture.cpp @@ -92,7 +92,7 @@ FAutomapTexture::FAutomapTexture (int lumpnum) PalettedPixels FAutomapTexture::CreatePalettedPixels(int conversion) { int x, y; - FileData data = fileSystem.ReadFile (SourceLump); + auto data = fileSystem.ReadFile (SourceLump); auto indata = data.GetBytes(); PalettedPixels Pixels(Width * Height); diff --git a/src/common/textures/formats/imgztexture.cpp b/src/common/textures/formats/imgztexture.cpp index fb020c9a10..e85d3bac9e 100644 --- a/src/common/textures/formats/imgztexture.cpp +++ b/src/common/textures/formats/imgztexture.cpp @@ -120,7 +120,7 @@ FIMGZTexture::FIMGZTexture (int lumpnum, uint16_t w, uint16_t h, int16_t l, int1 PalettedPixels FIMGZTexture::CreatePalettedPixels(int conversion) { - FileData lump = fileSystem.ReadFile (SourceLump); + auto lump = fileSystem.ReadFile (SourceLump); auto imgz = (const ImageHeader *)lump.GetMem(); const uint8_t *data = (const uint8_t *)&imgz[1]; diff --git a/src/common/textures/formats/patchtexture.cpp b/src/common/textures/formats/patchtexture.cpp index d64e003e2c..80179a54da 100644 --- a/src/common/textures/formats/patchtexture.cpp +++ b/src/common/textures/formats/patchtexture.cpp @@ -174,7 +174,7 @@ PalettedPixels FPatchTexture::CreatePalettedPixels(int conversion) const column_t *maxcol; int x; - FileData lump = fileSystem.ReadFile (SourceLump); + auto lump = fileSystem.ReadFile (SourceLump); const patch_t *patch = (const patch_t *)lump.GetMem(); maxcol = (const column_t *)((const uint8_t *)patch + fileSystem.FileLength (SourceLump) - 3); @@ -284,7 +284,7 @@ void FPatchTexture::DetectBadPatches () // Check if this patch is likely to be a problem. // It must be 256 pixels tall, and all its columns must have exactly // one post, where each post has a supposed length of 0. - FileData lump = fileSystem.ReadFile (SourceLump); + auto lump = fileSystem.ReadFile (SourceLump); const patch_t *realpatch = (patch_t *)lump.GetMem(); const uint32_t *cofs = realpatch->columnofs; int x, x2 = LittleShort(realpatch->width); diff --git a/src/common/textures/formats/rawpagetexture.cpp b/src/common/textures/formats/rawpagetexture.cpp index e2b6c11466..4caa6bb9e9 100644 --- a/src/common/textures/formats/rawpagetexture.cpp +++ b/src/common/textures/formats/rawpagetexture.cpp @@ -172,7 +172,7 @@ FRawPageTexture::FRawPageTexture (int lumpnum) PalettedPixels FRawPageTexture::CreatePalettedPixels(int conversion) { - FileData lump = fileSystem.ReadFile (SourceLump); + auto lump = fileSystem.ReadFile (SourceLump); auto source = lump.GetBytes(); const uint8_t *source_p = source; uint8_t *dest_p; @@ -204,8 +204,8 @@ int FRawPageTexture::CopyPixels(FBitmap *bmp, int conversion) if (mPaletteLump < 0) return FImageSource::CopyPixels(bmp, conversion); else { - FileData lump = fileSystem.ReadFile(SourceLump); - FileData plump = fileSystem.ReadFile(mPaletteLump); + auto lump = fileSystem.ReadFile(SourceLump); + auto plump = fileSystem.ReadFile(mPaletteLump); auto source = lump.GetBytes(); auto psource = plump.GetBytes(); PalEntry paldata[256]; diff --git a/src/common/textures/formats/startuptexture.cpp b/src/common/textures/formats/startuptexture.cpp index 718b7182a2..cb1c5b7191 100644 --- a/src/common/textures/formats/startuptexture.cpp +++ b/src/common/textures/formats/startuptexture.cpp @@ -164,7 +164,7 @@ FStartupTexture::FStartupTexture (int lumpnum) Height = 480; bUseGamePalette = false; - FileData lump = fileSystem.ReadFile (SourceLump); + auto lump = fileSystem.ReadFile (SourceLump); auto source = lump.GetBytes(); // Initialize the bitmap palette. @@ -233,7 +233,7 @@ void PlanarToChunky(T* dest, const uint8_t* src, const T* remap, int width, int PalettedPixels FStartupTexture::CreatePalettedPixels(int conversion) { - FileData lump = fileSystem.ReadFile (SourceLump); + auto lump = fileSystem.ReadFile (SourceLump); auto source = lump.GetBytes(); const uint8_t *remap = ImageHelpers::GetRemap(conversion == luminance); @@ -253,7 +253,7 @@ PalettedPixels FStartupTexture::CreatePalettedPixels(int conversion) int FStartupTexture::CopyPixels(FBitmap *bmp, int conversion) { - FileData lump = fileSystem.ReadFile (SourceLump); + auto lump = fileSystem.ReadFile (SourceLump); auto source = lump.GetBytes(); PlanarToChunky((uint32_t*)bmp->GetPixels(), source + 48, startuppalette32, Width, Height); return 0; @@ -281,7 +281,7 @@ FNotchTexture::FNotchTexture (int lumpnum, int width, int height) PalettedPixels FNotchTexture::CreatePalettedPixels(int conversion) { - FileData lump = fileSystem.ReadFile (SourceLump); + auto lump = fileSystem.ReadFile (SourceLump); auto source = lump.GetBytes(); const uint8_t *remap = ImageHelpers::GetRemap(conversion == luminance); @@ -304,7 +304,7 @@ PalettedPixels FNotchTexture::CreatePalettedPixels(int conversion) int FNotchTexture::CopyPixels(FBitmap *bmp, int conversion) { - FileData lump = fileSystem.ReadFile (SourceLump); + auto lump = fileSystem.ReadFile (SourceLump); auto source = lump.GetBytes(); auto Work = (uint32_t*)bmp->GetPixels(); @@ -338,7 +338,7 @@ FStrifeStartupTexture::FStrifeStartupTexture (int lumpnum, int w, int h) PalettedPixels FStrifeStartupTexture::CreatePalettedPixels(int conversion) { - FileData lump = fileSystem.ReadFile (SourceLump); + auto lump = fileSystem.ReadFile (SourceLump); auto source = lump.GetBytes(); PalettedPixels Pixels(Width*Height); const uint8_t *remap = ImageHelpers::GetRemap(conversion == luminance); diff --git a/src/common/textures/gametexture.cpp b/src/common/textures/gametexture.cpp index 20b22939db..2c873d15f0 100644 --- a/src/common/textures/gametexture.cpp +++ b/src/common/textures/gametexture.cpp @@ -182,7 +182,7 @@ void FGameTexture::AddAutoMaterials() if (this->*(layer.pointer) == nullptr) // only if no explicit assignment had been done. { FStringf lookup("%s%s%s", layer.path, fullname ? "" : "auto/", searchname.GetChars()); - auto lump = fileSystem.CheckNumForFullName(lookup, false, ns_global, true); + auto lump = fileSystem.CheckNumForFullName(lookup, false, FileSys::ns_global, true); if (lump != -1) { auto bmtex = TexMan.FindGameTexture(fileSystem.GetFileFullName(lump), ETextureType::Any, FTextureManager::TEXMAN_TryAny); @@ -199,7 +199,7 @@ void FGameTexture::AddAutoMaterials() if (!this->Layers || this->Layers.get()->*(layer.pointer) == nullptr) // only if no explicit assignment had been done. { FStringf lookup("%s%s%s", layer.path, fullname ? "" : "auto/", searchname.GetChars()); - auto lump = fileSystem.CheckNumForFullName(lookup, false, ns_global, true); + auto lump = fileSystem.CheckNumForFullName(lookup, false, FileSys::ns_global, true); if (lump != -1) { auto bmtex = TexMan.FindGameTexture(fileSystem.GetFileFullName(lump), ETextureType::Any, FTextureManager::TEXMAN_TryAny); diff --git a/src/common/textures/m_png.h b/src/common/textures/m_png.h index 2f52a1fcf5..f65de4c0d6 100644 --- a/src/common/textures/m_png.h +++ b/src/common/textures/m_png.h @@ -47,7 +47,6 @@ enum ESSType SS_BGRA }; -class FileWriter; // PNG Writing -------------------------------------------------------------- // Start writing an 8-bit palettized PNG file. @@ -82,13 +81,13 @@ struct PNGHandle uint32_t Size; }; - FileReader File; + FileSys::FileReader File; bool bDeleteFilePtr; TArray Chunks; TArray TextChunks; unsigned int ChunkPt; - PNGHandle(FileReader &file); + PNGHandle(FileSys::FileReader &file); ~PNGHandle(); }; @@ -96,7 +95,7 @@ struct PNGHandle // the signature, but also checking for the IEND chunk. CRC checking of // each chunk is not done. If it is valid, you get a PNGHandle to pass to // the following functions. -PNGHandle *M_VerifyPNG (FileReader &file); +PNGHandle *M_VerifyPNG (FileSys::FileReader &file); // Finds a chunk in a PNG file. The file pointer will be positioned at the // beginning of the chunk data, and its length will be returned. A return @@ -115,7 +114,7 @@ bool M_GetPNGText (PNGHandle *png, const char *keyword, char *buffer, size_t buf // The file must be positioned at the start of the first IDAT. It reads // image data into the provided buffer. Returns true on success. -bool M_ReadIDAT (FileReader &file, uint8_t *buffer, int width, int height, int pitch, +bool M_ReadIDAT (FileSys::FileReader &file, uint8_t *buffer, int width, int height, int pitch, uint8_t bitdepth, uint8_t colortype, uint8_t interlace, unsigned int idatlen); diff --git a/src/common/textures/multipatchtexturebuilder.cpp b/src/common/textures/multipatchtexturebuilder.cpp index 201398ee81..c032372c37 100644 --- a/src/common/textures/multipatchtexturebuilder.cpp +++ b/src/common/textures/multipatchtexturebuilder.cpp @@ -397,12 +397,12 @@ void FMultipatchTextureBuilder::AddTexturesLumps(int lump1, int lump2, int patch if (lump1 >= 0) { - FileData texdir = fileSystem.ReadFile(lump1); + auto texdir = fileSystem.ReadFile(lump1); AddTexturesLump(texdir.GetMem(), fileSystem.FileLength(lump1), lump1, patcheslump, firstdup, true); } if (lump2 >= 0) { - FileData texdir = fileSystem.ReadFile(lump2); + auto texdir = fileSystem.ReadFile(lump2); AddTexturesLump(texdir.GetMem(), fileSystem.FileLength(lump2), lump2, patcheslump, firstdup, false); } } diff --git a/src/common/textures/texturemanager.cpp b/src/common/textures/texturemanager.cpp index 969a5f2010..c2ebe6249b 100644 --- a/src/common/textures/texturemanager.cpp +++ b/src/common/textures/texturemanager.cpp @@ -50,6 +50,7 @@ #include "basics.h" #include "cmdlib.h" +using namespace FileSys; FTextureManager TexMan; diff --git a/src/common/utility/cmdlib.cpp b/src/common/utility/cmdlib.cpp index b5ac83415e..8dbce2b7a6 100644 --- a/src/common/utility/cmdlib.cpp +++ b/src/common/utility/cmdlib.cpp @@ -1018,7 +1018,7 @@ void uppercopy(char* to, const char* from) FString GetStringFromLump(int lump) { - FileData fd = fileSystem.ReadFile(lump); + auto fd = fileSystem.ReadFile(lump); FString ScriptBuffer(fd.GetString(), fd.GetSize()); ScriptBuffer.Truncate(strlen(ScriptBuffer.GetChars())); // this is necessary to properly truncate the generated string to not contain 0 bytes. return ScriptBuffer; diff --git a/src/common/utility/cmdlib.h b/src/common/utility/cmdlib.h index 9d94d0d3f2..06b5a5e0f4 100644 --- a/src/common/utility/cmdlib.h +++ b/src/common/utility/cmdlib.h @@ -12,6 +12,7 @@ #include #include #include "zstring.h" +#include "files.h" #if !defined(GUID_DEFINED) #define GUID_DEFINED @@ -82,7 +83,6 @@ inline constexpr double Scale(double a, double b, double c) return (a * b) / c; } -class FileReader; struct MD5Context; void md5Update(FileReader& file, MD5Context& md5, unsigned len); diff --git a/src/common/utility/filereadermusicinterface.h b/src/common/utility/filereadermusicinterface.h index f261f9dd03..633599b63e 100644 --- a/src/common/utility/filereadermusicinterface.h +++ b/src/common/utility/filereadermusicinterface.h @@ -6,6 +6,7 @@ inline ZMusicCustomReader *GetMusicReader(FileReader& fr) { + using FileSys::FileReaderInterface; auto zcr = new ZMusicCustomReader; zcr->handle = fr.GetInterface(); diff --git a/src/common/utility/findfile.cpp b/src/common/utility/findfile.cpp index 17d2c9154f..ff1e53f4fe 100644 --- a/src/common/utility/findfile.cpp +++ b/src/common/utility/findfile.cpp @@ -139,11 +139,11 @@ void D_AddWildFile(std::vector& wadfiles, const char* value, const else { // Try pattern matching - FileList list; + FileSys::FileList list; auto path = ExtractFilePath(value); auto name = ExtractFileBase(value, true); if (path.IsEmpty()) path = "."; - if (ScanDirectory(list, path, name, true)) + if (FileSys::ScanDirectory(list, path, name, true)) { for(auto& entry : list) { @@ -193,8 +193,8 @@ void D_AddConfigFiles(std::vector& wadfiles, const char* section, c void D_AddDirectory(std::vector& wadfiles, const char* dir, const char *filespec, FConfigFile* config) { - FileList list; - if (ScanDirectory(list, dir, "*.wad", true)) + FileSys::FileList list; + if (FileSys::ScanDirectory(list, dir, "*.wad", true)) { for (auto& entry : list) { diff --git a/src/common/utility/palette.cpp b/src/common/utility/palette.cpp index 178db734b5..0b5cca67be 100644 --- a/src/common/utility/palette.cpp +++ b/src/common/utility/palette.cpp @@ -929,7 +929,7 @@ int ReadPalette(int lumpnum, uint8_t* buffer) { return 0; } - FileData lump = fileSystem.ReadFile(lumpnum); + auto lump = fileSystem.ReadFile(lumpnum); auto lumpmem = lump.GetBytes(); memset(buffer, 0, 768); diff --git a/src/common/utility/s_playlist.h b/src/common/utility/s_playlist.h index 5bd5fd55ef..84d2040b03 100644 --- a/src/common/utility/s_playlist.h +++ b/src/common/utility/s_playlist.h @@ -34,7 +34,7 @@ #ifndef __S_PLAYLIST_H__ #define __S_PLAYLIST_H__ -class FileReader; +#include "files.h" class FPlayList { diff --git a/src/common/utility/zstring.h b/src/common/utility/zstring.h index 1164ddb6d4..7777bbf617 100644 --- a/src/common/utility/zstring.h +++ b/src/common/utility/zstring.h @@ -40,6 +40,7 @@ #include #include "tarray.h" #include "utf8.h" +#include "filesystem.h" #ifdef __GNUC__ #define PRINTFISH(x) __attribute__((format(printf, 2, x))) @@ -117,8 +118,6 @@ enum ELumpNum { }; -class FileSystem; - class FString { public: diff --git a/src/d_iwad.cpp b/src/d_iwad.cpp index 88cc0032e7..ab562f283a 100644 --- a/src/d_iwad.cpp +++ b/src/d_iwad.cpp @@ -300,7 +300,7 @@ void FIWadManager::ParseIWadInfo(const char *fn, const char *data, int datasize, // Look for IWAD definition lump // //========================================================================== -void GetReserved(LumpFilterInfo& lfi); +void GetReserved(FileSys::LumpFilterInfo& lfi); FIWadManager::FIWadManager(const char *firstfn, const char *optfn) { @@ -385,7 +385,7 @@ int FIWadManager::CheckIWADInfo(const char* fn) { FileSystem check; - LumpFilterInfo lfi; + FileSys::LumpFilterInfo lfi; GetReserved(lfi); std::vector filenames = { fn }; @@ -471,9 +471,9 @@ void FIWadManager::CollectSearchPaths() void FIWadManager::AddIWADCandidates(const char *dir) { - FileList list; + FileSys::FileList list; - if (ScanDirectory(list, dir, "*", true)) + if (FileSys::ScanDirectory(list, dir, "*", true)) { for(auto& entry : list) { diff --git a/src/d_main.cpp b/src/d_main.cpp index a35035fcc0..f2c5b6d5aa 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -122,6 +122,8 @@ #include "i_system.h" // for SHARE_DIR #endif // __unix__ +using namespace FileSys; + EXTERN_CVAR(Bool, hud_althud) EXTERN_CVAR(Int, vr_mode) EXTERN_CVAR(Bool, cl_customizeinvulmap) diff --git a/src/g_game.cpp b/src/g_game.cpp index d1374a9254..f68fca2257 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1981,7 +1981,7 @@ void G_DoLoadGame () LoadGameError("TXT_COULDNOTREAD"); return; } - FResourceLump *info = resfile->FindLump("info.json"); + auto info = resfile->FindLump("info.json"); if (info == nullptr) { LoadGameError("TXT_NOINFOJSON"); @@ -2408,7 +2408,7 @@ void G_DoSaveGame (bool okForQuicksave, bool forceQuicksave, FString filename, c } auto picdata = savepic.GetBuffer(); - FCompressedBuffer bufpng = { picdata->Size(), picdata->Size(), METHOD_STORED, 0, static_cast(crc32(0, &(*picdata)[0], picdata->Size())), (char*)&(*picdata)[0] }; + FCompressedBuffer bufpng = { picdata->Size(), picdata->Size(), FileSys::METHOD_STORED, 0, static_cast(crc32(0, &(*picdata)[0], picdata->Size())), (char*)&(*picdata)[0] }; savegame_content.Push(bufpng); savegame_filenames.Push("savepic.png"); diff --git a/src/g_level.cpp b/src/g_level.cpp index 147f5d48a6..4b7229ab0e 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -2004,7 +2004,7 @@ void G_ReadSnapshots(FResourceFile *resf) for (unsigned j = 0; j < resf->LumpCount(); j++) { - FResourceLump * resl = resf->GetLump(j); + auto resl = resf->GetLump(j); if (resl != nullptr) { auto name = resl->getName(); diff --git a/src/g_level.h b/src/g_level.h index 75a0aab564..71ae6f2762 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -3,10 +3,10 @@ #include "doomtype.h" #include "vectors.h" #include "sc_man.h" -#include "file_zip.h" #include "g_mapinfo.h" +using FileSys::FCompressedBuffer; extern bool savegamerestore; void G_InitNew (const char *mapname, bool bTitleLevel); diff --git a/src/gameconfigfile.h b/src/gameconfigfile.h index 023277ae7b..0b898112eb 100644 --- a/src/gameconfigfile.h +++ b/src/gameconfigfile.h @@ -36,6 +36,7 @@ #include "doomtype.h" #include "configfile.h" +#include "files.h" class FArgs; class FIWadManager; diff --git a/src/gamedata/decallib.cpp b/src/gamedata/decallib.cpp index e765959b8f..961b63f30d 100644 --- a/src/gamedata/decallib.cpp +++ b/src/gamedata/decallib.cpp @@ -392,7 +392,7 @@ void FDecalLib::ParseDecal (FScanner &sc) case DECAL_PIC: sc.MustGetString (); picnum = TexMan.CheckForTexture (sc.String, ETextureType::Any); - if (!picnum.Exists() && (lumpnum = fileSystem.CheckNumForName (sc.String, ns_graphics)) >= 0) + if (!picnum.Exists() && (lumpnum = fileSystem.CheckNumForName (sc.String, FileSys::ns_graphics)) >= 0) { picnum = TexMan.CreateTexture (lumpnum, ETextureType::Decal); } diff --git a/src/gamedata/doomfont.h b/src/gamedata/doomfont.h index b9d14db7d4..fedeb513c4 100644 --- a/src/gamedata/doomfont.h +++ b/src/gamedata/doomfont.h @@ -18,7 +18,7 @@ void InitDoomFonts() if (fileSystem.CheckNumForName("FONTA_S") >= 0) { int wadfile = -1; - auto a = fileSystem.CheckNumForName("FONTA33", ns_graphics); + auto a = fileSystem.CheckNumForName("FONTA33", FileSys::ns_graphics); if (a != -1) wadfile = fileSystem.GetFileContainer(a); if (wadfile > fileSystem.GetIwadNum()) { @@ -32,10 +32,10 @@ void InitDoomFonts() SmallFont->SetCursor('['); } } - else if (fileSystem.CheckNumForName("STCFN033", ns_graphics) >= 0) + else if (fileSystem.CheckNumForName("STCFN033", FileSys::ns_graphics) >= 0) { int wadfile = -1; - auto a = fileSystem.CheckNumForName("STCFN065", ns_graphics); + auto a = fileSystem.CheckNumForName("STCFN065", FileSys::ns_graphics); if (a != -1) wadfile = fileSystem.GetFileContainer(a); if (wadfile > fileSystem.GetIwadNum()) { @@ -55,7 +55,7 @@ void InitDoomFonts() OriginalSmallFont = new FFont("OriginalSmallFont", "FONTA%02u", "defsmallfont", HU_FONTSTART, HU_FONTSIZE, 1, -1, -1, false, true); OriginalSmallFont->SetCursor('['); } - else if (fileSystem.CheckNumForName("STCFN033", ns_graphics) >= 0) + else if (fileSystem.CheckNumForName("STCFN033", FileSys::ns_graphics) >= 0) { OriginalSmallFont = new FFont("OriginalSmallFont", "STCFN%.3d", "defsmallfont", HU_FONTSTART, HU_FONTSIZE, HU_FONTSTART, -1, -1, false, true, true); } @@ -63,7 +63,7 @@ void InitDoomFonts() if (!(SmallFont2 = V_GetFont("SmallFont2"))) // Only used by Strife { - if (fileSystem.CheckNumForName("STBFN033", ns_graphics) >= 0) + if (fileSystem.CheckNumForName("STBFN033", FileSys::ns_graphics) >= 0) { SmallFont2 = new FFont("SmallFont2", "STBFN%.3d", "defsmallfont2", HU_FONTSTART, HU_FONTSIZE, HU_FONTSTART, -1); } diff --git a/src/gamedata/g_mapinfo.cpp b/src/gamedata/g_mapinfo.cpp index 78ffb15a12..bc692cd618 100644 --- a/src/gamedata/g_mapinfo.cpp +++ b/src/gamedata/g_mapinfo.cpp @@ -2596,7 +2596,7 @@ void G_ParseMapInfo (FString basemapinfo) // If that exists we need to skip this one. int wad = fileSystem.GetFileContainer(lump); - int altlump = fileSystem.CheckNumForName("ZMAPINFO", ns_global, wad, true); + int altlump = fileSystem.CheckNumForName("ZMAPINFO", FileSys::ns_global, wad, true); if (altlump >= 0) continue; } @@ -2604,9 +2604,9 @@ void G_ParseMapInfo (FString basemapinfo) { // MAPINFO and ZMAPINFO will override UMAPINFO if in the same WAD. int wad = fileSystem.GetFileContainer(lump); - int altlump = fileSystem.CheckNumForName("ZMAPINFO", ns_global, wad, true); + int altlump = fileSystem.CheckNumForName("ZMAPINFO", FileSys::ns_global, wad, true); if (altlump >= 0) continue; - altlump = fileSystem.CheckNumForName("MAPINFO", ns_global, wad, true); + altlump = fileSystem.CheckNumForName("MAPINFO", FileSys::ns_global, wad, true); if (altlump >= 0) continue; } if (nindex != 2) diff --git a/src/gamedata/g_mapinfo.h b/src/gamedata/g_mapinfo.h index f9e97e0c5f..b7e48f3019 100644 --- a/src/gamedata/g_mapinfo.h +++ b/src/gamedata/g_mapinfo.h @@ -38,7 +38,6 @@ #include "doomtype.h" #include "vectors.h" #include "sc_man.h" -#include "file_zip.h" #include "screenjob.h" #include "hwrenderer/postprocessing/hw_postprocess.h" #include "hw_viewpointuniforms.h" @@ -349,7 +348,7 @@ struct level_info_t FString AuthorName; int8_t WallVertLight, WallHorizLight; int musicorder; - FCompressedBuffer Snapshot; + FileSys::FCompressedBuffer Snapshot; TArray deferred; float skyspeed1; float skyspeed2; diff --git a/src/gamedata/keysections.cpp b/src/gamedata/keysections.cpp index 8561b6b247..30a3f8d2ac 100644 --- a/src/gamedata/keysections.cpp +++ b/src/gamedata/keysections.cpp @@ -165,7 +165,7 @@ void D_LoadWadSettings () while ((lump = fileSystem.FindLump ("KEYCONF", &lastlump)) != -1) { - FileData data = fileSystem.ReadFile (lump); + auto data = fileSystem.ReadFile (lump); const char* conf = data.GetString(); const char *eof = conf + data.GetSize(); diff --git a/src/gamedata/textures/anim_switches.cpp b/src/gamedata/textures/anim_switches.cpp index 36666bc3f8..c0485714b4 100644 --- a/src/gamedata/textures/anim_switches.cpp +++ b/src/gamedata/textures/anim_switches.cpp @@ -66,7 +66,7 @@ void FTextureAnimator::InitSwitchList () if (lump != -1) { - FileData lumpdata = fileSystem.ReadFile (lump); + auto lumpdata = fileSystem.ReadFile (lump); auto alphSwitchList = lumpdata.GetString(); const char *list_p; FSwitchDef *def1, *def2; diff --git a/src/gamedata/textures/animations.cpp b/src/gamedata/textures/animations.cpp index 51834d4e08..202b5bdb63 100644 --- a/src/gamedata/textures/animations.cpp +++ b/src/gamedata/textures/animations.cpp @@ -203,7 +203,7 @@ void FTextureAnimator::InitAnimated (void) int lumpnum = fileSystem.CheckNumForName ("ANIMATED"); if (lumpnum != -1) { - FileData animatedlump = fileSystem.ReadFile (lumpnum); + auto animatedlump = fileSystem.ReadFile (lumpnum); int animatedlen = fileSystem.FileLength(lumpnum); auto animdefs = animatedlump.GetBytes(); const uint8_t *anim_p; diff --git a/src/gamedata/textures/buildloader.cpp b/src/gamedata/textures/buildloader.cpp index 515635871e..2f076e29cb 100644 --- a/src/gamedata/textures/buildloader.cpp +++ b/src/gamedata/textures/buildloader.cpp @@ -41,7 +41,7 @@ #include "colormatcher.h" #include "bitmap.h" #include "textures.h" -#include "resourcefile.h" +#include "fs_filesystem.h" #include "image.h" #include "animations.h" #include "texturemanager.h" @@ -84,7 +84,7 @@ static int BuildPaletteTranslation(int lump) return false; } - FileData data = fileSystem.ReadFile(lump); + auto data = fileSystem.ReadFile(lump); auto ipal = data.GetBytes(); FRemapTable opal; diff --git a/src/maploader/edata.cpp b/src/maploader/edata.cpp index 3bc4928f03..fcf82a10dc 100644 --- a/src/maploader/edata.cpp +++ b/src/maploader/edata.cpp @@ -520,7 +520,7 @@ void MapLoader::InitED() FScanner sc; if (filename.IsEmpty()) return; - int lump = fileSystem.CheckNumForFullName(filename, true, ns_global); + int lump = fileSystem.CheckNumForFullName(filename, true, FileSys::ns_global); if (lump == -1) return; sc.OpenLumpNum(lump); diff --git a/src/maploader/glnodes.cpp b/src/maploader/glnodes.cpp index a72b3b7e47..1a6d67084a 100644 --- a/src/maploader/glnodes.cpp +++ b/src/maploader/glnodes.cpp @@ -736,14 +736,14 @@ static int FindGLNodesInWAD(int labellump) glheader.Format("GL_%s", fileSystem.GetFileFullName(labellump)); if (glheader.Len()<=8) { - int gllabel = fileSystem.CheckNumForName(glheader, ns_global, wadfile); + int gllabel = fileSystem.CheckNumForName(glheader, FileSys::ns_global, wadfile); if (gllabel >= 0) return gllabel; } else { // Before scanning the entire WAD directory let's check first whether // it is necessary. - int gllabel = fileSystem.CheckNumForName("GL_LEVEL", ns_global, wadfile); + int gllabel = fileSystem.CheckNumForName("GL_LEVEL", FileSys::ns_global, wadfile); if (gllabel >= 0) { @@ -753,7 +753,7 @@ static int FindGLNodesInWAD(int labellump) { if (fileSystem.GetFileContainer(lump)==wadfile) { - FileData mem = fileSystem.ReadFile(lump); + auto mem = fileSystem.ReadFile(lump); if (MatchHeader(fileSystem.GetFileFullName(labellump), GetStringFromLump(lump))) return lump; } } @@ -1199,11 +1199,11 @@ bool MapLoader::CheckCachedNodes(MapData *map) UNSAFE_CCMD(clearnodecache) { - FileList list; + FileSys::FileList list; FString path = M_GetCachePath(false); path += "/"; - if (!ScanDirectory(list, path, "*", false)) + if (!FileSys::ScanDirectory(list, path, "*", false)) { Printf("Unable to scan node cache directory %s\n", path.GetChars()); return; diff --git a/src/maploader/maploader.cpp b/src/maploader/maploader.cpp index 56b1e23fed..fdb409c6a5 100644 --- a/src/maploader/maploader.cpp +++ b/src/maploader/maploader.cpp @@ -733,7 +733,7 @@ bool MapLoader::LoadExtendedNodes (FileReader &dalump, uint32_t id) if (compressed) { FileReader zip; - if (zip.OpenDecompressor(dalump, -1, METHOD_ZLIB, false, true)) + if (zip.OpenDecompressor(dalump, -1, FileSys::METHOD_ZLIB, false, true)) { LoadZNodes(zip, type); return true; @@ -753,7 +753,7 @@ bool MapLoader::LoadExtendedNodes (FileReader &dalump, uint32_t id) { Printf("Error loading nodes: %s\n", error.GetMessage()); } - catch (FileSystemException& error) + catch (FileSys::FileSystemException& error) { Printf("Error loading nodes: %s\n", error.what()); } @@ -1157,7 +1157,7 @@ void MapLoader::LoadSectors (MapData *map, FMissingTextureTracker &missingtex) template bool MapLoader::LoadNodes (MapData * map) { - FileData data; + FileSys::FileData data; int j; int k; nodetype *mn; @@ -3338,7 +3338,7 @@ void MapLoader::LoadLightmap(MapData *map) return; FileReader fr; - if (!fr.OpenDecompressor(map->Reader(ML_LIGHTMAP), -1, METHOD_ZLIB, false, false)) + if (!fr.OpenDecompressor(map->Reader(ML_LIGHTMAP), -1, FileSys::METHOD_ZLIB, false, false)) return; diff --git a/src/maploader/maploader.h b/src/maploader/maploader.h index 93c65f9838..6ea2e6121f 100644 --- a/src/maploader/maploader.h +++ b/src/maploader/maploader.h @@ -2,8 +2,8 @@ #include "nodebuild.h" #include "g_levellocals.h" +#include "files.h" -class FileReader; struct FStrifeDialogueNode; struct FStrifeDialogueReply; struct Response; diff --git a/src/menu/loadsavemenu.cpp b/src/menu/loadsavemenu.cpp index e6ed52e9e2..2651f24b40 100644 --- a/src/menu/loadsavemenu.cpp +++ b/src/menu/loadsavemenu.cpp @@ -66,8 +66,8 @@ void FSavegameManager::ReadSaveStrings() LastSaved = LastAccessed = -1; quickSaveSlot = nullptr; - FileList list; - if (ScanDirectory(list, G_GetSavegamesFolder().GetChars(), "*." SAVEGAME_EXT, true)) + FileSys::FileList list; + if (FileSys::ScanDirectory(list, G_GetSavegamesFolder().GetChars(), "*." SAVEGAME_EXT, true)) { for (auto& entry : list) { @@ -76,7 +76,7 @@ void FSavegameManager::ReadSaveStrings() { bool oldVer = false; bool missing = false; - FResourceLump *info = savegame->FindLump("info.json"); + auto info = savegame->FindLump("info.json"); if (info == nullptr) { // savegame info not found. This is not a savegame so leave it alone. diff --git a/src/p_conversation.h b/src/p_conversation.h index b055d5f4c5..d674b3d53e 100644 --- a/src/p_conversation.h +++ b/src/p_conversation.h @@ -72,7 +72,5 @@ void P_ResumeConversation (); void P_ConversationCommand (int netcode, int player, uint8_t **stream); -class FileReader; - #endif diff --git a/src/p_setup.h b/src/p_setup.h index 27c646b5b9..e9142b3562 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -28,7 +28,7 @@ #ifndef __P_SETUP__ #define __P_SETUP__ -#include "resourcefile.h" +#include "fs_filesystem.h" #include "doomdata.h" #include "r_defs.h" #include "nodebuild.h" diff --git a/src/playsim/fragglescript/t_func.cpp b/src/playsim/fragglescript/t_func.cpp index 549c330ae8..fc711eac9f 100644 --- a/src/playsim/fragglescript/t_func.cpp +++ b/src/playsim/fragglescript/t_func.cpp @@ -54,6 +54,8 @@ #include "s_music.h" #include "texturemanager.h" +using namespace FileSys; + static FRandom pr_script("FScript"); // functions. FParser::SF_ means Script Function not, well.. heh, me diff --git a/src/playsim/p_acs.cpp b/src/playsim/p_acs.cpp index 17f6cc459b..6aa85943b2 100644 --- a/src/playsim/p_acs.cpp +++ b/src/playsim/p_acs.cpp @@ -1930,7 +1930,7 @@ void FBehaviorContainer::LoadDefaultModules () FScanner sc(lump); while (sc.GetString()) { - int acslump = fileSystem.CheckNumForName (sc.String, ns_acslibrary); + int acslump = fileSystem.CheckNumForName (sc.String, FileSys::ns_acslibrary); if (acslump >= 0) { LoadModule (acslump); @@ -2567,7 +2567,7 @@ bool FBehavior::Init(FLevelLocals *Level, int lumpnum, FileReader * fr, int len, if (parse[i]) { FBehavior *module = NULL; - int lump = fileSystem.CheckNumForName (&parse[i], ns_acslibrary); + int lump = fileSystem.CheckNumForName (&parse[i], FileSys::ns_acslibrary); if (lump < 0) { Printf (TEXTCOLOR_RED "Could not find ACS library %s.\n", &parse[i]); diff --git a/src/playsim/p_acs.h b/src/playsim/p_acs.h index c2013a0f12..695b229488 100644 --- a/src/playsim/p_acs.h +++ b/src/playsim/p_acs.h @@ -38,12 +38,12 @@ #include "doomtype.h" #include "dthinker.h" #include "engineerrors.h" +#include "files.h" #define LOCAL_SIZE 20 #define NUM_MAPVARS 128 class FFont; -class FileReader; struct line_t; class FSerializer; diff --git a/src/playsim/p_user.cpp b/src/playsim/p_user.cpp index 87633398cc..66a7e83bb4 100644 --- a/src/playsim/p_user.cpp +++ b/src/playsim/p_user.cpp @@ -828,16 +828,16 @@ static int SetupCrouchSprite(AActor *self, int crouchsprite) FString normspritename = sprites[self->SpawnState->sprite].name; FString crouchspritename = sprites[crouchsprite].name; - int spritenorm = fileSystem.CheckNumForName(normspritename + "A1", ns_sprites); + int spritenorm = fileSystem.CheckNumForName(normspritename + "A1", FileSys::ns_sprites); if (spritenorm == -1) { - spritenorm = fileSystem.CheckNumForName(normspritename + "A0", ns_sprites); + spritenorm = fileSystem.CheckNumForName(normspritename + "A0", FileSys::ns_sprites); } - int spritecrouch = fileSystem.CheckNumForName(crouchspritename + "A1", ns_sprites); + int spritecrouch = fileSystem.CheckNumForName(crouchspritename + "A1", FileSys::ns_sprites); if (spritecrouch == -1) { - spritecrouch = fileSystem.CheckNumForName(crouchspritename + "A0", ns_sprites); + spritecrouch = fileSystem.CheckNumForName(crouchspritename + "A0", FileSys::ns_sprites); } if (spritenorm == -1 || spritecrouch == -1) diff --git a/src/r_data/colormaps.cpp b/src/r_data/colormaps.cpp index ad1559c6ba..4d9604b614 100644 --- a/src/r_data/colormaps.cpp +++ b/src/r_data/colormaps.cpp @@ -104,11 +104,11 @@ void R_InitColormaps (bool allowCustomColormap) for (uint32_t i = 0; i < NumLumps; i++) { - if (fileSystem.GetFileNamespace(i) == ns_colormaps) + if (fileSystem.GetFileNamespace(i) == FileSys::ns_colormaps) { auto name = fileSystem.GetFileShortName(i); - if (fileSystem.CheckNumForName (name, ns_colormaps) == (int)i) + if (fileSystem.CheckNumForName (name, FileSys::ns_colormaps) == (int)i) { strncpy(cm.name, name, 8); cm.blend = 0; diff --git a/src/r_data/r_translate.cpp b/src/r_data/r_translate.cpp index 1490faf260..86100a1cb4 100644 --- a/src/r_data/r_translate.cpp +++ b/src/r_data/r_translate.cpp @@ -430,7 +430,7 @@ static void R_CreatePlayerTranslation (float h, float s, float v, const FPlayerC } else { - FileData translump = fileSystem.ReadFile(colorset->Lump); + auto translump = fileSystem.ReadFile(colorset->Lump); auto trans = translump.GetBytes(); for (i = start; i <= end; ++i) { @@ -727,7 +727,7 @@ void R_ParseTrnslate() do { sc.MustGetToken(TK_StringConst); - int pallump = fileSystem.CheckNumForFullName(sc.String, true, ns_global); + int pallump = fileSystem.CheckNumForFullName(sc.String, true, FileSys::ns_global); if (pallump >= 0) // { int start = 0; diff --git a/src/r_data/sprites.cpp b/src/r_data/sprites.cpp index 1f6b161a98..58b9336a16 100644 --- a/src/r_data/sprites.cpp +++ b/src/r_data/sprites.cpp @@ -349,7 +349,7 @@ void R_InitSpriteDefs () memset(vhashes.Data(), -1, sizeof(VHasher)*vmax); for (i = 0; i < vmax; ++i) { - if (fileSystem.GetFileNamespace(i) == ns_voxels) + if (fileSystem.GetFileNamespace(i) == FileSys::ns_voxels) { size_t namelen; int spin; @@ -715,7 +715,7 @@ void R_InitSkins (void) int lump = fileSystem.CheckNumForName (sc.String, Skins[i].namespc); if (lump == -1) { - lump = fileSystem.CheckNumForFullName (sc.String, true, ns_sounds); + lump = fileSystem.CheckNumForFullName (sc.String, true, FileSys::ns_sounds); } if (lump != -1) { @@ -748,7 +748,7 @@ void R_InitSkins (void) sndlumps[j] = fileSystem.CheckNumForName (sc.String, Skins[i].namespc); if (sndlumps[j] == -1) { // Replacement not found, try finding it in the global namespace - sndlumps[j] = fileSystem.CheckNumForFullName (sc.String, true, ns_sounds); + sndlumps[j] = fileSystem.CheckNumForFullName (sc.String, true, FileSys::ns_sounds); } } } @@ -946,7 +946,7 @@ CCMD (skins) static void R_CreateSkinTranslation (const char *palname) { - FileData lump = fileSystem.ReadFile (palname); + auto lump = fileSystem.ReadFile (palname); auto otherPal = lump.GetBytes(); for (int i = 0; i < 256; ++i) @@ -1016,7 +1016,7 @@ void R_InitSprites () Skins[i].range0end = basetype->IntVar(NAME_ColorRangeEnd); Skins[i].Scale = basetype->Scale; Skins[i].sprite = basetype->SpawnState->sprite; - Skins[i].namespc = ns_global; + Skins[i].namespc = FileSys::ns_global; PlayerClasses[i].Skins.Push (i); diff --git a/src/r_data/v_palette.cpp b/src/r_data/v_palette.cpp index 068edb124a..cc63955498 100644 --- a/src/r_data/v_palette.cpp +++ b/src/r_data/v_palette.cpp @@ -44,6 +44,8 @@ #include "m_png.h" #include "v_colortables.h" +using namespace FileSys; + /* Current color blending values */ int BlendR, BlendG, BlendB, BlendA; diff --git a/src/r_data/voxeldef.cpp b/src/r_data/voxeldef.cpp index 1288621787..35037158b9 100644 --- a/src/r_data/voxeldef.cpp +++ b/src/r_data/voxeldef.cpp @@ -50,6 +50,8 @@ #include "g_level.h" #include "r_data/sprites.h" +using namespace FileSys; + struct VoxelOptions { int DroppedSpin = 0; diff --git a/src/rendering/swrenderer/r_swcolormaps.cpp b/src/rendering/swrenderer/r_swcolormaps.cpp index a2ca4666df..b303712eb7 100644 --- a/src/rendering/swrenderer/r_swcolormaps.cpp +++ b/src/rendering/swrenderer/r_swcolormaps.cpp @@ -346,9 +346,9 @@ void SetDefaultColormap (const char *name) uint8_t unremap[256]; uint8_t remap[256]; - lump = fileSystem.CheckNumForFullName (name, true, ns_colormaps); + lump = fileSystem.CheckNumForFullName (name, true, FileSys::ns_colormaps); if (lump == -1) - lump = fileSystem.CheckNumForName (name, ns_global); + lump = fileSystem.CheckNumForName (name, FileSys::ns_global); // [RH] If using BUILD's palette, generate the colormap if (lump == -1 || fileSystem.CheckNumForFullName("palette.dat") >= 0 || fileSystem.CheckNumForFullName("blood.pal") >= 0) diff --git a/src/sound/s_advsound.cpp b/src/sound/s_advsound.cpp index 98d17bc88f..4fbc221cdb 100644 --- a/src/sound/s_advsound.cpp +++ b/src/sound/s_advsound.cpp @@ -50,6 +50,8 @@ #include "i_system.h" #include "s_music.h" +using namespace FileSys; + // MACROS ------------------------------------------------------------------ #define RANDOM 1 diff --git a/src/sound/s_doomsound.cpp b/src/sound/s_doomsound.cpp index f47666e4e7..31a46ca2d3 100644 --- a/src/sound/s_doomsound.cpp +++ b/src/sound/s_doomsound.cpp @@ -191,7 +191,7 @@ static FileReader OpenMusic(const char* musicname) { int lumpnum; lumpnum = fileSystem.CheckNumForFullName(musicname); - if (lumpnum == -1) lumpnum = fileSystem.CheckNumForName(musicname, ns_music); + if (lumpnum == -1) lumpnum = fileSystem.CheckNumForName(musicname, FileSys::ns_music); if (lumpnum == -1) { Printf("Music \"%s\" not found\n", musicname);