~flosoft/s25rttr/trunk

« back to all changes in this revision

Viewing changes to src/TerritoryRegion.h

  • Committer: FloSoft
  • Date: 2014-04-25 15:35:50 UTC
  • Revision ID: flosoft@siedler25.org-20140425153550-9muu4vodhlqu58m0
committing subversion revision 9357 by FloSoft
astyle

modified:
s25client/trunk/
s25client/trunk/contrib/lua/lin32/include/
s25client/trunk/contrib/lua/lin64/include/
s25client/trunk/contrib/lua/mac/include/
s25client/trunk/contrib/lua/win32/include/
s25client/trunk/contrib/lua/win64/include/
s25client/trunk/driver/audio/SDL/src/
s25client/trunk/driver/src/
s25client/trunk/driver/video/GLFW/src/
s25client/trunk/driver/video/SDL/src/
s25client/trunk/driver/video/WinAPI/src/
s25client/trunk/src/
s25client/trunk/win32/
s25client/trunk/win32/prebuild-mutex/src/

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// $Id: TerritoryRegion.h 8374 2012-10-04 13:29:17Z marcus $
 
1
// $Id: TerritoryRegion.h 9357 2014-04-25 15:35:25Z FloSoft $
2
2
//
3
3
// Copyright (c) 2005 - 2011 Settlers Freaks (sf-team at siedler25.org)
4
4
//
32
32
 
33
33
class TerritoryRegion
34
34
{
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;
39
 
 
40
 
        /// Beschreibung eines Knotenpunktes
41
 
        struct TRNode
42
 
        {
43
 
                /// Spieler-index (+1, da 0 = besitzlos!)
44
 
                unsigned char owner;
45
 
                /// Entfernung vom Milit�rgeb�ude
46
 
                unsigned char radius;
47
 
        } * nodes;
48
 
        
49
 
        GameWorldBase * const gwb;
50
 
 
51
 
private:
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);
54
 
 
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);
61
 
 
62
 
public:
63
 
 
64
 
 
65
 
        TerritoryRegion(const int x1, const int y1, const int x2, const int y2, GameWorldBase * const gwb);
66
 
        ~TerritoryRegion();
67
 
 
68
 
        static bool IsPointValid(GameWorldBase *gwb, std::vector< Point<MapCoord> > &polygon, MapCoord x, MapCoord y);
69
 
 
70
 
        /// Berechnet ein Milit�rgeb�ude mit ein
71
 
        void CalcTerritoryOfBuilding(const noBaseBuilding * const building);
72
 
 
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; }
79
 
 
80
 
        // Korrigiert die Grenzen (schneidet vom aktuellen Territorium immer noch die �u�eren Punkte ab f�r die Grenzpf�hle)
81
 
        void AdjustBorders();
 
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;
 
39
 
 
40
        /// Beschreibung eines Knotenpunktes
 
41
        struct TRNode
 
42
        {
 
43
            /// Spieler-index (+1, da 0 = besitzlos!)
 
44
            unsigned char owner;
 
45
            /// Entfernung vom Milit�rgeb�ude
 
46
            unsigned char radius;
 
47
        }* nodes;
 
48
 
 
49
        GameWorldBase* const gwb;
 
50
 
 
51
    private:
 
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);
 
54
 
 
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);
 
61
 
 
62
    public:
 
63
 
 
64
 
 
65
        TerritoryRegion(const int x1, const int y1, const int x2, const int y2, GameWorldBase* const gwb);
 
66
        ~TerritoryRegion();
 
67
 
 
68
        static bool IsPointValid(GameWorldBase* gwb, std::vector< Point<MapCoord> > &polygon, MapCoord x, MapCoord y);
 
69
 
 
70
        /// Berechnet ein Milit�rgeb�ude mit ein
 
71
        void CalcTerritoryOfBuilding(const noBaseBuilding* const building);
 
72
 
 
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; }
 
79
 
 
80
        // Korrigiert die Grenzen (schneidet vom aktuellen Territorium immer noch die �u�eren Punkte ab f�r die Grenzpf�hle)
 
81
        void AdjustBorders();
82
82
 
83
83
 
84
84
};