Changeset 6 for trunk/Protocol.pas


Ignore:
Timestamp:
Jan 7, 2017, 11:32:14 AM (7 years ago)
Author:
chronos
Message:
  • Modified: Formated all project source files using Delphi formatter as original indentation and other formatting was really bad.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Protocol.pas

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