Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 399 lines (336 sloc) 8.995 kb
b87f2b0 Initial revision
jtraub authored
1 // START A3HEADER
2 //
3 // This source file is part of the Atlantis PBM game program.
4 // Copyright (C) 1995-1999 Geoff Dunbar
5 //
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program, in the file license.txt. If not, write
18 // to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 // Boston, MA 02111-1307, USA.
20 //
21 // See the Atlantis Project web page for details:
22 // http://www.prankster.com/project
23 //
24 // END A3HEADER
25 // MODIFICATIONS
26 // Date Person Comments
27 // ---- ------ --------
28 // 2000/MAR/16 Davis Kulis Added a new reporting Template.
29 // 2000/MAR/21 Azthar Septragen Added roads.
30 #ifndef REGION_CLASS
31 #define REGION_CLASS
32
33 class ARegion;
34 class ARegionList;
35
36 #include "gamedefs.h"
37 #include "gameio.h"
38 #include "faction.h"
39 #include "alist.h"
40 #include "unit.h"
41 #include "fileio.h"
42 #include "production.h"
43 #include "market.h"
44 #include "object.h"
45
46 /* Weather Types */
47 enum {
d247cd4 Roads now allow you to move into an adjacent combat as well.
jtraub authored
48 W_NORMAL,
49 W_WINTER,
50 W_MONSOON,
51 W_BLIZZARD
b87f2b0 Initial revision
jtraub authored
52 };
53
3c3b1e0 Reorganized terrain data structures slightly to make things easier
jtraub authored
54 struct Product
55 {
56 int product;
57 int chance;
58 int amount;
59 };
60
b87f2b0 Initial revision
jtraub authored
61 class TerrainType
62 {
d247cd4 Roads now allow you to move into an adjacent combat as well.
jtraub authored
63 public:
64 char * name;
65 int similar_type;
66
67 enum {
68 RIDINGMOUNTS = 0x1,
69 FLYINGMOUNTS = 0x2,
70 };
71 int flags;
72
73 int pop;
74 int wages;
75 int economy;
76 int movepoints;
77 Product prods[7];
78 // Race information
79 // A hex near water will have either one of the normal races or one
80 // of the coastal races in it. Non-coastal hexes will only have one
81 // of the normal races.
82 int races[4];
83 int coastal_races[3];
84 int wmonfreq;
85 int smallmon;
86 int bigmon;
87 int humanoid;
88 int lairChance;
89 int lairs[6];
b87f2b0 Initial revision
jtraub authored
90 };
91
d247cd4 Roads now allow you to move into an adjacent combat as well.
jtraub authored
92 extern TerrainType *TerrainDefs;
b87f2b0 Initial revision
jtraub authored
93
94 class Location : public AListElem
95 {
d247cd4 Roads now allow you to move into an adjacent combat as well.
jtraub authored
96 public:
97 Unit * unit;
98 Object * obj;
99 ARegion * region;
b87f2b0 Initial revision
jtraub authored
100 };
101
d247cd4 Roads now allow you to move into an adjacent combat as well.
jtraub authored
102 Location *GetUnit(AList *,int);
b87f2b0 Initial revision
jtraub authored
103
d247cd4 Roads now allow you to move into an adjacent combat as well.
jtraub authored
104 int AGetName(int town);
105 char *AGetNameString(int name);
b87f2b0 Initial revision
jtraub authored
106
107 class ARegionPtr : public AListElem
108 {
d247cd4 Roads now allow you to move into an adjacent combat as well.
jtraub authored
109 public:
110 ARegion * ptr;
b87f2b0 Initial revision
jtraub authored
111 };
112
d247cd4 Roads now allow you to move into an adjacent combat as well.
jtraub authored
113 ARegionPtr *GetRegion(AList *,int);
b87f2b0 Initial revision
jtraub authored
114
115 class Farsight : public AListElem
116 {
d247cd4 Roads now allow you to move into an adjacent combat as well.
jtraub authored
117 public:
118 Farsight();
a0d192c Added Stephen Baillies transit patch
jtraub authored
119
d247cd4 Roads now allow you to move into an adjacent combat as well.
jtraub authored
120 Faction *faction;
121 Unit *unit;
122 int level;
123 int exits_used[NDIRS];
b87f2b0 Initial revision
jtraub authored
124 };
125
126 Farsight *GetFarsight(AList *,Faction *);
127
128 enum {
d247cd4 Roads now allow you to move into an adjacent combat as well.
jtraub authored
129 TOWN_VILLAGE,
130 TOWN_TOWN,
131 TOWN_CITY,
132 NTOWNS
b87f2b0 Initial revision
jtraub authored
133 };
134
135 class TownInfo
136 {
d247cd4 Roads now allow you to move into an adjacent combat as well.
jtraub authored
137 public:
138 TownInfo();
139 ~TownInfo();
140
141 void Readin(Ainfile *, ATL_VER &);
142 void Writeout(Aoutfile *);
143 int TownType();
144
145 AString * name;
146 int pop;
147 int basepop;
148 int activity;
b87f2b0 Initial revision
jtraub authored
149 };
150
151 class ARegion : public AListElem
152 {
d247cd4 Roads now allow you to move into an adjacent combat as well.
jtraub authored
153 friend class Game;
154 friend class ARegionArray;
155
156 public:
157 ARegion();
158 ARegion(int,int);
159 ~ARegion();
160 void Setup();
161
162 void ZeroNeighbors();
163 void SetName(char *);
164
165 void Writeout(Aoutfile *);
166 void Readin(Ainfile *,AList *, ATL_VER v);
167
168 int CanMakeAdv(Faction *,int);
169 int HasItem(Faction *,int);
170 void WriteProducts(Areport *, Faction *, int);
171 void WriteMarkets(Areport *, Faction *, int);
172 void WriteEconomy(Areport *,Faction *, int);
173 void WriteExits(Areport *, ARegionList *pRegs, int *exits_seen);
174 void WriteReport(Areport *f, Faction *fac, int month,
175 ARegionList *pRegions);
176 // DK
177 void WriteTemplate(Areport *,Faction *, ARegionList *, int);
178 void WriteTemplateHeader(Areport *, Faction *, ARegionList *, int);
179 void GetMapLine(char *, int, ARegionList *);
180
181 AString ShortPrint(ARegionList *pRegs);
182 AString Print(ARegionList *pRegs);
183
184 void Kill(Unit *);
185 void ClearHell();
186
187 Unit * GetUnit(int);
188 Unit * GetUnitAlias(int,int); /* alias, faction number */
189 Unit * GetUnitId(UnitId *,int);
190 Location * GetLocation(UnitId *,int);
191
192 void SetLoc(int,int,int);
193 int Present(Faction *);
194 AList * PresentFactions();
195 int GetObservation(Faction *, int);
196 int GetTrueSight(Faction *, int);
197
198 Object * GetObject(int);
199 Object * GetDummy();
200
201 int MoveCost(int, ARegion *, int);
202 Unit * Forbidden(Unit *); /* Returns unit that is forbidding */
203 Unit * ForbiddenByAlly(Unit *); /* Returns unit that is forbidding */
204 int CanTax(Unit *);
205 int CanPillage(Unit *);
206 int ForbiddenShip(Object *);
207 int HasCityGuard();
208 void NotifySpell(Unit *,int, ARegionList *pRegs);
209 void NotifyCity(Unit *, AString& oldname, AString& newname);
210
211 void DefaultOrders();
212 void UpdateTown();
213 void PostTurn();
214 void UpdateProducts();
215 void SetWeather(int newWeather);
216 int IsCoastal();
217 void MakeStartingCity();
218 int IsStartingCity();
219 int IsSafeRegion();
220 int CanBeStartingCity(ARegionArray *pRA);
221 int HasShaft();
222
223 // AS
224 int HasRoad();
225 int HasExitRoad(int realDirection);
226 int CountConnectingRoads();
227 int HasConnectingRoad(int realDirection);
228 int GetRoadDirection(int realDirection);
229 int GetRealDirComp(int realDirection);
230 void DoDecayCheck();
231 void DoDecayClicks(Object *o);
232 void RunDecayEvent(Object *o);
233 AString GetDecayFlavor();
234 int GetMaxClicks();
235 int PillageCheck();
236
237 int CountWMons();
238 int IsGuarded();
239
240 int Wages();
241 AString WagesForReport();
242 int Population();
243
244 AString * name;
245 int num;
246 int type;
247 int buildingseq;
248 int weather;
249 int gate;
250
251 TownInfo * town;
252 int race;
253 int population;
254 int basepopulation;
255 int wages;
256 int maxwages;
257 int money;
258
259 /* Potential bonuses to economy */
260 int clearskies;
261 int earthlore;
262
263 ARegion * neighbors[NDIRS];
264 AList objects;
265 AList hell; /* Where dead units go */
266 AList farsees;
267 // List of units which passed through the region
268 AList passers;
269 ProductionList products;
270 MarketList markets;
271 int xloc,yloc,zloc;
272
273 private:
274 /* Private Setup Functions */
275 void SetupPop();
276 void SetupProds();
277 int GetNearestProd(int);
278 void SetupCityMarket();
279 void AddTown();
280 void MakeLair(int);
281 void LairCheck();
b87f2b0 Initial revision
jtraub authored
282 };
283
284 class ARegionArray
285 {
d247cd4 Roads now allow you to move into an adjacent combat as well.
jtraub authored
286 public:
287 ARegionArray(int,int);
288 ~ARegionArray();
289
290 void SetRegion(int,int,ARegion *);
291 ARegion * GetRegion(int,int);
292 void SetName(char *name);
293
294 int x;
295 int y;
296 ARegion ** regions;
297 AString *strName;
298
299 enum {
300 LEVEL_NEXUS,
301 LEVEL_SURFACE,
302 LEVEL_UNDERWORLD,
303 LEVEL_UNDERDEEP,
304 };
305 int levelType;
b87f2b0 Initial revision
jtraub authored
306 };
307
308 class ARegionFlatArray
309 {
d247cd4 Roads now allow you to move into an adjacent combat as well.
jtraub authored
310 public:
311 ARegionFlatArray(int);
312 ~ARegionFlatArray();
313
314 void SetRegion(int,ARegion *);
315 ARegion * GetRegion(int);
316
317 int size;
318 ARegion ** regions;
b87f2b0 Initial revision
jtraub authored
319 };
320
d247cd4 Roads now allow you to move into an adjacent combat as well.
jtraub authored
321 class ARegionList : public AList
b87f2b0 Initial revision
jtraub authored
322 {
d247cd4 Roads now allow you to move into an adjacent combat as well.
jtraub authored
323 public:
324 ARegionList();
325 ~ARegionList();
326
327 ARegion * GetRegion(int);
328 ARegion * GetRegion(int,int,int);
329 int ReadRegions(Ainfile *f, AList *, ATL_VER v);
330 void WriteRegions(Aoutfile *f);
331 Location * FindUnit(int);
332
333 void ChangeStartingCity(ARegion *,int);
334 ARegion *GetStartingCity(ARegion *AC, int num, int level, int maxX,
335 int maxY);
336
337 ARegion *FindGate(int);
338 int GetDistance(ARegion *,ARegion *);
339 int GetPlanarDistance(ARegion *,ARegion *);
340 int GetWeather(ARegion *pReg, int month);
341
342 ARegionArray *GetRegionArray(int level);
343
344 int numberofgates;
345 int numLevels;
346 ARegionArray **pRegionArrays;
347
348 public:
349 //
350 // Public world creation stuff
351 //
352 void CreateLevels(int numLevels);
353 void CreateAbyssLevel(int level, char *name);
354 void CreateNexusLevel(int level, int xSize, int ySize, char *name);
355 void CreateSurfaceLevel(int level, int xSize, int ySize, int percentOcean,
356 int continentSize, char *name);
357 void CreateIslandLevel(int level, int nPlayers, char *name);
358 void CreateUnderworldLevel(int level, int xSize, int ySize, char *name);
359 void CreateUnderdeepLevel(int level, int xSize, int ySize, char *name);
360
361 void MakeShaftLinks(int levelFrom, int levelTo, int odds);
362 void SetACNeighbors(int levelSrc, int levelTo, int maxX, int maxY);
363 void InitSetupGates(int level);
364 void FinalSetupGates();
365
366 void CalcDensities();
367
368 private:
369 //
370 // Private world creation stuff
371 //
372 void MakeRegions(int level, int xSize, int ySize);
373 void SetupNeighbors(ARegionArray *pRegs);
374 void NeighSetup(ARegion *r, ARegionArray *ar);
375
376 void SetRegTypes(ARegionArray *pRegs, int newType);
377 void MakeLand(ARegionArray *pRegs,int percentOcean,int continentSize);
378 void MakeCentralLand(ARegionArray *pRegs);
379
380 void SetupAnchors(ARegionArray *pArr);
381 void GrowTerrain(ARegionArray *pArr, int growOcean);
382 void RandomTerrain(ARegionArray *pArr);
383 void MakeUWMaze(ARegionArray *pArr);
384 void MakeIslands(ARegionArray *pArr, int nPlayers);
385 void MakeOneIsland(ARegionArray *pRegs, int xx, int yy);
386
387 void AssignTypes(ARegionArray *pArr);
388 void FinalSetup(ARegionArray *);
389
390 void MakeShaft(ARegion *reg, ARegionArray *pFrom, ARegionArray *pTo);
391
392 //
393 // Game-specific world stuff (see world.cpp)
394 //
395 int GetRegType(ARegion *pReg);
396 int CheckRegionExit(ARegion *pFrom, ARegion *pTo);
b87f2b0 Initial revision
jtraub authored
397 };
398 #endif
Something went wrong with that request. Please try again.