Fix skidding ai crash
This commit is contained in:
parent
8c223cd2c2
commit
fe028b4534
@ -29,6 +29,8 @@
|
||||
#include <SColor.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <algorithm>
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <random>
|
||||
@ -174,6 +176,14 @@ public:
|
||||
return dynamic_cast<Item*>(m_all_items[n]);
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
bool itemExists(const ItemState* is) const
|
||||
{
|
||||
if (!is)
|
||||
return false;
|
||||
auto it = std::find(m_all_items.begin(), m_all_items.end(), is);
|
||||
return it != m_all_items.end();
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns a reference to the array of all items on the specified quad.
|
||||
*/
|
||||
const AllItemTypes& getItemsInQuads(unsigned int n) const
|
||||
|
@ -222,6 +222,15 @@ unsigned int SkiddingAI::getNextSector(unsigned int index)
|
||||
void SkiddingAI::update(int ticks)
|
||||
{
|
||||
float dt = stk_config->ticks2Time(ticks);
|
||||
|
||||
// Clear stored items if they were deleted (for example a switched nitro)
|
||||
if (m_item_to_collect &&
|
||||
!ItemManager::get()->itemExists(m_item_to_collect))
|
||||
m_item_to_collect = NULL;
|
||||
if (m_last_item_random &&
|
||||
!ItemManager::get()->itemExists(m_last_item_random))
|
||||
m_last_item_random = NULL;
|
||||
|
||||
m_controls->setRescue(false);
|
||||
|
||||
// This is used to enable firing an item backwards.
|
||||
|
Loading…
x
Reference in New Issue
Block a user