Update grid system. Try to fix some crashes and transport passengers (now they are despawned after a while).
This commit is contained in:
@@ -100,7 +100,12 @@ class Grid
|
||||
|
||||
/** Returns the number of object within the grid.
|
||||
*/
|
||||
unsigned int ActiveObjectsInGrid(void) const { return /*m_activeGridObjects.size()+*/i_objects.template Count<ACTIVE_OBJECT>(); }
|
||||
//unsigned int ActiveObjectsInGrid(void) const { return i_objects.template Count<ACTIVE_OBJECT>(); }
|
||||
template<class T>
|
||||
uint32 GetWorldObjectCountInGrid() const
|
||||
{
|
||||
return i_objects.template Count<T>();
|
||||
}
|
||||
|
||||
/** Inserts a container type object into the grid.
|
||||
*/
|
||||
|
||||
@@ -31,7 +31,7 @@ void ActiveState::Update(Map &m, NGridType &grid, GridInfo & info, const uint32
|
||||
info.UpdateTimeTracker(t_diff);
|
||||
if (info.getTimeTracker().Passed())
|
||||
{
|
||||
if (grid.ActiveObjectsInGrid() == 0 && !m.ActiveObjectsNearGrid(grid))
|
||||
if (!grid.GetWorldObjectCountInNGrid<Player>() && !m.ActiveObjectsNearGrid(grid))
|
||||
{
|
||||
ObjectGridStoper worker;
|
||||
TypeContainerVisitor<ObjectGridStoper, GridTypeMapContainer> visitor(worker);
|
||||
|
||||
@@ -158,14 +158,28 @@ class NGrid
|
||||
GetGridType(x, y).Visit(visitor);
|
||||
}
|
||||
|
||||
unsigned int ActiveObjectsInGrid(void) const
|
||||
//This gets the player count in grid
|
||||
//I disable this to avoid confusion (active object usually means something else)
|
||||
/*
|
||||
uint32 GetActiveObjectCountInGrid() const
|
||||
{
|
||||
unsigned int count=0;
|
||||
for (unsigned int x=0; x < N; ++x)
|
||||
for (unsigned int y=0; y < N; ++y)
|
||||
uint32 count = 0;
|
||||
for (uint32 x = 0; x < N; ++x)
|
||||
for (uint32 y = 0; y < N; ++y)
|
||||
count += i_cells[x][y].ActiveObjectsInGrid();
|
||||
return count;
|
||||
}
|
||||
*/
|
||||
|
||||
template<class T>
|
||||
uint32 GetWorldObjectCountInNGrid() const
|
||||
{
|
||||
uint32 count = 0;
|
||||
for (uint32 x = 0; x < N; ++x)
|
||||
for (uint32 y = 0; y < N; ++y)
|
||||
count += i_cells[x][y].GetWorldObjectCountInGrid<T>();
|
||||
return count;
|
||||
}
|
||||
|
||||
private:
|
||||
uint32 i_gridId;
|
||||
|
||||
Reference in New Issue
Block a user