33
33
class TerritoryRegion
35
/// Lage des Ausschnittes in der Karte
36
const int x1, y1, x2, y2;
37
/// Gr��e der Karte (wird aus x1,y1...) berechnet
38
const unsigned short width,height;
40
/// Beschreibung eines Knotenpunktes
43
/// Spieler-index (+1, da 0 = besitzlos!)
45
/// Entfernung vom Milit�rgeb�ude
49
GameWorldBase * const gwb;
52
/// Check whether the point x, y is part of the polygon
53
static bool IsPointInPolygon(GameWorldBase *gwb, std::vector< Point<MapCoord> > &polygon, MapCoord x, MapCoord y);
55
/// Testet einen Punkt, ob der neue Spieler ihn �bernehmen kann und �bernimmt ihn ggf.
56
void TestNode( int x, int y,const unsigned char player, const unsigned char radius, const bool check_barriers);
57
/// Unterfunktionen von AdjustBorders, vergleicht 2 Punkte, ob sie von unterschiedlichen Spielern sind und setzt
58
/// Punkt ggf. zu gar keinem Spieler, 2. Funktion wird f�r Punkte im 2er Abstand verwendet, da es dort ein bisschen anders l�uft!
59
void AdjustNodes(const unsigned short x1, const unsigned short y1, const unsigned short x2, const unsigned short y2);
60
void AdjustNodes2(const unsigned short x1, const unsigned short y1, const unsigned short x2, const unsigned short y2);
65
TerritoryRegion(const int x1, const int y1, const int x2, const int y2, GameWorldBase * const gwb);
68
static bool IsPointValid(GameWorldBase *gwb, std::vector< Point<MapCoord> > &polygon, MapCoord x, MapCoord y);
70
/// Berechnet ein Milit�rgeb�ude mit ein
71
void CalcTerritoryOfBuilding(const noBaseBuilding * const building);
73
// Liefert den Besitzer eines Punktes (mit absoluten Koordinaten, werden automatisch in relative umgerechnet!)
74
unsigned char GetOwner(const int x, const int y)
75
{ return nodes[(y-y1)*(x2-x1)+(x-x1)].owner; }
76
/// Liefert Radius mit dem der Punkt besetzt wurde
77
unsigned char GetRadius(const int x, const int y) const
78
{ return nodes[(y-y1)*(x2-x1)+(x-x1)].radius; }
80
// Korrigiert die Grenzen (schneidet vom aktuellen Territorium immer noch die �u�eren Punkte ab f�r die Grenzpf�hle)
35
/// Lage des Ausschnittes in der Karte
36
const int x1, y1, x2, y2;
37
/// Gr��e der Karte (wird aus x1,y1...) berechnet
38
const unsigned short width, height;
40
/// Beschreibung eines Knotenpunktes
43
/// Spieler-index (+1, da 0 = besitzlos!)
45
/// Entfernung vom Milit�rgeb�ude
49
GameWorldBase* const gwb;
52
/// Check whether the point x, y is part of the polygon
53
static bool IsPointInPolygon(GameWorldBase* gwb, std::vector< Point<MapCoord> > &polygon, MapCoord x, MapCoord y);
55
/// Testet einen Punkt, ob der neue Spieler ihn �bernehmen kann und �bernimmt ihn ggf.
56
void TestNode( int x, int y, const unsigned char player, const unsigned char radius, const bool check_barriers);
57
/// Unterfunktionen von AdjustBorders, vergleicht 2 Punkte, ob sie von unterschiedlichen Spielern sind und setzt
58
/// Punkt ggf. zu gar keinem Spieler, 2. Funktion wird f�r Punkte im 2er Abstand verwendet, da es dort ein bisschen anders l�uft!
59
void AdjustNodes(const unsigned short x1, const unsigned short y1, const unsigned short x2, const unsigned short y2);
60
void AdjustNodes2(const unsigned short x1, const unsigned short y1, const unsigned short x2, const unsigned short y2);
65
TerritoryRegion(const int x1, const int y1, const int x2, const int y2, GameWorldBase* const gwb);
68
static bool IsPointValid(GameWorldBase* gwb, std::vector< Point<MapCoord> > &polygon, MapCoord x, MapCoord y);
70
/// Berechnet ein Milit�rgeb�ude mit ein
71
void CalcTerritoryOfBuilding(const noBaseBuilding* const building);
73
// Liefert den Besitzer eines Punktes (mit absoluten Koordinaten, werden automatisch in relative umgerechnet!)
74
unsigned char GetOwner(const int x, const int y)
75
{ return nodes[(y - y1) * (x2 - x1) + (x - x1)].owner; }
76
/// Liefert Radius mit dem der Punkt besetzt wurde
77
unsigned char GetRadius(const int x, const int y) const
78
{ return nodes[(y - y1) * (x2 - x1) + (x - x1)].radius; }
80
// Korrigiert die Grenzen (schneidet vom aktuellen Territorium immer noch die �u�eren Punkte ab f�r die Grenzpf�hle)