From 67c0696061d87b8aa8d6a65ea67775572d254d3f Mon Sep 17 00:00:00 2001 From: Vladislav Khorev Date: Sun, 18 Jan 2026 13:18:59 +0300 Subject: [PATCH] By default make offline --- proj-windows/CMakeLists.txt | 2 +- server/server.cpp | 6 +++--- src/network/LocalClient.cpp | 12 ++---------- src/network/LocalClient.h | 4 ++++ src/network/WebSocketClient.cpp | 8 ++++++-- src/network/WebSocketClient.h | 5 ++++- 6 files changed, 20 insertions(+), 17 deletions(-) diff --git a/proj-windows/CMakeLists.txt b/proj-windows/CMakeLists.txt index dad2933..06e1ed3 100644 --- a/proj-windows/CMakeLists.txt +++ b/proj-windows/CMakeLists.txt @@ -78,7 +78,7 @@ target_compile_definitions(space-game001 PRIVATE WIN32_LEAN_AND_MEAN PNG_ENABLED SDL_MAIN_HANDLED - NETWORK +# NETWORK # SIMPLIFIED ) diff --git a/server/server.cpp b/server/server.cpp index 06f2331..1853f88 100644 --- a/server/server.cpp +++ b/server/server.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -12,7 +12,7 @@ #include #include "../src/network/ClientState.h" -// split +// Вспомогательный split std::vector split(const std::string& s, char delimiter) { std::vector tokens; std::string token; @@ -78,7 +78,7 @@ class Session : public std::enable_shared_from_this { std::lock_guard lock(g_sessions_mutex); for (auto& session : g_sessions) { - if (session->get_id() != id_) { // + if (session->get_id() != id_) { // Не шлем отправителю session->send_message(event_msg); } } diff --git a/src/network/LocalClient.cpp b/src/network/LocalClient.cpp index 57d3266..264f526 100644 --- a/src/network/LocalClient.cpp +++ b/src/network/LocalClient.cpp @@ -8,19 +8,11 @@ namespace ZL { } void LocalClient::Poll() { - - if (!messageQueue.empty()) { - std::string msg = messageQueue.front(); - messageQueue.pop(); - std::cout << "LocalClient received message: " << msg << std::endl; - } } void LocalClient::Send(const std::string& message) { - if (message == "PING") - { - messageQueue.push("PONG"); - } } + + } \ No newline at end of file diff --git a/src/network/LocalClient.h b/src/network/LocalClient.h index 3e9b15e..55994b3 100644 --- a/src/network/LocalClient.h +++ b/src/network/LocalClient.h @@ -17,5 +17,9 @@ namespace ZL { bool IsConnected() const override { return true; } int GetClientId() const { return 1; } + + std::unordered_map getRemotePlayers() override { + return std::unordered_map(); + } }; } \ No newline at end of file diff --git a/src/network/WebSocketClient.cpp b/src/network/WebSocketClient.cpp index e9d1789..ce9dd3e 100644 --- a/src/network/WebSocketClient.cpp +++ b/src/network/WebSocketClient.cpp @@ -1,4 +1,6 @@ -#include "WebSocketClient.h" +#ifdef NETWORK + +#include "WebSocketClient.h" #include #include @@ -168,4 +170,6 @@ namespace ZL { } ); } -} \ No newline at end of file +} + +#endif diff --git a/src/network/WebSocketClient.h b/src/network/WebSocketClient.h index 09d3616..d8b108f 100644 --- a/src/network/WebSocketClient.h +++ b/src/network/WebSocketClient.h @@ -1,5 +1,7 @@ #pragma once +#ifdef NETWORK + // WebSocketClient.h #include "NetworkInterface.h" #include @@ -53,4 +55,5 @@ namespace ZL { return remotePlayers; } }; -} \ No newline at end of file +} +#endif