working on refactoring

This commit is contained in:
Vladislav Khorev committed 2026-10-24 22:37:20 +06:00
1 parent 9b71ee447a
commit d5ef126264
12 files changed
+309 -219

No files matched your search

+8
View File
@@ -61,6 +61,7 @@ void GameState::save(nlohmann::json& out) const
out["tutorialPhoneChatScreenOpened"] = tutorialPhoneChatScreenOpened;
out["tutorialJournalScreenOpened"] = tutorialJournalScreenOpened;
out["tutorialNeedOpenTaxiScreen"] = tutorialNeedOpenTaxiScreen;
out["tutorialTaxiHintDone"] = tutorialTaxiHintDone;
// --- Phone / chat ---
out["chatUnread"] = { chatUnread[0], chatUnread[1], chatUnread[2] };
@@ -87,7 +88,9 @@ void GameState::save(nlohmann::json& out) const
out["questJournal"] = std::move(questJson);
// --- Locations ---
// Unloaded locations keep their last stored state; loaded ones are saved live.
nlohmann::json locsJson = nlohmann::json::object();
for (const auto& [name, stored] : storedLocationStates) locsJson[name] = stored;
for (const auto& [name, loc] : locations) {
if (loc) {
nlohmann::json locJson;
@@ -147,6 +150,7 @@ void GameState::load(const nlohmann::json& in)
tutorialPhoneChatScreenOpened = in.value("tutorialPhoneChatScreenOpened", tutorialPhoneChatScreenOpened);
tutorialJournalScreenOpened = in.value("tutorialJournalScreenOpened", tutorialJournalScreenOpened);
tutorialNeedOpenTaxiScreen = in.value("tutorialNeedOpenTaxiScreen", tutorialNeedOpenTaxiScreen);
tutorialTaxiHintDone = in.value("tutorialTaxiHintDone", false);
//logger() << "GameState::load step 6" << std::endl;
@@ -190,9 +194,13 @@ void GameState::load(const nlohmann::json& in)
logger() << "GameState::load step 10" << std::endl;
// --- Locations ---
// Every location's state is stored (applied when the location loads); the ones
// already loaded get it right away.
storedLocationStates.clear();
if (in.contains("locations") && in["locations"].is_object()) {
for (const auto& [name, locJson] : in["locations"].items()) {
//logger() << "GameState::load step 10.1: " << name << std::endl;
storedLocationStates[name] = locJson;
auto it = locations.find(name);
if (it != locations.end() && it->second) {