Ignore:
Timestamp:
Mar 9, 2021, 9:19:49 AM (3 years ago)
Author:
chronos
Message:
  • Modified: Synced code with current trunk version.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/highdpi/AI/StdAI/Protocol.pas

    r210 r303  
    4444  MaxMoneyPrice = $FFFF;
    4545  MaxShipPartPrice = 100;
    46   BombardmentDestroysCity = false;
     46  BombardmentDestroysCity = False;
    4747  StartMoney = 0;
    4848  InitialCredibility = 95;
     
    5353  // difficulty settings
    5454  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
     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
    5959
    6060  // test flags
     
    795795  imShipHab = 69;
    796796
    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);
     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);
    800800  // in 1/2*city size
    801801
     
    808808  preNA = -$FF;
    809809
    810   JobPreq: array [0 .. nJob - 1] of integer = (preNone, preNone, adRailroad,
     810  JobPreq: array [0 .. nJob - 1] of Integer = (preNone, preNone, adRailroad,
    811811    preNone, preNone, adRefrigeration, preNone, preNone, adExplosives,
    812812    adExplosives, adConstruction, preNone, adMedicine, preNone, preNone);
    813813
    814   AdvPreq: array [0 .. nAdv - 1, 0 .. 2] of integer = { advance prerequisites }
     814  AdvPreq: array [0 .. nAdv - 1, 0 .. 2] of Integer = { advance prerequisites }
    815815    ((adFlight, adRobotics, preNone), // adAdvancedFlight
    816816    (adNavigation, adTactics, preNone), // adAmphibiousWarfare
     
    10231023spPow = 1;
    10241024spHab = 2;
    1025 ShipNeed: array [0 .. nShipPart - 1] of integer = (6, 4, 2);
    1026 ShipImpIndex: array [0 .. nShipPart - 1] of integer = (imShipComp, imShipPow, imShipHab);
    1027 
    1028 GovPreq: array [1 .. nGov - 1] of integer = { government prerequisites }
     1025ShipNeed: array [0 .. nShipPart - 1] of Integer = (6, 4, 2);
     1026ShipImpIndex: array [0 .. nShipPart - 1] of Integer = (imShipComp, imShipPow, imShipHab);
     1027
     1028GovPreq: array [1 .. nGov - 1] of Integer = { government prerequisites }
    10291029  (preNone, adMonarchy, adTheRepublic, adTheology, adCommunism, adDemocracy,
    10301030  adInternet);
    10311031
    1032 AgePreq: array [1 .. 3] of integer = (adScience, adMassProduction,
     1032AgePreq: array [1 .. 3] of Integer = (adScience, adMassProduction,
    10331033  adTransstellarColonization);
    10341034
     
    10441044  TransTerrain: Integer;
    10451045  TransWork: Integer;
    1046   FoodRes, ProdRes, TradeRes: array [0 .. 2] of Integer;
     1046  FoodRes: array [0 .. 2] of Integer;
     1047  ProdRes: array [0 .. 2] of Integer;
     1048  TradeRes: array [0 .. 2] of Integer;
    10471049  Filler: array [0 .. 12] of Integer;
    10481050end
     
    11131115// cost values accumulate if prerequisite is future tech / are maximized if not
    11141116nUpgrade = 15;
    1115 upgrade:
    1116 array [0 .. nDomains - 1, 0 .. nUpgrade - 1] of record
     1117upgrade: array [0 .. nDomains - 1, 0 .. nUpgrade - 1] of record
    11171118  Preq: Integer;
    11181119  Strength: Integer;
     
    12011202
    12021203Feature: array [0 .. nFeature - 1] of { unit model features }
    1203   record Domains, Preq, Weight, Cost: integer;
    1204 end
     1204  record
     1205    Domains: Integer;
     1206    Preq: Integer;
     1207    Weight: Integer;
     1208    Cost: Integer;
     1209  end
    12051210= ((Domains: 7; Preq: preNone; Weight: 1; Cost: 1), { mcOffense }
    12061211  (Domains: 7; Preq: preNone; Weight: 1; Cost: 1), { mcDefense }
     
    12311236  (Domains: 7; Preq: adMassProduction; Weight: 0; Cost: 0)); { mcLine }
    12321237
    1233 WeightPreq7: array [0 .. nDomains - 1] of integer = (adHorsebackRiding, adSeafaring,
     1238WeightPreq7: array [0 .. nDomains - 1] of Integer = (adHorsebackRiding, adSeafaring,
    12341239  adAdvancedFlight);
    1235 WeightPreq10: array [0 .. nDomains - 1] of integer = (adAutomobile, adSteel, preNA);
     1240WeightPreq10: array [0 .. nDomains - 1] of Integer = (adAutomobile, adSteel, preNA);
    12361241
    12371242INFIN = 999999;
     
    12611266
    12621267type
    1263   TServerCall = function(Command, Player, Subject: integer; var Data)
    1264     : integer; stdcall;
    1265   TClientCall = procedure(Command, Player: integer; var Data); stdcall;
     1268  TServerCall = function (Command, Player, Subject: Integer; var Data)
     1269    : Integer; stdcall;
     1270  TClientCall = procedure (Command, Player: Integer; var Data); stdcall;
    12661271
    12671272  TUn = packed record
    1268     Loc, { location }
    1269     Status, // free for AI use
     1273    Loc: LongInt; { location }
     1274    Status: LongInt; // free for AI use
    12701275    SavedStatus: LongInt; // for server internal use only
    1271     ID: word; // unit number, never changes, unique within this nation
    1272     mix, { model index }
    1273     Home, { home city index, -1 if none }
    1274     Master, { index of transporting unit, -1 if none }
     1276    ID: Word; // unit number, never changes, unique within this nation
     1277    mix: SmallInt; { model index }
     1278    Home: SmallInt; { home city index, -1 if none }
     1279    Master: SmallInt; { index of transporting unit, -1 if none }
    12751280    Movement: SmallInt; { movement left for this turn }
    1276     Health, // = 100-Damage
     1281    Health: ShortInt; // = 100-Damage
    12771282    Fuel: ShortInt;
    1278     Job, { current terrain improvement job }
    1279     Exp, { micro experience, the level is Exp div ExpCost }
    1280     TroopLoad, { number of transported ground units }
     1283    Job: Byte; { current terrain improvement job }
     1284    Exp: Byte; { micro experience, the level is Exp div ExpCost }
     1285    TroopLoad: Byte; { number of transported ground units }
    12811286    AirLoad: Byte; // number of transported air units
    12821287    Flags: Cardinal;
    12831288  end;
    12841289
     1290  { TCity }
     1291
    12851292  TCity = packed record
    1286     Loc, { location }
    1287     Status, // free for AI use
     1293    Loc: LongInt; { location }
     1294    Status: LongInt; // free for AI use
    12881295    SavedStatus: LongInt; // for server internal use only
    1289     ID, // founding player shl 12 + number, never changes, unique within the whole game
    1290     Size: word;
    1291     Project, // current production project, see city project flags
    1292     Project0, // for server use only
    1293     Food, // collected food in storage
    1294     Pollution, // collected pollution in dump
    1295     Prod, // for project collected production points
     1296    ID: Word; // founding player shl 12 + number, never changes, unique within the whole game
     1297    Size: Word;
     1298    Project: SmallInt; // current production project, see city project flags
     1299    Project0: SmallInt; // for server use only
     1300    Food: SmallInt; // collected food in storage
     1301    Pollution: SmallInt; // collected pollution in dump
     1302    Prod: SmallInt; // for project collected production points
    12961303    Prod0: SmallInt;
    12971304    // for project collected production points in the beginning of the turn
    1298     Flags, // what happened within the last turnaround
    1299     Tiles, { currently by city exploited tiles, bitset with index
     1305    Flags: Cardinal; // what happened within the last turnaround
     1306    Tiles: Cardinal; { currently by city exploited tiles, bitset with index
    13001307      (dy+3) shl 2+(dx+3) shr 1, (dx,dy) relative to central tile }
    13011308    N1: Cardinal; // reserved for future use
     
    13051312
    13061313  TModel = packed record
    1307     Status, // free for AI use
     1314    Status: LongInt; // free for AI use
    13081315    SavedStatus: LongInt; // for server internal use only
    1309     ID, // developing player shl 12 + number, never changes, unique within the whole game
    1310     IntroTurn, Built, // units built with this model
    1311     Lost: word; // units of this model lost in combat
    1312     Kind, Domain: Byte;
    1313     Attack, Defense, Speed, Cost, MStrength: word;
     1316    ID: Word; // developing player shl 12 + number, never changes, unique within the whole game
     1317    IntroTurn: Word;
     1318    Built: Word; // units built with this model
     1319    Lost: Word; // units of this model lost in combat
     1320    Kind: Byte;
     1321    Domain: Byte;
     1322    Attack: Word;
     1323    Defense: Word;
     1324    Speed: Word;
     1325    Cost: Word;
     1326    MStrength: Word;
    13141327    // construction time multipliers, only valid if kind is mkSelfDeveloped or mkEnemyDeveloped
    1315     MTrans, MCost, Weight, MaxWeight: Byte;
     1328    MTrans: Byte;
     1329    MCost: Byte;
     1330    Weight: Byte;
     1331    MaxWeight: Byte;
    13161332    // weight and maximum weight (construction time)
    1317     Upgrades, // bitarray indicating all upgrades
     1333    Upgrades: Cardinal; // bitarray indicating all upgrades
    13181334    Flags: Cardinal;
    13191335    Cap: array [0 .. (nFeature + 3) div 4 * 4 - 1] of Byte; // special features
     
    13221338  TUnitInfo = packed record
    13231339    Loc: LongInt;
    1324     mix, // index of unit model for its owner
    1325     emix: word; // index in enemy model list
     1340    mix: Word; // index of unit model for its owner
     1341    emix: Word; // index in enemy model list
    13261342    Owner: Byte;
    1327     Health, // = 100-Damage
     1343    Health: ShortInt; // = 100-Damage
    13281344    Fuel: ShortInt;
    1329     Job, // current terrain improvement job
    1330     Exp, { micro experience, the level is Exp div ExpCost }
     1345    Job: Byte; // current terrain improvement job
     1346    Exp: Byte; { micro experience, the level is Exp div ExpCost }
    13311347    Load: Byte; { number of transported units }
    1332     Flags: word;
     1348    Flags: Word;
    13331349  end;
    13341350
    13351351  TCityInfo = packed record
    1336     Loc, Status, // free for AI use
     1352    Loc: LongInt;
     1353    Status: LongInt; // free for AI use
    13371354    SavedStatus: LongInt; // for server internal use only
    1338     Owner, // last known owner, even if not alive anymore!
    1339     ID, // founding player <<12 + number, never changes, unique within the whole game
    1340     Size, Flags: word;
     1355    Owner: Word; // last known owner, even if not alive anymore!
     1356    ID: Word; // founding player <<12 + number, never changes, unique within the whole game
     1357    Size: Word;
     1358    Flags: Word;
    13411359  end;
    13421360
    13431361  TModelInfo = packed record
    1344     Owner, // Player which owns the model
    1345     mix, // index of unit model for its owner
    1346     ID: word; // developing player shl 12 + number, never changes, unique within the whole game
    1347     Kind, Domain: Byte;
    1348     Attack, Defense, Speed, Cost: word;
    1349     TTrans, // ground unit transport capability
     1362    Owner: Word; // Player which owns the model
     1363    mix: Word; // index of unit model for its owner
     1364    ID: Word; // developing player shl 12 + number, never changes, unique within the whole game
     1365    Kind: Byte;
     1366    Domain: Byte;
     1367    Attack: Word;
     1368    Defense: Word;
     1369    Speed: Word;
     1370    Cost: Word;
     1371    TTrans: Byte; // ground unit transport capability
    13501372    ATrans_Fuel: Byte; // air unit transport capability resp. fuel
    1351     Bombs: word; // additional attack with bombs
     1373    Bombs: Word; // additional attack with bombs
    13521374    Cap: Cardinal; // special features, bitset with index Feature-mcFirstNonCap
    1353     MaxUpgrade, // maximum used upgrade
     1375    MaxUpgrade: Byte; // maximum used upgrade
    13541376    Weight: Byte;
    1355     Lost: word;
     1377    Lost: Word;
    13561378  end;
    13571379
    13581380  TBattle = packed record
    1359     Enemy, Flags: Byte;
    1360     Turn, mix, mixEnemy: word;
    1361     ToLoc, FromLoc: integer;
     1381    Enemy: Byte;
     1382    Flags: Byte;
     1383    Turn: Word;
     1384    mix: Word;
     1385    mixEnemy: Word;
     1386    ToLoc: Integer;
     1387    FromLoc: Integer;
    13621388  end;
    13631389
    13641390  TWonderInfo = record
    1365     CityID, // -2 if destroyed, -1 if never completed, >=0 ID of city
    1366     EffectiveOwner: integer
     1391    CityID: Integer; // -2 if destroyed, -1 if never completed, >=0 ID of city
     1392    EffectiveOwner: Integer;
    13671393    // owning player if effective, -1 if expired or not built
    1368     end;
    1369 
    1370     TShipInfo = record Parts: array [0 .. nShipPart - 1] of integer;
     1394  end;
     1395
     1396  TShipInfo = record
     1397    Parts: array [0 .. nShipPart - 1] of Integer;
    13711398  end;
    13721399
    13731400  TEnemyReport = record
    1374     TurnOfContact, TurnOfCivilReport, TurnOfMilReport, Attitude,
    1375       Credibility: integer; // 0..100, last update: ToC
    1376     Treaty: array [0 .. nPl - 1] of integer;
     1401    TurnOfContact: Integer;
     1402    TurnOfCivilReport: Integer;
     1403    TurnOfMilReport: Integer;
     1404    Attitude: Integer;
     1405    Credibility: Integer; // 0..100, last update: ToC
     1406    Treaty: array [0 .. nPl - 1] of Integer;
    13771407    // diplomatic status with other nations, last update: ToCR
    1378     Government, // gAnarchy..gDemocracy, last update: ToCR
    1379     Money, // last update: ToCR
    1380     ResearchTech, ResearchDone: integer; // last update: ToCR
     1408    Government: Integer; // gAnarchy..gDemocracy, last update: ToCR
     1409    Money: Integer; // last update: ToCR
     1410    ResearchTech: Integer; // last update: ToCR
     1411    ResearchDone: Integer; // last update: ToCR
    13811412    Tech: array [0 .. (nAdv + 3) div 4 * 4 - 1] of ShortInt;
    13821413    // tech status indicator, last update: ToCR
    1383     nModelCounted: integer;
     1414    nModelCounted: Integer;
    13841415    // number of models with info in UnCount, last update: ToMR
    1385     UnCount: array [0 .. INFIN] of word;
     1416    UnCount: array [0 .. INFIN] of Word;
    13861417    // number of available units for each model, last update: ToMR
    13871418  end;
    13881419
    13891420  TMoveAdviceData = record
    1390     ToLoc, nStep, MoreTurns, MaxHostile_MovementLeft: integer;
    1391     dx, dy: array [0 .. 24] of integer;
     1421    ToLoc: Integer;
     1422    nStep: Integer;
     1423    MoreTurns: Integer;
     1424    MaxHostile_MovementLeft: Integer;
     1425    dx: array [0 .. 24] of Integer;
     1426    dy: array [0 .. 24] of Integer;
    13921427  end;
    13931428
    13941429  TPlaneReturnData = record
    1395     Loc, Fuel, Movement: integer;
     1430    Loc: Integer;
     1431    Fuel: Integer;
     1432    Movement: Integer;
    13961433  end;
    13971434
    13981435  TTileInfo = record
    1399     Food, Prod, Trade, ExplCity: integer;
     1436    Food: Integer;
     1437    Prod: Integer;
     1438    Trade: Integer;
     1439    ExplCity: Integer;
    14001440  end;
    14011441
    14021442  TCityReport = record
    1403     HypoTiles, HypoTax, HypoLux, Working, Happy, FoodRep,
    1404       ProdRep, Trade, PollRep, Corruption, Tax, Lux, Science, Support, Eaten,
    1405       ProdCost, Storage, Deployed: integer;
     1443    HypoTiles: Integer;
     1444    HypoTax: Integer;
     1445    HypoLux: Integer;
     1446    Working: Integer;
     1447    Happy: Integer;
     1448    FoodRep: Integer;
     1449    ProdRep: Integer;
     1450    Trade: Integer;
     1451    PollRep: Integer;
     1452    Corruption: Integer;
     1453    Tax: Integer;
     1454    Lux: Integer;
     1455    Science: Integer;
     1456    Support: Integer;
     1457    Eaten: Integer;
     1458    ProdCost: Integer;
     1459    Storage: Integer;
     1460    Deployed: Integer;
    14061461  end;
    14071462
    14081463  TCityReportNew = record
    1409     HypoTiles,
     1464    HypoTiles: Integer;
    14101465    // tiles that should be considered as exploited (for the current adjustment, set this to -1 or to TCity.Tiles of the city)
    1411     HypoTaxRate, HypoLuxuryRate,
     1466    HypoTaxRate: Integer;
     1467    HypoLuxuryRate: Integer;
    14121468    // tax and luxury rate that should be assumed (for current rates, set this to -1 or to RO.TaxRate resp. RO.LuxRate)
    1413     Morale, FoodSupport, MaterialSupport,
     1469    Morale: Integer;
     1470    FoodSupport: Integer;
     1471    MaterialSupport: Integer;
    14141472    // food and material taken for unit support
    1415     ProjectCost, // material cost of current project
    1416     Storage, // size of food storage
    1417     Deployed, // number of units causing unrest (unrest=2*deployed)
    1418     CollectedControl, CollectedFood, CollectedMaterial, CollectedTrade,
     1473    ProjectCost: Integer; // material cost of current project
     1474    Storage: Integer; // size of food storage
     1475    Deployed: Integer; // number of units causing unrest (unrest=2*deployed)
     1476    CollectedControl: Integer;
     1477    CollectedFood: Integer;
     1478    CollectedMaterial: Integer;
     1479    CollectedTrade: Integer;
    14191480    // raw control, food, material and trade as collected by the citizens
    1420     Working, // number of exploited tiles including city tile
    1421     FoodSurplus, Production, AddPollution,
     1481    Working: Integer; // number of exploited tiles including city tile
     1482    FoodSurplus: Integer;
     1483    Production: Integer;
     1484    AddPollution: Integer;
    14221485    // food surplus, production gain and pollution after all effects
    1423     Corruption, Tax, Science, Luxury,
     1486    Corruption: Integer;
     1487    Tax: Integer;
     1488    Science: Integer;
     1489    Luxury: Integer;
    14241490    // corruption, tax, science and wealth after all effects
    1425     HappinessBalance: integer;
     1491    HappinessBalance: Integer;
    14261492    // = (Morale+Wealth+Control) - (Size+Unrest), value < 0 means disorder
    14271493  end;
    14281494
    14291495  TCityTileAdviceData = record
    1430     ResourceWeights, Tiles: Cardinal;
     1496    ResourceWeights: Cardinal;
     1497    Tiles: Cardinal;
    14311498    CityReport: TCityReport;
    14321499  end;
    14331500
    14341501  TGetCityData = record
    1435     Owner: integer;
     1502    Owner: Integer;
    14361503    c: TCity;
    14371504  end;
    14381505
    14391506  TCityAreaInfo = record
    1440     Available: array [0 .. 26] of integer;
     1507    Available: array [0 .. 26] of Integer;
    14411508  end;
    14421509
    14431510  TUnitReport = record
    1444     FoodSupport, ProdSupport, ReportFlags: integer;
     1511    FoodSupport: Integer;
     1512    ProdSupport: Integer;
     1513    ReportFlags: Integer;
    14451514  end;
    14461515
    14471516  TJobProgressData = array [0 .. nJob - 1] of record
    14481517    Required, Done,
    1449     NextTurnPlus: integer;
    1450   end;
     1518    NextTurnPlus: Integer;
     1519  end;
     1520
    14511521  TBattleForecast = record
    1452     pAtt, mixAtt, HealthAtt, ExpAtt, FlagsAtt, Movement,
    1453     EndHealthDef, EndHealthAtt: integer;
    1454   end;
     1522    pAtt: Integer;
     1523    mixAtt: Integer;
     1524    HealthAtt: Integer;
     1525    ExpAtt: Integer;
     1526    FlagsAtt: Integer;
     1527    Movement: Integer;
     1528    EndHealthDef: Integer;
     1529    EndHealthAtt: Integer;
     1530  end;
     1531
    14551532  TBattleForecastEx = record
    1456     pAtt, mixAtt, HealthAtt, ExpAtt, FlagsAtt, Movement,
    1457     EndHealthDef, EndHealthAtt: integer; // must be same as in TBattleForecast
    1458     AStr, DStr, ABaseDamage, DBaseDamage: integer;
    1459   end;
     1533    pAtt: Integer;
     1534    mixAtt: Integer;
     1535    HealthAtt: Integer;
     1536    ExpAtt: Integer;
     1537    FlagsAtt: Integer;
     1538    Movement: Integer;
     1539    EndHealthDef: Integer;
     1540    EndHealthAtt: Integer; // must be same as in TBattleForecast
     1541    AStr: Integer;
     1542    DStr: Integer;
     1543    ABaseDamage: Integer;
     1544    DBaseDamage: Integer;
     1545  end;
     1546
    14601547  TShowMove = record
    1461     Owner, Health, mix, emix, Flags, FromLoc, dx, dy, EndHealth,
    1462     EndHealthDef, Fuel, Exp, Load: integer;
    1463   end;
     1548    Owner: Integer;
     1549    Health: Integer;
     1550    mix: Integer;
     1551    emix: Integer;
     1552    Flags: Integer;
     1553    FromLoc: Integer;
     1554    dx: Integer;
     1555    dy: Integer;
     1556    EndHealth: Integer;
     1557    EndHealthDef: Integer;
     1558    Fuel: Integer;
     1559    Exp: Integer;
     1560    Load: Integer;
     1561  end;
     1562
    14641563  TShowShipChange = record
    1465     Reason, Ship1Owner, Ship2Owner: integer;
    1466     Ship1Change, Ship2Change: array [0 .. nShipPart - 1] of integer;
    1467   end;
     1564    Reason: Integer;
     1565    Ship1Owner: Integer;
     1566    Ship2Owner: Integer;
     1567    Ship1Change: array [0 .. nShipPart - 1] of Integer;
     1568    Ship2Change: array [0 .. nShipPart - 1] of Integer;
     1569  end;
     1570
    14681571  TOffer = record
    1469     nDeliver, nCost: integer;
     1572    nDeliver: Integer;
     1573    nCost: Integer;
    14701574    Price: array [0 .. 11] of Cardinal;
    14711575  end;
    1472   TChart = array [0 .. INFIN] of integer;
     1576
     1577  TChart = array [0 .. INFIN] of Integer;
    14731578  TEditTileData = record
    1474     Loc, NewTile: integer
     1579    Loc: Integer;
     1580    NewTile: Integer;
    14751581  end;
    14761582  TCreateUnitData = record
    1477     Loc, p, mix: integer;
     1583    Loc: Integer;
     1584    p: Integer;
     1585    mix: Integer;
    14781586  end;
    14791587
     
    14921600
    14931601  TPlayerContext = record
    1494     Data: pointer;
     1602    Data: Pointer;
    14951603    Map: ^TTileList;
    14961604    { the playground, a list of tiles with index = location, see tile flags }
     
    15061614    EnemyReport: array [0 .. nPl - 1] of ^TEnemyReport;
    15071615
    1508     TestFlags, // options turned on in the "Manipulation" menu
    1509     Turn, // current turn
    1510     Alive, { bitset of IDs of players still alive, flag 1 shl p for player p }
    1511     Happened, // flags indicate what happened within the last turnaround
    1512     AnarchyStart, // start turn of anarchy, <0 if not in anarchy
    1513     Credibility, // own credibility
    1514     MaxCredibility, // maximum credibility still to achieve
    1515     nUn, { number of units }
    1516     nCity, { number of cities }
    1517     nModel, { number of developed unit models }
    1518     nEnemyUn, nEnemyCity, nEnemyModel, Government, { gAnarchy..gDemocracy }
    1519     Money, TaxRate, LuxRate, Research,
     1616    TestFlags: Integer; // options turned on in the "Manipulation" menu
     1617    Turn: Integer; // current turn
     1618    Alive: Integer; { bitset of IDs of players still alive, flag 1 shl p for player p }
     1619    Happened: Integer; // flags indicate what happened within the last turnaround
     1620    AnarchyStart: Integer; // start turn of anarchy, <0 if not in anarchy
     1621    Credibility: Integer; // own credibility
     1622    MaxCredibility: Integer; // maximum credibility still to achieve
     1623    nUn: Integer; { number of units }
     1624    nCity: Integer; { number of cities }
     1625    nModel: Integer; { number of developed unit models }
     1626    nEnemyUn: Integer;
     1627    nEnemyCity: Integer;
     1628    nEnemyModel: Integer;
     1629    Government: Integer; { gAnarchy..gDemocracy }
     1630    Money: Integer;
     1631    TaxRate: Integer;
     1632    LuxRate: Integer;
     1633    Research: Integer;
    15201634    { collected research points for currently researched tech }
    1521     ResearchTech: integer; // currently researched tech
     1635    ResearchTech: Integer; // currently researched tech
    15221636    DevModel: TModel; { unit model currently under development }
    15231637    Tech: array [0 .. (nAdv + 3) div 4 * 4 - 1] of ShortInt; { tech status indicator }
    1524     Attitude: array [0 .. nPl - 1] of integer; // attitude to other nations
    1525     Treaty: array [0 .. nPl - 1] of integer; // treaty with other nations
    1526     EvaStart: array [0 .. nPl - 1] of integer; // peace treaty: start of evacuation period
    1527     Tribute: array [0 .. nPl - 1] of integer; // no longer in use
    1528     TributePaid: array [0 .. nPl - 1] of integer; // no longer in use
     1638    Attitude: array [0 .. nPl - 1] of Integer; // attitude to other nations
     1639    Treaty: array [0 .. nPl - 1] of Integer; // treaty with other nations
     1640    EvaStart: array [0 .. nPl - 1] of Integer; // peace treaty: start of evacuation period
     1641    Tribute: array [0 .. nPl - 1] of Integer; // no longer in use
     1642    TributePaid: array [0 .. nPl - 1] of Integer; // no longer in use
    15291643    Wonder: array [0 .. 27] of TWonderInfo;
    15301644    Ship: array [0 .. nPl - 1] of TShipInfo;
    15311645    NatBuilt: array [28 .. (nImp + 3) div 4 * 4 - 1] of ShortInt;
    1532     nBattleHistory: integer;
     1646    nBattleHistory: Integer;
    15331647    BattleHistory: ^TBattleList; // complete list of all my battles in the whole game
    15341648    BorderHelper: ^TByteList;
    1535     LastCancelTreaty: array [0 .. nPl - 1] of integer; // turn of last treaty cancel
    1536     OracleIncome: integer;
     1649    LastCancelTreaty: array [0 .. nPl - 1] of Integer; // turn of last treaty cancel
     1650    OracleIncome: Integer;
    15371651    DefaultDebugMap: ^TIntList;
    15381652    Filler: array [0 .. 879] of Byte;
     
    15411655  TInitModuleData = record
    15421656    Server: TServerCall;
    1543     DataVersion, DataSize, Flags: integer;
     1657    DataVersion: Integer;
     1658    DataSize: Integer;
     1659    Flags: Integer;
    15441660  end;
    15451661
    15461662  TNewGameData = record
    1547     lx, ly, LandMass, MaxTurn: integer;
    1548     Difficulty: array [0 .. nPl - 1] of integer;
     1663    lx: Integer;
     1664    ly: Integer;
     1665    LandMass: Integer;
     1666    MaxTurn: Integer;
     1667    Difficulty: array [0 .. nPl - 1] of Integer;
    15491668    { difficulty levels of the players, if it's 0 this player is the supervisor,
    15501669      -1 for unused slots }
    15511670    RO: array [0 .. nPl - 1] of ^TPlayerContext;
    1552     AssemblyPath: array [0 .. 255] of char;
     1671    AssemblyPath: array [0 .. 255] of Char;
    15531672    SuperVisorRO: array [0 .. nPl - 1] of ^TPlayerContext;
    15541673  end;
    15551674
    15561675  TNewGameExData = record
    1557     lx, ly, LandMass, MaxTurn, RND: integer;
    1558     Difficulty: array [0 .. nPl - 1] of integer;
     1676    lx: Integer;
     1677    ly: Integer;
     1678    LandMass: Integer;
     1679    MaxTurn: Integer;
     1680    RND: Integer;
     1681    Difficulty: array [0 .. nPl - 1] of Integer;
    15591682    { difficulty levels of the players, if it's 0 this player is the supervisor,
    15601683      -1 for unused slots }
    1561     Controlled: integer;
     1684    Controlled: Integer;
    15621685  end;
    15631686
    15641687  TShowNegoData = record
    1565     pSender, pTarget, Action: integer;
     1688    pSender: Integer;
     1689    pTarget: Integer;
     1690    Action: Integer;
    15661691    Offer: TOffer;
    15671692  end;
     
    16321757    { preLeo,preLighthouse, } preLeo);
    16331758
    1634 procedure MakeUnitInfo(p: integer; const u: TUn; var ui: TUnitInfo);
    1635 procedure MakeModelInfo(p, mix: integer; const m: TModel; var mi: TModelInfo);
    1636 function IsSameModel(const mi1, mi2: TModelInfo): boolean;
    1637 function SpecialTile(Loc, TerrType, lx: integer): integer;
     1759var
     1760  DelphiRandSeed: Integer;
     1761
     1762procedure MakeUnitInfo(p: Integer; const u: TUn; var ui: TUnitInfo);
     1763procedure MakeModelInfo(p, mix: Integer; const m: TModel; var mi: TModelInfo);
     1764function IsSameModel(const mi1, mi2: TModelInfo): Boolean;
     1765function SpecialTile(Loc, TerrType, lx: Integer): Integer;
     1766function DelphiRandom(const pi_Max: Integer): Integer; overload;
     1767function DelphiRandom: Extended; overload;
     1768procedure DelphiRandomize;
    16381769
    16391770implementation
    16401771
    1641 procedure MakeUnitInfo(p: integer; const u: TUn; var ui: TUnitInfo);
     1772procedure MakeUnitInfo(p: Integer; const u: TUn; var ui: TUnitInfo);
    16421773begin
    16431774  ui.Owner := p;
     
    16521783end;
    16531784
    1654 procedure MakeModelInfo(p, mix: integer; const m: TModel; var mi: TModelInfo);
     1785procedure MakeModelInfo(p, mix: Integer; const m: TModel; var mi: TModelInfo);
    16551786var
    1656   i: integer;
     1787  i: Integer;
    16571788begin
    16581789  mi.Owner := p;
     
    16911822end;
    16921823
    1693 function IsSameModel(const mi1, mi2: TModelInfo): boolean;
     1824function IsSameModel(const mi1, mi2: TModelInfo): Boolean;
    16941825type
    16951826  TModelInfo_Compare = array [0 .. 5] of Cardinal;
     
    17041835end;
    17051836
    1706 function SpecialTile(Loc, TerrType, lx: integer): integer;
     1837function SpecialTile(Loc, TerrType, lx: Integer): Integer;
    17071838var
    1708   x, y, qx, qy, a: integer;
     1839  x, y, qx, qy, a: Integer;
    17091840begin
    17101841  if TerrType = fOcean then
     
    17521883procedure InitUnit;
    17531884begin
    1754   { TODO
    1755   Assert(sizeof(TPlayerContext) = 2048);
    1756   Assert(sizeof(TModel) - 2 * sizeof(LongInt) - 4 * sizeof(word)
     1885  Assert(SizeOf(TPlayerContext) = 1936 + 28 * SizeOf(Pointer));
     1886  Assert(SizeOf(TModel) - 2 * SizeOf(LongInt) - 4 * SizeOf(Word)
    17571887  = sIntSetDevModel and $F * 4);
    1758   }
    17591888end;
    17601889
     1890function DelphiRandom(const pi_Max: Integer): Integer;
     1891var
     1892  Temp: LongInt;
     1893begin
     1894  Temp := LongInt(Int64(134775813) * Int64(DelphiRandSeed) + 1);
     1895  DelphiRandSeed := LongInt(Temp);
     1896  Result := (UInt64(Cardinal(pi_Max)) * UInt64(Cardinal(Temp))) shr 32;
     1897end;
     1898
     1899function DelphiRandom: Extended; overload;
     1900begin
     1901  Result := DelphiRandom(High(LongInt)) / High(LongInt);
     1902end;
     1903
     1904procedure DelphiRandomize;
     1905begin
     1906  Randomize;
     1907  DelphiRandSeed := RandSeed;
     1908end;
     1909
    17611910initialization
    17621911
Note: See TracChangeset for help on using the changeset viewer.