Advanced Strategic Command
terraintype.h
Go to the documentation of this file.
1 /***************************************************************************
2  terraintype.h - description
3  -------------------
4  begin : Fri Jul 27 2001
5  copyright : (C) 2001 by Martin Bickel
6  email : bickel@asc-hq.org
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef terraintypeH
19  #define terraintypeH
20 
21  #include "graphics/surface.h"
22  #include "typen.h"
23  #include "mapitemtype.h"
24 
25  class OverviewMapImage;
26 
28  const int terrainPropertyNum = 39;
29 
30 
32  class TerrainBits : public BitSet {
33  public:
34  void setInt ( int terrain1 = 0, int terrain2 = 0 );
35  void read ( tnstream& stream );
36  void write ( tnstream& stream ) const;
37 
38  void appendToString( ASCString& text ) const;
39  };
40 
42  class TerrainAccess {
43  public:
44  TerrainAccess ( void ) ;
45 
48 
51 
54 
57 
62  int accessible ( const TerrainBits& bts ) const;
63 
64  void read ( tnstream& stream );
65  void write ( tnstream& stream ) const;
66  void runTextIO ( PropertyContainer& pc );
67 
68  ASCString toString( bool brief = true) const;
69  };
70 
71 
72  typedef class TerrainType* pterraintype;
73 
75  class TerrainType : public MapItemType, public LoadableItemType {
76  public:
77  int id;
78 
80  vector<int> secondaryIDs;
81 
82  int getID() const { return id; };
84  ASCString getName() const { return name; };
85 
86  class MoveMalus: public vector<int> {
87  public: MoveMalus();
88  #ifdef _vector_at_broken_
89  int& at(size_t pos) { return operator[](pos); };
90  const int& at(size_t pos) const { return operator[](pos); };
91  #endif
92  // void read ( tnstream& stream ) { read ( stream, -1 ); };
93  void read ( tnstream& stream, int defaultValue, int moveMalusCount = -1 );
94  void write ( tnstream& stream ) const;
95  };
96 
97  class Weather: public LoadableItemType {
99  OverviewMapImage* quickView;
100  ASCString originalImageFilename;
101  public:
104 
107 
110 
113 
116 
118  void paint ( Surface& s, SPoint pos );
119 
120 
122  int bi_pict;
123 
126 
129 
131 
132  Weather ( TerrainType* base ) : quickView ( NULL ), terraintype ( base ) {};
133  ~Weather();
134  void runTextIO ( PropertyContainer& pc );
135  void read ( tnstream& stream );
136  void read ( tnstream& stream, int version );
137  void write ( tnstream& stream ) const;
138  int getMemoryFootprint() const;
139  };
141 
142  TerrainType();
143  void runTextIO ( PropertyContainer& pc );
144  void read ( tnstream& stream );
145  void write ( tnstream& stream ) const;
146  int getMemoryFootprint() const;
147  ~TerrainType();
148  };
149 
150 
151  extern const char* terrainProperty[] ;
152 
175 
177 
178 
179 #endif
The type of a field.
Definition: terraintype.h:75
void read(tnstream &stream, int defaultValue, int moveMalusCount=-1)
void write(tnstream &stream) const
write the binary representation of this item to the given stream
Weather(TerrainType *base)
Definition: terraintype.h:132
ASCString name
Definition: terraintype.h:82
void write(tnstream &stream) const
class TerrainType * pterraintype
Definition: terraintype.h:72
TerrainType * terraintype
pointer to the outer structure
Definition: terraintype.h:128
Weather * weather[cwettertypennum]
Definition: terraintype.h:140
const char * terrainProperty[]
Definition: terraintype.cpp:30
void appendToString(ASCString &text) const
The interface for all kinds of IO stream.
void read(tnstream &stream)
read the binary representation of this item from the given stream
TerrainBits art
the properties defining which unit can move onto this field and which not
Definition: terraintype.h:125
void write(tnstream &stream) const
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
const int terrainPropertyNum
the number of bits that specify the terrain of a field
Definition: terraintype.h:28
void read(tnstream &stream)
TerrainType::MoveMalus move_malus
the movement cost for the various units to move across this field
Definition: terraintype.h:115
const OverviewMapImage * getQuickView()
void runTextIO(PropertyContainer &pc)
Definition: terraintype.cpp:96
void runTextIO(PropertyContainer &pc)
registers the properties of this item for loading/writing into asctxt files
This class is used by buildings, vehicles and objects to specify which terrain it can move to / be bu...
Definition: terraintype.h:42
the properties of a terrain describing which units can move onto this field and which can't ...
Definition: terraintype.h:32
The base class for everything that can be placed on a map field.
Definition: mapitemtype.h:16
ASCString toString(bool brief=true) const
TerrainBits terrainreq
ALL these bits must be set in the terrain.
Definition: terraintype.h:50
An abstract base class that provides the interface for all kinds of items that ASC loads from disk...
Definition: typen.h:287
Surface image
the image of the field
Definition: terraintype.h:103
TerrainBitTypes
Definition: terraintype.h:153
TerrainBits terrainnot
if one of these bits is set, the field will NOT be accessible
Definition: terraintype.h:53
ASCString getName() const
Definition: terraintype.h:84
int accessible(const TerrainBits &bts) const
checks whether a field with the given terrainbits is accessible.
vector< int > secondaryIDs
when loading a file and these IDs are encountered, this object will be used.
Definition: terraintype.h:80
SDLmm::SPoint SPoint
Definition: surface.h:27
void paint(Surface &s, SPoint pos)
displays the image on the screen coordinates x1/y1
TerrainBits terrainkill
if a terrain is not accessible AND one of these bits is matched, the unit will be destroyed ...
Definition: terraintype.h:56
int bi_pict
the image index from the graphic set. -1 if graphics is not from graphic set.
Definition: terraintype.h:122
int basicjamming
the view obstraction of the field
Definition: terraintype.h:112
void read(tnstream &stream)
read the binary representation of this item from the given stream
void read(tnstream &stream)
Definition: terraintype.cpp:74
void setInt(int terrain1=0, int terrain2=0)
TerrainBits terrain
at least one of these bits must match on of the terrain
Definition: terraintype.h:47
void write(tnstream &stream) const
Definition: terraintype.cpp:86
int getMemoryFootprint() const
int getID() const
Definition: terraintype.h:82
the image for a TerrainType that is shown on the small map
int getMemoryFootprint() const
TerrainBits getTerrainBitType(TerrainBitTypes tbt)
int defensebonus
the defense bonus for the unit standing on this field.
Definition: terraintype.h:106
std::bitset< 64 > BitSet
Definition: basictypes.h:48
void runTextIO(PropertyContainer &pc)
registers the properties of this item for loading/writing into asctxt files
void write(tnstream &stream) const
write the binary representation of this item to the given stream
const int cwettertypennum
The number of different weather.
Definition: typen.h:61
int attackbonus
the attack bonus for the unit standing on this field.
Definition: terraintype.h:109