Pyrogenesis  trunk
Classes | Macros | Functions
CCmpTerritoryManager.cpp File Reference
#include "precompiled.h"
#include "simulation2/system/Component.h"
#include "ICmpTerritoryManager.h"
#include "graphics/Overlay.h"
#include "graphics/Terrain.h"
#include "graphics/TextureManager.h"
#include "graphics/TerritoryBoundary.h"
#include "maths/MathUtil.h"
#include "ps/Profile.h"
#include "ps/XML/Xeromyces.h"
#include "renderer/Renderer.h"
#include "renderer/Scene.h"
#include "renderer/TerrainOverlay.h"
#include "simulation2/MessageTypes.h"
#include "simulation2/components/ICmpOwnership.h"
#include "simulation2/components/ICmpPathfinder.h"
#include "simulation2/components/ICmpPlayer.h"
#include "simulation2/components/ICmpPlayerManager.h"
#include "simulation2/components/ICmpPosition.h"
#include "simulation2/components/ICmpTerritoryDecayManager.h"
#include "simulation2/components/ICmpTerritoryInfluence.h"
#include "simulation2/helpers/Grid.h"
#include "simulation2/helpers/Render.h"
#include <queue>
Include dependency graph for CCmpTerritoryManager.cpp:

Classes

class  TerritoryOverlay
 
class  CCmpTerritoryManager
 
struct  CCmpTerritoryManager::SBoundaryLine
 
struct  Tile
 

Macros

#define FLOODFILL(i, j, code)
 

Functions

static void NearestTerritoryTile (entity_pos_t x, entity_pos_t z, u16 &i, u16 &j, u16 w, u16 h)
 Compute the tile indexes on the grid nearest to a given point. More...
 

Macro Definition Documentation

◆ FLOODFILL

#define FLOODFILL (   i,
  j,
  code 
)
Value:
do {\
const int NUM_NEIGHBOURS = 8;\
const int NEIGHBOURS_X[NUM_NEIGHBOURS] = {1,-1, 0, 0, 1,-1, 1,-1};\
const int NEIGHBOURS_Z[NUM_NEIGHBOURS] = {0, 0, 1,-1, 1,-1,-1, 1};\
std::queue<Tile> openTiles;\
openTiles.emplace(i, j);\
while (!openTiles.empty())\
{\
u16 posX = openTiles.front().x;\
u16 posZ = openTiles.front().z;\
openTiles.pop();\
for (int n = 0; n < NUM_NEIGHBOURS; ++n)\
{\
u16 nx = posX + NEIGHBOURS_X[n];\
u16 nz = posZ + NEIGHBOURS_Z[n];\
/* Check the bounds, underflow will cause the values to be big again */\
if (nx >= tilesW || nz >= tilesH)\
continue;\
code\
openTiles.emplace(nx, nz);\
}\
}\
}\
while (false)

Function Documentation

◆ NearestTerritoryTile()

static void NearestTerritoryTile ( entity_pos_t  x,
entity_pos_t  z,
u16 i,
u16 j,
u16  w,
u16  h 
)
static

Compute the tile indexes on the grid nearest to a given point.