From 5c0c3bf16f462155259c25cb136452328520471a Mon Sep 17 00:00:00 2001 From: fed <58637860+fedddddd@users.noreply.github.com> Date: Sat, 22 Oct 2022 00:39:11 +0200 Subject: [PATCH] Add db_printDefaultAssets --- src/client/component/fastfiles.cpp | 31 +++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/client/component/fastfiles.cpp b/src/client/component/fastfiles.cpp index e2db9a4c..7b67f301 100644 --- a/src/client/component/fastfiles.cpp +++ b/src/client/component/fastfiles.cpp @@ -1,5 +1,6 @@ #include #include "loader/component_loader.hpp" +#include "game/dvars.hpp" #include "fastfiles.hpp" #include "command.hpp" @@ -16,6 +17,8 @@ namespace fastfiles namespace { + game::dvar_t* db_print_default_assets = nullptr; + template struct bit_array { @@ -41,18 +44,25 @@ namespace fastfiles const auto result = db_find_xasset_header.invoke(type, name, allow_create_default); const auto diff = game::Sys_Milliseconds() - start; + if (db_print_default_assets->current.enabled && game::DB_IsXAssetDefault(type, name)) + { + console::warn("Waited %i msec for default asset \"%s\" of type \"%s\"\n", + diff, name, game::g_assetNames[type]); + } + if (diff > 100) { + const auto missing = result.data == nullptr; console::print( - result.data == nullptr + missing ? console::con_type_error : console::con_type_warning, - "Waited %i msec for %sasset \"%s\", of type \"%s\"\n", - diff, - result.data == nullptr - ? "missing " - : "", - name, + "Waited %i msec for %sasset \"%s\" of type \"%s\"\n", + diff, + missing + ? "missing " + : "", + name, game::g_assetNames[type] ); } @@ -143,7 +153,7 @@ namespace fastfiles { 96, 88, 128, 56, 40, 216, 56, 696, 624, 32, 32, 32, 32, 32, 2112, 2032, - 104, 32, 24, 1520, 152, 152, 16, 64, + 104, 32, 24, 152, 152, 152, 16, 64, 640, 40, 16, 136, 24, 296, 176, 2896, 48, 0, 24, 200, 88, 16, 144, 3848, 56, 72, 16, 16, 0, 0, 0, 0, 24, @@ -484,6 +494,9 @@ namespace fastfiles public: void post_unpack() override { + db_print_default_assets = dvars::register_bool("db_printDefaultAssets", + false, game::DVAR_FLAG_SAVED, "Print default asset usage"); + db_try_load_x_file_internal_hook.create(0x1404173B0, db_try_load_x_file_internal); db_find_xasset_header.create(game::DB_FindXAssetHeader, db_find_xasset_header_stub); @@ -504,7 +517,7 @@ namespace fastfiles reallocate_asset_pools(); - // only load extra zones with addon maps & common_specialops & common_survival & custom maps if the exist + // only load extra zones with addon maps & common_specialops & common_survival & custom maps if they exist utils::hook::call(0x1404128B0, db_load_level_add_map_zone_stub); utils::hook::call(0x140412854, db_load_level_add_custom_zone_stub); utils::hook::call(0x14041282D, db_load_level_add_custom_zone_stub);