diff --git a/src/CivGame/CivState/Definitions/UnitEnum.cs b/src/CivGame/CivState/Definitions/UnitEnum.cs index b8cfbbf..929c50d 100644 --- a/src/CivGame/CivState/Definitions/UnitEnum.cs +++ b/src/CivGame/CivState/Definitions/UnitEnum.cs @@ -36,6 +36,7 @@ public enum UnitEnum Transport = 24, Nuclear = 25, Diplomat = 26, - Caravan = 27 + Caravan = 27, + Max } } diff --git a/src/CivGame/CivState/Player.cs b/src/CivGame/CivState/Player.cs index 9f9f5ad..19595a9 100644 --- a/src/CivGame/CivState/Player.cs +++ b/src/CivGame/CivState/Player.cs @@ -37,11 +37,11 @@ public class Player // Units public short UnitCount = 0; public short SettlerCount = 0; - public short[] ActiveUnits = new short[28]; + public short[] ActiveUnits = new short[(int)UnitEnum.Max]; public short[] UnitsDestroyed = new short[8]; public Unit[] Units = new Unit[129]; - public short[] UnitsInProduction = new short[28]; - public short[] LostUnits = new short[28]; + public short[] UnitsInProduction = new short[(int)UnitEnum.Max]; + public short[] LostUnits = new short[(int)UnitEnum.Max]; // Strategic locations public StrategicLocation[] StrategicLocations = new StrategicLocation[16]; diff --git a/src/CivGame/Game/CityWorker.cs b/src/CivGame/Game/CityWorker.cs index 3fe6933..3dc33b2 100644 --- a/src/CivGame/Game/CityWorker.cs +++ b/src/CivGame/Game/CityWorker.cs @@ -986,7 +986,7 @@ public ushort F0_1d12_0045_ProcessCityState(short cityID, short flag) } } - if (city.CurrentProductionID == 25 && this.oParent.CivState.Players[this.Var_6548_PlayerID].ActiveUnits[25] == 1) + if (city.CurrentProductionID == 25 && this.oParent.CivState.Players[this.Var_6548_PlayerID].ActiveUnits[(int)UnitEnum.Nuclear] == 1) { this.oParent.CivState.Players[this.oParent.CivState.HumanPlayerID].ContactPlayerCountdown = -1; } @@ -1362,7 +1362,7 @@ public ushort F0_1d12_0045_ProcessCityState(short cityID, short flag) 0, this.oParent.CivState.Players[this.Var_6548_PlayerID].Coins / 3); } - if (city.CurrentProductionID >= 0 && city.StatusFlag == 0x19 && this.oParent.CivState.Players[this.Var_6548_PlayerID].ActiveUnits[25] == 0 && city.ShieldsCount != 0) + if (city.CurrentProductionID >= 0 && city.StatusFlag == 0x19 && this.oParent.CivState.Players[this.Var_6548_PlayerID].ActiveUnits[(int)UnitEnum.Nuclear] == 0 && city.ShieldsCount != 0) { // Instruction address 0x1d12:0x260d, size: 5 local_cc = this.oParent.Segment_2dc4.F0_2dc4_007c_CheckValueRange( diff --git a/src/CivGame/Game/MeetWithKing.cs b/src/CivGame/Game/MeetWithKing.cs index 73c774e..9135088 100644 --- a/src/CivGame/Game/MeetWithKing.cs +++ b/src/CivGame/Game/MeetWithKing.cs @@ -233,7 +233,7 @@ public void F6_0000_0000(short playerID, int xPos, int yPos, ushort param4) if (this.oParent.CivState.Players[this.oParent.CivState.HumanPlayerID].Ranking != 7 || this.oParent.CivState.Players[this.oParent.CivState.HumanPlayerID].CityCount <= 4 || this.oParent.CivState.Players[playerID].CityCount <= 1 || - this.oParent.CivState.Players[this.oParent.CivState.HumanPlayerID].ActiveUnits[25] != 0 || + this.oParent.CivState.Players[this.oParent.CivState.HumanPlayerID].ActiveUnits[(int)UnitEnum.Nuclear] != 0 || this.oParent.CivState.TurnCount <= 200) { this.oCPU.AX.Word = 0; @@ -263,7 +263,7 @@ public void F6_0000_0000(short playerID, int xPos, int yPos, ushort param4) if (this.oCPU.Flags.LE) goto L02a0; L0267: - this.oCPU.AX.Word = (ushort)this.oParent.CivState.Players[this.oParent.CivState.HumanPlayerID].ActiveUnits[25]; + this.oCPU.AX.Word = (ushort)this.oParent.CivState.Players[this.oParent.CivState.HumanPlayerID].ActiveUnits[(int)UnitEnum.Nuclear]; this.oCPU.AX.Word = this.oCPU.OR_UInt16(this.oCPU.AX.Word, this.oCPU.AX.Word); if (this.oCPU.Flags.NE) goto L02a0; @@ -282,7 +282,7 @@ public void F6_0000_0000(short playerID, int xPos, int yPos, ushort param4) this.oCPU.IMUL_UInt16(this.oCPU.AX, this.oCPU.DX, (ushort)playerID); this.oCPU.BX.Word = this.oCPU.AX.Word; - if (this.oParent.CivState.Players[playerID].ActiveUnits[25] == 0) + if (this.oParent.CivState.Players[playerID].ActiveUnits[(int)UnitEnum.Nuclear] == 0) goto L02c1; this.oCPU.SI.Word = (ushort)playerID; @@ -299,9 +299,9 @@ public void F6_0000_0000(short playerID, int xPos, int yPos, ushort param4) this.oCPU.IMUL_UInt16(this.oCPU.AX, this.oCPU.DX, (ushort)playerID); this.oCPU.BX.Word = this.oCPU.AX.Word; - if (this.oParent.CivState.Players[playerID].ActiveUnits[25] == 0) goto L02fb; + if (this.oParent.CivState.Players[playerID].ActiveUnits[(int)UnitEnum.Nuclear] == 0) goto L02fb; - this.oCPU.AX.Word = (ushort)this.oParent.CivState.Players[this.oParent.CivState.HumanPlayerID].ActiveUnits[25]; + this.oCPU.AX.Word = (ushort)this.oParent.CivState.Players[this.oParent.CivState.HumanPlayerID].ActiveUnits[(int)UnitEnum.Nuclear]; this.oCPU.AX.Word = this.oCPU.OR_UInt16(this.oCPU.AX.Word, this.oCPU.AX.Word); if (this.oCPU.Flags.NE) goto L02fb; @@ -318,10 +318,10 @@ public void F6_0000_0000(short playerID, int xPos, int yPos, ushort param4) this.oCPU.IMUL_UInt16(this.oCPU.AX, this.oCPU.DX, (ushort)this.oParent.CivState.HumanPlayerID); this.oCPU.BX.Word = this.oCPU.AX.Word; - if (this.oParent.CivState.Players[this.oParent.CivState.HumanPlayerID].ActiveUnits[25] == 0) + if (this.oParent.CivState.Players[this.oParent.CivState.HumanPlayerID].ActiveUnits[(int)UnitEnum.Nuclear] == 0) goto L034c; - this.oCPU.AX.Word = (ushort)this.oParent.CivState.Players[playerID].ActiveUnits[25]; + this.oCPU.AX.Word = (ushort)this.oParent.CivState.Players[playerID].ActiveUnits[(int)UnitEnum.Nuclear]; this.oCPU.AX.Word = this.oCPU.OR_UInt16(this.oCPU.AX.Word, this.oCPU.AX.Word); if (this.oCPU.Flags.NE) goto L0321; @@ -332,7 +332,7 @@ public void F6_0000_0000(short playerID, int xPos, int yPos, ushort param4) this.oCPU.AX.Word = 0x38; this.oCPU.IMUL_UInt16(this.oCPU.AX, this.oCPU.DX, (ushort)this.oParent.CivState.HumanPlayerID); this.oCPU.BX.Word = this.oCPU.AX.Word; - this.oCPU.CX.Word = (ushort)this.oParent.CivState.Players[this.oParent.CivState.HumanPlayerID].ActiveUnits[25]; + this.oCPU.CX.Word = (ushort)this.oParent.CivState.Players[this.oParent.CivState.HumanPlayerID].ActiveUnits[(int)UnitEnum.Nuclear]; this.oCPU.AX.Word = this.oCPU.ReadUInt16(this.oCPU.SS.Word, (ushort)(this.oCPU.BP.Word - 0x6)); this.oCPU.CWD(this.oCPU.AX, this.oCPU.DX); this.oCPU.AX.Word = this.oCPU.SUB_UInt16(this.oCPU.AX.Word, this.oCPU.DX.Word); @@ -341,7 +341,7 @@ public void F6_0000_0000(short playerID, int xPos, int yPos, ushort param4) this.oCPU.AX.Word = 0x38; this.oCPU.IMUL_UInt16(this.oCPU.AX, this.oCPU.DX, (ushort)playerID); this.oCPU.SI.Word = this.oCPU.AX.Word; - this.oCPU.AX.Word = (ushort)this.oParent.CivState.Players[playerID].ActiveUnits[25]; + this.oCPU.AX.Word = (ushort)this.oParent.CivState.Players[playerID].ActiveUnits[(int)UnitEnum.Nuclear]; this.oCPU.IMUL_UInt16(this.oCPU.AX, this.oCPU.DX, this.oCPU.BX.Word); this.oCPU.CWD(this.oCPU.AX, this.oCPU.DX); this.oCPU.IDIV_UInt16(this.oCPU.AX, this.oCPU.DX, this.oCPU.CX.Word); @@ -427,7 +427,7 @@ public void F6_0000_0000(short playerID, int xPos, int yPos, ushort param4) this.oCPU.IMUL_UInt16(this.oCPU.AX, this.oCPU.DX, (ushort)playerID); this.oCPU.BX.Word = this.oCPU.AX.Word; - if (this.oParent.CivState.Players[playerID].ActiveUnits[25] == 0) + if (this.oParent.CivState.Players[playerID].ActiveUnits[(int)UnitEnum.Nuclear] == 0) goto L0464; this.oCPU.SI.Word = (ushort)this.oParent.CivState.HumanPlayerID; @@ -2284,7 +2284,7 @@ public void F6_0000_1874(short playerID) this.oCPU.IMUL_UInt16(this.oCPU.AX, this.oCPU.DX, (ushort)playerID); this.oCPU.BX.Word = this.oCPU.AX.Word; - if (this.oParent.CivState.Players[playerID].ActiveUnits[25] != 0) + if (this.oParent.CivState.Players[playerID].ActiveUnits[(int)UnitEnum.Nuclear] != 0) { // Instruction address 0x0000:0x1a32, size: 5 this.oParent.MSCAPI.strcat(0xba06, "Our words are backed\nwith NUCLEAR WEAPONS!\n"); diff --git a/src/CivGame/Game/Segment_1238.cs b/src/CivGame/Game/Segment_1238.cs index a8a3413..bd5de0e 100644 --- a/src/CivGame/Game/Segment_1238.cs +++ b/src/CivGame/Game/Segment_1238.cs @@ -1423,7 +1423,7 @@ public void F0_1238_0da1() this.oCPU.IMUL_UInt16(this.oCPU.AX, this.oCPU.DX, (ushort)this.oParent.CivState.HumanPlayerID); this.oCPU.BX.Word = this.oCPU.AX.Word; - if (this.oParent.CivState.Players[this.oParent.CivState.HumanPlayerID].ActiveUnits[25] != 0 || + if (this.oParent.CivState.Players[this.oParent.CivState.HumanPlayerID].ActiveUnits[(int)UnitEnum.Nuclear] != 0 || oParent.CivState.TurnCount <= 200) goto L0fe4; this.oParent.Var_8078 = 1; diff --git a/src/CivGame/Game/Segment_1ade.cs b/src/CivGame/Game/Segment_1ade.cs index ae63ca1..73b92ba 100644 --- a/src/CivGame/Game/Segment_1ade.cs +++ b/src/CivGame/Game/Segment_1ade.cs @@ -1420,7 +1420,7 @@ public ushort F0_1ade_0421(short playerID, short cityID) this.oCPU.IMUL_UInt16(this.oCPU.AX, this.oCPU.DX, (ushort)playerID); this.oCPU.BX.Word = this.oCPU.AX.Word; - if (this.oParent.CivState.Players[playerID].UnitsInProduction[27] > 0) + if (this.oParent.CivState.Players[playerID].UnitsInProduction[(int)UnitEnum.Caravan] > 0) goto L0ed5; // Instruction address 0x1ade:0x0e04, size: 5 @@ -1666,7 +1666,7 @@ public ushort F0_1ade_0421(short playerID, short cityID) this.oCPU.IMUL_UInt16(this.oCPU.AX, this.oCPU.DX, (ushort)playerID); this.oCPU.BX.Word = this.oCPU.AX.Word; - if (this.oParent.CivState.Players[playerID].ActiveUnits[0] != 0x0) + if (this.oParent.CivState.Players[playerID].ActiveUnits[(int)UnitEnum.Settlers] != 0x0) goto L0f53; this.oCPU.CMP_UInt16(this.oCPU.ReadUInt16(this.oCPU.SS.Word, (ushort)(this.oCPU.BP.Word - 0x11a)), 0x1); @@ -1686,10 +1686,10 @@ public ushort F0_1ade_0421(short playerID, short cityID) this.oCPU.IMUL_UInt16(this.oCPU.AX, this.oCPU.DX, (ushort)playerID); this.oCPU.SI.Word = this.oCPU.AX.Word; - if (this.oParent.CivState.Players[playerID].ActiveUnits[25] >= 4) + if (this.oParent.CivState.Players[playerID].ActiveUnits[(int)UnitEnum.Nuclear] >= 4) goto L0f53; - if (this.oParent.CivState.Players[playerID].UnitsInProduction[25] >= 2) + if (this.oParent.CivState.Players[playerID].UnitsInProduction[(int)UnitEnum.Nuclear] >= 2) goto L0f53; L1009: @@ -1707,7 +1707,7 @@ public ushort F0_1ade_0421(short playerID, short cityID) this.oCPU.BX.Word = this.oCPU.AX.Word; //this.oCPU.AX.Word = this.oCPU.ReadUInt16(this.oCPU.DS.Word, (ushort)(this.oCPU.BX.Word + 0xb3dc)); - this.oCPU.AX.Word = (ushort)this.oParent.CivState.Players[this.oParent.CivState.HumanPlayerID].ActiveUnits[15]; + this.oCPU.AX.Word = (ushort)this.oParent.CivState.Players[this.oParent.CivState.HumanPlayerID].ActiveUnits[(int)UnitEnum.Bomber]; this.oCPU.CWD(this.oCPU.AX, this.oCPU.DX); this.oCPU.AX.Word = this.oCPU.SUB_UInt16(this.oCPU.AX.Word, this.oCPU.DX.Word); diff --git a/src/CivGame/Game/Segment_2517.cs b/src/CivGame/Game/Segment_2517.cs index 30e84ff..69f6269 100644 --- a/src/CivGame/Game/Segment_2517.cs +++ b/src/CivGame/Game/Segment_2517.cs @@ -1138,14 +1138,14 @@ public ushort F0_2517_0b1d(short playerID1, short playerID2) goto L0b64; L0b9b: - this.oCPU.AX.Word = (ushort)this.oParent.CivState.Players[playerID2].ActiveUnits[25]; + this.oCPU.AX.Word = (ushort)this.oParent.CivState.Players[playerID2].ActiveUnits[(int)UnitEnum.Nuclear]; this.oCPU.CX.Word = this.oCPU.AX.Word; this.oCPU.AX.Word = 0x38; this.oCPU.IMUL_UInt16(this.oCPU.AX, this.oCPU.DX, (ushort)playerID1); this.oCPU.BX.Word = this.oCPU.AX.Word; - if (this.oParent.CivState.Players[playerID1].ActiveUnits[25] < (short)this.oCPU.CX.Word) + if (this.oParent.CivState.Players[playerID1].ActiveUnits[(int)UnitEnum.Nuclear] < (short)this.oCPU.CX.Word) goto L0b64; this.oCPU.WriteUInt16(this.oCPU.SS.Word, (ushort)(this.oCPU.BP.Word - 0xa), 0x0); diff --git a/src/CivGame/Game/Segment_25fb.cs b/src/CivGame/Game/Segment_25fb.cs index b562f4f..02c97dd 100644 --- a/src/CivGame/Game/Segment_25fb.cs +++ b/src/CivGame/Game/Segment_25fb.cs @@ -1841,7 +1841,7 @@ public ushort F0_25fb_0c9d(short playerID, short unitID) this.oCPU.IMUL_UInt16(this.oCPU.AX, this.oCPU.DX, this.oCPU.ReadUInt16(this.oCPU.SS.Word, (ushort)(this.oCPU.BP.Word - 0x3a))); this.oCPU.BX.Word = this.oCPU.AX.Word; - if (this.oParent.CivState.Players[this.oCPU.ReadUInt16(this.oCPU.SS.Word, (ushort)(this.oCPU.BP.Word - 0x3a))].ActiveUnits[25] != 0) + if (this.oParent.CivState.Players[this.oCPU.ReadUInt16(this.oCPU.SS.Word, (ushort)(this.oCPU.BP.Word - 0x3a))].ActiveUnits[(int)UnitEnum.Nuclear] != 0) goto L1083; this.oCPU.CMP_UInt16(this.oCPU.ReadUInt16(this.oCPU.SS.Word, (ushort)(this.oCPU.BP.Word - 0x5e)), this.oCPU.DI.Word); @@ -1881,7 +1881,7 @@ public ushort F0_25fb_0c9d(short playerID, short unitID) this.oCPU.IMUL_UInt16(this.oCPU.AX, this.oCPU.DX, (ushort)playerID); this.oCPU.BX.Word = this.oCPU.AX.Word; - if (this.oParent.CivState.Players[playerID].ActiveUnits[25] <= 1) + if (this.oParent.CivState.Players[playerID].ActiveUnits[(int)UnitEnum.Nuclear] <= 1) goto L16b3; this.oCPU.AX.Word = this.oCPU.ReadUInt16(this.oCPU.SS.Word, (ushort)(this.oCPU.BP.Word - 0x34));