Major refactoring - internal server state machine implemented
This commit is contained in:
1 parent
71c654e5b6
commit
66e93d46f4
48 files changed
+3948
-3696
No files matched your search
+13
-8
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "items/Item.h"
|
||||
#include "quest/QuestJournal.h"
|
||||
#include "Location.h"
|
||||
#include "LocationGameState.h"
|
||||
#include "ISaveable.h"
|
||||
#include "external/nlohmann/json.hpp"
|
||||
#include <unordered_map>
|
||||
@@ -32,17 +32,17 @@ struct StoredChatMessage {
|
||||
bool incoming;
|
||||
};
|
||||
|
||||
using LocationMap = std::unordered_map<std::string, std::shared_ptr<Location>>;
|
||||
|
||||
struct GameState : public ISaveable {
|
||||
static constexpr int kSchemaVersion = 1;
|
||||
|
||||
// --- World ---
|
||||
// Campaign being played (see CampaignRegistry).
|
||||
std::string campaignId = "main";
|
||||
// The campaign's loaded location(s); only the one the player is in is kept loaded.
|
||||
LocationMap locations;
|
||||
// Saved state (Location::save) of the campaign's locations that are not loaded,
|
||||
// applied when one is loaded again. save()/load() cover both maps.
|
||||
std::unordered_map<std::string, nlohmann::json> storedLocationStates;
|
||||
// Pure authoritative location data. Live Location/render/script instances are
|
||||
// private runtime storage in InternalGameServer and never enter GameState.
|
||||
std::unordered_map<std::string, LocationGameState> locations;
|
||||
// Players are campaign-level entities and remain stable across locations.
|
||||
PlayerStateMap players;
|
||||
std::string currentLocationName;
|
||||
bool isDarklands = false;
|
||||
bool isNight = false;
|
||||
@@ -73,6 +73,11 @@ struct GameState : public ISaveable {
|
||||
// Moves to the next step if `step` is the current one; returns whether it did.
|
||||
bool completeTutorialStep(TutorialStep step);
|
||||
|
||||
CharacterState* findCharacter(
|
||||
const std::string& locationId, const std::string& characterId);
|
||||
const CharacterState* findCharacter(
|
||||
const std::string& locationId, const std::string& characterId) const;
|
||||
|
||||
// --- Phone / chat ---
|
||||
bool chatUnread[3] = { true, true, true };
|
||||
std::string chatPreviewMsg[3];
|
||||
|
||||
Reference in new issue
Block a user