📄 protocol.pas
字号:
{$INCLUDE switches}
unit Protocol;
interface
const
lxmax=100; lymax=96;
nAdv=94; {number of advances}
nImp=70; {number of improvements}
nPl=15; {max number of players, don't change!}
nExp=5; // number of experience levels
ExpCost=50; {received damage required for next experience level}
MaxFutureTech=50; // maximum number of future techs of one kind
CountryRadius=9;
MaxCitySize=20;
BasicHappy=2; {basically happy citizens}
MaxPollution=240;
NeedAqueductSize=8;
NeedSewerSize=12;
ColossusEffect=75; // percent wonder building cost
UniversityFutureBonus=30; // percent per tech
ResLabFutureBonus=60; // percent per tech
FactoryFutureBonus=10; // percent per tech
MfgPlantFutureBonus=20; // percent per tech
AnarchyTurns=3;
CaptureTurns=3;
PeaceEvaTurns=5;
ColdWarTurns=40;
DesertThurst=20; // damage for turn in desert
ArcticThurst=20; // damage for turn in arctic
FastRecovery=50;
CityRecovery=20;
NoCityRecovery=8;
MaxMoneyPrice=$FFFF;
MaxShipPartPrice=100;
//difficulty settings
MaxDiff=3; {maximum difficulty level}
StorageSize: array[1..MaxDiff] of integer=(30,40,50);
TechFormula_M: array[1..MaxDiff] of single =(2.0,2.3,2.6);
TechFormula_D: array[1..MaxDiff] of single =(102.0,80.0,64.0);
BuildCostMod: array[1..MaxDiff] of integer =(9,12,16); // in 1/12
// test flags
nTestFlags=7; // max. 11
tfAllTechs=$001; {all nations get all techs}
tfImmImprove=$002; {city projects complete each turn}
tfImmAdvance=$004; {research complete each turn}
tfImmGrow=$008; {all cities grow in each turn}
tfUncover=$010; // all players see like supervisor
tfAllContact=$020; // all nations can contact each other
tfNoRareNeed=$040; // producing colony ship requires no modern resources
tfTested=$800; // 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}
sctMask=$3800; // server command type
sExecute=$4000; {call command-sExecute to request return value without
execution}
cClientEx=$8000;
// Info Request Commands
sctInfo=$0000;
sMessage=$0000; sSetDebugMap=$0010; sGetDebugMap=$0020;
sChangeSuperView=$0030;
sGetChart=$0100; // + type shl 4
sGetTechCost=$0180;
sGetAICredits=$01D0;sGetVersion=$01E0;sGetGameChanged=$01F0;
sGetTileInfo=$0200;sGetCityTileInfo=$0210;
sGetModels=$0270;
sGetUnits=$0280;sGetDefender=$0290;sGetBattleForecast=$02A0;
sGetMoveAdvice=$02C0;
sGetCity=$0300;sGetCityReport=$0310;sGetCityAreaInfo=$0320;
sGetEnemyCityReport=$0330;sGetEnemyCityAreaInfo=$0340;
// Map Editor Commands
sEditTile=$0710;sRandomMap=$0780;sMapGeneratorRequest=$0790;
// Server Internal Commands
sctInternal=sctInfo; // sctInfo - without sExecute flag, sctInternal - with sExecute flag
sIntTellAboutNation=$4000; sIntHaveContact=$4010; sIntCancelTreaty=$4020;
sIntTellAboutModel=$4100; {+told player shl 4}
sIntDiscoverZOC=$4201; sIntExpandTerritory=$4218;
sIntPayPrices=$4402;
sIntSetDevModel=$450D;
sIntSetModelStatus=$4601;sIntSetUnitStatus=$4611;sIntSetCityStatus=$4621;
sIntSetECityStatus=$4631;
sIntDataChange=$4700;
// Client Deactivation Commands
sctEndClient=$0800;
sTurn=$4800;sBreak=$4810;sResign=$4820;sNextRound=$4830;
sSaveMap=$4880;sAbandonMap=$4890;
// diplomacy commands equal to client, see below
// General Commands
sctGeneral=$1000;
sClearTestFlag=$5000;sSetTestFlag=$5010;
sSetGovernment=$5100;sSetRates=$5110;sRevolution=$5120;
sSetResearch=$5200;sStealTech=$5210;
sSetAttitude=$5300; // + concerned player shl 4
sCancelTreaty=$5400;
// Model Related Commands
sctModel=$1800;
sCreateDevModel=$5800;
sSetDevModelCap=$5C00; {+value shl 4}
{reserves $5CXX, $5DXX, $5EXX, $5FXX}
// Unit Related Commands
sctUnit=$2000;
sRemoveUnit=$6000;sSetUnitHome=$6010;
sSetSpyMission=$6100; // + mission shl 4
sLoadUnit=$6200;sUnloadUnit=$6210;
sCreateUnit=$6301; // + player shl 4
sMoveUnit=$6400; {+dx and 7 shl 4 +dy and 7 shl 7}
{reserves $64XX, $65XX, $66XX, $67XX}
// Settlers Related Commands
sctSettlers=$2800;
sAddToCity=$6810;
sStartJob=$6C00; {+job shl 4}
{reserves $6CXX, $6DXX, $6EXX, $6FXX}
// City Related Commands
sctCity=$3000;
sSetCityProject=$7001;sBuyCityProject=$7010;sSellCityProject=$7020;
sSellCityImprovement=$7101;sRebuildCityImprovement=$7111;
sSetCityTiles=$7201;
// free command space
sctUnused=$3800;
{client commands}
cInitModule=$0000;cReleaseModule=$0100;cBroadcast=$0200;
cHelpOnly=$0700;cStartHelp=$0710;
cNewGame=$0800;cLoadGame=$0810;cNewGameEx=$0840;cLoadGameEx=$0850;
cNewMap=$0880;cReplay=$08E0;cGetReady=$08F0;cBreakGame=$0900;
cTurn=$2000;cResume=$2010;cContinue=$2080;
cEditMap=$2800;
//cShowTileM=$3000;cShowTileA=$3010;cShowFoundCity=$3020;
cShowUnitChanged=$3030; cShowAfterMove=$3040; cShowAfterAttack=$3050;
cShowCityChanged=$3090;
//cShowMove=$3100;cShowCapture=$3110;
//cShowAttackBegin=$3200;cShowAttackWon=$3210;cShowAttackLost=$3220;
cShowMoving=$3140; cShowCapturing=$3150; cShowAttacking=$3240;
cShowMissionResult=$3300;
cShowTurnChange=$3700;
cShowCancelTreaty=$3800; cShowEndContact=$3810;
cShowCancelTreatyByAlliance=$3820;
cShowGame=$3F00; cShowSuperView=$3F80;
// diplomacy commands equal to server, see below
cDebugMessage=$7000;
// commands same for server and client
scContact=$4900; // + concerned player shl 4 for server call
scReject=$4A00;
scDipStart=$4B00;
scDipNotice=$4B10;
scDipAccept=$4B20;
scDipCancelTreaty=$4B30;
scDipOffer=$4B4E;
scDipBreak=$4BF0;
{server return codes: flags}
rExecuted= $40000000;
rEffective= $20000000;
rUnitRemoved= $10000000;
rEnemySpotted= $08000000;
{server return codes: command executed}
// note: the same return code might have a different meaning for different server functions!
eOK= $60000000; // ok
eEnemySpotted= $68000000; // unit move ok, new enemy unit/city spotted
eDied= $70000000; // move executed, unit died due to hostile terrain
eEnemySpotted_Died= $78000000; // unit move ok, new enemy unit/city spotted, unit died due to hostile terrain
eLoaded= $60000002; // unit move caused loading to transport ship
eLost= $70000004; // attack executed, battle lost, unit is dead
eWon= $60000005; // attack executed, battle won, defender destroyed
eBloody= $70000005; // attack executed, defender destroyed, unit is dead
eBombarded= $60000006; // empty enemy city bombarded
eExpelled= $60000007; // friendly spy expelled
eMissionDone= $70000008; // spy moved into city: mission done, spy no longer exists
eJobDone= $60000001; // settler job started and already done
eJobDone_Died= $70000001; // settler job started and already done, unit died due to hostile terrain
eCity= $70000002; // city founded, settler no more exists
eRemoved= $70000000; // sRemoveUnit: unit removed
eUtilized= $70000001; // sRemoveUnit: unit utilized for city project
eNotChanged= $40000000; // ok, but no effect (e.g. current city project set again)
{server return codes: command not executed}
eHiddenUnit= $20000013; // unit move: not possible, destination tile occupied by hidden foreign submarine
eStealthUnit= $2000001A; // unit move: not possible, destination tile occupied by foreign stealth unit
eZOC_EnemySpotted= $28000014; // unit move: not possible, new enemy unit spotted, ZOC violation
eInvalid= $0000; // command not allowed now or parameter out of allowed range
eUnknown= $0001; // unknown command
eNoTurn= $0002; // command only allowed during player's turn
eViolation= $0003; // general violation of game rules
eNoPreq= $0004; // the prerequisites for this command are not fully met
eNoTime_Move= $0008; // normal unit move: too few movement points left
eNoTime_Load= $0009; // load unit: too few movement points left
eNoTime_Attack= $000A; // attack: no movement points left
eNoTime_Bombard= $000B; // bombard city: too few movement points left
eNoTime_Expel= $000C; // expel spy: too few movement points left
eDomainMismatch= $0011; // move/attack: action not allowed for this unit domain
eNoCapturer= $0012; // unit move: this type of unit is not allowed to capture a city
eZOC= $0014; // unit move: not possible, ZOC violation
eTreaty= $0015; // move/attack: not possible, peace treaty violation
eEerie= $0016; // unit move: not possible, eerie terrain
eNoRoad= $0017; // unit move: not possible, no road
eNoNav= $0019; // unit move: not possible, open sea without navigation
eNoLoadCapacity= $001B; // load to transport: no more transport capacity
eNoBombarder= $001C; // bombardment impossible because no attack power
eMaxSize= $0020; // add to city: bigger size not allowed due to missing aqueduct/sewer
eNoCityTerrain= $0022; // found city: not possible in this terrain
eNoBridgeBuilding= $0023;
eInvalidOffer= $0030;
eOfferNotAcceptable= $0031;
eAnarchy= $0038; // no negotiation in anarchy
eColdWar= $003F;
eNoModel= $0040; // sCreateDevModel must be called before!
eTileNotAvailable= $0050;
eNoWorkerAvailable= $0051;
eOnlyOnce= $0058; // sell/rebuild city improvement: only once per city and turn!
eObsolete= $0059; // city project: more advanced improvement already exists
eOutOfControl= $005A; // buy/sell/rebuild improvement: not in anarchy, not in captured cities
eNoWay= $0100; // sGetMoveAdvice: no way found
// chart types
nStat=6;
stPop=0; stTerritory=1; stMil=2; stScience=3; stExplore=4; stWork=5;
{tile flags: terrain type}
fTerrain=$1F; // mask for terrain type
fOcean=$00;fShore=$01;fGrass=$02;fDesert=$03;fPrairie=$04;
fTundra=$05;fArctic=$06;fSwamp=$07;fForest=$09;fHills=$0A;fMountains=$0B;
fUNKNOWN=fTerrain;
{tile flags: terrain improvements}
fTerImp=$0000F000; // mask for terrain improvement
tiNone=$00000000;tiIrrigation=$00001000;tiFarm=$00002000;tiMine=$00003000;
tiFort=$00004000;tiBase=$00005000;
{tile flags: add ons}
fSpecial=$00000060;fSpecial1=$00000020;fSpecial2=$00000040;
fRiver=$00000080;
fRoad=$00000100;fRR=$00000200;fCanal=$00000400;fPoll=$00000800;
fGrWall=$00010000; // tile protected by great wall
fSpiedOut=$00020000;fStealthUnit=$00040000;fHiddenUnit=$00080000;
fObserved=$00100000; // set if tile information is from this turn
fOwned=$00200000; // set if unit/city here is own one
fUnit=$00400000;fCity=$00800000;
fPrefStartPos=$00200000;fStartPos=$00400000; // map editor only
fRare=$01000000; // eerie terrain or modern resource
fRare1=$02000000; fRare2=$04000000;
// modern resource type: $01...=eerie $03=titanium $05=uranium $07=mercury
{tile flags: territory}
fTerritory=$78000000; // nation territory: player shl 27, 15 indicates none
// city project flags
cpIndex=$1FF;
cpConscripts=$200; // produce unit as conscripts
cpDisbandCity=$400; // allow to disband city when settlers/conscripts are produced
cpImp=$800; // 0: index refers to model, 1: index refers to city improvement
cpRepeat=$1000; cpCompleted=$2000; cpAuto=$F000; // for internal use only
// tech status indicators
tsNA=-2;tsSeen=-1;tsResearched=0;tsGrLibrary=1;tsCheat=15;
tsApplicable=tsResearched;
// nation treaties
trNoContact=-1; trNone=0; trCeaseFire=1; trPeace=2; trFriendlyContact=3;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -