From 17d4701e88901b9656d7777d165be1da2b60a412 Mon Sep 17 00:00:00 2001 From: redpolline <11156324-redpolline@users.noreply.gitlab.com> Date: Wed, 12 Feb 2025 05:21:10 -0500 Subject: [PATCH] Add more debug logging to achievement image loads. --- dll/common_includes.h | 1 + dll/steam_user_stats.h | 57 +++++++++++++++++++++++++++++++++++++++--- 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/dll/common_includes.h b/dll/common_includes.h index f29bef5..a00cc04 100644 --- a/dll/common_includes.h +++ b/dll/common_includes.h @@ -174,6 +174,7 @@ inline void reset_LastError() #include #include #include +#include #include #include diff --git a/dll/steam_user_stats.h b/dll/steam_user_stats.h index ff42133..617295a 100644 --- a/dll/steam_user_stats.h +++ b/dll/steam_user_stats.h @@ -139,11 +139,19 @@ int32 achievement_image_data_gray_find(std::string key) { void load_achievements_db() { uint64 count = 0; + uint64 bad_count = 0; + uint64 corrupt_count = 0; + uint64 missing_normal_images = 0; + uint64 missing_gray_images = 0; + uint64 unreadable_normal_images = 0; + uint64 unreadable_gray_images = 0; + std::string name = ""; std::string file_path = Local_Storage::get_game_settings_path() + achievements_user_file; local_storage->load_json(file_path, defined_achievements); for (auto & it : defined_achievements) { + name = ""; try { - std::string name = static_cast(it["name"]); + name = static_cast(it["name"]); if (name.length() > 0) { std::string normal = Local_Storage::get_game_settings_path() + static_cast(it["icon"]); std::string gray = Local_Storage::get_game_settings_path() + static_cast(it["icongray"]); @@ -175,13 +183,56 @@ void load_achievements_db() achievement_image_data_normal[name] = settings->add_image(normalStr, normal_width, normal_height); achievement_image_data_gray[name] = settings->add_image(grayStr, gray_width, gray_height); count++; + } else { + corrupt_count++; + if (normal_width <= 0 || normal_height <= 0) + unreadable_normal_images++; + if (gray_width <= 0 || gray_height <= 0) + unreadable_gray_images++; + PRINT_DEBUG("%s %s %s.\n", + "Unable to load images for achievement", + name.c_str(), + "unable to get resolution from images."); } + } else { + corrupt_count++; + if (normal.length() <= 0) + missing_normal_images++; + if (gray.length() <= 0) + missing_gray_images++; + PRINT_DEBUG("%s %s %s.\n", + "Unable to load images for achievement", + name.c_str(), + "an image path is not configured"); } + } else { + bad_count++; + PRINT_DEBUG("%s %s %s %" PRIu64 " %s.\n", + "Invalid achievement json at", + file_path.c_str(), + "for achievement number", + count + corrupt_count + bad_count + 1, + "is invalid"); } - } catch (...) {} + } catch (std::exception &e) { + bad_count++; + PRINT_DEBUG("Loading image data for achievement %s failed. Exception type: %s Reason: %s.\n", + (name.length() > 0) ? name.c_str() : "ERROR: NAME PARSING FROM JSON FAILED", + typeid(e).name(), + e.what()); + } } - PRINT_DEBUG("loaded %llu achievement images.\n", count); + PRINT_DEBUG("loaded %" PRIu64 " achievement images.\npartial loaded %" PRIu64 " achievements.\nskipped %" PRIu64 " invalid achievements.\n", + count, + corrupt_count, + bad_count); + PRINT_DEBUG("ignored %" PRIu64 " missing normal achivement images.\nignored %" PRIu64 " missing gray achivement images.\n", + missing_normal_images, + missing_gray_images); + PRINT_DEBUG("ignored %" PRIu64 " unreadable normal achivement images.\nignored %" PRIu64 " unreadable gray achivement images.\n", + unreadable_normal_images, + unreadable_gray_images); } void load_achievements()