diff --git a/source/network/NetClient.cpp b/source/network/NetClient.cpp index 02b0630a4a..aaa9686b1f 100644 --- a/source/network/NetClient.cpp +++ b/source/network/NetClient.cpp @@ -355,9 +355,11 @@ bool CNetClient::OnAuthenticate( void* pContext, CFsmEvent* pEvent ) CAuthenticateResultMessage* pMessage =( CAuthenticateResultMessage* )pEvent->GetParamRef(); if ( !pMessage ) return true; - LOG(CLogger::Error, LOG_CAT_NET, "CNetClient::OnAuthenticate(): Authentication result: %s", pMessage->m_Message.c_str() ); + LOG(CLogger::Error, LOG_CAT_NET, "CNetClient::OnAuthenticate(): Authentication result: %ls", pMessage->m_Message.c_str() ); pSession->SetID( pMessage->m_SessionID ); + + LOG(CLogger::Error, LOG_CAT_NET, "CNetClient::OnAuthenticate(): My session ID is %d", pMessage->m_SessionID); } return true; @@ -415,8 +417,9 @@ bool CNetClient::OnPreGame( void* pContext, CFsmEvent* pEvent ) // FIXME Validate slot id to prevent us from going boom CPlayerSlot* pSlot = pClient->m_pGameAttributes->GetSlot( pMessage->m_SlotID ); - if ( pSlot == pClient->m_pLocalPlayerSlot ) + if ( pSlot == pClient->m_pLocalPlayerSlot ) { pClient->m_pLocalPlayerSlot = NULL; + } switch ( pMessage->m_Assignment ) { @@ -426,8 +429,8 @@ bool CNetClient::OnPreGame( void* pContext, CFsmEvent* pEvent ) if ( pSession->GetID() == pMessage->m_SessionID ) { pClient->m_pLocalPlayerSlot = pSlot; - pSlot->AssignToSessionID( pMessage->m_SessionID ); } + pSlot->AssignToSessionID( pMessage->m_SessionID ); } break; diff --git a/source/network/NetServer.cpp b/source/network/NetServer.cpp index cdae8c5b0f..d23bdae291 100644 --- a/source/network/NetServer.cpp +++ b/source/network/NetServer.cpp @@ -834,8 +834,11 @@ void CNetServer::PlayerConfigMessageCallback( //----------------------------------------------------------------------------- uint CNetServer::GetFreeSessionID( void ) const { - uint sessionID = CLIENT_MIN_SESSIONID; + // No need to be conservative with session IDs; just use a global counter. + static uint lastSessionID = CLIENT_MIN_SESSIONID; + return lastSessionID++; + /* // Loop through the list of sessions and return the first // ID for which the associated session is NULL. If no such // free slot is found, return a new session ID which is higher @@ -850,6 +853,7 @@ uint CNetServer::GetFreeSessionID( void ) const } return sessionID; + */ } //----------------------------------------------------------------------------- diff --git a/source/ps/Game.cpp b/source/ps/Game.cpp index 6d03d7be23..5670784bbe 100644 --- a/source/ps/Game.cpp +++ b/source/ps/Game.cpp @@ -183,7 +183,9 @@ PSRETURN CGame::StartGame(CGameAttributes *pAttribs) debug_assert(m_pLocalPlayer && "Darn it! We weren't assigned to a slot!"); } else + { m_pLocalPlayer=m_Players[1]; + } RegisterInit(pAttribs); } diff --git a/source/ps/GameAttributes.cpp b/source/ps/GameAttributes.cpp index 57eb869363..a8e8616209 100644 --- a/source/ps/GameAttributes.cpp +++ b/source/ps/GameAttributes.cpp @@ -352,6 +352,14 @@ CPlayerSlot *CGameAttributes::GetSlot(size_t index) void CGameAttributes::FinalizeSlots() { + // This method was causing players to be mis-assigned, partly because the + // slot status changes did not seem to get broadcasted correctly. However, + // fundamentally, we really don't want to reassign players' IDs this way. + // We want to keep around dummy players for those that aren't human. So + // let's not mess with the array indices, etc unless it is really needed. + return; + + /* // Back up our old slots, and empty the resulting std::vector std::vector oldSlots; oldSlots.swap(m_PlayerSlots); @@ -382,6 +390,7 @@ void CGameAttributes::FinalizeSlots() } m_NumSlots=assignedSlots; + */ } void CGameAttributes::SetValue(const CStrW& name, const CStrW& value)