Advanced Strategic Command
Go to the documentation of this file.
1 /***************************************************************************
2  buildings.h - description
3  -------------------
4  begin : Sat Feb 17 2001
5  copyright : (C) 2001 by Martin Bickel
6  email :
7  ***************************************************************************/
13 /***************************************************************************
14  * *
15  * This program is free software; you can redistribute it and/or modify *
16  * it under the terms of the GNU General Public License as published by *
17  * the Free Software Foundation; either version 2 of the License, or *
18  * (at your option) any later version. *
19  * *
20  ***************************************************************************/
22 #ifndef buildingsH
23  #define buildingsH
25  #include "typen.h"
26  #include "containerbase.h"
27  #include "ascstring.h"
28  #include "buildingtype.h"
29  #include "mapalgorithms.h"
31 class MapField;
38 class Building : public ContainerBase {
39  MapCoordinate entryPosition;
41  Uint8 _completion;
43  friend class tprocessminingfields;
45  bool viewOnMap;
47  public:
48  const BuildingType* typ;
50  const BuildingType* getType() const { return typ; };
54  int ammo[waffenanzahl];
63  bool visible;
65  bool getVisible() { return visible; };
68  AiValue* aiparam[8];
70  Building( GameMap* map, const MapCoordinate& entryPosition, const BuildingType* type , int player, bool setupImages = true, bool chainToField = true);
74  bool canRepair ( const ContainerBase* item ) const;
76  static Building* newFromStream ( GameMap* gamemap, tnstream& stream, bool chainToField = true );
77  void write ( tnstream& stream, bool includeLoadedUnits = true ) const;
78  void read ( tnstream& stream );
79  private:
80  void readData ( tnstream& stream, int version );
81  public:
84  void execnetcontrol ( void );
85  // int getmininginfo ( int res );
87  int putResource ( int amount, int resourcetype, bool queryonly, int scope = 1, int player = -1 );
88  int getResource ( int amount, int resourcetype, bool queryonly, int scope = 1, int player = -1 );
89  int getAvailableResource ( int amount, int resourcetype, int scope = 1 ) const;
90  Resources putResource ( const Resources& res, bool queryonly, int scope = 1, int player = -1 ) { return ContainerBase::putResource ( res, queryonly, scope, player ); };
91  Resources getResource ( const Resources& res, bool queryonly, int scope = 1, int player = -1 ) { return ContainerBase::getResource ( res, queryonly, scope, player ); };
97  int getIdentification() const;
101  const Surface& getPicture ( const BuildingType::LocalCoordinate& localCoordinate ) const;
103  void paintSingleField ( Surface& s, SPoint imgpos, BuildingType::LocalCoordinate pos ) const;
105  virtual Surface getImage() const;
108  bool isBuilding() const { return true; };
112  void convert ( int player, bool recursive = true );
115  void registerForNewOwner( int player );
119  void addview();
122  void resetview();
125  void removeview();
129  bool isViewing ( ) const { return viewOnMap; };
133  int getArmor() const;
136  MapField* getEntryField() const;
139  MapCoordinate3D getEntry ( ) const;
142  MapField* getField( const BuildingType::LocalCoordinate& localCoordinates ) const;
145  MapCoordinate getFieldCoordinates( const BuildingType::LocalCoordinate& localCoordinates ) const;
152  MapCoordinate3D getPosition ( ) const { return getEntry(); };
158  int chainbuildingtofield ( const MapCoordinate& entryPos, bool setupImages = true );
161  int unchainbuildingfromfield ( void );
164  int getCompletion() const { return _completion; };
171  void setCompletion ( int completion, bool setupImages = true );
174  void endRound( void );
177  ASCString getName() const;
180  int getAmmo( int type, int num, bool queryOnly );
181  int getAmmo( int type, int num ) const;
182  int putAmmo( int type, int num, bool queryOnly );
183  int maxAmmo( int type ) const { return maxint; };
187  int getHeight() const { return typ->height; };
190  ~Building();
192  virtual int repairableDamage() const;
194  int getMemoryFootprint() const;
196  protected:
199  virtual void postRepair ( int oldDamage, bool autoRepair );
200  vector<MapCoordinate> getCoveredFields();
201 };
204 extern void doresearch ( GameMap* actmap, int player );
205 extern ASCString getBuildingReference ( Building* bld );
207 #endif
int maxAmmo(int type) const
Definition: buildings.h:183
int getIdentification() const
Definition: buildings.cpp:100
bool canRepair(const ContainerBase *item) const
checks whether the item can be repaired provided that it is in range
Definition: buildings.cpp:93
The base class for buildings and vehicles.
A mathematical matrix for transforming Resources instance (which is mathematically a vector) into a d...
Definition: typen.h:158
virtual int putResource(int amount, int resourcetype, bool queryonly, int scope=1, int player=-1)=0
scope: 0 = local 1 = resource network 2 = global in all buildings 3 = map wide pool( used only intern...
const BuildingType * typ
Definition: buildings.h:48
const int waffenanzahl
The number of different weapon types.
Definition: typen.h:58
ASCString getName() const
returns a name for the building. If the building itself has a name, it will be returned. If it doesn't, the name of the building type will be returned.
Definition: buildings.cpp:711
void paintSingleField(Surface &s, SPoint imgpos, BuildingType::LocalCoordinate pos) const
Definition: buildings.cpp:198
MapCoordinate getFieldCoordinates(const BuildingType::LocalCoordinate &localCoordinates) const
returns the absolute map coordinate of the given part of the building
Definition: buildings.cpp:417
int chainbuildingtofield(const MapCoordinate &entryPos, bool setupImages=true)
registers the building at the given position on the map
Definition: buildings.cpp:268
void read(tnstream &stream)
Definition: buildings.cpp:567
A local coordinate referencing a single field that a building covers.
Definition: buildingtype.h:57
MapCoordinate3D getEntry() const
returns the position of the buildings entry
Definition: buildings.cpp:410
void removeview()
Removes the view and jamming of the building from the player's global radar field.
Definition: buildings.cpp:371
BuildingType::LocalCoordinate getLocalCoordinate(const MapCoordinate &field) const
converts a global coordinate into a local coordinate.
Definition: buildings.cpp:423
ASCString getBuildingReference(Building *bld)
Definition: buildings.cpp:881
The interface for all kinds of IO stream.
a single field of the map
Definition: mapfield.h:26
int getCompletion() const
returns the completion of the building.
Definition: buildings.h:164
MapField * getEntryField() const
returns the field the buildings entry is standing on
Definition: buildings.cpp:405
int getAmmo(int type, int num, bool queryOnly)
Definition: buildings.cpp:719
int netcontrol
a bitmapped variable containing the status of the resource-net connection.
Definition: buildings.h:57
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
int getAvailableResource(int amount, int resourcetype, int scope=1) const
Definition: controls.cpp:260
int getMemoryFootprint() const
Definition: buildings.cpp:768
The value of a unit for the AI.
virtual int getResource(int amount, int resourcetype, bool queryonly, int scope=1, int player=-1)=0
The class describing properties that are common to all buildings of a certain kind.
Definition: buildingtype.h:35
virtual int repairableDamage() const
returns the amount of damage that can still be repaired this turn
Definition: buildings.cpp:78
void endRound(void)
hook that is called when a turn ends
Definition: buildings.cpp:750
int putResource(int amount, int resourcetype, bool queryonly, int scope=1, int player=-1)
scope: 0 = local 1 = resource network 2 = global in all buildings 3 = map wide pool( used only intern...
Definition: controls.cpp:226
virtual Surface getImage() const
returns an image for the Container.
Definition: buildings.cpp:229
Coordinate on the twodimensional map.
Definition: typen.h:202
void resetview()
resets the internal view state, so that addview() can be executed again
Definition: buildings.cpp:365
MapField * getField(const BuildingType::LocalCoordinate &localCoordinates) const
returns the pointer to the field which the given part of the building is standing on ...
Definition: buildings.cpp:399
int unchainbuildingfromfield(void)
unregister the building from the map position
Definition: buildings.cpp:332
virtual void postRepair(int oldDamage, bool autoRepair)
is called after a repair is performed. Vehicles use this to reduce their experience.
Definition: buildings.cpp:88
int ammo[waffenanzahl]
the ammo that is stored in the building
Definition: buildings.h:50
The interface for the buildingtype class.
void doresearch(GameMap *actmap, int player)
Definition: buildings.cpp:799
void execnetcontrol(void)
executes the resource net operations, like filling the tanks with fuel.
Definition: controls.cpp:194
void setCompletion(int completion, bool setupImages=true)
Sets the level of completion of the building.
Definition: buildings.cpp:259
int putAmmo(int type, int num, bool queryOnly)
Definition: buildings.cpp:737
SDLmm::SPoint SPoint
Definition: surface.h:27
const ResourceMatrix & getRepairEfficiency() const
when a ContainerBase is repair by this ContainerBase, the default cost can be customized with this ma...
Definition: buildings.h:198
GameMap * gamemap
the map that this container is placed on
Definition: containerbase.h:52
int getHeight() const
returns the bitmapped level of height. Only one bit will be set, of course
Definition: buildings.h:187
int connection
bitmapped: are there events that are triggered by actions affecting this building ...
Definition: buildings.h:60
Resources getResource(const Resources &res, bool queryonly, int scope=1, int player=-1)
Definition: buildings.h:91
int lastmineddist
Definition: buildings.h:72
int height
the levels of height which this unit can enter
Resources actstorage
the current storage of Resources
Definition: buildings.h:91
void convert(int player, bool recursive=true)
changes the building's owner.
Definition: buildings.cpp:105
ResourceMatrix repairEfficiency
Definition: buildings.h:197
const Surface & getPicture(const BuildingType::LocalCoordinate &localCoordinate) const
returns the picture of the building. It may depend on the current weather of the fields the building ...
Definition: buildings.cpp:188
friend class tprocessminingfields
Definition: buildings.h:43
int getResource(int amount, int resourcetype, bool queryonly, int scope=1, int player=-1)
Definition: controls.cpp:243
MapCoordinate3D getPosition3D() const
returns the position of the buildings entry
Definition: buildings.cpp:385
Coordinate on the map including height.
Definition: typen.h:238
#define maxint
Definition: typen.h:462
GameMap * actmap
Definition: spfst.cpp:64
The parent class of Vehicle and Building; The name Container originates from Battle Isle...
Definition: containerbase.h:40
An actual building on the map, which references a BuildingType Buildings have an owner,.
Definition: buildings.h:38
Resources are basically the currency of ASC.
Definition: typen.h:97
static Building * newFromStream(GameMap *gamemap, tnstream &stream, bool chainToField=true)
Definition: buildings.cpp:523
bool isViewing() const
returns true if the buildings' view is currently added to the maps global visibility.
Definition: buildings.h:129
bool visible
is the building visible? Building can be made invisible, but this feature should be used only in some...
Definition: buildings.h:63
int getArmor() const
returns the armor of the building.
Definition: buildings.cpp:393
Resources putResource(const Resources &res, bool queryonly, int scope=1, int player=-1)
Definition: buildings.h:90
bool getVisible()
Definition: buildings.h:65
vector< MapCoordinate > getCoveredFields()
Definition: buildings.cpp:757
Building(GameMap *map, const MapCoordinate &entryPosition, const BuildingType *type, int player, bool setupImages=true, bool chainToField=true)
Definition: buildings.cpp:46
MapCoordinate3D getPosition() const
returns the position of the buildings entry
Definition: buildings.h:152
const BuildingType * getType() const
Definition: buildings.h:50
void addview()
Adds the view and jamming of the building to the player's global radar field.
Definition: buildings.cpp:353
void registerForNewOwner(int player)
this is a low level functions that changes the registration in the map. It's called by convert(int...
Definition: buildings.cpp:162
The map. THE central structure of ASC, which holds everything not globally available together...
Definition: gamemap.h:182
bool isBuilding() const
Definition: buildings.h:108
AiValue * aiparam[8]
Definition: buildings.h:65
void write(tnstream &stream, bool includeLoadedUnits=true) const
Definition: buildings.cpp:451