diff --git a/ghost/bnet.cpp b/ghost/bnet.cpp index 3a231fdb..a7fb88ee 100644 --- a/ghost/bnet.cpp +++ b/ghost/bnet.cpp @@ -1544,7 +1544,7 @@ void CBNET :: BotCommand( string Message, string User, bool Whisper, bool ForceR if( UTIL_FileExists( File ) ) { QueueChatCommand( m_GHost->m_Language->LoadingReplay( File ), User, Whisper ); - CReplay *Replay = new CReplay( m_GHost->m_Map->m_MaxSlots ); + CReplay *Replay = new CReplay( m_GHost->m_MaxSlots ); Replay->Load( File, false ); Replay->ParseReplay( false ); m_GHost->m_EnforcePlayers = Replay->GetPlayers( ); @@ -2267,9 +2267,9 @@ void CBNET :: QueueGameRefresh( unsigned char state, string gameName, string hos boost::mutex::scoped_lock packetsLock( m_PacketsMutex ); if( m_GHost->m_Reconnect ) - m_OutPackets.push( m_Protocol->SEND_SID_STARTADVEX3( state, UTIL_CreateByteArray( MapGameType, false ), map->GetMapGameFlags( ), MapWidth, MapHeight, gameName, hostName, upTime, "Save\\Multiplayer\\" + saveGame->GetFileNameNoPath( ), saveGame->GetMagicNumber( ), map->GetMapSHA1( ), m_GHost->m_Map->m_MaxSlots, FixedHostCounter ) ); + m_OutPackets.push( m_Protocol->SEND_SID_STARTADVEX3( state, UTIL_CreateByteArray( MapGameType, false ), map->GetMapGameFlags( ), MapWidth, MapHeight, gameName, hostName, upTime, "Save\\Multiplayer\\" + saveGame->GetFileNameNoPath( ), saveGame->GetMagicNumber( ), map->GetMapSHA1( ), m_GHost->m_MaxSlots, FixedHostCounter ) ); else - m_OutPackets.push( m_Protocol->SEND_SID_STARTADVEX3( state, UTIL_CreateByteArray( MapGameType, false ), map->GetMapGameFlags( ), UTIL_CreateByteArray( (uint16_t)0, false ), UTIL_CreateByteArray( (uint16_t)0, false ), gameName, hostName, upTime, "Save\\Multiplayer\\" + saveGame->GetFileNameNoPath( ), saveGame->GetMagicNumber( ), map->GetMapSHA1( ), m_GHost->m_Map->m_MaxSlots, FixedHostCounter ) ); + m_OutPackets.push( m_Protocol->SEND_SID_STARTADVEX3( state, UTIL_CreateByteArray( MapGameType, false ), map->GetMapGameFlags( ), UTIL_CreateByteArray( (uint16_t)0, false ), UTIL_CreateByteArray( (uint16_t)0, false ), gameName, hostName, upTime, "Save\\Multiplayer\\" + saveGame->GetFileNameNoPath( ), saveGame->GetMagicNumber( ), map->GetMapSHA1( ), m_GHost->m_MaxSlots, FixedHostCounter ) ); packetsLock.unlock( ); } @@ -2295,9 +2295,9 @@ void CBNET :: QueueGameRefresh( unsigned char state, string gameName, string hos boost::mutex::scoped_lock packetsLock( m_PacketsMutex ); if( m_GHost->m_Reconnect ) - m_OutPackets.push( m_Protocol->SEND_SID_STARTADVEX3( state, UTIL_CreateByteArray( MapGameType, false ), map->GetMapGameFlags( ), MapWidth, MapHeight, gameName, hostName, upTime, map->GetMapPath( ), map->GetMapCRC( ), map->GetMapSHA1( ), m_GHost->m_Map->m_MaxSlots, FixedHostCounter ) ); + m_OutPackets.push( m_Protocol->SEND_SID_STARTADVEX3( state, UTIL_CreateByteArray( MapGameType, false ), map->GetMapGameFlags( ), MapWidth, MapHeight, gameName, hostName, upTime, map->GetMapPath( ), map->GetMapCRC( ), map->GetMapSHA1( ), m_GHost->m_MaxSlots, FixedHostCounter ) ); else - m_OutPackets.push( m_Protocol->SEND_SID_STARTADVEX3( state, UTIL_CreateByteArray( MapGameType, false ), map->GetMapGameFlags( ), map->GetMapWidth( ), map->GetMapHeight( ), gameName, hostName, upTime, map->GetMapPath( ), map->GetMapCRC( ), map->GetMapSHA1( ), m_GHost->m_Map->m_MaxSlots, FixedHostCounter ) ); + m_OutPackets.push( m_Protocol->SEND_SID_STARTADVEX3( state, UTIL_CreateByteArray( MapGameType, false ), map->GetMapGameFlags( ), map->GetMapWidth( ), map->GetMapHeight( ), gameName, hostName, upTime, map->GetMapPath( ), map->GetMapCRC( ), map->GetMapSHA1( ), m_GHost->m_MaxSlots, FixedHostCounter ) ); packetsLock.unlock( ); } diff --git a/ghost/game.cpp b/ghost/game.cpp index cc9c6219..6eacd0da 100644 --- a/ghost/game.cpp +++ b/ghost/game.cpp @@ -725,7 +725,7 @@ bool CGame :: EventPlayerBotCommand( CGamePlayer *player, string command, string { unsigned char SID = (unsigned char)( Slot - 1 ); - if( !( m_Map->GetMapOptions( ) & MAPOPT_FIXEDPLAYERSETTINGS ) && Colour < ((uint32_t) m_GHost->m_Map->m_MaxSlots) && SID < m_Slots.size( ) ) + if( !( m_Map->GetMapOptions( ) & MAPOPT_FIXEDPLAYERSETTINGS ) && Colour < ((uint32_t) m_GHost->m_MaxSlots) && SID < m_Slots.size( ) ) { if( m_Slots[SID].GetSlotStatus( ) == SLOTSTATUS_OCCUPIED && m_Slots[SID].GetComputer( ) == 1 ) ColourSlot( SID, Colour ); @@ -879,7 +879,7 @@ bool CGame :: EventPlayerBotCommand( CGamePlayer *player, string command, string { unsigned char SID = (unsigned char)( Slot - 1 ); - if( !( m_Map->GetMapOptions( ) & MAPOPT_FIXEDPLAYERSETTINGS ) && Team < ((uint32_t) m_GHost->m_Map->m_MaxSlots) && SID < m_Slots.size( ) ) + if( !( m_Map->GetMapOptions( ) & MAPOPT_FIXEDPLAYERSETTINGS ) && Team < ((uint32_t) m_GHost->m_MaxSlots) && SID < m_Slots.size( ) ) { if( m_Slots[SID].GetSlotStatus( ) == SLOTSTATUS_OCCUPIED && m_Slots[SID].GetComputer( ) == 1 ) { @@ -1466,7 +1466,7 @@ bool CGame :: EventPlayerBotCommand( CGamePlayer *player, string command, string BYTEARRAY MapHeight; MapHeight.push_back( 0 ); MapHeight.push_back( 0 ); - m_GHost->m_UDPSocket->SendTo( IP, Port, m_Protocol->SEND_W3GS_GAMEINFO( m_GHost->m_TFT, m_GHost->m_LANWar3Version, UTIL_CreateByteArray( MapGameType, false ), m_Map->GetMapGameFlags( ), MapWidth, MapHeight, m_GameName, "Varlock", GetTime( ) - m_CreationTime, "Save\\Multiplayer\\" + m_SaveGame->GetFileNameNoPath( ), m_SaveGame->GetMagicNumber( ), m_GHost->m_Map->m_MaxSlots, m_GHost->m_Map->m_MaxSlots, m_HostPort, FixedHostCounter, m_EntryKey ) ); + m_GHost->m_UDPSocket->SendTo( IP, Port, m_Protocol->SEND_W3GS_GAMEINFO( m_GHost->m_TFT, m_GHost->m_LANWar3Version, UTIL_CreateByteArray( MapGameType, false ), m_Map->GetMapGameFlags( ), MapWidth, MapHeight, m_GameName, "Varlock", GetTime( ) - m_CreationTime, "Save\\Multiplayer\\" + m_SaveGame->GetFileNameNoPath( ), m_SaveGame->GetMagicNumber( ), m_GHost->m_MaxSlots, m_GHost->m_MaxSlots, m_HostPort, FixedHostCounter, m_EntryKey ) ); } else { @@ -1474,7 +1474,7 @@ bool CGame :: EventPlayerBotCommand( CGamePlayer *player, string command, string // note: we do not use m_Map->GetMapGameType because none of the filters are set when broadcasting to LAN (also as you might expect) uint32_t MapGameType = MAPGAMETYPE_UNKNOWN0; - m_GHost->m_UDPSocket->SendTo( IP, Port, m_Protocol->SEND_W3GS_GAMEINFO( m_GHost->m_TFT, m_GHost->m_LANWar3Version, UTIL_CreateByteArray( MapGameType, false ), m_Map->GetMapGameFlags( ), m_Map->GetMapWidth( ), m_Map->GetMapHeight( ), m_GameName, "Varlock", GetTime( ) - m_CreationTime, m_Map->GetMapPath( ), m_Map->GetMapCRC( ), m_GHost->m_Map->m_MaxSlots, m_GHost->m_Map->m_MaxSlots, m_HostPort, FixedHostCounter, m_EntryKey ) ); + m_GHost->m_UDPSocket->SendTo( IP, Port, m_Protocol->SEND_W3GS_GAMEINFO( m_GHost->m_TFT, m_GHost->m_LANWar3Version, UTIL_CreateByteArray( MapGameType, false ), m_Map->GetMapGameFlags( ), m_Map->GetMapWidth( ), m_Map->GetMapHeight( ), m_GameName, "Varlock", GetTime( ) - m_CreationTime, m_Map->GetMapPath( ), m_Map->GetMapCRC( ), m_GHost->m_MaxSlots, m_GHost->m_MaxSlots, m_HostPort, FixedHostCounter, m_EntryKey ) ); } } } diff --git a/ghost/game_admin.cpp b/ghost/game_admin.cpp index dbacc47e..9bcb4624 100644 --- a/ghost/game_admin.cpp +++ b/ghost/game_admin.cpp @@ -832,7 +832,7 @@ bool CAdminGame :: EventPlayerBotCommand( CGamePlayer *player, string command, s if( UTIL_FileExists( File ) ) { SendChat( player, m_GHost->m_Language->LoadingReplay( File ) ); - CReplay *Replay = new CReplay( m_GHost->m_Map->m_MaxSlots ); + CReplay *Replay = new CReplay( m_GHost->m_MaxSlots ); Replay->Load( File, false ); Replay->ParseReplay( false ); m_GHost->m_EnforcePlayers = Replay->GetPlayers( ); diff --git a/ghost/game_base.cpp b/ghost/game_base.cpp index 9f815a33..b19f3ae4 100644 --- a/ghost/game_base.cpp +++ b/ghost/game_base.cpp @@ -50,7 +50,7 @@ CBaseGame :: CBaseGame( CGHost *nGHost, CMap *nMap, CSaveGame *nSaveGame, uint16 m_Map = new CMap( m_GHost ); if( m_GHost->m_SaveReplays && !m_SaveGame ) - m_Replay = new CReplay( m_GHost->m_Map->m_MaxSlots ); + m_Replay = new CReplay( m_GHost->m_MaxSlots ); // wait time of 1 minute = 0 empty actions required // wait time of 2 minutes = 1 empty action required @@ -434,7 +434,7 @@ bool CBaseGame :: Update( void *fd, void *send_fd ) // create the virtual host player - if( !m_GameLoading && !m_GameLoaded && GetNumPlayers( ) < ((uint32_t) m_GHost->m_Map->m_MaxSlots) ) + if( !m_GameLoading && !m_GameLoaded && GetNumPlayers( ) < ((uint32_t) m_GHost->m_MaxSlots) ) CreateVirtualHost( ); // unlock the game @@ -493,7 +493,7 @@ bool CBaseGame :: Update( void *fd, void *send_fd ) BYTEARRAY MapHeight; MapHeight.push_back( 0 ); MapHeight.push_back( 0 ); - m_GHost->m_UDPSocket->Broadcast( 6112, m_Protocol->SEND_W3GS_GAMEINFO( m_GHost->m_TFT, m_GHost->m_LANWar3Version, UTIL_CreateByteArray( MapGameType, false ), m_Map->GetMapGameFlags( ), MapWidth, MapHeight, m_GameName, "Varlock", GetTime( ) - m_CreationTime, "Save\\Multiplayer\\" + m_SaveGame->GetFileNameNoPath( ), m_SaveGame->GetMagicNumber( ), m_GHost->m_Map->m_MaxSlots, m_GHost->m_Map->m_MaxSlots, m_HostPort, FixedHostCounter, m_EntryKey ) ); + m_GHost->m_UDPSocket->Broadcast( 6112, m_Protocol->SEND_W3GS_GAMEINFO( m_GHost->m_TFT, m_GHost->m_LANWar3Version, UTIL_CreateByteArray( MapGameType, false ), m_Map->GetMapGameFlags( ), MapWidth, MapHeight, m_GameName, "Varlock", GetTime( ) - m_CreationTime, "Save\\Multiplayer\\" + m_SaveGame->GetFileNameNoPath( ), m_SaveGame->GetMagicNumber( ), m_GHost->m_MaxSlots, m_GHost->m_MaxSlots, m_HostPort, FixedHostCounter, m_EntryKey ) ); } else { @@ -501,7 +501,7 @@ bool CBaseGame :: Update( void *fd, void *send_fd ) // note: we do not use m_Map->GetMapGameType because none of the filters are set when broadcasting to LAN (also as you might expect) uint32_t MapGameType = MAPGAMETYPE_UNKNOWN0; - m_GHost->m_UDPSocket->Broadcast( 6112, m_Protocol->SEND_W3GS_GAMEINFO( m_GHost->m_TFT, m_GHost->m_LANWar3Version, UTIL_CreateByteArray( MapGameType, false ), m_Map->GetMapGameFlags( ), m_Map->GetMapWidth( ), m_Map->GetMapHeight( ), m_GameName, "Varlock", GetTime( ) - m_CreationTime, m_Map->GetMapPath( ), m_Map->GetMapCRC( ), m_GHost->m_Map->m_MaxSlots, m_GHost->m_Map->m_MaxSlots, m_HostPort, FixedHostCounter, m_EntryKey ) ); + m_GHost->m_UDPSocket->Broadcast( 6112, m_Protocol->SEND_W3GS_GAMEINFO( m_GHost->m_TFT, m_GHost->m_LANWar3Version, UTIL_CreateByteArray( MapGameType, false ), m_Map->GetMapGameFlags( ), m_Map->GetMapWidth( ), m_Map->GetMapHeight( ), m_GameName, "Varlock", GetTime( ) - m_CreationTime, m_Map->GetMapPath( ), m_Map->GetMapCRC( ), m_GHost->m_MaxSlots, m_GHost->m_MaxSlots, m_HostPort, FixedHostCounter, m_EntryKey ) ); } } @@ -2049,7 +2049,7 @@ void CBaseGame :: EventPlayerJoined( CPotentialPlayer *potential, CIncomingJoinP // we have a slot for the new player // make room for them by deleting the virtual host player if we have to - if( GetNumPlayers( ) >= ((uint32_t) (m_GHost->m_Map->m_MaxSlots-1)) || EnforcePID == m_VirtualHostPID ) + if( GetNumPlayers( ) >= ((uint32_t) (m_GHost->m_MaxSlots-1)) || EnforcePID == m_VirtualHostPID ) DeleteVirtualHost( ); // turning the CPotentialPlayer into a CGamePlayer is a bit of a pain because we have to be careful not to close the socket @@ -2079,9 +2079,9 @@ void CBaseGame :: EventPlayerJoined( CPotentialPlayer *potential, CIncomingJoinP else { if( m_Map->GetMapFlags( ) & MAPFLAG_RANDOMRACES ) - m_Slots[SID] = CGameSlot( Player->GetPID( ), 255, SLOTSTATUS_OCCUPIED, 0, m_GHost->m_Map->m_MaxSlots, m_GHost->m_Map->m_MaxSlots, SLOTRACE_RANDOM ); + m_Slots[SID] = CGameSlot( Player->GetPID( ), 255, SLOTSTATUS_OCCUPIED, 0, m_GHost->m_MaxSlots, m_GHost->m_MaxSlots, SLOTRACE_RANDOM ); else - m_Slots[SID] = CGameSlot( Player->GetPID( ), 255, SLOTSTATUS_OCCUPIED, 0, m_GHost->m_Map->m_MaxSlots, m_GHost->m_Map->m_MaxSlots, SLOTRACE_RANDOM | SLOTRACE_SELECTABLE ); + m_Slots[SID] = CGameSlot( Player->GetPID( ), 255, SLOTSTATUS_OCCUPIED, 0, m_GHost->m_MaxSlots, m_GHost->m_MaxSlots, SLOTRACE_RANDOM | SLOTRACE_SELECTABLE ); // try to pick a team and colour // make sure there aren't too many other players already @@ -2090,7 +2090,7 @@ void CBaseGame :: EventPlayerJoined( CPotentialPlayer *potential, CIncomingJoinP for( unsigned char i = 0; i < m_Slots.size( ); ++i ) { - if( m_Slots[i].GetSlotStatus( ) == SLOTSTATUS_OCCUPIED && m_Slots[i].GetTeam( ) != m_GHost->m_Map->m_MaxSlots ) + if( m_Slots[i].GetSlotStatus( ) == SLOTSTATUS_OCCUPIED && m_Slots[i].GetTeam( ) != m_GHost->m_MaxSlots ) NumOtherPlayers++; } @@ -2439,7 +2439,7 @@ void CBaseGame :: EventPlayerJoinedWithScore( CPotentialPlayer *potential, CInco // we have a slot for the new player // make room for them by deleting the virtual host player if we have to - if( GetNumPlayers( ) >= ((uint32_t) (m_GHost->m_Map->m_MaxSlots-1)) ) + if( GetNumPlayers( ) >= ((uint32_t) (m_GHost->m_MaxSlots-1)) ) DeleteVirtualHost( ); // identify their joined realm @@ -3033,10 +3033,10 @@ void CBaseGame :: EventPlayerChangeTeam( CGamePlayer *player, unsigned char team } else { - if( team > m_GHost->m_Map->m_MaxSlots ) + if( team > m_GHost->m_MaxSlots ) return; - if( team == m_GHost->m_Map->m_MaxSlots ) + if( team == m_GHost->m_MaxSlots ) { if( m_Map->GetMapObservers( ) != MAPOBS_ALLOWED && m_Map->GetMapObservers( ) != MAPOBS_REFEREES ) return; @@ -3052,7 +3052,7 @@ void CBaseGame :: EventPlayerChangeTeam( CGamePlayer *player, unsigned char team for( unsigned char i = 0; i < m_Slots.size( ); ++i ) { - if( m_Slots[i].GetSlotStatus( ) == SLOTSTATUS_OCCUPIED && m_Slots[i].GetTeam( ) != m_GHost->m_Map->m_MaxSlots && m_Slots[i].GetPID( ) != player->GetPID( ) ) + if( m_Slots[i].GetSlotStatus( ) == SLOTSTATUS_OCCUPIED && m_Slots[i].GetTeam( ) != m_GHost->m_MaxSlots && m_Slots[i].GetPID( ) != player->GetPID( ) ) ++NumOtherPlayers; } @@ -3066,13 +3066,13 @@ void CBaseGame :: EventPlayerChangeTeam( CGamePlayer *player, unsigned char team { m_Slots[SID].SetTeam( team ); - if( team == m_GHost->m_Map->m_MaxSlots ) + if( team == m_GHost->m_MaxSlots ) { // if they're joining the observer team give them the observer colour - m_Slots[SID].SetColour( m_GHost->m_Map->m_MaxSlots ); + m_Slots[SID].SetColour( m_GHost->m_MaxSlots ); } - else if( m_Slots[SID].GetColour( ) == m_GHost->m_Map->m_MaxSlots ) + else if( m_Slots[SID].GetColour( ) == m_GHost->m_MaxSlots ) { // if they're joining a regular team give them an unused colour @@ -3094,7 +3094,7 @@ void CBaseGame :: EventPlayerChangeColour( CGamePlayer *player, unsigned char co if( m_Map->GetMapOptions( ) & MAPOPT_FIXEDPLAYERSETTINGS ) return; - if( colour > m_GHost->m_Map->m_MaxSlots-1 ) + if( colour > m_GHost->m_MaxSlots-1 ) return; unsigned char SID = GetSIDFromPID( player->GetPID( ) ); @@ -3103,7 +3103,7 @@ void CBaseGame :: EventPlayerChangeColour( CGamePlayer *player, unsigned char co { // make sure the player isn't an observer - if( m_Slots[SID].GetTeam( ) == m_GHost->m_Map->m_MaxSlots ) + if( m_Slots[SID].GetTeam( ) == m_GHost->m_MaxSlots ) return; ColourSlot( SID, colour ); @@ -3698,7 +3698,7 @@ unsigned char CBaseGame :: GetNewColour( ) { // find an unused colour for a player to use - for( unsigned char TestColour = 0; TestColour < m_GHost->m_Map->m_MaxSlots; ++TestColour ) + for( unsigned char TestColour = 0; TestColour < m_GHost->m_MaxSlots; ++TestColour ) { bool InUse = false; @@ -3717,7 +3717,7 @@ unsigned char CBaseGame :: GetNewColour( ) // this should never happen - return m_GHost->m_Map->m_MaxSlots; + return m_GHost->m_MaxSlots; } BYTEARRAY CBaseGame :: GetPIDs( ) @@ -4013,7 +4013,7 @@ void CBaseGame :: ComputerSlot( unsigned char SID, unsigned char skill, bool kic void CBaseGame :: ColourSlot( unsigned char SID, unsigned char colour ) { - if( SID < m_Slots.size( ) && colour < m_GHost->m_Map->m_MaxSlots ) + if( SID < m_Slots.size( ) && colour < m_GHost->m_MaxSlots ) { // make sure the requested colour isn't already taken @@ -4094,7 +4094,7 @@ void CBaseGame :: ShuffleSlots( ) for( vector :: iterator i = m_Slots.begin( ); i != m_Slots.end( ); ++i ) { - if( (*i).GetSlotStatus( ) == SLOTSTATUS_OCCUPIED && (*i).GetComputer( ) == 0 && (*i).GetTeam( ) != m_GHost->m_Map->m_MaxSlots ) + if( (*i).GetSlotStatus( ) == SLOTSTATUS_OCCUPIED && (*i).GetComputer( ) == 0 && (*i).GetTeam( ) != m_GHost->m_MaxSlots ) PlayerSlots.push_back( *i ); } @@ -4140,7 +4140,7 @@ void CBaseGame :: ShuffleSlots( ) for( vector :: iterator i = m_Slots.begin( ); i != m_Slots.end( ); ++i ) { - if( (*i).GetSlotStatus( ) == SLOTSTATUS_OCCUPIED && (*i).GetComputer( ) == 0 && (*i).GetTeam( ) != m_GHost->m_Map->m_MaxSlots ) + if( (*i).GetSlotStatus( ) == SLOTSTATUS_OCCUPIED && (*i).GetComputer( ) == 0 && (*i).GetTeam( ) != m_GHost->m_MaxSlots ) { Slots.push_back( *CurrentPlayer ); ++CurrentPlayer; @@ -4168,7 +4168,7 @@ vector CBaseGame :: BalanceSlotsRecursive( vector vector BestOrdering = PlayerIDs; double BestDifference = -1.0; - for( unsigned char i = StartTeam; i < m_GHost->m_Map->m_MaxSlots; ++i ) + for( unsigned char i = StartTeam; i < m_GHost->m_MaxSlots; ++i ) { if( TeamSizes[i] > 0 ) { @@ -4195,9 +4195,9 @@ vector CBaseGame :: BalanceSlotsRecursive( vector // now calculate the team scores for all the teams that we know about (e.g. on subsequent recursion steps this will NOT be every possible team) vector :: iterator CurrentPID = TestOrdering.begin( ); - double TeamScores[m_GHost->m_Map->m_MaxSlots]; + double TeamScores[m_GHost->m_MaxSlots]; - for( unsigned char j = StartTeam; j < m_GHost->m_Map->m_MaxSlots; ++j ) + for( unsigned char j = StartTeam; j < m_GHost->m_MaxSlots; ++j ) { TeamScores[j] = 0.0; @@ -4212,11 +4212,11 @@ vector CBaseGame :: BalanceSlotsRecursive( vector double LargestDifference = 0.0; - for( unsigned char j = StartTeam; j < m_GHost->m_Map->m_MaxSlots; ++j ) + for( unsigned char j = StartTeam; j < m_GHost->m_MaxSlots; ++j ) { if( TeamSizes[j] > 0 ) { - for( unsigned char k = j + 1; k < m_GHost->m_Map->m_MaxSlots; ++k ) + for( unsigned char k = j + 1; k < m_GHost->m_MaxSlots; ++k ) { if( TeamSizes[k] > 0 ) { @@ -4255,9 +4255,9 @@ void CBaseGame :: BalanceSlots( ) // use an array of 13 elements for MAX_SLOTS players because GHost++ allocates PID's from 1-MAX_SLOTS (i.e. excluding 0) and we use the PID to index the array vector PlayerIDs; - unsigned char TeamSizes[m_GHost->m_Map->m_MaxSlots]; + unsigned char TeamSizes[m_GHost->m_MaxSlots]; double PlayerScores[13]; - memset( TeamSizes, 0, sizeof( unsigned char ) * m_GHost->m_Map->m_MaxSlots ); + memset( TeamSizes, 0, sizeof( unsigned char ) * m_GHost->m_MaxSlots ); for( vector :: iterator i = m_Players.begin( ); i != m_Players.end( ); ++i ) { @@ -4271,7 +4271,7 @@ void CBaseGame :: BalanceSlots( ) { unsigned char Team = m_Slots[SID].GetTeam( ); - if( Team < m_GHost->m_Map->m_MaxSlots ) + if( Team < m_GHost->m_MaxSlots ) { // we are forced to use a default score because there's no way to balance the teams otherwise @@ -4306,7 +4306,7 @@ void CBaseGame :: BalanceSlots( ) uint32_t AlgorithmCost = 0; uint32_t PlayersLeft = PlayerIDs.size( ); - for( unsigned char i = 0; i < m_GHost->m_Map->m_MaxSlots; ++i ) + for( unsigned char i = 0; i < m_GHost->m_MaxSlots; ++i ) { if( TeamSizes[i] > 0 ) { @@ -4339,7 +4339,7 @@ void CBaseGame :: BalanceSlots( ) vector :: iterator CurrentPID = BestOrdering.begin( ); - for( unsigned char i = 0; i < m_GHost->m_Map->m_MaxSlots; ++i ) + for( unsigned char i = 0; i < m_GHost->m_MaxSlots; ++i ) { unsigned char CurrentSlot = 0; @@ -4377,7 +4377,7 @@ void CBaseGame :: BalanceSlots( ) SendAllChat( m_GHost->m_Language->BalancingSlotsCompleted( ) ); SendAllSlotInfo( ); - for( unsigned char i = 0; i < m_GHost->m_Map->m_MaxSlots; ++i ) + for( unsigned char i = 0; i < m_GHost->m_MaxSlots; ++i ) { bool TeamHasPlayers = false; double TeamScore = 0.0; @@ -4731,7 +4731,7 @@ void CBaseGame :: CreateFakePlayer( ) if( SID < m_Slots.size( ) ) { - if( GetNumPlayers( ) >= ((uint32_t) (m_GHost->m_Map->m_MaxSlots-1)) ) + if( GetNumPlayers( ) >= ((uint32_t) (m_GHost->m_MaxSlots-1)) ) DeleteVirtualHost( ); m_FakePlayerPID = GetNewPID( ); diff --git a/ghost/gameprotocol.cpp b/ghost/gameprotocol.cpp index b5cb8f03..e43ff120 100644 --- a/ghost/gameprotocol.cpp +++ b/ghost/gameprotocol.cpp @@ -172,7 +172,7 @@ CIncomingChatPlayer *CGameProtocol :: RECEIVE_W3GS_CHAT_TO_HOST( BYTEARRAY data unsigned int i = 5; unsigned char Total = data[4]; - if( Total > 0 && Total <= m_GHost->m_Map->m_MaxSlots && data.size( ) >= i + Total ) + if( Total > 0 && Total <= m_GHost->m_MaxSlots && data.size( ) >= i + Total ) { BYTEARRAY ToPIDs = BYTEARRAY( data.begin( ) + i, data.begin( ) + i + Total ); i += Total; diff --git a/ghost/ghost.cpp b/ghost/ghost.cpp index c3c070c8..9b77f7c2 100644 --- a/ghost/ghost.cpp +++ b/ghost/ghost.cpp @@ -464,6 +464,9 @@ CGHost :: CGHost( CConfig *CFG ) m_Version = "17.2"; m_HostCounter = 1; m_AutoHostMaximumGames = CFG->GetInt( "autohost_maxgames", 0 ); + m_MaxSlots = CFG->GetInt( "max_slots", 24 ); + if ( !m_MaxSlots ) + CONSOLE_Print( "[GHOST] WARNING: max_slots with missing value or value = 0? possible correct values are 12 or 24" ); m_AutoHostAutoStartPlayers = CFG->GetInt( "autohost_startplayers", 0 ); m_AutoHostGameName = CFG->GetString( "autohost_gamename", string( ) ); m_AutoHostOwner = CFG->GetString( "autohost_owner", string( ) ); @@ -607,10 +610,7 @@ CGHost :: CGHost( CConfig *CFG ) CConfig MapCFG; MapCFG.Read( m_MapCFGPath + m_DefaultMap ); - unsigned char MaxSlots = CFG->GetInt( "max_slots", 24 ); - if ( !MaxSlots ) - CONSOLE_Print( "[GHOST] WARNING: max_slots with missing value or value = 0? possible correct values are 12 or 24" ); - m_Map = new CMap( this, &MapCFG, m_MapCFGPath + m_DefaultMap, MaxSlots ); + m_Map = new CMap( this, &MapCFG, m_MapCFGPath + m_DefaultMap ); if( !m_AdminGameMap.empty( ) ) { @@ -623,19 +623,19 @@ CGHost :: CGHost( CConfig *CFG ) CONSOLE_Print( "[GHOST] trying to load default admin game map" ); CConfig AdminMapCFG; AdminMapCFG.Read( m_MapCFGPath + m_AdminGameMap ); - m_AdminMap = new CMap( this, &AdminMapCFG, m_MapCFGPath + m_AdminGameMap, MaxSlots ); + m_AdminMap = new CMap( this, &AdminMapCFG, m_MapCFGPath + m_AdminGameMap ); if( !m_AdminMap->GetValid( ) ) { CONSOLE_Print( "[GHOST] default admin game map isn't valid, using hardcoded admin game map instead" ); delete m_AdminMap; - m_AdminMap = new CMap( this, MaxSlots ); + m_AdminMap = new CMap( this ); } } else { CONSOLE_Print( "[GHOST] using hardcoded admin game map" ); - m_AdminMap = new CMap( this, MaxSlots ); + m_AdminMap = new CMap( this ); } m_AutoHostMap = new CMap( this, MaxSlots ); diff --git a/ghost/ghost.h b/ghost/ghost.h index 68203277..79e4ea77 100644 --- a/ghost/ghost.h +++ b/ghost/ghost.h @@ -86,6 +86,7 @@ class CGHost string m_AutoHostOwner; string m_AutoHostServer; uint32_t m_AutoHostMaximumGames; // maximum number of games to auto host + unsigned char m_MaxSlots; // maximum number of slots in game lobby uint32_t m_AutoHostAutoStartPlayers; // when using auto hosting auto start the game when this many players have joined uint32_t m_LastAutoHostTime; // GetTime when the last auto host was attempted bool m_AutoHostMatchMaking; diff --git a/ghost/map.cpp b/ghost/map.cpp index f4d7fb7a..5802c7fe 100644 --- a/ghost/map.cpp +++ b/ghost/map.cpp @@ -35,7 +35,7 @@ // CMap // -CMap :: CMap( CGHost *nGHost, unsigned char nMaxSlots ) : m_GHost( nGHost ), m_Valid( true ), m_MapPath( "Maps\\FrozenThrone\\(12)EmeraldGardens.w3x" ), m_MapSize( UTIL_ExtractNumbers( "174 221 4 0", 4 ) ), m_MapInfo( UTIL_ExtractNumbers( "251 57 68 98", 4 ) ), m_MapCRC( UTIL_ExtractNumbers( "108 250 204 59", 4 ) ), m_MapSHA1( UTIL_ExtractNumbers( "35 81 104 182 223 63 204 215 1 17 87 234 220 66 3 185 82 99 6 13", 20 ) ), m_MapSpeed( MAPSPEED_FAST ), m_MapVisibility( MAPVIS_DEFAULT ), m_MapObservers( MAPOBS_NONE ), m_MapFlags( MAPFLAG_TEAMSTOGETHER | MAPFLAG_FIXEDTEAMS ), m_MapFilterMaker( MAPFILTER_MAKER_BLIZZARD ), m_MapFilterType( MAPFILTER_TYPE_MELEE ), m_MapFilterSize( MAPFILTER_SIZE_LARGE ), m_MapFilterObs( MAPFILTER_OBS_NONE ), m_MapOptions( MAPOPT_MELEE ), m_MapWidth( UTIL_ExtractNumbers( "172 0", 2 ) ), m_MapHeight( UTIL_ExtractNumbers( "172 0", 2 ) ), m_MapLoadInGame( false ), m_MapNumPlayers( 12 ), m_MapNumTeams( 12 ), m_MaxSlots( nMaxSlots ) +CMap :: CMap( CGHost *nGHost ) : m_GHost( nGHost ), m_Valid( true ), m_MapPath( "Maps\\FrozenThrone\\(12)EmeraldGardens.w3x" ), m_MapSize( UTIL_ExtractNumbers( "174 221 4 0", 4 ) ), m_MapInfo( UTIL_ExtractNumbers( "251 57 68 98", 4 ) ), m_MapCRC( UTIL_ExtractNumbers( "108 250 204 59", 4 ) ), m_MapSHA1( UTIL_ExtractNumbers( "35 81 104 182 223 63 204 215 1 17 87 234 220 66 3 185 82 99 6 13", 20 ) ), m_MapSpeed( MAPSPEED_FAST ), m_MapVisibility( MAPVIS_DEFAULT ), m_MapObservers( MAPOBS_NONE ), m_MapFlags( MAPFLAG_TEAMSTOGETHER | MAPFLAG_FIXEDTEAMS ), m_MapFilterMaker( MAPFILTER_MAKER_BLIZZARD ), m_MapFilterType( MAPFILTER_TYPE_MELEE ), m_MapFilterSize( MAPFILTER_SIZE_LARGE ), m_MapFilterObs( MAPFILTER_OBS_NONE ), m_MapOptions( MAPOPT_MELEE ), m_MapWidth( UTIL_ExtractNumbers( "172 0", 2 ) ), m_MapHeight( UTIL_ExtractNumbers( "172 0", 2 ) ), m_MapLoadInGame( false ), m_MapNumPlayers( 12 ), m_MapNumTeams( 12 ) { CONSOLE_Print( "[MAP] using hardcoded Emerald Gardens map data for Warcraft 3 version 1.24 & 1.24b" ); m_Slots.push_back( CGameSlot( 0, 255, SLOTSTATUS_OPEN, 0, 0, 0, SLOTRACE_RANDOM | SLOTRACE_SELECTABLE ) ); @@ -52,7 +52,7 @@ CMap :: CMap( CGHost *nGHost, unsigned char nMaxSlots ) : m_GHost( nGHost ), m_V m_Slots.push_back( CGameSlot( 0, 255, SLOTSTATUS_OPEN, 0, 11, 11, SLOTRACE_RANDOM | SLOTRACE_SELECTABLE ) ); } -CMap :: CMap( CGHost *nGHost, CConfig *CFG, string nCFGFile, unsigned char nMaxSlots ) : m_GHost( nGHost ), m_MaxSlots( nMaxSlots ) +CMap :: CMap( CGHost *nGHost, CConfig *CFG, string nCFGFile ) : m_GHost( nGHost ) { Load( CFG, nCFGFile ); } @@ -611,7 +611,7 @@ void CMap :: Load( CConfig *CFG, string nCFGFile ) ISS.read( (char *)&Flags, 4 ); // flags ISS.read( (char *)&PlayerMask, 4 ); // player mask - for( unsigned char j = 0; j < m_MaxSlots; ++j ) + for( unsigned char j = 0; j < m_GHost->m_MaxSlots; ++j ) { if( PlayerMask & 1 ) { @@ -816,7 +816,7 @@ void CMap :: Load( CConfig *CFG, string nCFGFile ) if( Slots.empty( ) ) { - for( uint32_t Slot = 1; Slot <= ((uint32_t) m_MaxSlots); ++Slot ) + for( uint32_t Slot = 1; Slot <= ((uint32_t) m_GHost->m_MaxSlots); ++Slot ) { string SlotString = CFG->GetString( "map_slot" + UTIL_ToString( Slot ), string( ) ); @@ -832,7 +832,7 @@ void CMap :: Load( CConfig *CFG, string nCFGFile ) CONSOLE_Print( "[MAP] overriding slots" ); Slots.clear( ); - for( uint32_t Slot = 1; Slot <= ((uint32_t) m_MaxSlots); ++Slot ) + for( uint32_t Slot = 1; Slot <= ((uint32_t) m_GHost->m_MaxSlots); ++Slot ) { string SlotString = CFG->GetString( "map_slot" + UTIL_ToString( Slot ), string( ) ); @@ -860,14 +860,14 @@ void CMap :: Load( CConfig *CFG, string nCFGFile ) if( m_MapObservers == MAPOBS_ALLOWED || m_MapObservers == MAPOBS_REFEREES ) { - uint32_t DefaultMaxSlots = (uint32_t) m_MaxSlots; + uint32_t DefaultMaxSlots = (uint32_t) m_GHost->m_MaxSlots; if( EditorVersion < 6060 ) DefaultMaxSlots = 12; uint32_t MaxSlots = CFG->GetInt( "map_maxslots", DefaultMaxSlots ); CONSOLE_Print( "[MAP] adding " + UTIL_ToString( MaxSlots - m_Slots.size( ) ) + " observer slots" ); while( m_Slots.size( ) < MaxSlots ) - m_Slots.push_back( CGameSlot( 0, 255, SLOTSTATUS_OPEN, 0, m_MaxSlots, m_MaxSlots, SLOTRACE_RANDOM ) ); + m_Slots.push_back( CGameSlot( 0, 255, SLOTSTATUS_OPEN, 0, m_GHost->m_MaxSlots, m_GHost->m_MaxSlots, SLOTRACE_RANDOM ) ); } CheckValid( ); @@ -950,19 +950,19 @@ void CMap :: CheckValid( ) CONSOLE_Print( "[MAP] invalid map_height detected" ); } - if( m_MapNumPlayers == 0 || m_MapNumPlayers > ((uint32_t) m_MaxSlots) ) + if( m_MapNumPlayers == 0 || m_MapNumPlayers > ((uint32_t) m_GHost->m_MaxSlots) ) { m_Valid = false; CONSOLE_Print( "[MAP] invalid map_numplayers detected" ); } - if( m_MapNumTeams == 0 || m_MapNumTeams > ((uint32_t) m_MaxSlots) ) + if( m_MapNumTeams == 0 || m_MapNumTeams > ((uint32_t) m_GHost->m_MaxSlots) ) { m_Valid = false; CONSOLE_Print( "[MAP] invalid map_numteams detected" ); } - if( m_Slots.empty( ) || m_Slots.size( ) > ((size_t) m_MaxSlots) ) + if( m_Slots.empty( ) || m_Slots.size( ) > ((size_t) m_GHost->m_MaxSlots) ) { m_Valid = false; CONSOLE_Print( "[MAP] invalid map_slot detected" ); diff --git a/ghost/map.h b/ghost/map.h index 7366ddc9..48acc3f9 100644 --- a/ghost/map.h +++ b/ghost/map.h @@ -93,7 +93,6 @@ class CMap { public: CGHost *m_GHost; - unsigned char m_MaxSlots; private: bool m_Valid; @@ -127,8 +126,8 @@ class CMap vector m_Slots; public: - CMap( CGHost *nGHost, unsigned char nMaxSlots ); - CMap( CGHost *nGHost, CConfig *CFG, string nCFGFile, unsigned char nMaxSlots ); + CMap( CGHost *nGHost ); + CMap( CGHost *nGHost, CConfig *CFG, string nCFGFile ); ~CMap( ); bool GetValid( ) { return m_Valid; }