Adapting music to web, fixing scripts, fixing bug in initial state

This commit is contained in:
Vladislav Khorev committed 2026-07-24 23:58:29 +03:00
1 parent c3f449b999
commit 5ecf5fb9d7
43 files changed
+875 -388

No files matched your search

+26
View File
@@ -2147,10 +2147,13 @@ namespace FRG
void Location::load(const nlohmann::json& in)
{
//logger() << "Location::load step 1" << std::endl;
// Location-level state
if (in.contains("locationState")) {
state.load(in["locationState"]);
}
//logger() << "Location::load step 2" << std::endl;
// Re-sync navigation pointer from restored index
if (state.activeNavigationIndex >= 0 &&
@@ -2159,6 +2162,8 @@ namespace FRG
navigation = &navigationMaps[state.activeNavigationIndex];
}
//logger() << "Location::load step 3" << std::endl;
// Restore trigger zone runtime state (by id)
if (in.contains("triggerZoneState") && in["triggerZoneState"].is_object()) {
const auto& tzs = in["triggerZoneState"];
@@ -2169,6 +2174,7 @@ namespace FRG
}
}
}
//logger() << "Location::load step 4" << std::endl;
// Restore teleport zone runtime state (by id)
if (in.contains("teleportZoneState") && in["teleportZoneState"].is_object()) {
@@ -2180,11 +2186,15 @@ namespace FRG
}
}
//logger() << "Location::load step 5" << std::endl;
// Player character state
if (player && in.contains("playerState")) {
player->state.load(in["playerState"]);
}
//logger() << "Location::load step 6" << std::endl;
// NPC states
if (in.contains("npcStates") && in["npcStates"].is_array()) {
const auto& arr = in["npcStates"];
@@ -2195,6 +2205,8 @@ namespace FRG
}
}
//logger() << "Location::load step 7" << std::endl;
// Interactive object states
if (in.contains("interactiveObjectStates") && in["interactiveObjectStates"].is_array()) {
const auto& arr = in["interactiveObjectStates"];
@@ -2202,17 +2214,23 @@ namespace FRG
interactiveObjects[i].state.load(arr[i]);
}
}
//logger() << "Location::load step 8" << std::endl;
// Dialogue runtime state
if (in.contains("dialogueState")) {
dialogueSystem.loadDialogueState(in["dialogueState"]);
}
//logger() << "Location::load step 9" << std::endl;
// Lua globals
if (in.contains("scriptGlobals")) {
scriptEngine.loadScriptGlobals(in["scriptGlobals"]);
}
//logger() << "Location::load step 10" << std::endl;
// Re-wire in-flight, one-shot Lua callbacks (walk-arrival / animation-complete)
// that were serialized by name. Must run after scriptEngine has already run the
// location's script (guaranteed: Location::setup() always runs before load())
@@ -2220,16 +2238,24 @@ namespace FRG
if (player && !player->state.onArrivedCallbackName.empty()) {
scriptEngine.rehydrateNamedCallback(player->state.onArrivedCallbackName, player->state.onArrivedCallback);
}
//logger() << "Location::load step 11" << std::endl;
for (auto& npc : npcs) {
if (npc && !npc->state.onArrivedCallbackName.empty()) {
scriptEngine.rehydrateNamedCallback(npc->state.onArrivedCallbackName, npc->state.onArrivedCallback);
}
}
//logger() << "Location::load step 12" << std::endl;
for (auto& intObj : interactiveObjects) {
if (intObj.state.isAnimating && intObj.state.animTask && !intObj.state.animTask->onCompleteName.empty()) {
scriptEngine.rehydrateNamedCallback(intObj.state.animTask->onCompleteName, intObj.state.animTask->onComplete);
}
}
//logger() << "Location::load step 13" << std::endl;
}
} // namespace FRG