Fix the crash when removing object from an unloaded grid. Object should always be unlinked from grid no matter if the grid is loaded.

This commit is contained in:
megamage
2011-11-10 17:31:45 -05:00
parent 23b3f16f3a
commit 31a88d4fe5
6 changed files with 51 additions and 95 deletions
+5 -3
View File
@@ -527,9 +527,11 @@ template<class T>
class GridObject
{
public:
GridReference<T> &GetGridRef() { return m_gridRef; }
protected:
GridReference<T> m_gridRef;
bool IsInGrid() const { return _gridRef.isValid(); }
void AddToGrid(GridRefManager<T>& m) { ASSERT(!IsInGrid()); _gridRef.link(&m, (T*)this); }
void RemoveFromGrid() { ASSERT(IsInGrid()); _gridRef.unlink(); }
private:
GridReference<T> _gridRef;
};
template <class T_VALUES, class T_FLAGS, class FLAG_TYPE, uint8 ARRAY_SIZE>