Ticket #2360: grid.diff
File grid.diff, 1.3 KB (added by , 10 years ago) |
---|
-
source/simulation2/components/CCmpTerritoryManager.cpp
451 451 FloodFill(entityGrid, influenceGrid, openTiles, falloff); 452 452 453 453 // TODO: we should do a sparse grid and only add the non-zero regions, for performance 454 for (u16 j = 0; j < entityGrid.m_H; ++j) 455 for (u16 i = 0; i < entityGrid.m_W; ++i) 456 playerGrid.set(i, j, playerGrid.get(i, j) + entityGrid.get(i, j)); 454 playerGrid.add(entityGrid); 457 455 } 458 456 459 457 playerGrids.push_back(std::make_pair(it->first, playerGrid)); -
source/simulation2/helpers/Grid.h
82 82 memset(m_Data, 0, m_W*m_H*sizeof(T)); 83 83 } 84 84 85 void add(const Grid& g) 86 { 87 #if GRID_BOUNDS_DEBUG 88 ENSURE(0 <= g.m_W && g.m_W < m_W && 0 <= g.m_H && g.m_H < m_H); 89 #endif 90 for (int j=0; j < g.m_H; ++j) 91 for (int i=0; i < g.m_W; ++i) 92 m_Data[j*m_W + i] += g.m_Data[j*g.m_W + i]; 93 } 94 85 95 void set(int i, int j, const T& value) 86 96 { 87 97 #if GRID_BOUNDS_DEBUG