Ticket #3907: network_cleanup.patch

File network_cleanup.patch, 23.2 KB (added by Itms, 8 years ago)
  • binaries/data/mods/public/gui/common/network.js

     
    172172{
    173173    // Remove outdated messages
    174174    for (let guid in g_NetworkWarnings)
    175     {
    176         if (Date.now() > g_NetworkWarnings[guid].added + g_NetworkWarningTimeout)
     175        if (Date.now() > g_NetworkWarnings[guid].added + g_NetworkWarningTimeout ||
     176            guid != "server" && !g_PlayerAssignments[guid])
    177177            delete g_NetworkWarnings[guid];
    178178
    179         if (guid != "server" && !g_PlayerAssignments[guid])
    180             delete g_NetworkWarnings[guid];
    181     }
    182 
    183179    // Show local messages first
    184180    let guids = Object.keys(g_NetworkWarnings).sort(guid => guid != "server");
    185181
  • source/network/NetClient.cpp

     
    140140
    141141void CNetClient::TraceMember(JSTracer *trc)
    142142{
    143     std::deque<JS::Heap<JS::Value> >::iterator itr;
    144     for (itr=m_GuiMessageQueue.begin(); itr != m_GuiMessageQueue.end(); ++itr)
    145         JS_CallHeapValueTracer(trc, &*itr, "m_GuiMessageQueue");
     143    for (JS::Heap<JS::Value>& guiMessage : m_GuiMessageQueue)
     144        JS_CallHeapValueTracer(trc, &guiMessage, "m_GuiMessageQueue");
    146145}
    147146
    148147void CNetClient::SetUserName(const CStrW& username)
     
    278277    JS::RootedValue hosts(cx);
    279278    GetScriptInterface().GetProperty(msg, "hosts", &hosts);
    280279
    281     for (PlayerAssignmentMap::iterator it = m_PlayerAssignments.begin(); it != m_PlayerAssignments.end(); ++it)
     280    for (const std::pair<CStr, PlayerAssignment>& p : m_PlayerAssignments)
    282281    {
    283282        JS::RootedValue host(cx);
    284283        GetScriptInterface().Eval("({})", &host);
    285         GetScriptInterface().SetProperty(host, "name", std::wstring(it->second.m_Name), false);
    286         GetScriptInterface().SetProperty(host, "player", it->second.m_PlayerID, false);
    287         GetScriptInterface().SetProperty(host, "status", it->second.m_Status, false);
    288         GetScriptInterface().SetProperty(hosts, it->first.c_str(), host, false);
     284        GetScriptInterface().SetProperty(host, "name", std::wstring(p.second.m_Name), false);
     285        GetScriptInterface().SetProperty(host, "player", p.second.m_PlayerID, false);
     286        GetScriptInterface().SetProperty(host, "status", p.second.m_Status, false);
     287        GetScriptInterface().SetProperty(hosts, p.first.c_str(), host, false);
    289288    }
    290289
    291290    PushGuiMessage(msg);
     
    709708        return true;
    710709
    711710    CClientPerformanceMessage* message = (CClientPerformanceMessage*)event->GetParamRef();
    712     std::vector<CClientPerformanceMessage::S_m_Clients> &clients = message->m_Clients;
    713711
    714712    // Display warnings for other clients with bad ping
    715     for (size_t i = 0; i < clients.size(); ++i)
     713    for (size_t i = 0; i < message->m_Clients.size(); ++i)
    716714    {
    717         if (clients[i].m_MeanRTT < DEFAULT_TURN_LENGTH_MP || clients[i].m_GUID == client->m_GUID)
     715        if (message->m_Clients[i].m_MeanRTT < DEFAULT_TURN_LENGTH_MP || message->m_Clients[i].m_GUID == client->m_GUID)
    718716            continue;
    719717
    720718        JS::RootedValue msg(cx);
    721719        client->GetScriptInterface().Eval("({ 'type':'netwarn', 'warntype': 'client-latency' })", &msg);
    722         client->GetScriptInterface().SetProperty(msg, "guid", clients[i].m_GUID);
    723         client->GetScriptInterface().SetProperty(msg, "meanRTT", clients[i].m_MeanRTT);
     720        client->GetScriptInterface().SetProperty(msg, "guid", message->m_Clients[i].m_GUID);
     721        client->GetScriptInterface().SetProperty(msg, "meanRTT", message->m_Clients[i].m_MeanRTT);
    724722        client->PushGuiMessage(msg);
    725723    }
    726724
  • source/network/NetClient.h

     
    249249    CStr m_GUID;
    250250
    251251    /// Queue of messages for GuiPoll
    252     std::deque<JS::Heap<JS::Value> > m_GuiMessageQueue;
     252    std::deque<JS::Heap<JS::Value>> m_GuiMessageQueue;
    253253
    254254    /// Serialized game state received when joining an in-progress game
    255255    std::string m_JoinSyncBuffer;
  • source/network/NetFileTransfer.cpp

     
     1/* Copyright (C) 2016 Wildfire Games.
     2 * This file is part of 0 A.D.
     3 *
     4 * 0 A.D. is free software: you can redistribute it and/or modify
     5 * it under the terms of the GNU General Public License as published by
     6 * the Free Software Foundation, either version 2 of the License, or
     7 * (at your option) any later version.
     8 *
     9 * 0 A.D. is distributed in the hope that it will be useful,
     10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12 * GNU General Public License for more details.
     13 *
     14 * You should have received a copy of the GNU General Public License
     15 * along with 0 A.D.  If not, see <http://www.gnu.org/licenses/>.
     16 */
     17
    118#include "precompiled.h"
    219
    320#include "NetFileTransfer.h"
     
    141158{
    142159    // Find tasks which have fewer packets in flight than their window size,
    143160    // and send more packets
    144     for (FileSendTasksMap::iterator it = m_FileSendTasks.begin(); it != m_FileSendTasks.end(); ++it)
     161    for (std::pair<const u32, CNetFileSendTask>& p : m_FileSendTasks)
    145162    {
    146         while (it->second.packetsInFlight < it->second.maxWindowSize && it->second.offset < it->second.buffer.size())
     163        CNetFileSendTask& task = p.second;
     164
     165        while (task.packetsInFlight < task.maxWindowSize && task.offset < task.buffer.size())
    147166        {
    148167            CFileTransferDataMessage dataMessage;
    149             dataMessage.m_RequestID = it->second.requestID;
    150             ssize_t packetSize = std::min(DEFAULT_FILE_TRANSFER_PACKET_SIZE, it->second.buffer.size() - it->second.offset);
    151             dataMessage.m_Data = it->second.buffer.substr(it->second.offset, packetSize);
    152             it->second.offset += packetSize;
    153             it->second.packetsInFlight++;
     168            dataMessage.m_RequestID = task.requestID;
     169            ssize_t packetSize = std::min(DEFAULT_FILE_TRANSFER_PACKET_SIZE, task.buffer.size() - task.offset);
     170            dataMessage.m_Data = task.buffer.substr(task.offset, packetSize);
     171            task.offset += packetSize;
     172            ++task.packetsInFlight;
    154173            m_Session->SendMessage(&dataMessage);
    155174        }
    156175    }
  • source/network/NetFileTransfer.h

     
    1 /* Copyright (C) 2011 Wildfire Games.
     1/* Copyright (C) 2016 Wildfire Games.
    22 * This file is part of 0 A.D.
    33 *
    44 * 0 A.D. is free software: you can redistribute it and/or modify
     
    121121
    122122    u32 m_NextRequestID;
    123123
    124     typedef std::map<u32, shared_ptr<CNetFileReceiveTask> > FileReceiveTasksMap;
     124    typedef std::map<u32, shared_ptr<CNetFileReceiveTask>> FileReceiveTasksMap;
    125125    FileReceiveTasksMap m_FileReceiveTasks;
    126126
    127127    typedef std::map<u32, CNetFileSendTask> FileSendTasksMap;
  • source/network/NetServer.cpp

     
    9090
    9191        // Find the session corresponding to the rejoining host (if any)
    9292        CNetServerSession* session = NULL;
    93         for (size_t i = 0; i < m_Server.m_Sessions.size(); ++i)
     93        for (CNetServerSession* serverSession : m_Server.m_Sessions)
    9494        {
    95             if (m_Server.m_Sessions[i]->GetHostID() == m_RejoinerHostID)
     95            if (serverSession->GetHostID() == m_RejoinerHostID)
    9696            {
    97                 session = m_Server.m_Sessions[i];
     97                session = serverSession;
    9898                break;
    9999            }
    100100        }
     
    157157
    158158    delete m_Stats;
    159159
    160     for (size_t i = 0; i < m_Sessions.size(); ++i)
     160    for (CNetServerSession* session : m_Sessions)
    161161    {
    162         m_Sessions[i]->DisconnectNow(NDR_SERVER_SHUTDOWN);
    163         delete m_Sessions[i];
     162        session->DisconnectNow(NDR_SERVER_SHUTDOWN);
     163        delete session;
    164164    }
    165165
    166166    if (m_Host)
    167     {
    168167        enet_host_destroy(m_Host);
    169     }
    170168
    171169    delete m_ServerTurnManager;
    172170}
     
    346344    bool ok = true;
    347345
    348346    // Send to all sessions that are active and has finished authentication
    349     for (size_t i = 0; i < m_Sessions.size(); ++i)
    350     {
    351         if (m_Sessions[i]->GetCurrState() == NSS_PREGAME || m_Sessions[i]->GetCurrState() == NSS_INGAME)
    352         {
    353             if (!m_Sessions[i]->SendMessage(message))
     347    // TODO: this does lots of repeated message serialisation if we have lots
     348    // of remote peers; could do it more efficiently if that's a real problem
     349    for (CNetServerSession* session : m_Sessions)
     350        if (session->GetCurrState() == NSS_PREGAME || session->GetCurrState() == NSS_INGAME)
     351            if (!session->SendMessage(message))
    354352                ok = false;
    355353
    356             // TODO: this does lots of repeated message serialisation if we have lots
    357             // of remote peers; could do it more efficiently if that's a real problem
    358         }
    359     }
    360 
    361354    return ok;
    362355}
    363356
     
    411404    JSContext* cx = m_ScriptInterface->GetContext();
    412405    JSAutoRequest rq(cx);
    413406
    414     std::vector<std::pair<int, CStr> > newAssignPlayer;
     407    std::vector<std::pair<int, CStr>> newAssignPlayer;
    415408    std::vector<bool> newStartGame;
    416     std::vector<std::pair<CStr, int> > newPlayerReady;
     409    std::vector<std::pair<CStr, int>> newPlayerReady;
    417410    std::vector<bool> newPlayerResetReady;
    418411    std::vector<std::string> newGameAttributes;
    419412    std::vector<u32> newTurnLength;
     
    432425        newTurnLength.swap(m_TurnLengthQueue);
    433426    }
    434427
    435     for (size_t i = 0; i < newAssignPlayer.size(); ++i)
    436         AssignPlayer(newAssignPlayer[i].first, newAssignPlayer[i].second);
     428    for (const std::pair<int, CStr8>& p : newAssignPlayer)
     429        AssignPlayer(p.first, p.second);
    437430
    438     for (size_t i = 0; i < newPlayerReady.size(); ++i)
    439         SetPlayerReady(newPlayerReady[i].first, newPlayerReady[i].second);
     431    for (const std::pair<CStr8, int>& p : newPlayerReady)
     432        SetPlayerReady(p.first, p.second);
    440433
    441434    if (!newPlayerResetReady.empty())
    442435        ClearAllPlayerReady();
     
    456449        StartGame();
    457450
    458451    // Perform file transfers
    459     for (size_t i = 0; i < m_Sessions.size(); ++i)
    460         m_Sessions[i]->GetFileTransferer().Poll();
     452    for (CNetServerSession* session : m_Sessions)
     453        session->GetFileTransferer().Poll();
    461454
    462455    CheckClientConnections();
    463456
     
    635628    }
    636629
    637630    // Update FSM
    638     bool ok = session->Update(message->GetType(), (void*)message);
    639     if (!ok)
     631    if (!session->Update(message->GetType(), (void*)message))
    640632        LOGERROR("Net server: Error running FSM update (type=%d state=%d)", (int)message->GetType(), (int)session->GetCurrState());
    641633}
    642634
     
    719711{
    720712    // Find all player IDs in active use; we mustn't give them to a second player (excluding the unassigned ID: -1)
    721713    std::set<i32> usedIDs;
    722     for (PlayerAssignmentMap::iterator it = m_PlayerAssignments.begin(); it != m_PlayerAssignments.end(); ++it)
    723         if (it->second.m_Enabled && it->second.m_PlayerID != -1)
    724             usedIDs.insert(it->second.m_PlayerID);
     714    for (const std::pair<CStr, PlayerAssignment>& p : m_PlayerAssignments)
     715        if (p.second.m_Enabled && p.second.m_PlayerID != -1)
     716            usedIDs.insert(p.second.m_PlayerID);
    725717
    726718    // If the player is rejoining after disconnecting, try to give them
    727719    // back their old player ID
     
    824816void CNetServerWorker::AssignPlayer(int playerID, const CStr& guid)
    825817{
    826818    // Remove anyone who's already assigned to this player
    827     for (PlayerAssignmentMap::iterator it = m_PlayerAssignments.begin(); it != m_PlayerAssignments.end(); ++it)
     819    for (std::pair<const CStr, PlayerAssignment>& p : m_PlayerAssignments)
    828820    {
    829         if (it->second.m_PlayerID == playerID)
    830             it->second.m_PlayerID = -1;
     821        if (p.second.m_PlayerID == playerID)
     822            p.second.m_PlayerID = -1;
    831823    }
    832824
    833825    // Update this host's assignment if it exists
     
    839831
    840832void CNetServerWorker::ConstructPlayerAssignmentMessage(CPlayerAssignmentMessage& message)
    841833{
    842     for (PlayerAssignmentMap::iterator it = m_PlayerAssignments.begin(); it != m_PlayerAssignments.end(); ++it)
     834    for (const std::pair<CStr, PlayerAssignment>& p : m_PlayerAssignments)
    843835    {
    844         if (!it->second.m_Enabled)
     836        if (!p.second.m_Enabled)
    845837            continue;
    846838
    847839        CPlayerAssignmentMessage::S_m_Hosts h;
    848         h.m_GUID = it->first;
    849         h.m_Name = it->second.m_Name;
    850         h.m_PlayerID = it->second.m_PlayerID;
    851         h.m_Status = it->second.m_Status;
     840        h.m_GUID = p.first;
     841        h.m_Name = p.second.m_Name;
     842        h.m_PlayerID = p.second.m_PlayerID;
     843        h.m_Status = p.second.m_Status;
    852844        message.m_Hosts.push_back(h);
    853845    }
    854846}
     
    955947        int disconnectedPlayers = 0;
    956948        int connectedPlayers = 0;
    957949        // (TODO: if GUIDs were stable, we should use them instead)
    958         for (PlayerAssignmentMap::iterator it = server.m_PlayerAssignments.begin(); it != server.m_PlayerAssignments.end(); ++it)
     950        for (const std::pair<CStr, PlayerAssignment>& p : server.m_PlayerAssignments)
    959951        {
    960             if (!it->second.m_Enabled && it->second.m_Name == username)
     952            const PlayerAssignment& assignment = p.second;
     953
     954            if (!assignment.m_Enabled && assignment.m_Name == username)
    961955            {
    962                 isObserver = it->second.m_PlayerID == -1;
     956                isObserver = assignment.m_PlayerID == -1;
    963957                isRejoining = true;
    964958            }
    965959
    966             if (it->second.m_PlayerID == -1)
     960            if (assignment.m_PlayerID == -1)
    967961                continue;
    968962
    969             if (it->second.m_Enabled)
     963            if (assignment.m_Enabled)
    970964                ++connectedPlayers;
    971965            else
    972966                ++disconnectedPlayers;
     
    12081202
    12091203void CNetServerWorker::CheckGameLoadStatus(CNetServerSession* changedSession)
    12101204{
    1211     for (size_t i = 0; i < m_Sessions.size(); ++i)
     1205    for (const CNetServerSession* session : m_Sessions)
    12121206    {
    1213         if (m_Sessions[i] != changedSession && m_Sessions[i]->GetCurrState() != NSS_INGAME)
     1207        if (session != changedSession && session->GetCurrState() != NSS_INGAME)
    12141208            return;
    12151209    }
    12161210
     
    12251219{
    12261220    m_ServerTurnManager = new CNetServerTurnManager(*this);
    12271221
    1228     for (size_t i = 0; i < m_Sessions.size(); ++i)
    1229         m_ServerTurnManager->InitialiseClient(m_Sessions[i]->GetHostID(), 0); // TODO: only for non-observers
     1222    for (const CNetServerSession* session : m_Sessions)
     1223        m_ServerTurnManager->InitialiseClient(session->GetHostID(), 0); // TODO: only for non-observers
    12301224
    12311225    m_State = SERVER_STATE_LOADING;
    12321226
     
    12891283    while (true)
    12901284    {
    12911285        bool unique = true;
    1292         for (size_t i = 0; i < m_Sessions.size(); ++i)
     1286        for (const CNetServerSession* session : m_Sessions)
    12931287        {
    1294             if (m_Sessions[i]->GetUserName() == name)
     1288            if (session->GetUserName() == name)
    12951289            {
    12961290                unique = false;
    12971291                break;
  • source/network/NetServer.h

     
    327327     * turn number, to simplify support for rejoining etc.
    328328     * TODO: verify this doesn't use too much RAM.
    329329     */
    330     std::vector<std::vector<CSimulationMessage> > m_SavedCommands;
     330    std::vector<std::vector<CSimulationMessage>> m_SavedCommands;
    331331
    332332    /**
    333333     * The latest copy of the simulation state, received from an existing
     
    361361    bool m_Shutdown; // protected by m_WorkerMutex
    362362
    363363    // Queues for messages sent by the game thread:
    364     std::vector<std::pair<int, CStr> > m_AssignPlayerQueue; // protected by m_WorkerMutex
     364    std::vector<std::pair<int, CStr>> m_AssignPlayerQueue; // protected by m_WorkerMutex
    365365    std::vector<bool> m_StartGameQueue; // protected by m_WorkerMutex
    366     std::vector<std::pair<CStr, int> > m_PlayerReadyQueue; // protected by m_WorkerMutex
     366    std::vector<std::pair<CStr, int>> m_PlayerReadyQueue; // protected by m_WorkerMutex
    367367    std::vector<bool> m_PlayerResetReadyQueue; // protected by m_WorkerMutex
    368368    std::vector<std::string> m_GameAttributesQueue; // protected by m_WorkerMutex
    369369    std::vector<u32> m_TurnLengthQueue; // protected by m_WorkerMutex
  • source/network/NetStats.cpp

     
    1 /* Copyright (C) 2010 Wildfire Games.
     1/* Copyright (C) 2016 Wildfire Games.
    22 * This file is part of 0 A.D.
    33 *
    44 * 0 A.D. is free software: you can redistribute it and/or modify
     
    6969{
    7070    m_ColumnDescriptions.clear();
    7171    m_ColumnDescriptions.push_back(ProfileColumn("Name", 200));
     72
    7273    if (m_Peer)
    73     {
    7474        m_ColumnDescriptions.push_back(ProfileColumn("Value", 80));
    75     }
    7675    else
    7776    {
    7877        CScopeLock lock(m_Mutex);
     
    8079        for (size_t i = 0; i < m_LatchedData.size(); ++i)
    8180            m_ColumnDescriptions.push_back(ProfileColumn("Peer "+CStr::FromUInt(i), 80));
    8281    }
     82
    8383    return m_ColumnDescriptions;
    8484}
    8585
  • source/network/NetStats.h

     
    1 /* Copyright (C) 2010 Wildfire Games.
     1/* Copyright (C) 2016 Wildfire Games.
    22 * This file is part of 0 A.D.
    33 *
    44 * 0 A.D. is free software: you can redistribute it and/or modify
     
    5454    std::vector<ProfileColumn> m_ColumnDescriptions;
    5555
    5656    CMutex m_Mutex;
    57     std::vector<std::vector<CStr> > m_LatchedData; // protected by m_Mutex
     57    std::vector<std::vector<CStr>> m_LatchedData; // protected by m_Mutex
    5858};
    5959
    6060#endif // INCLUDED_NETSTATS
  • source/network/NetTurnManager.cpp

     
    170170
    171171        // Put all the client commands into a single list, in a globally consistent order
    172172        std::vector<SimulationCommand> commands;
    173         for (std::map<u32, std::vector<SimulationCommand> >::iterator it = m_QueuedCommands[0].begin(); it != m_QueuedCommands[0].end(); ++it)
    174         {
    175             commands.insert(commands.end(), std::make_move_iterator(it->second.begin()), std::make_move_iterator(it->second.end()));
    176         }
     173        for (std::pair<const u32, std::vector<SimulationCommand>>& p : m_QueuedCommands[0])
     174            commands.insert(commands.end(), std::make_move_iterator(p.second.begin()), std::make_move_iterator(p.second.end()));
     175
    177176        m_QueuedCommands.pop_front();
    178177        m_QueuedCommands.resize(m_QueuedCommands.size() + 1);
    179178
     
    214213
    215214        // Put all the client commands into a single list, in a globally consistent order
    216215        std::vector<SimulationCommand> commands;
    217         for (std::map<u32, std::vector<SimulationCommand> >::iterator it = m_QueuedCommands[0].begin(); it != m_QueuedCommands[0].end(); ++it)
    218         {
    219             commands.insert(commands.end(), std::make_move_iterator(it->second.begin()), std::make_move_iterator(it->second.end()));
    220         }
     216        for (std::pair<const u32, std::vector<SimulationCommand>>& p : m_QueuedCommands[0])
     217            commands.insert(commands.end(), std::make_move_iterator(p.second.begin()), std::make_move_iterator(p.second.end()));
     218
    221219        m_QueuedCommands.pop_front();
    222220        m_QueuedCommands.resize(m_QueuedCommands.size() + 1);
    223221
     
    564562    m_TurnLength = m_ReplayTurnLengths[turn];
    565563
    566564    // Simulate commands for that turn
    567     for (const std::pair<player_id_t, std::string>& pair : m_ReplayCommands[turn])
     565    for (const std::pair<player_id_t, std::string>& p : m_ReplayCommands[turn])
    568566    {
    569567        JS::RootedValue command(m_Simulation2.GetScriptInterface().GetContext());
    570         m_Simulation2.GetScriptInterface().ParseJSON(pair.second, &command);
    571         AddCommand(m_ClientId, pair.first, command, m_CurrentTurn + 1);
     568        m_Simulation2.GetScriptInterface().ParseJSON(p.second, &command);
     569        AddCommand(m_ClientId, p.first, command, m_CurrentTurn + 1);
    572570    }
    573571
    574572    if (turn == m_FinalTurn)
     
    602600void CNetServerTurnManager::CheckClientsReady()
    603601{
    604602    // See if all clients (including self) are ready for a new turn
    605     for (std::map<int, u32>::iterator it = m_ClientsReady.begin(); it != m_ClientsReady.end(); ++it)
     603    for (const std::pair<int, u32>& clientReady : m_ClientsReady)
    606604    {
    607         NETTURN_LOG((L"  %d: %d <=? %d\n", it->first, it->second, m_ReadyTurn));
    608         if (it->second <= m_ReadyTurn)
     605        NETTURN_LOG((L"  %d: %d <=? %d\n", clientReady.first, clientReady.second, m_ReadyTurn));
     606        if (clientReady.second <= m_ReadyTurn)
    609607            return; // wasn't ready for m_ReadyTurn+1
    610608    }
    611609
     
    640638
    641639    // Find the newest turn which we know all clients have simulated
    642640    u32 newest = std::numeric_limits<u32>::max();
    643     for (std::map<int, u32>::iterator it = m_ClientsSimulated.begin(); it != m_ClientsSimulated.end(); ++it)
    644     {
    645         if (it->second < newest)
    646             newest = it->second;
    647     }
     641    for (const std::pair<int, u32>& clientSimulated : m_ClientsSimulated)
     642        if (clientSimulated.second < newest)
     643            newest = clientSimulated.second;
    648644
    649645    // For every set of state hashes that all clients have simulated, check for OOS
    650     for (std::map<u32, std::map<int, std::string> >::iterator it = m_ClientStateHashes.begin(); it != m_ClientStateHashes.end(); ++it)
     646    for (const std::pair<u32, std::map<int, std::string>>& clientStateHash : m_ClientStateHashes)
    651647    {
    652         if (it->first > newest)
     648        if (clientStateHash.first > newest)
    653649            break;
    654650
    655651        // Assume the host is correct (maybe we should choose the most common instead to help debugging)
    656         std::string expected = it->second.begin()->second;
     652        std::string expected = clientStateHash.second.begin()->second;
    657653
    658654        // Find all players that are OOS on that turn
    659655        std::vector<CStrW> OOSPlayerNames;
    660         for (std::map<int, std::string>::iterator cit = it->second.begin(); cit != it->second.end(); ++cit)
     656        for (const std::pair<int, std::string>& hashPair : clientStateHash.second)
    661657        {
    662658            NETTURN_LOG((L"sync check %d: %d = %hs\n", it->first, cit->first, Hexify(cit->second).c_str()));
    663             if (cit->second != expected)
     659            if (hashPair.second != expected)
    664660            {
    665661                // Oh no, out of sync
    666662                m_HasSyncError = true;
    667                 OOSPlayerNames.push_back(m_ClientPlayernames[cit->first]);
     663                OOSPlayerNames.push_back(m_ClientPlayernames[hashPair.first]);
    668664            }
    669665        }
    670666
     
    672668        if (m_HasSyncError)
    673669        {
    674670            CSyncErrorMessage msg;
    675             msg.m_Turn = it->first;
     671            msg.m_Turn = clientStateHash.first;
    676672            msg.m_HashExpected = expected;
    677673            for (const CStrW& playername : OOSPlayerNames)
    678674            {
  • source/network/NetTurnManager.h

     
    180180    u32 m_TurnLength;
    181181
    182182    /// Commands queued at each turn (index 0 is for m_CurrentTurn+1)
    183     std::deque<std::map<u32, std::vector<SimulationCommand> > > m_QueuedCommands;
     183    std::deque<std::map<u32, std::vector<SimulationCommand>>> m_QueuedCommands;
    184184
    185185    int m_PlayerId;
    186186    uint m_ClientId;
     
    272272    void DoTurn(u32 turn);
    273273
    274274    // Contains the commands of every player on each turn
    275     std::map<u32, std::vector<std::pair<player_id_t, std::string> > > m_ReplayCommands;
     275    std::map<u32, std::vector<std::pair<player_id_t, std::string>>> m_ReplayCommands;
    276276
    277277    // Contains the length of every turn
    278278    std::map<u32, u32> m_ReplayTurnLengths;
    279279
    280280    // Contains all replay hash values and weather or not the quick hash method was used
    281     std::map<u32, std::pair<std::string, bool> > m_ReplayHash;
     281    std::map<u32, std::pair<std::string, bool>> m_ReplayHash;
    282282};
    283283/**
    284284 * The server-side counterpart to CNetClientTurnManager.
     
    337337    std::map<int, u32> m_ClientsSimulated;
    338338
    339339    // Map of turn -> {Client ID -> state hash}; old indexes <= min(m_ClientsSimulated) are deleted
    340     std::map<u32, std::map<int, std::string> > m_ClientStateHashes;
     340    std::map<u32, std::map<int, std::string>> m_ClientStateHashes;
    341341
    342342    // Map of client ID -> playername
    343343    std::map<u32, CStrW> m_ClientPlayernames;