Changeset 24 for trunk/AI/Protocol.pas


Ignore:
Timestamp:
Jan 8, 2017, 5:53:41 PM (7 years ago)
Author:
chronos
Message:
  • Fixed: AI DLL library handle data type for 64-bit mode.
Location:
trunk/AI
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/AI

    • Property svn:ignore
      •  

        old new  
        22AIProject.lps
        33StdAI.dll.dll
         4StdAI.dll
  • trunk/AI/Protocol.pas

    r23 r24  
    1 {$INCLUDE switches.inc}
     1{$INCLUDE Switches.inc}
    22{$HINTS OFF}
    33unit Protocol;
     
    5252
    5353  // difficulty settings
    54   MaxDiff = 3; { maximum difficulty level }
    55   StorageSize: array [1 .. MaxDiff] of integer = (30, 40, 50);
    56   TechFormula_M: array [1 .. MaxDiff] of single = (2.0, 2.3, 2.6);
    57   TechFormula_D: array [1 .. MaxDiff] of single = (102.0, 80.0, 64.0);
    58   BuildCostMod: array [1 .. MaxDiff] of integer = (9, 12, 15); // in 1/12
     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
    5959
    6060  // test flags
     
    8383  sSetDebugMap = $0010;
    8484  sGetDebugMap = $0020;
    85   sChangeSuperView = $0030;
     85  { sChangeSuperView=$0030; } sRefreshDebugMap = $0040;
    8686  sGetChart = $0100; // + type shl 4
    8787  sGetTechCost = $0180;
     88  sGetAIInfo = $01C0;
    8889  sGetAICredits = $01D0;
    8990  sGetVersion = $01E0;
     
    198199  cHelpOnly = $0700;
    199200  cStartHelp = $0710;
     201  cStartCredits = $0720;
    200202
    201203  cNewGame = $0800;
     
    235237  cShowSupportAllianceAgainst = $3830;
    236238  cShowPeaceViolation = $3880;
    237   cShowGame = $3F00;
    238   cShowSuperView = $3F80;
     239  cShowGame = $3F00; { cShowSuperView=$3F80; }
     240  cRefreshDebugMap = $3F90;
    239241
    240242  // diplomacy commands equal to server, see below
     
    252254  scDipOffer = $4B4E;
    253255  scDipBreak = $4BF0;
    254 
    255   // advisor commands
    256   aInitModule = $0000;
    257   aReleaseModule = $0100;
    258   aNewGame = $0800;
    259   aBreakGame = $0900;
    260   aGiveStrategyAdvice = $4000;
    261   aGiveCityAdvice = $4100;
    262256
    263257  { server return codes: flags }
     
    430424  trNoContact = -1;
    431425  trNone = 0;
    432   trCeaseFire = 1;
    433426  trPeace = 2;
    434427  trFriendlyContact = 3;
     
    580573  gDemocracy = 6;
    581574  gFuture = 7;
    582 
    583   // colony ship
    584   nShipPart = 3;
    585   spComp = 0;
    586   spPow = 1;
    587   spHab = 2;
    588   ShipNeed: array [0 .. nShipPart - 1] of integer = (6, 4, 2);
    589575
    590576  // ship change reasons
     
    738724  futMaterialTechnology = 92;
    739725  futArtificialIntelligence = 93;
     726
     727  FutureTech = [futComputingTechnology, futNanoTechnology,
     728    futMaterialTechnology, futArtificialIntelligence];
    740729
    741730  adMilitary = $800; // Military Research
     
    10251014  (NewImp: imMilAcademy; OldImp: imBarracks));
    10261015
     1016// colony ship
     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
    10271026GovPreq:
    10281027array [1 .. nGov - 1] of integer = { government prerequisites }
     
    12221221mkDiplomat = mkCommando;
    12231222gLybertarianism = gFuture;
     1223trCeaseFire = 1;
    12241224adIntelligenArms = adSmartWeapons;
    12251225adIntelligentArms = adSmartWeapons;
     
    12411241    : integer; stdcall;
    12421242  TClientCall = procedure(Command, Player: integer; var Data); stdcall;
    1243   TGiveAdviceCall = procedure(Text: PChar;
    1244     Nation, CityID, Loc: integer); stdcall;
    12451243
    12461244  TUn = packed record
     
    14181416  TJobProgressData = array [0 .. nJob - 1] of record Required, Done,
    14191417    NextTurnPlus: integer;
    1420 end;
    1421 TBattleForecast = record pAtt, mixAtt, HealthAtt, ExpAtt, FlagsAtt, Movement,
    1422   EndHealthDef, EndHealthAtt: integer;
    1423 end;
    1424 TBattleForecastEx = record pAtt, mixAtt, HealthAtt, ExpAtt, FlagsAtt, Movement,
    1425   EndHealthDef, EndHealthAtt: integer; // must be same as in TBattleForecast
    1426 AStr, DStr, ABaseDamage, DBaseDamage: integer;
    1427 end;
    1428 TShowMove = record Owner, Health, mix, emix, Flags, FromLoc, dx, dy, EndHealth,
    1429   EndHealthDef, Fuel, Exp, Load: integer;
    1430 end;
    1431 TShowShipChange = record Reason, Ship1Owner, Ship2Owner: integer;
    1432 Ship1Change, Ship2Change: array [0 .. nShipPart - 1] of integer;
    1433 end;
    1434 TOffer = record nDeliver, nCost: integer;
    1435 Price:
    1436 array [0 .. 11] of Cardinal;
    1437 end;
    1438 TChart = array [0 .. INFIN] of integer;
    1439 TEditTileData = record Loc, NewTile: integer
    1440 end;
    1441 TCreateUnitData = record Loc, p, mix: integer;
    1442 end;
    1443 
    1444 TTileList = array [0 .. INFIN] of Cardinal;
    1445 TTileObservedLastList = array [0 .. INFIN] of SmallInt;
    1446 TOwnerList = array [0 .. INFIN] of ShortInt;
    1447 TByteList = array [0 .. INFIN] of Byte;
    1448 TCityList = array [0 .. INFIN] of TCity;
    1449 TUnList = array [0 .. INFIN] of TUn;
    1450 TModelList = array [0 .. INFIN] of TModel;
    1451 TEnemyUnList = array [0 .. INFIN] of TUnitInfo;
    1452 TEnemyCityList = array [0 .. INFIN] of TCityInfo;
    1453 TEnemyModelList = array [0 .. INFIN] of TModelInfo;
    1454 TBattleList = array [0 .. INFIN] of TBattle;
    1455 
    1456 TPlayerContext = record Data: pointer;
    1457 Map:
    1458 ^TTileList;
    1459 { the playground, a list of tiles with index = location, see tile flags }
    1460 MapObservedLast:
    1461 ^TTileObservedLastList;
    1462 // turn in which the tile was observed last, index = location
    1463 Territory:
    1464 ^TOwnerList; // nation to which's territory a tile belongs, -1 indicates none
    1465 Un:
    1466 ^TUnList; { units }
    1467 City:
    1468 ^TCityList; { cities }
    1469 Model:
    1470 ^TModelList; { unit models }
    1471 EnemyUn:
    1472 ^TEnemyUnList; // known units of enemy players
    1473 EnemyCity:
    1474 ^TEnemyCityList; // known cities of enemy players
    1475 EnemyModel:
    1476 ^TEnemyModelList; // known unit models of enemy players
    1477 EnemyReport:
    1478 array [0 .. nPl - 1] of ^TEnemyReport;
    1479 
    1480 TestFlags, // options turned on in the "Manipulation" menu
    1481 Turn, // current turn
    1482 Alive, { bitset of IDs of players still alive, flag 1 shl p for player p }
    1483 Happened, // flags indicate what happened within the last turnaround
    1484 AnarchyStart, // start turn of anarchy, <0 if not in anarchy
    1485 Credibility, // own credibility
    1486 MaxCredibility, // maximum credibility still to achieve
    1487 nUn, { number of units }
    1488 nCity, { number of cities }
    1489 nModel, { number of developed unit models }
    1490 nEnemyUn, nEnemyCity, nEnemyModel, Government, { gAnarchy..gDemocracy }
    1491 Money, TaxRate, LuxRate, Research,
    1492 { collected research points for currently researched tech }
    1493 ResearchTech: integer; // currently researched tech
    1494 DevModel:
    1495 TModel; { unit model currently under development }
    1496 Tech:
    1497 array [0 .. (nAdv + 3) div 4 * 4 - 1] of ShortInt; { tech status indicator }
    1498 Attitude:
    1499 array [0 .. nPl - 1] of integer; // attitude to other nations
    1500 Treaty:
    1501 array [0 .. nPl - 1] of integer; // treaty with other nations
    1502 EvaStart:
    1503 array [0 .. nPl - 1] of integer; // peace treaty: start of evacuation period
    1504 Tribute:
    1505 array [0 .. nPl - 1] of integer; // no longer in use
    1506 TributePaid:
    1507 array [0 .. nPl - 1] of integer; // no longer in use
    1508 Wonder:
    1509 array [0 .. 27] of TWonderInfo;
    1510 Ship:
    1511 array [0 .. nPl - 1] of TShipInfo;
    1512 NatBuilt:
    1513 array [28 .. (nImp + 3) div 4 * 4 - 1] of ShortInt;
    1514 nBattleHistory:
    1515 integer;
    1516 BattleHistory:
    1517 ^TBattleList; // complete list of all my battles in the whole game
    1518 BorderHelper:
    1519 ^TByteList;
    1520 LastCancelTreaty:
    1521 array [0 .. nPl - 1] of integer; // turn of last treaty cancel
    1522 OracleIncome:
    1523 integer;
    1524 Filler:
    1525 array [0 .. 883] of Byte;
    1526 end;
    1527 
    1528 TInitModuleData = record Server: TServerCall;
    1529 DataVersion, DataSize, Flags: integer;
    1530 end;
    1531 TInitAdvisorData = record Server: TServerCall;
    1532 GiveAdvice:
    1533 TGiveAdviceCall;
    1534 end;
    1535 TNewGameData = record lx, ly, LandMass, MaxTurn: integer;
    1536 Difficulty:
    1537 array [0 .. nPl - 1] of integer;
    1538 { difficulty levels of the players, if it's 0 this player is the supervisor,
    1539   -1 for unused slots }
    1540 RO:
    1541 array [0 .. nPl - 1] of ^TPlayerContext;
    1542 end;
    1543 TNewGameExData = record lx, ly, LandMass, MaxTurn, RND: integer;
    1544 Difficulty:
    1545 array [0 .. nPl - 1] of integer;
    1546 { difficulty levels of the players, if it's 0 this player is the supervisor,
    1547   -1 for unused slots }
    1548 Controlled:
    1549 integer;
    1550 end;
    1551 TShowNegoData = record pSender, pTarget, Action: integer;
    1552 Offer:
    1553 TOffer;
    1554 end;
     1418  end;
     1419  TBattleForecast = record
     1420    pAtt, mixAtt, HealthAtt, ExpAtt, FlagsAtt, Movement,
     1421    EndHealthDef, EndHealthAtt: integer;
     1422  end;
     1423  TBattleForecastEx = record
     1424    pAtt, mixAtt, HealthAtt, ExpAtt, FlagsAtt, Movement,
     1425    EndHealthDef, EndHealthAtt: integer; // must be same as in TBattleForecast
     1426    AStr, DStr, ABaseDamage, DBaseDamage: integer;
     1427  end;
     1428  TShowMove = record
     1429    Owner, Health, mix, emix, Flags, FromLoc, dx, dy, EndHealth,
     1430    EndHealthDef, Fuel, Exp, Load: integer;
     1431  end;
     1432  TShowShipChange = record
     1433    Reason, Ship1Owner, Ship2Owner: integer;
     1434    Ship1Change, Ship2Change: array [0 .. nShipPart - 1] of integer;
     1435  end;
     1436  TOffer = record nDeliver, nCost: integer;
     1437    Price: array [0 .. 11] of Cardinal;
     1438  end;
     1439  TChart = array [0 .. INFIN] of integer;
     1440  TEditTileData = record
     1441    Loc, NewTile: integer
     1442  end;
     1443  TCreateUnitData = record
     1444    Loc, p, mix: integer;
     1445  end;
     1446
     1447  TTileList = array [0 .. INFIN] of Cardinal;
     1448  TTileObservedLastList = array [0 .. INFIN] of SmallInt;
     1449  TOwnerList = array [0 .. INFIN] of ShortInt;
     1450  TByteList = array [0 .. INFIN] of Byte;
     1451  TIntList = array [0 .. INFIN] of integer;
     1452  TCityList = array [0 .. INFIN] of TCity;
     1453  TUnList = array [0 .. INFIN] of TUn;
     1454  TModelList = array [0 .. INFIN] of TModel;
     1455  TEnemyUnList = array [0 .. INFIN] of TUnitInfo;
     1456  TEnemyCityList = array [0 .. INFIN] of TCityInfo;
     1457  TEnemyModelList = array [0 .. INFIN] of TModelInfo;
     1458  TBattleList = array [0 .. INFIN] of TBattle;
     1459
     1460  TPlayerContext = record
     1461    Data: pointer;
     1462    Map: ^TTileList;
     1463    { the playground, a list of tiles with index = location, see tile flags }
     1464    MapObservedLast: ^TTileObservedLastList;
     1465    // turn in which the tile was observed last, index = location
     1466    Territory: ^TOwnerList; // nation to which's territory a tile belongs, -1 indicates none
     1467    Un: ^TUnList; { units }
     1468    City: ^TCityList; { cities }
     1469    Model: ^TModelList; { unit models }
     1470    EnemyUn: ^TEnemyUnList; // known units of enemy players
     1471    EnemyCity: ^TEnemyCityList; // known cities of enemy players
     1472    EnemyModel: ^TEnemyModelList; // known unit models of enemy players
     1473    EnemyReport: array [0 .. nPl - 1] of ^TEnemyReport;
     1474
     1475    TestFlags, // options turned on in the "Manipulation" menu
     1476    Turn, // current turn
     1477    Alive, { bitset of IDs of players still alive, flag 1 shl p for player p }
     1478    Happened, // flags indicate what happened within the last turnaround
     1479    AnarchyStart, // start turn of anarchy, <0 if not in anarchy
     1480    Credibility, // own credibility
     1481    MaxCredibility, // maximum credibility still to achieve
     1482    nUn, { number of units }
     1483    nCity, { number of cities }
     1484    nModel, { number of developed unit models }
     1485    nEnemyUn, nEnemyCity, nEnemyModel, Government, { gAnarchy..gDemocracy }
     1486    Money, TaxRate, LuxRate, Research,
     1487    { collected research points for currently researched tech }
     1488    ResearchTech: integer; // currently researched tech
     1489    DevModel: TModel; { unit model currently under development }
     1490    Tech: array [0 .. (nAdv + 3) div 4 * 4 - 1] of ShortInt; { tech status indicator }
     1491    Attitude: array [0 .. nPl - 1] of integer; // attitude to other nations
     1492    Treaty: array [0 .. nPl - 1] of integer; // treaty with other nations
     1493    EvaStart: array [0 .. nPl - 1] of integer; // peace treaty: start of evacuation period
     1494    Tribute: array [0 .. nPl - 1] of integer; // no longer in use
     1495    TributePaid: array [0 .. nPl - 1] of integer; // no longer in use
     1496    Wonder: array [0 .. 27] of TWonderInfo;
     1497    Ship: array [0 .. nPl - 1] of TShipInfo;
     1498    NatBuilt: array [28 .. (nImp + 3) div 4 * 4 - 1] of ShortInt;
     1499    nBattleHistory: integer;
     1500    BattleHistory: ^TBattleList; // complete list of all my battles in the whole game
     1501    BorderHelper: ^TByteList;
     1502    LastCancelTreaty: array [0 .. nPl - 1] of integer; // turn of last treaty cancel
     1503    OracleIncome: integer;
     1504    DefaultDebugMap: ^TIntList;
     1505    Filler: array [0 .. 879] of Byte;
     1506  end;
     1507
     1508  TInitModuleData = record
     1509    Server: TServerCall;
     1510    DataVersion, DataSize, Flags: integer;
     1511  end;
     1512
     1513  TNewGameData = record
     1514    lx, ly, LandMass, MaxTurn: integer;
     1515    Difficulty: array [0 .. nPl - 1] of integer;
     1516    { difficulty levels of the players, if it's 0 this player is the supervisor,
     1517      -1 for unused slots }
     1518    RO: array [0 .. nPl - 1] of ^TPlayerContext;
     1519    AssemblyPath: array [0 .. 255] of char;
     1520    SuperVisorRO: array [0 .. nPl - 1] of ^TPlayerContext;
     1521  end;
     1522
     1523  TNewGameExData = record
     1524    lx, ly, LandMass, MaxTurn, RND: integer;
     1525    Difficulty: array [0 .. nPl - 1] of integer;
     1526    { difficulty levels of the players, if it's 0 this player is the supervisor,
     1527      -1 for unused slots }
     1528    Controlled: integer;
     1529  end;
     1530
     1531  TShowNegoData = record
     1532    pSender, pTarget, Action: integer;
     1533    Offer: TOffer;
     1534  end;
    15551535
    15561536const
     
    16451625  mi.Owner := p;
    16461626  mi.mix := mix;
     1627  mi.ID := m.ID;
    16471628  mi.Domain := m.Domain;
    16481629  if m.Kind = mkEnemyDeveloped then
     
    17361717end;
    17371718
     1719procedure InitUnit;
    17381720begin
    1739   assert(sizeof(TPlayerContext) = 2048);
    1740   assert(sizeof(TModel) - 2 * sizeof(LongInt) - 4 * sizeof(word)
    1741     = sIntSetDevModel and $F * 4);
     1721  { TODO
     1722  Assert(sizeof(TPlayerContext) = 2048);
     1723  Assert(sizeof(TModel) - 2 * sizeof(LongInt) - 4 * sizeof(word)
     1724  = sIntSetDevModel and $F * 4);
     1725  }
     1726end;
     1727
     1728initialization
     1729
     1730InitUnit;
    17421731
    17431732end.
Note: See TracChangeset for help on using the changeset viewer.