1762 lines
63 KiB
C++
1762 lines
63 KiB
C++
// This file is part of cevo-evo.
|
|
//
|
|
// This software is governed by the CeCILL license under French law and
|
|
// abiding by the rules of distribution of free software. You can use,
|
|
// modify and/or redistribute the software under the terms of the CeCILL
|
|
// license as circulated by CEA, CNRS and INRIA at the following URL
|
|
// "http://www.cecill.info".
|
|
//
|
|
// As a counterpart to the access to the source code and rights to copy,
|
|
// modify and redistribute granted by the license, users are provided only
|
|
// with a limited warranty and the software's author, the holder of the
|
|
// economic rights, and the successive licensors have only limited
|
|
// liability.
|
|
//
|
|
// In this respect, the user's attention is drawn to the risks associated
|
|
// with loading, using, modifying and/or developing or reproducing the
|
|
// software by the user in light of its specific status of free software,
|
|
// that may mean that it is complicated to manipulate, and that also
|
|
// therefore means that it is reserved for developers and experienced
|
|
// professionals having in-depth computer knowledge. Users are therefore
|
|
// encouraged to load and test the software's suitability as regards their
|
|
// requirements in conditions enabling the security of their systems and/or
|
|
// data to be ensured and, more generally, to use and operate it in the
|
|
// same conditions as regards security.
|
|
//
|
|
// The fact that you are presently reading this means that you have had
|
|
// knowledge of the CeCILL license and that you accept its terms.
|
|
|
|
#pragma once
|
|
|
|
// C++ port of the C-evo "Protocol" unit (AI Template/Protocol.pas): the wire
|
|
// format shared between the game server and every "brain" module (AI
|
|
// plugins, the terminal/human client, network proxies, ...). It has no
|
|
// dependency on Qt (or any other UI framework) in the original Pascal, and
|
|
// none is introduced here either, so this header can be used standalone by
|
|
// any AI implementation.
|
|
//
|
|
// Scope: command/flag/rule-index constants, the structs exchanged across the
|
|
// Client/Server call boundary, and the TClientCall/TServerCall function
|
|
// pointer ABI. This covers everything needed for *interface compatibility*
|
|
// with existing precompiled AI modules (StdAI, Capital AI, KIAI, SETI,
|
|
// Shah, Crystal, ...): same numeric command codes, same struct layouts, same
|
|
// calling convention.
|
|
//
|
|
// NOT ported here (left as a follow-up, pure data with no ABI-shape impact):
|
|
// the large gameplay rule tables Imp[], Terrain[], Upgrade[], Feature[],
|
|
// AdvPreq[], GovPreq, AgePreq, JobPreq, SpecialModel[], ShipNeed/ShipImpIndex,
|
|
// SettlerFood/CorrLevel/SupportFree, ImpReplacement, AutoFeature,
|
|
// WeightPreq7/10. An AI module compiled against a slightly different copy of
|
|
// those tables still speaks the same wire protocol; it just has stale rule
|
|
// knowledge, which is a correctness/strength concern, not an ABI one.
|
|
//
|
|
// Field order/types mirror the Pascal records exactly; `{$PACKRECORDS C}`
|
|
// (Free Pascal's C-compatible alignment) matches plain C++ struct layout on
|
|
// every platform/compiler C-evo ships for, except the handful of Pascal
|
|
// "packed record"s below, which are additionally pragma-packed to remove
|
|
// all padding, matching the "packed" modifier overriding the C-mode default.
|
|
|
|
#include <cstdint>
|
|
|
|
namespace Cevo {
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Calling convention: Free Pascal's "stdcall" is only a real distinct ABI on
|
|
// Windows; on Linux/macOS it is implemented identically to the platform's
|
|
// normal (cdecl-like) calling convention. This matches StdAI's precompiled
|
|
// libstdai-amd64.so/libstdai-arm64.so, which export a plain C-convention
|
|
// "client" symbol.
|
|
#if defined(_WIN32)
|
|
#define CEVO_ABI_CALL __stdcall
|
|
#else
|
|
#define CEVO_ABI_CALL
|
|
#endif
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// General limits
|
|
|
|
constexpr int lxmax = 100;
|
|
constexpr int lymax = 96;
|
|
constexpr int nAdv = 94; // number of advances
|
|
constexpr int nImp = 70; // number of improvements
|
|
constexpr int nPl = 15; // max number of players, don't change!
|
|
constexpr int nWonder = 28; // number of wonders
|
|
constexpr int nUmax = 4096; // max units/player, don't set above 4096
|
|
constexpr int nCmax = 1024; // max cities/player, don't set above 4096
|
|
constexpr int nMmax = 256; // max models/player, don't set above 1024
|
|
constexpr int nExp = 5; // number of experience levels
|
|
constexpr int ExpCost = 50; // received damage required for next experience level
|
|
constexpr int MaxFutureTech = 25; // max future techs of one kind except computing technology
|
|
constexpr int MaxFutureTech_Computing = 100; // max computing technology future techs
|
|
constexpr int CountryRadius = 9;
|
|
constexpr int MaxCitySize = 30;
|
|
constexpr int BasicHappy = 2; // basically happy citizens
|
|
constexpr int MaxPollution = 240;
|
|
constexpr int NeedAqueductSize = 8;
|
|
constexpr int NeedSewerSize = 12;
|
|
constexpr int ColossusEffect = 75; // percent wonder building cost
|
|
constexpr int UniversityFutureBonus = 5; // percent per tech
|
|
constexpr int ResLabFutureBonus = 10; // percent per tech
|
|
constexpr int FactoryFutureBonus = 5; // percent per tech
|
|
constexpr int MfgPlantFutureBonus = 10; // percent per tech
|
|
constexpr int AnarchyTurns = 3;
|
|
constexpr int CaptureTurns = 3;
|
|
constexpr int CancelTreatyTurns = 3;
|
|
constexpr int PeaceEvaTurns = 5;
|
|
constexpr int ColdWarTurns = 40;
|
|
constexpr int DesertThurst = 20; // damage for turn in desert
|
|
constexpr int ArcticThurst = 20; // damage for turn in arctic
|
|
constexpr int FastRecovery = 50;
|
|
constexpr int CityRecovery = 20;
|
|
constexpr int NoCityRecovery = 8;
|
|
constexpr int MaxMoneyPrice = 0xFFFF;
|
|
constexpr int MaxShipPartPrice = 100;
|
|
constexpr bool BombardmentDestroysCity = false;
|
|
constexpr int StartMoney = 0;
|
|
constexpr int InitialCredibility = 95;
|
|
constexpr int INFIN = 999999;
|
|
|
|
// AI module flags (for TInitModuleData.Flags)
|
|
constexpr int aiThreaded = 0x01;
|
|
|
|
// Difficulty settings (index 0 unused: matches Pascal's 1-based 1..MaxDiff)
|
|
constexpr int MaxDiff = 4;
|
|
constexpr int StorageSize[MaxDiff + 1] = { 0, 30, 40, 50, 60 };
|
|
constexpr float TechFormula_M[MaxDiff + 1] = { 0.0f, 2.0f, 2.3f, 2.6f, 4.0f };
|
|
constexpr float TechFormula_D[MaxDiff + 1] = { 0.0f, 102.0f, 80.0f, 64.0f, 64.0f };
|
|
constexpr int BuildCostMod[MaxDiff + 1] = { 0, 9, 12, 15, 18 }; // in 1/12
|
|
|
|
// Test flags
|
|
constexpr int nTestFlags = 7; // max. 11
|
|
constexpr int tfAllTechs = 0x001; // all nations get all techs
|
|
constexpr int tfImmImprove = 0x002; // city projects complete each turn
|
|
constexpr int tfImmAdvance = 0x004; // research complete each turn
|
|
constexpr int tfImmGrow = 0x008; // all cities grow in each turn
|
|
constexpr int tfUncover = 0x010; // all players see like supervisor
|
|
constexpr int tfAllContact = 0x020; // all nations can contact each other
|
|
constexpr int tfNoRareNeed = 0x040; // producing colony ship requires no modern resources
|
|
constexpr int tfTested = 0x800; // at least one test flag was set
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Server commands
|
|
// IMPORTANT: lowest 4 bits must indicate size in DWORDS of data parameter,
|
|
// except for request commands.
|
|
|
|
constexpr int sctMask = 0x3800; // server command type
|
|
constexpr int sExecute = 0x4000; // call command-sExecute to request return value without execution
|
|
constexpr int cClientEx = 0x8000;
|
|
|
|
// Info Request Commands
|
|
constexpr int sctInfo = 0x0000;
|
|
constexpr int sMessage = 0x0000;
|
|
constexpr int sSetDebugMap = 0x0010;
|
|
constexpr int sGetDebugMap = 0x0020;
|
|
constexpr int sRefreshDebugMap = 0x0040;
|
|
constexpr int sGetChart = 0x0100; // + type shl 4
|
|
constexpr int sGetTechCost = 0x0180;
|
|
constexpr int sGetAIInfo = 0x01C0;
|
|
constexpr int sGetAICredits = 0x01D0;
|
|
constexpr int sGetVersion = 0x01E0;
|
|
constexpr int sGetGameChanged = 0x01F0;
|
|
constexpr int sGetTileInfo = 0x0200;
|
|
constexpr int sGetCityTileInfo = 0x0210;
|
|
constexpr int sGetHypoCityTileInfo = 0x0220;
|
|
constexpr int sGetJobProgress = 0x0230;
|
|
constexpr int sGetModels = 0x0270;
|
|
constexpr int sGetUnits = 0x0280;
|
|
constexpr int sGetDefender = 0x0290;
|
|
constexpr int sGetBattleForecast = 0x02A0;
|
|
constexpr int sGetUnitReport = 0x02B0;
|
|
constexpr int sGetMoveAdvice = 0x02C0;
|
|
constexpr int sGetPlaneReturn = 0x02D0;
|
|
constexpr int sGetBattleForecastEx = 0x02E0;
|
|
constexpr int sGetCity = 0x0300;
|
|
constexpr int sGetCityReport = 0x0310;
|
|
constexpr int sGetCityAreaInfo = 0x0320;
|
|
constexpr int sGetEnemyCityReport = 0x0330;
|
|
constexpr int sGetEnemyCityAreaInfo = 0x0340;
|
|
constexpr int sGetCityTileAdvice = 0x0350;
|
|
constexpr int sGetCityReportNew = 0x0360;
|
|
constexpr int sGetEnemyCityReportNew = 0x0370;
|
|
|
|
// Map Editor Commands
|
|
constexpr int sEditTile = 0x0710;
|
|
constexpr int sRandomMap = 0x0780;
|
|
constexpr int sMapGeneratorRequest = 0x0790;
|
|
|
|
// Server Internal Commands (sctInfo without sExecute, sctInternal with sExecute)
|
|
constexpr int sctInternal = sctInfo;
|
|
constexpr int sIntTellAboutNation = 0x4000;
|
|
constexpr int sIntHaveContact = 0x4010;
|
|
constexpr int sIntCancelTreaty = 0x4020;
|
|
constexpr int sIntTellAboutModel = 0x4100; // + told player shl 4
|
|
constexpr int sIntDiscoverZOC = 0x4201;
|
|
constexpr int sIntExpandTerritory = 0x4218;
|
|
constexpr int sIntBuyMaterial = 0x4301;
|
|
constexpr int sIntPayPrices = 0x4402;
|
|
constexpr int sIntSetDevModel = 0x450D;
|
|
constexpr int sIntSetModelStatus = 0x4601;
|
|
constexpr int sIntSetUnitStatus = 0x4611;
|
|
constexpr int sIntSetCityStatus = 0x4621;
|
|
constexpr int sIntSetECityStatus = 0x4631;
|
|
constexpr int sIntDataChange = 0x4700;
|
|
|
|
// Client Deactivation Commands
|
|
constexpr int sctEndClient = 0x0800;
|
|
constexpr int sTurn = 0x4800;
|
|
constexpr int sBreak = 0x4810;
|
|
constexpr int sResign = 0x4820;
|
|
constexpr int sNextRound = 0x4830;
|
|
constexpr int sReload = 0x4841;
|
|
constexpr int sSaveMap = 0x4880;
|
|
constexpr int sAbandonMap = 0x4890;
|
|
|
|
// General Commands
|
|
constexpr int sctGeneral = 0x1000;
|
|
constexpr int sClearTestFlag = 0x5000;
|
|
constexpr int sSetTestFlag = 0x5010;
|
|
constexpr int sSetGovernment = 0x5100;
|
|
constexpr int sSetRates = 0x5110;
|
|
constexpr int sRevolution = 0x5120;
|
|
constexpr int sSetResearch = 0x5200;
|
|
constexpr int sStealTech = 0x5210;
|
|
constexpr int sSetAttitude = 0x5300; // + concerned player shl 4
|
|
constexpr int sCancelTreaty = 0x5400;
|
|
|
|
// Model Related Commands
|
|
constexpr int sctModel = 0x1800;
|
|
constexpr int sCreateDevModel = 0x5800;
|
|
constexpr int sSetDevModelCap = 0x5C00; // + value shl 4
|
|
|
|
// Unit Related Commands
|
|
constexpr int sctUnit = 0x2000;
|
|
constexpr int sRemoveUnit = 0x6000;
|
|
constexpr int sSetUnitHome = 0x6010;
|
|
constexpr int sSetSpyMission = 0x6100; // + mission shl 4
|
|
constexpr int sLoadUnit = 0x6200;
|
|
constexpr int sUnloadUnit = 0x6210;
|
|
constexpr int sSelectTransport = 0x6220;
|
|
constexpr int sCreateUnit = 0x6301; // + player shl 4
|
|
constexpr int sMoveUnit = 0x6400; // + dx and 7 shl 4 + dy and 7 shl 7
|
|
|
|
// Settlers Related Commands
|
|
constexpr int sctSettlers = 0x2800;
|
|
constexpr int sAddToCity = 0x6810;
|
|
constexpr int sStartJob = 0x6C00; // + job shl 4
|
|
|
|
// City Related Commands
|
|
constexpr int sctCity = 0x3000;
|
|
constexpr int sSetCityProject = 0x7001;
|
|
constexpr int sBuyCityProject = 0x7010;
|
|
constexpr int sSellCityProject = 0x7020;
|
|
constexpr int sSellCityImprovement = 0x7101;
|
|
constexpr int sRebuildCityImprovement = 0x7111;
|
|
constexpr int sSetCityTiles = 0x7201;
|
|
|
|
constexpr int sctUnused = 0x3800;
|
|
|
|
// Client commands
|
|
constexpr int cInitModule = 0x0000;
|
|
constexpr int cReleaseModule = 0x0100;
|
|
constexpr int cBroadcast = 0x0200;
|
|
constexpr int cHelpOnly = 0x0700;
|
|
constexpr int cStartHelp = 0x0710;
|
|
constexpr int cStartCredits = 0x0720;
|
|
|
|
constexpr int cNewGame = 0x0800;
|
|
constexpr int cLoadGame = 0x0810;
|
|
constexpr int cMovie = 0x0820;
|
|
constexpr int cNewGameEx = 0x0840;
|
|
constexpr int cLoadGameEx = 0x0850;
|
|
constexpr int cNewMap = 0x0880;
|
|
constexpr int cReplay = 0x08E0;
|
|
constexpr int cGetReady = 0x08F0;
|
|
constexpr int cBreakGame = 0x0900;
|
|
|
|
constexpr int cTurn = 0x2000;
|
|
constexpr int cResume = 0x2010;
|
|
constexpr int cContinue = 0x2080;
|
|
constexpr int cMovieTurn = 0x2100;
|
|
constexpr int cMovieEndTurn = 0x2110;
|
|
constexpr int cEditMap = 0x2800;
|
|
|
|
constexpr int cShowUnitChanged = 0x3030;
|
|
constexpr int cShowAfterMove = 0x3040;
|
|
constexpr int cShowAfterAttack = 0x3050;
|
|
constexpr int cShowCityChanged = 0x3090;
|
|
constexpr int cShowMoving = 0x3140;
|
|
constexpr int cShowCapturing = 0x3150;
|
|
constexpr int cShowAttacking = 0x3240;
|
|
constexpr int cShowMissionResult = 0x3300;
|
|
constexpr int cShowShipChange = 0x3400;
|
|
constexpr int cShowGreatLibTech = 0x3500;
|
|
constexpr int cShowTurnChange = 0x3700;
|
|
constexpr int cShowCancelTreaty = 0x3800;
|
|
constexpr int cShowEndContact = 0x3810;
|
|
constexpr int cShowCancelTreatyByAlliance = 0x3820;
|
|
constexpr int cShowSupportAllianceAgainst = 0x3830;
|
|
constexpr int cShowPeaceViolation = 0x3880;
|
|
constexpr int cShowGame = 0x3F00;
|
|
constexpr int cRefreshDebugMap = 0x3F90;
|
|
|
|
constexpr int cDebugMessage = 0x7000;
|
|
constexpr int cShowNego = 0x7010;
|
|
|
|
// Commands same for server and client
|
|
constexpr int scContact = 0x4900; // + concerned player shl 4 for server call
|
|
constexpr int scReject = 0x4A00;
|
|
constexpr int scDipStart = 0x4B00;
|
|
constexpr int scDipNotice = 0x4B10;
|
|
constexpr int scDipAccept = 0x4B20;
|
|
constexpr int scDipCancelTreaty = 0x4B30;
|
|
constexpr int scDipOffer = 0x4B4E;
|
|
constexpr int scDipBreak = 0x4BF0;
|
|
|
|
// Server return codes: flags
|
|
constexpr int rExecuted = 0x40000000;
|
|
constexpr int rEffective = 0x20000000;
|
|
constexpr int rUnitRemoved = 0x10000000;
|
|
constexpr int rEnemySpotted = 0x08000000;
|
|
|
|
// Server return codes: command executed
|
|
// Note: the same return code might have a different meaning for different server functions!
|
|
constexpr int eOK = 0x60000000;
|
|
constexpr int eEnemySpotted = 0x68000000;
|
|
constexpr int eDied = 0x70000000;
|
|
constexpr int eEnemySpotted_Died = 0x78000000;
|
|
constexpr int eLoaded = 0x60000002;
|
|
constexpr int eLost = 0x70000004;
|
|
constexpr int eWon = 0x60000005;
|
|
constexpr int eBloody = 0x70000005;
|
|
constexpr int eBombarded = 0x60000006;
|
|
constexpr int eExpelled = 0x60000007;
|
|
constexpr int eMissionDone = 0x70000008;
|
|
constexpr int eJobDone = 0x60000001;
|
|
constexpr int eJobDone_Died = 0x70000001;
|
|
constexpr int eCity = 0x70000002;
|
|
constexpr int eRemoved = 0x70000000;
|
|
constexpr int eUtilized = 0x70000001;
|
|
constexpr int eNotChanged = 0x40000000;
|
|
|
|
// Server return codes: command not executed
|
|
constexpr int eHiddenUnit = 0x20000013;
|
|
constexpr int eStealthUnit = 0x2000001A;
|
|
constexpr int eZOC_EnemySpotted = 0x28000014;
|
|
|
|
constexpr int eInvalid = 0x0000;
|
|
constexpr int eUnknown = 0x0001;
|
|
constexpr int eNoTurn = 0x0002;
|
|
constexpr int eViolation = 0x0003;
|
|
constexpr int eNoPreq = 0x0004;
|
|
|
|
constexpr int eNoTime_Move = 0x0008;
|
|
constexpr int eNoTime_Load = 0x0009;
|
|
constexpr int eNoTime_Attack = 0x000A;
|
|
constexpr int eNoTime_Bombard = 0x000B;
|
|
constexpr int eNoTime_Expel = 0x000C;
|
|
|
|
constexpr int eDomainMismatch = 0x0011;
|
|
constexpr int eNoCapturer = 0x0012;
|
|
constexpr int eZOC = 0x0014;
|
|
constexpr int eTreaty = 0x0015;
|
|
constexpr int eDeadLands = 0x0016;
|
|
constexpr int eNoRoad = 0x0017;
|
|
constexpr int eNoNav = 0x0019;
|
|
constexpr int eNoLoadCapacity = 0x001B;
|
|
constexpr int eNoBombarder = 0x001C;
|
|
|
|
constexpr int eMaxSize = 0x0020;
|
|
constexpr int eNoCityTerrain = 0x0022;
|
|
constexpr int eNoBridgeBuilding = 0x0023;
|
|
constexpr int eInvalidOffer = 0x0030;
|
|
constexpr int eOfferNotAcceptable = 0x0031;
|
|
constexpr int eCancelTreatyRush = 0x0032;
|
|
constexpr int eAnarchy = 0x0038;
|
|
constexpr int eColdWar = 0x003F;
|
|
constexpr int eNoModel = 0x0040;
|
|
constexpr int eTileNotAvailable = 0x0050;
|
|
constexpr int eNoWorkerAvailable = 0x0051;
|
|
constexpr int eOnlyOnce = 0x0058;
|
|
constexpr int eObsolete = 0x0059;
|
|
constexpr int eOutOfControl = 0x005A;
|
|
|
|
constexpr int eNoWay = 0x0100;
|
|
|
|
// Additional return codes
|
|
constexpr int rLocationReached = 0x00010000; // Unit_Move: move not interrupted, location reached
|
|
constexpr int rMoreTurns = 0x00020000; // Unit_Move: move not interrupted, location not reached yet
|
|
|
|
// Chart types
|
|
constexpr int nStat = 6;
|
|
constexpr int stPop = 0;
|
|
constexpr int stTerritory = 1;
|
|
constexpr int stMil = 2;
|
|
constexpr int stScience = 3;
|
|
constexpr int stExplore = 4;
|
|
constexpr int stWork = 5;
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Tile flags: terrain type
|
|
|
|
constexpr int fTerrain = 0x1F; // mask for terrain type
|
|
constexpr int fOcean = 0x00;
|
|
constexpr int fShore = 0x01;
|
|
constexpr int fGrass = 0x02;
|
|
constexpr int fDesert = 0x03;
|
|
constexpr int fPrairie = 0x04;
|
|
constexpr int fTundra = 0x05;
|
|
constexpr int fArctic = 0x06;
|
|
constexpr int fSwamp = 0x07;
|
|
constexpr int fForest = 0x09;
|
|
constexpr int fHills = 0x0A;
|
|
constexpr int fMountains = 0x0B;
|
|
constexpr int fUNKNOWN = fTerrain;
|
|
|
|
// Tile flags: terrain improvements
|
|
constexpr int fTerImp = 0x0000F000; // mask for terrain improvement
|
|
constexpr int tiNone = 0x00000000;
|
|
constexpr int tiIrrigation = 0x00001000;
|
|
constexpr int tiFarm = 0x00002000;
|
|
constexpr int tiMine = 0x00003000;
|
|
constexpr int tiFort = 0x00004000;
|
|
constexpr int tiBase = 0x00005000;
|
|
|
|
// Tile flags: add ons
|
|
constexpr int fSpecial = 0x00000060;
|
|
constexpr int fSpecial1 = 0x00000020;
|
|
constexpr int fSpecial2 = 0x00000040;
|
|
constexpr int fRiver = 0x00000080;
|
|
constexpr int fRoad = 0x00000100;
|
|
constexpr int fRR = 0x00000200; // railroad
|
|
constexpr int fCanal = 0x00000400;
|
|
constexpr int fPoll = 0x00000800;
|
|
constexpr int fPrefStartPos = 0x00200000;
|
|
constexpr int fStartPos = 0x00400000; // map editor only
|
|
constexpr int fDeadLands = 0x01000000;
|
|
constexpr int fModern = 0x06000000;
|
|
constexpr int fCobalt = 0x02000000;
|
|
constexpr int fUranium = 0x04000000;
|
|
constexpr int fMercury = 0x06000000;
|
|
|
|
// Tile flags: redundant helper info
|
|
constexpr int fGrWall = 0x00010000; // tile protected by great wall
|
|
constexpr int fSpiedOut = 0x00020000;
|
|
constexpr int fStealthUnit = 0x00040000;
|
|
constexpr int fHiddenUnit = 0x00080000;
|
|
constexpr int fObserved = 0x00100000; // set if tile information is from this turn
|
|
constexpr int fOwned = 0x00200000; // set if unit/city here is own one
|
|
constexpr int fUnit = 0x00400000;
|
|
constexpr int fCity = 0x00800000;
|
|
constexpr int fOwnZoCUnit = 0x10000000; // own ZoC unit present at this tile
|
|
constexpr int fInEnemyZoC = 0x20000000; // adjacent to known foreign ZoC unit (not allied)
|
|
constexpr int fPeace = 0x40000000; // belongs to territory of nation at peace with but not allied
|
|
|
|
// City project flags
|
|
constexpr int cpIndex = 0x1FF;
|
|
constexpr int cpConscripts = 0x200;
|
|
constexpr int cpDisbandCity = 0x400;
|
|
constexpr int cpImp = 0x800; // 0: index refers to model, 1: index refers to city improvement
|
|
constexpr int cpRepeat = 0x1000;
|
|
constexpr int cpCompleted = 0x2000;
|
|
constexpr int cpAuto = 0xF000; // for internal use only
|
|
|
|
// Tech status indicators
|
|
constexpr int tsNA = -2;
|
|
constexpr int tsSeen = -1;
|
|
constexpr int tsResearched = 0;
|
|
constexpr int tsGrLibrary = 1;
|
|
constexpr int tsCheat = 15;
|
|
constexpr int tsApplicable = tsResearched;
|
|
|
|
// Nation treaties
|
|
constexpr int trNoContact = -1;
|
|
constexpr int trNone = 0;
|
|
constexpr int trPeace = 2;
|
|
constexpr int trFriendlyContact = 3;
|
|
constexpr int trAlliance = 4;
|
|
|
|
// Attitudes
|
|
constexpr int nAttitude = 7;
|
|
constexpr int atHostile = 0;
|
|
constexpr int atIcy = 1;
|
|
constexpr int atUncoop = 2;
|
|
constexpr int atNeutral = 3;
|
|
constexpr int atReceptive = 4;
|
|
constexpr int atCordial = 5;
|
|
constexpr int atEnth = 6;
|
|
|
|
// Offer prices
|
|
constexpr int opChoose = 0x00000000;
|
|
constexpr int opCivilReport = 0x11000000; // + turn + concerned player shl 16
|
|
constexpr int opMilReport = 0x12000000; // + turn + concerned player shl 16
|
|
constexpr int opMap = 0x1F000000;
|
|
constexpr int opTreaty = 0x20000000; // + suggested nation treaty
|
|
constexpr int opShipParts = 0x30000000; // + number + part type shl 16
|
|
constexpr int opMoney = 0x40000000; // + value
|
|
constexpr int opTribute = 0x48000000; // obsolete
|
|
constexpr int opTech = 0x50000000; // + advance
|
|
constexpr int opAllTech = 0x51000000;
|
|
constexpr int opModel = 0x58000000; // + model index
|
|
constexpr int opAllModel = 0x59000000;
|
|
constexpr int opMask = 0xFF000000;
|
|
|
|
// Improvement kinds
|
|
constexpr int ikTrGoods = 0;
|
|
constexpr int ikCommon = 1;
|
|
constexpr int ikNatLocal = 2;
|
|
constexpr int ikNatGlobal = 3;
|
|
constexpr int ikWonder = 4;
|
|
constexpr int ikShipPart = 5;
|
|
constexpr int ikNA = 0x7F;
|
|
|
|
// Model domains
|
|
constexpr int nDomains = 3;
|
|
constexpr int dGround = 0;
|
|
constexpr int dSea = 1;
|
|
constexpr int dAir = 2;
|
|
|
|
// Model kinds
|
|
constexpr int mkSelfDeveloped = 0x00;
|
|
constexpr int mkEnemyDeveloped = 0x01;
|
|
constexpr int mkSpecial_Boat = 0x08;
|
|
constexpr int mkSpecial_SubCabin = 0x0A;
|
|
constexpr int mkSpecial_TownGuard = 0x10;
|
|
constexpr int mkSpecial_Glider = 0x11;
|
|
constexpr int mkScout = 0x20;
|
|
constexpr int mkSlaves = 0x21;
|
|
constexpr int mkSettler = 0x22;
|
|
constexpr int mkCommando = 0x23;
|
|
constexpr int mkFreight = 0x24;
|
|
|
|
// Unit flags
|
|
constexpr int unFortified = 0x01;
|
|
constexpr int unBombsLoaded = 0x02;
|
|
constexpr int unMountainDelay = 0x04;
|
|
constexpr int unConscripts = 0x08;
|
|
constexpr int unWithdrawn = 0x10;
|
|
constexpr int unMulti = 0x80;
|
|
|
|
// Unit report flags
|
|
constexpr int urfAlwaysSupport = 0x01;
|
|
constexpr int urfDeployed = 0x02;
|
|
|
|
// Unit moves
|
|
constexpr int umCapturing = 0x0100;
|
|
constexpr int umSpyMission = 0x0200;
|
|
constexpr int umBombarding = 0x0400;
|
|
constexpr int umExpelling = 0x0800;
|
|
constexpr int umShipLoading = 0x1000;
|
|
constexpr int umShipUnloading = 0x2000;
|
|
constexpr int umPlaneLoading = 0x4000;
|
|
constexpr int umPlaneUnloading = 0x8000;
|
|
|
|
// Model flags
|
|
constexpr int mdZOC = 0x01;
|
|
constexpr int mdCivil = 0x02;
|
|
constexpr int mdDoubleSupport = 0x04;
|
|
|
|
// Player happened flags
|
|
constexpr int phTech = 0x01;
|
|
constexpr int phStealTech = 0x02;
|
|
constexpr int phChangeGov = 0x08;
|
|
constexpr int phGliderLost = 0x100;
|
|
constexpr int phPlaneLost = 0x200;
|
|
constexpr int phPeaceViolation = 0x400;
|
|
constexpr int phPeaceEvacuation = 0x800;
|
|
constexpr int phShipComplete = 0x2000;
|
|
constexpr int phTimeUp = 0x4000;
|
|
constexpr int phExtinct = 0x8000;
|
|
constexpr int phGameEnd = 0xF000;
|
|
|
|
// City happened flags
|
|
constexpr int chDisorder = 0x01;
|
|
constexpr int chProduction = 0x02;
|
|
constexpr int chPopIncrease = 0x04;
|
|
constexpr int chPopDecrease = 0x08;
|
|
constexpr int chUnitLost = 0x10;
|
|
constexpr int chImprovementLost = 0x20;
|
|
constexpr int chProductionSabotaged = 0x40;
|
|
constexpr int chNoGrowthWarning = 0x80;
|
|
constexpr int chPollution = 0x100;
|
|
constexpr int chSiege = 0x200;
|
|
constexpr int chOldWonder = 0x400;
|
|
constexpr int chNoSettlerProd = 0x800;
|
|
constexpr int chFounded = 0x1000;
|
|
constexpr int chAfterCapture = 0x2000;
|
|
constexpr int chCaptured = 0xF0000;
|
|
constexpr unsigned chImprovementSold = 0x80000000;
|
|
|
|
// City info flags
|
|
constexpr int ciCapital = 0x01;
|
|
constexpr int ciWalled = 0x02;
|
|
constexpr int ciCoastalFort = 0x04;
|
|
constexpr int ciMissileBat = 0x08;
|
|
constexpr int ciBunker = 0x10;
|
|
constexpr int ciSpacePort = 0x20;
|
|
|
|
// City tile available values
|
|
constexpr int faAvailable = 0;
|
|
constexpr int faNotAvailable = 1;
|
|
constexpr int faSiege = 2;
|
|
constexpr int faTreaty = 4;
|
|
constexpr int faInvalid = 0xFF;
|
|
|
|
// Battle history flags
|
|
constexpr int bhEnemyAttack = 0x01;
|
|
constexpr int bhMyUnitLost = 0x02;
|
|
constexpr int bhEnemyUnitLost = 0x04;
|
|
|
|
// Move advice special destinations
|
|
constexpr int maNextCity = -1;
|
|
|
|
// Government forms
|
|
constexpr int nGov = 8;
|
|
constexpr int gAnarchy = 0;
|
|
constexpr int gDespotism = 1;
|
|
constexpr int gMonarchy = 2;
|
|
constexpr int gRepublic = 3;
|
|
constexpr int gFundamentalism = 4;
|
|
constexpr int gCommunism = 5;
|
|
constexpr int gDemocracy = 6;
|
|
constexpr int gFuture = 7;
|
|
|
|
// Ship change reasons
|
|
constexpr int scrProduction = 0;
|
|
constexpr int scrDestruction = 1;
|
|
constexpr int scrTrade = 2;
|
|
constexpr int scrCapture = 3;
|
|
|
|
// Unit jobs
|
|
constexpr int nJob = 15;
|
|
constexpr int jNone = 0;
|
|
constexpr int jRoad = 1;
|
|
constexpr int jRR = 2;
|
|
constexpr int jClear = 3;
|
|
constexpr int jIrr = 4;
|
|
constexpr int jFarm = 5;
|
|
constexpr int jAfforest = 6;
|
|
constexpr int jMine = 7;
|
|
constexpr int jCanal = 8;
|
|
constexpr int jTrans = 9;
|
|
constexpr int jFort = 10;
|
|
constexpr int jPoll = 11;
|
|
constexpr int jBase = 12;
|
|
constexpr int jPillage = 13;
|
|
constexpr int jCity = 14;
|
|
|
|
// Spy mission
|
|
constexpr int nSpyMission = 5;
|
|
constexpr int smSabotageProd = 0;
|
|
constexpr int smStealMap = 1;
|
|
constexpr int smStealForeignReports = 2;
|
|
constexpr int smStealCivilReport = 3;
|
|
constexpr int smStealMilReport = 4;
|
|
|
|
// Resource weights
|
|
constexpr unsigned rwOff = 0x00000000;
|
|
constexpr unsigned rwMaxGrowth = 0x3F514141; // 120*F + 1/8*P + 1/16*T + 1/16*S
|
|
constexpr unsigned rwMaxProd = 0x413F1F01; // 1/16*F + 120*P + 30*T + 1*S
|
|
constexpr unsigned rwMaxScience = 0x41040408; // 1/16*F + 4*P + 4*T + 8*S
|
|
constexpr unsigned rwForceProd = 0xF1080201; // F^1/2 * (8*P + 2*T + 1*S)
|
|
constexpr unsigned rwForceScience = 0xF1010101; // F^1/2 * (1*P + 1*T + 1*S)
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Advances
|
|
|
|
constexpr int adAdvancedFlight = 0;
|
|
constexpr int adAmphibiousWarfare = 1;
|
|
constexpr int adAstronomy = 2;
|
|
constexpr int adAtomicTheory = 3;
|
|
constexpr int adAutomobile = 4;
|
|
constexpr int adBallistics = 5;
|
|
constexpr int adBanking = 6;
|
|
constexpr int adBridgeBuilding = 7;
|
|
constexpr int adBronzeWorking = 8;
|
|
constexpr int adCeremonialBurial = 9;
|
|
constexpr int adChemistry = 10;
|
|
constexpr int adChivalry = 11;
|
|
constexpr int adComposites = 12;
|
|
constexpr int adCodeOfLaws = 13;
|
|
constexpr int adCombinedArms = 14;
|
|
constexpr int adCombustionEngine = 15;
|
|
constexpr int adCommunism = 16;
|
|
constexpr int adComputers = 17;
|
|
constexpr int adConscription = 18;
|
|
constexpr int adConstruction = 19;
|
|
constexpr int adTheCorporation = 20;
|
|
constexpr int adSpaceFlight = 21;
|
|
constexpr int adCurrency = 22;
|
|
constexpr int adDemocracy = 23;
|
|
constexpr int adEconomics = 24;
|
|
constexpr int adElectricity = 25;
|
|
constexpr int adElectronics = 26;
|
|
constexpr int adEngineering = 27;
|
|
constexpr int adEnvironmentalism = 28;
|
|
constexpr int adWheel = 29;
|
|
constexpr int adExplosives = 30;
|
|
constexpr int adFlight = 31;
|
|
constexpr int adIntelligence = 32;
|
|
constexpr int adGunpowder = 33;
|
|
constexpr int adHorsebackRiding = 34;
|
|
constexpr int adImpulseDrive = 35;
|
|
constexpr int adIndustrialization = 36;
|
|
constexpr int adSmartWeapons = 37;
|
|
constexpr int adInvention = 38;
|
|
constexpr int adIronWorking = 39;
|
|
constexpr int adTheLaser = 40;
|
|
constexpr int adNuclearPower = 41;
|
|
constexpr int adLiterature = 42;
|
|
constexpr int adInternet = 43;
|
|
constexpr int adMagnetism = 44;
|
|
constexpr int adMapMaking = 45;
|
|
constexpr int adMasonry = 46;
|
|
constexpr int adMassProduction = 47;
|
|
constexpr int adMathematics = 48;
|
|
constexpr int adMedicine = 49;
|
|
constexpr int adMetallurgy = 50;
|
|
constexpr int adMin = 51;
|
|
constexpr int adMobileWarfare = 52;
|
|
constexpr int adMonarchy = 53;
|
|
constexpr int adMysticism = 54;
|
|
constexpr int adNavigation = 55;
|
|
constexpr int adNuclearFission = 56;
|
|
constexpr int adPhilosophy = 57;
|
|
constexpr int adPhysics = 58;
|
|
constexpr int adPlastics = 59;
|
|
constexpr int adPoetry = 60;
|
|
constexpr int adPottery = 61;
|
|
constexpr int adRadio = 62;
|
|
constexpr int adRecycling = 63;
|
|
constexpr int adRefrigeration = 64;
|
|
constexpr int adMonotheism = 65;
|
|
constexpr int adTheRepublic = 66;
|
|
constexpr int adRobotics = 67;
|
|
constexpr int adRocketry = 68;
|
|
constexpr int adRailroad = 69;
|
|
constexpr int adSanitation = 70;
|
|
constexpr int adScience = 71;
|
|
constexpr int adWriting = 72;
|
|
constexpr int adSeafaring = 73;
|
|
constexpr int adSelfContainedEnvironment = 74;
|
|
constexpr int adStealth = 75;
|
|
constexpr int adSteamEngine = 76;
|
|
constexpr int adSteel = 77;
|
|
constexpr int adSyntheticFood = 78;
|
|
constexpr int adTactics = 79;
|
|
constexpr int adTheology = 80;
|
|
constexpr int adTheoryOfGravity = 81;
|
|
constexpr int adTrade = 82;
|
|
constexpr int adTransstellarColonization = 83;
|
|
constexpr int adUniversity = 84;
|
|
constexpr int adAdvancedRocketry = 85;
|
|
constexpr int adWarriorCode = 86;
|
|
constexpr int adAlphabet = 87;
|
|
constexpr int adPolytheism = 88;
|
|
constexpr int adRefining = 89;
|
|
constexpr int futComputingTechnology = 90;
|
|
constexpr int futNanoTechnology = 91;
|
|
constexpr int futMaterialTechnology = 92;
|
|
constexpr int futArtificialIntelligence = 93;
|
|
|
|
constexpr int adMilitary = 0x800; // Military Research
|
|
|
|
// Wonders
|
|
constexpr int woPyramids = 0;
|
|
constexpr int woZeus = 1;
|
|
constexpr int woGardens = 2;
|
|
constexpr int woColossus = 3;
|
|
constexpr int woLighthouse = 4;
|
|
constexpr int woGrLibrary = 5;
|
|
constexpr int woOracle = 6;
|
|
constexpr int woSun = 7;
|
|
constexpr int woLeo = 8;
|
|
constexpr int woMagellan = 9;
|
|
constexpr int woMich = 10;
|
|
constexpr int woNewton = 12;
|
|
constexpr int woBach = 13;
|
|
constexpr int woLiberty = 15;
|
|
constexpr int woEiffel = 16;
|
|
constexpr int woHoover = 17;
|
|
constexpr int woShinkansen = 18;
|
|
constexpr int woManhattan = 19;
|
|
constexpr int woMir = 20;
|
|
|
|
// City improvements
|
|
constexpr int imTrGoods = 28;
|
|
constexpr int imBarracks = 29;
|
|
constexpr int imGranary = 30;
|
|
constexpr int imTemple = 31;
|
|
constexpr int imMarket = 32;
|
|
constexpr int imLibrary = 33;
|
|
constexpr int imCourt = 34;
|
|
constexpr int imWalls = 35;
|
|
constexpr int imAqueduct = 36;
|
|
constexpr int imBank = 37;
|
|
constexpr int imCathedral = 38;
|
|
constexpr int imUniversity = 39;
|
|
constexpr int imHarbor = 40;
|
|
constexpr int imTheater = 41;
|
|
constexpr int imFactory = 42;
|
|
constexpr int imMfgPlant = 43;
|
|
constexpr int imRecycling = 44;
|
|
constexpr int imPower = 45;
|
|
constexpr int imHydro = 46;
|
|
constexpr int imNuclear = 47;
|
|
constexpr int imPlatform = 48;
|
|
constexpr int imTownHall = 49;
|
|
constexpr int imSewer = 50;
|
|
constexpr int imSupermarket = 51;
|
|
constexpr int imHighways = 52;
|
|
constexpr int imResLab = 53;
|
|
constexpr int imMissileBat = 54;
|
|
constexpr int imCoastalFort = 55;
|
|
constexpr int imAirport = 56;
|
|
constexpr int imDockyard = 57;
|
|
constexpr int imPalace = 58;
|
|
constexpr int imGrWall = 59;
|
|
constexpr int imColosseum = 60;
|
|
constexpr int imObservatory = 61;
|
|
constexpr int imMilAcademy = 62;
|
|
constexpr int imBunker = 63;
|
|
constexpr int imAlgae = 64;
|
|
constexpr int imStockEx = 65;
|
|
constexpr int imSpacePort = 66;
|
|
constexpr int imShipComp = 67;
|
|
constexpr int imShipPow = 68;
|
|
constexpr int imShipHab = 69;
|
|
|
|
// Special prerequisite values
|
|
constexpr int preNone = -1;
|
|
constexpr int preLighthouse = -2;
|
|
constexpr int preSun = -3;
|
|
constexpr int preLeo = -4;
|
|
constexpr int preBuilder = -5;
|
|
constexpr int preNA = -0xFF;
|
|
|
|
// Wonders CityID constants
|
|
constexpr int WonderNotBuiltYet = -1;
|
|
constexpr int WonderDestroyed = -2;
|
|
|
|
// Model features
|
|
constexpr int nFeature = 27;
|
|
constexpr int mcWeapons = 0;
|
|
constexpr int mcArmor = 1;
|
|
constexpr int mcMob = 2;
|
|
constexpr int mcSeaTrans = 3;
|
|
constexpr int mcCarrier = 4;
|
|
constexpr int mcTurbines = 5;
|
|
constexpr int mcBombs = 6;
|
|
constexpr int mcFuel = 7;
|
|
constexpr int mcAirTrans = 8;
|
|
constexpr int mcNav = 9;
|
|
constexpr int mcRadar = 10;
|
|
constexpr int mcSub = 11;
|
|
constexpr int mcArtillery = 12;
|
|
constexpr int mcAlpine = 13;
|
|
constexpr int mcSupplyShip = 14;
|
|
constexpr int mcOver = 15;
|
|
constexpr int mcAirDef = 16;
|
|
constexpr int mcSpy = 17;
|
|
constexpr int mcSE = 18;
|
|
constexpr int mcNP = 19;
|
|
constexpr int mcJet = 20;
|
|
constexpr int mcStealth = 21;
|
|
constexpr int mcFanatic = 22;
|
|
constexpr int mcFirst = 23;
|
|
constexpr int mcWill = 24;
|
|
constexpr int mcAcademy = 25;
|
|
constexpr int mcLine = 26;
|
|
constexpr int mcFirstNonCap = mcNav;
|
|
// Unit class advances, automatically applied if available.
|
|
constexpr std::uint32_t AutoFeature = (1u << mcNav) | (1u << mcSE) | (1u << mcNP) | (1u << mcJet) | (1u << mcAcademy);
|
|
|
|
struct FeatureInfo {
|
|
int Domains;
|
|
int Preq;
|
|
int Weight;
|
|
int Cost;
|
|
};
|
|
|
|
constexpr FeatureInfo Feature[nFeature] = {
|
|
{ 7, preNone, 1, 1 }, // mcOffense
|
|
{ 7, preNone, 1, 1 }, // mcDefense
|
|
{ 1, adHorsebackRiding, 1, 1 }, // mcMob
|
|
{ 2, preNone, 2, 1 }, // mcSeaTrans
|
|
{ 2, adAdvancedFlight, 2, 2 }, // mcCarrier
|
|
{ 2, adPhysics, 3, 1 }, // mcTurbines
|
|
{ 4, adAdvancedFlight, 1, 1 }, // mcBombs
|
|
{ 4, preNone, 1, 1 }, // mcFuel
|
|
{ 4, adCombinedArms, 2, 1 }, // mcAirTrans
|
|
{ 2, adNavigation, 0, 0 }, // mcNav
|
|
{ 2, adRadio, 0, 1 }, // mcRadar
|
|
{ 2, adCombustionEngine, 2, 1 }, // mcSub
|
|
{ 3, adBallistics, 1, 1 }, // mcArtillery
|
|
{ 1, adTactics, 2, 1 }, // mcAlpine
|
|
{ 2, adMedicine, 1, 1 }, // mcSupplyShip
|
|
{ 1, adBridgeBuilding, 0, 2 }, // mcOver
|
|
{ 2, adAdvancedRocketry, 1, 1 }, // mcAirDef
|
|
{ 4, adIntelligence, 2, 1 }, // mcSpy
|
|
{ 2, adSteamEngine, 0, 0 }, // mcSE
|
|
{ 2, adNuclearPower, 0, 0 }, // mcNP
|
|
{ 4, adRocketry, 0, 0 }, // mcJet
|
|
{ 4, adStealth, 1, 2 }, // mcStealth
|
|
{ 5, adCommunism, 0, 1 }, // mcFanatic
|
|
{ 1, preSun, 0, 1 }, // mcFirst
|
|
{ 1, preSun, 0, 1 }, // mcWill
|
|
{ 1, preSun, 0, 0 }, // mcAcademy
|
|
{ 7, adMassProduction, 0, 0 }, // mcLine
|
|
};
|
|
|
|
constexpr int WeightPreq7[nDomains] = { adHorsebackRiding, adSeafaring, adAdvancedFlight };
|
|
constexpr int WeightPreq10[nDomains] = { adAutomobile, adSteel, preNA };
|
|
|
|
// Upgrades for new unit models
|
|
constexpr int nUpgrade = 15;
|
|
|
|
// Colony ship
|
|
constexpr int nShipPart = 3;
|
|
constexpr int spComp = 0;
|
|
constexpr int spPow = 1;
|
|
constexpr int spHab = 2;
|
|
|
|
// Settler work required MP
|
|
constexpr int PillageWork = 100;
|
|
constexpr int CityWork = 900;
|
|
constexpr int FarmWork = 3; // *IrrClearWork
|
|
constexpr int RoadWork = 300; // *MoveCost
|
|
constexpr int RoadBridgeWork = 900;
|
|
constexpr int RRWork = 600; // *MoveCost
|
|
constexpr int RRBridgeWork = 900;
|
|
constexpr int CanalWork = 1800;
|
|
constexpr int FortWork = 600; // *MoveCost
|
|
constexpr int BaseWork = 600; // *MoveCost
|
|
constexpr int PollWork = 1800;
|
|
|
|
// For backward compatibility
|
|
constexpr int fRare = fDeadLands;
|
|
constexpr int fRare1 = fCobalt;
|
|
constexpr int fRare2 = fUranium;
|
|
constexpr int mkCaravan = mkFreight;
|
|
constexpr int mkDiplomat = mkCommando;
|
|
constexpr int gLybertarianism = gFuture;
|
|
constexpr int trCeaseFire = 1;
|
|
constexpr int adIntelligenArms = adSmartWeapons;
|
|
constexpr int adIntelligentArms = adSmartWeapons;
|
|
constexpr int adRadioCommunication = adRadio;
|
|
constexpr int adLybertarianism = adInternet;
|
|
constexpr int futResearchTechnology = futComputingTechnology;
|
|
constexpr int futProductionTechnology = futNanoTechnology;
|
|
constexpr int futArmorTechnology = futMaterialTechnology;
|
|
constexpr int futMissileTechnology = futArtificialIntelligence;
|
|
constexpr int imNatObs = imObservatory;
|
|
constexpr int imElite = imMilAcademy;
|
|
constexpr int mcOffense = mcWeapons;
|
|
constexpr int mcDefense = mcArmor;
|
|
constexpr int mcLongRange = mcArtillery;
|
|
constexpr int mcHospital = mcSupplyShip;
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Client command identifiers (TCommand). Values match the c* constants above
|
|
// one-for-one (cm* naming kept only for parity with the Pascal enum name).
|
|
|
|
enum TCommand : int {
|
|
cmInitModule = 0x0000,
|
|
cmReleaseModule = 0x0100,
|
|
cmBroadcast = 0x0200,
|
|
cmHelpOnly = 0x0700,
|
|
cmStartHelp = 0x0710,
|
|
cmStartCredits = 0x0720,
|
|
|
|
cmNewGame = 0x0800,
|
|
cmLoadGame = 0x0810,
|
|
cmMovie = 0x0820,
|
|
cmNewGameEx = 0x0840,
|
|
cmLoadGameEx = 0x0850,
|
|
cmNewMap = 0x0880,
|
|
cmReplay = 0x08E0,
|
|
cmGetReady = 0x08F0,
|
|
cmBreakGame = 0x0900,
|
|
|
|
cmTurn = 0x2000,
|
|
cmResume = 0x2010,
|
|
cmContinue = 0x2080,
|
|
cmMovieTurn = 0x2100,
|
|
cmMovieEndTurn = 0x2110,
|
|
cmEditMap = 0x2800,
|
|
|
|
cmShowUnitChanged = 0x3030,
|
|
cmShowAfterMove = 0x3040,
|
|
cmShowAfterAttack = 0x3050,
|
|
cmShowCityChanged = 0x3090,
|
|
cmShowMoving = 0x3140,
|
|
cmShowCapturing = 0x3150,
|
|
cmShowAttacking = 0x3240,
|
|
cmShowMissionResult = 0x3300,
|
|
cmShowShipChange = 0x3400,
|
|
cmShowGreatLibTech = 0x3500,
|
|
cmShowTurnChange = 0x3700,
|
|
cmShowCancelTreaty = 0x3800,
|
|
cmShowEndContact = 0x3810,
|
|
cmShowCancelTreatyByAlliance = 0x3820,
|
|
cmShowSupportAllianceAgainst = 0x3830,
|
|
cmShowPeaceViolation = 0x3880,
|
|
cmShowGame = 0x3F00,
|
|
cmRefreshDebugMap = 0x3F90,
|
|
|
|
cmDebugMessage = 0x7000,
|
|
cmShowNego = 0x7010,
|
|
};
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// ABI: function pointer types for the Client<->Server call boundary.
|
|
// TServerCall is implemented by the game server/host and called by brain
|
|
// modules; TClientCall is implemented (and exported as "client") by every
|
|
// brain module (AI plugin, terminal UI, ...) and called by the host.
|
|
|
|
extern "C" {
|
|
using TServerCall = std::int32_t(CEVO_ABI_CALL *)(std::int32_t Command, std::int32_t Player,
|
|
std::int32_t Subject, void *Data);
|
|
using TClientCall = void(CEVO_ABI_CALL *)(std::int32_t Command, std::int32_t Player, void *Data);
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Data structures exchanged across the ABI boundary.
|
|
// The six marked "packed" below mirror Pascal "packed record" (zero padding,
|
|
// overriding the {$PACKRECORDS C} default used for every other struct here).
|
|
|
|
#if defined(_MSC_VER)
|
|
#pragma pack(push, 1)
|
|
#define CEVO_PACKED
|
|
#else
|
|
#define CEVO_PACKED __attribute__((packed))
|
|
#endif
|
|
|
|
struct CEVO_PACKED TUn {
|
|
std::int32_t Loc; // location
|
|
std::int32_t Status; // free for AI use
|
|
std::int32_t SavedStatus; // for server internal use only
|
|
std::uint16_t ID; // unit number, never changes, unique within this nation
|
|
std::int16_t mix; // model index
|
|
std::int16_t Home; // home city index, -1 if none
|
|
std::int16_t Master; // index of transporting unit, -1 if none
|
|
std::int16_t Movement; // movement left for this turn
|
|
std::int8_t Health; // = 100-Damage
|
|
std::int8_t Fuel;
|
|
std::uint8_t Job; // current terrain improvement job
|
|
std::uint8_t Exp; // micro experience, the level is Exp div ExpCost
|
|
std::uint8_t TroopLoad; // number of transported ground units
|
|
std::uint8_t AirLoad; // number of transported air units
|
|
std::uint32_t Flags;
|
|
};
|
|
|
|
struct CEVO_PACKED TCity {
|
|
std::int32_t Loc;
|
|
std::int32_t Status;
|
|
std::int32_t SavedStatus;
|
|
std::uint16_t ID; // founding player shl 12 + number, unique within the whole game
|
|
std::uint16_t Size;
|
|
std::int16_t Project; // current production project, see city project flags
|
|
std::int16_t Project0; // for server use only
|
|
std::int16_t Food; // collected food in storage
|
|
std::int16_t Pollution; // collected pollution in dump
|
|
std::int16_t Prod; // for project collected production points
|
|
std::int16_t Prod0; // for project collected production points at turn begin
|
|
std::uint32_t Flags; // what happened within the last turnaround
|
|
std::uint32_t Tiles; // exploited tiles, bitset with index (dy+3) shl 2 + (dx+3) shr 1
|
|
std::uint32_t N1; // reserved for future use
|
|
std::int8_t Built[(nImp + 3) / 4 * 4]; // =1 indicates built improvement
|
|
};
|
|
|
|
struct CEVO_PACKED TModel {
|
|
std::int32_t Status;
|
|
std::int32_t SavedStatus;
|
|
std::uint16_t ID; // developing player shl 12 + number, unique within the whole game
|
|
std::uint16_t IntroTurn;
|
|
std::uint16_t Built; // units built with this model
|
|
std::uint16_t Lost; // units of this model lost in combat
|
|
std::uint8_t Kind;
|
|
std::uint8_t Domain;
|
|
std::uint16_t Attack;
|
|
std::uint16_t Defense;
|
|
std::uint16_t Speed;
|
|
std::uint16_t Cost;
|
|
std::uint16_t MStrength; // construction time multiplier (mkSelfDeveloped/mkEnemyDeveloped only)
|
|
std::uint8_t MTrans;
|
|
std::uint8_t MCost;
|
|
std::uint8_t Weight;
|
|
std::uint8_t MaxWeight;
|
|
std::uint32_t Upgrades; // bitarray indicating all upgrades
|
|
std::uint32_t Flags;
|
|
std::uint8_t Cap[(nFeature + 3) / 4 * 4]; // special features
|
|
};
|
|
|
|
struct CEVO_PACKED TUnitInfo {
|
|
std::int32_t Loc;
|
|
std::uint16_t mix; // index of unit model for its owner
|
|
std::uint16_t emix; // index in enemy model list
|
|
std::uint8_t Owner;
|
|
std::int8_t Health; // = 100-Damage
|
|
std::int8_t Fuel;
|
|
std::uint8_t Job; // current terrain improvement job
|
|
std::uint8_t Exp; // micro experience, the level is Exp div ExpCost
|
|
std::uint8_t Load; // number of transported units
|
|
std::uint16_t Flags;
|
|
};
|
|
|
|
struct CEVO_PACKED TCityInfo {
|
|
std::int32_t Loc;
|
|
std::int32_t Status;
|
|
std::int32_t SavedStatus;
|
|
std::uint16_t Owner; // last known owner, even if not alive anymore!
|
|
std::uint16_t ID; // founding player shl 12 + number, unique within the whole game
|
|
std::uint16_t Size;
|
|
std::uint16_t Flags;
|
|
};
|
|
|
|
struct CEVO_PACKED TModelInfo {
|
|
std::uint16_t Owner; // player which owns the model
|
|
std::uint16_t mix; // index of unit model for its owner
|
|
std::uint16_t ID; // developing player shl 12 + number, unique within the whole game
|
|
std::uint8_t Kind;
|
|
std::uint8_t Domain;
|
|
std::uint16_t Attack;
|
|
std::uint16_t Defense;
|
|
std::uint16_t Speed;
|
|
std::uint16_t Cost;
|
|
std::uint8_t TTrans; // ground unit transport capability
|
|
std::uint8_t ATrans_Fuel; // air unit transport capability resp. fuel
|
|
std::uint16_t Bombs; // additional attack with bombs
|
|
std::uint32_t Cap; // special features, bitset with index Feature-mcFirstNonCap
|
|
std::uint8_t MaxUpgrade; // maximum used upgrade
|
|
std::uint8_t Weight;
|
|
std::uint16_t Lost;
|
|
};
|
|
|
|
struct CEVO_PACKED TBattle {
|
|
std::uint8_t Enemy;
|
|
std::uint8_t Flags;
|
|
std::uint16_t Turn;
|
|
std::uint16_t mix;
|
|
std::uint16_t mixEnemy;
|
|
std::int32_t ToLoc;
|
|
std::int32_t FromLoc;
|
|
};
|
|
|
|
#if defined(_MSC_VER)
|
|
#pragma pack(pop)
|
|
#endif
|
|
#undef CEVO_PACKED
|
|
|
|
// ---- Unpacked structs (natural/"C mode" alignment) ----
|
|
|
|
struct TWonderInfo {
|
|
std::int32_t CityID; // -2 if destroyed, -1 if never completed, >=0 ID of city
|
|
std::int32_t EffectiveOwner; // owning player if effective, -1 if expired or not built
|
|
};
|
|
|
|
struct TShipInfo {
|
|
std::int32_t Parts[nShipPart];
|
|
};
|
|
|
|
struct TEnemyReport {
|
|
std::int32_t TurnOfContact;
|
|
std::int32_t TurnOfCivilReport;
|
|
std::int32_t TurnOfMilReport;
|
|
std::int32_t Attitude;
|
|
std::int32_t Credibility; // 0..100, last update: ToC
|
|
std::int32_t Treaty[nPl]; // diplomatic status with other nations, last update: ToCR
|
|
std::int32_t Government; // gAnarchy..gDemocracy, last update: ToCR
|
|
std::int32_t Money; // last update: ToCR
|
|
std::int32_t ResearchTech; // last update: ToCR
|
|
std::int32_t ResearchDone; // last update: ToCR
|
|
std::int8_t Tech[(nAdv + 3) / 4 * 4]; // tech status indicator, last update: ToCR
|
|
std::int32_t nModelCounted; // number of models with info in UnCount, last update: ToMR
|
|
std::uint16_t UnCount[INFIN + 1]; // number of available units for each model, last update: ToMR
|
|
};
|
|
|
|
struct TMoveAdviceData {
|
|
std::int32_t ToLoc;
|
|
std::int32_t nStep;
|
|
std::int32_t MoreTurns;
|
|
std::int32_t MaxHostile_MovementLeft;
|
|
std::int32_t dx[25];
|
|
std::int32_t dy[25];
|
|
};
|
|
|
|
struct TPlaneReturnData {
|
|
std::int32_t Loc;
|
|
std::int32_t Fuel;
|
|
std::int32_t Movement;
|
|
};
|
|
|
|
struct TTileInfo {
|
|
std::int32_t Food;
|
|
std::int32_t Prod;
|
|
std::int32_t Trade;
|
|
std::int32_t ExplCity;
|
|
};
|
|
|
|
struct TCityReport {
|
|
std::int32_t HypoTiles;
|
|
std::int32_t HypoTax;
|
|
std::int32_t HypoLux;
|
|
std::int32_t Working;
|
|
std::int32_t Happy;
|
|
std::int32_t FoodRep;
|
|
std::int32_t ProdRep;
|
|
std::int32_t Trade;
|
|
std::int32_t PollRep;
|
|
std::int32_t Corruption;
|
|
std::int32_t Tax;
|
|
std::int32_t Lux;
|
|
std::int32_t Science;
|
|
std::int32_t Support;
|
|
std::int32_t Eaten;
|
|
std::int32_t ProdCost;
|
|
std::int32_t Storage;
|
|
std::int32_t Deployed;
|
|
};
|
|
|
|
struct TCityReportNew {
|
|
std::int32_t HypoTiles;
|
|
std::int32_t HypoTaxRate;
|
|
std::int32_t HypoLuxuryRate;
|
|
std::int32_t Morale;
|
|
std::int32_t FoodSupport;
|
|
std::int32_t MaterialSupport;
|
|
std::int32_t ProjectCost;
|
|
std::int32_t Storage;
|
|
std::int32_t Deployed;
|
|
std::int32_t CollectedControl;
|
|
std::int32_t CollectedFood;
|
|
std::int32_t CollectedMaterial;
|
|
std::int32_t CollectedTrade;
|
|
std::int32_t Working;
|
|
std::int32_t FoodSurplus;
|
|
std::int32_t Production;
|
|
std::int32_t AddPollution;
|
|
std::int32_t Corruption;
|
|
std::int32_t Tax;
|
|
std::int32_t Science;
|
|
std::int32_t Luxury;
|
|
std::int32_t HappinessBalance; // <0 means disorder
|
|
};
|
|
|
|
struct TCityTileAdviceData {
|
|
std::uint32_t ResourceWeights;
|
|
std::uint32_t Tiles;
|
|
TCityReport CityReport;
|
|
};
|
|
|
|
struct TGetCityData {
|
|
std::int32_t Owner;
|
|
TCity C;
|
|
};
|
|
|
|
struct TCityAreaInfo {
|
|
std::int32_t Available[27];
|
|
};
|
|
|
|
struct TUnitReport {
|
|
std::int32_t FoodSupport;
|
|
std::int32_t ProdSupport;
|
|
std::int32_t ReportFlags;
|
|
};
|
|
|
|
struct TJobProgressEntry {
|
|
std::int32_t Required;
|
|
std::int32_t Done;
|
|
std::int32_t NextTurnPlus;
|
|
};
|
|
using TJobProgressData = TJobProgressEntry[nJob];
|
|
|
|
struct TBattleForecast {
|
|
std::int32_t pAtt;
|
|
std::int32_t mixAtt;
|
|
std::int32_t HealthAtt;
|
|
std::int32_t ExpAtt;
|
|
std::int32_t FlagsAtt;
|
|
std::int32_t Movement;
|
|
std::int32_t EndHealthDef;
|
|
std::int32_t EndHealthAtt;
|
|
};
|
|
|
|
struct TBattleForecastEx {
|
|
std::int32_t pAtt;
|
|
std::int32_t mixAtt;
|
|
std::int32_t HealthAtt;
|
|
std::int32_t ExpAtt;
|
|
std::int32_t FlagsAtt;
|
|
std::int32_t Movement;
|
|
std::int32_t EndHealthDef;
|
|
std::int32_t EndHealthAtt; // Must be same as in TBattleForecast
|
|
std::int32_t AStr;
|
|
std::int32_t DStr;
|
|
std::int32_t ABaseDamage;
|
|
std::int32_t DBaseDamage;
|
|
};
|
|
|
|
struct TShowMove {
|
|
std::int32_t Owner;
|
|
std::int32_t Health;
|
|
std::int32_t mix;
|
|
std::int32_t emix;
|
|
std::int32_t Flags;
|
|
std::int32_t FromLoc;
|
|
std::int32_t dx;
|
|
std::int32_t dy;
|
|
std::int32_t EndHealth;
|
|
std::int32_t EndHealthDef;
|
|
std::int32_t Fuel;
|
|
std::int32_t Exp;
|
|
std::int32_t Load;
|
|
};
|
|
|
|
struct TShowShipChange {
|
|
std::int32_t Reason;
|
|
std::int32_t Ship1Owner;
|
|
std::int32_t Ship2Owner;
|
|
std::int32_t Ship1Change[nShipPart];
|
|
std::int32_t Ship2Change[nShipPart];
|
|
};
|
|
|
|
struct TOffer {
|
|
std::int32_t nDeliver;
|
|
std::int32_t nCost;
|
|
std::uint32_t Price[12];
|
|
};
|
|
|
|
using TChart = std::int32_t[INFIN + 1];
|
|
|
|
struct TEditTileData {
|
|
std::int32_t Loc;
|
|
std::int32_t NewTile;
|
|
};
|
|
|
|
struct TCreateUnitData {
|
|
std::int32_t Loc;
|
|
std::int32_t P;
|
|
std::int32_t mix;
|
|
};
|
|
|
|
using TTileList = std::uint32_t[INFIN + 1];
|
|
using TTileObservedLastList = std::int16_t[INFIN + 1];
|
|
using TOwnerList = std::int8_t[INFIN + 1];
|
|
using TByteList = std::uint8_t[INFIN + 1];
|
|
using TIntList = std::int32_t[INFIN + 1];
|
|
using TCityList = TCity[INFIN + 1];
|
|
using TUnList = TUn[INFIN + 1];
|
|
using TModelList = TModel[INFIN + 1];
|
|
using TEnemyUnList = TUnitInfo[INFIN + 1];
|
|
using TEnemyCityList = TCityInfo[INFIN + 1];
|
|
using TEnemyModelList = TModelInfo[INFIN + 1];
|
|
using TBattleList = TBattle[INFIN + 1];
|
|
|
|
struct TPlayerContext {
|
|
void *Data;
|
|
TTileList *Map; // the playground, a list of tiles with index = location, see tile flags
|
|
TTileObservedLastList *MapObservedLast; // turn in which the tile was observed last
|
|
TOwnerList *Territory; // nation to which's territory a tile belongs, -1 indicates none
|
|
TUnList *Un; // units
|
|
TCityList *City; // cities
|
|
TModelList *Model; // unit models
|
|
TEnemyUnList *EnemyUn; // known units of enemy players
|
|
TEnemyCityList *EnemyCity; // known cities of enemy players
|
|
TEnemyModelList *EnemyModel; // known unit models of enemy players
|
|
TEnemyReport *EnemyReport[nPl];
|
|
|
|
std::int32_t TestFlags; // options turned on in the "Manipulation" menu
|
|
std::int32_t Turn; // current turn
|
|
std::int32_t Alive; // bitset of IDs of players still alive, flag 1 shl p for player p
|
|
std::int32_t Happened; // flags indicate what happened within the last turnaround
|
|
std::int32_t AnarchyStart; // start turn of anarchy, <0 if not in anarchy
|
|
std::int32_t Credibility; // own credibility
|
|
std::int32_t MaxCredibility; // maximum credibility still to achieve
|
|
std::int32_t nUn; // number of units
|
|
std::int32_t nCity; // number of cities
|
|
std::int32_t nModel; // number of developed unit models
|
|
std::int32_t nEnemyUn;
|
|
std::int32_t nEnemyCity;
|
|
std::int32_t nEnemyModel;
|
|
std::int32_t Government; // gAnarchy..gDemocracy
|
|
std::int32_t Money;
|
|
std::int32_t TaxRate;
|
|
std::int32_t LuxRate;
|
|
std::int32_t Research; // collected research points for currently researched tech
|
|
std::int32_t ResearchTech; // currently researched tech
|
|
TModel DevModel; // unit model currently under development
|
|
std::int8_t Tech[(nAdv + 3) / 4 * 4]; // tech status indicator
|
|
std::int32_t Attitude[nPl]; // attitude to other nations
|
|
std::int32_t Treaty[nPl]; // treaty with other nations
|
|
std::int32_t EvaStart[nPl]; // peace treaty: start of evacuation period
|
|
std::int32_t Tribute[nPl]; // no longer in use
|
|
std::int32_t TributePaid[nPl]; // no longer in use
|
|
TWonderInfo Wonder[nWonder];
|
|
TShipInfo Ship[nPl];
|
|
std::int8_t NatBuilt[(nImp + 3) / 4 * 4 - nWonder]; // index range nWonder..
|
|
std::int32_t nBattleHistory;
|
|
TBattleList *BattleHistory; // complete list of all my battles in the whole game
|
|
TByteList *BorderHelper;
|
|
std::int32_t LastCancelTreaty[nPl]; // turn of last treaty cancel
|
|
std::int32_t OracleIncome;
|
|
TIntList *DefaultDebugMap;
|
|
std::uint8_t Filler[880];
|
|
};
|
|
|
|
struct TInitModuleData {
|
|
TServerCall Server;
|
|
std::int32_t DataVersion;
|
|
std::int32_t DataSize;
|
|
std::int32_t Flags;
|
|
};
|
|
|
|
struct TNewGameData {
|
|
std::int32_t lx; // map width
|
|
std::int32_t ly; // map height
|
|
std::int32_t LandMass;
|
|
std::int32_t MaxTurn;
|
|
std::int32_t Difficulty[nPl]; // 0: this player is the supervisor, -1: unused slot
|
|
TPlayerContext *RO[nPl];
|
|
char AssemblyPath[256];
|
|
TPlayerContext *SuperVisorRO[nPl];
|
|
};
|
|
|
|
struct TNewGameExData {
|
|
std::int32_t lx;
|
|
std::int32_t ly;
|
|
std::int32_t LandMass;
|
|
std::int32_t MaxTurn;
|
|
std::int32_t RND;
|
|
std::int32_t Difficulty[nPl];
|
|
std::int32_t Controlled;
|
|
};
|
|
|
|
struct TShowNegoData {
|
|
std::int32_t pSender;
|
|
std::int32_t pTarget;
|
|
std::int32_t Action;
|
|
TOffer Offer;
|
|
};
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Gameplay rule tables (previously deferred as "pure data, no ABI-shape
|
|
// impact" - now needed by ToolAI.pas's SetAdvancedness/CityTaxBalance/
|
|
// CheckStep/CurrentMStrength). Index 0 of GovPreq/AgePreq is an unused
|
|
// filler, matching the originals' 1-based array[1..N] declarations.
|
|
|
|
constexpr int JobPreq[nJob] = { preNone, preNone, adRailroad, preNone, preNone, adRefrigeration, preNone,
|
|
preNone, adExplosives, adExplosives, adConstruction, preNone, adMedicine,
|
|
preNone, preNone };
|
|
|
|
// Advance prerequisites: up to 2 required (AdvPreq[ad][2]==preNone), or any 2
|
|
// of 3 if AdvPreq[ad][2]!=preNone.
|
|
constexpr int AdvPreq[nAdv][3] = {
|
|
{ adFlight, adRobotics, preNone }, // adAdvancedFlight
|
|
{ adNavigation, adTactics, preNone }, // adAmphibiousWarfare
|
|
{ adMysticism, adAlphabet, preNone }, // adAstronomy
|
|
{ adTheoryOfGravity, preNone, preNone }, // adAtomicTheory
|
|
{ adCombustionEngine, adSteel, preNone }, // adAutomobile
|
|
{ adMathematics, adMetallurgy, preNone }, // adBallistics
|
|
{ adCurrency, adEngineering, preNone }, // adBanking
|
|
{ adConstruction, adWheel, preNone }, // adBridgeBuilding
|
|
{ preNone, preNone, preNone }, // adBronzeWorking
|
|
{ preNone, preNone, preNone }, // adCeremonialBurial
|
|
{ adScience, preNone, preNone }, // adChemistry
|
|
{ adMonarchy, adWarriorCode, preNone }, // adChivalry
|
|
{ adMetallurgy, adPlastics, preNone }, // adComposites
|
|
{ adWriting, preNone, preNone }, // adCodeOfLaws
|
|
{ adAdvancedFlight, adMobileWarfare, preNone }, // adCombinedArms
|
|
{ adRefining, adExplosives, preNone }, // adCombustionEngine
|
|
{ adPhilosophy, adIndustrialization, preNone }, // adCommunism
|
|
{ adMin, preNone, preNone }, // adComputers
|
|
{ adTheRepublic, adTactics, preNone }, // adConscription
|
|
{ adMasonry, adAlphabet, preNone }, // adConstruction
|
|
{ adEconomics, adDemocracy, preNone }, // adTheCorporation
|
|
{ adAdvancedFlight, adAdvancedRocketry, preNone }, // adSpaceFlight
|
|
{ adBronzeWorking, preNone, preNone }, // adCurrency
|
|
{ adConscription, adIndustrialization, preNone }, // adDemocracy
|
|
{ adBanking, adUniversity, preNone }, // adEconomics
|
|
{ adMagnetism, preNone, preNone }, // adElectricity
|
|
{ adRadio, adAtomicTheory, preNone }, // adElectronics
|
|
{ adConstruction, adBronzeWorking, preNone }, // adEngineering
|
|
{ adIndustrialization, preNone, preNone }, // adEnvironmentalism
|
|
{ preNone, preNone, preNone }, // adWheel
|
|
{ adChemistry, adEngineering, preNone }, // adExplosives
|
|
{ adCombustionEngine, adPhysics, preNone }, // adFlight
|
|
{ adTactics, adInvention, preNone }, // adIntelligence
|
|
{ adMedicine, adIronWorking, preNone }, // adGunpowder
|
|
{ preNone, preNone, preNone }, // adHorsebackRiding
|
|
{ adSpaceFlight, adNuclearPower, preNone }, // adImpulseDrive
|
|
{ adRailroad, adBanking, preNone }, // adIndustrialization
|
|
{ adAdvancedRocketry, adTheLaser, preNone }, // adSmartWeapons
|
|
{ adWriting, adWheel, preNone }, // adInvention
|
|
{ adBronzeWorking, adInvention, preNone }, // adIronWorking
|
|
{ adMin, adPhysics, preNone }, // adTheLaser
|
|
{ adNuclearFission, preNone, preNone }, // adNuclearPower
|
|
{ adPoetry, adTrade, preNone }, // adLiterature
|
|
{ adDemocracy, adComputers, preNone }, // adInternet
|
|
{ adPhysics, adIronWorking, preNone }, // adMagnetism
|
|
{ adAlphabet, preNone, preNone }, // adMapMaking
|
|
{ preNone, preNone, preNone }, // adMasonry
|
|
{ adAutomobile, adElectronics, adTheCorporation }, // adMassProduction
|
|
{ adCurrency, adAlphabet, preNone }, // adMathematics
|
|
{ adMysticism, adPottery, preNone }, // adMedicine
|
|
{ adGunpowder, preNone, preNone }, // adMetallurgy
|
|
{ adRobotics, adPlastics, preNone }, // adMin
|
|
{ adAutomobile, adTactics, preNone }, // adMobileWarfare
|
|
{ adPolytheism, preNone, preNone }, // adMonarchy
|
|
{ adCeremonialBurial, preNone, preNone }, // adMysticism
|
|
{ adSeafaring, adAstronomy, preNone }, // adNavigation
|
|
{ adAtomicTheory, adMassProduction, preNone }, // adNuclearFission
|
|
{ adMathematics, adLiterature, preNone }, // adPhilosophy
|
|
{ adScience, preNone, preNone }, // adPhysics
|
|
{ adMassProduction, adRefining, preNone }, // adPlastics
|
|
{ adMysticism, adWarriorCode, preNone }, // adPoetry
|
|
{ preNone, preNone, preNone }, // adPottery
|
|
{ adElectricity, adEngineering, preNone }, // adRadio
|
|
{ adEnvironmentalism, adPlastics, preNone }, // adRecycling
|
|
{ adElectricity, preNone, preNone }, // adRefrigeration
|
|
{ adPolytheism, adAstronomy, preNone }, // adMonotheism
|
|
{ adLiterature, preNone, preNone }, // adTheRepublic
|
|
{ adMassProduction, adEconomics, preNone }, // adRobotics
|
|
{ adBallistics, adExplosives, preNone }, // adRocketry
|
|
{ adSteamEngine, adBridgeBuilding, preNone }, // adRailroad
|
|
{ adEnvironmentalism, adMedicine, preNone }, // adSanitation
|
|
{ adMetallurgy, adTheology, adPhilosophy }, // adScience
|
|
{ adAlphabet, preNone, preNone }, // adWriting
|
|
{ adPottery, adMapMaking, preNone }, // adSeafaring
|
|
{ adRecycling, adSyntheticFood, preNone }, // adSelfContainedEnvironment
|
|
{ adComposites, adRadio, preNone }, // adStealth
|
|
{ adScience, adEngineering, preNone }, // adSteamEngine
|
|
{ adIronWorking, adRailroad, preNone }, // adSteel
|
|
{ adChemistry, adRefrigeration, preNone }, // adSyntheticFood
|
|
{ adWarriorCode, adUniversity, preNone }, // adTactics
|
|
{ adMonotheism, adPoetry, preNone }, // adTheology
|
|
{ adAstronomy, adPhysics, preNone }, // adTheoryOfGravity
|
|
{ adCurrency, adCodeOfLaws, preNone }, // adTrade
|
|
{ adImpulseDrive, adSelfContainedEnvironment, preNone }, // adTransstellarColonization
|
|
{ adScience, preNone, preNone }, // adUniversity
|
|
{ adComputers, adRocketry, preNone }, // adAdvancedRocketry
|
|
{ preNone, preNone, preNone }, // adWarriorCode
|
|
{ preNone, preNone, preNone }, // adAlphabet
|
|
{ adCeremonialBurial, adHorsebackRiding, preNone }, // adPolytheism
|
|
{ adChemistry, preNone, preNone }, // adRefining
|
|
{ adComputers, preNone, preNone }, // futComputingTechnology
|
|
{ adRobotics, preNone, preNone }, // futNanoTechnology
|
|
{ adComposites, preNone, preNone }, // futMaterialTechnology
|
|
{ adSmartWeapons, preNone, preNone }, // futArtificialIntelligence
|
|
};
|
|
|
|
struct ImpInfo {
|
|
int Kind;
|
|
int Preq;
|
|
int Cost;
|
|
int Maint;
|
|
int Expiration;
|
|
};
|
|
|
|
constexpr ImpInfo Imp[nImp] = {
|
|
{ ikWonder, adMathematics, 400, 0, adDemocracy }, // woPyramids
|
|
{ ikWonder, adPolytheism, 200, 0, adElectronics }, // woZeus
|
|
{ ikWonder, adInvention, 200, 0, adNuclearFission }, // woGardens
|
|
{ ikWonder, adBronzeWorking, 200, 0, -1 }, // woColossus
|
|
{ ikWonder, adMapMaking, 200, 0, adSteel }, // woLighthouse
|
|
{ ikWonder, adLiterature, 400, 0, adPlastics }, // woGrLibrary
|
|
{ ikWonder, adMysticism, 200, 0, -1 }, // woOracle
|
|
{ ikWonder, adChivalry, 300, 0, adSpaceFlight }, // woSun
|
|
{ ikWonder, adPhilosophy, 500, 0, -1 }, // woLeo
|
|
{ ikWonder, adNavigation, 300, 0, -1 }, // woMagellan
|
|
{ ikWonder, adMonotheism, 400, 0, -1 }, // woMich
|
|
{ ikNA, preNA, 0, 0, 0 }, // {11}
|
|
{ ikWonder, adTheoryOfGravity, 400, 0, -1 }, // woNewton
|
|
{ ikWonder, adTheology, 400, 0, -1 }, // woBach
|
|
{ ikNA, preNA, 0, 0, 0 }, // {14}
|
|
{ ikWonder, adDemocracy, 500, 0, -1 }, // woLiberty
|
|
{ ikWonder, adSteel, 800, 0, -1 }, // woEiffel
|
|
{ ikWonder, adElectronics, 800, 0, -1 }, // woHoover
|
|
{ ikWonder, adPlastics, 500, 0, -1 }, // woShinkansen
|
|
{ ikWonder, adNuclearFission, 400, 0, -1 }, // woManhattan
|
|
{ ikWonder, adSpaceFlight, 800, 0, -1 }, // woMir
|
|
{ ikNA, preNA, 0, 0, 0 }, // {21}
|
|
{ ikNA, preNA, 0, 0, 0 }, // {22}
|
|
{ ikNA, preNA, 0, 0, 0 }, // {23}
|
|
{ ikNA, preNA, 0, 0, 0 }, // {24}
|
|
{ ikNA, preNA, 0, 0, 0 }, // {25}
|
|
{ ikNA, preNA, 0, 0, 0 }, // {26}
|
|
{ ikNA, preNA, 0, 0, 0 }, // {27}
|
|
{ ikTrGoods, preNone, 0, 0, 0 }, // imTrGoods
|
|
{ ikCommon, adWarriorCode, 40, 1, 0 }, // imBarracks
|
|
{ ikCommon, adPottery, 60, 1, 0 }, // imGranary
|
|
{ ikCommon, adCeremonialBurial, 40, 1, 0 }, // imTemple
|
|
{ ikCommon, adCurrency, 60, 1, 0 }, // imMarket
|
|
{ ikCommon, adWriting, 80, 3, 0 }, // imLibrary
|
|
{ ikCommon, adCodeOfLaws, 80, 2, 0 }, // imCourt
|
|
{ ikCommon, adMasonry, 80, 1, 0 }, // imWalls
|
|
{ ikCommon, adConstruction, 80, 1, 0 }, // imAqueduct
|
|
{ ikCommon, adBanking, 120, 2, 0 }, // imBank
|
|
{ ikCommon, adMonotheism, 100, 1, 0 }, // imCathedral
|
|
{ ikCommon, adUniversity, 160, 5, 0 }, // imUniversity
|
|
{ ikCommon, adSeafaring, 60, 1, 0 }, // imHarbor
|
|
{ ikCommon, adPoetry, 60, 2, 0 }, // imTheater
|
|
{ ikCommon, adIndustrialization, 200, 3, 0 }, // imFactory
|
|
{ ikCommon, adRobotics, 320, 5, 0 }, // imMfgPlant
|
|
{ ikCommon, adRecycling, 320, 4, 0 }, // imRecycling
|
|
{ ikCommon, adElectricity, 120, 2, 0 }, // imPower
|
|
{ ikCommon, adEnvironmentalism, 120, 1, 0 }, // imHydro
|
|
{ ikCommon, adNuclearPower, 240, 2, 0 }, // imNuclear
|
|
{ ikCommon, adRefining, 160, 2, 0 }, // imPlatform
|
|
{ ikCommon, preNone, 40, 1, 0 }, // imTownHall
|
|
{ ikCommon, adSanitation, 120, 2, 0 }, // imSewer
|
|
{ ikCommon, adRefrigeration, 80, 2, 0 }, // imSupermarket
|
|
{ ikCommon, adAutomobile, 160, 4, 0 }, // imHighways
|
|
{ ikCommon, adComputers, 240, 7, 0 }, // imResLab
|
|
{ ikCommon, adAdvancedRocketry, 100, 1, 0 }, // imMissileBat
|
|
{ ikCommon, adMetallurgy, 80, 1, 0 }, // imCoastalFort
|
|
{ ikCommon, adAdvancedFlight, 160, 1, 0 }, // imAirport
|
|
{ ikCommon, adAmphibiousWarfare, 80, 1, 0 }, // imDockyard
|
|
{ ikNatLocal, preNone, 100, 0, 0 }, // imPalace
|
|
{ ikNatLocal, adEngineering, 400, 4, 0 }, // imGrWall
|
|
{ ikNatLocal, adConstruction, 200, 4, 0 }, // imColosseum
|
|
{ ikNatLocal, adAstronomy, 300, 4, 0 }, // imObservatory
|
|
{ ikNatLocal, adTactics, 100, 4, 0 }, // imMilAcademy
|
|
{ ikNatLocal, adSteel, 200, 2, 0 }, // imBunker
|
|
{ ikNatLocal, adSyntheticFood, 120, 2, 0 }, // imAlgae
|
|
{ ikNatGlobal, adTheCorporation, 320, 4, 0 }, // imStockEx
|
|
{ ikNatLocal, adSpaceFlight, 400, 0, 0 }, // imSpacePort
|
|
{ ikShipPart, adTransstellarColonization, 240, 0, 0 }, // imShipComp
|
|
{ ikShipPart, adImpulseDrive, 600, 0, 0 }, // imShipPow
|
|
{ ikShipPart, adSelfContainedEnvironment, 800, 0, 0 }, // imShipHab
|
|
};
|
|
|
|
constexpr int nImpReplacement = 5;
|
|
struct ImpReplacementInfo {
|
|
int NewImp;
|
|
int OldImp;
|
|
};
|
|
constexpr ImpReplacementInfo ImpReplacement[nImpReplacement] = {
|
|
{ imSewer, imAqueduct }, { imCourt, imTownHall }, { imPalace, imTownHall }, { imPalace, imCourt },
|
|
{ imMilAcademy, imBarracks },
|
|
};
|
|
|
|
constexpr int ShipNeed[nShipPart] = { 6, 4, 2 };
|
|
constexpr int ShipImpIndex[nShipPart] = { imShipComp, imShipPow, imShipHab };
|
|
|
|
// index 0 unused (matches Pascal's GovPreq: array[1..nGov-1])
|
|
constexpr int GovPreq[nGov] = { preNA, preNone, adMonarchy, adTheRepublic, adTheology,
|
|
adCommunism, adDemocracy, adInternet };
|
|
|
|
// index 0 unused (matches Pascal's AgePreq: array[1..3])
|
|
constexpr int AgePreq[4] = { preNA, adScience, adMassProduction, adTransstellarColonization };
|
|
|
|
constexpr int SettlerFood[nGov] = { 1, 1, 1, 2, 1, 2, 2, 2 };
|
|
|
|
struct TerrainInfo {
|
|
int MoveCost;
|
|
int Defense;
|
|
int ClearTerrain;
|
|
int IrrEff;
|
|
int IrrClearWork;
|
|
int AfforestTerrain;
|
|
int MineEff;
|
|
int MineAfforestWork;
|
|
int TransTerrain;
|
|
int TransWork;
|
|
int FoodRes[3];
|
|
int ProdRes[3];
|
|
int TradeRes[3];
|
|
};
|
|
|
|
constexpr TerrainInfo Terrain[12] = {
|
|
{ 1, 4, -1, 0, 0, -1, 0, 0, -1, 0, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } }, // Ocean
|
|
{ 1, 4, -1, 0, 0, -1, 0, 0, -1, 0, { 1, 5, 1 }, { 0, 0, 5 }, { 3, 3, 3 } }, // Shore
|
|
{ 1, 4, -1, 1, 600, fForest, 0, 1800, fHills, 3000, { 3, 2, 2 }, { 0, 1, 0 }, { 1, 1, 1 } }, // Grass
|
|
{ 1, 4, fGrass, 0, 1800, -1, 1, 600, fPrairie, 3000, { 0, 3, 0 }, { 1, 1, 4 }, { 1, 1, 1 } }, // Desert
|
|
{ 1, 4, -1, 1, 600, fForest, 0, 2400, -1, 0, { 1, 3, 1 }, { 1, 1, 3 }, { 1, 1, 1 } }, // Prairie
|
|
{ 1, 4, -1, 1, 600, -1, 0, 0, fGrass, 3000, { 1, 1, 1 }, { 0, 0, 4 }, { 1, 6, 1 } }, // Tundra
|
|
{ 2, 4, -1, 0, 0, -1, 3, 1800, -1, 0, { 0, 3, 0 }, { 1, 1, 0 }, { 0, 4, 0 } }, // Arctic
|
|
{ 2, 6, fGrass, 0, 2400, fForest, 0, 2400, fHills, 3000, { 1, 1, 1 }, { 0, 4, 1 }, { 1, 1, 5 } }, // Swamp
|
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } }, // -
|
|
{ 2, 6, fPrairie, 0, 600, -1, 0, 0, -1, 0, { 1, 3, 1 }, { 2, 2, 2 }, { 1, 1, 4 } }, // Forest
|
|
{ 2, 8, -1, 1, 600, -1, 3, 1200, fGrass, 6000, { 1, 1, 1 }, { 0, 0, 2 }, { 0, 4, 0 } }, // Hills
|
|
{ 3, 12, -1, 0, 0, -1, 2, 1200, -1, 0, { 0, 0, 0 }, { 1, 4, 1 }, { 0, 0, 7 } }, // Mountains
|
|
};
|
|
|
|
struct UpgradeInfo {
|
|
int Preq;
|
|
int Strength;
|
|
int Trans;
|
|
int Cost;
|
|
};
|
|
|
|
constexpr UpgradeInfo Upgrade[nDomains][nUpgrade] = {
|
|
{
|
|
{ adWarriorCode, 4, 0, 3 },
|
|
{ adBronzeWorking, 2, 0, 4 },
|
|
{ adIronWorking, 2, 0, 5 },
|
|
{ adChivalry, 2, 0, 5 },
|
|
{ adMonotheism, 3, 0, 7 },
|
|
{ adGunpowder, 3, 0, 8 },
|
|
{ adExplosives, 4, 0, 9 },
|
|
{ adTactics, 5, 0, 10 },
|
|
{ adRadio, 6, 0, 11 },
|
|
{ adDemocracy, 6, 0, 5 },
|
|
{ adMobileWarfare, 7, 0, 12 },
|
|
{ adRobotics, 8, 0, 15 },
|
|
{ adComposites, 8, 0, 15 },
|
|
{ adTheLaser, 8, 0, 14 },
|
|
{ futMaterialTechnology, 10, 0, 2 },
|
|
},
|
|
{
|
|
{ adMapMaking, 4, 1, 8 },
|
|
{ adNavigation, 4, 0, 10 },
|
|
{ adEngineering, 0, 1, 8 },
|
|
{ adGunpowder, 8, 0, 12 },
|
|
{ adMagnetism, 12, 1, 20 },
|
|
{ adExplosives, 16, 0, 24 },
|
|
{ adSteamEngine, 24, 0, 28 },
|
|
{ adAmphibiousWarfare, 24, 1, 18 },
|
|
{ adAdvancedRocketry, 32, 0, 38 },
|
|
{ futMaterialTechnology, 14, 0, 4 },
|
|
{ futArtificialIntelligence, 14, 0, 4 },
|
|
{ preNA, 0, 0, 0 },
|
|
{ preNA, 0, 0, 0 },
|
|
{ preNA, 0, 0, 0 },
|
|
{ preNA, 0, 0, 0 },
|
|
},
|
|
{
|
|
{ adFlight, 12, 1, 14 },
|
|
{ adTactics, 6, 0, 17 },
|
|
{ adElectronics, 6, 0, 20 },
|
|
{ adMin, 8, 0, 24 },
|
|
{ adComposites, 8, 0, 26 },
|
|
{ adSmartWeapons, 11, 0, 32 },
|
|
{ futArtificialIntelligence, 7, 0, 4 },
|
|
{ preNA, 0, 0, 0 },
|
|
{ preNA, 0, 0, 0 },
|
|
{ preNA, 0, 0, 0 },
|
|
{ preNA, 0, 0, 0 },
|
|
{ preNA, 0, 0, 0 },
|
|
{ preNA, 0, 0, 0 },
|
|
{ preNA, 0, 0, 0 },
|
|
{ preNA, 0, 0, 0 },
|
|
},
|
|
};
|
|
|
|
// Pascal's `ad in FutureTech` set membership test.
|
|
constexpr bool IsFutureTech(int advance)
|
|
{
|
|
return advance == futComputingTechnology || advance == futNanoTechnology ||
|
|
advance == futMaterialTechnology || advance == futArtificialIntelligence;
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Helper functions (Protocol.cpp)
|
|
|
|
void MakeUnitInfo(int P, const TUn &U, TUnitInfo &ui);
|
|
void MakeModelInfo(int P, int mix, const TModel &M, TModelInfo &mi);
|
|
bool IsSameModel(const TModelInfo &mi1, const TModelInfo &mi2);
|
|
int SpecialTile(int Loc, int TerrType, int lx);
|
|
int GetCommandDataSize(TCommand Command);
|
|
|
|
} // namespace Cevo
|