source: tags/1.3.4/Protocol.pas

Last change on this file was 457, checked in by chronos, 12 months ago
  • Modified: Use enumeration type in Help unit for better readability.
  • Fixed: Corruption external help image referenced with incorrect file name case.
  • Fixed: Chinese translation converted to UTF-8.
  • Modified: Code cleanup.
File size: 70.3 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; // railroad
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 TCommand = (
1278 cmInitModule = $0000,
1279 cmReleaseModule = $0100,
1280 cmBroadcast = $0200,
1281 cmHelpOnly = $0700,
1282 cmStartHelp = $0710,
1283 cmStartCredits = $0720,
1284
1285 cmNewGame = $0800,
1286 cmLoadGame = $0810,
1287 cmMovie = $0820,
1288 cmNewGameEx = $0840,
1289 cmLoadGameEx = $0850,
1290 cmNewMap = $0880,
1291 cmReplay = $08E0,
1292 cmGetReady = $08F0,
1293 cmBreakGame = $0900,
1294
1295 cmTurn = $2000,
1296 cmResume = $2010,
1297 cmContinue = $2080,
1298 cmMovieTurn = $2100,
1299 cmMovieEndTurn = $2110,
1300 cmEditMap = $2800,
1301
1302 // cShowTileM=$3000;cShowTileA=$3010;cShowFoundCity=$3020;
1303 cmShowUnitChanged = $3030,
1304 cmShowAfterMove = $3040,
1305 cmShowAfterAttack = $3050,
1306 cmShowCityChanged = $3090,
1307 // cShowMove=$3100;cShowCapture=$3110;
1308 // cShowAttackBegin=$3200;cShowAttackWon=$3210;cShowAttackLost=$3220;
1309 cmShowMoving = $3140,
1310 cmShowCapturing = $3150,
1311 cmShowAttacking = $3240,
1312 cmShowMissionResult = $3300,
1313 cmShowShipChange = $3400,
1314 cmShowGreatLibTech = $3500,
1315 cmShowTurnChange = $3700,
1316 cmShowCancelTreaty = $3800,
1317 cmShowEndContact = $3810,
1318 cmShowCancelTreatyByAlliance = $3820,
1319 cmShowSupportAllianceAgainst = $3830,
1320 cmShowPeaceViolation = $3880,
1321 cmShowGame = $3F00, { cShowSuperView=$3F80; }
1322 cmRefreshDebugMap = $3F90,
1323
1324 // Diplomacy commands equal to server, see below
1325
1326 cmDebugMessage = $7000,
1327 cmShowNego = $7010
1328 );
1329
1330 TUn = packed record
1331 Loc: LongInt; { location }
1332 Status: LongInt; // free for AI use
1333 SavedStatus: LongInt; // for server internal use only
1334 ID: Word; // unit number, never changes, unique within this nation
1335 mix: SmallInt; { model index }
1336 Home: SmallInt; { home city index, -1 if none }
1337 Master: SmallInt; { index of transporting unit, -1 if none }
1338 Movement: SmallInt; { movement left for this turn }
1339 Health: ShortInt; // = 100-Damage
1340 Fuel: ShortInt;
1341 Job: Byte; { current terrain improvement job }
1342 Exp: Byte; { micro experience, the level is Exp div ExpCost }
1343 TroopLoad: Byte; { number of transported ground units }
1344 AirLoad: Byte; // number of transported air units
1345 Flags: Cardinal;
1346 end;
1347 PUn = ^TUn;
1348
1349 { TCity }
1350
1351 TCity = packed record
1352 Loc: LongInt; { location }
1353 Status: LongInt; // free for AI use
1354 SavedStatus: LongInt; // for server internal use only
1355 ID: Word; // founding player shl 12 + number, never changes, unique within the whole game
1356 Size: Word;
1357 Project: SmallInt; // current production project, see city project flags
1358 Project0: SmallInt; // for server use only
1359 Food: SmallInt; // collected food in storage
1360 Pollution: SmallInt; // collected pollution in dump
1361 Prod: SmallInt; // for project collected production points
1362 Prod0: SmallInt;
1363 // for project collected production points in the beginning of the turn
1364 Flags: Cardinal; // what happened within the last turnaround
1365 Tiles: Cardinal; { currently by city exploited tiles, bitset with index
1366 (dy+3) shl 2+(dx+3) shr 1, (dx,dy) relative to central tile }
1367 N1: Cardinal; // reserved for future use
1368 Built: array [0 .. (nImp + 3) div 4 * 4 - 1] of ShortInt;
1369 // array value =1 indicates built improvement
1370 end;
1371 PCity = ^TCity;
1372
1373 TModel = packed record
1374 Status: LongInt; // free for AI use
1375 SavedStatus: LongInt; // for server internal use only
1376 ID: Word; // developing player shl 12 + number, never changes, unique within the whole game
1377 IntroTurn: Word;
1378 Built: Word; // units built with this model
1379 Lost: Word; // units of this model lost in combat
1380 Kind: Byte;
1381 Domain: Byte;
1382 Attack: Word;
1383 Defense: Word;
1384 Speed: Word;
1385 Cost: Word;
1386 MStrength: Word;
1387 // Construction time multipliers, only valid if kind is mkSelfDeveloped or mkEnemyDeveloped
1388 MTrans: Byte;
1389 MCost: Byte;
1390 Weight: Byte;
1391 MaxWeight: Byte;
1392 // Weight and maximum weight (construction time)
1393 Upgrades: Cardinal; // bitarray indicating all upgrades
1394 Flags: Cardinal;
1395 Cap: array [0 .. (nFeature + 3) div 4 * 4 - 1] of Byte; // special features
1396 end;
1397
1398 TUnitInfo = packed record
1399 Loc: LongInt;
1400 mix: Word; // index of unit model for its owner
1401 emix: Word; // index in enemy model list
1402 Owner: Byte;
1403 Health: ShortInt; // = 100-Damage
1404 Fuel: ShortInt;
1405 Job: Byte; // current terrain improvement job
1406 Exp: Byte; { micro experience, the level is Exp div ExpCost }
1407 Load: Byte; { number of transported units }
1408 Flags: Word;
1409 end;
1410 PUnitInfo = ^TUnitInfo;
1411
1412 TCityInfo = packed record
1413 Loc: LongInt;
1414 Status: LongInt; // free for AI use
1415 SavedStatus: LongInt; // for server internal use only
1416 Owner: Word; // last known owner, even if not alive anymore!
1417 ID: Word; // founding player <<12 + number, never changes, unique within the whole game
1418 Size: Word;
1419 Flags: Word;
1420 end;
1421 PCityInfo = ^TCityInfo;
1422
1423 TModelInfo = packed record
1424 Owner: Word; // Player which owns the model
1425 mix: Word; // index of unit model for its owner
1426 ID: Word; // developing player shl 12 + number, never changes, unique within the whole game
1427 Kind: Byte;
1428 Domain: Byte;
1429 Attack: Word;
1430 Defense: Word;
1431 Speed: Word;
1432 Cost: Word;
1433 TTrans: Byte; // ground unit transport capability
1434 ATrans_Fuel: Byte; // air unit transport capability resp. fuel
1435 Bombs: Word; // additional attack with bombs
1436 Cap: Cardinal; // special features, bitset with index Feature-mcFirstNonCap
1437 MaxUpgrade: Byte; // maximum used upgrade
1438 Weight: Byte;
1439 Lost: Word;
1440 end;
1441
1442 TBattle = packed record
1443 Enemy: Byte;
1444 Flags: Byte;
1445 Turn: Word;
1446 mix: Word;
1447 mixEnemy: Word;
1448 ToLoc: Integer;
1449 FromLoc: Integer;
1450 end;
1451
1452 TWonderInfo = record
1453 CityID: Integer; // -2 if destroyed, -1 if never completed, >=0 ID of city
1454 EffectiveOwner: Integer;
1455 // owning player if effective, -1 if expired or not built
1456 end;
1457
1458 TShipInfo = record
1459 Parts: array [0 .. nShipPart - 1] of Integer;
1460 end;
1461
1462 TEnemyReport = record
1463 TurnOfContact: Integer;
1464 TurnOfCivilReport: Integer;
1465 TurnOfMilReport: Integer;
1466 Attitude: Integer;
1467 Credibility: Integer; // 0..100, last update: ToC
1468 Treaty: array [0 .. nPl - 1] of Integer;
1469 // diplomatic status with other nations, last update: ToCR
1470 Government: Integer; // gAnarchy..gDemocracy, last update: ToCR
1471 Money: Integer; // last update: ToCR
1472 ResearchTech: Integer; // last update: ToCR
1473 ResearchDone: Integer; // last update: ToCR
1474 Tech: array [0 .. (nAdv + 3) div 4 * 4 - 1] of ShortInt;
1475 // tech status indicator, last update: ToCR
1476 nModelCounted: Integer;
1477 // number of models with info in UnCount, last update: ToMR
1478 UnCount: array [0 .. INFIN] of Word;
1479 // number of available units for each model, last update: ToMR
1480 end;
1481
1482 TMoveAdviceData = record
1483 ToLoc: Integer;
1484 nStep: Integer;
1485 MoreTurns: Integer;
1486 MaxHostile_MovementLeft: Integer;
1487 dx: array [0 .. 24] of Integer;
1488 dy: array [0 .. 24] of Integer;
1489 end;
1490
1491 TPlaneReturnData = record
1492 Loc: Integer;
1493 Fuel: Integer;
1494 Movement: Integer;
1495 end;
1496
1497 TTileInfo = record
1498 Food: Integer;
1499 Prod: Integer;
1500 Trade: Integer;
1501 ExplCity: Integer;
1502 end;
1503
1504 TCityReport = record
1505 HypoTiles: Integer;
1506 HypoTax: Integer;
1507 HypoLux: Integer;
1508 Working: Integer;
1509 Happy: Integer;
1510 FoodRep: Integer;
1511 ProdRep: Integer;
1512 Trade: Integer;
1513 PollRep: Integer;
1514 Corruption: Integer;
1515 Tax: Integer;
1516 Lux: Integer;
1517 Science: Integer;
1518 Support: Integer;
1519 Eaten: Integer;
1520 ProdCost: Integer;
1521 Storage: Integer;
1522 Deployed: Integer;
1523 end;
1524
1525 TCityReportNew = record
1526 HypoTiles: Integer;
1527 // Tiles that should be considered as exploited (for the current adjustment, set this to -1 or to TCity.Tiles of the city)
1528 HypoTaxRate: Integer;
1529 HypoLuxuryRate: Integer;
1530 // Tax and luxury rate that should be assumed (for current rates, set this to -1 or to RO.TaxRate resp. RO.LuxRate)
1531 Morale: Integer;
1532 FoodSupport: Integer;
1533 MaterialSupport: Integer;
1534 // Food and material taken for unit support
1535 ProjectCost: Integer; // material cost of current project
1536 Storage: Integer; // size of food storage
1537 Deployed: Integer; // number of units causing unrest (unrest=2*deployed)
1538 CollectedControl: Integer;
1539 CollectedFood: Integer;
1540 CollectedMaterial: Integer;
1541 CollectedTrade: Integer;
1542 // Raw control, food, material and trade as collected by the citizens
1543 Working: Integer; // number of exploited tiles including city tile
1544 FoodSurplus: Integer;
1545 Production: Integer;
1546 AddPollution: Integer;
1547 // Food surplus, production gain and pollution after all effects
1548 Corruption: Integer;
1549 Tax: Integer;
1550 Science: Integer;
1551 Luxury: Integer;
1552 // Corruption, tax, science and wealth after all effects
1553 HappinessBalance: Integer;
1554 // = (Morale+Wealth+Control) - (Size+Unrest), value < 0 means disorder
1555 end;
1556
1557 TCityTileAdviceData = record
1558 ResourceWeights: Cardinal;
1559 Tiles: Cardinal;
1560 CityReport: TCityReport;
1561 end;
1562
1563 TGetCityData = record
1564 Owner: Integer;
1565 C: TCity;
1566 end;
1567
1568 TCityAreaInfo = record
1569 Available: array [0 .. 26] of Integer;
1570 end;
1571
1572 TUnitReport = record
1573 FoodSupport: Integer;
1574 ProdSupport: Integer;
1575 ReportFlags: Integer;
1576 end;
1577
1578 TJobProgressData = array [0 .. nJob - 1] of record
1579 Required, Done,
1580 NextTurnPlus: Integer;
1581 end;
1582
1583 TBattleForecast = record
1584 pAtt: Integer;
1585 mixAtt: Integer;
1586 HealthAtt: Integer;
1587 ExpAtt: Integer;
1588 FlagsAtt: Integer;
1589 Movement: Integer;
1590 EndHealthDef: Integer;
1591 EndHealthAtt: Integer;
1592 end;
1593
1594 TBattleForecastEx = record
1595 pAtt: Integer;
1596 mixAtt: Integer;
1597 HealthAtt: Integer;
1598 ExpAtt: Integer;
1599 FlagsAtt: Integer;
1600 Movement: Integer;
1601 EndHealthDef: Integer;
1602 EndHealthAtt: Integer; // Must be same as in TBattleForecast
1603 AStr: Integer;
1604 DStr: Integer;
1605 ABaseDamage: Integer;
1606 DBaseDamage: Integer;
1607 end;
1608
1609 TShowMove = record
1610 Owner: Integer;
1611 Health: Integer;
1612 mix: Integer;
1613 emix: Integer;
1614 Flags: Integer;
1615 FromLoc: Integer;
1616 dx: Integer;
1617 dy: Integer;
1618 EndHealth: Integer;
1619 EndHealthDef: Integer;
1620 Fuel: Integer;
1621 Exp: Integer;
1622 Load: Integer;
1623 end;
1624
1625 TShowShipChange = record
1626 Reason: Integer;
1627 Ship1Owner: Integer;
1628 Ship2Owner: Integer;
1629 Ship1Change: array [0 .. nShipPart - 1] of Integer;
1630 Ship2Change: array [0 .. nShipPart - 1] of Integer;
1631 end;
1632
1633 TOffer = record
1634 nDeliver: Integer;
1635 nCost: Integer;
1636 Price: array [0 .. 11] of Cardinal;
1637 end;
1638
1639 TChart = array [0 .. INFIN] of Integer;
1640 TEditTileData = record
1641 Loc: Integer;
1642 NewTile: Integer;
1643 end;
1644 TCreateUnitData = record
1645 Loc: Integer;
1646 P: Integer;
1647 mix: Integer;
1648 end;
1649
1650 TTileList = array [0 .. INFIN] of Cardinal;
1651 PTileList = ^TTileList;
1652 TTileObservedLastList = array [0 .. INFIN] of SmallInt;
1653 TOwnerList = array [0 .. INFIN] of ShortInt;
1654 TByteList = array [0 .. INFIN] of Byte;
1655 TIntList = array [0 .. INFIN] of Integer;
1656 TCityList = array [0 .. INFIN] of TCity;
1657 TUnList = array [0 .. INFIN] of TUn;
1658 TModelList = array [0 .. INFIN] of TModel;
1659 TEnemyUnList = array [0 .. INFIN] of TUnitInfo;
1660 TEnemyCityList = array [0 .. INFIN] of TCityInfo;
1661 TEnemyModelList = array [0 .. INFIN] of TModelInfo;
1662 TBattleList = array [0 .. INFIN] of TBattle;
1663
1664 TPlayerContext = record
1665 Data: Pointer;
1666 Map: ^TTileList;
1667 { The playground, a list of tiles with index = location, see tile flags }
1668 MapObservedLast: ^TTileObservedLastList;
1669 // Turn in which the tile was observed last, index = location
1670 Territory: ^TOwnerList; // nation to which's territory a tile belongs, -1 indicates none
1671 Un: ^TUnList; { units }
1672 City: ^TCityList; { cities }
1673 Model: ^TModelList; { unit models }
1674 EnemyUn: ^TEnemyUnList; // known units of enemy players
1675 EnemyCity: ^TEnemyCityList; // known cities of enemy players
1676 EnemyModel: ^TEnemyModelList; // known unit models of enemy players
1677 EnemyReport: array [0 .. nPl - 1] of ^TEnemyReport;
1678
1679 TestFlags: Integer; // options turned on in the "Manipulation" menu
1680 Turn: Integer; // current turn
1681 Alive: Integer; { bitset of IDs of players still alive, flag 1 shl p for player p }
1682 Happened: Integer; // flags indicate what happened within the last turnaround
1683 AnarchyStart: Integer; // start turn of anarchy, <0 if not in anarchy
1684 Credibility: Integer; // own credibility
1685 MaxCredibility: Integer; // maximum credibility still to achieve
1686 nUn: Integer; { number of units }
1687 nCity: Integer; { number of cities }
1688 nModel: Integer; { number of developed unit models }
1689 nEnemyUn: Integer;
1690 nEnemyCity: Integer;
1691 nEnemyModel: Integer;
1692 Government: Integer; { gAnarchy..gDemocracy }
1693 Money: Integer;
1694 TaxRate: Integer;
1695 LuxRate: Integer;
1696 Research: Integer;
1697 { Collected research points for currently researched tech }
1698 ResearchTech: Integer; // currently researched tech
1699 DevModel: TModel; { unit model currently under development }
1700 Tech: array [0 .. (nAdv + 3) div 4 * 4 - 1] of ShortInt; { tech status indicator }
1701 Attitude: array [0 .. nPl - 1] of Integer; // attitude to other nations
1702 Treaty: array [0 .. nPl - 1] of Integer; // treaty with other nations
1703 EvaStart: array [0 .. nPl - 1] of Integer; // peace treaty: start of evacuation period
1704 Tribute: array [0 .. nPl - 1] of Integer; // no longer in use
1705 TributePaid: array [0 .. nPl - 1] of Integer; // no longer in use
1706 Wonder: array [0 .. nWonder - 1] of TWonderInfo;
1707 Ship: array [0 .. nPl - 1] of TShipInfo;
1708 NatBuilt: array [nWonder .. (nImp + 3) div 4 * 4 - 1] of ShortInt;
1709 nBattleHistory: Integer;
1710 BattleHistory: ^TBattleList; // complete list of all my battles in the whole game
1711 BorderHelper: ^TByteList;
1712 LastCancelTreaty: array [0 .. nPl - 1] of Integer; // turn of last treaty cancel
1713 OracleIncome: Integer;
1714 DefaultDebugMap: ^TIntList;
1715 Filler: array [0 .. 879] of Byte;
1716 end;
1717
1718 TInitModuleData = record
1719 Server: TServerCall;
1720 DataVersion: Integer;
1721 DataSize: Integer;
1722 Flags: Integer;
1723 end;
1724 PInitModuleData = ^TInitModuleData;
1725
1726 TNewGameData = record
1727 lx: Integer; // Map width
1728 ly: Integer; // Map height
1729 LandMass: Integer;
1730 MaxTurn: Integer;
1731 Difficulty: array [0 .. nPl - 1] of Integer;
1732 { Difficulty levels of the players, if it's 0 this player is the supervisor,
1733 -1 for unused slots }
1734 RO: array [0 .. nPl - 1] of ^TPlayerContext;
1735 AssemblyPath: array [0 .. 255] of Char;
1736 SuperVisorRO: array [0 .. nPl - 1] of ^TPlayerContext;
1737 end;
1738
1739 TNewGameExData = record
1740 lx: Integer;
1741 ly: Integer;
1742 LandMass: Integer;
1743 MaxTurn: Integer;
1744 RND: Integer;
1745 Difficulty: array [0 .. nPl - 1] of Integer;
1746 { Difficulty levels of the players, if it's 0 this player is the supervisor,
1747 -1 for unused slots }
1748 Controlled: Integer;
1749 end;
1750
1751 TShowNegoData = record
1752 pSender: Integer;
1753 pTarget: Integer;
1754 Action: Integer;
1755 Offer: TOffer;
1756 end;
1757
1758const
1759 { Predefined unit models: }
1760 nSpecialModel = 9;
1761 SpecialModel: array [0 .. nSpecialModel - 1] of TModel = ((Status: 0;
1762 SavedStatus: 0; ID: 0; IntroTurn: 0; Built: 0; Lost: 0; Kind: mkSettler;
1763 Domain: dGround; Attack: 0; Defense: 10; Speed: 150; Cost: 40; MStrength: 0;
1764 MTrans: 0; MCost: 0; Weight: 0; MaxWeight: 0; Upgrades: 0; Flags: 0;
1765 Cap: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1766 0, 0, 0, 0, 0)), { Settlers }
1767 (Status: 0; SavedStatus: 0; ID: 0; IntroTurn: 0; Built: 0; Lost: 0;
1768 Kind: mkSettler; Domain: dGround; Attack: 0; Defense: 20; Speed: 300;
1769 Cost: 40; MStrength: 0; MTrans: 0; MCost: 0; Weight: 0; MaxWeight: 0;
1770 Upgrades: 0; Flags: 0; Cap: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1771 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), { Engineers }
1772 (Status: 0; SavedStatus: 0; ID: 0; IntroTurn: 0; Built: 0; Lost: 0;
1773 Kind: mkSelfDeveloped; Domain: dGround; Attack: 6; Defense: 6; Speed: 150;
1774 Cost: 10; MStrength: 0; MTrans: 0; MCost: 0; Weight: 0; MaxWeight: 0;
1775 Upgrades: 0; Flags: 0; Cap: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1776 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), { Militia }
1777 (Status: 0; SavedStatus: 0; ID: 0; IntroTurn: 0; Built: 0; Lost: 0;
1778 Kind: mkSpecial_TownGuard; Domain: dGround; Attack: 4; Defense: 6;
1779 Speed: 150; Cost: 20; MStrength: 0; MTrans: 0; MCost: 0; Weight: 0;
1780 MaxWeight: 0; Upgrades: 0; Flags: 0;
1781 Cap: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1782 0, 0, 0, 0, 0)), { Town Guard }
1783 (Status: 0; SavedStatus: 0; ID: 0; IntroTurn: 0; Built: 0; Lost: 0;
1784 Kind: mkDiplomat; Domain: dGround; Attack: 12; Defense: 12; Speed: 250;
1785 Cost: 20; MStrength: 0; MTrans: 0; MCost: 0; Weight: 0; MaxWeight: 0;
1786 Upgrades: 0; Flags: 0; Cap: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1787 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), { Special Commando }
1788 (Status: 0; SavedStatus: 0; ID: 0; IntroTurn: 0; Built: 0; Lost: 0;
1789 Kind: mkCaravan; Domain: dGround; Attack: 0; Defense: 6; Speed: 150;
1790 Cost: 60; MStrength: 0; MTrans: 0; MCost: 0; Weight: 0; MaxWeight: 0;
1791 Upgrades: 0; Flags: 0; Cap: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1792 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), { Freight }
1793 (Status: 0; SavedStatus: 0; ID: 0; IntroTurn: 0; Built: 0; Lost: 0;
1794 Kind: mkSpecial_Boat; Domain: dSea; Attack: 0; Defense: 3; Speed: 250;
1795 Cost: 20; MStrength: 0; MTrans: 1; MCost: 0; Weight: 0; MaxWeight: 0;
1796 Upgrades: 0; Flags: 0; Cap: (0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1797 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), { Longboat }
1798 (Status: 0; SavedStatus: 0; ID: 0; IntroTurn: 0; Built: 0; Lost: 0;
1799 Kind: mkSlaves; Domain: dGround; Attack: 0; Defense: 15; Speed: 150;
1800 Cost: 40; MStrength: 0; MTrans: 0; MCost: 0; Weight: 0; MaxWeight: 0;
1801 Upgrades: 0; Flags: 0; Cap: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1802 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), { Slaves }
1803 { (Status:0;SavedStatus:0;ID:0;IntroTurn:0;Built:0;Lost:0;
1804 Kind:mkSpecial_Carriage;Domain:dGround;Attack:50;Defense:30;Speed:250;Cost:50;
1805 MStrength:0;MTrans:0;MCost:0;Weight:0;MaxWeight:0;Upgrades:0;Flags:0;
1806 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)), }
1807 { (Status:0;SavedStatus:0;ID:0;IntroTurn:0;Built:0;Lost:0;
1808 Kind:mkSpecial_SubCabin;Domain:dSea;Attack:16;Defense:1;Speed:350;Cost:40;
1809 MStrength:0;MTrans:0;MCost:0;Weight:0;MaxWeight:0;Upgrades:0;Flags:0;
1810 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)), }
1811 (Status: 0; SavedStatus: 0; ID: 0; IntroTurn: 0; Built: 0; Lost: 0;
1812 Kind: mkSpecial_Glider; Domain: dAir; Attack: 6; Defense: 6; Speed: 450;
1813 Cost: 30; MStrength: 0; MTrans: 0; MCost: 0; Weight: 0; MaxWeight: 0;
1814 Upgrades: 0; Flags: 0; Cap: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1815 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)));
1816
1817 SpecialModelPreq: array [0 .. nSpecialModel - 1] of Integer = (preNone,
1818 adExplosives, preNone, preNone, (* adWri, *) adIntelligence, adTrade,
1819 (* adTheCorporation,adHorsebackRiding,adAutomobile,adNavigation,
1820 adCombustionEngine, *) adMapMaking, preBuilder,
1821 { preLeo,preLighthouse, } preLeo);
1822
1823var
1824 DelphiRandSeed: Integer;
1825
1826procedure MakeUnitInfo(P: Integer; const U: TUn; var ui: TUnitInfo);
1827procedure MakeModelInfo(P, mix: Integer; const M: TModel; var mi: TModelInfo);
1828function IsSameModel(const mi1, mi2: TModelInfo): Boolean;
1829function SpecialTile(Loc, TerrType, lx: Integer): Integer;
1830function DelphiRandom(const pi_Max: Integer): Integer; overload;
1831function DelphiRandom: Extended; overload;
1832procedure DelphiRandomize;
1833function GetCommandDataSize(Command: TCommand): Integer;
1834
1835
1836implementation
1837
1838procedure MakeUnitInfo(P: Integer; const U: TUn; var ui: TUnitInfo);
1839begin
1840 ui.Owner := P;
1841 ui.Loc := U.Loc;
1842 ui.Health := U.Health;
1843 ui.Fuel := U.Fuel;
1844 ui.Job := U.Job;
1845 ui.Exp := U.Exp;
1846 ui.Load := U.TroopLoad + U.AirLoad;
1847 ui.mix := U.mix;
1848 ui.Flags := U.Flags;
1849end;
1850
1851procedure MakeModelInfo(P, mix: Integer; const M: TModel; var mi: TModelInfo);
1852var
1853 I: Integer;
1854begin
1855 mi.Owner := P;
1856 mi.mix := mix;
1857 mi.ID := M.ID;
1858 mi.Domain := M.Domain;
1859 if M.Kind = mkEnemyDeveloped then
1860 mi.Kind := mkSelfDeveloped // Important for IsSameModel()
1861 else
1862 mi.Kind := M.Kind;
1863 mi.Attack := M.Attack;
1864 mi.Defense := M.Defense;
1865 mi.Speed := M.Speed;
1866 mi.Cost := M.Cost;
1867 if mi.Domain = dAir then
1868 begin
1869 mi.TTrans := M.Cap[mcAirTrans] * M.MTrans;
1870 mi.ATrans_Fuel := M.Cap[mcFuel];
1871 end
1872 else
1873 begin
1874 mi.TTrans := M.Cap[mcSeaTrans] * M.MTrans;
1875 mi.ATrans_Fuel := M.Cap[mcCarrier] * M.MTrans;
1876 end;
1877 mi.Bombs := M.Cap[mcBombs] * M.MStrength * 2;
1878 mi.Cap := 0;
1879 for I := mcFirstNonCap to nFeature - 1 do
1880 if M.Cap[I] > 0 then
1881 mi.Cap := mi.Cap or (1 shl (I - mcFirstNonCap));
1882 mi.MaxUpgrade := 0;
1883 for I := 1 to nUpgrade - 1 do
1884 if M.Upgrades and (1 shl I) <> 0 then
1885 mi.MaxUpgrade := I;
1886 mi.Weight := M.Weight;
1887 mi.Lost := 0;
1888end;
1889
1890function IsSameModel(const mi1, mi2: TModelInfo): Boolean;
1891type
1892 TModelInfo_Compare = array [0 .. 5] of Cardinal;
1893var
1894 Compare1, Compare2: ^TModelInfo_Compare;
1895begin
1896 Compare1 := @mi1;
1897 Compare2 := @mi2;
1898 Result := (Compare1[1] and $FFFF0000 = Compare2[1] and $FFFF0000) and
1899 (Compare1[2] = Compare2[2]) and (Compare1[3] = Compare2[3]) and
1900 (Compare1[4] = Compare2[4]) and (Compare1[5] = Compare2[5])
1901end;
1902
1903function SpecialTile(Loc, TerrType, lx: Integer): Integer;
1904var
1905 X, Y, qx, qy, A: Integer;
1906begin
1907 if TerrType = fOcean then
1908 Result := 0
1909 else
1910 begin
1911 Y := Loc div lx;
1912 X := Loc - Y * lx;
1913 if TerrType = fGrass then { Formula for productive grassland }
1914 if Odd((lymax + X - Y shr 1) shr 1 + X + (Y + 1) shr 1) then
1915 Result := 1
1916 else
1917 Result := 0
1918 else { Formula for special resources }
1919 begin
1920 A := 4 * X - Y + 9980;
1921 qx := A div 10;
1922 if (qx * 10 = A) and (qx and 3 <> 0) then
1923 begin
1924 qy := (Y + X) div 5;
1925 if qy and 3 <> qx shr 2 and 1 * 2 then
1926 if (TerrType = fArctic) or (TerrType = fSwamp) then
1927 Result := 1
1928 else if TerrType = fShore then
1929 begin
1930 if (qx + qy) and 1 = 0 then
1931 if qx and 3 = 2 then
1932 Result := 2
1933 else
1934 Result := 1
1935 else
1936 Result := 0
1937 end
1938 else
1939 Result := (qx + qy) and 1 + 1
1940 else
1941 Result := 0;
1942 end
1943 else
1944 Result := 0;
1945 end;
1946 end;
1947end;
1948
1949procedure InitUnit;
1950begin
1951 Assert(SizeOf(TPlayerContext) = 1936 + 28 * SizeOf(Pointer));
1952 Assert(SizeOf(TModel) - 2 * SizeOf(LongInt) - 4 * SizeOf(Word)
1953 = sIntSetDevModel and $F * 4);
1954end;
1955
1956function DelphiRandom(const pi_Max: Integer): Integer;
1957var
1958 Temp: LongInt;
1959begin
1960 Temp := LongInt(Int64(134775813) * Int64(DelphiRandSeed) + 1);
1961 DelphiRandSeed := LongInt(Temp);
1962 Result := (UInt64(Cardinal(pi_Max)) * UInt64(Cardinal(Temp))) shr 32;
1963end;
1964
1965function DelphiRandom: Extended; overload;
1966begin
1967 Result := DelphiRandom(High(LongInt)) / High(LongInt);
1968end;
1969
1970procedure DelphiRandomize;
1971begin
1972 Randomize;
1973 DelphiRandSeed := RandSeed;
1974end;
1975
1976function GetCommandDataSize(Command: TCommand): Integer;
1977begin
1978 case Command of
1979 cmInitModule: Result := SizeOf(TInitModuleData);
1980 cmGetReady: Result := 0;
1981 cmTurn: Result := 0;
1982 cmShowTurnChange: Result := SizeOf(Integer);
1983 cmShowNego: Result := SizeOf(TShowNegoData);
1984 cmNewGame, cmLoadGame, cmMovie, cmNewMap: Result := SizeOf(TNewGameData);
1985 cmShowShipChange: Result := SizeOf(TShowShipChange);
1986 cmShowGreatLibTech: Result := SizeOf(Integer);
1987 cmShowCityChanged: Result := SizeOf(Integer);
1988 cmShowPeaceViolation: Result := SizeOf(Integer);
1989 cmShowMoving: Result := SizeOf(TShowMove);
1990 cmShowUnitChanged: Result := SizeOf(Integer);
1991 cmShowMissionResult: Result := SizeOf(Cardinal);
1992 cmShowAfterMove: Result := SizeOf(Integer);
1993 cmShowAfterAttack: Result := SizeOf(Integer);
1994 cmShowSupportAllianceAgainst: Result := SizeOf(Integer);
1995 cmShowCancelTreatyByAlliance: Result := SizeOf(Integer);
1996 cmShowEndContact: Result := 0;
1997 cmShowGame: Result := 0;
1998 //sIntCancelTreaty: Result := SizeOf(Integer);
1999 else begin
2000 Result := 0;
2001 end;
2002 end;
2003end;
2004
2005
2006initialization
2007
2008InitUnit;
2009
2010end.
Note: See TracBrowser for help on using the repository browser.