Fixed 3+ player games. The problem was the FinalizeSlots method in GameAttributes, which confused player and slot IDs by deleting nonexistent slots/players from the array. Since this doesn't seem particularly useful (and is even undesirable for scenarios where some players *want* to be the last slot and to leave others empty), I commented it out rather than having the code incur the extra complexity of supporting renumberings.
This was SVN commit r6228.
This commit is contained in:
parent
8161197f0e
commit
0cbb38bfd9
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
*/
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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<CPlayerSlot *> oldSlots;
|
||||
oldSlots.swap(m_PlayerSlots);
|
||||
@ -382,6 +390,7 @@ void CGameAttributes::FinalizeSlots()
|
||||
}
|
||||
|
||||
m_NumSlots=assignedSlots;
|
||||
*/
|
||||
}
|
||||
|
||||
void CGameAttributes::SetValue(const CStrW& name, const CStrW& value)
|
||||
|
Loading…
Reference in New Issue
Block a user