By default make offline

This commit is contained in:
Vladislav Khorev 2026-01-18 13:18:59 +03:00
parent 1a7e424085
commit 67c0696061
6 changed files with 20 additions and 17 deletions

View File

@ -78,7 +78,7 @@ target_compile_definitions(space-game001 PRIVATE
WIN32_LEAN_AND_MEAN WIN32_LEAN_AND_MEAN
PNG_ENABLED PNG_ENABLED
SDL_MAIN_HANDLED SDL_MAIN_HANDLED
NETWORK # NETWORK
# SIMPLIFIED # SIMPLIFIED
) )

View File

@ -1,4 +1,4 @@
#include <boost/beast/core.hpp> #include <boost/beast/core.hpp>
#include <boost/beast/websocket.hpp> #include <boost/beast/websocket.hpp>
#include <boost/asio/ip/tcp.hpp> #include <boost/asio/ip/tcp.hpp>
#include <iostream> #include <iostream>
@ -12,7 +12,7 @@
#include <math.h> #include <math.h>
#include "../src/network/ClientState.h" #include "../src/network/ClientState.h"
// Âñïîìîãàòåëüíûé split // Вспомогательный split
std::vector<std::string> split(const std::string& s, char delimiter) { std::vector<std::string> split(const std::string& s, char delimiter) {
std::vector<std::string> tokens; std::vector<std::string> tokens;
std::string token; std::string token;
@ -78,7 +78,7 @@ class Session : public std::enable_shared_from_this<Session> {
std::lock_guard<std::mutex> lock(g_sessions_mutex); std::lock_guard<std::mutex> lock(g_sessions_mutex);
for (auto& session : g_sessions) { for (auto& session : g_sessions) {
if (session->get_id() != id_) { // Íå øëåì îòïðàâèòåëþ if (session->get_id() != id_) { // Не шлем отправителю
session->send_message(event_msg); session->send_message(event_msg);
} }
} }

View File

@ -8,19 +8,11 @@ namespace ZL {
} }
void LocalClient::Poll() { 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) { void LocalClient::Send(const std::string& message) {
if (message == "PING")
{
messageQueue.push("PONG");
}
} }
} }

View File

@ -17,5 +17,9 @@ namespace ZL {
bool IsConnected() const override { return true; } bool IsConnected() const override { return true; }
int GetClientId() const { return 1; } int GetClientId() const { return 1; }
std::unordered_map<int, ClientStateInterval> getRemotePlayers() override {
return std::unordered_map<int, ClientStateInterval>();
}
}; };
} }

View File

@ -1,4 +1,6 @@
#include "WebSocketClient.h" #ifdef NETWORK
#include "WebSocketClient.h"
#include <iostream> #include <iostream>
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
@ -168,4 +170,6 @@ namespace ZL {
} }
); );
} }
} }
#endif

View File

@ -1,5 +1,7 @@
#pragma once #pragma once
#ifdef NETWORK
// WebSocketClient.h // WebSocketClient.h
#include "NetworkInterface.h" #include "NetworkInterface.h"
#include <queue> #include <queue>
@ -53,4 +55,5 @@ namespace ZL {
return remotePlayers; return remotePlayers;
} }
}; };
} }
#endif