aboutsummaryrefslogtreecommitdiff
path: root/src/path_functions.cpp
diff options
context:
space:
mode:
authoroldmud0 <oldmud0@users.noreply.github.com>2021-12-30 20:44:59 -0600
committerGitHub <noreply@github.com>2021-12-30 20:44:59 -0600
commit6e1e847750dc593bcb2571c9775b2db11661cdb2 (patch)
treed744ace687e5a603e00daae604cb1a5a35de6795 /src/path_functions.cpp
parent593bd54000be14c9a1455914285c1b2549b0fa51 (diff)
Add and refine debug log messages (#625)
Since these are going to be visible to the user now, at least let's properly format them and make them somewhat helpful.
Diffstat (limited to 'src/path_functions.cpp')
-rw-r--r--src/path_functions.cpp42
1 files changed, 39 insertions, 3 deletions
diff --git a/src/path_functions.cpp b/src/path_functions.cpp
index 6fd06e79..fe0a77e8 100644
--- a/src/path_functions.cpp
+++ b/src/path_functions.cpp
@@ -19,6 +19,15 @@
#define CASE_SENSITIVE_FILESYSTEM
#endif
+static bool is_power_2(unsigned int n) {
+ unsigned int r = 0;
+ while (n) {
+ r += n & 1;
+ n >>= 1;
+ }
+ return r == 1;
+}
+
QString AOApplication::get_base_path()
{
QString base_path = "";
@@ -172,20 +181,41 @@ QString AOApplication::get_config_value(QString p_identifier, QString p_config,
QString AOApplication::get_asset(QString p_element, QString p_theme, QString p_subtheme, QString p_default_theme, QString p_misc, QString p_character, QString p_placeholder)
{
- return get_asset_path(get_asset_paths(p_element, p_theme, p_subtheme, p_default_theme, p_misc, p_character, p_placeholder));
+ QString ret = get_asset_path(get_asset_paths(p_element, p_theme, p_subtheme, p_default_theme, p_misc, p_character, p_placeholder));
+ if (ret.isEmpty()) {
+ qWarning().nospace() << "could not find asset " << p_element
+ << " (theme = " << p_theme
+ << ", misc = " << p_misc
+ << ", char = " << p_character << ")";
+ }
+ return ret;
}
QString AOApplication::get_image(QString p_element, QString p_theme, QString p_subtheme, QString p_default_theme, QString p_misc, QString p_character, QString p_placeholder,
bool static_image)
{
- return get_image_path(get_asset_paths(p_element, p_theme, p_subtheme, p_default_theme, p_misc, p_character, p_placeholder), static_image);
+ QString ret = get_image_path(get_asset_paths(p_element, p_theme, p_subtheme, p_default_theme, p_misc, p_character, p_placeholder), static_image);
+ if (ret.isEmpty()) {
+ qWarning().nospace() << "could not find image " << p_element
+ << " (theme = " << p_theme
+ << ", misc = " << p_misc
+ << ", char = " << p_character
+ << ", static = " << static_image << ")";
+ }
+ return ret;
}
QString AOApplication::get_sfx(QString p_sfx, QString p_misc, QString p_character)
{
QVector<VPath> pathlist = get_asset_paths(p_sfx, current_theme, get_subtheme(), default_theme, p_misc, p_character);
pathlist += get_sounds_path(p_sfx); // Sounds folder path
- return get_sfx_path(pathlist);
+ QString ret = get_sfx_path(pathlist);
+ if (ret.isEmpty()) {
+ qWarning().nospace() << "could not find sfx " << p_sfx
+ << " (char = " << p_character
+ << ", misc = " << p_misc << ")";
+ }
+ return ret;
}
QString AOApplication::get_case_sensitive_path(QString p_file)
@@ -249,6 +279,9 @@ QString AOApplication::get_real_path(const VPath &vpath) {
path = get_case_sensitive_path(path);
if (exists(path)) {
asset_lookup_cache.insert(qHash(vpath), path);
+ unsigned int cache_size = asset_lookup_cache.size();
+ if (is_power_2(cache_size))
+ qDebug() << "lookup cache has reached" << cache_size << "entries";
return path;
}
}
@@ -291,6 +324,9 @@ QString AOApplication::get_real_suffixed_path(const VPath &vpath,
path = get_case_sensitive_path(path);
if (exists(path)) {
asset_lookup_cache.insert(qHash(vpath), path);
+ unsigned int cache_size = asset_lookup_cache.size();
+ if (is_power_2(cache_size))
+ qDebug() << "lookup cache has reached" << cache_size << "entries";
return path;
}
}