Implemented the real server
This commit is contained in:
1 parent
931236bec0
commit
075750442f
22 files changed
+1130
-44
No files matched your search
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include "IGameServer.h"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace FRG {
|
||||
|
||||
// Keeps references held by UI and runtime objects stable while campaigns switch
|
||||
// between the local and remote implementations.
|
||||
class GameServerRouter final : public IGameServer {
|
||||
public:
|
||||
explicit GameServerRouter(IGameServer& initial)
|
||||
: active_(&initial)
|
||||
{
|
||||
}
|
||||
|
||||
void use(IGameServer& server) { active_ = &server; }
|
||||
std::shared_ptr<const GameSnapshot> snapshot() const override {
|
||||
return active_->snapshot();
|
||||
}
|
||||
const std::string& localPlayerId() const override {
|
||||
return active_->localPlayerId();
|
||||
}
|
||||
void submit(const GameCommand& command) override { active_->submit(command); }
|
||||
std::vector<GameServerEvent> drainEvents() override {
|
||||
return active_->drainEvents();
|
||||
}
|
||||
void update(std::int64_t deltaMs) override { active_->update(deltaMs); }
|
||||
void save(nlohmann::json& out) const override { active_->save(out); }
|
||||
void load(const nlohmann::json& in) override { active_->load(in); }
|
||||
|
||||
private:
|
||||
IGameServer* active_;
|
||||
};
|
||||
|
||||
} // namespace FRG
|
||||
Reference in new issue
Block a user