source: trunk/Protocol.pas@ 328

Last change on this file since 328 was 328, checked in by chronos, 9 months ago
  • Modified: Use nWonder constant as number of wonders instead of numeric value.
  • Modified: Code cleanup.
File size: 67.6 KB
Line 
1{$INCLUDE Switches.inc}
2{$HINTS OFF}
3unit Protocol;
4
5interface
6
7const
8 lxmax = 100;
9 lymax = 96;
10 nAdv = 94; { number of advances }
11 nImp = 70; { number of improvements }
12 nPl = 15; { max number of players, don't change! }
13 nWonder = 28; { number of wonders }
14 nUmax = 4096; { max units/player, don't set above 4096 }
15 nCmax = 1024; { max cities/player, don't set above 4096 }
16 nMmax = 256; { max models/player, don't set above 1024 }
17 nExp = 5; // number of experience levels
18 ExpCost = 50; { received damage required for next experience level }
19 MaxFutureTech = 25;
20 // maximum number of future techs of one kind except computing technology
21 MaxFutureTech_Computing = 100;
22 // maximum number of computing technology future techs
23 CountryRadius = 9;
24 MaxCitySize = 30;
25 BasicHappy = 2; { basically happy citizens }
26 MaxPollution = 240;
27 NeedAqueductSize = 8;
28 NeedSewerSize = 12;
29 ColossusEffect = 75; // percent wonder building cost
30 UniversityFutureBonus = 5; // percent per tech
31 ResLabFutureBonus = 10; // percent per tech
32 FactoryFutureBonus = 5; // percent per tech
33 MfgPlantFutureBonus = 10; // percent per tech
34 AnarchyTurns = 3;
35 CaptureTurns = 3;
36 CancelTreatyTurns = 3;
37 PeaceEvaTurns = 5;
38 // should be less then 2*CancelTreatyTurns, so that you can't attack an ally without re-entering
39 ColdWarTurns = 40;
40 DesertThurst = 20; // damage for turn in desert
41 ArcticThurst = 20; // damage for turn in arctic
42 FastRecovery = 50;
43 CityRecovery = 20;
44 NoCityRecovery = 8;
45 MaxMoneyPrice = $FFFF;
46 MaxShipPartPrice = 100;
47 BombardmentDestroysCity = False;
48 StartMoney = 0;
49 InitialCredibility = 95;
50
51 // ai module flags (for TInitModuleData.Flags)
52 aiThreaded = $01;
53
54 // difficulty settings
55 MaxDiff = 4; { maximum difficulty level }
56 StorageSize: array [1 .. MaxDiff] of Integer = (30, 40, 50, 60);
57 TechFormula_M: array [1 .. MaxDiff] of Single = (2.0, 2.3, 2.6, 4.0);
58 TechFormula_D: array [1 .. MaxDiff] of Single = (102.0, 80.0, 64.0, 64.0);
59 BuildCostMod: array [1 .. MaxDiff] of Integer = (9, 12, 15, 18); // in 1/12
60
61 // test flags
62 nTestFlags = 7; // max. 11
63 tfAllTechs = $001; { all nations get all techs }
64 tfImmImprove = $002; { city projects complete each turn }
65 tfImmAdvance = $004; { research complete each turn }
66 tfImmGrow = $008; { all cities grow in each turn }
67 tfUncover = $010; // all players see like supervisor
68 tfAllContact = $020; // all nations can contact each other
69 tfNoRareNeed = $040; // producing colony ship requires no modern resources
70 tfTested = $800; // at least one test flag was set
71
72 { server commands
73 IMPORTANT: lowest 4 bits must indicate size in DWORDS of data parameter,
74 except for request commands }
75
76 sctMask = $3800; // server command type
77 sExecute = $4000; { call command-sExecute to request return value without
78 execution }
79 cClientEx = $8000;
80
81 // Info Request Commands
82 sctInfo = $0000;
83 sMessage = $0000;
84 sSetDebugMap = $0010;
85 sGetDebugMap = $0020;
86 { sChangeSuperView=$0030; } sRefreshDebugMap = $0040;
87 sGetChart = $0100; // + type shl 4
88 sGetTechCost = $0180;
89 sGetAIInfo = $01C0;
90 sGetAICredits = $01D0;
91 sGetVersion = $01E0;
92 sGetGameChanged = $01F0;
93 sGetTileInfo = $0200;
94 sGetCityTileInfo = $0210;
95 sGetHypoCityTileInfo = $0220;
96 sGetJobProgress = $0230;
97 sGetModels = $0270;
98 sGetUnits = $0280;
99 sGetDefender = $0290;
100 sGetBattleForecast = $02A0;
101 sGetUnitReport = $02B0;
102 sGetMoveAdvice = $02C0;
103 sGetPlaneReturn = $02D0;
104 sGetBattleForecastEx = $02E0;
105 sGetCity = $0300;
106 sGetCityReport = $0310;
107 sGetCityAreaInfo = $0320;
108 sGetEnemyCityReport = $0330;
109 sGetEnemyCityAreaInfo = $0340;
110 sGetCityTileAdvice = $0350;
111 sGetCityReportNew = $0360;
112 sGetEnemyCityReportNew = $0370;
113
114 // Map Editor Commands
115 sEditTile = $0710;
116 sRandomMap = $0780;
117 sMapGeneratorRequest = $0790;
118
119 // Server Internal Commands
120 sctInternal = sctInfo;
121 // sctInfo - without sExecute flag, sctInternal - with sExecute flag
122 sIntTellAboutNation = $4000;
123 sIntHaveContact = $4010;
124 sIntCancelTreaty = $4020;
125 sIntTellAboutModel = $4100; { +told player shl 4 }
126 sIntDiscoverZOC = $4201;
127 sIntExpandTerritory = $4218;
128 sIntBuyMaterial = $4301;
129 sIntPayPrices = $4402;
130 sIntSetDevModel = $450D;
131 sIntSetModelStatus = $4601;
132 sIntSetUnitStatus = $4611;
133 sIntSetCityStatus = $4621;
134 sIntSetECityStatus = $4631;
135 sIntDataChange = $4700;
136
137 // Client Deactivation Commands
138 sctEndClient = $0800;
139 sTurn = $4800;
140 sBreak = $4810;
141 sResign = $4820;
142 sNextRound = $4830;
143 sReload = $4841;
144 sSaveMap = $4880;
145 sAbandonMap = $4890;
146 // diplomacy commands equal to client, see below
147
148 // General Commands
149 sctGeneral = $1000;
150 sClearTestFlag = $5000;
151 sSetTestFlag = $5010;
152 sSetGovernment = $5100;
153 sSetRates = $5110;
154 sRevolution = $5120;
155 sSetResearch = $5200;
156 sStealTech = $5210;
157 sSetAttitude = $5300; // + concerned player shl 4
158 sCancelTreaty = $5400;
159
160 // Model Related Commands
161 sctModel = $1800;
162 sCreateDevModel = $5800;
163 sSetDevModelCap = $5C00; { +value shl 4 }
164 { reserves $5CXX, $5DXX, $5EXX, $5FXX }
165
166 // Unit Related Commands
167 sctUnit = $2000;
168 sRemoveUnit = $6000;
169 sSetUnitHome = $6010;
170 sSetSpyMission = $6100; // + mission shl 4
171 sLoadUnit = $6200;
172 sUnloadUnit = $6210;
173 sSelectTransport = $6220;
174 sCreateUnit = $6301; // + player shl 4
175 sMoveUnit = $6400; { +dx and 7 shl 4 +dy and 7 shl 7 }
176 { reserves $64XX, $65XX, $66XX, $67XX }
177
178 // Settlers Related Commands
179 sctSettlers = $2800;
180 sAddToCity = $6810;
181 sStartJob = $6C00; { +job shl 4 }
182 { reserves $6CXX, $6DXX, $6EXX, $6FXX }
183
184 // City Related Commands
185 sctCity = $3000;
186 sSetCityProject = $7001;
187 sBuyCityProject = $7010;
188 sSellCityProject = $7020;
189 sSellCityImprovement = $7101;
190 sRebuildCityImprovement = $7111;
191 sSetCityTiles = $7201;
192
193 // free command space
194 sctUnused = $3800;
195
196 { client commands }
197 cInitModule = $0000;
198 cReleaseModule = $0100;
199 cBroadcast = $0200;
200 cHelpOnly = $0700;
201 cStartHelp = $0710;
202 cStartCredits = $0720;
203
204 cNewGame = $0800;
205 cLoadGame = $0810;
206 cMovie = $0820;
207 cNewGameEx = $0840;
208 cLoadGameEx = $0850;
209 cNewMap = $0880;
210 cReplay = $08E0;
211 cGetReady = $08F0;
212 cBreakGame = $0900;
213
214 cTurn = $2000;
215 cResume = $2010;
216 cContinue = $2080;
217 cMovieTurn = $2100;
218 cMovieEndTurn = $2110;
219 cEditMap = $2800;
220
221 // cShowTileM=$3000;cShowTileA=$3010;cShowFoundCity=$3020;
222 cShowUnitChanged = $3030;
223 cShowAfterMove = $3040;
224 cShowAfterAttack = $3050;
225 cShowCityChanged = $3090;
226 // cShowMove=$3100;cShowCapture=$3110;
227 // cShowAttackBegin=$3200;cShowAttackWon=$3210;cShowAttackLost=$3220;
228 cShowMoving = $3140;
229 cShowCapturing = $3150;
230 cShowAttacking = $3240;
231 cShowMissionResult = $3300;
232 cShowShipChange = $3400;
233 cShowGreatLibTech = $3500;
234 cShowTurnChange = $3700;
235 cShowCancelTreaty = $3800;
236 cShowEndContact = $3810;
237 cShowCancelTreatyByAlliance = $3820;
238 cShowSupportAllianceAgainst = $3830;
239 cShowPeaceViolation = $3880;
240 cShowGame = $3F00; { cShowSuperView=$3F80; }
241 cRefreshDebugMap = $3F90;
242
243 // diplomacy commands equal to server, see below
244
245 cDebugMessage = $7000;
246 cShowNego = $7010;
247
248 // commands same for server and client
249 scContact = $4900; // + concerned player shl 4 for server call
250 scReject = $4A00;
251 scDipStart = $4B00;
252 scDipNotice = $4B10;
253 scDipAccept = $4B20;
254 scDipCancelTreaty = $4B30;
255 scDipOffer = $4B4E;
256 scDipBreak = $4BF0;
257
258 { server return codes: flags }
259 rExecuted = $40000000;
260 rEffective = $20000000;
261 rUnitRemoved = $10000000;
262 rEnemySpotted = $08000000;
263
264 { server return codes: command executed }
265 // note: the same return code might have a different meaning for different server functions!
266 eOK = $60000000; // ok
267 eEnemySpotted = $68000000; // unit move ok, new enemy unit/city spotted
268 eDied = $70000000; // move executed, unit died due to hostile terrain
269 eEnemySpotted_Died = $78000000;
270 // unit move ok, new enemy unit/city spotted, unit died due to hostile terrain
271 eLoaded = $60000002; // unit move caused loading to transport ship
272 eLost = $70000004; // attack executed, battle lost, unit is dead
273 eWon = $60000005; // attack executed, battle won, defender destroyed
274 eBloody = $70000005; // attack executed, defender destroyed, unit is dead
275 eBombarded = $60000006; // empty enemy city bombarded
276 eExpelled = $60000007; // friendly unit expelled
277 eMissionDone = $70000008;
278 // spy moved into city: mission done, spy no longer exists
279 eJobDone = $60000001; // settler job started and already done
280 eJobDone_Died = $70000001;
281 // settler job started and already done, unit died due to hostile terrain
282 eCity = $70000002; // city founded, settler no more exists
283 eRemoved = $70000000; // sRemoveUnit: unit removed
284 eUtilized = $70000001; // sRemoveUnit: unit utilized for city project
285
286 eNotChanged = $40000000;
287 // ok, but no effect (e.g. current city project set again)
288
289 { server return codes: command not executed }
290 eHiddenUnit = $20000013;
291 // unit move: not possible, destination tile occupied by hidden foreign submarine
292 eStealthUnit = $2000001A;
293 // unit move: not possible, destination tile occupied by foreign stealth unit
294 eZOC_EnemySpotted = $28000014;
295 // unit move: not possible, new enemy unit spotted, ZOC violation
296
297 eInvalid = $0000; // command not allowed now or parameter out of allowed range
298 eUnknown = $0001; // unknown command
299 eNoTurn = $0002; // command only allowed during player's turn
300 eViolation = $0003; // general violation of game rules
301 eNoPreq = $0004; // the prerequisites for this command are not fully met
302
303 eNoTime_Move = $0008; // normal unit move: too few movement points left
304 eNoTime_Load = $0009; // load unit: too few movement points left
305 eNoTime_Attack = $000A; // attack: no movement points left
306 eNoTime_Bombard = $000B; // bombard city: too few movement points left
307 eNoTime_Expel = $000C; // expel spy: too few movement points left
308
309 eDomainMismatch = $0011;
310 // move/attack: action not allowed for this unit domain
311 eNoCapturer = $0012;
312 // unit move: this type of unit is not allowed to capture a city
313 eZOC = $0014; // unit move: not possible, ZOC violation
314 eTreaty = $0015; // move/attack: not possible, peace treaty violation
315 eDeadLands = $0016; // sStartJob: not possible, dead lands
316 eNoRoad = $0017; // unit move: not possible, no road
317 eNoNav = $0019; // unit move: not possible, open sea without navigation
318 eNoLoadCapacity = $001B; // load to transport: no more transport capacity
319 eNoBombarder = $001C; // bombardment impossible because no attack power
320
321 eMaxSize = $0020;
322 // add to city: bigger size not allowed due to missing aqueduct/sewer
323 eNoCityTerrain = $0022; // found city: not possible in this terrain
324 eNoBridgeBuilding = $0023;
325 eInvalidOffer = $0030;
326 eOfferNotAcceptable = $0031;
327 eCancelTreatyRush = $0032;
328 eAnarchy = $0038; // no negotiation in anarchy
329 eColdWar = $003F;
330 eNoModel = $0040; // sCreateDevModel must be called before!
331 eTileNotAvailable = $0050;
332 eNoWorkerAvailable = $0051;
333 eOnlyOnce = $0058;
334 // sell/rebuild city improvement: only once per city and turn!
335 eObsolete = $0059; // city project: more advanced improvement already exists
336 eOutOfControl = $005A;
337 // buy/sell/rebuild improvement: not in anarchy, not in captured cities
338
339 eNoWay = $0100; // sGetMoveAdvice: no way found
340
341 // chart types
342 nStat = 6;
343 stPop = 0;
344 stTerritory = 1;
345 stMil = 2;
346 stScience = 3;
347 stExplore = 4;
348 stWork = 5;
349
350 { tile flags: terrain type }
351 fTerrain = $1F; // mask for terrain type
352 fOcean = $00;
353 fShore = $01;
354 fGrass = $02;
355 fDesert = $03;
356 fPrairie = $04;
357 fTundra = $05;
358 fArctic = $06;
359 fSwamp = $07;
360 fForest = $09;
361 fHills = $0A;
362 fMountains = $0B;
363 fUNKNOWN = fTerrain;
364
365 { tile flags: terrain improvements }
366 fTerImp = $0000F000; // mask for terrain improvement
367 tiNone = $00000000;
368 tiIrrigation = $00001000;
369 tiFarm = $00002000;
370 tiMine = $00003000;
371 tiFort = $00004000;
372 tiBase = $00005000;
373
374 { tile flags: add ons }
375 fSpecial = $00000060;
376 fSpecial1 = $00000020;
377 fSpecial2 = $00000040;
378 fRiver = $00000080;
379 fRoad = $00000100;
380 fRR = $00000200;
381 fCanal = $00000400;
382 fPoll = $00000800;
383 fPrefStartPos = $00200000;
384 fStartPos = $00400000; // map editor only
385 fDeadLands = $01000000;
386 fModern = $06000000;
387 fCobalt = $02000000;
388 fUranium = $04000000;
389 fMercury = $06000000;
390
391 { tile flags: redundant helper info }
392 fGrWall = $00010000; // tile protected by great wall
393 fSpiedOut = $00020000;
394 fStealthUnit = $00040000;
395 fHiddenUnit = $00080000;
396 fObserved = $00100000; // set if tile information is from this turn
397 fOwned = $00200000; // set if unit/city here is own one
398 fUnit = $00400000;
399 fCity = $00800000;
400 fOwnZoCUnit = $10000000; // own ZoC unit present at this tile
401 fInEnemyZoC = $20000000;
402 // tile is adjacent to known foreign ZoC unit (not allied)
403 fPeace = $40000000;
404 // tile belongs to territory of nation that we are in peace with but not allied
405
406 // city project flags
407 cpIndex = $1FF;
408 cpConscripts = $200; // produce unit as conscripts
409 cpDisbandCity = $400;
410 // allow to disband city when settlers/conscripts are produced
411 cpImp = $800; // 0: index refers to model, 1: index refers to city improvement
412 cpRepeat = $1000;
413 cpCompleted = $2000;
414 cpAuto = $F000; // for internal use only
415
416 // tech status indicators
417 tsNA = -2;
418 tsSeen = -1;
419 tsResearched = 0;
420 tsGrLibrary = 1;
421 tsCheat = 15;
422 tsApplicable = tsResearched;
423
424 // nation treaties
425 trNoContact = -1;
426 trNone = 0;
427 trPeace = 2;
428 trFriendlyContact = 3;
429 trAlliance = 4;
430
431 // attitudes
432 nAttitude = 7;
433 atHostile = 0;
434 atIcy = 1;
435 atUncoop = 2;
436 atNeutral = 3;
437 atReceptive = 4;
438 atCordial = 5;
439 atEnth = 6;
440
441 // offer prices
442 opChoose = $00000000;
443 opCivilReport = $11000000; // + turn + concerned player shl 16
444 opMilReport = $12000000; // + turn + concerned player shl 16
445 opMap = $1F000000;
446 opTreaty = $20000000; // + suggested nation treaty
447 opShipParts = $30000000; // + number + part type shl 16
448 opMoney = $40000000; // + value
449 opTribute = $48000000; // obsolete
450 opTech = $50000000; // + advance
451 opAllTech = $51000000;
452 opModel = $58000000; // + model index
453 opAllModel = $59000000;
454
455 opMask = $FF000000;
456
457 // improvement kinds
458 ikTrGoods = 0;
459 ikCommon = 1;
460 ikNatLocal = 2;
461 ikNatGlobal = 3;
462 ikWonder = 4;
463 ikShipPart = 5;
464 ikNA = $7F;
465
466 { model domains }
467 nDomains = 3;
468 dGround = 0;
469 dSea = 1;
470 dAir = 2;
471
472 { model kinds }
473 mkSelfDeveloped = $00;
474 mkEnemyDeveloped = $01;
475 mkSpecial_Boat = $08;
476 mkSpecial_SubCabin = $0A;
477 mkSpecial_TownGuard = $10;
478 mkSpecial_Glider = $11;
479 mkScout = $20;
480 mkSlaves = $21;
481 mkSettler = $22;
482 mkCommando = $23;
483 mkFreight = $24;
484
485 { unit flags }
486 unFortified = $01;
487 unBombsLoaded = $02;
488 unMountainDelay = $04;
489 unConscripts = $08;
490 unWithdrawn = $10;
491 unMulti = $80;
492
493 // unit report flags
494 urfAlwaysSupport = $01;
495 urfDeployed = $02;
496
497 // unit moves
498 umCapturing = $0100;
499 umSpyMission = $0200;
500 umBombarding = $0400;
501 umExpelling = $0800;
502 umShipLoading = $1000;
503 umShipUnloading = $2000;
504 umPlaneLoading = $4000;
505 umPlaneUnloading = $8000;
506
507 { model flags }
508 mdZOC = $01;
509 mdCivil = $02;
510 mdDoubleSupport = $04;
511
512 { player happened flags }
513 phTech = $01;
514 phStealTech = $02;
515 phChangeGov = $08;
516 phGliderLost = $100;
517 phPlaneLost = $200;
518 phPeaceViolation = $400;
519 phPeaceEvacuation = $800;
520 phShipComplete = $2000;
521 phTimeUp = $4000;
522 phExtinct = $8000;
523 phGameEnd = $F000;
524
525 { city happened flags }
526 chDisorder = $01;
527 chProduction = $02;
528 chPopIncrease = $04;
529 chPopDecrease = $08;
530 chUnitLost = $10;
531 chImprovementLost = $20;
532 chProductionSabotaged = $40;
533 chNoGrowthWarning = $80;
534 chPollution = $100;
535 chSiege = $200;
536 chOldWonder = $400;
537 chNoSettlerProd = $800;
538 chFounded = $1000;
539 chAfterCapture = $2000;
540 chCaptured = $F0000;
541 chImprovementSold = $80000000;
542
543 { city info flags }
544 ciCapital = $01;
545 ciWalled = $02;
546 ciCoastalFort = $04;
547 ciMissileBat = $08;
548 ciBunker = $10;
549 ciSpacePort = $20;
550
551 { city tile available values }
552 faAvailable = 0;
553 faNotAvailable = 1;
554 faSiege = 2;
555 faTreaty = 4;
556 faInvalid = $FF;
557
558 // battle history flags
559 bhEnemyAttack = $01;
560 bhMyUnitLost = $02;
561 bhEnemyUnitLost = $04;
562
563 { move advice special destinations }
564 maNextCity = -1;
565
566 { goverment forms }
567 nGov = 8;
568 gAnarchy = 0;
569 gDespotism = 1;
570 gMonarchy = 2;
571 gRepublic = 3;
572 gFundamentalism = 4;
573 gCommunism = 5;
574 gDemocracy = 6;
575 gFuture = 7;
576
577 // ship change reasons
578 scrProduction = 0;
579 scrDestruction = 1;
580 scrTrade = 2;
581 scrCapture = 3;
582
583 { unit jobs }
584 nJob = 15;
585 jNone = 0;
586 jRoad = 1;
587 jRR = 2;
588 jClear = 3;
589 jIrr = 4;
590 jFarm = 5;
591 jAfforest = 6;
592 jMine = 7;
593 jCanal = 8;
594 jTrans = 9;
595 jFort = 10;
596 jPoll = 11;
597 jBase = 12;
598 jPillage = 13;
599 jCity = 14;
600
601 // job preconditions are:
602 // technology JobPreq is available, no city, plus the following:
603 // jRoad: no river when bridge building unavailable
604 // jRR: road
605 // jClear: Terrain.ClearTerrain, Hanging Gardens for desert
606 // jIrr: Terrain.IrrEff
607 // jFarm: irrigation
608 // jAfforest: Terrain.AfforestTerrain
609 // jMine: Terrain.MineEff
610 // jCanal: no Mountains, no Arctic
611 // jTrans: Terrain.TransWork
612 // jPoll: pollution
613 // jPillage: any tile improvement
614 // jCity, jFort, jBase: none
615
616 // spy mission
617 nSpyMission = 5;
618 smSabotageProd = 0;
619 smStealMap = 1;
620 smStealForeignReports = 2;
621 smStealCivilReport = 3;
622 smStealMilReport = 4;
623
624 // resource weights
625 rwOff = $00000000;
626 rwMaxGrowth = $3F514141; // 120*F + 1/8*P + 1/16*T + 1/16*S
627 rwMaxProd = $413F1F01; // 1/16*F + 120*P + 30*T + 1*S
628 rwMaxScience = $41040408; // 1/16*F + 4*P + 4*T + 8*S
629 rwForceProd = $F1080201; // F^1/2 * (8*P + 2*T + 1*S)
630 rwForceScience = $F1010101; // F^1/2 * (1*P + 1*T + 1*S)
631
632 { advances }
633 adAdvancedFlight = 0;
634 adAmphibiousWarfare = 1;
635 adAstronomy = 2;
636 adAtomicTheory = 3;
637 adAutomobile = 4;
638 adBallistics = 5;
639 adBanking = 6;
640 adBridgeBuilding = 7;
641 adBronzeWorking = 8;
642 adCeremonialBurial = 9;
643 adChemistry = 10;
644 adChivalry = 11;
645 adComposites = 12;
646 adCodeOfLaws = 13;
647 adCombinedArms = 14;
648 adCombustionEngine = 15;
649 adCommunism = 16;
650 adComputers = 17;
651 adConscription = 18;
652 adConstruction = 19;
653 adTheCorporation = 20;
654 adSpaceFlight = 21;
655 adCurrency = 22;
656 adDemocracy = 23;
657 adEconomics = 24;
658 adElectricity = 25;
659 adElectronics = 26;
660 adEngineering = 27;
661 adEnvironmentalism = 28;
662 adWheel = 29;
663 adExplosives = 30;
664 adFlight = 31;
665 adIntelligence = 32;
666 adGunpowder = 33;
667 adHorsebackRiding = 34;
668 adImpulseDrive = 35;
669 adIndustrialization = 36;
670 adSmartWeapons = 37;
671 adInvention = 38;
672 adIronWorking = 39;
673 adTheLaser = 40;
674 adNuclearPower = 41;
675 adLiterature = 42;
676 adInternet = 43;
677 adMagnetism = 44;
678 adMapMaking = 45;
679 adMasonry = 46;
680 adMassProduction = 47;
681 adMathematics = 48;
682 adMedicine = 49;
683 adMetallurgy = 50;
684 adMin = 51;
685 adMobileWarfare = 52;
686 adMonarchy = 53;
687 adMysticism = 54;
688 adNavigation = 55;
689 adNuclearFission = 56;
690 adPhilosophy = 57;
691 adPhysics = 58;
692 adPlastics = 59;
693 adPoetry = 60;
694 adPottery = 61;
695 adRadio = 62;
696 adRecycling = 63;
697 adRefrigeration = 64;
698 adMonotheism = 65;
699 adTheRepublic = 66;
700 adRobotics = 67;
701 adRocketry = 68;
702 adRailroad = 69;
703 adSanitation = 70;
704 adScience = 71;
705 adWriting = 72;
706 adSeafaring = 73;
707 adSelfContainedEnvironment = 74;
708 adStealth = 75;
709 adSteamEngine = 76;
710 adSteel = 77;
711 adSyntheticFood = 78;
712 adTactics = 79;
713 adTheology = 80;
714 adTheoryOfGravity = 81;
715 adTrade = 82;
716 adTransstellarColonization = 83;
717 adUniversity = 84;
718 adAdvancedRocketry = 85;
719 adWarriorCode = 86;
720 adAlphabet = 87;
721 adPolytheism = 88;
722 adRefining = 89;
723 futComputingTechnology = 90;
724 futNanoTechnology = 91;
725 futMaterialTechnology = 92;
726 futArtificialIntelligence = 93;
727
728 FutureTech = [futComputingTechnology, futNanoTechnology,
729 futMaterialTechnology, futArtificialIntelligence];
730
731 adMilitary = $800; // Military Research
732
733 { wonders }
734 woPyramids = 00;
735 woZeus = 01;
736 woGardens = 02;
737 woColossus = 03;
738 woLighthouse = 04;
739 woGrLibrary = 05;
740 woOracle = 06;
741 woSun = 07;
742 woLeo = 08;
743 woMagellan = 09;
744 woMich = 10; { 11; }
745 woNewton = 12;
746 woBach = 13;
747 { 14; } woLiberty = 15;
748 woEiffel = 16;
749 woHoover = 17;
750 woShinkansen = 18;
751 woManhattan = 19;
752 woMir = 20;
753
754 { city improvements }
755 imTrGoods = 28;
756 imBarracks = 29;
757 imGranary = 30;
758 imTemple = 31;
759 imMarket = 32;
760 imLibrary = 33;
761 imCourt = 34;
762 imWalls = 35;
763 imAqueduct = 36;
764 imBank = 37;
765 imCathedral = 38;
766 imUniversity = 39;
767 imHarbor = 40;
768 imTheater = 41;
769 imFactory = 42;
770 imMfgPlant = 43;
771 imRecycling = 44;
772 imPower = 45;
773 imHydro = 46;
774 imNuclear = 47;
775 imPlatform = 48;
776 imTownHall = 49;
777 imSewer = 50;
778 imSupermarket = 51;
779 imHighways = 52;
780 imResLab = 53;
781 imMissileBat = 54;
782 imCoastalFort = 55;
783 imAirport = 56;
784 imDockyard = 57;
785 imPalace = 58;
786 imGrWall = 59;
787 imColosseum = 60;
788 imObservatory = 61;
789 imMilAcademy = 62;
790 imBunker = 63;
791 imAlgae = 64;
792 imStockEx = 65;
793 imSpacePort = 66;
794 imShipComp = 67;
795 imShipPow = 68;
796 imShipHab = 69;
797
798 SettlerFood: array [0 .. nGov - 1] of Integer = (1, 1, 1, 2, 1, 2, 2, 2);
799 CorrLevel: array [0 .. nGov - 1] of Integer = (3, 3, 1, 2, 1, 0, 0, 0);
800 SupportFree: array [0 .. nGov - 1] of Integer = (2, 2, 1, 0, 2, 1, 0, 0);
801 // in 1/2*city size
802
803 // special prerequisite values
804 preNone = -1;
805 preLighthouse = -2;
806 preSun = -3;
807 preLeo = -4;
808 preBuilder = -5;
809 preNA = -$FF;
810
811 JobPreq: array [0 .. nJob - 1] of Integer = (preNone, preNone, adRailroad,
812 preNone, preNone, adRefrigeration, preNone, preNone, adExplosives,
813 adExplosives, adConstruction, preNone, adMedicine, preNone, preNone);
814
815 AdvPreq: array [0 .. nAdv - 1, 0 .. 2] of Integer = { advance prerequisites }
816 ((adFlight, adRobotics, preNone), // adAdvancedFlight
817 (adNavigation, adTactics, preNone), // adAmphibiousWarfare
818 (adMysticism, adAlphabet, preNone), // adAstronomy
819 (adTheoryOfGravity, preNone, preNone), // adAtomicTheory
820 (adCombustionEngine, adSteel, preNone), // adAutomobile
821 (adMathematics, adMetallurgy, preNone), // adBallistics
822 (adCurrency, adEngineering, preNone), // adBanking
823 (adConstruction, adWheel, preNone), // adBridgeBuilding
824 (preNone, preNone, preNone), // adBronzeWorking
825 (preNone, preNone, preNone), // adCeremonialBurial
826 (adScience, preNone, preNone), // adChemistry
827 (adMonarchy, adWarriorCode, preNone), // adChivalry
828 (adMetallurgy, adPlastics, preNone), // adComposites
829 (adWriting, preNone, preNone), // adCodeOfLaws
830 (adAdvancedFlight, adMobileWarfare, preNone), // adCombinedArms
831 (adRefining, adExplosives, preNone), // adCombustionEngine
832 (adPhilosophy, adIndustrialization, preNone), // adCommunism
833 (adMin, preNone, preNone), // adComputers
834 (adTheRepublic, adTactics, preNone), // adConscription
835 (adMasonry, adAlphabet, preNone), // adConstruction
836 (adEconomics, adDemocracy, preNone), // adTheCorporation
837 (adAdvancedFlight, adAdvancedRocketry, preNone), // adSpaceFlight
838 (adBronzeWorking, preNone, preNone), // adCurrency
839 (adConscription, adIndustrialization, preNone), // adDemocracy
840 (adBanking, adUniversity, preNone), // adEconomics
841 (adMagnetism, preNone, preNone), // adElectricity
842 (adRadio, adAtomicTheory, preNone), // adElectronics
843 (adConstruction, adBronzeWorking, preNone), // adEngineering
844 (adIndustrialization, preNone, preNone), // adEnvironmentalism
845 (preNone, preNone, preNone), // adWheel
846 (adChemistry, adEngineering, preNone), // adExplosives
847 (adCombustionEngine, adPhysics, preNone), // adFlight
848 (adTactics, adInvention, preNone), // adIntelligence
849 (adMedicine, adIronWorking, preNone), // adGunpowder
850 (preNone, preNone, preNone), // adHorsebackRiding
851 (adSpaceFlight, adNuclearPower, preNone), // adImpulseDrive
852 (adRailroad, adBanking, preNone), // adIndustrialization
853 (adAdvancedRocketry, adTheLaser, preNone), // adIntelligenArms
854 (adWriting, adWheel, preNone), // adInvention
855 (adBronzeWorking, adInvention, preNone), // adIronWorking
856 (adMin, adPhysics, preNone), // adTheLaser
857 (adNuclearFission, preNone, preNone), // adNuclearPower
858 (adPoetry, adTrade, preNone), // adLiterature
859 (adDemocracy, adComputers, preNone), // adLybertarianism
860 (adPhysics, adIronWorking, preNone), // adMagnetism
861 (adAlphabet, preNone, preNone), // adMapMaking
862 (preNone, preNone, preNone), // adMasonry
863 (adAutomobile, adElectronics, adTheCorporation), // adMassProduction
864 (adCurrency, adAlphabet, preNone), // adMathematics
865 (adMysticism, adPottery, preNone), // adMedicine
866 (adGunpowder, preNone, preNone), // adMetallurgy
867 (adRobotics, adPlastics, preNone), // adMin
868 (adAutomobile, adTactics, preNone), // adMobileWarfare
869 (adPolytheism, preNone, preNone), // adMonarchy
870 (adCeremonialBurial, preNone, preNone), // adMysticism
871 (adSeafaring, adAstronomy, preNone), // adNavigation
872 (adAtomicTheory, adMassProduction, preNone), // adNuclearFission
873 (adMathematics, adLiterature, preNone), // adPhilosophy
874 (adScience, preNone, preNone), // adPhysics
875 (adMassProduction, adRefining, preNone), // adPlastics
876 (adMysticism, adWarriorCode, preNone), // adPoetry
877 (preNone, preNone, preNone), // adPottery
878 (adElectricity, adEngineering, preNone), // adRadio
879 (adEnvironmentalism, adPlastics, preNone), // adRecycling
880 (adElectricity, preNone, preNone), // adRefrigeration
881 (adPolytheism, adAstronomy, preNone), // adMonotheism
882 (adLiterature, preNone, preNone), // adTheRepublic
883 (adMassProduction, adEconomics, preNone), // adRobotics
884 (adBallistics, adExplosives, preNone), // adRocketry
885 (adSteamEngine, adBridgeBuilding, preNone), // adRailroad
886 (adEnvironmentalism, adMedicine, preNone), // adSanitation
887 (adMetallurgy, adTheology, adPhilosophy), // adScience
888 (adAlphabet, preNone, preNone), // adWriting
889 (adPottery, adMapMaking, preNone), // adSeafaring
890 (adRecycling, adSyntheticFood, preNone), // adSelfContainedEnvironment
891 (adComposites, adRadio, preNone), // adStealth
892 (adScience, adEngineering, preNone), // adSteamEngine
893 (adIronWorking, adRailroad, preNone), // adSteel
894 (adChemistry, adRefrigeration, preNone), // adSyntheticFood
895 (adWarriorCode, adUniversity, preNone), // adTactics
896 (adMonotheism, adPoetry, preNone), // adTheology
897 (adAstronomy, adPhysics, preNone), // adTheoryOfGravity
898 (adCurrency, adCodeOfLaws, preNone), // adTrade
899 (adImpulseDrive, adSelfContainedEnvironment, preNone),
900 // adTransstellarColonization
901 (adScience, preNone, preNone), // adUniversity
902 (adComputers, adRocketry, preNone), // adAdvancedRocketry
903 (preNone, preNone, preNone), // adWarriorCode
904 (preNone, preNone, preNone), // adAlphabet
905 (adCeremonialBurial, adHorsebackRiding, preNone), // adPolytheism
906 (adChemistry, preNone, preNone), // adRefining
907 (adComputers, preNone, preNone), // futResearchTechnology
908 (adRobotics, preNone, preNone), // futProductionTechnology
909 (adComposites, preNone, preNone), // futArmorTechnology
910 (adSmartWeapons, preNone, preNone)); // futMissileTechnology
911
912Imp: array [0 .. nImp - 1] of // city improvements
913record
914 Kind: Integer;
915 Preq: Integer;
916 Cost: Integer;
917 Maint: Integer;
918 Expiration: integer;
919end
920= ((Kind: ikWonder; Preq: adMathematics; Cost: 400; Maint: 0;
921 Expiration: adDemocracy), // woPyramids
922 (Kind: ikWonder; Preq: adPolytheism; Cost: 200; Maint: 0;
923 Expiration: adElectronics), // woZeus
924 (Kind: ikWonder; Preq: adInvention; Cost: 200; Maint: 0;
925 Expiration: adNuclearFission), // woGardens
926 (Kind: ikWonder; Preq: adBronzeWorking; Cost: 200; Maint: 0; Expiration: - 1),
927 // woColossus
928 (Kind: ikWonder; Preq: adMapMaking; Cost: 200; Maint: 0; Expiration: adSteel),
929 // woLighthouse
930 (Kind: ikWonder; Preq: adLiterature; Cost: 400; Maint: 0;
931 Expiration: adPlastics), // woGrLibrary
932 (Kind: ikWonder; Preq: adMysticism; Cost: 200; Maint: 0; Expiration: - 1),
933 // woOracle
934 (Kind: ikWonder; Preq: adChivalry; Cost: 300; Maint: 0;
935 Expiration: adSpaceFlight), // woSun
936 (Kind: ikWonder; Preq: adPhilosophy; Cost: 500; Maint: 0; Expiration: - 1),
937 // woLeo
938 (Kind: ikWonder; Preq: adNavigation; Cost: 300; Maint: 0; Expiration: - 1),
939 // woMagellan
940 (Kind: ikWonder; Preq: adMonotheism; Cost: 400; Maint: 0; Expiration: - 1),
941 // woMich
942 (Kind: ikNA; Preq: preNA; Cost: 0; Maint: 0; Expiration: 0), // {11}
943 (Kind: ikWonder; Preq: adTheoryOfGravity; Cost: 400; Maint: 0; Expiration: - 1), // woNewton
944 (Kind: ikWonder; Preq: adTheology; Cost: 400; Maint: 0; Expiration: - 1),
945 // woBach
946 (Kind: ikNA; Preq: preNA; Cost: 0; Maint: 0; Expiration: 0), // {14}
947 (Kind: ikWonder; Preq: adDemocracy; Cost: 500; Maint: 0; Expiration: - 1),
948 // woLiberty
949 (Kind: ikWonder; Preq: adSteel; Cost: 800; Maint: 0; Expiration: - 1),
950 // woEiffel
951 (Kind: ikWonder; Preq: adElectronics; Cost: 800; Maint: 0; Expiration: - 1),
952 // woHoover
953 (Kind: ikWonder; Preq: adPlastics; Cost: 500; Maint: 0; Expiration: - 1),
954 // woShinkansen
955 (Kind: ikWonder; Preq: adNuclearFission; Cost: 400; Maint: 0;
956 Expiration: - 1), // woManhattan
957 (Kind: ikWonder; Preq: adSpaceFlight; Cost: 800; Maint: 0; Expiration: - 1),
958 // woMir
959 (Kind: ikNA; Preq: preNA; Cost: 0; Maint: 0; Expiration: 0), // {21}
960 (Kind: ikNA; Preq: preNA; Cost: 0; Maint: 0; Expiration: 0), // {22}
961 (Kind: ikNA; Preq: preNA; Cost: 0; Maint: 0; Expiration: 0), // {23}
962 (Kind: ikNA; Preq: preNA; Cost: 0; Maint: 0; Expiration: 0), // {24}
963 (Kind: ikNA; Preq: preNA; Cost: 0; Maint: 0; Expiration: 0), // {25}
964 (Kind: ikNA; Preq: preNA; Cost: 0; Maint: 0; Expiration: 0), // {26}
965 (Kind: ikNA; Preq: preNA; Cost: 0; Maint: 0; Expiration: 0), // {27}
966 (Kind: ikTrGoods; Preq: preNone; Cost: 0; Maint: 0; Expiration: 0), // imTrGoods
967 (Kind: ikCommon; Preq: adWarriorCode; Cost: 40; Maint: 1; Expiration: 0), // imBarracks
968 (Kind: ikCommon; Preq: adPottery; Cost: 60; Maint: 1; Expiration: 0), // imGranary
969 (Kind: ikCommon; Preq: adCeremonialBurial; Cost: 40; Maint: 1; Expiration: 0), // imTemple
970 (Kind: ikCommon; Preq: adCurrency; Cost: 60; Maint: 1; Expiration: 0), // imMarket
971 (Kind: ikCommon; Preq: adWriting; Cost: 80; Maint: 3; Expiration: 0), // imLibrary
972 (Kind: ikCommon; Preq: adCodeOfLaws; Cost: 80; Maint: 2; Expiration: 0), // imCourt
973 (Kind: ikCommon; Preq: adMasonry; Cost: 80; Maint: 1; Expiration: 0), // imWalls
974 (Kind: ikCommon; Preq: adConstruction; Cost: 80; Maint: 1; Expiration: 0), // imAqueduct
975 (Kind: ikCommon; Preq: adBanking; Cost: 120; Maint: 2; Expiration: 0), // imBank
976 (Kind: ikCommon; Preq: adMonotheism; Cost: 100; Maint: 1; Expiration: 0), // imCathedral
977 (Kind: ikCommon; Preq: adUniversity; Cost: 160; Maint: 5; Expiration: 0), // imUniversity
978 (Kind: ikCommon; Preq: adSeafaring; Cost: 60; Maint: 1; Expiration: 0), // imHarbor
979 (Kind: ikCommon; Preq: adPoetry; Cost: 60; Maint: 2; Expiration: 0), // imTheater
980 (Kind: ikCommon; Preq: adIndustrialization; Cost: 200; Maint: 3; Expiration: 0), // imFactory
981 (Kind: ikCommon; Preq: adRobotics; Cost: 320; Maint: 5; Expiration: 0), // imMfgPlant
982 (Kind: ikCommon; Preq: adRecycling; Cost: 320; Maint: 4; Expiration: 0), // imRecycling
983 (Kind: ikCommon; Preq: adElectricity; Cost: 120; Maint: 2; Expiration: 0), // imPower
984 (Kind: ikCommon; Preq: adEnvironmentalism; Cost: 120; Maint: 1; Expiration: 0), // imHydro
985 (Kind: ikCommon; Preq: adNuclearPower; Cost: 240; Maint: 2; Expiration: 0), // imNuclear
986 (Kind: ikCommon; Preq: adRefining; Cost: 160; Maint: 2; Expiration: 0), // imPlatform
987 (Kind: ikCommon; Preq: preNone; Cost: 40; Maint: 1; Expiration: 0), // imTownHall
988 (Kind: ikCommon; Preq: adSanitation; Cost: 120; Maint: 2; Expiration: 0), // imSewer
989 (Kind: ikCommon; Preq: adRefrigeration; Cost: 80; Maint: 2; Expiration: 0), // imSupermarket
990 (Kind: ikCommon; Preq: adAutomobile; Cost: 160; Maint: 4; Expiration: 0), // imHighways
991 (Kind: ikCommon; Preq: adComputers; Cost: 240; Maint: 7; Expiration: 0), // imResLab
992 (Kind: ikCommon; Preq: adAdvancedRocketry; Cost: 100; Maint: 1; Expiration: 0),
993 // imMissileBat
994 (Kind: ikCommon; Preq: adMetallurgy; Cost: 80; Maint: 1; Expiration: 0), // imCoastalFort
995 (Kind: ikCommon; Preq: adAdvancedFlight; Cost: 160; Maint: 1; Expiration: 0), // imAirport
996 (Kind: ikCommon; Preq: adAmphibiousWarfare; Cost: 80; Maint: 1; Expiration: 0), // imDockyard
997 (Kind: ikNatLocal; Preq: preNone; Cost: 100; Maint: 0; Expiration: 0), // imPalace
998 (Kind: ikNatLocal; Preq: adEngineering; Cost: 400; Maint: 4; Expiration: 0), // imGrWall
999 (Kind: ikNatLocal; Preq: adConstruction; Cost: 200; Maint: 4; Expiration: 0), // imColosseum
1000 (Kind: ikNatLocal; Preq: adAstronomy; Cost: 300; Maint: 4; Expiration: 0), // imObservatory
1001 (Kind: ikNatLocal; Preq: adTactics; Cost: 100; Maint: 4; Expiration: 0), // imMilAcademy
1002 (Kind: ikNatLocal; Preq: adSteel; Cost: 200; Maint: 2; Expiration: 0), // imBunker
1003 (Kind: ikNatLocal; Preq: adSyntheticFood; Cost: 120; Maint: 2; Expiration: 0), // imAlgae
1004 (Kind: ikNatGlobal; Preq: adTheCorporation; Cost: 320; Maint: 4; Expiration: 0), // imStockEx
1005 (Kind: ikNatLocal; Preq: adSpaceFlight; Cost: 400; Maint: 0; Expiration: 0), // imSpacePort
1006 (Kind: ikShipPart; Preq: adTransstellarColonization; Cost: 240; Maint: 0; Expiration: 0),
1007 // imShipComp
1008 (Kind: ikShipPart; Preq: adImpulseDrive; Cost: 600; Maint: 0; Expiration: 0), // imShipPow
1009 (Kind: ikShipPart; Preq: adSelfContainedEnvironment; Cost: 800; Maint: 0; Expiration: 0));
1010// imShipHab
1011
1012nImpReplacement = 5;
1013ImpReplacement: array [0 .. nImpReplacement - 1] of record
1014 NewImp: Integer;
1015 OldImp: Integer;
1016end
1017= ((NewImp: imSewer; OldImp: imAqueduct), (NewImp: imCourt; OldImp: imTownHall),
1018 (NewImp: imPalace; OldImp: imTownHall), (NewImp: imPalace; OldImp: imCourt),
1019 (NewImp: imMilAcademy; OldImp: imBarracks));
1020
1021// colony ship
1022nShipPart = 3;
1023spComp = 0;
1024spPow = 1;
1025spHab = 2;
1026ShipNeed: array [0 .. nShipPart - 1] of Integer = (6, 4, 2);
1027ShipImpIndex: array [0 .. nShipPart - 1] of Integer = (imShipComp, imShipPow, imShipHab);
1028
1029GovPreq: array [1 .. nGov - 1] of Integer = { government prerequisites }
1030 (preNone, adMonarchy, adTheRepublic, adTheology, adCommunism, adDemocracy,
1031 adInternet);
1032
1033AgePreq: array [1 .. 3] of Integer = (adScience, adMassProduction,
1034 adTransstellarColonization);
1035
1036Terrain: array [0 .. 11] of record
1037 MoveCost: Integer;
1038 Defense: Integer;
1039 ClearTerrain: Integer;
1040 IrrEff: Integer;
1041 IrrClearWork: Integer;
1042 AfforestTerrain: Integer;
1043 MineEff: Integer;
1044 MineAfforestWork: Integer;
1045 TransTerrain: Integer;
1046 TransWork: Integer;
1047 FoodRes: array [0 .. 2] of Integer;
1048 ProdRes: array [0 .. 2] of Integer;
1049 TradeRes: array [0 .. 2] of Integer;
1050 Filler: array [0 .. 12] of Integer;
1051end
1052= ((MoveCost: 1; Defense: 4; ClearTerrain: - 1; IrrEff: 0; IrrClearWork: 0;
1053 AfforestTerrain: - 1; MineEff: 0; MineAfforestWork: 0; TransTerrain: - 1;
1054 TransWork: 0; FoodRes: (0, 0, 0); ProdRes: (0, 0, 0);
1055 TradeRes: (0, 0, 0); Filler: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), { Ocn }
1056 (MoveCost: 1; Defense: 4; ClearTerrain: - 1; IrrEff: 0; IrrClearWork: 0;
1057 AfforestTerrain: - 1; MineEff: 0; MineAfforestWork: 0; TransTerrain: - 1;
1058 TransWork: 0; FoodRes: (1, 5, 1); ProdRes: (0, 0, 5);
1059 TradeRes: (3, 3, 3); Filler: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), { Sho }
1060 (MoveCost: 1; Defense: 4; ClearTerrain: - 1; IrrEff: 1; IrrClearWork: 600;
1061 AfforestTerrain: fForest; MineEff: 0; MineAfforestWork: 1800;
1062 TransTerrain: fHills; TransWork: 3000; FoodRes: (3, 2, 2); ProdRes: (0, 1, 0);
1063 TradeRes: (1, 1, 1); Filler: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), { Gra }
1064 (MoveCost: 1; Defense: 4; ClearTerrain: fGrass; IrrEff: 0; IrrClearWork: 1800;
1065 AfforestTerrain: - 1; MineEff: 1; MineAfforestWork: 600;
1066 TransTerrain: fPrairie; TransWork: 3000; FoodRes: (0, 3, 0);
1067 ProdRes: (1, 1, 4); TradeRes: (1, 1, 1); Filler: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), { Dst }
1068 (MoveCost: 1; Defense: 4; ClearTerrain: - 1; IrrEff: 1; IrrClearWork: 600;
1069 AfforestTerrain: fForest; MineEff: 0; MineAfforestWork: 2400;
1070 TransTerrain: - 1; TransWork: 0; FoodRes: (1, 3, 1); ProdRes: (1, 1, 3);
1071 TradeRes: (1, 1, 1); Filler: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), { Pra }
1072 (MoveCost: 1; Defense: 4; ClearTerrain: - 1; IrrEff: 1; IrrClearWork: 600;
1073 AfforestTerrain: - 1; MineEff: 0; MineAfforestWork: 0; TransTerrain: fGrass;
1074 TransWork: 3000; FoodRes: (1, 1, 1); ProdRes: (0, 0, 4);
1075 TradeRes: (1, 6, 1); Filler: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), { Tun }
1076 (MoveCost: 2; Defense: 4; ClearTerrain: - 1; IrrEff: 0; IrrClearWork: 0;
1077 AfforestTerrain: - 1; MineEff: 3; MineAfforestWork: 1800; TransTerrain: - 1;
1078 TransWork: 0; FoodRes: (0, 3, 0); ProdRes: (1, 1, 0);
1079 TradeRes: (0, 4, 0); Filler: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), { Arc }
1080 (MoveCost: 2; Defense: 6; ClearTerrain: fGrass; IrrEff: 0; IrrClearWork: 2400;
1081 AfforestTerrain: fForest; MineEff: 0; MineAfforestWork: 2400;
1082 TransTerrain: fHills; TransWork: 3000; FoodRes: (1, 1, 1); ProdRes: (0, 4, 1);
1083 TradeRes: (1, 1, 5); Filler: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), { Swa }
1084 (MoveCost: 0; Defense: 0; ClearTerrain: 0; IrrEff: 0;
1085 IrrClearWork: 0; AfforestTerrain: 0; MineEff: 0; MineAfforestWork: 0;
1086 TransTerrain: 0; TransWork: 0; FoodRes: (0, 0, 0); ProdRes: (0, 0, 0);
1087 TradeRes: (0, 0, 0); Filler: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), { - }
1088 (MoveCost: 2; Defense: 6; ClearTerrain: fPrairie; IrrEff: 0;
1089 IrrClearWork: 600; AfforestTerrain: - 1; MineEff: 0; MineAfforestWork: 0;
1090 TransTerrain: - 1; TransWork: 0; FoodRes: (1, 3, 1); ProdRes: (2, 2, 2);
1091 TradeRes: (1, 1, 4); Filler: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), { For }
1092 (MoveCost: 2; Defense: 8; ClearTerrain: - 1; IrrEff: 1; IrrClearWork: 600;
1093 AfforestTerrain: - 1; MineEff: 3; MineAfforestWork: 1200;
1094 TransTerrain: fGrass; TransWork: 6000; FoodRes: (1, 1, 1); ProdRes: (0, 0, 2);
1095 TradeRes: (0, 4, 0); Filler: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), { Hil }
1096 (MoveCost: 3; Defense: 12; ClearTerrain: - 1; IrrEff: 0; IrrClearWork: 0;
1097 AfforestTerrain: - 1; MineEff: 2; MineAfforestWork: 1200; TransTerrain: - 1;
1098 TransWork: 0; FoodRes: (0, 0, 0); ProdRes: (1, 4, 1);
1099 TradeRes: (0, 0, 7); Filler: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))); { Mou }
1100
1101// settler work required MP
1102PillageWork = 100;
1103CityWork = 900;
1104FarmWork = 3; // *IrrClearWork
1105RoadWork = 300; // *MoveCost
1106RoadBridgeWork = 900;
1107RRWork = 600; // *MoveCost
1108RRBridgeWork = 900;
1109CanalWork = 1800;
1110FortWork = 600; // *MoveCost
1111BaseWork = 600; // *MoveCost
1112PollWork = 1800;
1113
1114// upgrades for new unit models
1115// upgrade[domain,0].preq is domain precondition advance
1116// cost values accumulate if prerequisite is future tech / are maximized if not
1117nUpgrade = 15;
1118upgrade: array [0 .. nDomains - 1, 0 .. nUpgrade - 1] of record
1119 Preq: Integer;
1120 Strength: Integer;
1121 Trans: Integer;
1122 Cost: integer;
1123end
1124= (((Preq: adWarriorCode; Strength: 4; Trans: 0; Cost: 3),
1125 (Preq: adBronzeWorking; Strength: 2; Trans: 0; Cost: 4),
1126 (Preq: adIronWorking; Strength: 2; Trans: 0; Cost: 5),
1127 (Preq: adChivalry; Strength: 2; Trans: 0; Cost: 5),
1128 (Preq: adMonotheism; Strength: 3; Trans: 0; Cost: 7),
1129 (Preq: adGunpowder; Strength: 3; Trans: 0; Cost: 8),
1130 (Preq: adExplosives; Strength: 4; Trans: 0; Cost: 9),
1131 (Preq: adTactics; Strength: 5; Trans: 0; Cost: 10),
1132 (Preq: adRadio; Strength: 6; Trans: 0; Cost: 11),
1133 (Preq: adDemocracy; Strength: 6; Trans: 0; Cost: 5),
1134 (Preq: adMobileWarfare; Strength: 7; Trans: 0; Cost: 12),
1135 (Preq: adRobotics; Strength: 8; Trans: 0; Cost: 15),
1136 (Preq: adComposites; Strength: 8; Trans: 0; Cost: 15),
1137 (Preq: adTheLaser; Strength: 8; Trans: 0; Cost: 14),
1138 (Preq: futMaterialTechnology; Strength: 10; Trans: 0; Cost: 2)),
1139 ((Preq: adMapMaking; Strength: 4; Trans: 1; Cost: 8),
1140 (Preq: adNavigation; Strength: 4; Trans: 0; Cost: 10),
1141 (Preq: adEngineering; Strength: 0; Trans: 1; Cost: 8),
1142 (Preq: adGunpowder; Strength: 8; Trans: 0; Cost: 12),
1143 (Preq: adMagnetism; Strength: 12; Trans: 1; Cost: 20),
1144 (Preq: adExplosives; Strength: 16; Trans: 0; Cost: 24),
1145 (Preq: adSteamEngine; Strength: 24; Trans: 0; Cost: 28),
1146 (Preq: adAmphibiousWarfare; Strength: 24; Trans: 1; Cost: 18),
1147 (Preq: adAdvancedRocketry; Strength: 32; Trans: 0; Cost: 38),
1148 (Preq: futMaterialTechnology; Strength: 14; Trans: 0; Cost: 4),
1149 (Preq: futArtificialIntelligence; Strength: 14; Trans: 0; Cost: 4),
1150 (Preq: preNA; Strength: 0; Trans: 0; Cost: 0),
1151 (Preq: preNA; Strength: 0; Trans: 0; Cost: 0),
1152 (Preq: preNA; Strength: 0; Trans: 0; Cost: 0),
1153 (Preq: preNA; Strength: 0; Trans: 0; Cost: 0)),
1154 ((Preq: adFlight; Strength: 12; Trans: 1; Cost: 14),
1155 (Preq: adTactics; Strength: 6; Trans: 0; Cost: 17),
1156 (Preq: adElectronics; Strength: 6; Trans: 0; Cost: 20),
1157 (Preq: adMin; Strength: 8; Trans: 0; Cost: 24),
1158 (Preq: adComposites; Strength: 8; Trans: 0; Cost: 26),
1159 (Preq: adSmartWeapons; Strength: 11; Trans: 0; Cost: 32),
1160 (Preq: futArtificialIntelligence; Strength: 7; Trans: 0; Cost: 4),
1161 (Preq: preNA; Strength: 0; Trans: 0; Cost: 0),
1162 (Preq: preNA; Strength: 0; Trans: 0; Cost: 0),
1163 (Preq: preNA; Strength: 0; Trans: 0; Cost: 0),
1164 (Preq: preNA; Strength: 0; Trans: 0; Cost: 0),
1165 (Preq: preNA; Strength: 0; Trans: 0; Cost: 0),
1166 (Preq: preNA; Strength: 0; Trans: 0; Cost: 0),
1167 (Preq: preNA; Strength: 0; Trans: 0; Cost: 0),
1168 (Preq: preNA; Strength: 0; Trans: 0; Cost: 0)));
1169
1170{ model features }
1171nFeature = 27;
1172mcWeapons = 0;
1173mcArmor = 1;
1174mcMob = 2;
1175mcSeaTrans = 3;
1176mcCarrier = 4;
1177mcTurbines = 5;
1178mcBombs = 6;
1179mcFuel = 7;
1180mcAirTrans = 8;
1181mcNav = 9;
1182mcRadar = 10;
1183mcSub = 11;
1184mcArtillery = 12;
1185mcAlpine = 13;
1186mcSupplyShip = 14;
1187mcOver = 15;
1188mcAirDef = 16;
1189mcSpy = 17;
1190mcSE = 18;
1191mcNP = 19;
1192mcJet = 20;
1193mcStealth = 21;
1194mcFanatic = 22;
1195mcFirst = 23;
1196mcWill = 24;
1197mcAcademy = 25;
1198mcLine = 26;
1199mcFirstNonCap = mcNav;
1200AutoFeature: set of mcFirstNonCap .. nFeature - 1 = [mcNav, mcSE, mcNP, mcJet,
1201 mcAcademy];
1202// unit class advances, automatically applied if available
1203
1204Feature: array [0 .. nFeature - 1] of { unit model features }
1205 record
1206 Domains: Integer;
1207 Preq: Integer;
1208 Weight: Integer;
1209 Cost: Integer;
1210 end
1211= ((Domains: 7; Preq: preNone; Weight: 1; Cost: 1), { mcOffense }
1212 (Domains: 7; Preq: preNone; Weight: 1; Cost: 1), { mcDefense }
1213 (Domains: 1; Preq: adHorsebackRiding; Weight: 1; Cost: 1), { mcMob }
1214 (Domains: 2; Preq: preNone; Weight: 2; Cost: 1), { mcSeaTrans }
1215 (Domains: 2; Preq: adAdvancedFlight; Weight: 2; Cost: 2), { mcCarrier }
1216 (Domains: 2; Preq: adPhysics; Weight: 3; Cost: 1), { mcTurbines }
1217 (Domains: 4; Preq: adAdvancedFlight; Weight: 1; Cost: 1), { mcBombs }
1218 (Domains: 4; Preq: preNone; Weight: 1; Cost: 1), { mcFuel }
1219 (Domains: 4; Preq: adCombinedArms; Weight: 2; Cost: 1), { mcAirTrans }
1220 (Domains: 2; Preq: adNavigation; Weight: 0; Cost: 0), { mcNav }
1221 (Domains: 2; Preq: adRadio; Weight: 0; Cost: 1), { mcRadar }
1222 (Domains: 2; Preq: adCombustionEngine; Weight: 2; Cost: 1), { mcSub }
1223 (Domains: 3; Preq: adBallistics; Weight: 1; Cost: 1), { mcArtillery }
1224 (Domains: 1; Preq: adTactics; Weight: 2; Cost: 1), { mcAlpine }
1225 (Domains: 2; Preq: adMedicine; Weight: 1; Cost: 1), { mcSupplyShip }
1226 (Domains: 1; Preq: adBridgeBuilding; Weight: 0; Cost: 2), { mcOver }
1227 (Domains: 2; Preq: adAdvancedRocketry; Weight: 1; Cost: 1), { mcAirDef }
1228 (Domains: 4; Preq: adIntelligence; Weight: 2; Cost: 1), { mcSpy }
1229 (Domains: 2; Preq: adSteamEngine; Weight: 0; Cost: 0), { mcSE }
1230 (Domains: 2; Preq: adNuclearPower; Weight: 0; Cost: 0), { mcNP }
1231 (Domains: 4; Preq: adRocketry; Weight: 0; Cost: 0), { mcJet }
1232 (Domains: 4; Preq: adStealth; Weight: 1; Cost: 2), { mcStealth }
1233 (Domains: 5; Preq: adCommunism; Weight: 0; Cost: 1), { mcFanatic }
1234 (Domains: 1; Preq: preSun; Weight: 0; Cost: 1), { mcFirst }
1235 (Domains: 1; Preq: preSun; Weight: 0; Cost: 1), { mcWill }
1236 (Domains: 1; Preq: preSun; Weight: 0; Cost: 0), { mcAcademy }
1237 (Domains: 7; Preq: adMassProduction; Weight: 0; Cost: 0)); { mcLine }
1238
1239WeightPreq7: array [0 .. nDomains - 1] of Integer = (adHorsebackRiding, adSeafaring,
1240 adAdvancedFlight);
1241WeightPreq10: array [0 .. nDomains - 1] of Integer = (adAutomobile, adSteel, preNA);
1242
1243INFIN = 999999;
1244
1245// for backward compatibility
1246fRare = fDeadLands;
1247fRare1 = fCobalt;
1248fRare2 = fUranium;
1249mkCaravan = mkFreight;
1250mkDiplomat = mkCommando;
1251gLybertarianism = gFuture;
1252trCeaseFire = 1;
1253adIntelligenArms = adSmartWeapons;
1254adIntelligentArms = adSmartWeapons;
1255adRadioCommunication = adRadio;
1256adLybertarianism = adInternet;
1257futResearchTechnology = futComputingTechnology;
1258futProductionTechnology = futNanoTechnology;
1259futArmorTechnology = futMaterialTechnology;
1260futMissileTechnology = futArtificialIntelligence;
1261imNatObs = imObservatory;
1262imElite = imMilAcademy;
1263mcOffense = mcWeapons;
1264mcDefense = mcArmor;
1265mcLongRange = mcArtillery;
1266mcHospital = mcSupplyShip;
1267
1268// Wonders CityID constants
1269WonderNotBuiltYet = -1;
1270WonderDestroyed = -2;
1271
1272type
1273 TServerCall = function (Command, Player, Subject: Integer; var Data)
1274 : Integer; stdcall;
1275 TClientCall = procedure (Command, Player: Integer; var Data); stdcall;
1276
1277 TUn = packed record
1278 Loc: LongInt; { location }
1279 Status: LongInt; // free for AI use
1280 SavedStatus: LongInt; // for server internal use only
1281 ID: Word; // unit number, never changes, unique within this nation
1282 mix: SmallInt; { model index }
1283 Home: SmallInt; { home city index, -1 if none }
1284 Master: SmallInt; { index of transporting unit, -1 if none }
1285 Movement: SmallInt; { movement left for this turn }
1286 Health: ShortInt; // = 100-Damage
1287 Fuel: ShortInt;
1288 Job: Byte; { current terrain improvement job }
1289 Exp: Byte; { micro experience, the level is Exp div ExpCost }
1290 TroopLoad: Byte; { number of transported ground units }
1291 AirLoad: Byte; // number of transported air units
1292 Flags: Cardinal;
1293 end;
1294 PUn = ^TUn;
1295
1296 { TCity }
1297
1298 TCity = packed record
1299 Loc: LongInt; { location }
1300 Status: LongInt; // free for AI use
1301 SavedStatus: LongInt; // for server internal use only
1302 ID: Word; // founding player shl 12 + number, never changes, unique within the whole game
1303 Size: Word;
1304 Project: SmallInt; // current production project, see city project flags
1305 Project0: SmallInt; // for server use only
1306 Food: SmallInt; // collected food in storage
1307 Pollution: SmallInt; // collected pollution in dump
1308 Prod: SmallInt; // for project collected production points
1309 Prod0: SmallInt;
1310 // for project collected production points in the beginning of the turn
1311 Flags: Cardinal; // what happened within the last turnaround
1312 Tiles: Cardinal; { currently by city exploited tiles, bitset with index
1313 (dy+3) shl 2+(dx+3) shr 1, (dx,dy) relative to central tile }
1314 N1: Cardinal; // reserved for future use
1315 Built: array [0 .. (nImp + 3) div 4 * 4 - 1] of ShortInt;
1316 // array value =1 indicates built improvement
1317 end;
1318 PCity = ^TCity;
1319
1320 TModel = packed record
1321 Status: LongInt; // free for AI use
1322 SavedStatus: LongInt; // for server internal use only
1323 ID: Word; // developing player shl 12 + number, never changes, unique within the whole game
1324 IntroTurn: Word;
1325 Built: Word; // units built with this model
1326 Lost: Word; // units of this model lost in combat
1327 Kind: Byte;
1328 Domain: Byte;
1329 Attack: Word;
1330 Defense: Word;
1331 Speed: Word;
1332 Cost: Word;
1333 MStrength: Word;
1334 // construction time multipliers, only valid if kind is mkSelfDeveloped or mkEnemyDeveloped
1335 MTrans: Byte;
1336 MCost: Byte;
1337 Weight: Byte;
1338 MaxWeight: Byte;
1339 // weight and maximum weight (construction time)
1340 Upgrades: Cardinal; // bitarray indicating all upgrades
1341 Flags: Cardinal;
1342 Cap: array [0 .. (nFeature + 3) div 4 * 4 - 1] of Byte; // special features
1343 end;
1344
1345 TUnitInfo = packed record
1346 Loc: LongInt;
1347 mix: Word; // index of unit model for its owner
1348 emix: Word; // index in enemy model list
1349 Owner: Byte;
1350 Health: ShortInt; // = 100-Damage
1351 Fuel: ShortInt;
1352 Job: Byte; // current terrain improvement job
1353 Exp: Byte; { micro experience, the level is Exp div ExpCost }
1354 Load: Byte; { number of transported units }
1355 Flags: Word;
1356 end;
1357 PUnitInfo = ^TUnitInfo;
1358
1359 TCityInfo = packed record
1360 Loc: LongInt;
1361 Status: LongInt; // free for AI use
1362 SavedStatus: LongInt; // for server internal use only
1363 Owner: Word; // last known owner, even if not alive anymore!
1364 ID: Word; // founding player <<12 + number, never changes, unique within the whole game
1365 Size: Word;
1366 Flags: Word;
1367 end;
1368 PCityInfo = ^TCityInfo;
1369
1370 TModelInfo = packed record
1371 Owner: Word; // Player which owns the model
1372 mix: Word; // index of unit model for its owner
1373 ID: Word; // developing player shl 12 + number, never changes, unique within the whole game
1374 Kind: Byte;
1375 Domain: Byte;
1376 Attack: Word;
1377 Defense: Word;
1378 Speed: Word;
1379 Cost: Word;
1380 TTrans: Byte; // ground unit transport capability
1381 ATrans_Fuel: Byte; // air unit transport capability resp. fuel
1382 Bombs: Word; // additional attack with bombs
1383 Cap: Cardinal; // special features, bitset with index Feature-mcFirstNonCap
1384 MaxUpgrade: Byte; // maximum used upgrade
1385 Weight: Byte;
1386 Lost: Word;
1387 end;
1388
1389 TBattle = packed record
1390 Enemy: Byte;
1391 Flags: Byte;
1392 Turn: Word;
1393 mix: Word;
1394 mixEnemy: Word;
1395 ToLoc: Integer;
1396 FromLoc: Integer;
1397 end;
1398
1399 TWonderInfo = record
1400 CityID: Integer; // -2 if destroyed, -1 if never completed, >=0 ID of city
1401 EffectiveOwner: Integer;
1402 // owning player if effective, -1 if expired or not built
1403 end;
1404
1405 TShipInfo = record
1406 Parts: array [0 .. nShipPart - 1] of Integer;
1407 end;
1408
1409 TEnemyReport = record
1410 TurnOfContact: Integer;
1411 TurnOfCivilReport: Integer;
1412 TurnOfMilReport: Integer;
1413 Attitude: Integer;
1414 Credibility: Integer; // 0..100, last update: ToC
1415 Treaty: array [0 .. nPl - 1] of Integer;
1416 // diplomatic status with other nations, last update: ToCR
1417 Government: Integer; // gAnarchy..gDemocracy, last update: ToCR
1418 Money: Integer; // last update: ToCR
1419 ResearchTech: Integer; // last update: ToCR
1420 ResearchDone: Integer; // last update: ToCR
1421 Tech: array [0 .. (nAdv + 3) div 4 * 4 - 1] of ShortInt;
1422 // tech status indicator, last update: ToCR
1423 nModelCounted: Integer;
1424 // number of models with info in UnCount, last update: ToMR
1425 UnCount: array [0 .. INFIN] of Word;
1426 // number of available units for each model, last update: ToMR
1427 end;
1428
1429 TMoveAdviceData = record
1430 ToLoc: Integer;
1431 nStep: Integer;
1432 MoreTurns: Integer;
1433 MaxHostile_MovementLeft: Integer;
1434 dx: array [0 .. 24] of Integer;
1435 dy: array [0 .. 24] of Integer;
1436 end;
1437
1438 TPlaneReturnData = record
1439 Loc: Integer;
1440 Fuel: Integer;
1441 Movement: Integer;
1442 end;
1443
1444 TTileInfo = record
1445 Food: Integer;
1446 Prod: Integer;
1447 Trade: Integer;
1448 ExplCity: Integer;
1449 end;
1450
1451 TCityReport = record
1452 HypoTiles: Integer;
1453 HypoTax: Integer;
1454 HypoLux: Integer;
1455 Working: Integer;
1456 Happy: Integer;
1457 FoodRep: Integer;
1458 ProdRep: Integer;
1459 Trade: Integer;
1460 PollRep: Integer;
1461 Corruption: Integer;
1462 Tax: Integer;
1463 Lux: Integer;
1464 Science: Integer;
1465 Support: Integer;
1466 Eaten: Integer;
1467 ProdCost: Integer;
1468 Storage: Integer;
1469 Deployed: Integer;
1470 end;
1471
1472 TCityReportNew = record
1473 HypoTiles: Integer;
1474 // tiles that should be considered as exploited (for the current adjustment, set this to -1 or to TCity.Tiles of the city)
1475 HypoTaxRate: Integer;
1476 HypoLuxuryRate: Integer;
1477 // tax and luxury rate that should be assumed (for current rates, set this to -1 or to RO.TaxRate resp. RO.LuxRate)
1478 Morale: Integer;
1479 FoodSupport: Integer;
1480 MaterialSupport: Integer;
1481 // food and material taken for unit support
1482 ProjectCost: Integer; // material cost of current project
1483 Storage: Integer; // size of food storage
1484 Deployed: Integer; // number of units causing unrest (unrest=2*deployed)
1485 CollectedControl: Integer;
1486 CollectedFood: Integer;
1487 CollectedMaterial: Integer;
1488 CollectedTrade: Integer;
1489 // raw control, food, material and trade as collected by the citizens
1490 Working: Integer; // number of exploited tiles including city tile
1491 FoodSurplus: Integer;
1492 Production: Integer;
1493 AddPollution: Integer;
1494 // food surplus, production gain and pollution after all effects
1495 Corruption: Integer;
1496 Tax: Integer;
1497 Science: Integer;
1498 Luxury: Integer;
1499 // corruption, tax, science and wealth after all effects
1500 HappinessBalance: Integer;
1501 // = (Morale+Wealth+Control) - (Size+Unrest), value < 0 means disorder
1502 end;
1503
1504 TCityTileAdviceData = record
1505 ResourceWeights: Cardinal;
1506 Tiles: Cardinal;
1507 CityReport: TCityReport;
1508 end;
1509
1510 TGetCityData = record
1511 Owner: Integer;
1512 c: TCity;
1513 end;
1514
1515 TCityAreaInfo = record
1516 Available: array [0 .. 26] of Integer;
1517 end;
1518
1519 TUnitReport = record
1520 FoodSupport: Integer;
1521 ProdSupport: Integer;
1522 ReportFlags: Integer;
1523 end;
1524
1525 TJobProgressData = array [0 .. nJob - 1] of record
1526 Required, Done,
1527 NextTurnPlus: Integer;
1528 end;
1529
1530 TBattleForecast = record
1531 pAtt: Integer;
1532 mixAtt: Integer;
1533 HealthAtt: Integer;
1534 ExpAtt: Integer;
1535 FlagsAtt: Integer;
1536 Movement: Integer;
1537 EndHealthDef: Integer;
1538 EndHealthAtt: Integer;
1539 end;
1540
1541 TBattleForecastEx = record
1542 pAtt: Integer;
1543 mixAtt: Integer;
1544 HealthAtt: Integer;
1545 ExpAtt: Integer;
1546 FlagsAtt: Integer;
1547 Movement: Integer;
1548 EndHealthDef: Integer;
1549 EndHealthAtt: Integer; // must be same as in TBattleForecast
1550 AStr: Integer;
1551 DStr: Integer;
1552 ABaseDamage: Integer;
1553 DBaseDamage: Integer;
1554 end;
1555
1556 TShowMove = record
1557 Owner: Integer;
1558 Health: Integer;
1559 mix: Integer;
1560 emix: Integer;
1561 Flags: Integer;
1562 FromLoc: Integer;
1563 dx: Integer;
1564 dy: Integer;
1565 EndHealth: Integer;
1566 EndHealthDef: Integer;
1567 Fuel: Integer;
1568 Exp: Integer;
1569 Load: Integer;
1570 end;
1571
1572 TShowShipChange = record
1573 Reason: Integer;
1574 Ship1Owner: Integer;
1575 Ship2Owner: Integer;
1576 Ship1Change: array [0 .. nShipPart - 1] of Integer;
1577 Ship2Change: array [0 .. nShipPart - 1] of Integer;
1578 end;
1579
1580 TOffer = record
1581 nDeliver: Integer;
1582 nCost: Integer;
1583 Price: array [0 .. 11] of Cardinal;
1584 end;
1585
1586 TChart = array [0 .. INFIN] of Integer;
1587 TEditTileData = record
1588 Loc: Integer;
1589 NewTile: Integer;
1590 end;
1591 TCreateUnitData = record
1592 Loc: Integer;
1593 p: Integer;
1594 mix: Integer;
1595 end;
1596
1597 TTileList = array [0 .. INFIN] of Cardinal;
1598 PTileList = ^TTileList;
1599 TTileObservedLastList = array [0 .. INFIN] of SmallInt;
1600 TOwnerList = array [0 .. INFIN] of ShortInt;
1601 TByteList = array [0 .. INFIN] of Byte;
1602 TIntList = array [0 .. INFIN] of integer;
1603 TCityList = array [0 .. INFIN] of TCity;
1604 TUnList = array [0 .. INFIN] of TUn;
1605 TModelList = array [0 .. INFIN] of TModel;
1606 TEnemyUnList = array [0 .. INFIN] of TUnitInfo;
1607 TEnemyCityList = array [0 .. INFIN] of TCityInfo;
1608 TEnemyModelList = array [0 .. INFIN] of TModelInfo;
1609 TBattleList = array [0 .. INFIN] of TBattle;
1610
1611 TPlayerContext = record
1612 Data: Pointer;
1613 Map: ^TTileList;
1614 { the playground, a list of tiles with index = location, see tile flags }
1615 MapObservedLast: ^TTileObservedLastList;
1616 // turn in which the tile was observed last, index = location
1617 Territory: ^TOwnerList; // nation to which's territory a tile belongs, -1 indicates none
1618 Un: ^TUnList; { units }
1619 City: ^TCityList; { cities }
1620 Model: ^TModelList; { unit models }
1621 EnemyUn: ^TEnemyUnList; // known units of enemy players
1622 EnemyCity: ^TEnemyCityList; // known cities of enemy players
1623 EnemyModel: ^TEnemyModelList; // known unit models of enemy players
1624 EnemyReport: array [0 .. nPl - 1] of ^TEnemyReport;
1625
1626 TestFlags: Integer; // options turned on in the "Manipulation" menu
1627 Turn: Integer; // current turn
1628 Alive: Integer; { bitset of IDs of players still alive, flag 1 shl p for player p }
1629 Happened: Integer; // flags indicate what happened within the last turnaround
1630 AnarchyStart: Integer; // start turn of anarchy, <0 if not in anarchy
1631 Credibility: Integer; // own credibility
1632 MaxCredibility: Integer; // maximum credibility still to achieve
1633 nUn: Integer; { number of units }
1634 nCity: Integer; { number of cities }
1635 nModel: Integer; { number of developed unit models }
1636 nEnemyUn: Integer;
1637 nEnemyCity: Integer;
1638 nEnemyModel: Integer;
1639 Government: Integer; { gAnarchy..gDemocracy }
1640 Money: Integer;
1641 TaxRate: Integer;
1642 LuxRate: Integer;
1643 Research: Integer;
1644 { collected research points for currently researched tech }
1645 ResearchTech: Integer; // currently researched tech
1646 DevModel: TModel; { unit model currently under development }
1647 Tech: array [0 .. (nAdv + 3) div 4 * 4 - 1] of ShortInt; { tech status indicator }
1648 Attitude: array [0 .. nPl - 1] of Integer; // attitude to other nations
1649 Treaty: array [0 .. nPl - 1] of Integer; // treaty with other nations
1650 EvaStart: array [0 .. nPl - 1] of Integer; // peace treaty: start of evacuation period
1651 Tribute: array [0 .. nPl - 1] of Integer; // no longer in use
1652 TributePaid: array [0 .. nPl - 1] of Integer; // no longer in use
1653 Wonder: array [0 .. nWonder - 1] of TWonderInfo;
1654 Ship: array [0 .. nPl - 1] of TShipInfo;
1655 NatBuilt: array [nWonder .. (nImp + 3) div 4 * 4 - 1] of ShortInt;
1656 nBattleHistory: Integer;
1657 BattleHistory: ^TBattleList; // complete list of all my battles in the whole game
1658 BorderHelper: ^TByteList;
1659 LastCancelTreaty: array [0 .. nPl - 1] of Integer; // turn of last treaty cancel
1660 OracleIncome: Integer;
1661 DefaultDebugMap: ^TIntList;
1662 Filler: array [0 .. 879] of Byte;
1663 end;
1664
1665 TInitModuleData = record
1666 Server: TServerCall;
1667 DataVersion: Integer;
1668 DataSize: Integer;
1669 Flags: Integer;
1670 end;
1671
1672 TNewGameData = record
1673 lx: Integer;
1674 ly: Integer;
1675 LandMass: Integer;
1676 MaxTurn: Integer;
1677 Difficulty: array [0 .. nPl - 1] of Integer;
1678 { difficulty levels of the players, if it's 0 this player is the supervisor,
1679 -1 for unused slots }
1680 RO: array [0 .. nPl - 1] of ^TPlayerContext;
1681 AssemblyPath: array [0 .. 255] of Char;
1682 SuperVisorRO: array [0 .. nPl - 1] of ^TPlayerContext;
1683 end;
1684
1685 TNewGameExData = record
1686 lx: Integer;
1687 ly: Integer;
1688 LandMass: Integer;
1689 MaxTurn: Integer;
1690 RND: Integer;
1691 Difficulty: array [0 .. nPl - 1] of Integer;
1692 { difficulty levels of the players, if it's 0 this player is the supervisor,
1693 -1 for unused slots }
1694 Controlled: Integer;
1695 end;
1696
1697 TShowNegoData = record
1698 pSender: Integer;
1699 pTarget: Integer;
1700 Action: Integer;
1701 Offer: TOffer;
1702 end;
1703
1704const
1705 { predefined unit models: }
1706 nSpecialModel = 9;
1707 SpecialModel: array [0 .. nSpecialModel - 1] of TModel = ((Status: 0;
1708 SavedStatus: 0; ID: 0; IntroTurn: 0; Built: 0; Lost: 0; Kind: mkSettler;
1709 Domain: dGround; Attack: 0; Defense: 10; Speed: 150; Cost: 40; MStrength: 0;
1710 MTrans: 0; MCost: 0; Weight: 0; MaxWeight: 0; Upgrades: 0; Flags: 0;
1711 Cap: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1712 0, 0, 0, 0, 0)), { Settlers }
1713 (Status: 0; SavedStatus: 0; ID: 0; IntroTurn: 0; Built: 0; Lost: 0;
1714 Kind: mkSettler; Domain: dGround; Attack: 0; Defense: 20; Speed: 300;
1715 Cost: 40; MStrength: 0; MTrans: 0; MCost: 0; Weight: 0; MaxWeight: 0;
1716 Upgrades: 0; Flags: 0; Cap: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1717 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), { Engineers }
1718 (Status: 0; SavedStatus: 0; ID: 0; IntroTurn: 0; Built: 0; Lost: 0;
1719 Kind: mkSelfDeveloped; Domain: dGround; Attack: 6; Defense: 6; Speed: 150;
1720 Cost: 10; MStrength: 0; MTrans: 0; MCost: 0; Weight: 0; MaxWeight: 0;
1721 Upgrades: 0; Flags: 0; Cap: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1722 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), { Militia }
1723 (Status: 0; SavedStatus: 0; ID: 0; IntroTurn: 0; Built: 0; Lost: 0;
1724 Kind: mkSpecial_TownGuard; Domain: dGround; Attack: 4; Defense: 6;
1725 Speed: 150; Cost: 20; MStrength: 0; MTrans: 0; MCost: 0; Weight: 0;
1726 MaxWeight: 0; Upgrades: 0; Flags: 0;
1727 Cap: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1728 0, 0, 0, 0, 0)), { Town Guard }
1729 (Status: 0; SavedStatus: 0; ID: 0; IntroTurn: 0; Built: 0; Lost: 0;
1730 Kind: mkDiplomat; Domain: dGround; Attack: 12; Defense: 12; Speed: 250;
1731 Cost: 20; MStrength: 0; MTrans: 0; MCost: 0; Weight: 0; MaxWeight: 0;
1732 Upgrades: 0; Flags: 0; Cap: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1733 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), { Special Commando }
1734 (Status: 0; SavedStatus: 0; ID: 0; IntroTurn: 0; Built: 0; Lost: 0;
1735 Kind: mkCaravan; Domain: dGround; Attack: 0; Defense: 6; Speed: 150;
1736 Cost: 60; MStrength: 0; MTrans: 0; MCost: 0; Weight: 0; MaxWeight: 0;
1737 Upgrades: 0; Flags: 0; Cap: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1738 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), { Freight }
1739 (Status: 0; SavedStatus: 0; ID: 0; IntroTurn: 0; Built: 0; Lost: 0;
1740 Kind: mkSpecial_Boat; Domain: dSea; Attack: 0; Defense: 3; Speed: 250;
1741 Cost: 20; MStrength: 0; MTrans: 1; MCost: 0; Weight: 0; MaxWeight: 0;
1742 Upgrades: 0; Flags: 0; Cap: (0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1743 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), { Longboat }
1744 (Status: 0; SavedStatus: 0; ID: 0; IntroTurn: 0; Built: 0; Lost: 0;
1745 Kind: mkSlaves; Domain: dGround; Attack: 0; Defense: 15; Speed: 150;
1746 Cost: 40; MStrength: 0; MTrans: 0; MCost: 0; Weight: 0; MaxWeight: 0;
1747 Upgrades: 0; Flags: 0; Cap: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1748 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), { Slaves }
1749 { (Status:0;SavedStatus:0;ID:0;IntroTurn:0;Built:0;Lost:0;
1750 Kind:mkSpecial_Carriage;Domain:dGround;Attack:50;Defense:30;Speed:250;Cost:50;
1751 MStrength:0;MTrans:0;MCost:0;Weight:0;MaxWeight:0;Upgrades:0;Flags:0;
1752 Cap:(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)), }
1753 { (Status:0;SavedStatus:0;ID:0;IntroTurn:0;Built:0;Lost:0;
1754 Kind:mkSpecial_SubCabin;Domain:dSea;Attack:16;Defense:1;Speed:350;Cost:40;
1755 MStrength:0;MTrans:0;MCost:0;Weight:0;MaxWeight:0;Upgrades:0;Flags:0;
1756 Cap:(0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)), }
1757 (Status: 0; SavedStatus: 0; ID: 0; IntroTurn: 0; Built: 0; Lost: 0;
1758 Kind: mkSpecial_Glider; Domain: dAir; Attack: 6; Defense: 6; Speed: 450;
1759 Cost: 30; MStrength: 0; MTrans: 0; MCost: 0; Weight: 0; MaxWeight: 0;
1760 Upgrades: 0; Flags: 0; Cap: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1761 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)));
1762
1763 SpecialModelPreq: array [0 .. nSpecialModel - 1] of integer = (preNone,
1764 adExplosives, preNone, preNone, (* adWri, *) adIntelligence, adTrade,
1765 (* adTheCorporation,adHorsebackRiding,adAutomobile,adNavigation,
1766 adCombustionEngine, *) adMapMaking, preBuilder,
1767 { preLeo,preLighthouse, } preLeo);
1768
1769var
1770 DelphiRandSeed: Integer;
1771
1772procedure MakeUnitInfo(p: Integer; const u: TUn; var ui: TUnitInfo);
1773procedure MakeModelInfo(p, mix: Integer; const m: TModel; var mi: TModelInfo);
1774function IsSameModel(const mi1, mi2: TModelInfo): Boolean;
1775function SpecialTile(Loc, TerrType, lx: Integer): Integer;
1776function DelphiRandom(const pi_Max: Integer): Integer; overload;
1777function DelphiRandom: Extended; overload;
1778procedure DelphiRandomize;
1779
1780
1781implementation
1782
1783procedure MakeUnitInfo(p: Integer; const u: TUn; var ui: TUnitInfo);
1784begin
1785 ui.Owner := p;
1786 ui.Loc := u.Loc;
1787 ui.Health := u.Health;
1788 ui.Fuel := u.Fuel;
1789 ui.Job := u.Job;
1790 ui.Exp := u.Exp;
1791 ui.Load := u.TroopLoad + u.AirLoad;
1792 ui.mix := u.mix;
1793 ui.Flags := u.Flags;
1794end;
1795
1796procedure MakeModelInfo(p, mix: Integer; const m: TModel; var mi: TModelInfo);
1797var
1798 i: Integer;
1799begin
1800 mi.Owner := p;
1801 mi.mix := mix;
1802 mi.ID := m.ID;
1803 mi.Domain := m.Domain;
1804 if m.Kind = mkEnemyDeveloped then
1805 mi.Kind := mkSelfDeveloped // important for IsSameModel()
1806 else
1807 mi.Kind := m.Kind;
1808 mi.Attack := m.Attack;
1809 mi.Defense := m.Defense;
1810 mi.Speed := m.Speed;
1811 mi.Cost := m.Cost;
1812 if mi.Domain = dAir then
1813 begin
1814 mi.TTrans := m.Cap[mcAirTrans] * m.MTrans;
1815 mi.ATrans_Fuel := m.Cap[mcFuel];
1816 end
1817 else
1818 begin
1819 mi.TTrans := m.Cap[mcSeaTrans] * m.MTrans;
1820 mi.ATrans_Fuel := m.Cap[mcCarrier] * m.MTrans;
1821 end;
1822 mi.Bombs := m.Cap[mcBombs] * m.MStrength * 2;
1823 mi.Cap := 0;
1824 for i := mcFirstNonCap to nFeature - 1 do
1825 if m.Cap[i] > 0 then
1826 mi.Cap := mi.Cap or (1 shl (i - mcFirstNonCap));
1827 mi.MaxUpgrade := 0;
1828 for i := 1 to nUpgrade - 1 do
1829 if m.Upgrades and (1 shl i) <> 0 then
1830 mi.MaxUpgrade := i;
1831 mi.Weight := m.Weight;
1832 mi.Lost := 0;
1833end;
1834
1835function IsSameModel(const mi1, mi2: TModelInfo): Boolean;
1836type
1837 TModelInfo_Compare = array [0 .. 5] of Cardinal;
1838var
1839 Compare1, Compare2: ^TModelInfo_Compare;
1840begin
1841 Compare1 := @mi1;
1842 Compare2 := @mi2;
1843 result := (Compare1[1] and $FFFF0000 = Compare2[1] and $FFFF0000) and
1844 (Compare1[2] = Compare2[2]) and (Compare1[3] = Compare2[3]) and
1845 (Compare1[4] = Compare2[4]) and (Compare1[5] = Compare2[5])
1846end;
1847
1848function SpecialTile(Loc, TerrType, lx: Integer): Integer;
1849var
1850 x, y, qx, qy, a: Integer;
1851begin
1852 if TerrType = fOcean then
1853 result := 0
1854 else
1855 begin
1856 y := Loc div lx;
1857 x := Loc - y * lx;
1858 if TerrType = fGrass then { formula for productive grassland }
1859 if Odd((lymax + x - y shr 1) shr 1 + x + (y + 1) shr 1) then
1860 result := 1
1861 else
1862 result := 0
1863 else { formula for special resources }
1864 begin
1865 a := 4 * x - y + 9980;
1866 qx := a div 10;
1867 if (qx * 10 = a) and (qx and 3 <> 0) then
1868 begin
1869 qy := (y + x) div 5;
1870 if qy and 3 <> qx shr 2 and 1 * 2 then
1871 if (TerrType = fArctic) or (TerrType = fSwamp) then
1872 result := 1
1873 else if TerrType = fShore then
1874 begin
1875 if (qx + qy) and 1 = 0 then
1876 if qx and 3 = 2 then
1877 result := 2
1878 else
1879 result := 1
1880 else
1881 result := 0
1882 end
1883 else
1884 result := (qx + qy) and 1 + 1
1885 else
1886 result := 0;
1887 end
1888 else
1889 result := 0;
1890 end
1891 end;
1892end;
1893
1894procedure InitUnit;
1895begin
1896 Assert(SizeOf(TPlayerContext) = 1936 + 28 * SizeOf(Pointer));
1897 Assert(SizeOf(TModel) - 2 * SizeOf(LongInt) - 4 * SizeOf(Word)
1898 = sIntSetDevModel and $F * 4);
1899end;
1900
1901function DelphiRandom(const pi_Max: Integer): Integer;
1902var
1903 Temp: LongInt;
1904begin
1905 Temp := LongInt(Int64(134775813) * Int64(DelphiRandSeed) + 1);
1906 DelphiRandSeed := LongInt(Temp);
1907 Result := (UInt64(Cardinal(pi_Max)) * UInt64(Cardinal(Temp))) shr 32;
1908end;
1909
1910function DelphiRandom: Extended; overload;
1911begin
1912 Result := DelphiRandom(High(LongInt)) / High(LongInt);
1913end;
1914
1915procedure DelphiRandomize;
1916begin
1917 Randomize;
1918 DelphiRandSeed := RandSeed;
1919end;
1920
1921initialization
1922
1923InitUnit;
1924
1925end.
Note: See TracBrowser for help on using the repository browser.