Skip to content

Commit

Permalink
Get max slots from map class.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruk33 committed Oct 13, 2022
1 parent 1163f27 commit a565cec
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 78 deletions.
12 changes: 6 additions & 6 deletions default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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 = !
Expand Down Expand Up @@ -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
###
Expand Down
17 changes: 8 additions & 9 deletions ghost/bnet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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( );
Expand Down Expand Up @@ -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( );
}
Expand All @@ -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( );
}
Expand Down
3 changes: 1 addition & 2 deletions ghost/bnet.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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; }
Expand Down
8 changes: 4 additions & 4 deletions ghost/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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 )
{
Expand Down Expand Up @@ -1466,15 +1466,15 @@ 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
{
// note: the PrivateGame flag is not set when broadcasting to LAN (as you might expect)
// 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 ) );
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions ghost/game_admin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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( );
Expand Down Expand Up @@ -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( );
Expand Down
Loading

0 comments on commit a565cec

Please sign in to comment.