mirror of
https://github.com/jmarshall23/DoomRTX.git
synced 2026-08-16 00:01:53 +02:00
Fixes for the bots.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user