fix loaded tracks cache does not reset on assets reset

This commit is contained in:
MihailRis 2026-09-03 21:44:14 +03:00
parent bbdf31fc19
commit 8422349e45
5 changed files with 42 additions and 14 deletions

View file

@ -9,6 +9,7 @@
#include "graphics/core/Shader.hpp"
#include "graphics/render/ModelsGenerator.hpp"
#include "graphics/ui/GUI.hpp"
#include "logic/scripting/scripting.hpp"
static debug::Logger logger("assets-management");
@ -49,6 +50,8 @@ AssetsLoader& AssetsManagement::acquireBackgroundLoader() {
void AssetsManagement::loadAssets(Content* content) {
finishBackgroundLoader();
scripting::on_assets_loading();
const auto& paths = engine.getPaths();
logger.info() << "loading assets";
Shader::preprocessor->setPaths(&paths.resPaths);
@ -59,19 +62,24 @@ void AssetsManagement::loadAssets(Content* content) {
AssetsLoader loader(engine, *newAssets, paths.resPaths);
loader.addDefaults(content);
// no need
// correct log messages order is more useful
// todo: before setting to true, check if GLSLExtension thread safe
bool threading = false; // look at three upper lines
if (threading) {
auto task = loader.startTask(
[=]() {}, 0
);
task->waitForEnd();
} else {
while (loader.hasNext()) {
loader.loadNext();
try {
// no need
// correct log messages order is more useful
// todo: before setting to true, check if GLSLExtension thread safe
bool threading = false; // look at three upper lines
if (threading) {
auto task = loader.startTask(
[=]() {}, 0
);
task->waitForEnd();
} else {
while (loader.hasNext()) {
loader.loadNext();
}
}
} catch (...) {
scripting::revert_assets_loading();
throw;
}
assets = std::move(newAssets);
if (content) {

View file

@ -260,6 +260,14 @@ static int push_properties_tables(
return 1;
}
void scripting::on_assets_loading() {
lua::call_internal(lua::get_main_state(), "backup_and_clear_animation");
}
void scripting::revert_assets_loading() {
lua::call_internal(lua::get_main_state(), "restore_animation_backup");
}
void scripting::on_content_load(Content* content) {
scripting::content = content;
scripting::indices = content->getIndices();

View file

@ -50,6 +50,9 @@ namespace scripting {
void initialize(Engine& engine);
void on_assets_loading();
void revert_assets_loading();
void on_content_load(Content* content);
void on_content_reset();