Ticket #3305: t3305_clear_player_assignments_when_starting_the_game_v2.patch

File t3305_clear_player_assignments_when_starting_the_game_v2.patch, 733 bytes (added by elexis, 9 years ago)

Same as attachment:t3242_clear_player_assignments_when_starting_the_game.patch:ticket:3242 but cleaned. The iterator is not invalidated since erase returns the next element of the map.

  • source/network/NetServer.cpp

     
    10421042
    10431043    m_State = SERVER_STATE_LOADING;
    10441044
    10451045    // Send the final setup state to all clients
    10461046    UpdateGameAttributes(&m_GameAttributes.get());
     1047
     1048    // Remove players and observers from the assignment that are not present when the game starts
     1049    for(auto it = m_PlayerAssignments.begin(), ite = m_PlayerAssignments.end(); it != ite;)
     1050    {
     1051        if (it->second.m_Enabled)
     1052            ++it;
     1053        else
     1054            it = m_PlayerAssignments.erase(it);
     1055    }
     1056
    10471057    SendPlayerAssignments();
    10481058
    10491059    CGameStartMessage gameStart;
    10501060    Broadcast(&gameStart);
    10511061}