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 , 9 years ago) |
---|
-
source/network/NetServer.cpp
bool CNetServerWorker::OnRejoined(void* 1018 1018 CRejoinedMessage* message = (CRejoinedMessage*)event->GetParamRef(); 1019 1019 1020 1020 message->m_GUID = session->GetGUID(); 1021 1021 1022 1022 server.Broadcast(message); 1023 server.m_ServerTurnManager->ResetOOSCheck(); 1023 1024 1024 1025 return true; 1025 1026 } 1026 1027 1027 1028 bool CNetServerWorker::OnDisconnect(void* context, CFsmEvent* event) -
source/network/NetTurnManager.cpp
bool CNetTurnManager::UpdateFastForward( 221 221 222 222 void CNetTurnManager::OnSyncError(u32 turn, const CStr& expectedHash, std::vector<CSyncErrorMessage::S_m_PlayerNames>& playerNames) 223 223 { 224 224 NETTURN_LOG((L"OnSyncError(%d, %hs)\n", turn, Hexify(expectedHash).c_str())); 225 225 226 // Only complain the first time227 if (m_HasSyncError)228 return;229 230 226 bool quick = !TurnNeedsFullHash(turn); 231 227 std::string hash; 232 228 ENSURE(m_Simulation2.ComputeStateHash(hash, quick)); 233 229 234 230 OsPath path = psLogDir()/"oos_dump.txt"; … … void CNetTurnManager::OnSyncError(u32 tu 237 233 file.close(); 238 234 239 235 hash = Hexify(hash); 240 236 const std::string& expectedHashHex = Hexify(expectedHash); 241 237 242 DisplayOOSError(turn, hash, expectedHashHex, false, &playerNames , &path);238 DisplayOOSError(turn, hash, expectedHashHex, false, &playerNames); 243 239 } 244 240 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)241 void CNetTurnManager::DisplayOOSError(u32 turn, const CStr& hash, const CStr& expectedHash, bool isReplay, std::vector<CSyncErrorMessage::S_m_PlayerNames>* playerNames = NULL) 246 242 { 247 243 m_HasSyncError = true; 248 244 249 245 std::stringstream msg; 250 246 msg << "Out of sync on turn " << turn; … … void CNetTurnManager::DisplayOOSError(u3 252 248 if (playerNames) 253 249 for (size_t i = 0; i < playerNames->size(); ++i) 254 250 msg << (i == 0 ? "\nPlayers: " : ", ") << utf8_from_wstring((*playerNames)[i].m_Name); 255 251 256 252 if (isReplay) 253 { 257 254 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 } 258 257 else 258 { 259 259 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 } 263 262 264 263 LOGERROR("%s", msg.str()); 265 264 266 265 if (g_GUI) 267 266 g_GUI->DisplayMessageBox(600, 350, L"Sync error", wstring_from_utf8(msg.str())); … … void CNetClientTurnManager::NotifyFinish 424 423 425 424 NETTURN_LOG((L"NotifyFinishedUpdate(%d, %hs)\n", turn, Hexify(hash).c_str())); 426 425 427 426 m_Replay.Hash(hash, quick); 428 427 429 // Don't send the hash if OOS430 if (m_HasSyncError)431 return;432 433 428 // Send message to the server 434 429 CSyncCheckMessage msg; 435 430 msg.m_Turn = turn; 436 431 msg.m_Hash = hash; 437 432 m_NetClient.SendMessage(&msg); -
source/network/NetTurnManager.h
public: 111 111 virtual void OnSyncError(u32 turn, const CStr& expectedHash, std::vector<CSyncErrorMessage::S_m_PlayerNames>& playerNames); 112 112 113 113 /** 114 114 * Shows a message box when an out of sync error has been detected in the session or visual replay. 115 115 */ 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); 117 117 118 118 /** 119 119 * Called by simulation code, to add a new command to be distributed to all clients and executed soon. 120 120 */ 121 121 virtual void PostCommand(JS::HandleValue data) = 0; … … public: 319 319 * Returns the turn length that was used for the given turn. 320 320 * Requires turn <= GetReadyTurn(). 321 321 */ 322 322 u32 GetSavedTurnLength(u32 turn); 323 323 324 /** 325 * Start doing OOS checks again. 326 */ 327 void ResetOOSCheck() { m_HasSyncError = false; } 328 324 329 protected: 325 330 void CheckClientsReady(); 326 331 327 332 /// The latest turn for which we have received all commands from all clients 328 333 u32 m_ReadyTurn;