Ticket #3494: t3494_oos_error_after_each_failed rejoin_v1.patch

File t3494_oos_error_after_each_failed rejoin_v1.patch, 4.6 KB (added by elexis, 9 years ago)
  • source/network/NetServer.cpp

    bool CNetServerWorker::OnRejoined(void*  
    10181018    CRejoinedMessage* message = (CRejoinedMessage*)event->GetParamRef();
    10191019
    10201020    message->m_GUID = session->GetGUID();
    10211021
    10221022    server.Broadcast(message);
     1023    server.m_ServerTurnManager->ResetOOSCheck();
    10231024
    10241025    return true;
    10251026}
    10261027
    10271028bool CNetServerWorker::OnDisconnect(void* context, CFsmEvent* event)
  • source/network/NetTurnManager.cpp

    bool CNetTurnManager::UpdateFastForward(  
    221221
    222222void CNetTurnManager::OnSyncError(u32 turn, const CStr& expectedHash, std::vector<CSyncErrorMessage::S_m_PlayerNames>& playerNames)
    223223{
    224224    NETTURN_LOG((L"OnSyncError(%d, %hs)\n", turn, Hexify(expectedHash).c_str()));
    225225
    226     // Only complain the first time
    227     if (m_HasSyncError)
    228         return;
    229 
    230226    bool quick = !TurnNeedsFullHash(turn);
    231227    std::string hash;
    232228    ENSURE(m_Simulation2.ComputeStateHash(hash, quick));
    233229
    234230    OsPath path = psLogDir()/"oos_dump.txt";
    void CNetTurnManager::OnSyncError(u32 tu  
    237233    file.close();
    238234
    239235    hash = Hexify(hash);
    240236    const std::string& expectedHashHex = Hexify(expectedHash);
    241237
    242     DisplayOOSError(turn, hash, expectedHashHex, false, &playerNames, &path);
     238    DisplayOOSError(turn, hash, expectedHashHex, false, &playerNames);
    243239}
    244240
    245 void CNetTurnManager::DisplayOOSError(u32 turn, const CStr& hash, const CStr& expectedHash, bool isReplay, std::vector<CSyncErrorMessage::S_m_PlayerNames>* playerNames = NULL, OsPath* path = NULL)
     241void CNetTurnManager::DisplayOOSError(u32 turn, const CStr& hash, const CStr& expectedHash, bool isReplay, std::vector<CSyncErrorMessage::S_m_PlayerNames>* playerNames = NULL)
    246242{
    247243    m_HasSyncError = true;
    248244
    249245    std::stringstream msg;
    250246    msg << "Out of sync on turn " << turn;
    void CNetTurnManager::DisplayOOSError(u3  
    252248    if (playerNames)
    253249        for (size_t i = 0; i < playerNames->size(); ++i)
    254250            msg << (i == 0 ? "\nPlayers: " : ", ") << utf8_from_wstring((*playerNames)[i].m_Name);
    255251
    256252    if (isReplay)
     253    {
    257254        msg << "\n\n" << "The current game state is different from the original game state.";
     255        msg << "\n\n" << "Did you try to load an incompatible replay?";
     256    }
    258257    else
     258    {
    259259        msg << "\n\n" << "Your game state is " << (expectedHash == hash ? "identical to" : "different from") << " the hosts game state.";
    260 
    261     if (path)
    262         msg << "\n\n" << "Dumping current state to " << utf8_from_wstring(OsPath(*path).string());
     260        msg << "\n\n" << "Please report this error and provide the commands.txt file of the host.";
     261    }
    263262
    264263    LOGERROR("%s", msg.str());
    265264
    266265    if (g_GUI)
    267266        g_GUI->DisplayMessageBox(600, 350, L"Sync error", wstring_from_utf8(msg.str()));
    void CNetClientTurnManager::NotifyFinish  
    424423
    425424    NETTURN_LOG((L"NotifyFinishedUpdate(%d, %hs)\n", turn, Hexify(hash).c_str()));
    426425
    427426    m_Replay.Hash(hash, quick);
    428427
    429     // Don't send the hash if OOS
    430     if (m_HasSyncError)
    431         return;
    432 
    433428    // Send message to the server
    434429    CSyncCheckMessage msg;
    435430    msg.m_Turn = turn;
    436431    msg.m_Hash = hash;
    437432    m_NetClient.SendMessage(&msg);
  • source/network/NetTurnManager.h

    public:  
    111111    virtual void OnSyncError(u32 turn, const CStr& expectedHash, std::vector<CSyncErrorMessage::S_m_PlayerNames>& playerNames);
    112112
    113113    /**
    114114     * Shows a message box when an out of sync error has been detected in the session or visual replay.
    115115     */
    116     virtual void DisplayOOSError(u32 turn, const CStr& hash, const CStr& expectedHash, bool isReplay, std::vector<CSyncErrorMessage::S_m_PlayerNames>* playerNames, OsPath* path);
     116    virtual void DisplayOOSError(u32 turn, const CStr& hash, const CStr& expectedHash, bool isReplay, std::vector<CSyncErrorMessage::S_m_PlayerNames>* playerNames);
    117117
    118118    /**
    119119     * Called by simulation code, to add a new command to be distributed to all clients and executed soon.
    120120     */
    121121    virtual void PostCommand(JS::HandleValue data) = 0;
    public:  
    319319     * Returns the turn length that was used for the given turn.
    320320     * Requires turn <= GetReadyTurn().
    321321     */
    322322    u32 GetSavedTurnLength(u32 turn);
    323323
     324    /**
     325     * Start doing OOS checks again.
     326     */
     327    void ResetOOSCheck() { m_HasSyncError = false; }
     328
    324329protected:
    325330    void CheckClientsReady();
    326331
    327332    /// The latest turn for which we have received all commands from all clients
    328333    u32 m_ReadyTurn;