Menu

#12 Access violation when bot throws its last grenade

open
nobody
None
5
2017-05-22
2017-05-22
No

Hi!

When a bot throws its last grenade, the call m_pWeapon->getAmmo(pBot) at line #3712 of utils/RCBot2_meta/bot_task.cpp will cause an access viloation due to m_pWeapon->m_pWeaponInfo being a null pointer. This is beacuse the call m_pWeapons->update() at line #849 of utils/RCBot2_meta/bot.cpp will zero out the entry in m_theWeapons corresponding to the grenade on next think while the CThrowGrenadeTask instance is still in the queue.

I've solved the problem by changing the corresponding line of bot_task.cpp from:

if ( m_pWeapon->getAmmo(pBot) < m_iAmmo )

to

if ( !m_pWeapon || !m_pWeapon->hasWeapon() || m_pWeapon->getAmmo(pBot) < m_iAmmo )

This resolves the issue, but I'm not sure that this is the correct solution.

Discussion


Log in to post a comment.