Fixes for the bots.

This commit is contained in:
Justin Marshall
2026-05-19 19:43:23 -07:00
parent af56d4bfeb
commit ed6b826d23
15 changed files with 1419 additions and 1103 deletions
+19 -10
View File
@@ -17,7 +17,7 @@ idBotWeaponInfoManager::BotValidWeaponNumber
*/
int idBotWeaponInfoManager::BotValidWeaponNumber( int weaponnum )
{
if( weaponnum <= 0 || weaponnum > BOT_MAX_WEAPONS )
if( weaponnum < 0 || weaponnum >= BOT_MAX_WEAPONS )
{
gameLocal.Error( "weapon number out of range\n" );
return false;
@@ -35,6 +35,7 @@ bot_weaponstate_t* idBotWeaponInfoManager::BotWeaponStateFromHandle( int handle
if( handle <= 0 || handle > MAX_CLIENTS )
{
gameLocal.Error( "move state handle %d out of range\n", handle );
return NULL;
}
return &botweaponstates[handle];
@@ -374,19 +375,27 @@ idBotWeaponInfoManager::BotGetWeaponInfo
*/
void idBotWeaponInfoManager::BotGetWeaponInfo( int weaponstate, int weapon, weaponinfo_t* weaponinfo )
{
bot_weaponstate_t* ws;
if( !BotValidWeaponNumber( weapon ) )
{
return;
}
ws = BotWeaponStateFromHandle( weaponstate );
if( !ws )
if( weaponinfo == NULL )
{
return;
}
*weaponinfo = this->weaponinfo[weapon];
if( BotValidWeaponNumber( weapon ) && this->weaponinfo[weapon].valid )
{
*weaponinfo = this->weaponinfo[weapon];
return;
}
// Fallback: return the first loaded weapon so callers never keep an
// uninitialized weaponinfo_t when a bot has not picked a valid weapon yet.
for( int i = 0; i < BOT_MAX_WEAPONS; i++ )
{
if( this->weaponinfo[i].valid )
{
*weaponinfo = this->weaponinfo[i];
return;
}
}
}
/*