Ignore:
Timestamp:
May 19, 2022, 10:39:34 PM (2 years ago)
Author:
chronos
Message:
  • Modified: Use first capital letter in identifiers.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/CityProcessing.pas

    r425 r447  
    88
    99// Reporting
    10 procedure GetCityAreaInfo(p, Loc: integer; var CityAreaInfo: TCityAreaInfo);
    11 function CanCityGrow(p, cix: integer): boolean;
    12 function GetCityReport(p, cix: integer; var CityReport: TCityReport): integer;
    13 function GetCityReportNew(p, cix: integer;
    14   var CityReportNew: TCityReportNew): integer;
     10procedure GetCityAreaInfo(P, Loc: Integer; var CityAreaInfo: TCityAreaInfo);
     11function CanCityGrow(P, cix: Integer): Boolean;
     12function GetCityReport(P, cix: Integer; var CityReport: TCityReport): Integer;
     13function GetCityReportNew(P, cix: Integer;
     14  var CityReportNew: TCityReportNew): Integer;
    1515
    1616// Internal Tile Picking
    17 function AddBestCityTile(p, cix: integer): boolean;
    18 procedure CityGrowth(p, cix: integer);
    19 procedure CityShrink(p, cix: integer);
    20 procedure Pollute(p, cix: integer);
     17function AddBestCityTile(P, cix: Integer): Boolean;
     18procedure CityGrowth(P, cix: Integer);
     19procedure CityShrink(P, cix: Integer);
     20procedure Pollute(P, cix: Integer);
    2121
    2222// Turn Processing
    23 procedure PayCityMaintenance(p, cix: integer);
    24 procedure CollectCityResources(p, cix: integer);
    25 function CityTurn(p, cix: integer): boolean;
     23procedure PayCityMaintenance(P, cix: Integer);
     24procedure CollectCityResources(P, cix: Integer);
     25function CityTurn(P, cix: Integer): Boolean;
    2626
    2727// Tile Access
    28 function SetCityTiles(p, cix, NewTiles: integer;
    29   TestOnly: boolean = false): integer;
    30 procedure GetCityTileAdvice(p, cix: integer; var Advice: TCityTileAdviceData);
     28function SetCityTiles(P, cix, NewTiles: Integer;
     29  TestOnly: Boolean = False): Integer;
     30procedure GetCityTileAdvice(P, cix: Integer; var Advice: TCityTileAdviceData);
    3131
    3232// Start/End Game
     
    6767
    6868var
    69   MaxDist: integer;
     69  MaxDist: Integer;
    7070
    7171{
     
    7373  ____________________________________________________________________
    7474}
    75 procedure GetCityAreaInfo(p, Loc: integer; var CityAreaInfo: TCityAreaInfo);
    76 var
    77   V21, Loc1, p1: integer;
     75procedure GetCityAreaInfo(P, Loc: Integer; var CityAreaInfo: TCityAreaInfo);
     76var
     77  V21, Loc1, p1: Integer;
    7878  Radius: TVicinity21Loc;
    7979begin
    80 {$IFOPT O-}assert(1 shl p and InvalidTreatyMap = 0); {$ENDIF}
     80{$IFOPT O-}Assert(1 shl P and InvalidTreatyMap = 0); {$ENDIF}
    8181  with CityAreaInfo do
    8282  begin
     
    9090      begin
    9191        p1 := RealMap[Loc1] shr 27;
    92         if (p1 < nPl) and (p1 <> p) and (RW[p].Treaty[p1] >= trPeace) then
     92        if (p1 < nPl) and (p1 <> P) and (RW[P].Treaty[p1] >= trPeace) then
    9393          Available[V21] := faTreaty
    94         else if (ZoCMap[Loc1] > 0) and (Occupant[Loc1] <> p) and
    95           (RW[p].Treaty[Occupant[Loc1]] < trAlliance) then
     94        else if (ZoCMap[Loc1] > 0) and (Occupant[Loc1] <> P) and
     95          (RW[P].Treaty[Occupant[Loc1]] < trAlliance) then
    9696          Available[V21] := faSiege
    9797        else if (UsedByCity[Loc1] <> -1) and (UsedByCity[Loc1] <> Loc) then
     
    104104end;
    105105
    106 function CanCityGrow(p, cix: integer): boolean;
    107 begin
    108   with RW[p].City[cix] do
    109     result := (Size < MaxCitySize) and
     106function CanCityGrow(P, cix: Integer): Boolean;
     107begin
     108  with RW[P].City[cix] do
     109    Result := (Size < MaxCitySize) and
    110110      ((Size < NeedAqueductSize) or (Built[imAqueduct] = 1) and
    111111      (Size < NeedSewerSize) or (Built[imSewer] = 1));
    112112end;
    113113
    114 procedure DetermineCityProdProcessing(p, cix: integer;
     114procedure DetermineCityProdProcessing(P, cix: Integer;
    115115  var ProdProcessing: TProdProcessing);
    116116begin
    117   with RW[p].City[cix], ProdProcessing do
     117  with RW[P].City[cix], ProdProcessing do
    118118  begin
    119119    ProdBonus := 0;
    120120    PollBonus := 0;
    121121    if Built[imFactory] = 1 then
    122       inc(ProdBonus);
     122      Inc(ProdBonus);
    123123    if Built[imMfgPlant] = 1 then
    124       inc(ProdBonus);
     124      Inc(ProdBonus);
    125125    if (Built[imPower] = 1) or (Built[imHydro] = 1) or (Built[imNuclear] = 1) or
    126       (GWonder[woHoover].EffectiveOwner = p) then
     126      (GWonder[woHoover].EffectiveOwner = P) then
    127127      ProdBonus := ProdBonus * 2;
    128128    if Built[imFactory] = 1 then
    129       inc(PollBonus);
     129      Inc(PollBonus);
    130130    if Built[imMfgPlant] = 1 then
    131       inc(PollBonus);
     131      Inc(PollBonus);
    132132    if (Built[imFactory] + Built[imMfgPlant] > 0) then
    133       if (Built[imHydro] > 0) or (GWonder[woHoover].EffectiveOwner = p) then
    134         dec(PollBonus)
     133      if (Built[imHydro] > 0) or (GWonder[woHoover].EffectiveOwner = P) then
     134        Dec(PollBonus)
    135135      else if (Built[imNuclear] = 0) and (Built[imPower] = 1) then
    136         inc(PollBonus);
    137     if (RW[p].Government <= gDespotism) or (Built[imRecycling] = 1) then
     136        Inc(PollBonus);
     137    if (RW[P].Government <= gDespotism) or (Built[imRecycling] = 1) then
    138138      PollBonus := -2; // no pollution
    139139    PollThreshold := Size;
    140140    FutProdBonus := 0;
    141     if RW[p].Tech[futProductionTechnology] > 0 then
     141    if RW[P].Tech[futProductionTechnology] > 0 then
    142142    begin // future tech benefits
    143143      if Built[imFactory] = 1 then
    144         inc(FutProdBonus, FactoryFutureBonus * RW[p].Tech
     144        Inc(FutProdBonus, FactoryFutureBonus * RW[P].Tech
    145145          [futProductionTechnology]);
    146146      if Built[imMfgPlant] = 1 then
    147         inc(FutProdBonus, MfgPlantFutureBonus * RW[p].Tech
     147        Inc(FutProdBonus, MfgPlantFutureBonus * RW[P].Tech
    148148          [futProductionTechnology]);
    149149    end;
     
    151151end;
    152152
    153 procedure BoostProd(BaseProd: integer; ProdProcessing: TProdProcessing;
    154   var Prod, Poll: integer);
     153procedure BoostProd(BaseProd: Integer; ProdProcessing: TProdProcessing;
     154  var Prod, Poll: Integer);
    155155begin
    156156  Poll := BaseProd * (2 + ProdProcessing.PollBonus) shr 1;
     
    158158    Poll := 0
    159159  else
    160     dec(Poll, ProdProcessing.PollThreshold);
     160    Dec(Poll, ProdProcessing.PollThreshold);
    161161  if ProdProcessing.FutProdBonus > 0 then
    162162    Prod := BaseProd * (100 + ProdProcessing.ProdBonus * 50 +
     
    166166end;
    167167
    168 procedure DetermineCityTradeProcessing(p, cix, HappinessBeforeLux: integer;
     168procedure DetermineCityTradeProcessing(P, cix, HappinessBeforeLux: Integer;
    169169  var TradeProcessing: TTradeProcessing);
    170170var
    171   i, Dist: integer;
    172 begin
    173   with RW[p].City[cix], TradeProcessing do
     171  I, Dist: Integer;
     172begin
     173  with RW[P].City[cix], TradeProcessing do
    174174  begin
    175175    TaxBonus := 0;
    176176    ScienceBonus := 0;
    177177    if Built[imMarket] = 1 then
    178       inc(TaxBonus, 2);
     178      Inc(TaxBonus, 2);
    179179    if Built[imBank] = 1 then
    180180    begin
    181       inc(TaxBonus, 3);
    182       if RW[p].NatBuilt[imStockEx] = 1 then
    183         inc(TaxBonus, 3);
     181      Inc(TaxBonus, 3);
     182      if RW[P].NatBuilt[imStockEx] = 1 then
     183        Inc(TaxBonus, 3);
    184184    end;
    185185    LuxBonus := TaxBonus;
    186186    if Built[imLibrary] = 1 then
    187       inc(ScienceBonus, 2);
     187      Inc(ScienceBonus, 2);
    188188    if Built[imUniversity] = 1 then
    189       inc(ScienceBonus, 3);
     189      Inc(ScienceBonus, 3);
    190190    if Built[imResLab] = 1 then
    191       inc(ScienceBonus, 3);
     191      Inc(ScienceBonus, 3);
    192192    ScienceDoubling := 0;
    193193    if Built[imNatObs] > 0 then
    194       inc(ScienceDoubling);
    195     if RW[p].Government = gFundamentalism then
    196       dec(ScienceDoubling)
    197     else if (GWonder[woNewton].EffectiveOwner = p) and
    198       (RW[p].Government = gMonarchy) then
    199       inc(ScienceDoubling);
    200     FlexibleLuxury := ((ServerVersion[p] >= $0100F1) and
    201       (GWonder[woLiberty].EffectiveOwner = p) or (ServerVersion[p] < $0100F1)
    202       and (GWonder[woMich].EffectiveOwner = p)) and
    203       (RW[p].Government <> gAnarchy);
     194      Inc(ScienceDoubling);
     195    if RW[P].Government = gFundamentalism then
     196      Dec(ScienceDoubling)
     197    else if (GWonder[woNewton].EffectiveOwner = P) and
     198      (RW[P].Government = gMonarchy) then
     199      Inc(ScienceDoubling);
     200    FlexibleLuxury := ((ServerVersion[P] >= $0100F1) and
     201      (GWonder[woLiberty].EffectiveOwner = P) or (ServerVersion[P] < $0100F1)
     202      and (GWonder[woMich].EffectiveOwner = P)) and
     203      (RW[P].Government <> gAnarchy);
    204204    FutResBonus := 0;
    205     if RW[p].Tech[futResearchTechnology] > 0 then
     205    if RW[P].Tech[futResearchTechnology] > 0 then
    206206    begin // future tech benefits
    207207      if Built[imUniversity] = 1 then
    208         inc(FutResBonus, UniversityFutureBonus * RW[p].Tech
     208        Inc(FutResBonus, UniversityFutureBonus * RW[P].Tech
    209209          [futResearchTechnology]);
    210210      if Built[imResLab] = 1 then
    211         inc(FutResBonus, ResLabFutureBonus * RW[p].Tech[futResearchTechnology]);
    212     end;
    213     if (RW[p].NatBuilt[imPalace] > 0) or (ServerVersion[p] < $010000) then
     211        Inc(FutResBonus, ResLabFutureBonus * RW[P].Tech[futResearchTechnology]);
     212    end;
     213    if (RW[P].NatBuilt[imPalace] > 0) or (ServerVersion[P] < $010000) then
    214214    begin // calculate corruption
    215215      Dist := MaxDist;
    216       for i := 0 to RW[p].nCity - 1 do
    217         if (RW[p].City[i].Loc >= 0) and (RW[p].City[i].Built[imPalace] = 1) then
    218           Dist := Distance(Loc, RW[p].City[i].Loc);
    219       if (Dist = 0) or (CorrLevel[RW[p].Government] = 0) then
     216      for I := 0 to RW[P].nCity - 1 do
     217        if (RW[P].City[I].Loc >= 0) and (RW[P].City[I].Built[imPalace] = 1) then
     218          Dist := Distance(Loc, RW[P].City[I].Loc);
     219      if (Dist = 0) or (CorrLevel[RW[P].Government] = 0) then
    220220        RelCorr := 0.0
    221221      else
    222222      begin
    223223        RelCorr := Dist / MaxDist;
    224         if CorrLevel[RW[p].Government] > 1 then
    225           RelCorr := Exp(ln(RelCorr) / CorrLevel[RW[p].Government]);
     224        if CorrLevel[RW[P].Government] > 1 then
     225          RelCorr := Exp(ln(RelCorr) / CorrLevel[RW[P].Government]);
    226226        if Built[imCourt] = 1 then
    227227          RelCorr := RelCorr / 2;
     
    237237end;
    238238
    239 procedure SplitTrade(Trade, TaxRate, LuxRate, Working: integer;
     239procedure SplitTrade(Trade, TaxRate, LuxRate, Working: Integer;
    240240  TradeProcessing: TTradeProcessing; var Corruption, Tax, Lux,
    241   Science: integer);
    242 var
    243   plus: integer;
     241  Science: Integer);
     242var
     243  plus: Integer;
    244244begin
    245245  Corruption := Trunc(Trade * TradeProcessing.RelCorr);
     
    276276end;
    277277
    278 function GetProjectCost(p, cix: integer): integer;
    279 var
    280   i: integer;
    281 begin
    282   with RW[p].City[cix] do
     278function GetProjectCost(P, cix: Integer): Integer;
     279var
     280  I: Integer;
     281begin
     282  with RW[P].City[cix] do
    283283  begin
    284284    if Project and cpImp = 0 then
    285285    begin
    286       result := RW[p].Model[Project and cpIndex].Cost; { unit project }
     286      Result := RW[P].Model[Project and cpIndex].Cost; { unit project }
    287287      if Project and cpConscripts <> 0 then
    288288      begin
    289         i := RW[p].Model[Project and cpIndex].MCost;
    290         result := result - 3 * i;
    291         if result <= 0 then
    292           result := i;
     289        I := RW[P].Model[Project and cpIndex].MCost;
     290        Result := Result - 3 * I;
     291        if Result <= 0 then
     292          Result := I;
    293293      end
    294       else if RW[p].Model[Project and cpIndex].Cap[mcLine] > 0 then
     294      else if RW[P].Model[Project and cpIndex].Cap[mcLine] > 0 then
    295295        if Project0 and (not cpAuto or cpRepeat) = Project and not cpAuto or cpRepeat
    296296        then
    297           result := result shr 1
     297          Result := Result shr 1
    298298        else
    299           result := result * 2;
     299          Result := Result * 2;
    300300    end
    301301    else
    302302    begin { improvement project }
    303       result := Imp[Project and cpIndex].Cost;
    304       if (Project and cpIndex < nWonder) and (GWonder[woColossus].EffectiveOwner = p)
     303      Result := Imp[Project and cpIndex].Cost;
     304      if (Project and cpIndex < nWonder) and (GWonder[woColossus].EffectiveOwner = P)
    305305      then
    306         result := result * ColossusEffect div 100;
    307     end;
    308     result := result * BuildCostMod[Difficulty[p]] div 12;
    309   end;
    310 end;
    311 
    312 function GetSmallCityReport(p, cix: integer; var CityReport: TCityReport;
    313   PCityReportEx: PCityReportEx = nil): integer;
    314 var
    315   i, uix, V21, Loc1, ForcedSupport, BaseHappiness, Control: integer;
     306        Result := Result * ColossusEffect div 100;
     307    end;
     308    Result := Result * BuildCostMod[Difficulty[P]] div 12;
     309  end;
     310end;
     311
     312function GetSmallCityReport(P, cix: Integer; var CityReport: TCityReport;
     313  PCityReportEx: PCityReportEx = nil): Integer;
     314var
     315  I, uix, V21, Loc1, ForcedSupport, BaseHappiness, Control: Integer;
    316316  ProdProcessing: TProdProcessing;
    317317  TradeProcessing: TTradeProcessing;
    318318  Radius: TVicinity21Loc;
    319319  UnitReport: TUnitReport;
    320   RareOK: array [0 .. 3] of integer;
     320  RareOK: array [0 .. 3] of Integer;
    321321  TileInfo: TTileInfo;
    322322begin
    323   with RW[p].City[cix], CityReport do
     323  with RW[P].City[cix], CityReport do
    324324  begin
    325325    if HypoTiles <= 0 then
    326326      HypoTiles := Tiles;
    327327    if HypoTax < 0 then
    328       HypoTax := RW[p].TaxRate;
     328      HypoTax := RW[P].TaxRate;
    329329    if HypoLux < 0 then
    330       HypoLux := RW[p].LuxRate;
    331 
    332     if (Flags and chCaptured <> 0) or (RW[p].Government = gAnarchy) then
     330      HypoLux := RW[P].LuxRate;
     331
     332    if (Flags and chCaptured <> 0) or (RW[P].Government = gAnarchy) then
    333333    begin
    334334      Working := 0;
    335335      for V21 := 1 to 26 do
    336336        if HypoTiles and (1 shl V21) <> 0 then
    337           inc(Working); // for backward compatibility
    338 
    339       if RW[p].Government = gFundamentalism then
     337          Inc(Working); // for backward compatibility
     338
     339      if RW[P].Government = gFundamentalism then
    340340      begin
    341341        Happy := Size;
     
    380380          BaseHappiness := Size;
    381381      end;
    382       for i := 0 to nWonder - 1 do
    383         if Built[i] = 1 then
     382      for I := 0 to nWonder - 1 do
     383        if Built[I] = 1 then
    384384        begin
    385           inc(Happy);
    386           inc(BaseHappiness, 2);
     385          Inc(Happy);
     386          Inc(BaseHappiness, 2);
    387387        end;
    388388      if Built[imTemple] = 1 then
    389389      begin
    390         inc(Happy);
    391         inc(BaseHappiness, 2);
     390        Inc(Happy);
     391        Inc(BaseHappiness, 2);
    392392      end;
    393393      if Built[imCathedral] = 1 then
    394394      begin
    395         inc(Happy, 2);
    396         inc(BaseHappiness, 4);
    397         if GWonder[woBach].EffectiveOwner = p then
     395        Inc(Happy, 2);
     396        Inc(BaseHappiness, 4);
     397        if GWonder[woBach].EffectiveOwner = P then
    398398        begin
    399           inc(Happy);
    400           inc(BaseHappiness, 2);
     399          Inc(Happy);
     400          Inc(BaseHappiness, 2);
    401401        end;
    402402      end;
    403403      if Built[imTheater] > 0 then
    404404      begin
    405         inc(Happy, 2);
    406         inc(BaseHappiness, 4);
     405        Inc(Happy, 2);
     406        Inc(BaseHappiness, 4);
    407407      end;
    408408
    409409      // calculate unit support
    410 {$IFOPT O-}assert(InvalidTreatyMap = 0); {$ENDIF}
     410{$IFOPT O-}Assert(InvalidTreatyMap = 0); {$ENDIF}
    411411      Support := 0;
    412412      ForcedSupport := 0;
    413413      Eaten := Size * 2;
    414414      Deployed := 0;
    415       for uix := 0 to RW[p].nUn - 1 do
    416         with RW[p].Un[uix] do
     415      for uix := 0 to RW[P].nUn - 1 do
     416        with RW[P].Un[uix] do
    417417          if (Loc >= 0) and (Home = cix) then
    418418          begin
    419             GetUnitReport(p, uix, UnitReport);
    420             inc(Eaten, UnitReport.FoodSupport);
     419            GetUnitReport(P, uix, UnitReport);
     420            Inc(Eaten, UnitReport.FoodSupport);
    421421            if UnitReport.ReportFlags and urfAlwaysSupport <> 0 then
    422               inc(ForcedSupport, UnitReport.ProdSupport)
     422              Inc(ForcedSupport, UnitReport.ProdSupport)
    423423            else
    424               inc(Support, UnitReport.ProdSupport);
     424              Inc(Support, UnitReport.ProdSupport);
    425425            if UnitReport.ReportFlags and urfDeployed <> 0 then
    426               inc(Deployed);
     426              Inc(Deployed);
    427427          end;
    428428      if Deployed >= Happy then
    429429        Happy := 0
    430430      else
    431         dec(Happy, Deployed);
    432       dec(Support, Size * SupportFree[RW[p].Government] shr 1);
     431        Dec(Happy, Deployed);
     432      Dec(Support, Size * SupportFree[RW[P].Government] shr 1);
    433433      if Support < 0 then
    434434        Support := 0;
    435       inc(Support, ForcedSupport);
     435      Inc(Support, ForcedSupport);
    436436
    437437      { control }
    438       case RW[p].Government of
     438      case RW[P].Government of
    439439        gDespotism:
    440           for uix := 0 to RW[p].nUn - 1 do
    441             if (RW[p].Un[uix].Loc = Loc) and
    442               (RW[p].Model[RW[p].Un[uix].mix].Kind = mkSpecial_TownGuard) then
     440          for uix := 0 to RW[P].nUn - 1 do
     441            if (RW[P].Un[uix].Loc = Loc) and
     442              (RW[P].Model[RW[P].Un[uix].mix].Kind = mkSpecial_TownGuard) then
    443443            begin
    444               inc(Happy);
    445               inc(Control, 2);
     444              Inc(Happy);
     445              Inc(Control, 2);
    446446            end;
    447447        gFundamentalism:
     
    454454
    455455      // collect processing parameters
    456       DetermineCityProdProcessing(p, cix, ProdProcessing);
    457       DetermineCityTradeProcessing(p, cix, BaseHappiness + Control - 2 *
     456      DetermineCityProdProcessing(P, cix, ProdProcessing);
     457      DetermineCityTradeProcessing(P, cix, BaseHappiness + Control - 2 *
    458458        Deployed, TradeProcessing);
    459459
     
    472472          // HypoTiles go beyond map border!
    473473          begin
    474             result := eInvalid;
    475             exit;
     474            Result := eInvalid;
     475            Exit;
    476476          end;
    477           GetTileInfo(p, cix, Loc1, TileInfo);
    478           inc(FoodRep, TileInfo.Food);
    479           inc(ProdRep, TileInfo.Prod);
    480           inc(Trade, TileInfo.Trade);
     477          GetTileInfo(P, cix, Loc1, TileInfo);
     478          Inc(FoodRep, TileInfo.Food);
     479          Inc(ProdRep, TileInfo.Prod);
     480          Inc(Trade, TileInfo.Trade);
    481481          if (RealMap[Loc1] and fModern <> 0) and
    482             (RW[p].Tech[adMassProduction] >= tsApplicable) then
    483             inc(RareOK[RealMap[Loc1] shr 25 and 3]);
    484           inc(Working);
     482            (RW[P].Tech[adMassProduction] >= tsApplicable) then
     483            Inc(RareOK[RealMap[Loc1] shr 25 and 3]);
     484          Inc(Working);
    485485        end;
    486486      if Built[imAlgae] = 1 then
    487         inc(FoodRep, 12);
     487        Inc(FoodRep, 12);
    488488
    489489      if PCityReportEx <> nil then
     
    510510    end;
    511511  end;
    512   result := eOk;
    513 end;
    514 
    515 function GetCityReport(p, cix: integer; var CityReport: TCityReport): integer;
    516 begin
    517   result := GetSmallCityReport(p, cix, CityReport);
    518   CityReport.Storage := StorageSize[Difficulty[p]];
    519   CityReport.ProdCost := GetProjectCost(p, cix);
    520 end;
    521 
    522 function GetCityReportNew(p, cix: integer;
    523   var CityReportNew: TCityReportNew): integer;
     512  Result := eOk;
     513end;
     514
     515function GetCityReport(P, cix: Integer; var CityReport: TCityReport): Integer;
     516begin
     517  Result := GetSmallCityReport(P, cix, CityReport);
     518  CityReport.Storage := StorageSize[Difficulty[P]];
     519  CityReport.ProdCost := GetProjectCost(P, cix);
     520end;
     521
     522function GetCityReportNew(P, cix: Integer;
     523  var CityReportNew: TCityReportNew): Integer;
    524524var
    525525  CityReport: TCityReport;
     
    531531    CityReport.HypoTax := HypoTaxRate;
    532532    CityReport.HypoLux := HypoLuxuryRate;
    533     result := GetSmallCityReport(p, cix, CityReport, @CityReportEx);
    534     FoodSupport := CityReport.Eaten - 2 * RW[p].City[cix].Size;
     533    Result := GetSmallCityReport(P, cix, CityReport, @CityReportEx);
     534    FoodSupport := CityReport.Eaten - 2 * RW[P].City[cix].Size;
    535535    MaterialSupport := CityReport.Support;
    536     ProjectCost := GetProjectCost(p, cix);
    537     Storage := StorageSize[Difficulty[p]];
     536    ProjectCost := GetProjectCost(P, cix);
     537    Storage := StorageSize[Difficulty[P]];
    538538    Deployed := CityReport.Deployed;
    539539    Morale := CityReportEx.BaseHappiness;
    540540    CollectedControl := CityReportEx.BaseControl +
    541       (RW[p].City[cix].Size - CityReport.Working) * 2;
     541      (RW[P].City[cix].Size - CityReport.Working) * 2;
    542542    CollectedFood := CityReport.FoodRep;
    543543    CollectedMaterial := CityReportEx.Material;
     
    551551    Luxury := CityReport.Lux;
    552552    FoodSurplus := CityReport.FoodRep - CityReport.Eaten;
    553     HappinessBalance := Morale + Luxury + CollectedControl - RW[p].City[cix]
     553    HappinessBalance := Morale + Luxury + CollectedControl - RW[P].City[cix]
    554554      .Size - 2 * Deployed;
    555555  end;
     
    560560  ____________________________________________________________________
    561561}
    562 procedure NextBest(p, cix: integer; var SelectedLoc, SelectedV21: integer);
     562procedure NextBest(P, cix: Integer; var SelectedLoc, SelectedV21: Integer);
    563563{ best tile unused but available by city cix }
    564564var
    565   Resources, Most, Loc1, p1, V21: integer;
     565  Resources, Most, Loc1, p1, V21: Integer;
    566566  TileInfo: TTileInfo;
    567567  Radius: TVicinity21Loc;
    568568begin
    569 {$IFOPT O-}assert(1 shl p and InvalidTreatyMap = 0); {$ENDIF}
     569{$IFOPT O-}Assert(1 shl P and InvalidTreatyMap = 0); {$ENDIF}
    570570  Most := 0;
    571571  SelectedLoc := -1;
    572572  SelectedV21 := -1;
    573   with RW[p].City[cix] do
     573  with RW[P].City[cix] do
    574574  begin
    575575    V21_to_Loc(Loc, Radius);
     
    580580      begin
    581581        p1 := RealMap[Loc1] shr 27;
    582         if ((p1 = nPl) or (p1 = p) or (RW[p].Treaty[p1] < trPeace)) and
    583           ((ZoCMap[Loc1] = 0) or (Occupant[Loc1] = p) or
    584           (RW[p].Treaty[Occupant[Loc1]] = trAlliance)) then
     582        if ((p1 = nPl) or (p1 = P) or (RW[P].Treaty[p1] < trPeace)) and
     583          ((ZoCMap[Loc1] = 0) or (Occupant[Loc1] = P) or
     584          (RW[P].Treaty[Occupant[Loc1]] = trAlliance)) then
    585585        begin
    586           GetTileInfo(p, cix, Loc1, TileInfo);
     586          GetTileInfo(P, cix, Loc1, TileInfo);
    587587          Resources := TileInfo.Food shl 16 + TileInfo.Prod shl 8 +
    588588            TileInfo.Trade;
     
    600600end;
    601601
    602 procedure NextWorst(p, cix: integer; var SelectedLoc, SelectedV21: integer);
     602procedure NextWorst(P, cix: Integer; var SelectedLoc, SelectedV21: Integer);
    603603{ worst tile used by city cix }
    604604var
    605   Resources, Least, Loc1, V21: integer;
     605  Resources, Least, Loc1, V21: Integer;
    606606  Radius: TVicinity21Loc;
    607607  TileInfo: TTileInfo;
     
    610610  SelectedLoc := -1;
    611611  SelectedV21 := -1;
    612   with RW[p].City[cix] do
     612  with RW[P].City[cix] do
    613613  begin
    614614    V21_to_Loc(Loc, Radius);
     
    619619        if (Loc1 >= 0) and (Loc1 < MapSize) and (1 shl V21 and Tiles <> 0) then
    620620        begin
    621           GetTileInfo(p, cix, Loc1, TileInfo);
     621          GetTileInfo(P, cix, Loc1, TileInfo);
    622622          Resources := TileInfo.Food shl 16 + TileInfo.Prod shl 8 +
    623623            TileInfo.Trade;
     
    634634end;
    635635
    636 function NextPoll(p, cix: integer): integer;
    637 var
    638   Resources, Best, dx, dy, Loc1, Dist, BestDist, V21, pTerr: integer;
     636function NextPoll(P, cix: Integer): Integer;
     637var
     638  Resources, Best, dx, dy, Loc1, Dist, BestDist, V21, pTerr: Integer;
    639639  Radius: TVicinity21Loc;
    640640  TileInfo: TTileInfo;
    641641begin
    642642  BestDist := MaxInt;
    643 {$IFOPT O-}assert(1 shl p and InvalidTreatyMap = 0); {$ENDIF}
     643{$IFOPT O-}Assert(1 shl P and InvalidTreatyMap = 0); {$ENDIF}
    644644  Best := 0;
    645   result := -1;
    646   with RW[p].City[cix] do
     645  Result := -1;
     646  with RW[P].City[cix] do
    647647  begin
    648648    V21_to_Loc(Loc, Radius);
     
    656656        begin
    657657          pTerr := RealMap[Loc1] shr 27;
    658           if (pTerr = nPl) or (pTerr = p) or (RW[p].Treaty[pTerr] < trPeace)
     658          if (pTerr = nPl) or (pTerr = P) or (RW[P].Treaty[pTerr] < trPeace)
    659659          then
    660660          begin
    661             GetTileInfo(p, cix, Loc1, TileInfo);
     661            GetTileInfo(P, cix, Loc1, TileInfo);
    662662            Resources := TileInfo.Prod shl 16 + TileInfo.Trade shl 8 +
    663663              TileInfo.Food;
     
    669669            then
    670670            begin
    671               result := Loc1;
     671              Result := Loc1;
    672672              Best := Resources;
    673673              BestDist := Dist;
     
    679679end;
    680680
    681 function AddBestCityTile(p, cix: integer): boolean;
    682 var
    683   TileLoc, V21: integer;
    684 begin
    685   NextBest(p, cix, TileLoc, V21);
    686   result := TileLoc >= 0;
    687   if result then
    688     with RW[p].City[cix] do
    689     begin
    690       assert(1 shl V21 and Tiles = 0);
     681function AddBestCityTile(P, cix: Integer): Boolean;
     682var
     683  TileLoc, V21: Integer;
     684begin
     685  NextBest(P, cix, TileLoc, V21);
     686  Result := TileLoc >= 0;
     687  if Result then
     688    with RW[P].City[cix] do
     689    begin
     690      Assert(1 shl V21 and Tiles = 0);
    691691      Tiles := Tiles or (1 shl V21);
    692692      UsedByCity[TileLoc] := Loc;
     
    694694end;
    695695
    696 procedure CityGrowth(p, cix: integer);
    697 var
    698   TileLoc, V21: integer;
     696procedure CityGrowth(P, cix: Integer);
     697var
     698  TileLoc, V21: Integer;
    699699  AltCityReport: TCityReport;
    700700begin
    701   with RW[p].City[cix] do
     701  with RW[P].City[cix] do
    702702  begin
    703     inc(Size);
    704     NextBest(p, cix, TileLoc, V21);
     703    Inc(Size);
     704    NextBest(P, cix, TileLoc, V21);
    705705    if TileLoc >= 0 then
    706706    begin { test whether exploitation of tile would lead to disorder }
     
    708708      AltCityReport.HypoTax := -1;
    709709      AltCityReport.HypoLux := -1;
    710       GetSmallCityReport(p, cix, AltCityReport);
     710      GetSmallCityReport(P, cix, AltCityReport);
    711711      if AltCityReport.Working - AltCityReport.Happy <= Size shr 1 then
    712712      // !!! change to new style disorder
    713713      begin { no disorder -- exploit tile }
    714         assert(1 shl V21 and Tiles = 0);
     714        Assert(1 shl V21 and Tiles = 0);
    715715        Tiles := Tiles or (1 shl V21);
    716716        UsedByCity[TileLoc] := Loc;
     
    720720end;
    721721
    722 procedure CityShrink(p, cix: integer);
    723 var
    724   TileLoc, V21, Working: integer;
     722procedure CityShrink(P, cix: Integer);
     723var
     724  TileLoc, V21, Working: Integer;
    725725  AltCityReport: TCityReport;
    726726begin
    727   with RW[p].City[cix] do
     727  with RW[P].City[cix] do
    728728  begin
    729729    Working := 0;
    730730    for V21 := 1 to 26 do
    731731      if Tiles and (1 shl V21) <> 0 then
    732         inc(Working);
    733     dec(Size);
    734     if Food > StorageSize[Difficulty[p]] then
    735       Food := StorageSize[Difficulty[p]];
    736     NextWorst(p, cix, TileLoc, V21);
     732        Inc(Working);
     733    Dec(Size);
     734    if Food > StorageSize[Difficulty[P]] then
     735      Food := StorageSize[Difficulty[P]];
     736    NextWorst(P, cix, TileLoc, V21);
    737737    if Working > Size then
    738738    begin { all citizens were working -- worst tile no longer exploited }
    739       assert(1 shl V21 and Tiles <> 0);
     739      Assert(1 shl V21 and Tiles <> 0);
    740740      Tiles := Tiles and not(1 shl V21);
    741741      UsedByCity[TileLoc] := -1;
     
    746746      AltCityReport.HypoTax := -1;
    747747      AltCityReport.HypoLux := -1;
    748       GetSmallCityReport(p, cix, AltCityReport);
     748      GetSmallCityReport(P, cix, AltCityReport);
    749749      if AltCityReport.Working - AltCityReport.Happy > Size shr 1 then
    750750      // !!! change to new style disorder
    751751      begin { disorder -- don't exploit tile }
    752         assert(1 shl V21 and Tiles <> 0);
     752        Assert(1 shl V21 and Tiles <> 0);
    753753        Tiles := Tiles and not(1 shl V21);
    754754        UsedByCity[TileLoc] := -1;
     
    758758end;
    759759
    760 procedure Pollute(p, cix: integer);
    761 var
    762   PollutionLoc: integer;
    763 begin
    764   with RW[p].City[cix] do
     760procedure Pollute(P, cix: Integer);
     761var
     762  PollutionLoc: Integer;
     763begin
     764  with RW[P].City[cix] do
    765765  begin
    766766    Pollution := Pollution - MaxPollution;
    767     PollutionLoc := NextPoll(p, cix);
     767    PollutionLoc := NextPoll(P, cix);
    768768    if PollutionLoc >= 0 then
    769769    begin
    770       inc(Flags, chPollution);
     770      Inc(Flags, chPollution);
    771771      RealMap[PollutionLoc] := RealMap[PollutionLoc] or fPoll;
    772772    end;
     
    778778  ____________________________________________________________________
    779779}
    780 procedure PayCityMaintenance(p, cix: integer);
    781 var
    782   i: integer;
    783 begin
    784   with RW[p], City[cix] do
    785     for i := nWonder to nImp - 1 do
    786       if (Built[i] > 0) and (Project0 and (cpImp or cpIndex) <> (cpImp or i))
     780procedure PayCityMaintenance(P, cix: Integer);
     781var
     782  I: Integer;
     783begin
     784  with RW[P], City[cix] do
     785    for I := nWonder to nImp - 1 do
     786      if (Built[I] > 0) and (Project0 and (cpImp or cpIndex) <> (cpImp or I))
    787787      then // don't pay maintenance when just completed
    788788      begin
    789         dec(Money, Imp[i].Maint);
     789        Dec(Money, Imp[I].Maint);
    790790        if Money < 0 then
    791791        begin { out of money - sell improvement }
    792           inc(Money, Imp[i].Cost * BuildCostMod[Difficulty[p]] div 12);
    793           Built[i] := 0;
    794           if Imp[i].Kind <> ikCommon then
     792          Inc(Money, Imp[I].Cost * BuildCostMod[Difficulty[P]] div 12);
     793          Built[I] := 0;
     794          if Imp[I].Kind <> ikCommon then
    795795          begin
    796             assert(i <> imSpacePort);
     796            Assert(I <> imSpacePort);
    797797            // never sell automatically! (solution: no maintenance)
    798             NatBuilt[i] := 0;
    799             if i = imGrWall then
    800               GrWallContinent[p] := -1;
     798            NatBuilt[I] := 0;
     799            if I = imGrWall then
     800              GrWallContinent[P] := -1;
    801801          end;
    802           inc(Flags, chImprovementLost);
    803         end;
    804       end;
    805 end;
    806 
    807 procedure CollectCityResources(p, cix: integer);
    808 var
    809   CityStorage, CityProjectCost: integer;
     802          Inc(Flags, chImprovementLost);
     803        end;
     804      end;
     805end;
     806
     807procedure CollectCityResources(P, cix: Integer);
     808var
     809  CityStorage, CityProjectCost: Integer;
    810810  CityReport: TCityReportNew;
    811   Disorder: boolean;
    812 begin
    813   with RW[p], City[cix], CityReport do
     811  Disorder: Boolean;
     812begin
     813  with RW[P], City[cix], CityReport do
    814814    if Flags and chCaptured <> 0 then
    815815    begin
    816816      Flags := Flags and not chDisorder;
    817       dec(Flags, $10000);
     817      Dec(Flags, $10000);
    818818      if Flags and chCaptured = 0 then
    819819        Flags := Flags or chAfterCapture;
     
    826826      HypoTaxRate := -1;
    827827      HypoLuxuryRate := -1;
    828       GetCityReportNew(p, cix, CityReport);
    829       CityStorage := StorageSize[Difficulty[p]];
    830       CityProjectCost := GetProjectCost(p, cix);
     828      GetCityReportNew(P, cix, CityReport);
     829      CityStorage := StorageSize[Difficulty[P]];
     830      CityProjectCost := GetProjectCost(P, cix);
    831831
    832832      Disorder := (HappinessBalance < 0);
     
    840840      if not Disorder and ((Government = gFuture) or (Size >= NeedAqueductSize)
    841841        and (FoodSurplus < 2)) and (FoodSurplus > 0) then
    842         inc(Money, FoodSurplus)
     842        Inc(Money, FoodSurplus)
    843843      else if not(Disorder and (FoodSurplus > 0)) then
    844844      begin { calculate new food storage }
     
    849849          (Project and (cpImp + cpIndex) <> cpImp + imAqueduct) and
    850850          (Project and (cpImp + cpIndex) <> cpImp + imSewer) and
    851           not CanCityGrow(p, cix) then
    852           inc(Flags, chNoGrowthWarning);
     851          not CanCityGrow(P, cix) then
     852          Inc(Flags, chNoGrowthWarning);
    853853      end;
    854854
    855855      if Prod > CityProjectCost then
    856856      begin
    857         inc(Money, Prod - CityProjectCost);
     857        Inc(Money, Prod - CityProjectCost);
    858858        Prod := CityProjectCost;
    859859      end;
     
    862862      else if not Disorder and (Flags and chProductionSabotaged = 0) then
    863863        if Project and (cpImp + cpIndex) = cpImp + imTrGoods then
    864           inc(Money, Production)
     864          Inc(Money, Production)
    865865        else
    866           inc(Prod, Production);
     866          Inc(Prod, Production);
    867867
    868868      if not Disorder then
    869869      begin
    870870        { sum research points and taxes }
    871         inc(Research, Science);
    872         inc(Money, Tax);
     871        Inc(Research, Science);
     872        Inc(Money, Tax);
    873873        Pollution := Pollution + AddPollution;
    874874      end;
     
    876876end;
    877877
    878 function CityTurn(p, cix: integer): boolean;
     878function CityTurn(P, cix: Integer): Boolean;
    879879// return value: whether city keeps existing
    880880var
    881   i, uix, cix2, p1, SizeMod, CityStorage, CityProjectCost, NewImp, Det,
    882     TestDet: integer;
    883   LackOfMaterial, CheckGrow, DoProd, IsActive: boolean;
    884 begin
    885   with RW[p], City[cix] do
     881  I, uix, cix2, p1, SizeMod, CityStorage, CityProjectCost, NewImp, Det,
     882    TestDet: Integer;
     883  LackOfMaterial, CheckGrow, DoProd, IsActive: Boolean;
     884begin
     885  with RW[P], City[cix] do
    886886  begin
    887887    SizeMod := 0;
    888     CityStorage := StorageSize[Difficulty[p]];
    889     CityProjectCost := GetProjectCost(p, cix);
     888    CityStorage := StorageSize[Difficulty[P]];
     889    CityProjectCost := GetProjectCost(P, cix);
    890890
    891891    LackOfMaterial := Flags and chUnitLost <> 0;
     
    897897    if CheckGrow and (GTestFlags and tfImmGrow <> 0) then { fast growth }
    898898    begin
    899       if CanCityGrow(p, cix) then
    900         inc(SizeMod);
     899      if CanCityGrow(P, cix) then
     900        Inc(SizeMod);
    901901    end
    902902    else if CheckGrow and (Food >= CityStorage) then { normal growth }
    903903    begin
    904       if CanCityGrow(p, cix) then
     904      if CanCityGrow(P, cix) then
    905905      begin
    906906        if Built[imGranary] = 1 then
    907           dec(Food, CityStorage shr 1)
     907          Dec(Food, CityStorage shr 1)
    908908        else
    909           dec(Food, CityStorage);
    910         inc(SizeMod);
     909          Dec(Food, CityStorage);
     910        Inc(SizeMod);
    911911      end;
    912912    end
     
    916916      // check if settlers or conscripts there to disband
    917917      uix := -1;
    918       for i := 0 to nUn - 1 do
    919         if (Un[i].Loc >= 0) and (Un[i].Home = cix) and
    920           ((Model[Un[i].mix].Kind = mkSettler)
     918      for I := 0 to nUn - 1 do
     919        if (Un[I].Loc >= 0) and (Un[I].Home = cix) and
     920          ((Model[Un[I].mix].Kind = mkSettler)
    921921          { and (GWonder[woFreeSettlers].EffectiveOwner<>p) }
    922           or (Un[i].Flags and unConscripts <> 0)) and
    923           ((uix = -1) or (Model[Un[i].mix].Cost < Model[Un[uix].mix].Cost) or
    924           (Model[Un[i].mix].Cost = Model[Un[uix].mix].Cost) and
    925           (Un[i].Exp < Un[uix].Exp)) then
    926           uix := i;
     922          or (Un[I].Flags and unConscripts <> 0)) and
     923          ((uix = -1) or (Model[Un[I].mix].Cost < Model[Un[uix].mix].Cost) or
     924          (Model[Un[I].mix].Cost = Model[Un[uix].mix].Cost) and
     925          (Un[I].Exp < Un[uix].Exp)) then
     926          uix := I;
    927927
    928928      if uix >= 0 then
    929929      begin
    930         RemoveUnit_UpdateMap(p, uix);
    931         inc(Flags, chUnitLost);
     930        RemoveUnit_UpdateMap(P, uix);
     931        Inc(Flags, chUnitLost);
    932932      end
    933933      else
    934934      begin
    935         dec(SizeMod);
    936         inc(Flags, chPopDecrease);
     935        Dec(SizeMod);
     936        Inc(Flags, chPopDecrease);
    937937      end
    938938    end;
     
    946946        uix := -1;
    947947        Det := MaxInt;
    948         for i := 0 to nUn - 1 do
    949           if (Un[i].Loc >= 0) and (Un[i].Home = cix) then
    950             with Model[Un[i].mix] do
     948        for I := 0 to nUn - 1 do
     949          if (Un[I].Loc >= 0) and (Un[I].Home = cix) then
     950            with Model[Un[I].mix] do
    951951            begin
    952952              if Kind = mkSpecial_TownGuard then
    953                 TestDet := Un[i].Health + Un[i].Exp shl 8
     953                TestDet := Un[I].Health + Un[I].Exp shl 8
    954954                // disband townguards first
    955955              else
    956956              begin
    957                 TestDet := Un[i].Health + Un[i].Exp shl 8 + Cost shl 16;
     957                TestDet := Un[I].Health + Un[I].Exp shl 8 + Cost shl 16;
    958958                // value of unit
    959959                if Flags and mdDoubleSupport <> 0 then
     
    963963              if TestDet < Det then
    964964              begin
    965                 uix := i;
     965                uix := I;
    966966                Det := TestDet;
    967967              end;
     
    969969        if uix >= 0 then
    970970        begin
    971           RemoveUnit_UpdateMap(p, uix);
    972           inc(Flags, chUnitLost);
     971          RemoveUnit_UpdateMap(P, uix);
     972          Inc(Flags, chUnitLost);
    973973        end;
    974974      end;
     
    984984      (GWonder[Project and cpIndex].CityID <> WonderNotBuiltYet) then
    985985    begin
    986       inc(Flags, chOldWonder);
    987       DoProd := false;
     986      Inc(Flags, chOldWonder);
     987      DoProd := False;
    988988    end;
    989989
     
    995995      (Project and cpConscripts <> 0))) then
    996996    begin
    997       inc(Flags, chNoSettlerProd);
    998       DoProd := false;
     997      Inc(Flags, chNoSettlerProd);
     998      DoProd := False;
    999999    end;
    10001000
    10011001    if DoProd then
    10021002    begin { project complete }
    1003       dec(Prod, CityProjectCost);
     1003      Dec(Prod, CityProjectCost);
    10041004      if Project and cpImp = 0 then { produce unit }
    10051005      begin
    10061006        if nUn < numax then
    10071007        begin
    1008           CreateUnit(p, Project and cpIndex);
     1008          CreateUnit(P, Project and cpIndex);
    10091009          Un[nUn - 1].Loc := Loc;
    10101010          with Un[nUn - 1] do
     
    10201020              Flags := Flags or unConscripts;
    10211021          end;
    1022           PlaceUnit(p, nUn - 1);
     1022          PlaceUnit(P, nUn - 1);
    10231023          UpdateUnitMap(Loc);
    10241024          if Model[Project and cpIndex].Kind = mkSettler then
    1025             dec(SizeMod, 2) { settler produced - city shrink }
     1025            Dec(SizeMod, 2) { settler produced - city shrink }
    10261026          else if (Model[Project and cpIndex].Kind = mkSlaves) or
    10271027            (Project and cpConscripts <> 0) then
    1028             dec(SizeMod); { slaves/conscripts produced - city shrink }
     1028            Dec(SizeMod); { slaves/conscripts produced - city shrink }
    10291029        end;
    10301030        Project0 := Project or cpRepeat or cpCompleted;
     
    10321032      else if Imp[Project and cpIndex].Kind = ikShipPart then
    10331033      begin { produce ship parts }
    1034         inc(GShip[p].Parts[Project and cpIndex - imShipComp]);
     1034        Inc(GShip[P].Parts[Project and cpIndex - imShipComp]);
    10351035        Project0 := Project or cpCompleted;
    10361036      end
     
    10381038      begin
    10391039        NewImp := Project and cpIndex;
    1040         inc(Money, Prod); { change rest to money }
     1040        Inc(Money, Prod); { change rest to money }
    10411041        Project0 := Project or cpCompleted;
    10421042        Project := cpImp + imTrGoods;
     
    10451045        if Imp[NewImp].Kind in [ikNatLocal, ikNatGlobal] then
    10461046        begin // nat. project
    1047           for i := 0 to nCity - 1 do
    1048             if (City[i].Loc >= 0) and (City[i].Built[NewImp] = 1) then
     1047          for I := 0 to nCity - 1 do
     1048            if (City[I].Loc >= 0) and (City[I].Built[NewImp] = 1) then
    10491049            begin { allowed only once }
    1050               inc(Money, Imp[NewImp].Cost * BuildCostMod[Difficulty[p]] div 12);
    1051               City[i].Built[NewImp] := 0;
     1050              Inc(Money, Imp[NewImp].Cost * BuildCostMod[Difficulty[P]] div 12);
     1051              City[I].Built[NewImp] := 0;
    10521052            end;
    10531053          NatBuilt[NewImp] := 1;
     
    10561056          case NewImp of
    10571057            imGrWall:
    1058               GrWallContinent[p] := Continent[Loc];
     1058              GrWallContinent[P] := Continent[Loc];
    10591059          end;
    10601060        end;
     
    10631063        begin // wonder
    10641064          GWonder[NewImp].CityID := ID;
    1065           GWonder[NewImp].EffectiveOwner := p;
     1065          GWonder[NewImp].EffectiveOwner := P;
    10661066          CheckExpiration(NewImp);
    10671067
     
    10701070            woEiffel:
    10711071              begin // reactivate wonders
    1072                 for i := 0 to nWonder - 1 do
    1073                   if Imp[i].Expiration >= 0 then
     1072                for I := 0 to nWonder - 1 do
     1073                  if Imp[I].Expiration >= 0 then
    10741074                    for cix2 := 0 to nCity - 1 do
    1075                       if (City[cix2].Loc >= 0) and (City[cix2].Built[i] = 1)
     1075                      if (City[cix2].Loc >= 0) and (City[cix2].Built[I] = 1)
    10761076                      then
    1077                         GWonder[i].EffectiveOwner := p;
     1077                        GWonder[I].EffectiveOwner := P;
    10781078              end;
    10791079            woLighthouse:
    1080               CheckSpecialModels(p, preLighthouse);
     1080              CheckSpecialModels(P, preLighthouse);
    10811081            woLeo:
    10821082              begin
    1083                 inc(Research, TechBaseCost(nTech[p], Difficulty[p]) +
    1084                   TechBaseCost(nTech[p] + 2, Difficulty[p]));
    1085                 CheckSpecialModels(p, preLeo);
     1083                Inc(Research, TechBaseCost(nTech[P], Difficulty[P]) +
     1084                  TechBaseCost(nTech[P] + 2, Difficulty[P]));
     1085                CheckSpecialModels(P, preLeo);
    10861086              end;
    10871087            woPyramids:
    1088               CheckSpecialModels(p, preBuilder);
     1088              CheckSpecialModels(P, preBuilder);
    10891089            woMir:
    10901090              begin
    10911091                for p1 := 0 to nPl - 1 do
    1092                   if (p1 <> p) and (1 shl p1 and GAlive <> 0) then
     1092                  if (p1 <> P) and (1 shl p1 and GAlive <> 0) then
    10931093                  begin
    1094                     if RW[p].Treaty[p1] = trNoContact then
    1095                       IntroduceEnemy(p, p1);
    1096                     GiveCivilReport(p, p1);
    1097                     GiveMilReport(p, p1);
     1094                    if RW[P].Treaty[p1] = trNoContact then
     1095                      IntroduceEnemy(P, p1);
     1096                    GiveCivilReport(P, p1);
     1097                    GiveMilReport(P, p1);
    10981098                  end;
    10991099              end;
     
    11011101        end;
    11021102
    1103         for i := 0 to nImpReplacement - 1 do // sell obsolete buildings
    1104           if (ImpReplacement[i].NewImp = NewImp) and
    1105             (Built[ImpReplacement[i].OldImp] > 0) then
     1103        for I := 0 to nImpReplacement - 1 do // sell obsolete buildings
     1104          if (ImpReplacement[I].NewImp = NewImp) and
     1105            (Built[ImpReplacement[I].OldImp] > 0) then
    11061106          begin
    1107             inc(RW[p].Money, Imp[ImpReplacement[i].OldImp].Cost * BuildCostMod
    1108               [Difficulty[p]] div 12);
    1109             Built[ImpReplacement[i].OldImp] := 0;
     1107            Inc(RW[P].Money, Imp[ImpReplacement[I].OldImp].Cost * BuildCostMod
     1108              [Difficulty[P]] div 12);
     1109            Built[ImpReplacement[I].OldImp] := 0;
    11101110          end;
    11111111
    11121112        if NewImp in [imPower, imHydro, imNuclear] then
    1113           for i := 0 to nImp - 1 do
    1114             if (i <> NewImp) and (i in [imPower, imHydro, imNuclear]) and
    1115               (Built[i] > 0) then
     1113          for I := 0 to nImp - 1 do
     1114            if (I <> NewImp) and (I in [imPower, imHydro, imNuclear]) and
     1115              (Built[I] > 0) then
    11161116            begin // sell obsolete power plant
    1117               inc(RW[p].Money, Imp[i].Cost * BuildCostMod[Difficulty[p]
     1117              Inc(RW[P].Money, Imp[I].Cost * BuildCostMod[Difficulty[P]
    11181118                ] div 12);
    1119               Built[i] := 0;
     1119              Built[I] := 0;
    11201120            end;
    11211121
     
    11231123      end;
    11241124      Prod0 := Prod;
    1125       inc(Flags, chProduction);
     1125      Inc(Flags, chProduction);
    11261126    end
    11271127    else
     
    11351135    if SizeMod > 0 then
    11361136    begin
    1137       CityGrowth(p, cix);
    1138       inc(Flags, chPopIncrease);
    1139     end;
    1140     result := Size + SizeMod >= 2;
    1141     if result then
     1137      CityGrowth(P, cix);
     1138      Inc(Flags, chPopIncrease);
     1139    end;
     1140    Result := Size + SizeMod >= 2;
     1141    if Result then
    11421142      while SizeMod < 0 do
    11431143      begin
    1144         CityShrink(p, cix);
    1145         inc(SizeMod);
     1144        CityShrink(P, cix);
     1145        Inc(SizeMod);
    11461146      end;
    11471147  end;
     
    11521152  ____________________________________________________________________
    11531153}
    1154 function SetCityTiles(p, cix, NewTiles: integer;
    1155   TestOnly: boolean = false): integer;
    1156 var
    1157   V21, Working, ChangeTiles, AddTiles, Loc1: integer;
     1154function SetCityTiles(P, cix, NewTiles: Integer;
     1155  TestOnly: Boolean = False): Integer;
     1156var
     1157  V21, Working, ChangeTiles, AddTiles, Loc1: Integer;
    11581158  CityAreaInfo: TCityAreaInfo;
    11591159  Radius: TVicinity21Loc;
    11601160begin
    1161   with RW[p].City[cix] do
     1161  with RW[P].City[cix] do
    11621162  begin
    1163     ChangeTiles := NewTiles xor integer(Tiles);
     1163    ChangeTiles := NewTiles xor Integer(Tiles);
    11641164    AddTiles := NewTiles and not Tiles;
    11651165    if Mode = moPlaying then
     
    11671167      if NewTiles and not $67F7F76 <> 0 then
    11681168      begin
    1169         result := eInvalid;
    1170         exit
     1169        Result := eInvalid;
     1170        Exit
    11711171      end; // invalid tile index included
    11721172      if NewTiles and (1 shl 13) = 0 then
    11731173      begin
    1174         result := eViolation;
    1175         exit
     1174        Result := eViolation;
     1175        Exit
    11761176      end; // city tile must be exploited
    11771177      if ChangeTiles = 0 then
    11781178      begin
    1179         result := eNotChanged;
    1180         exit
     1179        Result := eNotChanged;
     1180        Exit
    11811181      end;
    11821182      if AddTiles <> 0 then
    11831183      begin
    11841184        // check if new tiles possible
    1185         GetCityAreaInfo(p, Loc, CityAreaInfo);
     1185        GetCityAreaInfo(P, Loc, CityAreaInfo);
    11861186        for V21 := 1 to 26 do
    11871187          if AddTiles and (1 shl V21) <> 0 then
    11881188            if CityAreaInfo.Available[V21] <> faAvailable then
    11891189            begin
    1190               result := eTileNotAvailable;
    1191               exit;
     1190              Result := eTileNotAvailable;
     1191              Exit;
    11921192            end;
    11931193        // not more tiles than inhabitants
     
    11951195        for V21 := 1 to 26 do
    11961196          if NewTiles and (1 shl V21) <> 0 then
    1197             inc(Working);
     1197            Inc(Working);
    11981198        if Working > Size then
    11991199        begin
    1200           result := eNoWorkerAvailable;
    1201           exit;
    1202         end;
    1203       end;
    1204     end;
    1205     result := eOk;
     1200          Result := eNoWorkerAvailable;
     1201          Exit;
     1202        end;
     1203      end;
     1204    end;
     1205    Result := eOk;
    12061206    if not TestOnly then
    12071207    begin
     
    12111211        begin
    12121212          Loc1 := Radius[V21];
    1213           assert((Loc1 >= 0) and (Loc1 < MapSize));
     1213          Assert((Loc1 >= 0) and (Loc1 < MapSize));
    12141214          if NewTiles and (1 shl V21) <> 0 then
    12151215            UsedByCity[Loc1] := Loc // employ tile
    12161216          else if UsedByCity[Loc1] <> Loc then
    1217             assert(Mode < moPlaying)
     1217            Assert(Mode < moPlaying)
    12181218            // should only happen during loading, because of wrong sSetCityTiles command order
    12191219          else
     
    12251225end;
    12261226
    1227 procedure GetCityTileAdvice(p, cix: integer; var Advice: TCityTileAdviceData);
     1227procedure GetCityTileAdvice(P, cix: Integer; var Advice: TCityTileAdviceData);
    12281228const
    12291229  oFood = 0;
     
    12401240  end;
    12411241var
    1242   i, V21, Loc1, nHierarchy, iH, iT, iH_Switch, MinWorking, MaxWorking,
     1242  I, V21, Loc1, nHierarchy, iH, iT, iH_Switch, MinWorking, MaxWorking,
    12431243    WantedProd, MinFood, MinProd, count, Take, MaxTake, AreaSize, FormulaCode,
    12441244    NeedRare, RareTiles, cix1, dx, dy, BestTiles, ProdBeforeBoost, TestTiles,
    1245     SubPlus, SuperPlus: integer;
    1246   SuperValue, BestSuperValue, SubValue, BestSubValue: integer;
    1247   Value, BestValue, ValuePlus: extended;
    1248   ValueFormula_Weight: array [oFood .. oScience] of extended;
    1249   ValueFormula_Multiply: array [oFood .. oScience] of boolean;
    1250   Output: array [oFood .. oScience] of integer;
     1245    SubPlus, SuperPlus: Integer;
     1246  SuperValue, BestSuperValue, SubValue, BestSubValue: Integer;
     1247  Value, BestValue, ValuePlus: Extended;
     1248  ValueFormula_Weight: array [oFood .. oScience] of Extended;
     1249  ValueFormula_Multiply: array [oFood .. oScience] of Boolean;
     1250  Output: array [oFood .. oScience] of Integer;
    12511251  TileInfo, BaseTileInfo: TTileInfo;
    12521252  Radius, Radius1: TVicinity21Loc;
     
    12551255  CityAreaInfo: TCityAreaInfo;
    12561256  Hierarchy: array [0 .. 20, 0 .. 31] of TTileData;
    1257   nTile, nSelection: array [0 .. 20] of integer;
    1258   SubCriterion: array [0 .. 27] of integer;
    1259   FoodWasted, FoodToTax, ProdToTax, RareOK, NeedStep2, IsBest: boolean;
    1260 begin
    1261   if (RW[p].Government = gAnarchy) or (RW[p].City[cix].Flags and chCaptured <> 0)
     1257  nTile, nSelection: array [0 .. 20] of Integer;
     1258  SubCriterion: array [0 .. 27] of Integer;
     1259  FoodWasted, FoodToTax, ProdToTax, RareOK, NeedStep2, IsBest: Boolean;
     1260begin
     1261  if (RW[P].Government = gAnarchy) or (RW[P].City[cix].Flags and chCaptured <> 0)
    12621262  then
    12631263  begin
     
    12651265    Advice.Tiles := 1 shl CityOwnTile;
    12661266    Advice.CityReport.HypoTiles := 1 shl CityOwnTile;
    1267     exit;
    1268   end;
    1269 
    1270   for i := oFood to oScience do
     1267    Exit;
     1268  end;
     1269
     1270  for I := oFood to oScience do
    12711271  begin // decode evaluation formula from weights parameter
    1272     FormulaCode := Advice.ResourceWeights shr (24 - 8 * i) and $FF;
    1273     ValueFormula_Multiply[i] := FormulaCode and $80 <> 0;
     1272    FormulaCode := Advice.ResourceWeights shr (24 - 8 * I) and $FF;
     1273    ValueFormula_Multiply[I] := FormulaCode and $80 <> 0;
    12741274    if FormulaCode and $40 <> 0 then
    1275       ValueFormula_Weight[i] := (FormulaCode and $0F) *
     1275      ValueFormula_Weight[I] := (FormulaCode and $0F) *
    12761276        (1 shl (FormulaCode and $30 shr 4)) / 16
    12771277    else
    1278       ValueFormula_Weight[i] := (FormulaCode and $0F) *
     1278      ValueFormula_Weight[I] := (FormulaCode and $0F) *
    12791279        (1 shl (FormulaCode and $30 shr 4));
    12801280  end;
     
    12831283  TestReport.HypoTax := -1;
    12841284  TestReport.HypoLux := -1;
    1285   GetSmallCityReport(p, cix, TestReport, @CityReportEx);
    1286   with RW[p].City[cix] do
     1285  GetSmallCityReport(P, cix, TestReport, @CityReportEx);
     1286  with RW[P].City[cix] do
    12871287  begin
    12881288    V21_to_Loc(Loc, Radius);
    1289     FoodToTax := RW[p].Government = gFuture;
     1289    FoodToTax := RW[P].Government = gFuture;
    12901290    ProdToTax := Project and (cpImp + cpIndex) = cpImp + imTrGoods;
    1291     FoodWasted := not FoodToTax and (Food = StorageSize[Difficulty[p]]) and
    1292       not CanCityGrow(p, cix);
     1291    FoodWasted := not FoodToTax and (Food = StorageSize[Difficulty[P]]) and
     1292      not CanCityGrow(P, cix);
    12931293
    12941294    // sub criteria
     
    13001300          V21 xor $15;
    13011301    end;
    1302     for cix1 := 0 to RW[p].nCity - 1 do
     1302    for cix1 := 0 to RW[P].nCity - 1 do
    13031303      if cix1 <> cix then
    13041304      begin
    1305         Loc1 := RW[p].City[cix1].Loc;
     1305        Loc1 := RW[P].City[cix1].Loc;
    13061306        if Loc1 >= 0 then
    13071307        begin
     
    13161316              begin
    13171317                dxdy(Loc, Loc1, dx, dy);
    1318                 dec(SubCriterion[(dy + 3) shl 2 + (dx + 3) shr 1], 160);
     1318                Dec(SubCriterion[(dy + 3) shl 2 + (dx + 3) shr 1], 160);
    13191319              end;
    13201320            end;
     
    13231323      end;
    13241324
    1325     GetCityAreaInfo(p, Loc, CityAreaInfo);
     1325    GetCityAreaInfo(P, Loc, CityAreaInfo);
    13261326    AreaSize := 0;
    13271327    for V21 := 1 to 26 do
    13281328      if CityAreaInfo.Available[V21] = faAvailable then
    1329         inc(AreaSize);
    1330 
    1331     if RW[p].Government = gFundamentalism then
     1329        Inc(AreaSize);
     1330
     1331    if RW[P].Government = gFundamentalism then
    13321332    begin
    13331333      MinWorking := Size;
     
    13391339      if MinWorking > Size then
    13401340        MinWorking := Size;
    1341       if (RW[p].LuxRate = 0) and not CityReportEx.TradeProcessing.FlexibleLuxury
     1341      if (RW[P].LuxRate = 0) and not CityReportEx.TradeProcessing.FlexibleLuxury
    13421342      then
    13431343        MaxWorking := MinWorking
     
    13761376        Loc1 := Radius[V21];
    13771377        if (Loc1 >= 0) and (Loc1 < MapSize) and
    1378           (RealMap[Loc1] and fModern = cardinal(NeedRare)) then
     1378          (RealMap[Loc1] and fModern = Cardinal(NeedRare)) then
    13791379          RareTiles := RareTiles or (1 shl V21);
    13801380      end;
     
    13881388      begin
    13891389        Loc1 := Radius[V21];
    1390         assert((Loc1 >= 0) and (Loc1 < MapSize));
    1391         GetTileInfo(p, cix, Loc1, TileInfo);
     1390        Assert((Loc1 >= 0) and (Loc1 < MapSize));
     1391        GetTileInfo(P, cix, Loc1, TileInfo);
    13921392        if V21 = CityOwnTile then
    13931393          BaseTileInfo := TileInfo
     
    14051405              (TileInfo.Trade = Hierarchy[iH, iT].Trade) and
    14061406              (SubCriterion[V21] >= SubCriterion[Hierarchy[iH, iT].V21])) do
    1407               inc(iT);
     1407              Inc(iT);
    14081408            if (iT = nTile[iH]) // new worst tile in this hierarchy
    14091409              or ((TileInfo.Food >= Hierarchy[iH, iT].Food)
     
    14111411              and (TileInfo.Prod >= Hierarchy[iH, iT].Prod) and
    14121412              (TileInfo.Trade >= Hierarchy[iH, iT].Trade)) then
    1413               break; // insert position found!
    1414             inc(iH);
     1413              Break; // insert position found!
     1414            Inc(iH);
    14151415          end;
    14161416          if iH = nHierarchy then
    14171417          begin // need to start new hierarchy
    14181418            nTile[iH] := 0;
    1419             inc(nHierarchy);
     1419            Inc(nHierarchy);
    14201420            iT := 0;
    14211421          end;
    1422           move(Hierarchy[iH, iT], Hierarchy[iH, iT + 1],
     1422          Move(Hierarchy[iH, iT], Hierarchy[iH, iT + 1],
    14231423            (nTile[iH] - iT) * SizeOf(TTileData));
    1424           inc(nTile[iH]);
     1424          Inc(nTile[iH]);
    14251425          Hierarchy[iH, iT].V21 := V21;
    14261426          Hierarchy[iH, iT].Food := TileInfo.Food;
     
    14381438        begin
    14391439          Loc1 := Radius[V21];
    1440           assert((V21 <> CityOwnTile) and (Loc1 >= 0) and (Loc1 < MapSize));
    1441           GetTileInfo(p, cix, Loc1, TileInfo);
     1440          Assert((V21 <> CityOwnTile) and (Loc1 >= 0) and (Loc1 < MapSize));
     1441          GetTileInfo(P, cix, Loc1, TileInfo);
    14421442          if iH = nHierarchy then
    14431443          begin // need to start new hierarchy
    14441444            nTile[iH] := 0;
    1445             inc(nHierarchy);
     1445            Inc(nHierarchy);
    14461446            iT := 0;
    14471447          end
    14481448          else
    14491449            iT := nTile[iH];
    1450           inc(nTile[iH]);
     1450          Inc(nTile[iH]);
    14511451          Hierarchy[iH, iT].V21 := V21;
    14521452          Hierarchy[iH, iT].Food := TileInfo.Food; // = 0
     
    14571457    end;
    14581458    if Built[imAlgae] > 0 then
    1459       inc(BaseTileInfo.Food, 12);
     1459      Inc(BaseTileInfo.Food, 12);
    14601460
    14611461    // step 2: summarize resources
    14621462    for iH := 0 to nHierarchy - 1 do
    14631463    begin
    1464       move(Hierarchy[iH, 0], Hierarchy[iH, 1], nTile[iH] * SizeOf(TTileData));
     1464      Move(Hierarchy[iH, 0], Hierarchy[iH, 1], nTile[iH] * SizeOf(TTileData));
    14651465      Hierarchy[iH, 0].Food := 0;
    14661466      Hierarchy[iH, 0].Prod := 0;
     
    14701470      for iT := 1 to nTile[iH] do
    14711471      begin
    1472         inc(Hierarchy[iH, iT].Food, Hierarchy[iH, iT - 1].Food);
    1473         inc(Hierarchy[iH, iT].Prod, Hierarchy[iH, iT - 1].Prod);
    1474         inc(Hierarchy[iH, iT].Trade, Hierarchy[iH, iT - 1].Trade);
    1475         inc(Hierarchy[iH, iT].SubValue, Hierarchy[iH, iT - 1].SubValue);
     1472        Inc(Hierarchy[iH, iT].Food, Hierarchy[iH, iT - 1].Food);
     1473        Inc(Hierarchy[iH, iT].Prod, Hierarchy[iH, iT - 1].Prod);
     1474        Inc(Hierarchy[iH, iT].Trade, Hierarchy[iH, iT - 1].Trade);
     1475        Inc(Hierarchy[iH, iT].SubValue, Hierarchy[iH, iT - 1].SubValue);
    14761476        Hierarchy[iH, iT].V21 := 1 shl Hierarchy[iH, iT].V21 +
    14771477          Hierarchy[iH, iT - 1].V21;
     
    15011501        (ProdBeforeBoost < WantedProd)) do
    15021502      begin
    1503         assert(nSelection[iH] = 0);
     1503        Assert(nSelection[iH] = 0);
    15041504        Take := MinWorking - TestReport.Working;
    15051505        if Take > nTile[iH] then
     
    15141514          while (Take < MaxTake) and
    15151515            (TestReport.FoodRep + Hierarchy[iH, Take].Food < MinFood) do
    1516             inc(Take);
     1516            Inc(Take);
    15171517          while (Take < MaxTake) and
    15181518            (ProdBeforeBoost + Hierarchy[iH, Take].Prod < MinProd) do
    1519             inc(Take);
     1519            Inc(Take);
    15201520        end;
    15211521        nSelection[iH] := Take;
    1522         inc(TestReport.Working, Take);
     1522        Inc(TestReport.Working, Take);
    15231523        with Hierarchy[iH, Take] do
    15241524        begin
    1525           inc(TestReport.FoodRep, Food);
    1526           inc(ProdBeforeBoost, Prod);
    1527           inc(TestReport.Trade, Trade);
    1528         end;
    1529         inc(iH);
    1530       end;
    1531 
    1532       assert((TestReport.Working >= MinWorking) and
     1525          Inc(TestReport.FoodRep, Food);
     1526          Inc(ProdBeforeBoost, Prod);
     1527          Inc(TestReport.Trade, Trade);
     1528        end;
     1529        Inc(iH);
     1530      end;
     1531
     1532      Assert((TestReport.Working >= MinWorking) and
    15331533        (TestReport.Working <= MaxWorking));
    15341534      if (TestReport.FoodRep >= MinFood) and (ProdBeforeBoost >= MinProd) then
    15351535      begin
    1536         SplitTrade(TestReport.Trade, RW[p].TaxRate, RW[p].LuxRate,
     1536        SplitTrade(TestReport.Trade, RW[P].TaxRate, RW[P].LuxRate,
    15371537          TestReport.Working, CityReportEx.TradeProcessing,
    15381538          TestReport.Corruption, TestReport.Tax, TestReport.Lux,
     
    15431543          TestReport.Deployed >= Size then
    15441544        begin // city is not in disorder -- evaluate combination
    1545           inc(count);
     1545          Inc(count);
    15461546          if (MinProd < WantedProd) and (ProdBeforeBoost > MinProd) then
    15471547          begin // no combination reached wanted prod yet
     
    15911591              then
    15921592              begin
    1593                 inc(Output[oTax], Output[oFood]);
     1593                Inc(Output[oTax], Output[oFood]);
    15941594                Output[oFood] := 0;
    15951595              end;
     
    16031603              if NeedRare > 0 then
    16041604              begin
    1605                 RareOK := false;
     1605                RareOK := False;
    16061606                for iH := 0 to nHierarchy - 1 do
    16071607                  if Hierarchy[iH, nSelection[iH]].V21 and RareTiles <> 0 then
    1608                     RareOK := true;
     1608                    RareOK := True;
    16091609                if not RareOK then
    16101610                  TestReport.ProdRep := TestReport.Support;
     
    16131613              if ProdToTax then
    16141614              begin
    1615                 inc(Output[oTax], Output[oProd]);
     1615                Inc(Output[oTax], Output[oProd]);
    16161616                Output[oProd] := 0;
    16171617              end;
    16181618            end;
    16191619
    1620             NeedStep2 := false;
     1620            NeedStep2 := False;
    16211621            Value := 0;
    1622             for i := oFood to oScience do
    1623               if ValueFormula_Multiply[i] then
    1624                 NeedStep2 := true
     1622            for I := oFood to oScience do
     1623              if ValueFormula_Multiply[I] then
     1624                NeedStep2 := True
    16251625              else
    1626                 Value := Value + ValueFormula_Weight[i] * Output[i];
     1626                Value := Value + ValueFormula_Weight[I] * Output[I];
    16271627            if NeedStep2 then
    16281628            begin
    16291629              if Value > 0 then
    16301630                Value := ln(Value) + 123;
    1631               for i := oFood to oScience do
    1632                 if ValueFormula_Multiply[i] and (Output[i] > 0) then
    1633                   Value := Value + ValueFormula_Weight[i] *
    1634                     (ln(Output[i]) + 123);
     1631              for I := oFood to oScience do
     1632                if ValueFormula_Multiply[I] and (Output[I] > 0) then
     1633                  Value := Value + ValueFormula_Weight[I] *
     1634                    (ln(Output[I]) + 123);
    16351635            end;
    16361636
     
    16431643              for iH := 0 to nHierarchy - 1 do
    16441644              begin
    1645                 inc(TestTiles, Hierarchy[iH, nSelection[iH]].V21);
    1646                 inc(SubValue, Hierarchy[iH, nSelection[iH]].SubValue);
     1645                Inc(TestTiles, Hierarchy[iH, nSelection[iH]].V21);
     1646                Inc(SubValue, Hierarchy[iH, nSelection[iH]].SubValue);
    16471647              end;
    1648               IsBest := true;
     1648              IsBest := True;
    16491649              if (SuperPlus = 0) and (ValuePlus = 0.0) then
    16501650              begin
    16511651                SubPlus := SubValue - BestSubValue;
    16521652                if SubPlus < 0 then
    1653                   IsBest := false
     1653                  IsBest := False
    16541654                else if SubPlus = 0 then
    16551655                begin
    1656                   assert(TestTiles <> BestTiles);
     1656                  Assert(TestTiles <> BestTiles);
    16571657                  IsBest := TestTiles > BestTiles
    16581658                end
     
    16791679        with Hierarchy[iH_Switch, nSelection[iH_Switch]] do
    16801680        begin
    1681           dec(TestReport.FoodRep, Food);
    1682           dec(ProdBeforeBoost, Prod);
    1683           dec(TestReport.Trade, Trade);
    1684         end;
    1685         inc(nSelection[iH_Switch]);
    1686         inc(TestReport.Working);
     1681          Dec(TestReport.FoodRep, Food);
     1682          Dec(ProdBeforeBoost, Prod);
     1683          Dec(TestReport.Trade, Trade);
     1684        end;
     1685        Inc(nSelection[iH_Switch]);
     1686        Inc(TestReport.Working);
    16871687        if (nSelection[iH_Switch] <= nTile[iH_Switch]) and
    16881688          (TestReport.Working <= MaxWorking) then
     
    16901690          with Hierarchy[iH_Switch, nSelection[iH_Switch]] do
    16911691          begin
    1692             inc(TestReport.FoodRep, Food);
    1693             inc(ProdBeforeBoost, Prod);
    1694             inc(TestReport.Trade, Trade);
     1692            Inc(TestReport.FoodRep, Food);
     1693            Inc(ProdBeforeBoost, Prod);
     1694            Inc(TestReport.Trade, Trade);
    16951695          end;
    1696           break;
    1697         end;
    1698         dec(TestReport.Working, nSelection[iH_Switch]);
     1696          Break;
     1697        end;
     1698        Dec(TestReport.Working, nSelection[iH_Switch]);
    16991699        nSelection[iH_Switch] := 0;
    1700         inc(iH_Switch);
     1700        Inc(iH_Switch);
    17011701      until iH_Switch = nHierarchy;
    17021702    until iH_Switch = nHierarchy; // everything tested -- done
    17031703  end;
    1704   assert(BestSuperValue > 0); // advice should always be possible
     1704  Assert(BestSuperValue > 0); // advice should always be possible
    17051705  Advice.Tiles := BestTiles;
    17061706  Advice.CityReport.HypoTiles := BestTiles;
     
    17131713procedure InitGame;
    17141714var
    1715   p, i, mixTownGuard: integer;
     1715  P, I, mixTownGuard: Integer;
    17161716begin
    17171717  MaxDist := Distance(0, MapSize - lx shr 1);
    1718   for p := 0 to nPl - 1 do
    1719     if (1 shl p and GAlive <> 0) then
    1720       with RW[p] do
     1718  for P := 0 to nPl - 1 do
     1719    if (1 shl P and GAlive <> 0) then
     1720      with RW[P] do
    17211721      begin // initialize capital
    17221722        mixTownGuard := 0;
    17231723        while Model[mixTownGuard].Kind <> mkSpecial_TownGuard do
    1724           inc(mixTownGuard);
     1724          Inc(mixTownGuard);
    17251725        with City[0] do
    17261726        begin
    17271727          Built[imPalace] := 1;
    17281728          Size := 4;
    1729           for i := 2 to Size do
    1730             AddBestCityTile(p, 0);
     1729          for I := 2 to Size do
     1730            AddBestCityTile(P, 0);
    17311731          Project := mixTownGuard;
    17321732        end;
Note: See TracChangeset for help on using the changeset viewer.