Ticket #3643: defuse_v2.2.patch
File defuse_v2.2.patch, 4.5 KB (added by , 8 years ago) |
---|
-
source/network/NetServer.cpp
bool CNetServerWorker::OnInGame(void* co 1064 1064 // TODO: we shouldn't send the message back to the client that first sent it 1065 1065 } 1066 1066 else if (message->GetType() == (uint)NMT_SYNC_CHECK) 1067 1067 { 1068 1068 CSyncCheckMessage* syncMessage = static_cast<CSyncCheckMessage*> (message); 1069 server.m_ServerTurnManager->NotifyFinishedClientUpdate(session ->GetHostID(), session->GetUserName(), syncMessage->m_Turn, syncMessage->m_Hash);1069 server.m_ServerTurnManager->NotifyFinishedClientUpdate(session, syncMessage->m_Turn, syncMessage->m_Hash); 1070 1070 } 1071 1071 else if (message->GetType() == (uint)NMT_END_COMMAND_BATCH) 1072 1072 { 1073 1073 CEndCommandBatchMessage* endMessage = static_cast<CEndCommandBatchMessage*> (message); 1074 server.m_ServerTurnManager->NotifyFinishedClientCommands(session ->GetHostID(), endMessage->m_Turn);1074 server.m_ServerTurnManager->NotifyFinishedClientCommands(session, endMessage->m_Turn); 1075 1075 } 1076 1076 1077 1077 return true; 1078 1078 } 1079 1079 -
source/network/NetTurnManager.cpp
CNetServerTurnManager::CNetServerTurnMan 582 582 // so store dummy values into the saved lengths list 583 583 m_SavedTurnLengths.push_back(0); 584 584 m_SavedTurnLengths.push_back(0); 585 585 } 586 586 587 void CNetServerTurnManager::NotifyFinishedClientCommands( int client, u32 turn)587 void CNetServerTurnManager::NotifyFinishedClientCommands(CNetServerSession* session, u32 turn) 588 588 { 589 int client = session->GetHostID(); 590 589 591 NETTURN_LOG((L"NotifyFinishedClientCommands(client=%d, turn=%d)\n", client, turn)); 590 592 591 593 // Must be a client we've already heard of 592 594 ENSURE(m_ClientsReady.find(client) != m_ClientsReady.end()); 593 595 594 596 // Clients must advance one turn at a time 595 ENSURE(turn == m_ClientsReady[client] + 1); 597 if (turn != m_ClientsReady[client] + 1) 598 { 599 LOGERROR("NotifyFinishedClientCommands: Client %d (%s) is ready for turn %d, but expected %d", 600 client, 601 utf8_from_wstring(session->GetUserName()).c_str(), 602 turn, 603 m_ClientsReady[client] + 1 604 ); 605 606 session->Disconnect(NDR_UNKNOWN); 607 } 608 596 609 m_ClientsReady[client] = turn; 597 610 598 611 // Check whether this was the final client to become ready 599 612 CheckClientsReady(); 600 613 } … … void CNetServerTurnManager::CheckClients 623 636 // Save the turn length in case it's needed later 624 637 ENSURE(m_SavedTurnLengths.size() == m_ReadyTurn); 625 638 m_SavedTurnLengths.push_back(m_TurnLength); 626 639 } 627 640 628 void CNetServerTurnManager::NotifyFinishedClientUpdate( int client, const CStrW& playername, u32 turn, const CStr& hash)641 void CNetServerTurnManager::NotifyFinishedClientUpdate(CNetServerSession* session, u32 turn, const CStr& hash) 629 642 { 643 644 int client = session->GetHostID(); 645 const CStrW& playername = session->GetUserName(); 646 630 647 // Clients must advance one turn at a time 631 ENSURE(turn == m_ClientsSimulated[client] + 1); 648 if (turn != m_ClientsSimulated[client] + 1) 649 { 650 LOGERROR("NotifyFinishedClientUpdate: Client %d (%s) is ready for turn %d, but expected %d", 651 client, 652 utf8_from_wstring(playername).c_str(), 653 turn, 654 m_ClientsReady[client] + 1 655 ); 656 657 session->Disconnect(NDR_UNKNOWN); 658 } 659 632 660 m_ClientsSimulated[client] = turn; 633 661 634 662 // Check for OOS only if in sync 635 663 if (m_HasSyncError) 636 664 return; -
source/network/NetTurnManager.h
19 19 #define INCLUDED_NETTURNMANAGER 20 20 21 21 #include "simulation2/helpers/SimulationCommand.h" 22 22 #include "lib/os_path.h" 23 23 #include "NetMessage.h" 24 #include "NetSession.h" 24 25 25 26 #include <list> 26 27 #include <map> 27 28 #include <vector> 28 29 … … class CNetServerTurnManager 292 293 { 293 294 NONCOPYABLE(CNetServerTurnManager); 294 295 public: 295 296 CNetServerTurnManager(CNetServerWorker& server); 296 297 297 void NotifyFinishedClientCommands( int client, u32 turn);298 void NotifyFinishedClientCommands(CNetServerSession* session, u32 turn); 298 299 299 void NotifyFinishedClientUpdate( int client, const CStrW& playername, u32 turn, const CStr& hash);300 void NotifyFinishedClientUpdate(CNetServerSession* session, u32 turn, const CStr& hash); 300 301 301 302 /** 302 303 * Inform the turn manager of a new client who will be sending commands. 303 304 */ 304 305 void InitialiseClient(int client, u32 turn);