mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
Instead mark spell as delatable mark it as executed and referenced from Unit current spells array and not deleted spell in like cases.
This is solve crashs if spell deleted at caster die in result triggered spells casting chain from currently executed spell.
This commit is contained in:
parent
322b201c4d
commit
ed7390dede
7 changed files with 61 additions and 25 deletions
|
|
@ -26,7 +26,7 @@ EventProcessor::EventProcessor()
|
|||
|
||||
EventProcessor::~EventProcessor()
|
||||
{
|
||||
KillAllEvents();
|
||||
KillAllEvents(true);
|
||||
}
|
||||
|
||||
void EventProcessor::Update(uint32 p_time)
|
||||
|
|
@ -58,21 +58,31 @@ void EventProcessor::Update(uint32 p_time)
|
|||
}
|
||||
}
|
||||
|
||||
void EventProcessor::KillAllEvents()
|
||||
void EventProcessor::KillAllEvents(bool force)
|
||||
{
|
||||
// prevent event insertions
|
||||
m_aborting = true;
|
||||
|
||||
// first, abort all existing events
|
||||
for (EventList::iterator i = m_events.begin(); i != m_events.end(); ++i)
|
||||
for (EventList::iterator i = m_events.begin(); i != m_events.end();)
|
||||
{
|
||||
i->second->to_Abort = true;
|
||||
i->second->Abort(m_time);
|
||||
delete i->second;
|
||||
EventList::iterator i_old = i;
|
||||
++i;
|
||||
|
||||
i_old->second->to_Abort = true;
|
||||
i_old->second->Abort(m_time);
|
||||
if(force || i_old->second->IsDeletable())
|
||||
{
|
||||
delete i_old->second;
|
||||
|
||||
if(!force) // need per-element cleanup
|
||||
m_events.erase (i_old);
|
||||
}
|
||||
}
|
||||
|
||||
// clear event list
|
||||
m_events.clear();
|
||||
// fast clear event list (in force case)
|
||||
if(force)
|
||||
m_events.clear();
|
||||
}
|
||||
|
||||
void EventProcessor::AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue