summaryrefslogtreecommitdiff
path: root/src/util/asset_manager.cc
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-09 17:35:32 +0100
committerskal <pascal.massimino@gmail.com>2026-02-09 17:35:32 +0100
commitd5f78a4c2e7b626a492643efd62ddeb394276722 (patch)
treecdf38c3d64f6bf417975ce396572fc425d6f8910 /src/util/asset_manager.cc
parent802e97ee695de1bc8657c5cbca653bb2f13b90a8 (diff)
feat: Add debug-only file change detection for rapid iteration
Enables --hot-reload flag to watch config files and notify on changes. Detects modifications to assets/sequences/music for rebuild workflow. Completely stripped from release builds (0 bytes overhead). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'src/util/asset_manager.cc')
-rw-r--r--src/util/asset_manager.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/util/asset_manager.cc b/src/util/asset_manager.cc
index a0e2a97..5067ebe 100644
--- a/src/util/asset_manager.cc
+++ b/src/util/asset_manager.cc
@@ -189,3 +189,23 @@ void DropAsset(AssetId asset_id, const uint8_t* asset) {
}
// For static assets, no dynamic memory to free.
}
+
+#if !defined(STRIP_ALL)
+// Hot-reload: Clear asset cache to force reload from disk
+// Note: This only works for assets that read from disk at runtime.
+// Compiled-in assets cannot be hot-reloaded.
+bool ReloadAssetsFromFile(const char* config_path) {
+ (void)config_path; // Unused - just for API consistency
+
+ // Clear cache to force reload
+ for (size_t i = 0; i < (size_t)AssetId::ASSET_LAST_ID; ++i) {
+ if (g_asset_cache[i].is_procedural && g_asset_cache[i].data) {
+ delete[] g_asset_cache[i].data;
+ }
+ g_asset_cache[i] = {};
+ }
+
+ fprintf(stderr, "[ReloadAssets] Cache cleared\n");
+ return true;
+}
+#endif // !defined(STRIP_ALL)