Core/Transports: Fix possible crash

Fix a crash happening when deleting an instance with transports. This case doesn't appear in current sources but could have happened in ICC and HoR.
This commit is contained in:
jackpoz
2013-12-25 22:52:35 +01:00
parent 9b88a789e6
commit e255d1d376

View File

@@ -63,15 +63,6 @@ Map::~Map()
obj->ResetMap();
}
for (TransportsContainer::iterator itr = _transports.begin(); itr != _transports.end();)
{
Transport* transport = *itr;
++itr;
transport->RemoveFromWorld();
delete transport;
}
if (!m_scriptSchedule.empty())
sScriptMgr->DecreaseScheduledScriptCount(m_scriptSchedule.size());
@@ -1357,6 +1348,17 @@ void Map::UnloadAll()
++i;
UnloadGrid(grid, true); // deletes the grid and removes it from the GridRefManager
}
for (TransportsContainer::iterator itr = _transports.begin(); itr != _transports.end();)
{
Transport* transport = *itr;
++itr;
transport->RemoveFromWorld();
delete transport;
}
_transports.clear();
}
// *****************************