Advanced Strategic Command
resourcenet.h
Go to the documentation of this file.
1 /***************************************************************************
2  resourcenet.cpp - description
3  -------------------
4  begin : Tue Jan 28 2001
5  copyright : (C) 2001 by Martin Bickel
6  email : bickel@asc-hq.org
7  ***************************************************************************/
8 
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  ***************************************************************************/
21 
22 
23 #ifndef resourcenetH
24  #define resourcenetH
25 
26 #include "gamemap.h"
27 
29 class MapNetwork {
30  static int instancesrunning;
31  protected:
33  int pass;
34 
36 
37  virtual int fieldavail ( int x, int y ) = 0;
38  virtual int searchfinished ( void ) = 0;
39  virtual void checkvehicle ( Vehicle* v ) = 0;
40  virtual void checkbuilding ( Building* b ) = 0;
41  virtual int globalsearch ( void ) = 0;
42 
43  virtual void searchbuilding ( int x, int y );
44  virtual void searchvehicle ( int x, int y );
45  virtual void searchfield ( int x, int y, int dir );
46  void searchAllVehiclesNextToBuildings ( int player );
47  public:
49  virtual void start ( int x, int y );
50  MapNetwork ( GameMap* gamemap, int checkInstances = 1 );
51  virtual ~MapNetwork();
52  };
53 
54 class ResourceNet : public MapNetwork {
55  public:
56  ResourceNet ( GameMap* gamemap, int _scope = -1 ) : MapNetwork ( gamemap, _scope != 0 ), resourcetype(-1), scope(_scope) {};
57  protected:
58  int resourcetype;
59  int scope;
60 
61  virtual int fieldavail ( int x, int y );
62  virtual int globalsearch ( void ) { return scope; };
63  };
64 
66  protected:
67  void checkvehicle ( Vehicle* v ) {};
68  void checkbuilding ( Building* b ) { buildingContainer.push_back ( b ); };
69  int searchfinished ( void ) { return false; };
70 
71  public:
72  typedef vector<Building*> BuildingContainer;
74  GetConnectedBuildings ( BuildingContainer& buildingContainer_, GameMap* gamemap, int resourceType ) : ResourceNet ( gamemap, gamemap->isResourceGlobal(resourceType)?2:1), buildingContainer ( buildingContainer_) { resourcetype = 0; };
75 };
76 
78  protected:
79  int need;
80  int got;
81  int queryonly;
82  int player;
83 
84  virtual int searchfinished ( void );
85 
86  public:
87  StaticResourceNet ( GameMap* gamemap, int scope = -1 ) : ResourceNet ( gamemap, scope ) {};
88  int getresource ( int x, int y, int resource, int _need, int _queryonly, int _player, int _scope );
89  /* _scope: 0 : only this field
90  1 : net
91  2 : global
92  */
93  };
94 
96  protected:
97  int tributegot[3][8];
98  virtual void checkvehicle ( Vehicle* v );
99  virtual void checkbuilding ( Building* b );
100  virtual void start ( int x, int y );
101  public:
102  GetResource ( GameMap* gamemap, int scope = -1 );
103  };
104 
106  protected:
107  virtual void checkbuilding ( Building* b );
108  virtual void checkvehicle ( Vehicle* v ) {};
109  virtual void start ( int x, int y );
110  public:
111  PutResource ( GameMap* gamemap, int scope = -1 ) : StaticResourceNet ( gamemap, scope ) {};
112  };
113 
115  protected:
118  virtual void checkbuilding ( Building* b );
119  virtual void checkvehicle ( Vehicle* v ) {};
120  virtual void start ( int x, int y );
121  public:
122  PutTribute ( GameMap* gamemap ) : StaticResourceNet( gamemap ) {};
123  int puttribute ( Building* start, int resource, int _queryonly, int _forplayer, int _fromplayer, int _scope );
124  };
125 
126 
128  protected:
129  virtual void checkbuilding ( Building* b );
130  virtual void checkvehicle ( Vehicle* v ) {};
131  virtual void start ( int x, int y );
132  virtual int searchfinished ( void ) { return 0; };
133  public:
134  GetResourceCapacity( GameMap* gamemap ) : StaticResourceNet ( gamemap ) {};
135  };
136 
138  protected:
139  int got;
140  int player;
141 
142  virtual int searchfinished ( void ) { return 0; };
143 
144  public:
145  int getresource ( int x, int y, int resource, int _player, int _scope );
146  /* _scope: 0 : only this field
147  1 : net
148  2 : global
149  */
150  ResourceChangeNet ( GameMap* gamemap ) : ResourceNet ( gamemap ) {};
151 
152  };
153 
154 
156  protected:
157  virtual void checkbuilding ( Building* b );
158  virtual void checkvehicle ( Vehicle* v );
159  public:
160  GetResourcePlus ( GameMap* gamemap ) : ResourceChangeNet ( gamemap ) {};
161  };
162 
164  protected:
165  virtual void checkbuilding ( Building* b );
166  virtual void checkvehicle ( Vehicle* v ) {};
167  public:
168  GetResourceUsage ( GameMap* gamemap ) : ResourceChangeNet ( gamemap ) {};
169  };
170 
171 extern void transfer_all_outstanding_tribute( Player& player );
172 
173 extern sigc::signal<void> tributeTransferred;
174 
175 extern bool compareMapResources( GameMap* currentMap, GameMap* replaymap, int player, ASCString* log );
176 
177 
178 #endif
virtual void checkbuilding(Building *b)
MapNetwork(GameMap *gamemap, int checkInstances=1)
void checkvehicle(Vehicle *v)
Definition: resourcenet.h:67
GetResourcePlus(GameMap *gamemap)
Definition: resourcenet.h:160
GetResourceCapacity(GameMap *gamemap)
Definition: resourcenet.h:134
virtual int searchfinished(void)
Definition: resourcenet.h:132
virtual void checkbuilding(Building *b)
int getresource(int x, int y, int resource, int _player, int _scope)
sigc::signal< void > tributeTransferred
Definition: resourcenet.cpp:32
virtual void start(int x, int y)
int searchfinished(void)
Definition: resourcenet.h:69
virtual int fieldavail(int x, int y)=0
int getresource(int x, int y, int resource, int _need, int _queryonly, int _player, int _scope)
GetConnectedBuildings(BuildingContainer &buildingContainer_, GameMap *gamemap, int resourceType)
Definition: resourcenet.h:74
ResourceNet(GameMap *gamemap, int _scope=-1)
Definition: resourcenet.h:56
int puttribute(Building *start, int resource, int _queryonly, int _forplayer, int _fromplayer, int _scope)
virtual void checkvehicle(Vehicle *v)
GameMap * actmap
Definition: resourcenet.h:32
virtual int globalsearch(void)
Definition: resourcenet.h:62
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
virtual int fieldavail(int x, int y)
virtual int globalsearch(void)=0
virtual void checkbuilding(Building *b)
virtual void start(int x, int y)
StaticResourceNet(GameMap *gamemap, int scope=-1)
Definition: resourcenet.h:87
virtual void searchvehicle(int x, int y)
virtual void checkvehicle(Vehicle *v)
Definition: resourcenet.h:119
virtual void searchbuilding(int x, int y)
Base class for the management of resource networks and globally stored resources. ...
Definition: resourcenet.h:29
void searchAllVehiclesNextToBuildings(int player)
virtual void checkvehicle(Vehicle *v)
Definition: resourcenet.h:130
void log(const Vehicle *attacker, const Vehicle *attackee)
Definition: attack.cpp:417
Coordinate on the twodimensional map.
Definition: typen.h:202
Definition of THE central asc class: GameMap.
BuildingContainer & buildingContainer
Definition: resourcenet.h:73
virtual void checkvehicle(Vehicle *v)
PutResource(GameMap *gamemap, int scope=-1)
Definition: resourcenet.h:111
virtual void checkbuilding(Building *b)
bool compareMapResources(GameMap *currentMap, GameMap *replaymap, int player, ASCString *log)
virtual void checkvehicle(Vehicle *v)=0
PutTribute(GameMap *gamemap)
Definition: resourcenet.h:122
virtual void checkbuilding(Building *b)=0
virtual int searchfinished(void)
void transfer_all_outstanding_tribute(Player &player)
int tributegot[3][8]
Definition: resourcenet.h:97
int resourcetype
Definition: resourcenet.h:56
virtual void searchfield(int x, int y, int dir)
Definition: resourcenet.cpp:34
virtual void checkvehicle(Vehicle *v)
Definition: resourcenet.h:108
void checkbuilding(Building *b)
Definition: resourcenet.h:68
virtual void checkbuilding(Building *b)
virtual void start(int x, int y)
Building * startbuilding
Definition: resourcenet.h:117
virtual void start(int x, int y)
virtual void start(int x, int y)
GetResourceUsage(GameMap *gamemap)
Definition: resourcenet.h:168
virtual void checkbuilding(Building *b)
An actual building on the map, which references a BuildingType Buildings have an owner,.
Definition: buildings.h:38
MapCoordinate startposition
Definition: resourcenet.h:35
the different players in ASC. There may be 8 players (0..7) and neutral units (8) ...
Definition: player.h:99
GetResource(GameMap *gamemap, int scope=-1)
virtual void checkvehicle(Vehicle *v)
Definition: resourcenet.h:166
int targplayer
Definition: resourcenet.h:116
virtual ~MapNetwork()
ResourceChangeNet(GameMap *gamemap)
Definition: resourcenet.h:150
virtual int searchfinished(void)
Definition: resourcenet.h:142
The map. THE central structure of ASC, which holds everything not globally available together...
Definition: gamemap.h:182
virtual int searchfinished(void)=0
vector< Building * > BuildingContainer
Definition: resourcenet.h:69