Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add max slots config & fix my_bool not defined issue #40

Closed
wants to merge 13 commits into from
6 changes: 6 additions & 0 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
6 changes: 1 addition & 5 deletions ghost/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ DFLAGS += -D__SOLARIS__
LFLAGS += -lresolv -lsocket -lnsl
endif

CFLAGS += $(OFLAGS) $(DFLAGS) -I.

ifeq ($(SYSTEM),Darwin)
CFLAGS += -I../mysql/include/
endif
CFLAGS += $(OFLAGS) $(DFLAGS) -I. -I../mysql/include/

OBJS = bncsutilinterface.o bnet.o bnetprotocol.o bnlsclient.o bnlsprotocol.o commandpacket.o config.o crc32.o csvparser.o game.o game_admin.o game_base.o gameplayer.o gameprotocol.o gameslot.o ghost.o ghostdb.o ghostdbmysql.o ghostdbsqlite.o gpsprotocol.o language.o map.o packed.o replay.o savegame.o sha1.o socket.o stats.o statsdota.o statsw3mmd.o util.o
COBJS = sqlite3.o
Expand Down
10 changes: 5 additions & 5 deletions ghost/bnet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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( );
CReplay *Replay = new CReplay( m_GHost->m_MaxSlots );
Replay->Load( File, false );
Replay->ParseReplay( false );
m_GHost->m_EnforcePlayers = Replay->GetPlayers( );
Expand Down Expand Up @@ -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( ), 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( ), 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( );
}
Expand All @@ -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( ), 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( ), 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( );
}
Expand Down
4 changes: 2 additions & 2 deletions ghost/bnetprotocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ BYTEARRAY CBNETProtocol :: SEND_SID_CHECKAD( )
return packet;
}

BYTEARRAY CBNETProtocol :: SEND_SID_STARTADVEX3( unsigned char state, BYTEARRAY mapGameType, BYTEARRAY mapFlags, BYTEARRAY mapWidth, BYTEARRAY mapHeight, string gameName, string hostName, uint32_t upTime, string mapPath, BYTEARRAY mapCRC, BYTEARRAY mapSHA1, uint32_t hostCounter )
BYTEARRAY CBNETProtocol :: SEND_SID_STARTADVEX3( unsigned char state, BYTEARRAY mapGameType, BYTEARRAY mapFlags, BYTEARRAY mapWidth, BYTEARRAY mapHeight, string gameName, string hostName, uint32_t upTime, string mapPath, BYTEARRAY mapCRC, BYTEARRAY mapSHA1, unsigned char maxSlots, uint32_t hostCounter )
{
// todotodo: sort out how GameType works, the documentation is horrendous

Expand Down Expand Up @@ -709,7 +709,7 @@ Observers: (mask 0x00700000) cant be combined
UTIL_AppendByteArray( packet, CustomGame, 4 ); // Custom Game
UTIL_AppendByteArrayFast( packet, gameName ); // Game Name
packet.push_back( 0 ); // Game Password is NULL
if( MAX_SLOTS > 12 )
if( maxSlots > 12 )
packet.push_back( 110 ); // Slots Free (ascii 98 = char 'b' = 11 slots free) - note: do not reduce this as this is the # of PID's Warcraft III will allocate
else
packet.push_back( 98 );
Expand Down
2 changes: 1 addition & 1 deletion ghost/bnetprotocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class CBNETProtocol
BYTEARRAY SEND_SID_JOINCHANNEL( string channel );
BYTEARRAY SEND_SID_CHATCOMMAND( string command );
BYTEARRAY SEND_SID_CHECKAD( );
BYTEARRAY SEND_SID_STARTADVEX3( unsigned char state, BYTEARRAY mapGameType, BYTEARRAY mapFlags, BYTEARRAY mapWidth, BYTEARRAY mapHeight, string gameName, string hostName, uint32_t upTime, string mapPath, BYTEARRAY mapCRC, BYTEARRAY mapSHA1, uint32_t hostCounter );
BYTEARRAY SEND_SID_STARTADVEX3( unsigned char state, BYTEARRAY mapGameType, BYTEARRAY mapFlags, BYTEARRAY mapWidth, BYTEARRAY mapHeight, string gameName, string hostName, uint32_t upTime, string mapPath, BYTEARRAY mapCRC, BYTEARRAY mapSHA1, unsigned char maxSlots, uint32_t hostCounter );
BYTEARRAY SEND_SID_NOTIFYJOIN( string gameName );
BYTEARRAY SEND_SID_PING( BYTEARRAY pingValue );
BYTEARRAY SEND_SID_LOGONRESPONSE( BYTEARRAY clientToken, BYTEARRAY serverToken, BYTEARRAY passwordHash, string accountName );
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 < MAX_SLOTS && 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 );
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 < MAX_SLOTS && 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 )
{
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( ), MAX_SLOTS, MAX_SLOTS, 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( ), (uint32_t) m_GHost->m_MaxSlots, (uint32_t) m_GHost->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( ), MAX_SLOTS, MAX_SLOTS, 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( ), (uint32_t) m_GHost->m_MaxSlots, (uint32_t) m_GHost->m_MaxSlots, m_HostPort, FixedHostCounter, m_EntryKey ) );
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion ghost/game_admin.cpp
Original file line number Diff line number Diff line change
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( );
CReplay *Replay = new CReplay( m_GHost->m_MaxSlots );
Replay->Load( File, false );
Replay->ParseReplay( false );
m_GHost->m_EnforcePlayers = Replay->GetPlayers( );
Expand Down
Loading