Production-ready, fixing server bugs

This commit is contained in:
Vladislav Khorev committed 2026-03-12 11:36:47 +03:00
1 parent ca98fea2bd
commit beac06fd45
10 files changed
+110 -108

No files matched your search

+1 -1
View File
@@ -25,7 +25,6 @@ Session::Session(Server& server, tcp::socket&& socket, int id)
}
bool Session::is_timed_out(std::chrono::system_clock::time_point now) const {
if (!joined_) return false;
auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(now - lastReceivedTime_).count();
return elapsed > PLAYER_TIMEOUT_MS;
}
@@ -268,6 +267,7 @@ void Session::process_message(const std::string& msg) {
std::lock_guard<std::mutex> lock(server_.g_sessions_mutex);
for (auto& session : server_.g_sessions) {
if (session->get_id() == this->id_) continue;
if (!session->joined_) continue;
std::string otherInfo = "PLAYERINFO:" + std::to_string(session->get_id()) + ":" + session->nickname + ":" + std::to_string(session->shipType);
this->send_message(otherInfo);