File: spfst.h

package info (click to toggle)
asc 2.6.1.0-9
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 81,740 kB
  • sloc: cpp: 158,704; sh: 11,544; ansic: 6,736; makefile: 604; perl: 138
file content (185 lines) | stat: -rw-r--r-- 7,627 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/*! \file spfst.h
    \brief map accessing and usage routines used by ASC and the mapeditor

    spfst comes from german "Spielfeldsteuerung" :-)
*/

/*
    This file is part of Advanced Strategic Command; http://www.asc-hq.de
    Copyright (C) 1994-2010  Martin Bickel  and  Marc Schellenberger

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; see the file COPYING. If not, write to the 
    Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
    Boston, MA  02111-1307  USA
*/

#ifndef spfstH
  #define spfstH

 #include <sigc++/sigc++.h>
  
  
  #include "typen.h"
  #include "gamemap.h"
  

//! puts a building onto the map. To be used by the map editor! For ingame usage, see ConstructBuildingCommand or SpawnBuilding
extern void  putbuilding( GameMap* gamemap,
                          const MapCoordinate& entryPosition,
                         int          color,
                         const BuildingType* buildingtyp,
                         int          completion,
                         int          ignoreunits = 0 ); 


//! recalculates the connection (like road interconnections) of all objects on the map
extern void  calculateallobjects( GameMap* m );

/** recalculates the connection (like road interconnections) of an object
      \param x The x coordinate of the field
      \param y The y coordinate of the field
      \param mof Should the neighbouring fields be modified if necessary
      \param obj The objecttype that is to be aligned on this field
      \param gamemap the map that the object is on
*/
extern void  calculateobject(int  x,
                             int  y,
                             bool mof,
                             const ObjectType* obj,
                             GameMap* gamemap  );

extern void  calculateobject( const MapCoordinate& pos, 
                             bool mof,
                             const ObjectType* obj,
                             GameMap* gamemap  );



/*! tests if the vehicle can move onto the field
   
   \param uheight the level of height for which the check should be done. Use -2 to use the current height of the unit
   \retval 0 unit cannot move there
   \retval 1 unit can pass over the field
   \retval 2 unit can stop its movement there
*/
extern int fieldAccessible( const MapField*        field,
                            const Vehicle*     vehicle,
                            int  uheight = -2,
                            const bool* attacked = NULL,
                            bool ignoreVisibility = false );


/** removes all units that cannot exist any more, either due to invalid terrin
    (like tanks on melting ice) or too much wind (eg. hoovercrafts in a storm) */
extern void  checkunitsforremoval( GameMap* gamemap );

//! removes all objects that cannot exist where they currently are (terrainaccess)
extern void checkobjectsforremoval( GameMap* gamemap );

//! returns the maximum wind speed that the unit can endure
extern int          getmaxwindspeedforunit ( const Vehicle* eht );

/** Wind may be different at different heights. This function returns the index 
    for the wind array. If uheight != -1 it is assumed the unit was uheight instead
    the actual level of height */
extern int          getwindheightforunit   ( const Vehicle* eht, int uheight = -1 );


/** Checks if the unit can drive on the field
    \param field the field that the unit is checked again
    \param vehicle the unit who accessabilit to field is tested
    \param uheight if != -1, the unit is assumed to be on this height instead of the actual one.
    \returns 0=unit cannot access this field; 
             1=unit can move across this field but cannot keep standing there
             2=unit can move and stand there
*/
extern int          terrainaccessible (  const MapField* field, const Vehicle* vehicle, int uheight = -1 );

/** Checks if the unit can drive on the field
    \param field the field that the unit is checked again
    \param vehicle the unit who accessabilit to field is tested
    \param uheight if != -1, the unit is assumed to be on this height instead of the actual one.
    \returns 0=unit cannot access this field;
             1=unit can move across this field but cannot keep standing there;
             2=unit can move and stand there;
             < 0 unit cannot access this field, because of:
                  -1   very deep water required to submerge deep
                  -2   deep water required to submerge
                  -3   unit cannot drive onto terrain
*/
extern int          terrainaccessible2 ( const MapField*        field, const Vehicle* vehicle, int uheight = -1 );


/** Checks if the field can be accessed
    \returns 0=unit cannot access this field;
             1=unit can move across this field but cannot keep standing there;
             2=unit can move and stand there;
             < 0 unit cannot access this field, because of:
                  -1   very deep water required to submerge deep
                  -2   deep water required to submerge
                  -3   unit cannot drive onto terrain
*/
int          terrainaccessible2 ( const MapField*        field, const TerrainAccess& terrainAccess, int uheight );


/*!
  \brief calculate the height difference between two levels of height.

  Since floating and ground based are assumed to be the same effective height, a simple subtraction isn't sufficient.
  Height is a numeric (and not bitmapped) value
 */
extern int getheightdelta ( const ContainerBase* c1, const ContainerBase* c2 );

  /*!
    evaluates the visibility of a field
    \param pe the field to be evaluated
    \param player the player who is 'looking'
  */
//! {@ 
  extern bool fieldvisiblenow( const MapField* pe, Vehicle* veh, int player   );
  inline bool fieldvisiblenow( const MapField* pe, int player ) { return fieldvisiblenow( pe, NULL, player); };
  inline bool fieldvisiblenow( const MapField* pe, Vehicle* veh  ) { return fieldvisiblenow( pe, veh, pe->getMap()->actplayer); };
  inline bool fieldvisiblenow( const MapField* pe ) { return fieldvisiblenow( pe, pe->getMap()->actplayer);};
//! }@

  /*!
    evaluates the visibility of a field
    \param pe the field to be evaluated
    \param player the player who is 'looking'; without player the active player will be used
   */
//! {@ 
  extern VisibilityStates fieldVisibility  ( const MapField* pe );
  extern VisibilityStates fieldVisibility  ( const MapField* pe, int player );
//! }@


extern sigc::signal<void> repaintMap;
extern sigc::signal<void> repaintDisplay;
extern sigc::signal<void> updateFieldInfo;
extern sigc::signal<void> cursorMoved;

//! the view of the player onto the map changed, for example because he scrolled the map
extern sigc::signal<void> viewChanged;
extern sigc::signal<void,GameMap*> mapChanged;
extern sigc::signal<void,ContainerBase*> showContainerInfo;
extern sigc::signal<void,VehicleType*> showVehicleTypeInfo;
extern sigc::signal<bool> idleEvent;
extern sigc::signal<void, const Context&> fieldCrossed;

extern void displaymap();


#endif