diff --git a/CMake/functions/devilutionx_library.cmake b/CMake/functions/devilutionx_library.cmake index 0ba57e24844..d56423dec21 100644 --- a/CMake/functions/devilutionx_library.cmake +++ b/CMake/functions/devilutionx_library.cmake @@ -31,6 +31,11 @@ function(add_devilutionx_library NAME) target_link_libraries(${NAME} PUBLIC "$<${ASAN_GENEX}:-fsanitize=address;-fsanitize-recover=address>") endif() + if(DEVILUTIONX_RESOURCE_TRACKING_ENABLED) + genex_for_option(DEVILUTIONX_RESOURCE_TRACKING_ENABLED) + target_compile_definitions(${NAME} PUBLIC "$<${DEVILUTIONX_RESOURCE_TRACKING_ENABLED_GENEX}:DEVILUTIONX_RESOURCE_TRACKING_ENABLED>") + endif() + if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") genex_for_option(DEVILUTIONX_STATIC_CXX_STDLIB) target_link_libraries(${NAME} PUBLIC $<${DEVILUTIONX_STATIC_CXX_STDLIB_GENEX}:-static-libgcc;-static-libstdc++>) diff --git a/CMakeLists.txt b/CMakeLists.txt index fef9d4bc15f..ceb17a29b99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,6 +94,7 @@ DEBUG_OPTION(ASAN "Enable address sanitizer") DEBUG_OPTION(UBSAN "Enable undefined behaviour sanitizer") option(TSAN "Enable thread sanitizer (not compatible with ASAN=ON)" OFF) DEBUG_OPTION(DEBUG "Enable debug mode in engine") +DEBUG_OPTION(DEVILUTIONX_RESOURCE_TRACKING_ENABLED "Enable resource tracking") option(GPERF "Build with GPerfTools profiler" OFF) cmake_dependent_option(GPERF_HEAP_FIRST_GAME_ITERATION "Save heap profile of the first game iteration" OFF "GPERF" OFF) option(ENABLE_CODECOVERAGE "Instrument code for code coverage (only enabled with BUILD_TESTING)" OFF) diff --git a/Source/cursor.cpp b/Source/cursor.cpp index e7680ec8586..c5986196713 100644 --- a/Source/cursor.cpp +++ b/Source/cursor.cpp @@ -495,14 +495,24 @@ void CreateHalfSizeItemSprites() const Surface halfSurface = ownedHalfSurface.subregion(0, 0, itemSurface.w() / 2, itemSurface.h() / 2); SDL_Rect halfSurfaceRect = MakeSdlRect(0, 0, halfSurface.w(), halfSurface.h()); SDL_SetClipRect(halfSurface.surface, &halfSurfaceRect); +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED std::string name = StrCat("runtime\\objcurs_half_size\\", cursId); +#endif BilinearDownscaleByHalf8(itemSurface.surface, paletteTransparencyLookup, halfSurface.surface, 1); - HalfSizeItemSprites[outputIndex].emplace(SurfaceToClx(std::string(name), /*trnName=*/ {}, halfSurface, 1, 1)); + HalfSizeItemSprites[outputIndex].emplace(SurfaceToClx( +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + std::string(name), /*trnName=*/ {}, +#endif + halfSurface, 1, 1)); SDL_FillRect(itemSurface.surface, nullptr, 1); ClxDrawTRN(itemSurface, { 0, itemSurface.h() }, itemSprite, redTrn); BilinearDownscaleByHalf8(itemSurface.surface, paletteTransparencyLookup, halfSurface.surface, 1); - HalfSizeItemSpritesRed[outputIndex].emplace(SurfaceToClx(std::move(name), /*trnName=*/"red", halfSurface, 1, 1)); + HalfSizeItemSpritesRed[outputIndex].emplace(SurfaceToClx( +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + std::move(name), /*trnName=*/"red", +#endif + halfSurface, 1, 1)); }; size_t outputIndex = 0; diff --git a/Source/engine/clx_sprite.hpp b/Source/engine/clx_sprite.hpp index e691e3be166..8aaa7dbfd07 100644 --- a/Source/engine/clx_sprite.hpp +++ b/Source/engine/clx_sprite.hpp @@ -115,7 +115,11 @@ class ClxSpriteList { ClxSpriteList(const OwnedClxSpriteList &owned); - [[nodiscard]] OwnedClxSpriteList clone(std::string_view name, std::string_view trnName = {}) const; + [[nodiscard]] OwnedClxSpriteList clone( +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + std::string_view name, std::string_view trnName = {} +#endif + ) const; [[nodiscard]] constexpr uint32_t numSprites() const { @@ -336,8 +340,13 @@ class OwnedClxSpriteListOrSheet; /** * @brief Implicitly convertible to `ClxSpriteList` and owns its data. */ -class OwnedClxSpriteList : public OwnedResource { +class OwnedClxSpriteList +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + : public OwnedResource +#endif +{ public: +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED explicit OwnedClxSpriteList(std::string_view name, std::string_view trnName, std::unique_ptr &&data) : OwnedResource(name, trnName) , data_(std::move(data)) @@ -351,10 +360,19 @@ class OwnedClxSpriteList : public OwnedResource { { assert(data_ != nullptr); } +#endif - explicit OwnedClxSpriteList(ResourceStoreHandle &&handle, std::unique_ptr &&data) - : OwnedResource(std::move(handle)) - , data_(std::move(data)) + explicit OwnedClxSpriteList( +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + ResourceStoreHandle &&handle, +#endif + std::unique_ptr &&data) + : +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + OwnedResource(std::move(handle)) + , +#endif + data_(std::move(data)) { assert(data_ != nullptr); } @@ -362,9 +380,18 @@ class OwnedClxSpriteList : public OwnedResource { OwnedClxSpriteList(OwnedClxSpriteList &&) noexcept = default; OwnedClxSpriteList &operator=(OwnedClxSpriteList &&) noexcept = default; - [[nodiscard]] OwnedClxSpriteList clone(std::string_view trnName = {}) const + [[nodiscard]] OwnedClxSpriteList clone( +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + std::string_view trnName = {} +#endif + ) const { - return ClxSpriteList { *this }.clone(resourceName(), trnName); + return ClxSpriteList { *this }.clone( +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + resourceName(), + trnName +#endif + ); } [[nodiscard]] ClxSprite operator[](size_t spriteIndex) const @@ -398,19 +425,33 @@ inline ClxSpriteList::ClxSpriteList(const OwnedClxSpriteList &owned) { } -inline OwnedClxSpriteList ClxSpriteList::clone(std::string_view name, std::string_view trnName) const +inline OwnedClxSpriteList ClxSpriteList::clone( +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + std::string_view name, std::string_view trnName +#endif +) const { const size_t size = dataSize(); std::unique_ptr data { new uint8_t[size] }; memcpy(data.get(), data_, size); - return OwnedClxSpriteList { name, trnName, std::move(data) }; + return OwnedClxSpriteList { +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + name, trnName, +#endif + std::move(data) + }; } /** * @brief Implicitly convertible to `ClxSpriteSheet` and owns its data. */ -class OwnedClxSpriteSheet : public OwnedResource { +class OwnedClxSpriteSheet +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + : public OwnedResource +#endif +{ public: +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED OwnedClxSpriteSheet(std::string_view name, std::string_view trnName, std::unique_ptr &&data, uint16_t numLists) : OwnedResource(name, trnName) , data_(std::move(data)) @@ -428,10 +469,19 @@ class OwnedClxSpriteSheet : public OwnedResource { assert(data_ != nullptr); assert(numLists > 0); } - - explicit OwnedClxSpriteSheet(ResourceStoreHandle &&handle, std::unique_ptr &&data, uint16_t numLists) - : OwnedResource(std::move(handle)) - , data_(std::move(data)) +#endif + + explicit OwnedClxSpriteSheet( +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + ResourceStoreHandle &&handle, +#endif + std::unique_ptr &&data, uint16_t numLists) + : +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + OwnedResource(std::move(handle)) + , +#endif + data_(std::move(data)) , num_lists_(numLists) { assert(data_ != nullptr); @@ -507,7 +557,11 @@ class ClxSpriteListOrSheet { ClxSpriteListOrSheet(const OwnedClxSpriteListOrSheet &listOrSheet); - [[nodiscard]] OwnedClxSpriteListOrSheet clone(std::string_view name, std::string_view trnName = {}) const; + [[nodiscard]] OwnedClxSpriteListOrSheet clone( +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + std::string_view name, std::string_view trnName = {} +#endif + ) const; [[nodiscard]] constexpr ClxSpriteList list() const { @@ -546,48 +600,87 @@ class OptionalOwnedClxSpriteListOrSheet; /** * @brief A CLX sprite list or a sprite sheet (list of lists). */ -class OwnedClxSpriteListOrSheet : public OwnedResource { +class OwnedClxSpriteListOrSheet +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + : public OwnedResource +#endif +{ public: static OwnedClxSpriteListOrSheet fromBuffer( - std::string_view name, std::string_view trnName, std::unique_ptr &&data, size_t size) +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + std::string_view name, std::string_view trnName, +#endif + std::unique_ptr &&data, size_t size) { const uint16_t numLists = GetNumListsFromClxListOrSheetBuffer(data.get(), size); - return OwnedClxSpriteListOrSheet { name, trnName, std::move(data), numLists }; - } - - explicit OwnedClxSpriteListOrSheet(std::string_view name, std::string_view trnName, std::unique_ptr &&data, uint16_t numLists) - : OwnedResource(name, trnName) - , data_(std::move(data)) + return OwnedClxSpriteListOrSheet { +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + name, trnName, +#endif + std::move(data), numLists + }; + } + + explicit OwnedClxSpriteListOrSheet( +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + std::string_view name, std::string_view trnName, +#endif + std::unique_ptr &&data, uint16_t numLists) + : +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + OwnedResource(name, trnName) + , +#endif + data_(std::move(data)) , num_lists_(numLists) { } +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED explicit OwnedClxSpriteListOrSheet(std::string &&name, std::string &&trnName, std::unique_ptr &&data, uint16_t numLists) : OwnedResource(std::move(name), std::move(trnName)) , data_(std::move(data)) , num_lists_(numLists) { } +#endif explicit OwnedClxSpriteListOrSheet(OwnedClxSpriteSheet &&sheet) noexcept - : OwnedResource(std::move(sheet.handle_)) - , data_(std::move(sheet.data_)) + : +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + OwnedResource(std::move(sheet.handle_)) + , +#endif + data_(std::move(sheet.data_)) , num_lists_(sheet.num_lists_) { } explicit OwnedClxSpriteListOrSheet(OwnedClxSpriteList &&list) noexcept - : OwnedResource(std::move(list.handle_)) - , data_(std::move(list.data_)) + : +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + OwnedResource(std::move(list.handle_)) + , +#endif + data_(std::move(list.data_)) { } OwnedClxSpriteListOrSheet(OwnedClxSpriteListOrSheet &&) noexcept = default; OwnedClxSpriteListOrSheet &operator=(OwnedClxSpriteListOrSheet &&) noexcept = default; - [[nodiscard]] OwnedClxSpriteListOrSheet clone(std::string_view trnName = {}) const + [[nodiscard]] OwnedClxSpriteListOrSheet clone( +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + std::string_view trnName = {} +#endif + ) const { - return ClxSpriteListOrSheet { *this }.clone(resourceName(), trnName); + return ClxSpriteListOrSheet { *this }.clone( +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + resourceName(), + trnName +#endif + ); } [[nodiscard]] ClxSpriteList list() const & @@ -599,7 +692,12 @@ class OwnedClxSpriteListOrSheet : public OwnedResourcedataSize(); std::unique_ptr data { new uint8_t[size] }; memcpy(data.get(), data_, size); - return OwnedClxSpriteListOrSheet { name, trnName, std::move(data), num_lists_ }; + return OwnedClxSpriteListOrSheet { +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + name, trnName, +#endif + std::move(data), num_lists_ + }; } /** diff --git a/Source/engine/load_cel.cpp b/Source/engine/load_cel.cpp index 3e3ab34cce2..b302df1e6f9 100644 --- a/Source/engine/load_cel.cpp +++ b/Source/engine/load_cel.cpp @@ -31,7 +31,11 @@ OwnedClxSpriteListOrSheet LoadCelListOrSheet(const char *pszName, PointerOrValue #ifdef DEBUG_CEL_TO_CL2_SIZE std::cout << path; #endif - return CelToClx(pszName, /*trnName=*/ {}, data.get(), size, widthOrWidths); + return CelToClx( +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + pszName, /*trnName=*/ {}, +#endif + data.get(), size, widthOrWidths); #endif } diff --git a/Source/engine/load_cl2.cpp b/Source/engine/load_cl2.cpp index 64f2ca6da33..157fd66badb 100644 --- a/Source/engine/load_cl2.cpp +++ b/Source/engine/load_cl2.cpp @@ -25,7 +25,11 @@ OwnedClxSpriteListOrSheet LoadCl2ListOrSheet(const char *pszName, PointerOrValue #else size_t size; std::unique_ptr data = LoadFileInMem(path, &size); - return Cl2ToClx(pszName, /*trnName=*/ {}, std::move(data), size, widthOrWidths); + return Cl2ToClx( +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + pszName, /*trnName=*/ {}, +#endif + std::move(data), size, widthOrWidths); #endif } diff --git a/Source/engine/load_cl2.hpp b/Source/engine/load_cl2.hpp index e0c98bba6fd..ed5163adec5 100644 --- a/Source/engine/load_cl2.hpp +++ b/Source/engine/load_cl2.hpp @@ -64,9 +64,19 @@ OwnedClxSpriteSheet LoadMultipleCl2Sheet(std::string_view name, tl::function_ref accumulatedSize += size; } #ifdef UNPACKED_MPQS - return OwnedClxSpriteSheet { name, /*trnName=*/ {}, std::move(data), static_cast(count) }; + return OwnedClxSpriteSheet { +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + name, /*trnName=*/ {}, +#endif + std::move(data), static_cast(count) + }; #else - return Cl2ToClx(name, /*trnName=*/ {}, std::move(data), accumulatedSize, frameWidth).sheet(); + return Cl2ToClx( +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + name, /*trnName=*/ {}, +#endif + std::move(data), accumulatedSize, frameWidth) + .sheet(); #endif } diff --git a/Source/engine/load_clx.cpp b/Source/engine/load_clx.cpp index 0a013200b79..aa94b953637 100644 --- a/Source/engine/load_clx.cpp +++ b/Source/engine/load_clx.cpp @@ -28,7 +28,11 @@ OptionalOwnedClxSpriteListOrSheet LoadOptionalClxListOrSheet(const char *path) return std::nullopt; } pathStrView.remove_suffix(4); - return OwnedClxSpriteListOrSheet::fromBuffer(pathStrView, /*trnName=*/ {}, std::move(data), size); + return OwnedClxSpriteListOrSheet::fromBuffer( +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + pathStrView, /*trnName=*/ {}, +#endif + std::move(data), size); } OwnedClxSpriteListOrSheet LoadClxListOrSheet(const char *path) @@ -37,7 +41,11 @@ OwnedClxSpriteListOrSheet LoadClxListOrSheet(const char *path) std::unique_ptr data = LoadFileInMem(path, &size); std::string_view pathStrView = path; pathStrView.remove_suffix(4); - return OwnedClxSpriteListOrSheet::fromBuffer(pathStrView, /*trnName=*/ {}, std::move(data), size); + return OwnedClxSpriteListOrSheet::fromBuffer( +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + pathStrView, /*trnName=*/ {}, +#endif + std::move(data), size); } } // namespace devilution diff --git a/Source/engine/resource_store.cpp b/Source/engine/resource_store.cpp index e131ad52f29..ddfceffef18 100644 --- a/Source/engine/resource_store.cpp +++ b/Source/engine/resource_store.cpp @@ -1,5 +1,7 @@ #include "engine/resource_store.hpp" +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + #include #include #include @@ -106,3 +108,5 @@ void ResourceStore::unregisterResource(const ResourceStoreHandle &handle) } } // namespace devilution + +#endif // DEVILUTIONX_RESOURCE_TRACKING_ENABLED diff --git a/Source/engine/resource_store.hpp b/Source/engine/resource_store.hpp index 38454ca2140..ade77c5db99 100644 --- a/Source/engine/resource_store.hpp +++ b/Source/engine/resource_store.hpp @@ -1,5 +1,7 @@ #pragma once +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + #include #include #include @@ -192,3 +194,5 @@ class OwnedResource { }; } // namespace devilution + +#endif // DEVILUTIONX_RESOURCE_TRACKING_ENABLED diff --git a/Source/lua/modules/dev.cpp b/Source/lua/modules/dev.cpp index c19cdb6c067..512bc9a4da0 100644 --- a/Source/lua/modules/dev.cpp +++ b/Source/lua/modules/dev.cpp @@ -26,7 +26,9 @@ sol::table LuaDevModule(sol::state_view &lua) SetDocumented(table, "player", "", "Player-related commands.", LuaDevPlayerModule(lua)); SetDocumented(table, "quests", "", "Quest-related commands.", LuaDevQuestsModule(lua)); SetDocumented(table, "search", "", "Search the map for monsters / items / objects.", LuaDevSearchModule(lua)); +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED SetDocumented(table, "resources", "", "Resource commands.", LuaDevResourcesModule(lua)); +#endif SetDocumented(table, "towners", "", "Town NPC commands.", LuaDevTownersModule(lua)); return table; } diff --git a/Source/lua/modules/dev/resources.cpp b/Source/lua/modules/dev/resources.cpp index a77be4c0938..cd2dba17298 100644 --- a/Source/lua/modules/dev/resources.cpp +++ b/Source/lua/modules/dev/resources.cpp @@ -1,4 +1,4 @@ -#ifdef _DEBUG +#if defined(_DEBUG) && defined(DEVILUTIONX_RESOURCE_TRACKING_ENABLED) #include "lua/modules/dev/resources.hpp" #include @@ -82,4 +82,4 @@ sol::table LuaDevResourcesModule(sol::state_view &lua) } } // namespace devilution -#endif // _DEBUG +#endif // defined(_DEBUG) && defined(DEVILUTIONX_RESOURCE_TRACKING_ENABLED) diff --git a/Source/lua/modules/dev/resources.hpp b/Source/lua/modules/dev/resources.hpp index caba9136cbd..316cea837bd 100644 --- a/Source/lua/modules/dev/resources.hpp +++ b/Source/lua/modules/dev/resources.hpp @@ -1,5 +1,5 @@ #pragma once -#ifdef _DEBUG +#if defined(_DEBUG) && defined(DEVILUTIONX_RESOURCE_TRACKING_ENABLED) #include namespace devilution { @@ -7,4 +7,4 @@ namespace devilution { sol::table LuaDevResourcesModule(sol::state_view &lua); } // namespace devilution -#endif // _DEBUG +#endif // defined(_DEBUG) && defined(DEVILUTIONX_RESOURCE_TRACKING_ENABLED) diff --git a/Source/monster.cpp b/Source/monster.cpp index 4ac053fb701..7185ce77211 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -139,7 +139,9 @@ void InitMonsterTRN(CMonster &monst) } AnimStruct &anim = monst.anims[i]; +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED anim.sprites->setVariant(monst.data().trnFile); +#endif if (anim.sprites->isSheet()) { ClxApplyTrans(ClxSpriteSheet { anim.sprites->sheet() }, colorTranslations.data()); } else { diff --git a/Source/panels/charpanel.cpp b/Source/panels/charpanel.cpp index 5317964b856..8ae4b3e7fa8 100644 --- a/Source/panels/charpanel.cpp +++ b/Source/panels/charpanel.cpp @@ -294,7 +294,11 @@ void LoadCharPanel() } } - Panel = SurfaceToClx("runtime\\char_panel", /*trnName=*/ {}, out); + Panel = SurfaceToClx( +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + "runtime\\char_panel", /*trnName=*/ {}, +#endif + out); } void FreeCharPanel() diff --git a/Source/panels/mainpanel.cpp b/Source/panels/mainpanel.cpp index c73177bb5ac..6e5b820325f 100644 --- a/Source/panels/mainpanel.cpp +++ b/Source/panels/mainpanel.cpp @@ -90,7 +90,11 @@ void LoadMainPanel() RenderMainButton(*out, 3, _("menu"), 0); RenderMainButton(*out, 4, _("inv"), 1); RenderMainButton(*out, 5, _("spells"), 0); - PanelButtonDown = SurfaceToClx("runtime\\panel_button_down", /*trnName=*/ {}, *out, NumButtonSprites); + PanelButtonDown = SurfaceToClx( +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + "runtime\\panel_button_down", /*trnName=*/ {}, +#endif + *out, NumButtonSprites); out = std::nullopt; if (IsChatAvailable()) { @@ -128,7 +132,11 @@ void LoadMainPanel() int voiceWidth = GetLineWidth(_("voice"), GameFont12, 2); RenderClxSprite(talkSurface.subregion((talkButtonWidth - voiceWidth) / 2, 39, voiceWidth, 9), (*PanelButtonGrime)[1], { 0, 0 }); DrawButtonText(talkSurface, _("voice"), { { 0, 33 }, { talkButtonWidth, 0 } }, UiFlags::ColorButtonpushed); - TalkButton = SurfaceToClx("runtime\\talk_button", /*trnName=*/ {}, talkSurface, NumTalkButtonSprites); + TalkButton = SurfaceToClx( +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + "runtime\\talk_button", /*trnName=*/ {}, +#endif + talkSurface, NumTalkButtonSprites); } PanelButtonDownGrime = std::nullopt; diff --git a/Source/qol/monhealthbar.cpp b/Source/qol/monhealthbar.cpp index 6925dc251f4..4a4fae15840 100644 --- a/Source/qol/monhealthbar.cpp +++ b/Source/qol/monhealthbar.cpp @@ -43,7 +43,11 @@ void InitMonsterHealthBar() healthBlueTrn[234] = 185; healthBlueTrn[235] = 186; healthBlueTrn[236] = 187; - healthBlue = health->clone("healthBlue"); + healthBlue = health->clone( +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + "healthBlue" +#endif + ); ClxApplyTrans(*healthBlue, healthBlueTrn.data()); } diff --git a/Source/utils/cel_to_clx.cpp b/Source/utils/cel_to_clx.cpp index 3d103fe0ca8..eaa9d85e40e 100644 --- a/Source/utils/cel_to_clx.cpp +++ b/Source/utils/cel_to_clx.cpp @@ -32,7 +32,11 @@ constexpr uint8_t GetCelTransparentWidth(uint8_t control) } // namespace -OwnedClxSpriteListOrSheet CelToClx(std::string_view name, std::string_view trnName, const uint8_t *data, size_t size, PointerOrValue widthOrWidths) +OwnedClxSpriteListOrSheet CelToClx( +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + std::string_view name, std::string_view trnName, +#endif + const uint8_t *data, size_t size, PointerOrValue widthOrWidths) { // A CEL file either begins with: // 1. A CEL header. @@ -125,7 +129,12 @@ OwnedClxSpriteListOrSheet CelToClx(std::string_view name, std::string_view trnNa #ifdef DEBUG_CEL_TO_CL2_SIZE std::cout << "\t" << size << "\t" << cl2Data.size() << "\t" << std::setprecision(1) << std::fixed << (static_cast(cl2Data.size()) - static_cast(size)) / ((float)size) * 100 << "%" << std::endl; #endif - return OwnedClxSpriteListOrSheet { name, trnName, std::move(out), static_cast(numGroups == 1 ? 0 : numGroups) }; + return OwnedClxSpriteListOrSheet { +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + name, trnName, +#endif + std::move(out), static_cast(numGroups == 1 ? 0 : numGroups) + }; } } // namespace devilution diff --git a/Source/utils/cel_to_clx.hpp b/Source/utils/cel_to_clx.hpp index 9fc5677abcb..4a954a5818f 100644 --- a/Source/utils/cel_to_clx.hpp +++ b/Source/utils/cel_to_clx.hpp @@ -9,6 +9,10 @@ namespace devilution { -OwnedClxSpriteListOrSheet CelToClx(std::string_view name, std::string_view trnName, const uint8_t *data, size_t size, PointerOrValue widthOrWidths); +OwnedClxSpriteListOrSheet CelToClx( +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + std::string_view name, std::string_view trnName, +#endif + const uint8_t *data, size_t size, PointerOrValue widthOrWidths); } // namespace devilution diff --git a/Source/utils/cl2_to_clx.hpp b/Source/utils/cl2_to_clx.hpp index 3596a631895..bfaa04ccd3b 100644 --- a/Source/utils/cl2_to_clx.hpp +++ b/Source/utils/cl2_to_clx.hpp @@ -20,14 +20,23 @@ namespace devilution { uint16_t Cl2ToClx(const uint8_t *data, size_t size, PointerOrValue widthOrWidths, std::vector &clxData); -inline OwnedClxSpriteListOrSheet Cl2ToClx(std::string_view name, std::string_view trnName, std::unique_ptr &&data, size_t size, PointerOrValue widthOrWidths) +inline OwnedClxSpriteListOrSheet Cl2ToClx( +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + std::string_view name, std::string_view trnName, +#endif + std::unique_ptr &&data, size_t size, PointerOrValue widthOrWidths) { std::vector clxData; const uint16_t numLists = Cl2ToClx(data.get(), size, widthOrWidths, clxData); data = nullptr; data = std::unique_ptr(new uint8_t[clxData.size()]); memcpy(&data[0], clxData.data(), clxData.size()); - return OwnedClxSpriteListOrSheet { name, trnName, std::move(data), numLists }; + return OwnedClxSpriteListOrSheet { +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + name, trnName, +#endif + std::move(data), numLists + }; } } // namespace devilution diff --git a/Source/utils/pcx_to_clx.cpp b/Source/utils/pcx_to_clx.cpp index 0665176b8d9..a6a5f1da480 100644 --- a/Source/utils/pcx_to_clx.cpp +++ b/Source/utils/pcx_to_clx.cpp @@ -190,7 +190,12 @@ OptionalOwnedClxSpriteList PcxToClx(std::string_view name, AssetHandle &handle, #ifdef DEBUG_PCX_TO_CL2_SIZE std::cout << "\t" << pixelDataSize << "\t" << cl2Data.size() << "\t" << std::setprecision(1) << std::fixed << (static_cast(cl2Data.size()) - static_cast(pixelDataSize)) / ((float)pixelDataSize) * 100 << "%" << std::endl; #endif - return OwnedClxSpriteList { name, /*trnName=*/ {}, std::move(out) }; + return OwnedClxSpriteList { +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + name, /*trnName=*/ {}, +#endif + std::move(out) + }; } } // namespace devilution diff --git a/Source/utils/surface_to_clx.cpp b/Source/utils/surface_to_clx.cpp index 740b6aa3420..c50bd1ec2c2 100644 --- a/Source/utils/surface_to_clx.cpp +++ b/Source/utils/surface_to_clx.cpp @@ -15,7 +15,11 @@ namespace devilution { -OwnedClxSpriteList SurfaceToClx(std::string &&name, std::string &&trnName, const Surface &surface, unsigned numFrames, +OwnedClxSpriteList SurfaceToClx( +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + std::string &&name, std::string &&trnName, +#endif + const Surface &surface, unsigned numFrames, std::optional transparentColor) { // CLX header: frame count, frame offset for each frame, file size @@ -92,7 +96,12 @@ OwnedClxSpriteList SurfaceToClx(std::string &&name, std::string &&trnName, const << std::setprecision(1) << std::fixed << (static_cast(clxData.size()) - surfaceSize) / ((float)surfaceSize) * 100 << "%" << std::endl; #endif - return OwnedClxSpriteList { std::move(name), std::move(trnName), std::move(out) }; + return OwnedClxSpriteList { +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + std::move(name), std::move(trnName), +#endif + std::move(out) + }; } } // namespace devilution diff --git a/Source/utils/surface_to_clx.hpp b/Source/utils/surface_to_clx.hpp index b8756c17912..57a6bbed2a2 100644 --- a/Source/utils/surface_to_clx.hpp +++ b/Source/utils/surface_to_clx.hpp @@ -17,7 +17,11 @@ namespace devilution { * @param numFrames The number of vertically stacked frames in the surface. * @param transparentColor The PCX palette index of the transparent color. */ -OwnedClxSpriteList SurfaceToClx(std::string &&name, std::string &&trnName, const Surface &surface, unsigned numFrames = 1, +OwnedClxSpriteList SurfaceToClx( +#ifdef DEVILUTIONX_RESOURCE_TRACKING_ENABLED + std::string &&name, std::string &&trnName, +#endif + const Surface &surface, unsigned numFrames = 1, std::optional transparentColor = std::nullopt); } // namespace devilution