diff --git a/default.cfg b/default.cfg index 6f9b997a..7f335053 100644 --- a/default.cfg +++ b/default.cfg @@ -61,6 +61,12 @@ bot_reconnectwaittime = 3 bot_maxgames = 5 +### slot limit in game lobby. this parameter depends on what Warcraft III version +### you intent to use. for example, for 1.27b, use max_slots = 12, otherwise, +### games won't be visible. + +max_slots = 24 + ### command trigger for ingame only (battle.net command triggers are defined later) bot_commandtrigger = ! @@ -451,12 +457,6 @@ bnet_custom_exeversionhash = bnet_custom_passwordhashtype = bnet_custom_pvpgnrealmname = PvPGN Realm -### slot limit in game lobby. this parameter depends on what Warcraft III version -### you intent to use. for example, for 1.27b, use max_slots = 12, otherwise, -### games won't be visible. - -bnet_max_slots = 24 - ### ### example configuration for connecting to a second official battle.net server ### diff --git a/ghost/bnet.cpp b/ghost/bnet.cpp index d5a81d16..3a231fdb 100644 --- a/ghost/bnet.cpp +++ b/ghost/bnet.cpp @@ -44,7 +44,7 @@ using namespace boost :: filesystem; // CBNET // -CBNET :: CBNET( CGHost *nGHost, string nServer, string nServerAlias, string nBNLSServer, uint16_t nBNLSPort, uint32_t nBNLSWardenCookie, string nCDKeyROC, string nCDKeyTFT, string nCountryAbbrev, string nCountry, uint32_t nLocaleID, string nUserName, string nUserPassword, string nFirstChannel, string nRootAdmin, char nCommandTrigger, bool nHoldFriends, bool nHoldClan, bool nPublicCommands, unsigned char nWar3Version, BYTEARRAY nEXEVersion, BYTEARRAY nEXEVersionHash, string nPasswordHashType, string nPVPGNRealmName, uint32_t nMaxMessageLength, unsigned char nMaxSlots, uint32_t nHostCounterID ) +CBNET :: CBNET( CGHost *nGHost, string nServer, string nServerAlias, string nBNLSServer, uint16_t nBNLSPort, uint32_t nBNLSWardenCookie, string nCDKeyROC, string nCDKeyTFT, string nCountryAbbrev, string nCountry, uint32_t nLocaleID, string nUserName, string nUserPassword, string nFirstChannel, string nRootAdmin, char nCommandTrigger, bool nHoldFriends, bool nHoldClan, bool nPublicCommands, unsigned char nWar3Version, BYTEARRAY nEXEVersion, BYTEARRAY nEXEVersionHash, string nPasswordHashType, string nPVPGNRealmName, uint32_t nMaxMessageLength, uint32_t nHostCounterID ) { // todotodo: append path seperator to Warcraft3Path if needed @@ -117,7 +117,6 @@ CBNET :: CBNET( CGHost *nGHost, string nServer, string nServerAlias, string nBNL m_PasswordHashType = nPasswordHashType; m_PVPGNRealmName = nPVPGNRealmName; m_MaxMessageLength = nMaxMessageLength; - m_MaxSlots = nMaxSlots; m_HostCounterID = nHostCounterID; m_LastDisconnectedTime = 0; m_LastConnectionAttemptTime = 0; @@ -1300,7 +1299,7 @@ void CBNET :: BotCommand( string Message, string User, bool Whisper, bool ForceR QueueChatCommand( m_GHost->m_Language->AutoHostEnabled( ), User, Whisper ); delete m_GHost->m_AutoHostMap; - m_GHost->m_AutoHostMap = new CMap( m_GHost, m_MaxSlots ); + m_GHost->m_AutoHostMap = new CMap( m_GHost ); m_GHost->m_AutoHostGameName = GameName; m_GHost->m_AutoHostOwner = User; m_GHost->m_AutoHostServer = m_Server; @@ -1388,7 +1387,7 @@ void CBNET :: BotCommand( string Message, string User, bool Whisper, bool ForceR QueueChatCommand( m_GHost->m_Language->AutoHostEnabled( ), User, Whisper ); delete m_GHost->m_AutoHostMap; - m_GHost->m_AutoHostMap = new CMap( m_GHost, m_MaxSlots ); + m_GHost->m_AutoHostMap = new CMap( m_GHost ); m_GHost->m_AutoHostGameName = GameName; m_GHost->m_AutoHostOwner = User; m_GHost->m_AutoHostServer = m_Server; @@ -1545,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_MaxSlots ); + CReplay *Replay = new CReplay( m_GHost->m_Map->m_MaxSlots ); Replay->Load( File, false ); Replay->ParseReplay( false ); m_GHost->m_EnforcePlayers = Replay->GetPlayers( ); @@ -2268,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( ), 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_Map->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( ), 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_Map->m_MaxSlots, FixedHostCounter ) ); packetsLock.unlock( ); } @@ -2296,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( ), 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_Map->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( ), 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_Map->m_MaxSlots, FixedHostCounter ) ); packetsLock.unlock( ); } diff --git a/ghost/bnet.h b/ghost/bnet.h index 4cda417c..ed37da10 100644 --- a/ghost/bnet.h +++ b/ghost/bnet.h @@ -109,7 +109,6 @@ class CBNET string m_PasswordHashType; // password hash type for PvPGN users string m_PVPGNRealmName; // realm name for PvPGN users (for mutual friend spoofchecks) uint32_t m_MaxMessageLength; // maximum message length for PvPGN users - unsigned char m_MaxSlots; // maximum slots in lobby uint32_t m_HostCounterID; // the host counter ID to identify players from this realm uint32_t m_LastDisconnectedTime; // GetTime when we were last disconnected from battle.net uint32_t m_LastConnectionAttemptTime; // GetTime when we last attempted to connect to battle.net @@ -129,7 +128,7 @@ class CBNET bool m_LastInviteCreation; // whether the last invite received was for a clan creation (else, it was for invitation response) public: - CBNET( CGHost *nGHost, string nServer, string nServerAlias, string nBNLSServer, uint16_t nBNLSPort, uint32_t nBNLSWardenCookie, string nCDKeyROC, string nCDKeyTFT, string nCountryAbbrev, string nCountry, uint32_t nLocaleID, string nUserName, string nUserPassword, string nFirstChannel, string nRootAdmin, char nCommandTrigger, bool nHoldFriends, bool nHoldClan, bool nPublicCommands, unsigned char nWar3Version, BYTEARRAY nEXEVersion, BYTEARRAY nEXEVersionHash, string nPasswordHashType, string nPVPGNRealmName, uint32_t nMaxMessageLength, unsigned char nMaxSlots, uint32_t nHostCounterID ); + CBNET( CGHost *nGHost, string nServer, string nServerAlias, string nBNLSServer, uint16_t nBNLSPort, uint32_t nBNLSWardenCookie, string nCDKeyROC, string nCDKeyTFT, string nCountryAbbrev, string nCountry, uint32_t nLocaleID, string nUserName, string nUserPassword, string nFirstChannel, string nRootAdmin, char nCommandTrigger, bool nHoldFriends, bool nHoldClan, bool nPublicCommands, unsigned char nWar3Version, BYTEARRAY nEXEVersion, BYTEARRAY nEXEVersionHash, string nPasswordHashType, string nPVPGNRealmName, uint32_t nMaxMessageLength, uint32_t nHostCounterID ); ~CBNET( ); bool GetExiting( ) { return m_Exiting; } diff --git a/ghost/game.cpp b/ghost/game.cpp index 4b578db9..cc9c6219 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 < m_Map->m_MaxSlots && SID < m_Slots.size( ) ) + if( !( m_Map->GetMapOptions( ) & MAPOPT_FIXEDPLAYERSETTINGS ) && Colour < ((uint32_t) m_GHost->m_Map->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 < m_Map->m_MaxSlots && SID < m_Slots.size( ) ) + if( !( m_Map->GetMapOptions( ) & MAPOPT_FIXEDPLAYERSETTINGS ) && Team < ((uint32_t) m_GHost->m_Map->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_Map->m_MaxSlots, 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_Map->m_MaxSlots, m_GHost->m_Map->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_Map->m_MaxSlots, 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_Map->m_MaxSlots, m_GHost->m_Map->m_MaxSlots, m_HostPort, FixedHostCounter, m_EntryKey ) ); } } } diff --git a/ghost/game_admin.cpp b/ghost/game_admin.cpp index d3f5944a..dbacc47e 100644 --- a/ghost/game_admin.cpp +++ b/ghost/game_admin.cpp @@ -445,7 +445,7 @@ bool CAdminGame :: EventPlayerBotCommand( CGamePlayer *player, string command, s SendChat( player, m_GHost->m_Language->AutoHostEnabled( ) ); delete m_GHost->m_AutoHostMap; - m_GHost->m_AutoHostMap = new CMap( m_GHost, m_Map->m_MaxSlots ); + m_GHost->m_AutoHostMap = new CMap( m_GHost ); m_GHost->m_AutoHostGameName = GameName; m_GHost->m_AutoHostOwner = User; m_GHost->m_AutoHostServer.clear( ); @@ -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_Map->m_MaxSlots ); + CReplay *Replay = new CReplay( m_GHost->m_Map->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 1104c719..9f815a33 100644 --- a/ghost/game_base.cpp +++ b/ghost/game_base.cpp @@ -46,11 +46,11 @@ CBaseGame :: CBaseGame( CGHost *nGHost, CMap *nMap, CSaveGame *nSaveGame, uint16_t nHostPort, unsigned char nGameState, string nGameName, string nOwnerName, string nCreatorName, string nCreatorServer ) : m_GHost( nGHost ), m_SaveGame( nSaveGame ), m_Replay( NULL ), m_Exiting( false ), m_Saving( false ), m_HostPort( nHostPort ), m_GameState( nGameState ), m_VirtualHostPID( 255 ), m_FakePlayerPID( 255 ), m_GProxyEmptyActions( 0 ), m_GameName( nGameName ), m_LastGameName( nGameName ), m_VirtualHostName( m_GHost->m_VirtualHostName ), m_OwnerName( nOwnerName ), m_CreatorName( nCreatorName ), m_CreatorServer( nCreatorServer ), m_HCLCommandString( nMap->GetMapDefaultHCL( ) ), m_RandomSeed( GetTicks( ) ), m_HostCounter( m_GHost->m_HostCounter++ ), m_EntryKey( rand( ) ), m_Latency( m_GHost->m_Latency ), m_SyncLimit( m_GHost->m_SyncLimit ), m_SyncCounter( 0 ), m_GameTicks( 0 ), m_CreationTime( GetTime( ) ), m_LastPingTime( GetTime( ) ), m_LastRefreshTime( GetTime( ) ), m_LastDownloadTicks( GetTime( ) ), m_DownloadCounter( 0 ), m_LastDownloadCounterResetTicks( GetTime( ) ), m_LastAnnounceTime( 0 ), m_AnnounceInterval( 0 ), m_LastAutoStartTime( GetTime( ) ), m_AutoStartPlayers( 0 ), m_LastCountDownTicks( 0 ), m_CountDownCounter( 0 ), m_StartedLoadingTicks( 0 ), m_StartPlayers( 0 ), m_LastLagScreenResetTime( 0 ), m_LastActionSentTicks( 0 ), m_LastActionLateBy( 0 ), m_StartedLaggingTime( 0 ), m_LastLagScreenTime( 0 ), m_LastReservedSeen( GetTime( ) ), m_StartedKickVoteTime( 0 ), m_GameOverTime( 0 ), m_LastPlayerLeaveTicks( 0 ), m_MinimumScore( 0. ), m_MaximumScore( 0. ), m_SlotInfoChanged( false ), m_Locked( false ), m_RefreshMessages( m_GHost->m_RefreshMessages ), m_RefreshError( false ), m_RefreshRehosted( false ), m_MuteAll( false ), m_MuteLobby( false ), m_CountDownStarted( false ), m_GameLoading( false ), m_GameLoaded( false ), m_LoadInGame( nMap->GetMapLoadInGame( ) ), m_Lagging( false ), m_AutoSave( m_GHost->m_AutoSave ), m_MatchMaking( false ), m_LocalAdminMessages( m_GHost->m_LocalAdminMessages ), m_DoDelete( 0 ), m_LastReconnectHandleTime( 0 ) { m_Socket = new CTCPServer( ); - m_Protocol = new CGameProtocol( m_GHost, nMap->m_MaxSlots ); - m_Map = new CMap( m_GHost, nMap->m_MaxSlots ); + m_Protocol = new CGameProtocol( m_GHost ); + m_Map = new CMap( m_GHost ); if( m_GHost->m_SaveReplays && !m_SaveGame ) - m_Replay = new CReplay( m_Map->m_MaxSlots ); + m_Replay = new CReplay( m_GHost->m_Map->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( ) < m_Map->m_MaxSlots ) + if( !m_GameLoading && !m_GameLoaded && GetNumPlayers( ) < ((uint32_t) m_GHost->m_Map->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_Map->m_MaxSlots, 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_Map->m_MaxSlots, m_GHost->m_Map->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_Map->m_MaxSlots, 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_Map->m_MaxSlots, m_GHost->m_Map->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( ) >= m_Map->m_MaxSlots-1 || EnforcePID == m_VirtualHostPID ) + if( GetNumPlayers( ) >= ((uint32_t) (m_GHost->m_Map->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_Map->m_MaxSlots, m_Map->m_MaxSlots, SLOTRACE_RANDOM ); + m_Slots[SID] = CGameSlot( Player->GetPID( ), 255, SLOTSTATUS_OCCUPIED, 0, m_GHost->m_Map->m_MaxSlots, m_GHost->m_Map->m_MaxSlots, SLOTRACE_RANDOM ); else - m_Slots[SID] = CGameSlot( Player->GetPID( ), 255, SLOTSTATUS_OCCUPIED, 0, m_Map->m_MaxSlots, m_Map->m_MaxSlots, SLOTRACE_RANDOM | SLOTRACE_SELECTABLE ); + 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 ); // 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_Map->m_MaxSlots ) + if( m_Slots[i].GetSlotStatus( ) == SLOTSTATUS_OCCUPIED && m_Slots[i].GetTeam( ) != m_GHost->m_Map->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( ) >= m_Map->m_MaxSlots-1 ) + if( GetNumPlayers( ) >= ((uint32_t) (m_GHost->m_Map->m_MaxSlots-1)) ) DeleteVirtualHost( ); // identify their joined realm @@ -3033,10 +3033,10 @@ void CBaseGame :: EventPlayerChangeTeam( CGamePlayer *player, unsigned char team } else { - if( team > m_Map->m_MaxSlots ) + if( team > m_GHost->m_Map->m_MaxSlots ) return; - if( team == m_Map->m_MaxSlots ) + if( team == m_GHost->m_Map->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_Map->m_MaxSlots && m_Slots[i].GetPID( ) != player->GetPID( ) ) + if( m_Slots[i].GetSlotStatus( ) == SLOTSTATUS_OCCUPIED && m_Slots[i].GetTeam( ) != m_GHost->m_Map->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_Map->m_MaxSlots ) + if( team == m_GHost->m_Map->m_MaxSlots ) { // if they're joining the observer team give them the observer colour - m_Slots[SID].SetColour( m_Map->m_MaxSlots ); + m_Slots[SID].SetColour( m_GHost->m_Map->m_MaxSlots ); } - else if( m_Slots[SID].GetColour( ) == m_Map->m_MaxSlots ) + else if( m_Slots[SID].GetColour( ) == m_GHost->m_Map->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_Map->m_MaxSlots-1 ) + if( colour > m_GHost->m_Map->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_Map->m_MaxSlots ) + if( m_Slots[SID].GetTeam( ) == m_GHost->m_Map->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_Map->m_MaxSlots; ++TestColour ) + for( unsigned char TestColour = 0; TestColour < m_GHost->m_Map->m_MaxSlots; ++TestColour ) { bool InUse = false; @@ -3717,7 +3717,7 @@ unsigned char CBaseGame :: GetNewColour( ) // this should never happen - return m_Map->m_MaxSlots; + return m_GHost->m_Map->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_Map->m_MaxSlots ) + if( SID < m_Slots.size( ) && colour < m_GHost->m_Map->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_Map->m_MaxSlots ) + if( (*i).GetSlotStatus( ) == SLOTSTATUS_OCCUPIED && (*i).GetComputer( ) == 0 && (*i).GetTeam( ) != m_GHost->m_Map->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_Map->m_MaxSlots ) + if( (*i).GetSlotStatus( ) == SLOTSTATUS_OCCUPIED && (*i).GetComputer( ) == 0 && (*i).GetTeam( ) != m_GHost->m_Map->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_Map->m_MaxSlots; ++i ) + for( unsigned char i = StartTeam; i < m_GHost->m_Map->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_Map->m_MaxSlots]; + double TeamScores[m_GHost->m_Map->m_MaxSlots]; - for( unsigned char j = StartTeam; j < m_Map->m_MaxSlots; ++j ) + for( unsigned char j = StartTeam; j < m_GHost->m_Map->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_Map->m_MaxSlots; ++j ) + for( unsigned char j = StartTeam; j < m_GHost->m_Map->m_MaxSlots; ++j ) { if( TeamSizes[j] > 0 ) { - for( unsigned char k = j + 1; k < m_Map->m_MaxSlots; ++k ) + for( unsigned char k = j + 1; k < m_GHost->m_Map->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_Map->m_MaxSlots]; + unsigned char TeamSizes[m_GHost->m_Map->m_MaxSlots]; double PlayerScores[13]; - memset( TeamSizes, 0, sizeof( unsigned char ) * m_Map->m_MaxSlots ); + memset( TeamSizes, 0, sizeof( unsigned char ) * m_GHost->m_Map->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_Map->m_MaxSlots ) + if( Team < m_GHost->m_Map->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_Map->m_MaxSlots; ++i ) + for( unsigned char i = 0; i < m_GHost->m_Map->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_Map->m_MaxSlots; ++i ) + for( unsigned char i = 0; i < m_GHost->m_Map->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_Map->m_MaxSlots; ++i ) + for( unsigned char i = 0; i < m_GHost->m_Map->m_MaxSlots; ++i ) { bool TeamHasPlayers = false; double TeamScore = 0.0; @@ -4731,7 +4731,7 @@ void CBaseGame :: CreateFakePlayer( ) if( SID < m_Slots.size( ) ) { - if( GetNumPlayers( ) >= m_Map->m_MaxSlots-1 ) + if( GetNumPlayers( ) >= ((uint32_t) (m_GHost->m_Map->m_MaxSlots-1)) ) DeleteVirtualHost( ); m_FakePlayerPID = GetNewPID( ); diff --git a/ghost/gameprotocol.cpp b/ghost/gameprotocol.cpp index edb78997..b5cb8f03 100644 --- a/ghost/gameprotocol.cpp +++ b/ghost/gameprotocol.cpp @@ -29,7 +29,7 @@ // CGameProtocol // -CGameProtocol :: CGameProtocol( CGHost *nGHost, unsigned char nMaxSlots ) : m_GHost( nGHost ), m_MaxSlots(nMaxSlots) +CGameProtocol :: CGameProtocol( CGHost *nGHost ) : m_GHost( nGHost ) { } @@ -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_MaxSlots && data.size( ) >= i + Total ) + if( Total > 0 && Total <= m_GHost->m_Map->m_MaxSlots && data.size( ) >= i + Total ) { BYTEARRAY ToPIDs = BYTEARRAY( data.begin( ) + i, data.begin( ) + i + Total ); i += Total; diff --git a/ghost/gameprotocol.h b/ghost/gameprotocol.h index 5c79e5de..0e95e6f8 100644 --- a/ghost/gameprotocol.h +++ b/ghost/gameprotocol.h @@ -58,9 +58,6 @@ class CIncomingMapSize; class CGameProtocol { -private: - unsigned char m_MaxSlots; - public: CGHost *m_GHost; @@ -104,7 +101,7 @@ class CGameProtocol W3GS_INCOMING_ACTION2 = 72 // 0x48 - received this packet when there are too many actions to fit in W3GS_INCOMING_ACTION }; - CGameProtocol( CGHost *nGHost, unsigned char nMaxSlots ); + CGameProtocol( CGHost *nGHost ); ~CGameProtocol( ); // receive functions diff --git a/ghost/ghost.cpp b/ghost/ghost.cpp index e1c8879e..c3c070c8 100644 --- a/ghost/ghost.cpp +++ b/ghost/ghost.cpp @@ -546,10 +546,6 @@ CGHost :: CGHost( CConfig *CFG ) string PasswordHashType = CFG->GetString( Prefix + "custom_passwordhashtype", string( ) ); string PVPGNRealmName = CFG->GetString( Prefix + "custom_pvpgnrealmname", "PvPGN Realm" ); uint32_t MaxMessageLength = CFG->GetInt( Prefix + "custom_maxmessagelength", 200 ); - unsigned char MaxSlots = CFG->GetUInt32( Prefix + "max_slots", 24 ); - - if (!MaxSlots) - CONSOLE_Print( "[GHOST] WARNING: " + Prefix + "max_slots with missing value or value = 0? possible correct values are 12 or 24" ); if( Server.empty( ) ) break; @@ -589,7 +585,7 @@ CGHost :: CGHost( CConfig *CFG ) #endif } - m_BNETs.push_back( new CBNET( this, Server, ServerAlias, BNLSServer, (uint16_t)BNLSPort, (uint32_t)BNLSWardenCookie, CDKeyROC, CDKeyTFT, CountryAbbrev, Country, LocaleID, UserName, UserPassword, FirstChannel, RootAdmin, BNETCommandTrigger[0], HoldFriends, HoldClan, PublicCommands, War3Version, EXEVersion, EXEVersionHash, PasswordHashType, PVPGNRealmName, MaxMessageLength, MaxSlots, i ) ); + m_BNETs.push_back( new CBNET( this, Server, ServerAlias, BNLSServer, (uint16_t)BNLSPort, (uint32_t)BNLSWardenCookie, CDKeyROC, CDKeyTFT, CountryAbbrev, Country, LocaleID, UserName, UserPassword, FirstChannel, RootAdmin, BNETCommandTrigger[0], HoldFriends, HoldClan, PublicCommands, War3Version, EXEVersion, EXEVersionHash, PasswordHashType, PVPGNRealmName, MaxMessageLength, i ) ); } if( m_BNETs.empty( ) ) @@ -611,8 +607,9 @@ CGHost :: CGHost( CConfig *CFG ) CConfig MapCFG; MapCFG.Read( m_MapCFGPath + m_DefaultMap ); - // todo: where to get this? - unsigned char MaxSlots = 12; + 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 ); if( !m_AdminGameMap.empty( ) ) @@ -626,8 +623,6 @@ CGHost :: CGHost( CConfig *CFG ) CONSOLE_Print( "[GHOST] trying to load default admin game map" ); CConfig AdminMapCFG; AdminMapCFG.Read( m_MapCFGPath + m_AdminGameMap ); - // todo: where to get this from? - unsigned char MaxSlots = 12; m_AdminMap = new CMap( this, &AdminMapCFG, m_MapCFGPath + m_AdminGameMap, MaxSlots ); if( !m_AdminMap->GetValid( ) ) diff --git a/ghost/map.cpp b/ghost/map.cpp index 6228e6e0..f4d7fb7a 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, 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 ) { 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, unsigned char nMaxSlots ) : m_GHost( nGHost ), m_MaxSlots( nMaxSlots ) { Load( CFG, nCFGFile ); } diff --git a/ghost/replay.cpp b/ghost/replay.cpp index 7b233106..2a164f6c 100644 --- a/ghost/replay.cpp +++ b/ghost/replay.cpp @@ -28,7 +28,7 @@ // CReplay // -CReplay :: CReplay( unsigned char nMaxSlots ) : CPacked( ), m_HostPID( 0 ), m_PlayerCount( 0 ), m_MapGameType( 0 ), m_RandomSeed( 0 ), m_SelectMode( 0 ), m_StartSpotCount( 0 ), m_MaxSlots(nMaxSlots) +CReplay :: CReplay( unsigned char nMaxSlots ) : CPacked( ), m_HostPID( 0 ), m_PlayerCount( 0 ), m_MapGameType( 0 ), m_RandomSeed( 0 ), m_SelectMode( 0 ), m_StartSpotCount( 0 ), m_MaxSlots( nMaxSlots ) { m_CompiledBlocks.reserve( 262144 ); } diff --git a/ghost/savegame.cpp b/ghost/savegame.cpp index d9fb315a..83804187 100644 --- a/ghost/savegame.cpp +++ b/ghost/savegame.cpp @@ -27,7 +27,7 @@ // CSaveGame // -CSaveGame :: CSaveGame( unsigned char nMaxSlots ) : CPacked( ), m_NumSlots( 0 ), m_RandomSeed( 0 ), m_MaxSlots(nMaxSlots) +CSaveGame :: CSaveGame( unsigned char nMaxSlots ) : CPacked( ), m_NumSlots( 0 ), m_RandomSeed( 0 ), m_MaxSlots( nMaxSlots ) { }