Working on the server

This commit is contained in:
Vladislav Khorev committed 2026-11-05 20:12:30 +06:00
1 parent 075750442f
commit 28c6e83eda
30 files changed
+646 -362

No files matched your search

+12 -3
View File
@@ -1,4 +1,5 @@
#include "game_server/NetworkProtocol.h"
#include "LocationState.h"
#include <cstdlib>
#include <iostream>
#include <string>
@@ -16,10 +17,14 @@ void require(bool condition, const char* message)
int main()
{
FRG::LocationNetworkState locationState;
nlohmann::json savedLocationState;
locationState.save(savedLocationState);
const nlohmann::json original{
{"schemaVersion", 1},
{"campaignId", "battle_zone"},
{"players", {{"player", {{"hp", 200.0}}}}}
{"schemaVersion", 2},
{"campaignId", "battle_zone_multiplayer"},
{"players", {{"player", {{"hp", 200.0}}}}},
{"locations", {{"uni_exterior", {{"state", savedLocationState}}}}}
};
const std::string message = FRG::makeStateMessage(original);
nlohmann::json parsed;
@@ -28,6 +33,10 @@ int main()
FRG::parseStateMessage(message, parsed, error),
"valid state envelope was rejected");
require(parsed == original, "state payload did not round trip");
require(
!parsed["locations"]["uni_exterior"]["state"].contains("cameraAzimuth") &&
!parsed["locations"]["uni_exterior"]["state"].contains("cameraInclination"),
"local camera state leaked into the network payload");
require(
!FRG::parseStateMessage(