Skip to content

Commit

Permalink
Fix issue #64: failed to save fortify/veteran state for FortifiedUnits
Browse files Browse the repository at this point in the history
  • Loading branch information
fire-eggs committed Jun 26, 2019
1 parent 9e6ce77 commit 9b03107
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ private static byte GetId(this City city)

private static CityData GetCityData(this City city, byte id)
{
IUnit[] units = city.Tile?.Units.Where(x => x.Home == city && x.Fortify).Take(2).ToArray();
// KBR TODO fails to take 'fortifyING' into account?
IUnit[] units = city.Tile?.Units.Where(x => x.Home == city && x.Fortify).Take(2).ToArray();

return new CityData {
Id = city.GetId(),
Expand All @@ -102,7 +103,8 @@ private static CityData GetCityData(this City city, byte id)
Food = (ushort)city.Food,
Shields = (ushort)city.Shields,
ResourceTiles = city.GetResourceTiles(),
FortifiedUnits = units?.Select(x => (byte)x.Type).ToArray()
// KBR 20190622 make sure to save fortify/veteran status as per Microprose
FortifiedUnits = units?.Select(x => (byte)((int)x.Type | 0x40 | (x.Veteran ? 0x80 : 0))).ToArray()
};
}

Expand Down

0 comments on commit 9b03107

Please sign in to comment.