From d5f78a4c2e7b626a492643efd62ddeb394276722 Mon Sep 17 00:00:00 2001 From: skal Date: Mon, 9 Feb 2026 17:35:32 +0100 Subject: 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 --- src/util/asset_manager.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/util/asset_manager.cc') 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) -- cgit v1.2.3