Changeset 25156
- Timestamp:
- Mar 29, 2021, 9:53:06 AM (3 years ago)
- Location:
- ps/trunk
- Files:
-
- 2 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
ps/trunk/binaries/data/config/default.cfg
r25123 r25156 487 487 lateobservers = everyone ; Allow observers to join the game after it started. Possible values: everyone, buddies, disabled. 488 488 observerlimit = 8 ; Prevent further observer joins in running games if this limit is reached 489 490 489 491 490 492 [overlay] -
ps/trunk/binaries/data/mods/public/gui/options/options.json
r25116 r25156 30 30 { 31 31 "type": "boolean", 32 "label": "Network warnings",33 "tooltip": "Show which player has a bad connection in multiplayer games.",34 "config": "overlay.netwarnings"35 },36 {37 "type": "boolean",38 32 "label": "FPS overlay", 39 33 "tooltip": "Show frames per second in top right corner.", … … 57 51 "tooltip": "Always show the remaining ceasefire time.", 58 52 "config": "gui.session.ceasefirecounter" 59 },60 {61 "type": "dropdown",62 "label": "Late observer joins",63 "tooltip": "Allow everybody or buddies only to join the game as observer after it started.",64 "config": "network.lateobservers",65 "list": [66 { "value": "everyone", "label": "Everyone" },67 { "value": "buddies", "label": "Buddies" },68 { "value": "disabled", "label": "Disabled" }69 ]70 },71 {72 "type": "number",73 "label": "Observer limit",74 "tooltip": "Prevent further observers from joining if the limit is reached.",75 "config": "network.observerlimit",76 "min": 0,77 "max": 3278 53 }, 79 54 { … … 426 401 }, 427 402 { 428 "label": " Lobby",403 "label": "Lobby", 429 404 "tooltip": "These settings only affect the multiplayer.", 430 405 "options": … … 448 423 "tooltip": "Show the average rating of the participating players in a column of the gamelist.", 449 424 "config": "lobby.columns.gamerating" 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 450 464 } 451 465 ] -
ps/trunk/binaries/data/mods/public/gui/session/session.js
r25116 r25156 21 21 var g_MiniMapPanel; 22 22 var g_NetworkStatusOverlay; 23 23 24 var g_ObjectivesDialog; 24 25 var g_OutOfSyncNetwork; … … 290 291 g_MiniMapPanel = new MiniMapPanel(g_PlayerViewControl, g_DiplomacyColors, g_WorkerTypes); 291 292 g_NetworkStatusOverlay = new NetworkStatusOverlay(); 293 292 294 g_ObjectivesDialog = new ObjectivesDialog(g_PlayerViewControl, mapCache); 293 295 g_OutOfSyncNetwork = new OutOfSyncNetwork(); -
ps/trunk/binaries/data/mods/public/gui/session/session.xml
r24979 r25156 39 39 40 40 <include file="gui/session/NetworkStatusOverlay.xml"/> 41 41 42 <include file="gui/session/PauseOverlay.xml"/> 42 43 <include file="gui/session/TimeNotificationOverlay.xml"/> -
ps/trunk/source/network/NetServer.cpp
r25099 r25156 748 748 749 749 if (m_ServerTurnManager && session->GetCurrState() != NSS_JOIN_SYNCING) 750 m_ServerTurnManager->UninitialiseClient(session->GetHostID()); // TODO: only for non-observers750 m_ServerTurnManager->UninitialiseClient(session->GetHostID()); 751 751 752 752 // TODO: ought to switch the player controlled by that client … … 1403 1403 1404 1404 // Tell the turn manager to expect commands from this new client 1405 server.m_ServerTurnManager->InitialiseClient(session->GetHostID(), readyTurn); 1405 // Special case: the controller shouldn't be treated as an observer in any case. 1406 bool isObserver = server.m_PlayerAssignments[session->GetGUID()].m_PlayerID == -1 && server.m_ControllerGUID != session->GetGUID(); 1407 server.m_ServerTurnManager->InitialiseClient(session->GetHostID(), readyTurn, isObserver); 1406 1408 1407 1409 // Tell the client that everything has finished loading and it should start now … … 1531 1533 1532 1534 for (CNetServerSession* session : m_Sessions) 1533 m_ServerTurnManager->InitialiseClient(session->GetHostID(), 0); // TODO: only for non-observers 1535 { 1536 // Special case: the controller shouldn't be treated as an observer in any case. 1537 bool isObserver = m_PlayerAssignments[session->GetGUID()].m_PlayerID == -1 && m_ControllerGUID != session->GetGUID(); 1538 m_ServerTurnManager->InitialiseClient(session->GetHostID(), 0, isObserver); 1539 } 1534 1540 1535 1541 m_State = SERVER_STATE_LOADING; -
ps/trunk/source/network/NetServerTurnManager.cpp
r25001 r25156 25 25 #include "lib/utf8.h" 26 26 #include "ps/CLogger.h" 27 27 28 #include "simulation2/system/TurnManager.h" 28 29 … … 74 75 void CNetServerTurnManager::CheckClientsReady() 75 76 { 77 78 79 80 81 76 82 // See if all clients (including self) are ready for a new turn 77 83 for (const std::pair<const int, u32>& clientReady : m_ClientsReady) 78 84 { 85 86 87 79 88 NETSERVERTURN_LOG(" %d: %d <=? %d\n", clientReady.first, clientReady.second, m_ReadyTurn); 80 89 if (clientReady.second <= m_ReadyTurn) … … 172 181 } 173 182 174 void CNetServerTurnManager::InitialiseClient(int client, u32 turn )183 void CNetServerTurnManager::InitialiseClient(int client, u32 turn) 175 184 { 176 185 NETSERVERTURN_LOG("InitialiseClient(client=%d, turn=%d)\n", client, turn); … … 179 188 m_ClientsReady[client] = turn + COMMAND_DELAY_MP - 1; 180 189 m_ClientsSimulated[client] = turn; 190 181 191 } 182 192 … … 188 198 m_ClientsReady.erase(client); 189 199 m_ClientsSimulated.erase(client); 200 190 201 191 202 // Check whether we're ready for the next turn now that we're not -
ps/trunk/source/network/NetServerTurnManager.h
r21023 r25156 1 /* Copyright (C) 20 18Wildfire Games.1 /* Copyright (C) 20 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * … … 19 19 #define INCLUDED_NETSERVERTURNMANAGER 20 20 21 22 21 23 #include <map> 22 #include "ps/CStr.h"24 #include 23 25 24 26 class CNetServerWorker; … … 28 30 * The server-side counterpart to CNetClientTurnManager. 29 31 * Records the turn state of each client, and sends turn advancement messages 30 * when allclients are ready.32 * when clients are ready. 31 33 * 32 34 * Thread-safety: … … 44 46 45 47 /** 46 * Inform the turn manager of a new client who will be sending commands. 48 * Inform the turn manager of a new client 49 * @param observer - whether this client is an observer. 47 50 */ 48 void InitialiseClient(int client, u32 turn );51 void InitialiseClient(int client, u32 turn); 49 52 50 53 /** 51 * Inform the turn manager that a previously-initialised client has left the game 52 * and will no longer be sending commands. 54 * Inform the turn manager that a previously-initialised client has left the game. 53 55 */ 54 56 void UninitialiseClient(int client); … … 74 76 u32 m_ReadyTurn; 75 77 78 79 80 76 81 // Client ID -> ready turn number (the latest turn for which all commands have been received from that client) 77 82 std::map<int, u32> m_ClientsReady; … … 85 90 86 91 // Map of client ID -> playername 87 std::map< u32, CStrW> m_ClientPlayernames;92 std::map<, CStrW> m_ClientPlayernames; 88 93 89 94 // Current turn length -
ps/trunk/source/ps/scripting/JSInterface_Game.cpp
r24983 r25156 99 99 } 100 100 101 102 103 104 105 106 107 108 109 110 111 101 112 bool IsPaused(const ScriptRequest& rq) 102 113 { … … 180 191 ScriptFunction::Register<&GetSimRate>(rq, "GetSimRate"); 181 192 ScriptFunction::Register<&SetSimRate>(rq, "SetSimRate"); 193 182 194 ScriptFunction::Register<&IsPaused>(rq, "IsPaused"); 183 195 ScriptFunction::Register<&SetPaused>(rq, "SetPaused"); -
ps/trunk/source/simulation2/system/TurnManager.cpp
r25016 r25156 1 /* Copyright (C) 202 0Wildfire Games.1 /* Copyright (C) 202 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * … … 37 37 #endif 38 38 39 /**40 * Maximum number of turns between two clients.41 * When we are on turn n, we schedule new commands for n+COMMAND_DELAY.42 * We know that all other clients have finished scheduling commands for n,43 * else we couldn't have got here, which means they're at least on turn n-COMMAND_DELAY+1.44 * We know we have not yet finished scheduling commands for n+COMMAND_DELAY, so no client can be there.45 * Hence other clients can be on turns [n-COMMAND_DELAY+1, ..., n+COMMAND_DELAY-1], and no other,46 * hence any two clients can only be this many turns apart.47 */48 constexpr int MaxClientTurnDelta(int commandDelay)49 {50 return 2 * (commandDelay - 1);51 }52 53 39 const CStr CTurnManager::EventNameSavegameLoaded = "SavegameLoaded"; 54 40 … … 59 45 m_QuickSaveMetadata(m_Simulation2.GetScriptInterface().GetGeneralJSContext()) 60 46 { 61 // Lag between any two clients is bounded. Add 1 for inclusive bounds. 62 m_QueuedCommands.resize(MaxClientTurnDelta(m_CommandDelay) + 1); 47 m_QueuedCommands.resize(1); 63 48 } 64 49 … … 238 223 NETTURN_LOG("AddCommand(client=%d player=%d turn=%d current=%d, ready=%d)\n", client, player, turn, m_CurrentTurn, m_ReadyTurn); 239 224 240 // Reject commands for turns that we should not be able to compute (in the past or too far future). 241 if (m_CurrentTurn >= turn || turn > m_CurrentTurn + MaxClientTurnDelta(m_CommandDelay) + 1) 242 { 243 debug_warn(L"Received command for invalid turn"); 225 // Reject commands for turns that we should not be able to compute (in the past). 226 if (m_CurrentTurn >= turn) 227 { 228 // The most likely explanation is that an observer that's lagging behind is sending commands, 229 // which is possible when cheats are enabled. Report & ignore. 230 // It seems a bad idea to error out too badly here: 231 // nefarious clients could try and send broken commands to DOS. 232 LOGWARNING("Received command for invalid turn %i (current turn is %i)", turn, m_CurrentTurn); 244 233 return; 245 234 } … … 248 237 249 238 ScriptRequest rq(m_Simulation2.GetScriptInterface()); 239 240 241 250 242 m_QueuedCommands[turn - (m_CurrentTurn+1)][client].emplace_back(player, rq.cx, data); 251 243 } -
ps/trunk/source/simulation2/system/TurnManager.h
r25001 r25156 1 /* Copyright (C) 202 0Wildfire Games.1 /* Copyright (C) 202 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * … … 156 156 void QuickLoad(); 157 157 158 u32 GetCurrentTurn() { return m_CurrentTurn; } 158 u32 GetCurrentTurn() const { return m_CurrentTurn; } 159 160 /** 161 * @return how many turns are ready to be computed. 162 * (used to detect players/observers that fall behind the live game. 163 */ 164 u32 GetPendingTurns() const { return m_ReadyTurn - m_CurrentTurn; } 159 165 160 166 protected:
Note:
See TracChangeset
for help on using the changeset viewer.