Changeset 447 for trunk/LocalPlayer


Ignore:
Timestamp:
May 19, 2022, 10:39:34 PM (2 years ago)
Author:
chronos
Message:
  • Modified: Use first capital letter in identifiers.
Location:
trunk/LocalPlayer
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/Battle.pas

    r442 r447  
    3232    uix, ToLoc: Integer;
    3333    Forecast: TBattleForecastEx;
    34     IsSuicideQuery: boolean;
     34    IsSuicideQuery: Boolean;
    3535  end;
    3636
     
    6363  TextSize: TSize;
    6464  LabelText: string;
    65   FirstStrike: boolean;
     65  FirstStrike: Boolean;
    6666begin
    6767  MaxBar := 65;
     
    196196  BitBltCanvas(Buffer.Canvas, 0, 0, 66, 48, ca, xm - 8 - 4 - 66,
    197197    ym + 8 + 12);
    198   MakeUnitInfo(me, MyUn[uix], UnitInfo);
     198  MakeUnitInfo(Me, MyUn[uix], UnitInfo);
    199199  UnitInfo.Flags := UnitInfo.Flags and not unFortified;
    200200  IsoMap.PaintUnit(1, 0, UnitInfo, 0);
     
    216216    ClientWidth := 300;
    217217    ClientHeight := 288;
    218     OKBtn.Visible := true;
    219     CancelBtn.Visible := true;
     218    OKBtn.Visible := True;
     219    CancelBtn.Visible := True;
    220220    Left := (Screen.Width - ClientWidth) div 2; // center on screen
    221221    Top := (Screen.Height - ClientHeight) div 2;
     
    225225    ClientWidth := 178;
    226226    ClientHeight := 178;
    227     OKBtn.Visible := false;
    228     CancelBtn.Visible := false;
     227    OKBtn.Visible := False;
     228    CancelBtn.Visible := False;
    229229  end;
    230230end;
     
    232232procedure TBattleDlg.FormPaint(Sender: TObject);
    233233var
    234   ym, cix, p: Integer;
    235   s, s1: string;
     234  ym, cix, P: Integer;
     235  S, s1: string;
    236236begin
    237237  with Canvas do
     
    253253  begin
    254254    Canvas.Font.Assign(UniFont[ftCaption]);
    255     s := Phrases.Lookup('TITLE_SUICIDE');
    256     RisedTextOut(Canvas, (ClientWidth - BiColorTextWidth(Canvas, s)) div 2,
    257       7 + Border, s);
     255    S := Phrases.Lookup('TITLE_SUICIDE');
     256    RisedTextOut(Canvas, (ClientWidth - BiColorTextWidth(Canvas, S)) div 2,
     257      7 + Border, S);
    258258    Canvas.Font.Assign(UniFont[ftNormal]);
    259     s := Phrases.Lookup('SUICIDE');
    260     p := pos('\', s);
    261     if p = 0 then
    262       RisedTextOut(Canvas, (ClientWidth - BiColorTextWidth(Canvas, s))
    263         div 2, 205, s)
     259    S := Phrases.Lookup('SUICIDE');
     260    P := Pos('\', S);
     261    if P = 0 then
     262      RisedTextOut(Canvas, (ClientWidth - BiColorTextWidth(Canvas, S))
     263        div 2, 205, S)
    264264    else
    265265    begin
    266       s1 := copy(s, 1, p - 1);
     266      s1 := Copy(S, 1, P - 1);
    267267      RisedTextOut(Canvas, (ClientWidth - BiColorTextWidth(Canvas, s1)) div 2,
    268268        205 - MessageLineSpacing div 2, s1);
    269       s1 := copy(s, p + 1, 255);
     269      s1 := Copy(S, P + 1, 255);
    270270      RisedTextOut(Canvas, (ClientWidth - BiColorTextWidth(Canvas, s1)) div 2,
    271271        205 + (MessageLineSpacing - MessageLineSpacing div 2), s1);
  • trunk/LocalPlayer/CityScreen.pas

    r442 r447  
    3939    procedure FormDestroy(Sender: TObject);
    4040    procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
    41       Shift: TShiftState; x, y: integer);
     41      Shift: TShiftState; X, Y: Integer);
    4242    procedure BuyClick(Sender: TObject);
    4343    procedure CloseBtnClick(Sender: TObject);
     
    5353    procedure PageDownBtnClick(Sender: TObject);
    5454  private
    55     c: TCity;
     55    C: TCity;
    5656    Report: TCityReportNew;
    5757    cOwner: Integer;
     
    7070    Optimize_cixTileChange: Integer;
    7171    Optimize_TilesBeforeChange: Integer;
    72     Happened: cardinal;
    73     imix: array [0 .. 15] of integer;
     72    Happened: Cardinal;
     73    imix: array [0 .. 15] of Integer;
    7474    CityAreaInfo: TCityAreaInfo;
    7575    AreaMap: TIsoMap;
     
    8989    procedure InitZoomCityMap;
    9090    procedure ChooseProject;
    91     procedure ChangeCity(d: integer);
    92     procedure ChangeResourceWeights(iResourceWeights: integer);
     91    procedure ChangeCity(D: Integer);
     92    procedure ChangeResourceWeights(iResourceWeights: Integer);
    9393    procedure OnPlaySound(var Msg: TMessage); message WM_PLAYSOUND;
    9494  public
     
    9696    CloseAction: TCityCloseAction;
    9797    procedure OffscreenPaint; override;
    98     procedure ShowNewContent(NewMode: TWindowMode; Loc: integer; ShowEvent: cardinal);
     98    procedure ShowNewContent(NewMode: TWindowMode; Loc: Integer; ShowEvent: Cardinal);
    9999    procedure Reset;
    100100    procedure CheckAge;
     
    202202  NoMap := TIsoMap.Create;
    203203  AreaMap := TIsoMap.Create;
    204   AreaMap.SetOutput(offscreen);
     204  AreaMap.SetOutput(Offscreen);
    205205  AreaMap.SetPaintBounds(xmArea - 192, ymArea - 96 - 32, xmArea + 192,
    206206    ymArea + 96);
     
    293293procedure TCityDlg.InitSmallCityMap;
    294294var
    295   i, iix, cli1, Color0, Color1, Color2: integer;
     295  I, iix, cli1, Color0, Color1, Color2: Integer;
    296296begin
    297297  if cix >= 0 then
    298     c := MyCity[cix];
     298    C := MyCity[cix];
    299299  case MyMap[cLoc] and fTerrain of
    300300    fPrairie: cli1 := cliPrairie;
     
    329329  begin
    330330    Brush.Color := ScreenTools.Colors.Canvas.Pixels[clkAge0 + Age, cliImp];
    331     for i := 0 to 29 do
     331    for I := 0 to 29 do
    332332    begin
    333333      for iix := nWonder to nImp - 1 do
    334         if (ImpPosition[iix] = i) and (c.Built[iix] > 0) then
     334        if (ImpPosition[iix] = I) and (C.Built[iix] > 0) then
    335335        begin
    336           FillRect(Rect(5 + 16 * (i mod 3) + 48 * (i div 18),
    337             3 + 12 * (i mod 18 div 3), 13 + 16 * (i mod 3) + 48 * (i div 18),
    338             11 + 12 * (i mod 18 div 3)));
    339           break;
     336          FillRect(Rect(5 + 16 * (I mod 3) + 48 * (I div 18),
     337            3 + 12 * (I mod 18 div 3), 13 + 16 * (I mod 3) + 48 * (I div 18),
     338            11 + 12 * (I mod 18 div 3)));
     339          Break;
    340340        end;
    341341    end;
    342     i := 30;
     342    I := 30;
    343343    for iix := 0 to nImp do
    344       if (c.Built[iix] > 0) and ((iix < nWonder) or (ImpPosition[iix] < 0)) then
     344      if (C.Built[iix] > 0) and ((iix < nWonder) or (ImpPosition[iix] < 0)) then
    345345      begin
    346         FillRect(Rect(5 + 16 * (i mod 3) + 48 * (i div 18),
    347           3 + 12 * (i mod 18 div 3), 13 + 16 * (i mod 3) + 48 * (i div 18),
    348           11 + 12 * (i mod 18 div 3)));
    349         inc(i);
    350         if i = 36 then
    351           break; // area is full
     346        FillRect(Rect(5 + 16 * (I mod 3) + 48 * (I div 18),
     347          3 + 12 * (I mod 18 div 3), 13 + 16 * (I mod 3) + 48 * (I div 18),
     348          11 + 12 * (I mod 18 div 3)));
     349        Inc(I);
     350        if I = 36 then
     351          Break; // area is full
    352352      end;
    353     if c.Project and cpImp <> 0 then
    354     begin
    355       iix := c.Project and cpIndex;
     353    if C.Project and cpImp <> 0 then
     354    begin
     355      iix := C.Project and cpIndex;
    356356      if iix <> imTrGoods then
    357357      begin
    358358        if (iix >= nWonder) and (ImpPosition[iix] >= 0) then
    359           i := ImpPosition[iix];
    360         if i < 36 then
     359          I := ImpPosition[iix];
     360        if I < 36 then
    361361        begin
    362           brush.Color := ScreenTools.Colors.Canvas.Pixels[clkAge0 + Age, cliImpProject];
    363           FillRect(Rect(5 + 16 * (i mod 3) + 48 * (i div 18),
    364             3 + 12 * (i mod 18 div 3), 13 + 16 * (i mod 3) + 48 * (i div 18),
    365             11 + 12 * (i mod 18 div 3)));
     362          Brush.Color := ScreenTools.Colors.Canvas.Pixels[clkAge0 + Age, cliImpProject];
     363          FillRect(Rect(5 + 16 * (I mod 3) + 48 * (I div 18),
     364            3 + 12 * (I mod 18 div 3), 13 + 16 * (I mod 3) + 48 * (I div 18),
     365            11 + 12 * (I mod 18 div 3)));
    366366        end;
    367367      end;
    368368    end;
    369     brush.style := bsClear;
     369    Brush.style := bsClear;
    370370  end;
    371371end;
     
    384384        112 * (ZoomArea - 3), wZoomMap - wZoomEnvironment, hZoomMap);
    385385      ImageOp_B(ZoomCityMap, CityMapTemplate, wZoomMap - wZoomEnvironment, 0,
    386         1504 + wZoomEnvironment * byte(IsPort), 112 * (ZoomArea - 3),
     386        1504 + wZoomEnvironment * Byte(IsPort), 112 * (ZoomArea - 3),
    387387        wZoomEnvironment, hZoomMap);
    388388    end;
     
    392392procedure TCityDlg.OffscreenPaint;
    393393
    394   procedure FillBar(x, y, pos, Growth, max, Kind: integer;
    395     IndicateComplete: boolean);
     394  procedure FillBar(X, Y, Pos, Growth, Max, Kind: Integer;
     395    IndicateComplete: Boolean);
    396396  begin
    397397    BarTex.Assign(MainTexture);
     
    400400      BarTex.ColorBevelShade := BarTex.ColorBevelLight;
    401401    end;
    402     PaintRelativeProgressBar(offscreen.Canvas, Kind, x - 3, y, wBar - 4, pos,
    403       Growth, max, IndicateComplete, BarTex);
    404   end;
    405 
    406   procedure PaintResources(x, y, Loc: integer; Add4Happy: boolean);
     402    PaintRelativeProgressBar(Offscreen.Canvas, Kind, X - 3, Y, wBar - 4, Pos,
     403      Growth, Max, IndicateComplete, BarTex);
     404  end;
     405
     406  procedure PaintResources(X, Y, Loc: Integer; Add4Happy: Boolean);
    407407  var
    408     d, i, Total, xGr, yGr: integer;
     408    D, I, Total, xGr, yGr: Integer;
    409409    TileInfo: TTileInfo;
    410     rare: boolean;
     410    rare: Boolean;
    411411  begin
    412412    with AreaMap do begin
    413     if Server(sGetCityTileInfo, me, Loc, TileInfo) <> eOk then
    414     begin
    415       assert(cix < 0);
    416       exit
     413    if Server(sGetCityTileInfo, Me, Loc, TileInfo) <> eOk then
     414    begin
     415      Assert(cix < 0);
     416      Exit
    417417    end;
    418418    Total := TileInfo.Food + TileInfo.Prod + TileInfo.Trade;
    419419    rare := MyMap[Loc] and $06000000 > 0;
    420420    if rare then
    421       inc(Total);
     421      Inc(Total);
    422422    if Add4Happy then
    423       inc(Total, 4);
     423      Inc(Total, 4);
    424424    if Total > 1 then
    425       d := (xxt - 11) div (Total - 1);
    426     if d < 1 then
    427       d := 1;
    428     if d > 4 then
    429       d := 4;
    430     for i := 0 to Total - 1 do
     425      D := (xxt - 11) div (Total - 1);
     426    if D < 1 then
     427      D := 1;
     428    if D > 4 then
     429      D := 4;
     430    for I := 0 to Total - 1 do
    431431    begin
    432432      yGr := 115;
    433       if Add4Happy and (i >= Total - 4) then
     433      if Add4Happy and (I >= Total - 4) then
    434434      begin
    435435        xGr := 132;
    436436        yGr := 126
    437437      end
    438       else if rare and (i = Total - 1) then
     438      else if rare and (I = Total - 1) then
    439439        xGr := 66 + 110
    440       else if i >= TileInfo.Food + TileInfo.Prod then
     440      else if I >= TileInfo.Food + TileInfo.Prod then
    441441        xGr := 66 + 44
    442       else if i >= TileInfo.Prod then
     442      else if I >= TileInfo.Prod then
    443443        xGr := 66
    444444      else
    445445        xGr := 66 + 22;
    446       Sprite(offscreen, HGrSystem, x + xxt - 5 + d * (2 * i + 1 - Total),
    447         y + yyt - 5, 10, 10, xGr, yGr);
     446      Sprite(Offscreen, HGrSystem, X + xxt - 5 + D * (2 * I + 1 - Total),
     447        Y + yyt - 5, 10, 10, xGr, yGr);
    448448    end;
    449449    end;
    450450  end;
    451451var
    452   line, MessageCount: integer;
    453 
    454   procedure CheckMessage(Flag: integer);
     452  Line, MessageCount: Integer;
     453
     454  procedure CheckMessage(Flag: Integer);
    455455  var
    456     i, test: integer;
    457     s: string;
     456    I, Test: Integer;
     457    S: string;
    458458  begin
    459459    if Happened and Flag <> 0 then
    460460    begin
    461       i := 0;
    462       test := 1;
    463       while test < Flag do
     461      I := 0;
     462      Test := 1;
     463      while Test < Flag do
    464464      begin
    465         inc(i);
    466         inc(test, test)
     465        Inc(I);
     466        Inc(Test, Test);
    467467      end;
    468468
    469469      if AllowChange and (Sounds <> nil) and (OpenSoundEvent = -1) then
    470470      begin
    471         s := CityEventSoundItem[i];
    472         if s <> '' then
    473           s := Sounds.Lookup(s);
    474         if (Flag = chProduction) or (s <> '') and (s[1] <> '*') and (s[1] <> '[')
     471        S := CityEventSoundItem[I];
     472        if S <> '' then
     473          S := Sounds.Lookup(S);
     474        if (Flag = chProduction) or (S <> '') and (S[1] <> '*') and (S[1] <> '[')
    475475        then
    476           OpenSoundEvent := i
     476          OpenSoundEvent := I;
    477477      end;
    478478
    479       s := CityEventName(i);
     479      S := CityEventName(I);
    480480      { if Flag=chNoGrowthWarning then
    481         if c.Built[imAqueduct]=0 then
    482         s:=Format(s,[Phrases.Lookup('IMPROVEMENTS',imAqueduct)])
    483         else s:=Format(s,[Phrases.Lookup('IMPROVEMENTS',imSewer)]); }
    484       RisedTextOut(offscreen.Canvas, xmOpt + 40, ymOpt - 1 - 8 * MessageCount +
    485         16 * line, s);
    486       inc(line)
     481        if C.Built[imAqueduct]=0 then
     482        S:=Format(S,[Phrases.Lookup('IMPROVEMENTS',imAqueduct)])
     483        else S:=Format(S,[Phrases.Lookup('IMPROVEMENTS',imSewer)]); }
     484      RisedTextOut(Offscreen.Canvas, xmOpt + 40, ymOpt - 1 - 8 * MessageCount +
     485        16 * Line, S);
     486      Inc(Line);
    487487    end;
    488488  end;
    489489
    490490var
    491   x, y, xGr, i, j, iix, d, dx, dy, PrCost, Cnt, Loc1, FreeSupp, Paintiix,
     491  X, Y, xGr, I, J, iix, D, dx, dy, PrCost, Cnt, Loc1, FreeSupp, Paintiix,
    492492    HappyGain, OptiType, rx, ry, TrueFood, TrueProd, TruePoll: Integer;
    493493  av: Integer;
    494   PrName, s: string;
     494  PrName, S: string;
    495495  UnitInfo: TUnitInfo;
    496496  UnitReport: TUnitReport;
     
    499499  inherited;
    500500  if cix >= 0 then
    501     c := MyCity[cix];
     501    C := MyCity[cix];
    502502  Report.HypoTiles := -1;
    503503  Report.HypoTaxRate := -1;
    504504  Report.HypoLuxuryRate := -1;
    505505  if cix >= 0 then
    506     Server(sGetCityReportNew, me, cix, Report) // own city
     506    Server(sGetCityReportNew, Me, cix, Report) // own city
    507507  else
    508     Server(sGetEnemyCityReportNew, me, cLoc, Report); // enemy city
    509   TrueFood := c.Food;
    510   TrueProd := c.Prod;
    511   TruePoll := c.Pollution;
     508    Server(sGetEnemyCityReportNew, Me, cLoc, Report); // enemy city
     509  TrueFood := C.Food;
     510  TrueProd := C.Prod;
     511  TruePoll := C.Pollution;
    512512  if Supervising or (cix < 0) then
    513513  begin // normalize city from after-turn state
     
    522522      TruePoll := 0; // shouldn't happen
    523523  end;
    524   IsCityAlive := (cGov <> gAnarchy) and (c.Flags and chCaptured = 0);
     524  IsCityAlive := (cGov <> gAnarchy) and (C.Flags and chCaptured = 0);
    525525  if not IsCityAlive then
    526     Report.Working := c.Size;
     526    Report.Working := C.Size;
    527527
    528528  RedTex.Assign(MainTexture);
     
    532532  RedTex.ColorTextShade := $0000FF;
    533533
    534   BitBltCanvas(offscreen.Canvas, 0, 0, 640, 480, Back.Canvas, 0, 0);
     534  BitBltCanvas(Offscreen.Canvas, 0, 0, 640, 480, Back.Canvas, 0, 0);
    535535
    536536  Offscreen.Canvas.Font.Assign(UniFont[ftCaption]);
     
    544544    Brush.style := bsClear;
    545545    Font.Color := $000000;
    546     s := IntToStr(c.Size);
    547     TextOut(8 + 14 - TextWidth(s) div 2, 7, s);
     546    S := IntToStr(C.Size);
     547    TextOut(8 + 14 - TextWidth(S) div 2, 7, S);
    548548  end;
    549549  Offscreen.Canvas.Font.Assign(UniFont[ftSmall]);
     
    553553    MakeRed(Offscreen, 18, 280, 298, 40);
    554554    if cGov = gAnarchy then
    555       s := Phrases.Lookup('GOVERNMENT', gAnarchy)
     555      S := Phrases.Lookup('GOVERNMENT', gAnarchy)
    556556    else { if c.Flags and chCaptured<>0 then }
    557       s := Phrases.Lookup('CITYEVENTS', 14);
    558     RisedTextOut(offscreen.Canvas, 167 - BiColorTextWidth(offscreen.Canvas, s)
    559       div 2, ymOpt - 9, s);
     557      S := Phrases.Lookup('CITYEVENTS', 14);
     558    RisedTextOut(Offscreen.Canvas, 167 - BiColorTextWidth(Offscreen.Canvas, S)
     559      div 2, ymOpt - 9, S);
    560560  end
    561561  else if AllowChange then
    562562  begin
    563     OptiType := c.Status shr 4 and $0F;
    564     Sprite(offscreen, HGrSystem2, xmOpt - 32, ymOpt - 32, 64, 64,
     563    OptiType := C.Status shr 4 and $0F;
     564    Sprite(Offscreen, HGrSystem2, xmOpt - 32, ymOpt - 32, 64, 64,
    565565      1 + OptiType mod 3 * 64, 217 + OptiType div 3 * 64);
    566566
    567567    { display messages now }
    568568    MessageCount := 0;
    569     for i := 0 to 31 do
    570       if Happened and ($FFFFFFFF - chCaptured) and (1 shl i) <> 0 then
    571         inc(MessageCount);
     569    for I := 0 to 31 do
     570      if Happened and ($FFFFFFFF - chCaptured) and (1 shl I) <> 0 then
     571        Inc(MessageCount);
    572572    if MessageCount > 3 then
    573573      MessageCount := 3;
    574574    if MessageCount > 0 then
    575575    begin
    576       MakeBlue(offscreen, 74, 280, 242, 40);
    577       line := 0;
    578       for i := 0 to nCityEventPriority - 1 do
    579         if line < MessageCount then
    580           CheckMessage(CityEventPriority[i]);
     576      MakeBlue(Offscreen, 74, 280, 242, 40);
     577      Line := 0;
     578      for I := 0 to nCityEventPriority - 1 do
     579        if Line < MessageCount then
     580          CheckMessage(CityEventPriority[I]);
    581581    end
    582582    else
    583583    begin
    584       s := Phrases.Lookup('CITYMANAGETYPE', OptiType);
    585       j := pos('\', s);
    586       if j = 0 then
    587         LoweredTextout(offscreen.Canvas, -1, MainTexture, xmOpt + 40,
    588           ymOpt - 9, s)
     584      S := Phrases.Lookup('CITYMANAGETYPE', OptiType);
     585      J := Pos('\', S);
     586      if J = 0 then
     587        LoweredTextout(Offscreen.Canvas, -1, MainTexture, xmOpt + 40,
     588          ymOpt - 9, S)
    589589      else
    590590      begin
    591         LoweredTextout(offscreen.Canvas, -1, MainTexture, xmOpt + 40,
    592           ymOpt - 17, copy(s, 1, j - 1));
    593         LoweredTextout(offscreen.Canvas, -1, MainTexture, xmOpt + 40, ymOpt - 1,
    594           copy(s, j + 1, 255));
     591        LoweredTextout(Offscreen.Canvas, -1, MainTexture, xmOpt + 40,
     592          ymOpt - 17, Copy(S, 1, J - 1));
     593        LoweredTextout(Offscreen.Canvas, -1, MainTexture, xmOpt + 40, ymOpt - 1,
     594          Copy(S, J + 1, 255));
    595595      end;
    596596    end;
     
    602602    AreaMap.Paint(xmArea - xxt * 2 * rx, ymArea - yyt * 2 * ry - 3 * yyt,
    603603      dLoc(cLoc, -2 * rx + 1, -2 * ry - 1), 4 * rx - 1, 4 * ry + 1, cLoc, cOwner,
    604       false, AllowChange and IsCityAlive and
    605       (c.Status and csResourceWeightsMask = 0));
    606     BitBltCanvas(offscreen.Canvas, xmArea + 102, 42, 90, 33, Back.Canvas,
     604      False, AllowChange and IsCityAlive and
     605      (C.Status and csResourceWeightsMask = 0));
     606    BitBltCanvas(Offscreen.Canvas, xmArea + 102, 42, 90, 33, Back.Canvas,
    607607      xmArea + 102, 42);
    608608
     
    616616              ((Loc1 < 0) or (Loc1 >= G.lx * G.ly) or (MyMap[Loc1] and fCity = 0))
    617617            then
    618               Sprite(offscreen, HGrTerrain, xmArea - xxt + xxt * dx,
     618              Sprite(Offscreen, HGrTerrain, xmArea - xxt + xxt * dx,
    619619                ymArea - yyt + yyt * dy, xxt * 2, yyt * 2, 1 + 5 * (xxt * 2 + 1),
    620620                1 + yyt + 15 * (yyt * 3 + 1));
    621             if (1 shl ((dy + 3) shl 2 + (dx + 3) shr 1) and c.Tiles <> 0) then
     621            if (1 shl ((dy + 3) shl 2 + (dx + 3) shr 1) and C.Tiles <> 0) then
    622622              PaintResources(xmArea - xxt + xxt * dx, ymArea - yyt + yyt * dy,
    623623                Loc1, (dx = 0) and (dy = 0));
     
    626626
    627627  if Report.Working > 1 then
    628     d := (xService - (xmArea - 192) - 8 - 32) div (Report.Working - 1);
    629   if d > 28 then
    630     d := 28;
    631   for i := Report.Working - 1 downto 0 do
     628    D := (xService - (xmArea - 192) - 8 - 32) div (Report.Working - 1);
     629  if D > 28 then
     630    D := 28;
     631  for I := Report.Working - 1 downto 0 do
    632632  begin
    633633    if IsCityAlive then
     
    635635    else
    636636      xGr := 141;
    637     BitBltCanvas(offscreen.Canvas, xmArea - 192 + 5 + i * d, ymArea - 96 - 29,
     637    BitBltCanvas(Offscreen.Canvas, xmArea - 192 + 5 + I * D, ymArea - 96 - 29,
    638638      27, 30, HGrSystem.Mask.Canvas, xGr, 171, SRCAND); { shadow }
    639     Sprite(offscreen, HGrSystem, xmArea - 192 + 4 + i * d, ymArea - 96 - 30, 27,
     639    Sprite(Offscreen, HGrSystem, xmArea - 192 + 4 + I * D, ymArea - 96 - 30, 27,
    640640      30, xGr, 171);
    641641  end;
    642   if c.Size - Report.Working > 1 then
    643     d := (xmArea + 192 - xService - 32) div (c.Size - Report.Working - 1);
    644   if d > 28 then
    645     d := 28;
    646   for i := 0 to c.Size - Report.Working - 1 do
     642  if C.Size - Report.Working > 1 then
     643    D := (xmArea + 192 - xService - 32) div (C.Size - Report.Working - 1);
     644  if D > 28 then
     645    D := 28;
     646  for I := 0 to C.Size - Report.Working - 1 do
    647647  begin
    648648    xGr := 1 + 112;
    649     BitBltCanvas(offscreen.Canvas, xmArea + 192 - 27 + 1 - i * d, 29 + 1, 27,
     649    BitBltCanvas(Offscreen.Canvas, xmArea + 192 - 27 + 1 - I * D, 29 + 1, 27,
    650650      30, HGrSystem.Mask.Canvas, xGr, 171, SRCAND); { shadow }
    651     Sprite(offscreen, HGrSystem, xmArea + 192 - 27 - i * d, 29, 27, 30,
     651    Sprite(Offscreen, HGrSystem, xmArea + 192 - 27 - I * D, 29, 27, 30,
    652652      xGr, 171);
    653     Sprite(offscreen, HGrSystem, xmArea + 192 - 27 + 4 - i * d, 29 + 32, 10,
     653    Sprite(Offscreen, HGrSystem, xmArea + 192 - 27 + 4 - I * D, 29 + 32, 10,
    654654      10, 121, 126);
    655     Sprite(offscreen, HGrSystem, xmArea + 192 - 27 + 13 - i * d, 29 + 32, 10,
     655    Sprite(Offscreen, HGrSystem, xmArea + 192 - 27 + 13 - I * D, 29 + 32, 10,
    656656      10, 121, 126);
    657657    // Sprite(offscreen,HGrSystem,xmArea+192-31+18-i*d,ymArea-96-80+32,10,10,88,115);
    658658  end;
    659659
    660   if c.Project and cpImp = 0 then
    661     PrName := Tribe[cOwner].ModelName[c.Project and cpIndex]
     660  if C.Project and cpImp = 0 then
     661    PrName := Tribe[cOwner].ModelName[C.Project and cpIndex]
    662662  else
    663     PrName := Phrases.Lookup('IMPROVEMENTS', c.Project and cpIndex);
     663    PrName := Phrases.Lookup('IMPROVEMENTS', C.Project and cpIndex);
    664664  PrCost := Report.ProjectCost;
    665665
     
    668668  begin
    669669    if cGov = gFundamentalism then
    670       CountBar(offscreen, xHapp, yHapp + dyBar, wBar, 17,
     670      CountBar(Offscreen, xHapp, yHapp + dyBar, wBar, 17,
    671671        Phrases.Lookup('FAITH'), Report.CollectedControl, MainTexture)
    672672    else
    673673    begin
    674       CountBar(offscreen, xHapp, yHapp + dyBar, wBar, 17,
     674      CountBar(Offscreen, xHapp, yHapp + dyBar, wBar, 17,
    675675        Phrases.Lookup('HAPPINESS'), Report.Morale, MainTexture);
    676       CountBar(offscreen, xHapp, yHapp + 2 * dyBar, wBar, 16,
     676      CountBar(Offscreen, xHapp, yHapp + 2 * dyBar, wBar, 16,
    677677        Phrases.Lookup('CONTROL'), Report.CollectedControl, MainTexture);
    678678    end;
    679     CountBar(offscreen, xHapp, yHapp, wBar, 8, Phrases.Lookup('LUX'),
     679    CountBar(Offscreen, xHapp, yHapp, wBar, 8, Phrases.Lookup('LUX'),
    680680      Report.Luxury, MainTexture);
    681     CountBar(offscreen, xHapp + dxBar, yHapp, wBar, 19,
     681    CountBar(Offscreen, xHapp + dxBar, yHapp, wBar, 19,
    682682      Phrases.Lookup('UNREST'), 2 * Report.Deployed, MainTexture);
    683     CountBar(offscreen, xHapp + dxBar, yHapp + dyBar, wBar, 17,
    684       Phrases.Lookup('HAPPINESSDEMAND'), c.Size, MainTexture);
     683    CountBar(Offscreen, xHapp + dxBar, yHapp + dyBar, wBar, 17,
     684      Phrases.Lookup('HAPPINESSDEMAND'), C.Size, MainTexture);
    685685    if Report.HappinessBalance >= 0 then
    686       CountBar(offscreen, xHapp + dxBar, yHapp + 2 * dyBar, wBar, 17,
     686      CountBar(Offscreen, xHapp + dxBar, yHapp + 2 * dyBar, wBar, 17,
    687687        Phrases.Lookup('HAPPINESSPLUS'), Report.HappinessBalance, MainTexture)
    688688    else
    689689    begin
    690690      MakeRed(Offscreen, xHapp + dxBar - 6, yHapp + 2 * dyBar, wBar + 10, 38);
    691       CountBar(offscreen, xHapp + dxBar, yHapp + 2 * dyBar, wBar, 18,
     691      CountBar(Offscreen, xHapp + dxBar, yHapp + 2 * dyBar, wBar, 18,
    692692        Phrases.Lookup('LACK'), -Report.HappinessBalance, RedTex);
    693693    end;
     
    697697  if IsCityAlive then
    698698  begin
    699     CountBar(offscreen, xFood, yFood + dyBar div 2, wBar, 0,
     699    CountBar(Offscreen, xFood, yFood + dyBar div 2, wBar, 0,
    700700      Phrases.Lookup('FOOD'), Report.CollectedFood, MainTexture);
    701     CountBar(offscreen, xFood + dxBar, yFood + dyBar, wBar, 0,
    702       Phrases.Lookup('DEMAND'), 2 * c.Size, MainTexture);
    703     CountBar(offscreen, xFood + dxBar, yFood, wBar, 0,
     701    CountBar(Offscreen, xFood + dxBar, yFood + dyBar, wBar, 0,
     702      Phrases.Lookup('DEMAND'), 2 * C.Size, MainTexture);
     703    CountBar(Offscreen, xFood + dxBar, yFood, wBar, 0,
    704704      Phrases.Lookup('SUPPORT'), Report.FoodSupport, MainTexture);
    705705    if Report.FoodSurplus >= 0 then
    706       if (cGov = gFuture) or (c.Size >= NeedAqueductSize) and
     706      if (cGov = gFuture) or (C.Size >= NeedAqueductSize) and
    707707        (Report.FoodSurplus < 2) then
    708         CountBar(offscreen, xFood + dxBar, yFood + 2 * dyBar, wBar, 6,
     708        CountBar(Offscreen, xFood + dxBar, yFood + 2 * dyBar, wBar, 6,
    709709          Phrases.Lookup('PROFIT'), Report.FoodSurplus, MainTexture)
    710710      else
    711         CountBar(offscreen, xFood + dxBar, yFood + 2 * dyBar, wBar, 0,
     711        CountBar(Offscreen, xFood + dxBar, yFood + 2 * dyBar, wBar, 0,
    712712          Phrases.Lookup('SURPLUS'), Report.FoodSurplus, MainTexture)
    713713    else
    714714    begin
    715715      MakeRed(Offscreen, xFood + dxBar - 6, yFood + 2 * dyBar, wBar + 10, 38);
    716       CountBar(offscreen, xFood + dxBar, yFood + 2 * dyBar, wBar, 1,
     716      CountBar(Offscreen, xFood + dxBar, yFood + 2 * dyBar, wBar, 1,
    717717        Phrases.Lookup('LACK'), -Report.FoodSurplus, RedTex);
    718718    end;
    719719  end;
    720   CanGrow := (c.Size < MaxCitySize) and (cGov <> gFuture) and
    721     (Report.FoodSurplus > 0) and ((c.Size < NeedAqueductSize) or
    722     (c.Built[imAqueduct] = 1) and (c.Size < NeedSewerSize) or
    723     (c.Built[imSewer] = 1));
     720  CanGrow := (C.Size < MaxCitySize) and (cGov <> gFuture) and
     721    (Report.FoodSurplus > 0) and ((C.Size < NeedAqueductSize) or
     722    (C.Built[imAqueduct] = 1) and (C.Size < NeedSewerSize) or
     723    (C.Built[imSewer] = 1));
    724724  FillBar(xFood + 3, yFood + 102, TrueFood,
    725     CutCityFoodSurplus(Report.FoodSurplus, IsCityAlive, cGov, c.Size),
     725    CutCityFoodSurplus(Report.FoodSurplus, IsCityAlive, cGov, C.Size),
    726726    Report.Storage, 1, CanGrow);
    727   LoweredTextout(offscreen.Canvas, -1, MainTexture, xFood + 3 - 5,
     727  LoweredTextout(Offscreen.Canvas, -1, MainTexture, xFood + 3 - 5,
    728728    yFood + 102 - 20, Format('%d/%d', [TrueFood, Report.Storage]));
    729   LoweredTextout(offscreen.Canvas, -1, MainTexture, xFood - 2, yFood + 66,
     729  LoweredTextout(Offscreen.Canvas, -1, MainTexture, xFood - 2, yFood + 66,
    730730    Phrases.Lookup('STORAGE'));
    731731
     
    733733  if IsCityAlive then
    734734  begin
    735     CountBar(offscreen, xProd, yProd, wBar, 2, Phrases.Lookup('MATERIAL'),
     735    CountBar(Offscreen, xProd, yProd, wBar, 2, Phrases.Lookup('MATERIAL'),
    736736      Report.CollectedMaterial, MainTexture);
    737     CountBar(offscreen, xProd + dxBar, yProd, wBar, 2,
     737    CountBar(Offscreen, xProd + dxBar, yProd, wBar, 2,
    738738      Phrases.Lookup('SUPPORT'), Report.MaterialSupport, MainTexture);
    739739    if Report.Production >= 0 then
    740       if c.Project and (cpImp + cpIndex) = cpImp + imTrGoods then
    741         CountBar(offscreen, xProd + dxBar, yProd + dyBar + 16, wBar, 6,
     740      if C.Project and (cpImp + cpIndex) = cpImp + imTrGoods then
     741        CountBar(Offscreen, xProd + dxBar, yProd + dyBar + 16, wBar, 6,
    742742          Phrases.Lookup('PROFIT'), Report.Production, MainTexture)
    743743      else
    744         CountBar(offscreen, xProd + dxBar, yProd + dyBar + 16, wBar, 2,
     744        CountBar(Offscreen, xProd + dxBar, yProd + dyBar + 16, wBar, 2,
    745745          Phrases.Lookup('PROD'), Report.Production, MainTexture)
    746746    else
    747747    begin
    748748      MakeRed(Offscreen, xProd + dxBar - 6, yProd + dyBar + 17, wBar + 10, 38);
    749       CountBar(offscreen, xProd + dxBar, yProd + dyBar + 16, wBar, 3,
     749      CountBar(Offscreen, xProd + dxBar, yProd + dyBar + 16, wBar, 3,
    750750        Phrases.Lookup('LACK'), -Report.Production, RedTex);
    751751    end;
    752752  end;
    753   if c.Project and (cpImp + cpIndex) <> cpImp + imTrGoods then
    754     with offscreen.Canvas do
    755     begin
    756       i := Report.Production;
    757       if (i < 0) or not IsCityAlive then
    758         i := 0;
    759       FillBar(xProd + 3, yProd + 16 + 63, TrueProd, i, PrCost, 4, true);
    760       LoweredTextout(offscreen.Canvas, -1, MainTexture, xProd + 3 - 5,
     753  if C.Project and (cpImp + cpIndex) <> cpImp + imTrGoods then
     754    with Offscreen.Canvas do
     755    begin
     756      I := Report.Production;
     757      if (I < 0) or not IsCityAlive then
     758        I := 0;
     759      FillBar(xProd + 3, yProd + 16 + 63, TrueProd, I, PrCost, 4, True);
     760      LoweredTextout(Offscreen.Canvas, -1, MainTexture, xProd + 3 - 5,
    761761        yProd + 16 + 43, Format('%d/%d', [TrueProd, PrCost]));
    762       if BiColorTextWidth(offscreen.Canvas, PrName) > wBar + dxBar then
     762      if BiColorTextWidth(Offscreen.Canvas, PrName) > wBar + dxBar then
    763763      begin
    764764        repeat
    765           Delete(PrName, length(PrName), 1)
    766         until BiColorTextWidth(offscreen.Canvas, PrName) <= wBar + dxBar;
     765          Delete(PrName, Length(PrName), 1)
     766        until BiColorTextWidth(Offscreen.Canvas, PrName) <= wBar + dxBar;
    767767        PrName := PrName + '.'
    768768      end;
    769769    end;
    770   RisedTextOut(offscreen.Canvas, xProd - 2, yProd + 36, PrName);
     770  RisedTextOut(Offscreen.Canvas, xProd - 2, yProd + 36, PrName);
    771771
    772772  // pollution section
     
    774774  begin
    775775    FillBar(xPoll + 3, yPoll + 20, TruePoll, Report.AddPollution,
    776       MaxPollution, 3, true);
    777     RisedTextOut(offscreen.Canvas, xPoll + 3 - 5, yPoll + 20 - 20,
     776      MaxPollution, 3, True);
     777    RisedTextOut(Offscreen.Canvas, xPoll + 3 - 5, yPoll + 20 - 20,
    778778      Phrases.Lookup('POLL'));
    779779  end;
     
    782782  if IsCityAlive and (Report.CollectedTrade > 0) then
    783783  begin
    784     CountBar(offscreen, xTrade, yTrade + dyBar div 2, wBar, 4,
     784    CountBar(Offscreen, xTrade, yTrade + dyBar div 2, wBar, 4,
    785785      Phrases.Lookup('TRADE'), Report.CollectedTrade, MainTexture);
    786     CountBar(offscreen, xTrade + dxBar, yTrade + 2 * dyBar, wBar, 5,
     786    CountBar(Offscreen, xTrade + dxBar, yTrade + 2 * dyBar, wBar, 5,
    787787      Phrases.Lookup('CORR'), Report.Corruption, MainTexture);
    788     CountBar(offscreen, xTrade + dxBar, yTrade, wBar, 6, Phrases.Lookup('TAX'),
     788    CountBar(Offscreen, xTrade + dxBar, yTrade, wBar, 6, Phrases.Lookup('TAX'),
    789789      Report.Tax, MainTexture);
    790     CountBar(offscreen, xTrade + dxBar, yTrade + dyBar, wBar, 12,
     790    CountBar(Offscreen, xTrade + dxBar, yTrade + dyBar, wBar, 12,
    791791      Phrases.Lookup('SCIENCE'), Report.Science, MainTexture);
    792792  end;
    793793
    794794  // small map
    795   BitBltCanvas(offscreen.Canvas, xSmallMap, ySmallMap, wSmallMap, hSmallMap,
     795  BitBltCanvas(Offscreen.Canvas, xSmallMap, ySmallMap, wSmallMap, hSmallMap,
    796796    SmallCityMap.Canvas, 0, 0);
    797797  if SmallMapMode = smImprovements then
    798     Frame(offscreen.Canvas, xSmallMap + 48 * (ZoomArea div 3),
     798    Frame(Offscreen.Canvas, xSmallMap + 48 * (ZoomArea div 3),
    799799      ySmallMap + 24 * (ZoomArea mod 3), xSmallMap + 48 * (ZoomArea div 3) + 49,
    800800      ySmallMap + 24 * (ZoomArea mod 3) + 25, MainTexture.ColorMark,
    801801      MainTexture.ColorMark);
    802   Frame(offscreen.Canvas, xSmallMap - 1, ySmallMap - 1, xSmallMap + wSmallMap,
     802  Frame(Offscreen.Canvas, xSmallMap - 1, ySmallMap - 1, xSmallMap + wSmallMap,
    803803    ySmallMap + hSmallMap, $B0B0B0, $FFFFFF);
    804   RFrame(offscreen.Canvas, xSmallMap - 2, ySmallMap - 2, xSmallMap + wSmallMap +
     804  RFrame(Offscreen.Canvas, xSmallMap - 2, ySmallMap - 2, xSmallMap + wSmallMap +
    805805    1, ySmallMap + hSmallMap + 1, $FFFFFF, $B0B0B0);
    806806
    807   Frame(offscreen.Canvas, xSupport - 1, ySupport - 1, xSupport + wSupport,
     807  Frame(Offscreen.Canvas, xSupport - 1, ySupport - 1, xSupport + wSupport,
    808808    ySupport + hSupport, $B0B0B0, $FFFFFF);
    809   RFrame(offscreen.Canvas, xSupport - 2, ySupport - 2, xSupport + wSupport + 1,
     809  RFrame(Offscreen.Canvas, xSupport - 2, ySupport - 2, xSupport + wSupport + 1,
    810810    ySupport + hSupport + 1, $FFFFFF, $B0B0B0);
    811   x := xSupport + wSupport div 2;
    812   y := ySupport + hSupport div 2;
     811  X := xSupport + wSupport div 2;
     812  Y := ySupport + hSupport div 2;
    813813  if SmallMapMode = smSupportedUnits then
    814814  begin
    815     offscreen.Canvas.brush.Color := MainTexture.ColorMark;
    816     offscreen.Canvas.FillRect(Rect(x - 27, y - 6, x + 27, y + 6));
    817     offscreen.Canvas.brush.style := bsClear;
    818   end;
    819   Sprite(offscreen, HGrSystem, x - 16, y - 5, 10, 10, 88, 115);
    820   Sprite(offscreen, HGrSystem, x - 5, y - 5, 10, 10, 66, 115);
    821   Sprite(offscreen, HGrSystem, x + 6, y - 5, 10, 10, 154, 126);
    822 
    823   BitBltCanvas(offscreen.Canvas, xZoomMap, yZoomMap, wZoomMap, hZoomMap,
     815    Offscreen.Canvas.Brush.Color := MainTexture.ColorMark;
     816    Offscreen.Canvas.FillRect(Rect(X - 27, Y - 6, X + 27, Y + 6));
     817    Offscreen.Canvas.Brush.style := bsClear;
     818  end;
     819  Sprite(Offscreen, HGrSystem, X - 16, Y - 5, 10, 10, 88, 115);
     820  Sprite(Offscreen, HGrSystem, X - 5, Y - 5, 10, 10, 66, 115);
     821  Sprite(Offscreen, HGrSystem, X + 6, Y - 5, 10, 10, 154, 126);
     822
     823  BitBltCanvas(Offscreen.Canvas, xZoomMap, yZoomMap, wZoomMap, hZoomMap,
    824824    ZoomCityMap.Canvas, 0, 0);
    825825
    826   for i := 0 to 5 do
    827     imix[i] := -1;
     826  for I := 0 to 5 do
     827    imix[I] := -1;
    828828  if SmallMapMode = smImprovements then
    829829  begin
     
    832832      Cnt := 0;
    833833      for iix := 0 to nImp - 1 do
    834         if ((iix < nWonder) or (ImpPosition[iix] < 0)) and (c.Built[iix] > 0) then
     834        if ((iix < nWonder) or (ImpPosition[iix] < 0)) and (C.Built[iix] > 0) then
    835835        begin
    836           i := Cnt - Page * 6;
    837           if (i >= 0) and (i < 6) then
    838             imix[i] := iix;
    839           inc(Cnt);
     836          I := Cnt - Page * 6;
     837          if (I >= 0) and (I < 6) then
     838            imix[I] := iix;
     839          Inc(Cnt);
    840840        end;
    841841      PageCount := (Cnt + 5) div 6;
     
    845845      for iix := nWonder to nImp - 1 do
    846846      begin
    847         i := ImpPosition[iix] - 6 * ZoomArea;
    848         if (i >= 0) and (i < 6) and (c.Built[iix] > 0) then
    849           imix[i] := iix;
     847        I := ImpPosition[iix] - 6 * ZoomArea;
     848        if (I >= 0) and (I < 6) and (C.Built[iix] > 0) then
     849          imix[I] := iix;
    850850      end;
    851851      PageCount := 0;
    852852    end;
    853     for i := 0 to 5 do
    854       if imix[i] >= 0 then
     853    for I := 0 to 5 do
     854      if imix[I] >= 0 then
    855855      begin
    856         iix := imix[i];
    857         x := xZoomMap + 14 + 72 * (i mod 3);
    858         y := yZoomMap + 14 + 56 * (i div 3);
    859         ImpImage(offscreen.Canvas, x, y, iix, cGov, AllowChange and
     856        iix := imix[I];
     857        X := xZoomMap + 14 + 72 * (I mod 3);
     858        Y := yZoomMap + 14 + 56 * (I div 3);
     859        ImpImage(Offscreen.Canvas, X, Y, iix, cGov, AllowChange and
    860860          (ClientMode < scContact));
    861861        if IsCityAlive then
     
    863863          if iix = imColosseum then
    864864          begin
    865             Sprite(offscreen, HGrSystem, x + 46, y, 14, 14, 82, 100);
     865            Sprite(Offscreen, HGrSystem, X + 46, Y, 14, 14, 82, 100);
    866866          end
    867867          else
     
    881881            if HappyGain > 1 then
    882882            begin
    883               d := 30 div (HappyGain - 1);
    884               if d > 10 then
    885                 d := 10
     883              D := 30 div (HappyGain - 1);
     884              if D > 10 then
     885                D := 10
    886886            end;
    887             for j := 0 to HappyGain - 1 do
    888               Sprite(offscreen, HGrSystem, x + 50, y + d * j, 10, 10, 132, 126);
     887            for J := 0 to HappyGain - 1 do
     888              Sprite(Offscreen, HGrSystem, X + 50, Y + D * J, 10, 10, 132, 126);
    889889          end;
    890           for j := 0 to Imp[iix].Maint - 1 do
    891             Sprite(offscreen, HGrSystem, x - 4, y + 29 - 3 * j, 10, 10,
     890          for J := 0 to Imp[iix].Maint - 1 do
     891            Sprite(Offscreen, HGrSystem, X - 4, Y + 29 - 3 * J, 10, 10,
    892892              132, 115);
    893893        end
     
    920920  else { if SmallMapMode = smSupportedUnits then }
    921921  begin
    922     LoweredTextout(offscreen.Canvas, -1, MainTexture, xZoomMap + 6,
     922    LoweredTextout(Offscreen.Canvas, -1, MainTexture, xZoomMap + 6,
    923923      yZoomMap + 2, Phrases.Lookup('SUPUNITS'));
    924     FreeSupp := c.Size * SupportFree[cGov] shr 1;
     924    FreeSupp := C.Size * SupportFree[cGov] shr 1;
    925925    Cnt := 0;
    926     for i := 0 to MyRO.nUn - 1 do
    927       if (MyUn[i].Loc >= 0) and (MyUn[i].Home = cix) then
    928         with MyModel[MyUn[i].mix] do
     926    for I := 0 to MyRO.nUn - 1 do
     927      if (MyUn[I].Loc >= 0) and (MyUn[I].Home = cix) then
     928        with MyModel[MyUn[I].mix] do
    929929        begin
    930           Server(sGetUnitReport, me, i, UnitReport);
     930          Server(sGetUnitReport, Me, I, UnitReport);
    931931          if (Cnt >= 6 * Page) and (Cnt < 6 * (Page + 1)) then
    932932          begin // unit visible in display
    933             imix[Cnt - 6 * Page] := i;
    934             x := ((Cnt - 6 * Page) mod 3) * 64 + xZoomMap;
    935             y := ((Cnt - 6 * Page) div 3) * 52 + yZoomMap + 20;
    936             MakeUnitInfo(me, MyUn[i], UnitInfo);
    937             NoMap.SetOutput(offscreen);
    938             NoMap.PaintUnit(x, y, UnitInfo, MyUn[i].Status);
    939 
    940             for j := 0 to UnitReport.FoodSupport - 1 do
    941               Sprite(offscreen, HGrSystem, x + 38 + 11 * j, y + 40, 10,
     933            imix[Cnt - 6 * Page] := I;
     934            X := ((Cnt - 6 * Page) mod 3) * 64 + xZoomMap;
     935            Y := ((Cnt - 6 * Page) div 3) * 52 + yZoomMap + 20;
     936            MakeUnitInfo(Me, MyUn[I], UnitInfo);
     937            NoMap.SetOutput(Offscreen);
     938            NoMap.PaintUnit(X, Y, UnitInfo, MyUn[I].Status);
     939
     940            for J := 0 to UnitReport.FoodSupport - 1 do
     941              Sprite(Offscreen, HGrSystem, X + 38 + 11 * J, Y + 40, 10,
    942942                10, 66, 115);
    943             for j := 0 to UnitReport.ProdSupport - 1 do
     943            for J := 0 to UnitReport.ProdSupport - 1 do
    944944            begin
    945945              if (FreeSupp > 0) and
    946946                (UnitReport.ReportFlags and urfAlwaysSupport = 0) then
    947947              begin
    948                 Sprite(offscreen, HGrSystem, x + 16 - 11 * j, y + 40, 10,
     948                Sprite(Offscreen, HGrSystem, X + 16 - 11 * J, Y + 40, 10,
    949949                  10, 143, 115);
    950                 dec(FreeSupp);
     950                Dec(FreeSupp);
    951951              end
    952952              else
    953                 Sprite(offscreen, HGrSystem, x + 16 - 11 * j, y + 40, 10,
     953                Sprite(Offscreen, HGrSystem, X + 16 - 11 * J, Y + 40, 10,
    954954                  10, 88, 115);
    955955            end;
    956956            if UnitReport.ReportFlags and urfDeployed <> 0 then
    957               for j := 0 to 1 do
    958                 Sprite(offscreen, HGrSystem, x + 27 + 11 * j, y + 40, 10,
     957              for J := 0 to 1 do
     958                Sprite(Offscreen, HGrSystem, X + 27 + 11 * J, Y + 40, 10,
    959959                  10, 154, 126)
    960960          end // unit visible in display
     
    977977  begin
    978978    { display project now }
    979     DLine(offscreen.Canvas, xView + 9 + xSizeBig, xProd + 2 * wBar + 10,
     979    DLine(Offscreen.Canvas, xView + 9 + xSizeBig, xProd + 2 * wBar + 10,
    980980      yProd + dyBar + 16, $FFFFFF, $B0B0B0);
    981981    if ProdHint then
    982982    begin
    983       ScreenTools.Frame(offscreen.Canvas, xView + 9 - 1, yView + 5 - 1,
     983      ScreenTools.Frame(Offscreen.Canvas, xView + 9 - 1, yView + 5 - 1,
    984984        xView + 9 + xSizeBig, yView + 5 + ySizeBig, $B0B0B0, $FFFFFF);
    985       RFrame(offscreen.Canvas, xView + 9 - 2, yView + 5 - 2,
     985      RFrame(Offscreen.Canvas, xView + 9 - 2, yView + 5 - 2,
    986986        xView + 9 + xSizeBig + 1, yView + 5 + ySizeBig + 1, $FFFFFF, $B0B0B0);
    987       with offscreen.Canvas do
     987      with Offscreen.Canvas do
    988988      begin
    989         brush.Color := $000000;
     989        Brush.Color := $000000;
    990990        FillRect(Rect(xView + 9, yView + 5, xView + 1 + 72 - 8,
    991991          yView + 5 + 40));
    992         brush.style := bsClear;
     992        Brush.style := bsClear;
    993993      end;
    994994    end
    995     else if AllowChange and (c.Status and 7 <> 0) then
     995    else if AllowChange and (C.Status and 7 <> 0) then
    996996    begin // city type autobuild
    997       FrameImage(offscreen.Canvas, bigimp, xView + 9, yView + 5, xSizeBig,
    998         ySizeBig, (c.Status and 7 - 1 + 3) * xSizeBig, 0, (cix >= 0) and
     997      FrameImage(Offscreen.Canvas, bigimp, xView + 9, yView + 5, xSizeBig,
     998        ySizeBig, (C.Status and 7 - 1 + 3) * xSizeBig, 0, (cix >= 0) and
    999999        (ClientMode < scContact));
    10001000    end
    1001     else if c.Project and cpImp = 0 then
     1001    else if C.Project and cpImp = 0 then
    10021002    begin // project is unit
    1003       FrameImage(offscreen.Canvas, bigimp, xView + 9, yView + 5, xSizeBig,
     1003      FrameImage(Offscreen.Canvas, bigimp, xView + 9, yView + 5, xSizeBig,
    10041004        ySizeBig, 0, 0, AllowChange and (ClientMode < scContact));
    1005       with Tribe[cOwner].ModelPicture[c.Project and cpIndex] do
    1006         Sprite(offscreen, HGr, xView + 5, yView + 1, 64, 44,
     1005      with Tribe[cOwner].ModelPicture[C.Project and cpIndex] do
     1006        Sprite(Offscreen, HGr, xView + 5, yView + 1, 64, 44,
    10071007          pix mod 10 * 65 + 1, pix div 10 * 49 + 1);
    10081008    end
     
    10101010    begin // project is building
    10111011      if ProdHint then
    1012         Paintiix := c.Project0 and cpIndex
     1012        Paintiix := C.Project0 and cpIndex
    10131013      else
    1014         Paintiix := c.Project and cpIndex;
    1015       ImpImage(offscreen.Canvas, xView + 9, yView + 5, Paintiix, cGov,
     1014        Paintiix := C.Project and cpIndex;
     1015      ImpImage(Offscreen.Canvas, xView + 9, yView + 5, Paintiix, cGov,
    10161016        AllowChange and (ClientMode < scContact));
    10171017    end;
     
    10201020  if AllowChange and (ClientMode < scContact) then
    10211021  begin
    1022     i := Server(sBuyCityProject - sExecute, me, cix, nil^);
    1023     BuyBtn.Visible := (i = eOk) or (i = eViolation);
     1022    I := Server(sBuyCityProject - sExecute, Me, cix, nil^);
     1023    BuyBtn.Visible := (I = eOk) or (I = eViolation);
    10241024  end
    10251025  else
    1026     BuyBtn.Visible := false;
     1026    BuyBtn.Visible := False;
    10271027
    10281028  MarkUsedOffscreen(ClientWidth, ClientHeight);
     
    10311031procedure TCityDlg.FormShow(Sender: TObject);
    10321032var
    1033   dx, dy, Loc1: integer;
     1033  dx, dy, Loc1: Integer;
    10341034  GetCityData: TGetCityData;
    10351035begin
     
    10371037  if cix >= 0 then
    10381038  begin { own city }
    1039     c := MyCity[cix];
    1040     cOwner := me;
     1039    C := MyCity[cix];
     1040    cOwner := Me;
    10411041    cGov := MyRO.Government;
    10421042    ProdHint := (cGov <> gAnarchy) and
    10431043      (Happened and (chProduction or chFounded or chCaptured or
    10441044      chAllImpsMade) <> 0);
    1045     Server(sGetCityAreaInfo, me, cix, CityAreaInfo);
     1045    Server(sGetCityAreaInfo, Me, cix, CityAreaInfo);
    10461046    NextCityBtn.Visible := WindowMode = wmPersistent;
    10471047    PrevCityBtn.Visible := WindowMode = wmPersistent;
     
    10501050  begin
    10511051    SmallMapMode := smImprovements;
    1052     Server(sGetCity, me, cLoc, GetCityData);
    1053     c := GetCityData.c;
     1052    Server(sGetCity, Me, cLoc, GetCityData);
     1053    C := GetCityData.C;
    10541054    cOwner := GetCityData.Owner;
    10551055    cGov := MyRO.EnemyReport[cOwner].Government;
    1056     Happened := c.Flags and $7FFFFFFF;
    1057     ProdHint := false;
    1058     Server(sGetEnemyCityAreaInfo, me, cLoc, CityAreaInfo);
    1059 
    1060     if c.Project and cpImp = 0 then
     1056    Happened := C.Flags and $7FFFFFFF;
     1057    ProdHint := False;
     1058    Server(sGetEnemyCityAreaInfo, Me, cLoc, CityAreaInfo);
     1059
     1060    if C.Project and cpImp = 0 then
    10611061    begin
    10621062      emix := MyRO.nEnemyModel - 1;
    10631063      while (emix > 0) and ((MyRO.EnemyModel[emix].Owner <> cOwner) or
    1064         (integer(MyRO.EnemyModel[emix].mix) <> c.Project and cpIndex)) do
    1065         dec(emix);
    1066       if not Assigned(Tribe[cOwner].ModelPicture[c.Project and cpIndex].HGr) then
     1064        (Integer(MyRO.EnemyModel[emix].mix) <> C.Project and cpIndex)) do
     1065        Dec(emix);
     1066      if not Assigned(Tribe[cOwner].ModelPicture[C.Project and cpIndex].HGr) then
    10671067        InitEnemyModel(emix);
    10681068    end;
     
    10731073  Page := 0;
    10741074
    1075   if c.Size < 5 then
     1075  if C.Size < 5 then
    10761076    SizeClass := 0
    1077   else if c.Size < 9 then
     1077  else if C.Size < 9 then
    10781078    SizeClass := 1
    1079   else if c.Size < 13 then
     1079  else if C.Size < 13 then
    10801080    SizeClass := 2
    10811081  else
     
    11001100  end;
    11011101
    1102   Caption := CityName(c.ID);
     1102  Caption := CityName(C.ID);
    11031103
    11041104  InitSmallCityMap;
     
    11091109end;
    11101110
    1111 procedure TCityDlg.ShowNewContent(NewMode: TWindowMode; Loc: integer; ShowEvent: cardinal);
     1111procedure TCityDlg.ShowNewContent(NewMode: TWindowMode; Loc: Integer; ShowEvent: Cardinal);
    11121112begin
    11131113  if MyMap[Loc] and fOwned <> 0 then
     
    11151115    cix := MyRO.nCity - 1;
    11161116    while (cix >= 0) and (MyCity[cix].Loc <> Loc) do
    1117       dec(cix);
    1118     assert(cix >= 0);
     1117      Dec(cix);
     1118    Assert(cix >= 0);
    11191119    if (Optimize_cixTileChange >= 0) and
    11201120      (Optimize_TilesBeforeChange and not MyCity[Optimize_cixTileChange].Tiles
     
    11321132  else
    11331133    cix := -1;
    1134   AllowChange := not supervising and (cix >= 0);
     1134  AllowChange := not Supervising and (cix >= 0);
    11351135  cLoc := Loc;
    11361136  Happened := ShowEvent;
     
    11391139
    11401140procedure TCityDlg.FormMouseDown(Sender: TObject; Button: TMouseButton;
    1141   Shift: TShiftState; x, y: integer);
     1141  Shift: TShiftState; X, Y: Integer);
    11421142var
    1143   i, qx, qy, dx, dy, fix, NewTiles, Loc1, iix, SellResult: integer;
    1144   Rebuild: boolean;
    1145 begin
    1146   if (ssLeft in Shift) and (x >= xSmallMap) and (x < xSmallMap + wSmallMap) and
    1147     (y >= ySmallMap) and (y < ySmallMap + hSmallMap) then
     1143  I, qx, qy, dx, dy, fix, NewTiles, Loc1, iix, SellResult: Integer;
     1144  Rebuild: Boolean;
     1145begin
     1146  if (ssLeft in Shift) and (X >= xSmallMap) and (X < xSmallMap + wSmallMap) and
     1147    (Y >= ySmallMap) and (Y < ySmallMap + hSmallMap) then
    11481148  begin
    11491149    SmallMapMode := smImprovements;
    1150     ZoomArea := (y - ySmallMap) * 3 div hSmallMap + 3 *
    1151       ((x - xSmallMap) * 2 div wSmallMap);
     1150    ZoomArea := (Y - ySmallMap) * 3 div hSmallMap + 3 *
     1151      ((X - xSmallMap) * 2 div wSmallMap);
    11521152    Page := 0;
    11531153    InitZoomCityMap;
     
    11551155    Exit;
    11561156  end;
    1157   if (ssLeft in Shift) and (x >= xSupport) and (x < xSupport + wSupport) and
    1158     (y >= ySupport) and (y < ySupport + hSupport) then
     1157  if (ssLeft in Shift) and (X >= xSupport) and (X < xSupport + wSupport) and
     1158    (Y >= ySupport) and (Y < ySupport + hSupport) then
    11591159  begin
    11601160    SmallMapMode := smSupportedUnits;
     
    11681168
    11691169  if (ssLeft in Shift) then
    1170     if (ClientMode < scContact) and (x >= xView) and (y >= yView) and
    1171       (x < xView + 73) and (y < yView + 50) then
     1170    if (ClientMode < scContact) and (X >= xView) and (Y >= yView) and
     1171      (X < xView + 73) and (Y < yView + 50) then
    11721172      if cGov = gAnarchy then
    11731173        with MessgExDlg do
    11741174        begin
    11751175          { MessgText:=Phrases.Lookup('OUTOFCONTROL');
    1176             if c.Project and cpImp=0 then
    1177             MessgText:=Format(MessgText,[Tribe[cOwner].ModelName[c.Project and cpIndex]])
    1178             else MessgText:=Format(MessgText,[Phrases.Lookup('IMPROVEMENTS',c.Project and cpIndex)]); }
     1176            if C.Project and cpImp=0 then
     1177            MessgText:=Format(MessgText,[Tribe[cOwner].ModelName[C.Project and cpIndex]])
     1178            else MessgText:=Format(MessgText,[Phrases.Lookup('IMPROVEMENTS',C.Project and cpIndex)]); }
    11791179          MessgText := Phrases.Lookup('NOCHANGEINANARCHY');
    11801180          Kind := mkOk;
     
    11851185        if ProdHint then
    11861186        begin
    1187           ProdHint := false;
     1187          ProdHint := False;
    11881188          SmartUpdateContent
    11891189        end;
    11901190        ChooseProject;
    11911191      end
    1192     else if (SmallMapMode = smImprovements) and (x >= xZoomMap) and (x < xZoomMap + wZoomMap) and
    1193       (y >= yZoomMap) and (y < yZoomMap + hZoomMap) then
    1194     begin
    1195       i := 5;
    1196       while (i >= 0) and not((x >= xZoomMap + 14 + 72 * (i mod 3)) and
    1197         (x < xZoomMap + 14 + 56 + 72 * (i mod 3)) and
    1198         (y >= yZoomMap + 14 + 56 * (i div 3)) and
    1199         (y < yZoomMap + 14 + 40 + 56 * (i div 3))) do
    1200         dec(i);
    1201       if i >= 0 then
     1192    else if (SmallMapMode = smImprovements) and (X >= xZoomMap) and (X < xZoomMap + wZoomMap) and
     1193      (Y >= yZoomMap) and (Y < yZoomMap + hZoomMap) then
     1194    begin
     1195      I := 5;
     1196      while (I >= 0) and not((X >= xZoomMap + 14 + 72 * (I mod 3)) and
     1197        (X < xZoomMap + 14 + 56 + 72 * (I mod 3)) and
     1198        (Y >= yZoomMap + 14 + 56 * (I div 3)) and
     1199        (Y < yZoomMap + 14 + 40 + 56 * (I div 3))) do
     1200        Dec(I);
     1201      if I >= 0 then
    12021202      begin
    1203         iix := imix[i];
     1203        iix := imix[I];
    12041204        if iix >= 0 then
    12051205          if ssShift in Shift then
     
    12211221              else
    12221222              begin
    1223                 SellResult := Server(sSellCityImprovement - sExecute, me,
     1223                SellResult := Server(sSellCityImprovement - sExecute, Me,
    12241224                  cix, iix);
    12251225                if SellResult < rExecuted then
     
    12361236                else
    12371237                begin
    1238                   if Server(sRebuildCityImprovement - sExecute, me, cix, iix) < rExecuted
     1238                  if Server(sRebuildCityImprovement - sExecute, Me, cix, iix) < rExecuted
    12391239                  then
    12401240                  begin // no rebuild possible, ask for sell only
    1241                     Rebuild := false;
     1241                    Rebuild := False;
    12421242                    MessgText := Phrases.Lookup('IMPROVEMENTS', iix);
    12431243                    if not Phrases2FallenBackToEnglish then
    12441244                      MessgText := Format(Phrases2.Lookup('SELL2'),
    12451245                        [MessgText, Imp[iix].Cost * BuildCostMod
    1246                         [G.Difficulty[me]] div 12])
     1246                        [G.Difficulty[Me]] div 12])
    12471247                    else
    12481248                      MessgText := Format(Phrases.Lookup('SELL'), [MessgText]);
    12491249                    if iix = imSpacePort then
    1250                       with MyRO.Ship[me] do
     1250                      with MyRO.Ship[Me] do
    12511251                        if Parts[0] + Parts[1] + Parts[2] > 0 then
    12521252                          MessgText := MessgText + ' ' +
     
    12591259                  else
    12601260                  begin
    1261                     Rebuild := true;
     1261                    Rebuild := True;
    12621262                    MessgText := Phrases.Lookup('IMPROVEMENTS', iix);
    12631263                    if not Phrases2FallenBackToEnglish then
    12641264                      MessgText := Format(Phrases2.Lookup('DISPOSE2'),
    12651265                        [MessgText, Imp[iix].Cost * BuildCostMod
    1266                         [G.Difficulty[me]] div 12 * 2 div 3])
     1266                        [G.Difficulty[Me]] div 12 * 2 div 3])
    12671267                    else
    12681268                      MessgText := Format(Phrases.Lookup('DISPOSE'),
    12691269                        [MessgText]);
    12701270                    if iix = imSpacePort then
    1271                       with MyRO.Ship[me] do
     1271                      with MyRO.Ship[Me] do
    12721272                        if Parts[0] + Parts[1] + Parts[2] > 0 then
    12731273                          MessgText := MessgText + ' ' +
     
    12831283                    begin
    12841284                      Play('CITY_REBUILDIMP');
    1285                       Server(sRebuildCityImprovement, me, cix, iix);
     1285                      Server(sRebuildCityImprovement, Me, cix, iix);
    12861286                    end
    12871287                    else
    12881288                    begin
    12891289                      Play('CITY_SELLIMP');
    1290                       Server(sSellCityImprovement, me, cix, iix);
     1290                      Server(sSellCityImprovement, Me, cix, iix);
    12911291                    end;
    12921292                    CityOptimizer_CityChange(cix);
     
    13011301      end;
    13021302    end
    1303     else if (SmallMapMode = smSupportedUnits) and (x >= xZoomMap) and (x < xZoomMap + wZoomMap) and
    1304       (y >= yZoomMap) and (y < yZoomMap + hZoomMap) then
    1305     begin
    1306       i := 5;
    1307       while (i >= 0) and not((x >= xZoomMap + 64 * (i mod 3)) and
    1308         (x < xZoomMap + 64 + 64 * (i mod 3)) and
    1309         (y >= yZoomMap + 20 + 48 * (i div 3)) and
    1310         (y < yZoomMap + 20 + 52 + 48 * (i div 3))) do
    1311         dec(i);
    1312       if (i >= 0) and (imix[i] >= 0) then
     1303    else if (SmallMapMode = smSupportedUnits) and (X >= xZoomMap) and (X < xZoomMap + wZoomMap) and
     1304      (Y >= yZoomMap) and (Y < yZoomMap + hZoomMap) then
     1305    begin
     1306      I := 5;
     1307      while (I >= 0) and not((X >= xZoomMap + 64 * (I mod 3)) and
     1308        (X < xZoomMap + 64 + 64 * (I mod 3)) and
     1309        (Y >= yZoomMap + 20 + 48 * (I div 3)) and
     1310        (Y < yZoomMap + 20 + 52 + 48 * (I div 3))) do
     1311        Dec(I);
     1312      if (I >= 0) and (imix[I] >= 0) then
    13131313        if ssShift in Shift then
    13141314        else if (cix >= 0) and (ClientMode < scContact) and
     
    13171317          CloseAction := None;
    13181318          Close;
    1319           MainScreen.CityClosed(imix[i], false, true);
     1319          MainScreen.CityClosed(imix[I], False, True);
    13201320        end;
    13211321    end
    1322     else if (x >= xmArea - 192) and (x < xmArea + 192) and (y >= ymArea - 96)
    1323       and (y < ymArea + 96) then
     1322    else if (X >= xmArea - 192) and (X < xmArea + 192) and (Y >= ymArea - 96)
     1323      and (Y < ymArea + 96) then
    13241324    with AreaMap do begin
    1325       qx := ((4000 * xxt * yyt) + (x - xmArea) * (yyt * 2) + (y - ymArea + yyt)
     1325      qx := ((4000 * xxt * yyt) + (X - xmArea) * (yyt * 2) + (Y - ymArea + yyt)
    13261326        * (xxt * 2)) div (xxt * yyt * 4) - 1000;
    1327       qy := ((4000 * xxt * yyt) + (y - ymArea + yyt) * (xxt * 2) - (x - xmArea)
     1327      qy := ((4000 * xxt * yyt) + (Y - ymArea + yyt) * (xxt * 2) - (X - xmArea)
    13281328        * (yyt * 2)) div (xxt * yyt * 4) - 1000;
    13291329      dx := qx - qy;
     
    13381338        end
    13391339        else if (ClientMode < scContact) and (cGov <> gAnarchy) and
    1340           (c.Flags and chCaptured = 0) then
     1340          (C.Flags and chCaptured = 0) then
    13411341        begin // toggle exploitation
    1342           assert(not supervising);
    1343           if c.Status and csResourceWeightsMask <> 0 then
     1342          Assert(not Supervising);
     1343          if C.Status and csResourceWeightsMask <> 0 then
    13441344          begin
    13451345            with MessgExDlg do
     
    13551355              MyCity[cix].Status := MyCity[cix].Status and
    13561356                not csResourceWeightsMask; // off
    1357               c.Status := MyCity[cix].Status;
     1357              C.Status := MyCity[cix].Status;
    13581358              SmartUpdateContent;
    13591359            end;
    1360             exit;
     1360            Exit;
    13611361          end;
    13621362          fix := (dy + 3) shl 2 + (dx + 3) shr 1;
    13631363          NewTiles := MyCity[cix].Tiles xor (1 shl fix);
    1364           if Server(sSetCityTiles, me, cix, NewTiles) >= rExecuted then
     1364          if Server(sSetCityTiles, Me, cix, NewTiles) >= rExecuted then
    13651365          begin
    13661366            SmartUpdateContent;
     
    13711371    end
    13721372    else if (ClientMode < scContact) and (cGov <> gAnarchy) and
    1373       (c.Flags and chCaptured = 0) and (x >= xmOpt - 32) and (x < xmOpt + 32)
    1374       and (y >= ymOpt - 32) and (y < ymOpt + 32) then
    1375     begin
    1376       i := sqr(x - xmOpt) + sqr(y - ymOpt); // click radius
    1377       if i <= 32 * 32 then
     1373      (C.Flags and chCaptured = 0) and (X >= xmOpt - 32) and (X < xmOpt + 32)
     1374      and (Y >= ymOpt - 32) and (Y < ymOpt + 32) then
     1375    begin
     1376      I := sqr(X - xmOpt) + sqr(Y - ymOpt); // click radius
     1377      if I <= 32 * 32 then
    13781378      begin
    1379         if i < 16 * 16 then // inner area clicked
    1380           if c.Status and csResourceWeightsMask <> 0 then
    1381             i := (c.Status shr 4 and $0F) mod 5 + 1 // rotate except off
     1379        if I < 16 * 16 then // inner area clicked
     1380          if C.Status and csResourceWeightsMask <> 0 then
     1381            I := (C.Status shr 4 and $0F) mod 5 + 1 // rotate except off
    13821382          else
    1383             i := 3 // rwGrowth
     1383            I := 3 // rwGrowth
    13841384        else
    1385           case trunc(arctan2(x - xmOpt, ymOpt - y) * 180 / pi) of
     1385          case trunc(arctan2(X - xmOpt, ymOpt - Y) * 180 / pi) of
    13861386            - 25 - 52 * 2 .. -26 - 52:
    1387               i := 1;
     1387              I := 1;
    13881388            -25 - 52 .. -26:
    1389               i := 2;
     1389              I := 2;
    13901390            -25 .. 25:
    1391               i := 3;
     1391              I := 3;
    13921392            26 .. 25 + 52:
    1393               i := 4;
     1393              I := 4;
    13941394            26 + 52 .. 25 + 52 * 2:
    1395               i := 5;
     1395              I := 5;
    13961396            180 - 26 .. 180, -180 .. -180 + 26:
    1397               i := 0;
     1397              I := 0;
    13981398          else
    1399             i := -1;
     1399            I := -1;
    14001400          end;
    1401         if i >= 0 then
     1401        if I >= 0 then
    14021402        begin
    1403           ChangeResourceWeights(i);
     1403          ChangeResourceWeights(I);
    14041404          SmartUpdateContent;
    14051405          if WindowMode <> wmModal then
     
    14231423  );
    14241424
    1425   function ProjectType(Project: integer): TProjectType;
     1425  function ProjectType(Project: Integer): TProjectType;
    14261426  begin
    14271427    if Project and cpCompleted <> 0 then
     
    14451445
    14461446var
    1447   NewProject, OldMoney, cix1: integer;
     1447  NewProject, OldMoney, cix1: Integer;
    14481448  pt0, pt1: TProjectType;
    1449   QueryOk: boolean;
    1450 begin
    1451   Assert(not supervising);
     1449  QueryOk: Boolean;
     1450begin
     1451  Assert(not Supervising);
    14521452  ModalSelectDlg.ShowNewContent_CityProject(wmModal, cix);
    1453   if ModalSelectDlg.result <> -1 then
    1454   begin
    1455     if ModalSelectDlg.result and cpType <> 0 then
     1453  if ModalSelectDlg.Result <> -1 then
     1454  begin
     1455    if ModalSelectDlg.Result and cpType <> 0 then
    14561456    begin
    14571457      MyCity[cix].Status := MyCity[cix].Status and not 7 or
    1458         (1 + ModalSelectDlg.result and cpIndex);
    1459       AutoBuild(cix, MyData.ImpOrder[ModalSelectDlg.result and cpIndex]);
     1458        (1 + ModalSelectDlg.Result and cpIndex);
     1459      AutoBuild(cix, MyData.ImpOrder[ModalSelectDlg.Result and cpIndex]);
    14601460    end
    14611461    else
     
    15221522        then
    15231523          NewProject := NewProject or cpDisbandCity;
    1524       Server(sSetCityProject, me, cix, NewProject);
    1525       c.Project := MyCity[cix].Project;
     1524      Server(sSetCityProject, Me, cix, NewProject);
     1525      C.Project := MyCity[cix].Project;
    15261526      if MyRO.Money > OldMoney then
    15271527        Play('CITY_SELLIMP');
     
    15381538procedure TCityDlg.BuyClick(Sender: TObject);
    15391539var
    1540   NextProd, Cost: integer;
     1540  NextProd, Cost: Integer;
    15411541begin
    15421542  if (cix < 0) or (ClientMode >= scContact) then
    1543     exit;
     1543    Exit;
    15441544  with MyCity[cix], MessgExDlg do
    15451545  begin
     
    15491549      NextProd := 0;
    15501550    Cost := Cost - Prod - NextProd;
    1551     if (MyRO.Wonder[woMich].EffectiveOwner = me) and (Project and cpImp <> 0)
     1551    if (MyRO.Wonder[woMich].EffectiveOwner = Me) and (Project and cpImp <> 0)
    15521552    then
    15531553      Cost := Cost * 2
     
    15731573    if (Kind = mkYesNo) and (ModalResult = mrOK) then
    15741574    begin
    1575       if Server(sBuyCityProject, me, cix, nil^) >= rExecuted then
     1575      if Server(sBuyCityProject, Me, cix, nil^) >= rExecuted then
    15761576      begin
    15771577        Play('CITY_BUYPROJECT');
     
    16331633    else if BlinkTime = 6 then
    16341634    begin
    1635       if AllowChange and (c.Status and 7 <> 0) then
     1635      if AllowChange and (C.Status and 7 <> 0) then
    16361636      begin // city type autobuild
    16371637        FrameImage(Canvas, bigimp, xView + 9, yView + 5, xSizeBig, ySizeBig,
    1638           (c.Status and 7 - 1 + 3) * xSizeBig, 0, true);
     1638          (C.Status and 7 - 1 + 3) * xSizeBig, 0, True);
    16391639      end
    1640       else if c.Project and cpImp = 0 then
     1640      else if C.Project and cpImp = 0 then
    16411641      begin // project is unit
    16421642        BitBltCanvas(Canvas, xView + 9, yView + 5, xSizeBig, ySizeBig,
    16431643          Bigimp.Canvas, 0, 0);
    1644         with Tribe[cOwner].ModelPicture[c.Project and cpIndex] do
     1644        with Tribe[cOwner].ModelPicture[C.Project and cpIndex] do
    16451645          Sprite(Canvas, HGr, xView + 5, yView + 1, 64, 44, pix mod 10 * 65 + 1,
    16461646            pix div 10 * 49 + 1);
    16471647      end
    16481648      else
    1649         ImpImage(Canvas, xView + 9, yView + 5, c.Project0 and cpIndex,
    1650           cGov, true);
     1649        ImpImage(Canvas, xView + 9, yView + 5, C.Project0 and cpIndex,
     1650          cGov, True);
    16511651    end;
    16521652  end;
     
    16641664  if 1 shl OpenSoundEvent = chProduction then
    16651665  begin
    1666     if c.Project0 and cpImp <> 0 then
    1667     begin
    1668       if c.Project0 and cpIndex >= 28 then
     1666    if C.Project0 and cpImp <> 0 then
     1667    begin
     1668      if C.Project0 and cpIndex >= 28 then
    16691669      // wonders have already extra message with sound
    1670         if Imp[c.Project0 and cpIndex].Kind = ikShipPart then
     1670        if Imp[C.Project0 and cpIndex].Kind = ikShipPart then
    16711671          Play('SHIP_BUILT')
    16721672        else
     
    16821682end;
    16831683
    1684 function Prio(iix: integer): integer;
     1684function Prio(iix: Integer): Integer;
    16851685begin
    16861686  case Imp[iix].Kind of
    16871687    ikWonder:
    1688       result := iix + 10000;
     1688      Result := iix + 10000;
    16891689    ikNatLocal, ikNatGlobal:
    16901690      case iix of
    16911691        imPalace:
    1692           result := 0;
     1692          Result := 0;
    16931693      else
    1694         result := iix + 20000;
     1694        Result := iix + 20000;
    16951695      end;
    16961696  else
    16971697    case iix of
    16981698      imTownHall, imCourt:
    1699         result := iix + 30000;
     1699        Result := iix + 30000;
    17001700      imAqueduct, imSewer:
    1701         result := iix + 40000;
     1701        Result := iix + 40000;
    17021702      imTemple, imTheater, imCathedral:
    1703         result := iix + 50000;
    1704     else
    1705       result := iix + 90000;
     1703        Result := iix + 50000;
     1704    else
     1705      Result := iix + 90000;
    17061706    end;
    17071707  end;
     
    17181718end;
    17191719
    1720 procedure TCityDlg.ChangeCity(d: integer);
     1720procedure TCityDlg.ChangeCity(D: Integer);
    17211721var
    1722   cixNew: integer;
     1722  cixNew: Integer;
    17231723begin
    17241724  cixNew := cix;
    17251725  repeat
    1726     cixNew := (cixNew + MyRO.nCity + d) mod MyRO.nCity;
     1726    cixNew := (cixNew + MyRO.nCity + D) mod MyRO.nCity;
    17271727  until (MyCity[cixNew].Loc >= 0) or (cixNew = cix);
    17281728  if cixNew <> cix then
     
    17661766end;
    17671767
    1768 procedure TCityDlg.ChangeResourceWeights(iResourceWeights: integer);
     1768procedure TCityDlg.ChangeResourceWeights(iResourceWeights: Integer);
    17691769var
    17701770  Advice: TCityTileAdviceData;
    17711771begin
    1772   assert(not supervising);
    1773   assert(cix >= 0);
     1772  Assert(not Supervising);
     1773  Assert(cix >= 0);
    17741774  MyCity[cix].Status := MyCity[cix].Status and not csResourceWeightsMask or
    17751775    (iResourceWeights shl 4);
    1776   c.Status := MyCity[cix].Status;
     1776  C.Status := MyCity[cix].Status;
    17771777  if iResourceWeights > 0 then
    17781778  begin
    17791779    Advice.ResourceWeights := OfferedResourceWeights[iResourceWeights];
    1780     Server(sGetCityTileAdvice, me, cix, Advice);
     1780    Server(sGetCityTileAdvice, Me, cix, Advice);
    17811781    if Advice.Tiles <> MyCity[cix].Tiles then
    1782       Server(sSetCityTiles, me, cix, Advice.Tiles);
     1782      Server(sSetCityTiles, Me, cix, Advice.Tiles);
    17831783  end;
    17841784end;
     
    17861786procedure SortImprovements;
    17871787var
    1788   i, j, k: integer;
    1789 begin
    1790   for i := 0 to nImp - 1 do
    1791     ImpSorted[i] := i;
    1792   for i := 0 to nImp - 2 do
    1793     for j := i + 1 to nImp - 1 do
    1794       if Prio(ImpSorted[i]) > Prio(ImpSorted[j]) then begin
    1795         k := ImpSorted[i];
    1796         ImpSorted[i] := ImpSorted[j];
    1797         ImpSorted[j] := k;
     1788  I, J, K: Integer;
     1789begin
     1790  for I := 0 to nImp - 1 do
     1791    ImpSorted[I] := I;
     1792  for I := 0 to nImp - 2 do
     1793    for J := I + 1 to nImp - 1 do
     1794      if Prio(ImpSorted[I]) > Prio(ImpSorted[J]) then begin
     1795        K := ImpSorted[I];
     1796        ImpSorted[I] := ImpSorted[J];
     1797        ImpSorted[J] := K;
    17981798      end;
    17991799end;
  • trunk/LocalPlayer/CityType.pas

    r442 r447  
    1818    procedure FormShow(Sender: TObject);
    1919    procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
    20       Shift: TShiftState; x, y: integer);
     20      Shift: TShiftState; X, Y: Integer);
    2121    procedure PaintBox1MouseUp(Sender: TObject; Button: TMouseButton;
    22       Shift: TShiftState; x, y: integer);
     22      Shift: TShiftState; X, Y: Integer);
    2323    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    2424    procedure DeleteBtnClick(Sender: TObject);
     
    2828    procedure OffscreenPaint; override;
    2929  private
    30     nPool, dragiix, ctype: integer;
    31     Pooliix: array [0 .. nImp - 1] of integer;
     30    nPool, dragiix, ctype: Integer;
     31    Pooliix: array [0 .. nImp - 1] of Integer;
    3232    listed: Set of 0 .. nImp;
    33     Changed: boolean;
    34     procedure LoadType(NewType: integer);
     33    Changed: Boolean;
     34    procedure LoadType(NewType: Integer);
    3535    procedure SaveType;
    3636  end;
     
    8282procedure TCityTypeDlg.OffscreenPaint;
    8383var
    84   i, iix: integer;
    85   s: string;
     84  I, iix: Integer;
     85  S: string;
    8686begin
    8787  inherited;
    88   offscreen.Canvas.Font.Assign(UniFont[ftSmall]);
     88  Offscreen.Canvas.Font.Assign(UniFont[ftSmall]);
    8989  FillOffscreen(xList - 7, yList, 42 * nListCol + 14, 32 * nListRow);
    9090  FillOffscreen(xPool - 7, yPool, 42 * nPoolCol + 14, 32 * nPoolRow);
     
    9292    yPool - yList - 32 * nListRow);
    9393
    94   Frame(offscreen.Canvas, 0, yList + 32 * nListRow, InnerWidth - 255,
     94  Frame(Offscreen.Canvas, 0, yList + 32 * nListRow, InnerWidth - 255,
    9595    yPool - 23, MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
    96   Frame(offscreen.Canvas, InnerWidth - 254, yList + 32 * nListRow,
     96  Frame(Offscreen.Canvas, InnerWidth - 254, yList + 32 * nListRow,
    9797    InnerWidth - 89, yPool - 23, MainTexture.ColorBevelLight,
    9898    MainTexture.ColorBevelShade);
    99   Frame(offscreen.Canvas, InnerWidth - 88, yList + 32 * nListRow,
     99  Frame(Offscreen.Canvas, InnerWidth - 88, yList + 32 * nListRow,
    100100    InnerWidth - 1, yPool - 23, MainTexture.ColorBevelLight,
    101101    MainTexture.ColorBevelShade);
    102   Frame(offscreen.Canvas, 0, yPool - 22, InnerWidth - 1, yPool - 1,
     102  Frame(Offscreen.Canvas, 0, yPool - 22, InnerWidth - 1, yPool - 1,
    103103    MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
    104   for i := 0 to nCityType - 1 do
    105   begin
    106     RFrame(offscreen.Canvas, xSwitch + i * 42, ySwitch, xSwitch + 39 + i * 42,
     104  for I := 0 to nCityType - 1 do
     105  begin
     106    RFrame(Offscreen.Canvas, xSwitch + I * 42, ySwitch, xSwitch + 39 + I * 42,
    107107      ySwitch + 23, MainTexture.ColorBevelShade, MainTexture.ColorBevelLight);
    108     if i = ctype then
    109       Frame(offscreen.Canvas, xSwitch + 1 + i * 42, ySwitch + 1,
    110         xSwitch + 38 + i * 42, ySwitch + 22, MainTexture.ColorBevelShade,
     108    if I = ctype then
     109      Frame(Offscreen.Canvas, xSwitch + 1 + I * 42, ySwitch + 1,
     110        xSwitch + 38 + I * 42, ySwitch + 22, MainTexture.ColorBevelShade,
    111111        MainTexture.ColorBevelLight)
    112112    else
    113       Frame(offscreen.Canvas, xSwitch + 1 + i * 42, ySwitch + 1,
    114         xSwitch + 38 + i * 42, ySwitch + 22, MainTexture.ColorBevelLight,
     113      Frame(Offscreen.Canvas, xSwitch + 1 + I * 42, ySwitch + 1,
     114        xSwitch + 38 + I * 42, ySwitch + 22, MainTexture.ColorBevelLight,
    115115        MainTexture.ColorBevelShade);
    116     BitBltCanvas(offscreen.Canvas, xSwitch + 2 + i * 42, ySwitch + 2,
    117       xSizeSmall, ySizeSmall, SmallImp.Canvas, (i + 3) * xSizeSmall, 0);
    118   end;
    119   RisedTextOut(offscreen.Canvas, 8, yList + 32 * nListRow + 2,
     116    BitBltCanvas(Offscreen.Canvas, xSwitch + 2 + I * 42, ySwitch + 2,
     117      xSizeSmall, ySizeSmall, SmallImp.Canvas, (I + 3) * xSizeSmall, 0);
     118  end;
     119  RisedTextOut(Offscreen.Canvas, 8, yList + 32 * nListRow + 2,
    120120    Phrases.Lookup('BUILDORDER'));
    121   RisedTextOut(offscreen.Canvas, 8, ySwitch + 26,
     121  RisedTextOut(Offscreen.Canvas, 8, ySwitch + 26,
    122122    Phrases.Lookup('CITYTYPE', ctype));
    123   s := Phrases.Lookup('BUILDREST');
    124   RisedTextOut(offscreen.Canvas,
    125     (InnerWidth - BiColorTextWidth(offscreen.Canvas, s)) div 2,
    126     yList + 72 + 32 * nListRow, s);
    127 
    128   with offscreen.Canvas do
    129   begin
    130     for i := 1 to nListRow - 1 do
    131       DLine(offscreen.Canvas, xList - 5, xList + 4 + 42 * nListCol,
    132         yList - 1 + 32 * i, MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
    133     for i := 0 to nListCol * nListRow - 1 do
    134     begin
    135       s := IntToStr(i + 1);
     123  S := Phrases.Lookup('BUILDREST');
     124  RisedTextOut(Offscreen.Canvas,
     125    (InnerWidth - BiColorTextWidth(Offscreen.Canvas, S)) div 2,
     126    yList + 72 + 32 * nListRow, S);
     127
     128  with Offscreen.Canvas do
     129  begin
     130    for I := 1 to nListRow - 1 do
     131      DLine(Offscreen.Canvas, xList - 5, xList + 4 + 42 * nListCol,
     132        yList - 1 + 32 * I, MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
     133    for I := 0 to nListCol * nListRow - 1 do
     134    begin
     135      S := IntToStr(I + 1);
    136136      Font.Color := MainTexture.ColorTextLight;
    137       Textout(xList + 20 + i mod nListCol * 42 - TextWidth(s) div 2,
    138         yList + 15 + i div nListCol * 32 - TextHeight(s) div 2, s);
    139     end;
    140   end;
    141 
    142   i := 0;
    143   while MyData.ImpOrder[ctype, i] >= 0 do
    144   begin
    145     RFrame(offscreen.Canvas, xList + 20 - xSizeSmall div 2 + i mod nListCol *
    146       42, yList + 15 - ySizeSmall div 2 + i div nListCol * 32,
    147       xList + 21 + xSizeSmall div 2 + i mod nListCol * 42,
    148       yList + 16 + ySizeSmall div 2 + i div nListCol * 32,
     137      Textout(xList + 20 + I mod nListCol * 42 - TextWidth(S) div 2,
     138        yList + 15 + I div nListCol * 32 - TextHeight(S) div 2, S);
     139    end;
     140  end;
     141
     142  I := 0;
     143  while MyData.ImpOrder[ctype, I] >= 0 do
     144  begin
     145    RFrame(Offscreen.Canvas, xList + 20 - xSizeSmall div 2 + I mod nListCol *
     146      42, yList + 15 - ySizeSmall div 2 + I div nListCol * 32,
     147      xList + 21 + xSizeSmall div 2 + I mod nListCol * 42,
     148      yList + 16 + ySizeSmall div 2 + I div nListCol * 32,
    149149      MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
    150     BitBltCanvas(offscreen.Canvas, xList + 21 - xSizeSmall div 2 +
    151       i mod nListCol * 42, yList + 16 - ySizeSmall div 2 + i div nListCol * 32,
     150    BitBltCanvas(Offscreen.Canvas, xList + 21 - xSizeSmall div 2 +
     151      I mod nListCol * 42, yList + 16 - ySizeSmall div 2 + I div nListCol * 32,
    152152      xSizeSmall, ySizeSmall, SmallImp.Canvas,
    153       MyData.ImpOrder[ctype, i] mod 7 * xSizeSmall,
    154       (MyData.ImpOrder[ctype, i] + SystemIconLines * 7) div 7 *
     153      MyData.ImpOrder[ctype, I] mod 7 * xSizeSmall,
     154      (MyData.ImpOrder[ctype, I] + SystemIconLines * 7) div 7 *
    155155      ySizeSmall);
    156     inc(i);
     156    Inc(I);
    157157  end;
    158158
     
    165165    begin
    166166      Pooliix[nPool] := iix;
    167       RFrame(offscreen.Canvas, xPool + 20 - xSizeSmall div 2 +
     167      RFrame(Offscreen.Canvas, xPool + 20 - xSizeSmall div 2 +
    168168        nPool mod nPoolCol * 42, yPool + 15 - ySizeSmall div 2 +
    169169        nPool div nPoolCol * 32, xPool + 21 + xSizeSmall div 2 +
     
    171171        nPool div nPoolCol * 32, MainTexture.ColorBevelLight,
    172172        MainTexture.ColorBevelShade);
    173       BitBltCanvas(offscreen.Canvas, xPool + 21 - xSizeSmall div 2 +
     173      BitBltCanvas(Offscreen.Canvas, xPool + 21 - xSizeSmall div 2 +
    174174        nPool mod nPoolCol * 42, yPool + 16 - ySizeSmall div 2 +
    175175        nPool div nPoolCol * 32, xSizeSmall, ySizeSmall, SmallImp.Canvas,
    176176        iix mod 7 * xSizeSmall, (iix + SystemIconLines * 7) div 7 *
    177177        ySizeSmall);
    178       inc(nPool);
     178      Inc(nPool);
    179179    end;
    180180  DeleteBtn.Visible := MyData.ImpOrder[ctype, 0] >= 0;
     
    182182  if dragiix >= 0 then
    183183  begin
    184     ImpImage(offscreen.Canvas, xView + 9, yView + 5, dragiix);
    185     s := Phrases.Lookup('IMPROVEMENTS', dragiix);
    186     RisedTextOut(offscreen.Canvas,
    187       xView + 36 - BiColorTextWidth(offscreen.Canvas, s) div 2,
    188       ySwitch + 26, s);
     184    ImpImage(Offscreen.Canvas, xView + 9, yView + 5, dragiix);
     185    S := Phrases.Lookup('IMPROVEMENTS', dragiix);
     186    RisedTextOut(Offscreen.Canvas,
     187      xView + 36 - BiColorTextWidth(Offscreen.Canvas, S) div 2,
     188      ySwitch + 26, S);
    189189  end;
    190190  MarkUsedOffscreen(InnerWidth, InnerHeight);
    191191end;
    192192
    193 procedure TCityTypeDlg.LoadType(NewType: integer);
    194 var
    195   i: integer;
     193procedure TCityTypeDlg.LoadType(NewType: Integer);
     194var
     195  I: Integer;
    196196begin
    197197  ctype := NewType;
    198198  listed := [];
    199   i := 0;
    200   while MyData.ImpOrder[ctype, i] >= 0 do
    201   begin
    202     include(listed, MyData.ImpOrder[ctype, i]);
    203     inc(i);
    204   end;
    205   Changed := false;
     199  I := 0;
     200  while MyData.ImpOrder[ctype, I] >= 0 do
     201  begin
     202    Include(listed, MyData.ImpOrder[ctype, I]);
     203    Inc(I);
     204  end;
     205  Changed := False;
    206206end;
    207207
    208208procedure TCityTypeDlg.SaveType;
    209209var
    210   cix: integer;
     210  cix: Integer;
    211211begin
    212212  if Changed then
     
    215215      if (MyCity[cix].Loc >= 0) and (MyCity[cix].Status and 7 = ctype + 1) then
    216216        AutoBuild(cix, MyData.ImpOrder[ctype]);
    217     Changed := false;
     217    Changed := False;
    218218  end;
    219219end;
     
    232232
    233233procedure TCityTypeDlg.PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
    234   Shift: TShiftState; x, y: integer);
    235 var
    236   i: integer;
    237 begin
    238   x := x - SideFrame;
    239   y := y - WideFrame;
    240   i := (x - xList) div 42 + (y - yList) div 32 * nListCol;
    241   if (i < nImp) and (MyData.ImpOrder[ctype, i] >= 0) and
    242     (x > xList + 2 + i mod nListCol * 42) and
    243     (y > yList + 5 + i div nListCol * 32) and
    244     (x < xList + 3 + 36 + i mod nListCol * 42) and
    245     (y < yList + 6 + 20 + i div nListCol * 32) then
     234  Shift: TShiftState; X, Y: Integer);
     235var
     236  I: Integer;
     237begin
     238  X := X - SideFrame;
     239  Y := Y - WideFrame;
     240  I := (X - xList) div 42 + (Y - yList) div 32 * nListCol;
     241  if (I < nImp) and (MyData.ImpOrder[ctype, I] >= 0) and
     242    (X > xList + 2 + I mod nListCol * 42) and
     243    (Y > yList + 5 + I div nListCol * 32) and
     244    (X < xList + 3 + 36 + I mod nListCol * 42) and
     245    (Y < yList + 6 + 20 + I div nListCol * 32) then
    246246  begin
    247247    if ssShift in Shift then
    248248      HelpDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), hkImp,
    249         MyData.ImpOrder[ctype, i])
     249        MyData.ImpOrder[ctype, I])
    250250    else
    251251    begin
    252       dragiix := MyData.ImpOrder[ctype, i];
     252      dragiix := MyData.ImpOrder[ctype, I];
    253253      Screen.Cursor := crImpDrag;
    254254      SmartUpdateContent;
    255255    end;
    256     exit;
    257   end;
    258   i := (x - xPool) div 42 + (y - yPool) div 32 * nPoolCol;
    259   if (i < nPool) and (x > xPool + 2 + i mod nPoolCol * 42) and
    260     (y > yPool + 5 + i div nPoolCol * 32) and
    261     (x < xPool + 3 + 36 + i mod nPoolCol * 42) and
    262     (y < yPool + 6 + 20 + i div nPoolCol * 32) then
     256    Exit;
     257  end;
     258  I := (X - xPool) div 42 + (Y - yPool) div 32 * nPoolCol;
     259  if (I < nPool) and (X > xPool + 2 + I mod nPoolCol * 42) and
     260    (Y > yPool + 5 + I div nPoolCol * 32) and
     261    (X < xPool + 3 + 36 + I mod nPoolCol * 42) and
     262    (Y < yPool + 6 + 20 + I div nPoolCol * 32) then
    263263  begin
    264264    if ssShift in Shift then
    265       HelpDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), hkImp, Pooliix[i])
     265      HelpDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), hkImp, Pooliix[I])
    266266    else
    267267    begin
    268       dragiix := Pooliix[i];
     268      dragiix := Pooliix[I];
    269269      Screen.Cursor := crImpDrag;
    270270      SmartUpdateContent;
    271271    end;
    272     exit;
    273   end;
    274   i := (x - xSwitch) div 42;
    275   if (i < nCityType) and (x > xSwitch + 2 + i * 42) and
    276     (x < xSwitch + 3 + 36 + i * 42) and (y >= ySwitch + 2) and (y < ySwitch + 22)
     272    Exit;
     273  end;
     274  I := (X - xSwitch) div 42;
     275  if (I < nCityType) and (X > xSwitch + 2 + I * 42) and
     276    (X < xSwitch + 3 + 36 + I * 42) and (Y >= ySwitch + 2) and (Y < ySwitch + 22)
    277277  then
    278278  begin
    279279    SaveType;
    280     LoadType(i);
     280    LoadType(I);
    281281    SmartUpdateContent;
    282282  end;
     
    284284
    285285procedure TCityTypeDlg.PaintBox1MouseUp(Sender: TObject; Button: TMouseButton;
    286   Shift: TShiftState; x, y: integer);
    287 
    288   procedure UnList(iix: integer);
     286  Shift: TShiftState; X, Y: Integer);
     287
     288  procedure UnList(iix: Integer);
    289289  var
    290     i: integer;
    291   begin
    292     i := 0;
    293     while (MyData.ImpOrder[ctype, i] >= 0) and
    294       (MyData.ImpOrder[ctype, i] <> iix) do
    295       inc(i);
    296     assert(MyData.ImpOrder[ctype, i] = iix);
    297     move(MyData.ImpOrder[ctype, i + 1], MyData.ImpOrder[ctype, i], nImp - i);
     290    I: Integer;
     291  begin
     292    I := 0;
     293    while (MyData.ImpOrder[ctype, I] >= 0) and
     294      (MyData.ImpOrder[ctype, I] <> iix) do
     295      Inc(I);
     296    Assert(MyData.ImpOrder[ctype, I] = iix);
     297    Move(MyData.ImpOrder[ctype, I + 1], MyData.ImpOrder[ctype, I], nImp - I);
    298298    Exclude(listed, iix);
    299299  end;
    300300
    301301var
    302   i: integer;
    303 begin
    304   x := x - SideFrame;
    305   y := y - WideFrame;
     302  I: Integer;
     303begin
     304  X := X - SideFrame;
     305  Y := Y - WideFrame;
    306306  if dragiix >= 0 then
    307307  begin
    308     if (x >= xList) and (x < xList + nListCol * 42) and (y >= yList) and
    309       (y < yList + nListRow * 32) then
     308    if (X >= xList) and (X < xList + nListCol * 42) and (Y >= yList) and
     309      (Y < yList + nListRow * 32) then
    310310    begin
    311311      if dragiix in listed then
    312312        UnList(dragiix);
    313       i := (x - xList) div 42 + (y - yList) div 32 * nListCol;
    314       while (i > 0) and (MyData.ImpOrder[ctype, i - 1] < 0) do
    315         dec(i);
    316       move(MyData.ImpOrder[ctype, i], MyData.ImpOrder[ctype, i + 1],
    317         nImp - i - 1);
    318       MyData.ImpOrder[ctype, i] := dragiix;
    319       include(listed, dragiix);
    320       Changed := true;
     313      I := (X - xList) div 42 + (Y - yList) div 32 * nListCol;
     314      while (I > 0) and (MyData.ImpOrder[ctype, I - 1] < 0) do
     315        Dec(I);
     316      Move(MyData.ImpOrder[ctype, I], MyData.ImpOrder[ctype, I + 1],
     317        nImp - I - 1);
     318      MyData.ImpOrder[ctype, I] := dragiix;
     319      Include(listed, dragiix);
     320      Changed := True;
    321321    end
    322     else if (dragiix in listed) and (x >= xPool) and (x < xPool + nPoolCol * 42)
    323       and (y >= yPool) and (y < yPool + nPoolRow * 32) then
     322    else if (dragiix in listed) and (X >= xPool) and (X < xPool + nPoolCol * 42)
     323      and (Y >= yPool) and (Y < yPool + nPoolRow * 32) then
    324324    begin
    325325      UnList(dragiix);
    326       Changed := true;
     326      Changed := True;
    327327    end;
    328328    dragiix := -1;
     
    340340procedure TCityTypeDlg.DeleteBtnClick(Sender: TObject);
    341341begin
    342   fillchar(MyData.ImpOrder[ctype], sizeof(MyData.ImpOrder[ctype]), Byte(-1));
     342  FillChar(MyData.ImpOrder[ctype], SizeOf(MyData.ImpOrder[ctype]), Byte(-1));
    343343  listed := [];
    344   Changed := true;
     344  Changed := True;
    345345  SmartUpdateContent;
    346346end;
  • trunk/LocalPlayer/ClientTools.pas

    r442 r447  
    99const
    1010  nOfferedResourceWeights = 6;
    11   OfferedResourceWeights: array [0 .. nOfferedResourceWeights - 1] of cardinal =
     11  OfferedResourceWeights: array [0 .. nOfferedResourceWeights - 1] of Cardinal =
    1212    (rwOff, rwMaxScience, rwForceScience, rwMaxGrowth, rwForceProd, rwMaxProd);
    1313
    1414type
    15   TImpOrder = array [0 .. (nImp + 4) div 4 * 4 - 1] of shortint;
    16   TEnhancementJobs = array [0 .. 11, 0 .. 7] of byte;
     15  TImpOrder = array [0 .. (nImp + 4) div 4 * 4 - 1] of ShortInt;
     16  TEnhancementJobs = array [0 .. 11, 0 .. 7] of Byte;
    1717  JobResultSet = set of 0 .. 39;
    1818
     
    3636  Server: TServerCall;
    3737  G: TNewGameData;
    38   me: integer;
     38  Me: Integer;
    3939  MyRO: ^TPlayerContext;
    4040  MyMap: ^TTileList;
     
    4343  MyModel: ^TModelList;
    4444
    45   AdvValue: array [0 .. nAdv - 1] of integer;
    46 
    47 function dLoc(Loc, dx, dy: integer): integer;
    48 function Distance(Loc0, Loc1: integer): integer;
    49 function UnrestAtLoc(uix, Loc: integer): boolean;
    50 function GetMoveAdvice(uix, ToLoc: integer;
    51   var MoveAdviceData: TMoveAdviceData): integer;
    52 function ColorOfHealth(Health: integer): integer;
    53 function IsMultiPlayerGame: boolean;
    54 procedure ItsMeAgain(p: integer);
    55 function GetAge(p: integer): integer;
    56 function IsCivilReportNew(Enemy: integer): boolean;
    57 function IsMilReportNew(Enemy: integer): boolean;
    58 function CutCityFoodSurplus(FoodSurplus: integer; IsCityAlive: boolean;
    59   gov, size: integer): integer;
    60 function CityTaxBalance(cix: integer; const CityReport: TCityReportNew): integer;
    61 procedure SumCities(var TaxSum, ScienceSum: integer);
    62 function JobTest(uix, Job: integer; IgnoreResults: JobResultSet = []): boolean;
    63 procedure GetUnitInfo(Loc: integer; var uix: integer; var UnitInfo: TUnitInfo);
    64 procedure GetCityInfo(Loc: integer; var cix: integer; var CityInfo: TCityInfo);
    65 function UnitExhausted(uix: integer): boolean;
    66 function ModelHash(const ModelInfo: TModelInfo): integer;
    67 function ProcessEnhancement(uix: integer; const Jobs: TEnhancementJobs): integer;
    68 function AutoBuild(cix: integer; const ImpOrder: TImpOrder): boolean;
    69 procedure DebugMessage(Level: integer; Text: string);
     45  AdvValue: array [0 .. nAdv - 1] of Integer;
     46
     47function dLoc(Loc, dx, dy: Integer): Integer;
     48function Distance(Loc0, Loc1: Integer): Integer;
     49function UnrestAtLoc(uix, Loc: Integer): Boolean;
     50function GetMoveAdvice(uix, ToLoc: Integer;
     51  var MoveAdviceData: TMoveAdviceData): Integer;
     52function ColorOfHealth(Health: Integer): Integer;
     53function IsMultiPlayerGame: Boolean;
     54procedure ItsMeAgain(P: Integer);
     55function GetAge(P: Integer): Integer;
     56function IsCivilReportNew(Enemy: Integer): Boolean;
     57function IsMilReportNew(Enemy: Integer): Boolean;
     58function CutCityFoodSurplus(FoodSurplus: Integer; IsCityAlive: Boolean;
     59  gov, size: Integer): Integer;
     60function CityTaxBalance(cix: Integer; const CityReport: TCityReportNew): Integer;
     61procedure SumCities(var TaxSum, ScienceSum: Integer);
     62function JobTest(uix, Job: Integer; IgnoreResults: JobResultSet = []): Boolean;
     63procedure GetUnitInfo(Loc: Integer; var uix: Integer; var UnitInfo: TUnitInfo);
     64procedure GetCityInfo(Loc: Integer; var cix: Integer; var CityInfo: TCityInfo);
     65function UnitExhausted(uix: Integer): Boolean;
     66function ModelHash(const ModelInfo: TModelInfo): Integer;
     67function ProcessEnhancement(uix: Integer; const Jobs: TEnhancementJobs): Integer;
     68function AutoBuild(cix: Integer; const ImpOrder: TImpOrder): Boolean;
     69procedure DebugMessage(Level: Integer; Text: string);
    7070procedure CityOptimizer_BeginOfTurn;
    71 procedure CityOptimizer_CityChange(cix: integer);
    72 procedure CityOptimizer_TileBecomesAvailable(Loc: integer);
    73 procedure CityOptimizer_ReleaseCityTiles(cix, ReleasedTiles: integer);
    74 procedure CityOptimizer_BeforeRemoveUnit(uix: integer);
     71procedure CityOptimizer_CityChange(cix: Integer);
     72procedure CityOptimizer_TileBecomesAvailable(Loc: Integer);
     73procedure CityOptimizer_ReleaseCityTiles(cix, ReleasedTiles: Integer);
     74procedure CityOptimizer_BeforeRemoveUnit(uix: Integer);
    7575procedure CityOptimizer_AfterRemoveUnit;
    7676procedure CityOptimizer_EndOfTurn;
     
    8484
    8585var
    86   CityNeedsOptimize: array [0 .. ncmax - 1] of boolean;
    87 
    88 function dLoc(Loc, dx, dy: integer): integer;
    89 var
    90   y0: integer;
     86  CityNeedsOptimize: array [0 .. ncmax - 1] of Boolean;
     87
     88function dLoc(Loc, dx, dy: Integer): Integer;
     89var
     90  y0: Integer;
    9191begin
    9292  y0 := (Loc + G.lx * 1024) div G.lx - 1024;
     
    9494end;
    9595
    96 function Distance(Loc0, Loc1: integer): integer;
    97 var
    98   dx, dy: integer;
     96function Distance(Loc0, Loc1: Integer): Integer;
     97var
     98  dx, dy: Integer;
    9999begin
    100100  Inc(Loc0, G.lx * 1024);
     
    106106end;
    107107
    108 function UnrestAtLoc(uix, Loc: integer): boolean;
    109 var
    110   uix1: integer;
     108function UnrestAtLoc(uix, Loc: Integer): Boolean;
     109var
     110  uix1: Integer;
    111111begin
    112112  Result := False;
     
    114114    case MyRO.Government of
    115115      gRepublic, gFuture:
    116         Result := (MyRO.Territory[Loc] >= 0) and (MyRO.Territory[Loc] <> me) and
     116        Result := (MyRO.Territory[Loc] >= 0) and (MyRO.Territory[Loc] <> Me) and
    117117          (MyRO.Treaty[MyRO.Territory[Loc]] < trAlliance);
    118118      gDemocracy:
    119         Result := (MyRO.Territory[Loc] < 0) or (MyRO.Territory[Loc] <> me) and
     119        Result := (MyRO.Territory[Loc] < 0) or (MyRO.Territory[Loc] <> Me) and
    120120          (MyRO.Treaty[MyRO.Territory[Loc]] < trAlliance);
    121121    end;
     
    127127end;
    128128
    129 function GetMoveAdvice(uix, ToLoc: integer;
    130   var MoveAdviceData: TMoveAdviceData): integer;
    131 var
    132   MinEndHealth: integer;
     129function GetMoveAdvice(uix, ToLoc: Integer;
     130  var MoveAdviceData: TMoveAdviceData): Integer;
     131var
     132  MinEndHealth: Integer;
    133133begin
    134134  if MyModel[MyUn[uix].mix].Domain = dGround then
     
    142142      MoveAdviceData.MoreTurns := 999;
    143143      MoveAdviceData.MaxHostile_MovementLeft := MyUn[uix].Health - MinEndHealth;
    144       Result := Server(sGetMoveAdvice, me, uix, MoveAdviceData);
     144      Result := Server(sGetMoveAdvice, Me, uix, MoveAdviceData);
    145145      if (MinEndHealth <= 1) or (Result <> eNoWay) then
    146         exit;
     146        Exit;
    147147    end;
    148148    case MinEndHealth of
     
    159159end;
    160160
    161 function ColorOfHealth(Health: integer): integer;
    162 var
    163   red, green: integer;
    164 begin
    165   green := 400 * Health div 100;
    166   if green > 200 then
    167     green := 200;
    168   red := 510 * (100 - Health) div 100;
    169   if red > 255 then
    170     red := 255;
    171   Result := green shl 8 + red;
    172 end;
    173 
    174 function IsMultiPlayerGame: boolean;
    175 var
    176   p1: integer;
     161function ColorOfHealth(Health: Integer): Integer;
     162var
     163  Red, Green: Integer;
     164begin
     165  Green := 400 * Health div 100;
     166  if Green > 200 then
     167    Green := 200;
     168  Red := 510 * (100 - Health) div 100;
     169  if Red > 255 then
     170    Red := 255;
     171  Result := Green shl 8 + Red;
     172end;
     173
     174function IsMultiPlayerGame: Boolean;
     175var
     176  p1: Integer;
    177177begin
    178178  Result := False;
     
    182182end;
    183183
    184 procedure ItsMeAgain(p: integer);
    185 begin
    186   if G.RO[p] <> nil then
    187     MyRO := pointer(G.RO[p])
    188   else if G.SuperVisorRO[p] <> nil then
    189     MyRO := pointer(G.SuperVisorRO[p])
     184procedure ItsMeAgain(P: Integer);
     185begin
     186  if G.RO[P] <> nil then
     187    MyRO := Pointer(G.RO[P])
     188  else if G.SuperVisorRO[P] <> nil then
     189    MyRO := Pointer(G.SuperVisorRO[P])
    190190  else
    191     exit;
    192   me := p;
    193   MyMap := pointer(MyRO.Map);
    194   MyUn := pointer(MyRO.Un);
    195   MyCity := pointer(MyRO.City);
    196   MyModel := pointer(MyRO.Model);
    197 end;
    198 
    199 function GetAge(p: integer): integer;
    200 var
    201   i: integer;
    202 begin
    203   if p = me then begin
     191    Exit;
     192  Me := P;
     193  MyMap := Pointer(MyRO.Map);
     194  MyUn := Pointer(MyRO.Un);
     195  MyCity := Pointer(MyRO.City);
     196  MyModel := Pointer(MyRO.Model);
     197end;
     198
     199function GetAge(P: Integer): Integer;
     200var
     201  I: Integer;
     202begin
     203  if P = Me then begin
    204204    Result := 0;
    205     for i := 1 to 3 do
    206       if MyRO.Tech[AgePreq[i]] >= tsApplicable then
    207         Result := i;
     205    for I := 1 to 3 do
     206      if MyRO.Tech[AgePreq[I]] >= tsApplicable then
     207        Result := I;
    208208  end else begin
    209209    Result := 0;
    210     for i := 1 to 3 do
    211       if MyRO.EnemyReport[p].Tech[AgePreq[i]] >= tsApplicable then
    212         Result := i;
    213   end;
    214 end;
    215 
    216 function IsCivilReportNew(Enemy: integer): boolean;
    217 var
    218   i: integer;
    219 begin
    220   assert(Enemy <> me);
    221   i := MyRO.EnemyReport[Enemy].TurnOfCivilReport;
    222   Result := (i = MyRO.Turn) or (i = MyRO.Turn - 1) and (Enemy > me);
    223 end;
    224 
    225 function IsMilReportNew(Enemy: integer): boolean;
    226 var
    227   i: integer;
    228 begin
    229   assert(Enemy <> me);
    230   i := MyRO.EnemyReport[Enemy].TurnOfMilReport;
    231   Result := (i = MyRO.Turn) or (i = MyRO.Turn - 1) and (Enemy > me);
    232 end;
    233 
    234 function CutCityFoodSurplus(FoodSurplus: integer; IsCityAlive: boolean;
    235   gov, size: integer): integer;
     210    for I := 1 to 3 do
     211      if MyRO.EnemyReport[P].Tech[AgePreq[I]] >= tsApplicable then
     212        Result := I;
     213  end;
     214end;
     215
     216function IsCivilReportNew(Enemy: Integer): Boolean;
     217var
     218  I: Integer;
     219begin
     220  Assert(Enemy <> Me);
     221  I := MyRO.EnemyReport[Enemy].TurnOfCivilReport;
     222  Result := (I = MyRO.Turn) or (I = MyRO.Turn - 1) and (Enemy > Me);
     223end;
     224
     225function IsMilReportNew(Enemy: Integer): Boolean;
     226var
     227  I: Integer;
     228begin
     229  Assert(Enemy <> Me);
     230  I := MyRO.EnemyReport[Enemy].TurnOfMilReport;
     231  Result := (I = MyRO.Turn) or (I = MyRO.Turn - 1) and (Enemy > Me);
     232end;
     233
     234function CutCityFoodSurplus(FoodSurplus: Integer; IsCityAlive: Boolean;
     235  gov, size: Integer): Integer;
    236236begin
    237237  Result := FoodSurplus;
     
    241241end;
    242242
    243 function CityTaxBalance(cix: integer; const CityReport: TCityReportNew): integer;
    244 var
    245   i: integer;
     243function CityTaxBalance(cix: Integer; const CityReport: TCityReportNew): Integer;
     244var
     245  I: Integer;
    246246begin
    247247  Result := 0;
     
    258258      Inc(Result, CityReport.FoodSurplus);
    259259  end;
    260   for i := nWonder to nImp - 1 do
    261     if MyCity[cix].Built[i] > 0 then
    262       Dec(Result, Imp[i].Maint);
    263 end;
    264 
    265 procedure SumCities(var TaxSum, ScienceSum: integer);
    266 var
    267   cix: integer;
     260  for I := nWonder to nImp - 1 do
     261    if MyCity[cix].Built[I] > 0 then
     262      Dec(Result, Imp[I].Maint);
     263end;
     264
     265procedure SumCities(var TaxSum, ScienceSum: Integer);
     266var
     267  cix: Integer;
    268268  CityReport: TCityReportNew;
    269269begin
     
    271271  ScienceSum := 0;
    272272  if MyRO.Government = gAnarchy then
    273     exit;
     273    Exit;
    274274  for cix := 0 to MyRO.nCity - 1 do
    275275    if MyCity[cix].Loc >= 0 then
     
    278278      CityReport.HypoTaxRate := -1;
    279279      CityReport.HypoLuxuryRate := -1;
    280       Server(sGetCityReportNew, me, cix, CityReport);
     280      Server(sGetCityReportNew, Me, cix, CityReport);
    281281      if (CityReport.HappinessBalance >= 0) { no disorder } and
    282282        (MyCity[cix].Flags and chCaptured = 0) then // not captured
     
    286286end;
    287287
    288 function JobTest(uix, Job: integer; IgnoreResults: JobResultSet): boolean;
    289 var
    290   Test: integer;
    291 begin
    292   Test := Server(sStartJob + Job shl 4 - sExecute, me, uix, nil^);
     288function JobTest(uix, Job: Integer; IgnoreResults: JobResultSet): Boolean;
     289var
     290  Test: Integer;
     291begin
     292  Test := Server(sStartJob + Job shl 4 - sExecute, Me, uix, nil^);
    293293  Result := (Test >= rExecuted) or (Test in IgnoreResults);
    294294end;
    295295
    296 procedure GetUnitInfo(Loc: integer; var uix: integer; var UnitInfo: TUnitInfo);
    297 var
    298   i, Cnt: integer;
     296procedure GetUnitInfo(Loc: Integer; var uix: Integer; var UnitInfo: TUnitInfo);
     297var
     298  I, Cnt: Integer;
    299299begin
    300300  if MyMap[Loc] and fOwned <> 0 then
    301301  begin
    302     Server(sGetDefender, me, Loc, uix);
     302    Server(sGetDefender, Me, Loc, uix);
    303303    Cnt := 0;
    304     for i := 0 to MyRO.nUn - 1 do
    305       if MyUn[i].Loc = Loc then
     304    for I := 0 to MyRO.nUn - 1 do
     305      if MyUn[I].Loc = Loc then
    306306        Inc(Cnt);
    307     MakeUnitInfo(me, MyUn[uix], UnitInfo);
     307    MakeUnitInfo(Me, MyUn[uix], UnitInfo);
    308308    if Cnt > 1 then
    309309      UnitInfo.Flags := UnitInfo.Flags or unMulti;
     
    318318end;
    319319
    320 procedure GetCityInfo(Loc: integer; var cix: integer; var CityInfo: TCityInfo);
     320procedure GetCityInfo(Loc: Integer; var cix: Integer; var CityInfo: TCityInfo);
    321321begin
    322322  if MyMap[Loc] and fOwned <> 0 then
     
    328328    with CityInfo do
    329329    begin
    330       Owner := me;
     330      Owner := Me;
    331331      ID := MyCity[cix].ID;
    332332      size := MyCity[cix].size;
     
    356356end;
    357357
    358 function UnitExhausted(uix: integer): boolean;
     358function UnitExhausted(uix: Integer): Boolean;
    359359  // check if another move of this unit is still possible
    360360var
    361   dx, dy: integer;
     361  dx, dy: Integer;
    362362begin
    363363  Result := True;
    364364  if (MyUn[uix].Movement > 0) or
    365     (MyRO.Wonder[woShinkansen].EffectiveOwner = me) then
     365    (MyRO.Wonder[woShinkansen].EffectiveOwner = Me) then
    366366    if (MyUn[uix].Movement >= 100) or
    367367      ((MyModel[MyUn[uix].mix].Kind = mkCaravan) and
     
    373373          if abs(dx) + abs(dy) = 2 then
    374374            if Server(sMoveUnit - sExecute + dx and 7 shl 4 + dy and
    375               7 shl 7, me, uix, nil^) >= rExecuted then
     375              7 shl 7, Me, uix, nil^) >= rExecuted then
    376376              Result := False;
    377377end;
    378378
    379 function ModelHash(const ModelInfo: TModelInfo): integer;
    380 var
    381   i, FeatureCode, Hash1, Hash2, Hash2r, d: cardinal;
     379function ModelHash(const ModelInfo: TModelInfo): Integer;
     380var
     381  I, FeatureCode, Hash1, Hash2, Hash2r, D: Cardinal;
    382382begin
    383383  with ModelInfo do
    384384    if Kind > mkEnemyDeveloped then
    385       Result := integer($C0000000 + Speed div 50 + Kind shl 8)
     385      Result := Integer($C0000000 + Speed div 50 + Kind shl 8)
    386386    else
    387387    begin
    388388      FeatureCode := 0;
    389       for i := mcFirstNonCap to nFeature - 1 do
    390         if 1 shl Domain and Feature[i].Domains <> 0 then
     389      for I := mcFirstNonCap to nFeature - 1 do
     390        if 1 shl Domain and Feature[I].Domains <> 0 then
    391391        begin
    392392          FeatureCode := FeatureCode * 2;
    393           if 1 shl (i - mcFirstNonCap) <> 0 then
     393          if 1 shl (I - mcFirstNonCap) <> 0 then
    394394            Inc(FeatureCode);
    395395        end;
     
    397397        dGround:
    398398        begin
    399           assert(FeatureCode < 1 shl 8);
    400           assert(Attack < 5113);
    401           assert(Defense < 2273);
    402           assert(Cost < 1611);
     399          Assert(FeatureCode < 1 shl 8);
     400          Assert(Attack < 5113);
     401          Assert(Defense < 2273);
     402          Assert(Cost < 1611);
    403403          Hash1 := (Attack * 2273 + Defense) * 9 + (Speed - 150) div 50;
    404404          Hash2 := FeatureCode * 1611 + Cost;
     
    406406        dSea:
    407407        begin
    408           assert(FeatureCode < 1 shl 9);
    409           assert(Attack < 12193);
    410           assert(Defense < 6097);
    411           assert(Cost < 4381);
     408          Assert(FeatureCode < 1 shl 9);
     409          Assert(Attack < 12193);
     410          Assert(Defense < 6097);
     411          Assert(Cost < 4381);
    412412          Hash1 := ((Attack * 6097 + Defense) * 5 +
    413413            (Speed - 350) div 100) * 2;
     
    419419        dAir:
    420420        begin
    421           assert(FeatureCode < 1 shl 5);
    422           assert(Attack < 2407);
    423           assert(Defense < 1605);
    424           assert(Bombs < 4813);
    425           assert(Cost < 2089);
     421          Assert(FeatureCode < 1 shl 5);
     422          Assert(Attack < 2407);
     423          Assert(Defense < 1605);
     424          Assert(Bombs < 4813);
     425          Assert(Cost < 2089);
    426426          Hash1 := (Attack * 1605 + Defense) shl 5 + FeatureCode;
    427427          Hash2 := ((Bombs * 7 + ATrans_Fuel) * 4 + TTrans) * 2089 + Cost;
     
    429429      end;
    430430      Hash2r := 0;
    431       for i := 0 to 7 do
     431      for I := 0 to 7 do
    432432      begin
    433433        Hash2r := Hash2r * 13;
    434         d := Hash2 div 13;
    435         Inc(Hash2r, Hash2 - d * 13);
    436         Hash2 := d;
     434        D := Hash2 div 13;
     435        Inc(Hash2r, Hash2 - D * 13);
     436        Hash2 := D;
    437437      end;
    438       Result := integer(Domain shl 30 + Hash1 xor Hash2r);
     438      Result := Integer(Domain shl 30 + Hash1 xor Hash2r);
    439439    end;
    440440end;
    441441
    442 function ProcessEnhancement(uix: integer; const Jobs: TEnhancementJobs): integer;
     442function ProcessEnhancement(uix: Integer; const Jobs: TEnhancementJobs): Integer;
    443443  { return values:
    444444    eJobDone - all applicable jobs done
     
    446446    eDied - job done and died (thurst) }
    447447var
    448   stage, NextJob, Tile: integer;
     448  stage, NextJob, Tile: Integer;
    449449  Done: set of jNone .. jPoll;
    450450begin
     
    452452  Tile := MyMap[MyUn[uix].Loc];
    453453  if Tile and fRoad <> 0 then
    454     include(Done, jRoad);
     454    Include(Done, jRoad);
    455455  if Tile and fRR <> 0 then
    456     include(Done, jRR);
     456    Include(Done, jRR);
    457457  if (Tile and fTerImp = tiIrrigation) or (Tile and fTerImp = tiFarm) then
    458     include(Done, jIrr);
     458    Include(Done, jIrr);
    459459  if Tile and fTerImp = tiFarm then
    460     include(Done, jFarm);
     460    Include(Done, jFarm);
    461461  if Tile and fTerImp = tiMine then
    462     include(Done, jMine);
     462    Include(Done, jMine);
    463463  if Tile and fPoll = 0 then
    464     include(Done, jPoll);
     464    Include(Done, jPoll);
    465465
    466466  if MyUn[uix].Job = jNone then
     
    485485      Break;
    486486    end; // tile enhancement complete
    487     Result := Server(sStartJob + NextJob shl 4, me, uix, nil^);
    488     include(Done, NextJob);
    489   end;
    490 end;
    491 
    492 function AutoBuild(cix: integer; const ImpOrder: TImpOrder): boolean;
    493 var
    494   i, NewProject: integer;
     487    Result := Server(sStartJob + NextJob shl 4, Me, uix, nil^);
     488    Include(Done, NextJob);
     489  end;
     490end;
     491
     492function AutoBuild(cix: Integer; const ImpOrder: TImpOrder): Boolean;
     493var
     494  I, NewProject: Integer;
    495495begin
    496496  Result := False;
     
    498498    (MyCity[cix].Flags and chProduction <> 0) then
    499499  begin
    500     i := 0;
     500    I := 0;
    501501    repeat
    502       while (ImpOrder[i] >= 0) and (MyCity[cix].Built[ImpOrder[i]] > 0) do
    503         Inc(i);
    504       if ImpOrder[i] < 0 then
     502      while (ImpOrder[I] >= 0) and (MyCity[cix].Built[ImpOrder[I]] > 0) do
     503        Inc(I);
     504      if ImpOrder[I] < 0 then
    505505        Break;
    506       assert(i < nImp);
    507       NewProject := cpImp + ImpOrder[i];
    508       if Server(sSetCityProject, me, cix, NewProject) >= rExecuted then
     506      Assert(I < nImp);
     507      NewProject := cpImp + ImpOrder[I];
     508      if Server(sSetCityProject, Me, cix, NewProject) >= rExecuted then
    509509      begin
    510510        Result := True;
     
    512512        Break;
    513513      end;
    514       Inc(i);
     514      Inc(I);
    515515    until False;
    516516  end;
     
    519519procedure CalculateAdvValues;
    520520var
    521   i, j: integer;
    522   known: array [0 .. nAdv - 1] of integer;
    523 
    524   procedure MarkPreqs(i: integer);
    525   begin
    526     if known[i] = 0 then
     521  I, J: Integer;
     522  known: array [0 .. nAdv - 1] of Integer;
     523
     524  procedure MarkPreqs(I: Integer);
     525  begin
     526    if known[I] = 0 then
    527527    begin
    528       known[i] := 1;
    529       if (i <> adScience) and (i <> adMassProduction) then
     528      known[I] := 1;
     529      if (I <> adScience) and (I <> adMassProduction) then
    530530      begin
    531         if (AdvPreq[i, 0] >= 0) then
    532           MarkPreqs(AdvPreq[i, 0]);
    533         if (AdvPreq[i, 1] >= 0) then
    534           MarkPreqs(AdvPreq[i, 1]);
     531        if (AdvPreq[I, 0] >= 0) then
     532          MarkPreqs(AdvPreq[I, 0]);
     533        if (AdvPreq[I, 1] >= 0) then
     534          MarkPreqs(AdvPreq[I, 1]);
    535535      end;
    536536    end;
     
    539539begin
    540540  FillChar(AdvValue, SizeOf(AdvValue), 0);
    541   for i := 0 to nAdv - 1 do
     541  for I := 0 to nAdv - 1 do
    542542  begin
    543543    FillChar(known, SizeOf(known), 0);
    544     MarkPreqs(i);
    545     for j := 0 to nAdv - 1 do
    546       if known[j] > 0 then
    547         Inc(AdvValue[i]);
    548     if i in FutureTech then
    549       Inc(AdvValue[i], 3000)
     544    MarkPreqs(I);
     545    for J := 0 to nAdv - 1 do
     546      if known[J] > 0 then
     547        Inc(AdvValue[I]);
     548    if I in FutureTech then
     549      Inc(AdvValue[I], 3000)
    550550    else if known[adMassProduction] > 0 then
    551       Inc(AdvValue[i], 2000)
     551      Inc(AdvValue[I], 2000)
    552552    else if known[adScience] > 0 then
    553       Inc(AdvValue[i], 1000);
    554   end;
    555 end;
    556 
    557 procedure DebugMessage(Level: integer; Text: string);
    558 begin
    559   Server(sMessage, me, Level, PChar(Text)^);
    560 end;
    561 
    562 function MarkCitiesAround(Loc, cixExcept: integer): boolean;
     553      Inc(AdvValue[I], 1000);
     554  end;
     555end;
     556
     557procedure DebugMessage(Level: Integer; Text: string);
     558begin
     559  Server(sMessage, Me, Level, PChar(Text)^);
     560end;
     561
     562function MarkCitiesAround(Loc, cixExcept: Integer): Boolean;
    563563  // return whether a city was marked
    564564var
    565   cix: integer;
     565  cix: Integer;
    566566begin
    567567  Result := False;
     
    576576end;
    577577
    578 procedure OptimizeCities(CheckOnly: boolean);
    579 var
    580   cix, fix, dx, dy, Loc1, OptiType: integer;
    581   Done: boolean;
     578procedure OptimizeCities(CheckOnly: Boolean);
     579var
     580  cix, fix, dx, dy, Loc1, OptiType: Integer;
     581  Done: Boolean;
    582582  Advice: TCityTileAdviceData;
    583583begin
     
    591591        begin
    592592          Advice.ResourceWeights := OfferedResourceWeights[OptiType];
    593           Server(sGetCityTileAdvice, me, cix, Advice);
     593          Server(sGetCityTileAdvice, Me, cix, Advice);
    594594          if Advice.Tiles <> MyCity[cix].Tiles then
    595595            if CheckOnly then
     
    611611                    Done := False;
    612612                end;
    613               Server(sSetCityTiles, me, cix, Advice.Tiles);
     613              Server(sSetCityTiles, Me, cix, Advice.Tiles);
    614614            end;
    615615        end;
     
    621621procedure CityOptimizer_BeginOfTurn;
    622622var
    623   cix: integer;
     623  cix: Integer;
    624624begin
    625625  FillChar(CityNeedsOptimize, MyRO.nCity - 1, 0); // false
     
    634634end;
    635635
    636 procedure CityOptimizer_CityChange(cix: integer);
     636procedure CityOptimizer_CityChange(cix: Integer);
    637637begin
    638638  if (MyRO.Government <> gAnarchy) and (cix <> -1) and (MyCity[cix].Flags and
     
    644644end;
    645645
    646 procedure CityOptimizer_TileBecomesAvailable(Loc: integer);
     646procedure CityOptimizer_TileBecomesAvailable(Loc: Integer);
    647647begin
    648648  if (MyRO.Government <> gAnarchy) and MarkCitiesAround(Loc, -1) then
     
    650650end;
    651651
    652 procedure CityOptimizer_ReleaseCityTiles(cix, ReleasedTiles: integer);
    653 var
    654   fix, dx, dy, Loc1: integer;
    655   Done: boolean;
     652procedure CityOptimizer_ReleaseCityTiles(cix, ReleasedTiles: Integer);
     653var
     654  fix, dx, dy, Loc1: Integer;
     655  Done: Boolean;
    656656begin
    657657  if (MyRO.Government <> gAnarchy) and (ReleasedTiles <> 0) then
     
    672672end;
    673673
    674 procedure CityOptimizer_BeforeRemoveUnit(uix: integer);
    675 var
    676   uix1: integer;
     674procedure CityOptimizer_BeforeRemoveUnit(uix: Integer);
     675var
     676  uix1: Integer;
    677677begin
    678678  if MyRO.Government <> gAnarchy then
     
    698698// all cities should already be optimized here -- only check this
    699699var
    700   cix: integer;
     700  cix: Integer;
    701701begin
    702702{$IFOPT O-}
  • trunk/LocalPlayer/Diagram.pas

    r442 r447  
    1919    procedure ToggleBtnClick(Sender: TObject);
    2020    procedure PlayerClick(Sender: TObject);
    21     procedure FormKeyDown(Sender: TObject; var Key: word; Shift: TShiftState);
     21    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    2222
    2323  public
    2424    procedure OffscreenPaint; override;
    2525    procedure ShowNewContent_Charts(NewMode: TWindowMode);
    26     procedure ShowNewContent_Ship(NewMode: TWindowMode; p: integer = -1);
     26    procedure ShowNewContent_Ship(NewMode: TWindowMode; P: Integer = -1);
    2727
    2828  private
    2929    Kind: (dkChart, dkShip);
    30     Player, Mode: integer;
     30    Player, Mode: Integer;
    3131  end;
    3232
     
    3434  DiaDlg: TDiaDlg;
    3535
    36 procedure PaintColonyShip(canvas: TCanvas; Player, Left, Width, Top: integer);
     36procedure PaintColonyShip(Canvas: TCanvas; Player, Left, Width, Top: Integer);
    3737
    3838implementation
     
    4545const
    4646  Border = 24;
    47   RoundPixels: array [0 .. nStat - 1] of integer = (0, 0, 0, 5, 5, 5);
     47  RoundPixels: array [0 .. nStat - 1] of Integer = (0, 0, 0, 5, 5, 5);
    4848
    4949  yArea = 48;
    50   xComp: array [0 .. 5] of integer = (-60, -28, 4, 4, 36, 68);
    51   yComp: array [0 .. 5] of integer = (-40, -40, -79, -1, -40, -40);
    52   xPow: array [0 .. 3] of integer = (-116, -116, -116, -116);
    53   yPow: array [0 .. 3] of integer = (-28, 0, -44, 16);
    54   xHab: array [0 .. 1] of integer = (23, 23);
    55   yHab: array [0 .. 1] of integer = (-81, 1);
    56 
    57 procedure PaintColonyShip(canvas: TCanvas; Player, Left, Width, Top: integer);
    58 var
    59   i, x, r, nComp, nPow, nHab: integer;
     50  xComp: array [0 .. 5] of Integer = (-60, -28, 4, 4, 36, 68);
     51  yComp: array [0 .. 5] of Integer = (-40, -40, -79, -1, -40, -40);
     52  xPow: array [0 .. 3] of Integer = (-116, -116, -116, -116);
     53  yPow: array [0 .. 3] of Integer = (-28, 0, -44, 16);
     54  xHab: array [0 .. 1] of Integer = (23, 23);
     55  yHab: array [0 .. 1] of Integer = (-81, 1);
     56
     57procedure PaintColonyShip(Canvas: TCanvas; Player, Left, Width, Top: Integer);
     58var
     59  I, X, R, nComp, nPow, nHab: Integer;
    6060begin
    6161  Canvas.Brush.Color := $000000;
    6262  Canvas.FillRect(Rect(Left, Top, Left + Width, Top + 200));
    6363  Canvas.Brush.Style := bsClear;
    64     ScreenTools.Frame(canvas, Left - 1, Top - 1, Left + Width, Top + 200,
     64    ScreenTools.Frame(Canvas, Left - 1, Top - 1, Left + Width, Top + 200,
    6565      MainTexture.ColorBevelShade, MainTexture.ColorBevelLight);
    66     RFrame(canvas, Left - 2, Top - 2, Left + Width + 1, Top + 200 + 1,
     66    RFrame(Canvas, Left - 2, Top - 2, Left + Width + 1, Top + 200 + 1,
    6767      MainTexture.ColorBevelShade, MainTexture.ColorBevelLight);
    6868
    6969    // stars
    7070    DelphiRandSeed := Player * 11111;
    71     for i := 1 to Width - 16 do
     71    for I := 1 to Width - 16 do
    7272    begin
    73       x := DelphiRandom((Width - 16) * 200);
    74       r := DelphiRandom(13) + 28;
    75       Canvas.Pixels[x div 200 + 8, x mod 200 + Top] :=
    76         (r * r * r * r div 10001) * $10101;
     73      X := DelphiRandom((Width - 16) * 200);
     74      R := DelphiRandom(13) + 28;
     75      Canvas.Pixels[X div 200 + 8, X mod 200 + Top] :=
     76        (R * R * R * R div 10001) * $10101;
    7777    end;
    7878
     
    8686    if nHab > 2 then
    8787      nHab := 2;
    88     for i := 0 to nHab - 1 do
    89       Sprite(canvas, HGrSystem2, Left + Width div 2 + xHab[i],
    90         Top + 100 + yHab[i], 80, 80, 34, 1);
    91     for i := 0 to nComp - 1 do
    92       Sprite(canvas, HGrSystem2, Left + Width div 2 + xComp[i],
    93         Top + 100 + yComp[i], 32, 80, 1, 1);
     88    for I := 0 to nHab - 1 do
     89      Sprite(Canvas, HGrSystem2, Left + Width div 2 + xHab[I],
     90        Top + 100 + yHab[I], 80, 80, 34, 1);
     91    for I := 0 to nComp - 1 do
     92      Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[I],
     93        Top + 100 + yComp[I], 32, 80, 1, 1);
    9494    if nComp > 0 then
    95       for i := 3 downto nPow do
    96         Sprite(canvas, HGrSystem2, Left + Width div 2 + xPow[i] + 40,
    97           Top + 100 + yPow[i], 16, 27, 1, 82);
    98     for i := nPow - 1 downto 0 do
    99       Sprite(canvas, HGrSystem2, Left + Width div 2 + xPow[i],
    100         Top + 100 + yPow[i], 56, 28, 58, 82);
     95      for I := 3 downto nPow do
     96        Sprite(Canvas, HGrSystem2, Left + Width div 2 + xPow[I] + 40,
     97          Top + 100 + yPow[I], 16, 27, 1, 82);
     98    for I := nPow - 1 downto 0 do
     99      Sprite(Canvas, HGrSystem2, Left + Width div 2 + xPow[I],
     100        Top + 100 + yPow[I], 56, 28, 58, 82);
    101101    if (nComp < 3) and (nHab >= 1) then
    102       Sprite(canvas, HGrSystem2, Left + Width div 2 + xComp[2] + 32 - 16,
     102      Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[2] + 32 - 16,
    103103        Top + 100 + 7 + yComp[2], 16, 27, 1, 82);
    104104    if (nComp >= 3) and (nHab < 1) then
    105       Sprite(canvas, HGrSystem2, Left + Width div 2 + xComp[2] + 32,
     105      Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[2] + 32,
    106106        Top + 100 + 7 + yComp[2], 16, 27, 18, 82);
    107107    if (nComp < 4) and (nHab >= 2) then
    108       Sprite(canvas, HGrSystem2, Left + Width div 2 + xComp[3] + 32 - 16,
     108      Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[3] + 32 - 16,
    109109        Top + 100 + 46 + yComp[3], 16, 27, 1, 82);
    110110    if (nComp >= 4) and (nHab < 2) then
    111       Sprite(canvas, HGrSystem2, Left + Width div 2 + xComp[3] + 32,
     111      Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[3] + 32,
    112112        Top + 100 + 46 + yComp[3], 16, 27, 18, 82);
    113113    if (nComp <> 6) and (nComp <> 2) and not((nComp = 0) and (nPow < 1)) then
    114       Sprite(canvas, HGrSystem2, Left + Width div 2 + xComp[nComp],
     114      Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[nComp],
    115115        Top + 100 + 7 + yComp[nComp], 16, 27, 18, 82);
    116116    if (nComp <> 6) and (nComp <> 3) and not((nComp = 0) and (nPow < 2)) then
    117       Sprite(canvas, HGrSystem2, Left + Width div 2 + xComp[nComp],
     117      Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[nComp],
    118118        Top + 100 + 46 + yComp[nComp], 16, 27, 18, 82);
    119119    if nComp = 2 then
    120       Sprite(canvas, HGrSystem2, Left + Width div 2 + xComp[3],
     120      Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[3],
    121121        Top + 100 + 7 + yComp[3], 16, 27, 18, 82);
    122122    if nComp = 3 then
    123       Sprite(canvas, HGrSystem2, Left + Width div 2 + xComp[4],
     123      Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[4],
    124124        Top + 100 + 7 + yComp[4], 16, 27, 18, 82);
    125125end;
     
    142142procedure TDiaDlg.OffscreenPaint;
    143143var
    144   p, T, max, x, y, y0, Stop, r, RoundRange, LineStep: integer;
    145   s: string;
     144  P, T, Max, X, Y, y0, Stop, R, RoundRange, LineStep: Integer;
     145  S: string;
    146146  List: ^TChart;
    147147
    148   function Round(T: integer): integer;
     148  function Round(T: Integer): Integer;
    149149  var
    150     n, i: integer;
     150    N, I: Integer;
    151151  begin
    152152    if T < RoundRange then
    153       n := T
     153      N := T
    154154    else
    155       n := RoundRange;
    156     result := 0;
    157     for i := T - n to T do
    158       inc(result, List[i]);
    159     result := result div (n + 1);
    160   end;
    161 
    162   procedure ShareBar(x, y: integer; Cap: string; val0, val1: integer);
    163   begin
    164     LoweredTextOut(offscreen.canvas, -1, MainTexture, x - 2, y, Cap);
    165     DLine(offscreen.canvas, x - 2, x + 169, y + 16, MainTexture.ColorTextShade,
     155      N := RoundRange;
     156    Result := 0;
     157    for I := T - N to T do
     158      Inc(Result, List[I]);
     159    Result := Result div (N + 1);
     160  end;
     161
     162  procedure ShareBar(X, Y: Integer; Cap: string; val0, val1: Integer);
     163  begin
     164    LoweredTextOut(Offscreen.Canvas, -1, MainTexture, X - 2, Y, Cap);
     165    DLine(Offscreen.Canvas, X - 2, X + 169, Y + 16, MainTexture.ColorTextShade,
    166166      MainTexture.ColorTextLight);
    167167    if val0 > 0 then
    168       s := Format(Phrases.Lookup('SHARE'), [val0, val1])
     168      S := Format(Phrases.Lookup('SHARE'), [val0, val1])
    169169    else
    170       s := '0';
    171     RisedTextOut(offscreen.canvas,
    172       x + 170 - BiColorTextWidth(offscreen.canvas, s), y, s);
     170      S := '0';
     171    RisedTextOut(Offscreen.Canvas,
     172      X + 170 - BiColorTextWidth(Offscreen.Canvas, S), Y, S);
    173173  end;
    174174
     
    176176  inherited;
    177177  if Kind = dkChart then
    178     with offscreen.canvas do
     178    with Offscreen.Canvas do
    179179    begin
    180180      Font.Assign(UniFont[ftTiny]);
     
    186186      GetMem(List, 4 * (MyRO.Turn + 2));
    187187      if Mode = stExplore then
    188         max := G.lx * G.ly
     188        Max := G.lx * G.ly
    189189      else
    190190      begin
    191         max := -1;
    192         for p := 0 to nPl - 1 do
    193           if (G.Difficulty[p] > 0) and
    194             (Server(sGetChart + Mode shl 4, me, p, List^) >= rExecuted) then
     191        Max := -1;
     192        for P := 0 to nPl - 1 do
     193          if (G.Difficulty[P] > 0) and
     194            (Server(sGetChart + Mode shl 4, Me, P, List^) >= rExecuted) then
    195195            for T := 0 to MyRO.Turn - 1 do
    196196            begin
    197               r := Round(T);
    198               if r > max then
    199                 max := r;
     197              R := Round(T);
     198              if R > Max then
     199                Max := R;
    200200            end;
    201201      end;
     
    215215      for T := 0 to (MyRO.Turn - 1) div LineStep do
    216216      begin
    217         x := Border + (InnerWidth - 2 * Border) * T *
     217        X := Border + (InnerWidth - 2 * Border) * T *
    218218          LineStep div (MyRO.Turn - 1);
    219         MoveTo(x, Border);
    220         LineTo(x, InnerHeight - Border);
    221         s := IntToStr(abs(TurnToYear(T * LineStep)));
    222         Textout(x - TextWidth(s) div 2, Border - 16, s);
     219        MoveTo(X, Border);
     220        LineTo(X, InnerHeight - Border);
     221        S := IntToStr(abs(TurnToYear(T * LineStep)));
     222        Textout(X - TextWidth(S) div 2, Border - 16, S);
    223223      end;
    224224
    225225      y0 := 0;
    226       if max > 0 then
     226      if Max > 0 then
    227227      begin
    228         for p := 0 to nPl - 1 do
    229           if (G.Difficulty[p] > 0) and
    230             (Server(sGetChart + Mode shl 4, me, p, List^) >= rExecuted) then
     228        for P := 0 to nPl - 1 do
     229          if (G.Difficulty[P] > 0) and
     230            (Server(sGetChart + Mode shl 4, Me, P, List^) >= rExecuted) then
    231231          begin
    232             Pen.Color := Tribe[p].Color;
     232            Pen.Color := Tribe[P].Color;
    233233            Stop := MyRO.Turn - 1;
    234234            while (Stop > 0) and (List[Stop] = 0) do
    235               dec(Stop);
     235              Dec(Stop);
    236236            for T := 0 to Stop do
    237237            begin
    238               r := Round(T);
    239               x := Border + (InnerWidth - 2 * Border) * T div (MyRO.Turn - 1);
    240               y := InnerHeight - Border - (InnerHeight - 2 * Border) *
    241                 r div max;
     238              R := Round(T);
     239              X := Border + (InnerWidth - 2 * Border) * T div (MyRO.Turn - 1);
     240              Y := InnerHeight - Border - (InnerHeight - 2 * Border) *
     241                R div Max;
    242242              if T = 0 then
    243                 MoveTo(x, y)
     243                MoveTo(X, Y)
    244244                // else if Mode=stTerritory then
    245245                // begin LineTo(x,y0); LineTo(x,y) end
    246246              else if RoundPixels[Mode] = 0 then
    247247              begin
    248                 if (y <> y0) or (T = Stop) then
    249                   LineTo(x, y)
     248                if (Y <> y0) or (T = Stop) then
     249                  LineTo(X, Y)
    250250              end
    251251              else
    252                 LineTo(x, y);
    253               y0 := y;
     252                LineTo(X, Y);
     253              y0 := Y;
    254254            end;
    255255          end;
     
    258258    end
    259259  else
    260     with offscreen.canvas do
     260    with Offscreen.Canvas do
    261261    begin
    262262      Font.Assign(UniFont[ftSmall]);
    263263      FillOffscreen(0, 0, InnerWidth, InnerHeight);
    264264
    265       PaintColonyShip(offscreen.canvas, Player, 8, InnerWidth - 16, yArea);
     265      PaintColonyShip(Offscreen.Canvas, Player, 8, InnerWidth - 16, yArea);
    266266
    267267      ShareBar(InnerWidth div 2 - 85, InnerHeight - 62,
     
    277277procedure TDiaDlg.FormPaint(Sender: TObject);
    278278var
    279   s: string;
     279  S: string;
    280280begin
    281281  inherited;
    282   canvas.Font.Assign(UniFont[ftNormal]);
     282  Canvas.Font.Assign(UniFont[ftNormal]);
    283283  if Kind = dkChart then
    284     s := Phrases.Lookup('DIAGRAM', Mode)
    285   else
    286     s := Tribe[Player].TPhrase('SHORTNAME');
    287   LoweredTextOut(canvas, -1, MainTexture,
    288     (ClientWidth - BiColorTextWidth(canvas, s)) div 2, 31, s);
     284    S := Phrases.Lookup('DIAGRAM', Mode)
     285  else
     286    S := Tribe[Player].TPhrase('SHORTNAME');
     287  LoweredTextOut(Canvas, -1, MainTexture,
     288    (ClientWidth - BiColorTextWidth(Canvas, S)) div 2, 31, S);
    289289end;
    290290
     
    309309end;
    310310
    311 procedure TDiaDlg.ShowNewContent_Ship(NewMode: TWindowMode; p: integer);
     311procedure TDiaDlg.ShowNewContent_Ship(NewMode: TWindowMode; P: Integer);
    312312begin
    313313  Kind := dkShip;
    314   if p < 0 then
    315   begin
    316     Player := me;
     314  if P < 0 then
     315  begin
     316    Player := Me;
    317317    while MyRO.Ship[Player].Parts[spComp] + MyRO.Ship[Player].Parts[spPow] +
    318318      MyRO.Ship[Player].Parts[spHab] = 0 do
     
    320320  end
    321321  else
    322     Player := p;
     322    Player := P;
    323323  ToggleBtn.ButtonIndex := 28;
    324324  ToggleBtn.Hint := Phrases.Lookup('BTN_SELECT');
     
    329329procedure TDiaDlg.ToggleBtnClick(Sender: TObject);
    330330var
    331   p1: integer;
    332   m: TMenuItem;
     331  p1: Integer;
     332  M: TMenuItem;
    333333begin
    334334  if Kind = dkChart then
     
    345345        MyRO.Ship[p1].Parts[spHab] > 0 then
    346346      begin
    347         m := TMenuItem.Create(Popup);
    348         m.RadioItem := true;
    349         m.Caption := Tribe[p1].TPhrase('SHORTNAME');
    350         m.Tag := p1;
    351         m.OnClick := PlayerClick;
     347        M := TMenuItem.Create(Popup);
     348        M.RadioItem := True;
     349        M.Caption := Tribe[p1].TPhrase('SHORTNAME');
     350        M.Tag := p1;
     351        M.OnClick := PlayerClick;
    352352        if p1 = Player then
    353           m.Checked := true;
    354         Popup.Items.Add(m);
     353          M.Checked := True;
     354        Popup.Items.Add(M);
    355355      end;
    356356    Popup.Popup(Left + ToggleBtn.Left, Top + ToggleBtn.Top + ToggleBtn.Height);
     
    363363end;
    364364
    365 procedure TDiaDlg.FormKeyDown(Sender: TObject; var Key: word;
     365procedure TDiaDlg.FormKeyDown(Sender: TObject; var Key: Word;
    366366  Shift: TShiftState);
    367367begin
  • trunk/LocalPlayer/Diplomacy.pas

    r38 r447  
    77
    88function DipCommandToString(pSender, pTarget, Treaty, OppCommand,
    9   Command: integer; const OppOffer, Offer: TOffer): string;
     9  Command: Integer; const OppOffer, Offer: TOffer): string;
    1010
    1111implementation
     
    1616function DipCommandToString;
    1717
    18   function PriceToString(p, Price: integer): string;
     18  function PriceToString(P, Price: Integer): string;
    1919  begin
    2020    case Price and opMask of
    2121      opChoose:
    22         result := Phrases.Lookup('PRICE_CHOOSE');
     22        Result := Phrases.Lookup('PRICE_CHOOSE');
    2323      opCivilReport:
    24         result := Tribe[p].TPhrase('PRICE_CIVIL');
     24        Result := Tribe[P].TPhrase('PRICE_CIVIL');
    2525      opMilReport:
    26         result := Tribe[p].TPhrase('PRICE_MIL');
     26        Result := Tribe[P].TPhrase('PRICE_MIL');
    2727      opMap:
    28         result := Tribe[p].TPhrase('PRICE_MAP');
     28        Result := Tribe[P].TPhrase('PRICE_MAP');
    2929      opTreaty:
    3030        { if Price-opTreaty<Treaty then
    3131          case Treaty of
    32           trPeace: result:=Phrases.Lookup('FRENDTREATY_PEACE');
    33           trFriendlyContact: result:=Phrases.Lookup('FRENDTREATY_FRIENDLY');
    34           trAlliance: result:=Phrases.Lookup('FRENDTREATY_ALLIANCE');
    35           end
    36           else } result := Phrases.Lookup('TREATY', Price - opTreaty);
     32          trPeace: Result:=Phrases.Lookup('FRENDTREATY_PEACE');
     33          trFriendlyContact: Result:=Phrases.Lookup('FRENDTREATY_FRIENDLY');
     34          trAlliance: Result:=Phrases.Lookup('FRENDTREATY_ALLIANCE');
     35          end
     36          else } Result := Phrases.Lookup('TREATY', Price - opTreaty);
    3737      opShipParts:
    3838        case Price shr 16 and $F of
    3939          0:
    40             result := Format(Phrases.Lookup('PRICE_SHIPCOMP'),
     40            Result := Format(Phrases.Lookup('PRICE_SHIPCOMP'),
    4141              [Price and $FFFF]);
    4242          1:
    43             result := Format(Phrases.Lookup('PRICE_SHIPPOW'),
     43            Result := Format(Phrases.Lookup('PRICE_SHIPPOW'),
    4444              [Price and $FFFF]);
    4545          2:
    46             result := Format(Phrases.Lookup('PRICE_SHIPHAB'),
     46            Result := Format(Phrases.Lookup('PRICE_SHIPHAB'),
    4747              [Price and $FFFF]);
    4848        end;
    4949      opMoney:
    50         result := Format('%d%%c', [Price - opMoney]);
     50        Result := Format('%d%%c', [Price - opMoney]);
    5151      opTribute:
    52         result := Format(Phrases.Lookup('PRICE_TRIBUTE'), [Price - opTribute]);
     52        Result := Format(Phrases.Lookup('PRICE_TRIBUTE'), [Price - opTribute]);
    5353      opTech:
    54         result := Phrases.Lookup('ADVANCES', Price - opTech);
     54        Result := Phrases.Lookup('ADVANCES', Price - opTech);
    5555      opAllTech:
    56         result := Tribe[p].TPhrase('PRICE_ALLTECH');
     56        Result := Tribe[P].TPhrase('PRICE_ALLTECH');
    5757      opModel:
    58         result := Tribe[p].ModelName[Price - opModel];
     58        Result := Tribe[P].ModelName[Price - opModel];
    5959      opAllModel:
    60         result := Tribe[p].TPhrase('PRICE_ALLMODEL');
     60        Result := Tribe[P].TPhrase('PRICE_ALLMODEL');
    6161      { opCity:
    62         result:=Format(TPhrase('PRICE_CITY',p),[CityName(Price-opCity)]); }
     62        Result:=Format(TPhrase('PRICE_CITY',P),[CityName(Price-opCity)]); }
    6363    end
    6464  end;
    6565
    6666var
    67   i: integer;
     67  I: Integer;
    6868  sAdd, sDeliver, sCost: string;
    69   DoIntro: boolean;
     69  DoIntro: Boolean;
    7070begin
    7171  DoIntro := OppCommand = scDipStart;
     
    7575        case Treaty of
    7676          trPeace:
    77             result := Phrases.Lookup('FRCANCELTREATY_PEACE');
     77            Result := Phrases.Lookup('FRCANCELTREATY_PEACE');
    7878          trFriendlyContact:
    79             result := Phrases.Lookup('FRCANCELTREATY_FRIENDLY');
     79            Result := Phrases.Lookup('FRCANCELTREATY_FRIENDLY');
    8080          trAlliance:
    81             result := Phrases.Lookup('FRCANCELTREATY_ALLIANCE');
    82         end;
    83         DoIntro := false;
     81            Result := Phrases.Lookup('FRCANCELTREATY_ALLIANCE');
     82        end;
     83        DoIntro := False;
    8484      end;
    8585    scDipNotice:
    86       result := Phrases.Lookup('FRNOTICE');
     86      Result := Phrases.Lookup('FRNOTICE');
    8787    scDipAccept:
    8888      begin
    8989        if (OppOffer.nDeliver + OppOffer.nCost = 1) and
    9090          (OppOffer.Price[0] and opMask = opTreaty) and
    91           (integer(OppOffer.Price[0] - opTreaty) > Treaty) then
     91          (Integer(OppOffer.Price[0] - opTreaty) > Treaty) then
    9292        // simple treaty offer
    9393          { if OppOffer.Price[0]-opTreaty=trCeaseFire then
    94             result:=Tribe[pTarget].TPhrase('FRACCEPTCEASEFIRE')
    95             else } result := Tribe[pTarget].TPhrase('FRACCEPTTREATY')
     94            Result:=Tribe[pTarget].TPhrase('FRACCEPTCEASEFIRE')
     95            else } Result := Tribe[pTarget].TPhrase('FRACCEPTTREATY')
    9696        else if OppOffer.nDeliver = 0 then
    97           result := Tribe[pSender].TPhrase('FRACCEPTDEMAND_STRONG')
     97          Result := Tribe[pSender].TPhrase('FRACCEPTDEMAND_STRONG')
    9898        else if OppOffer.nCost = 0 then
    99           result := Tribe[pSender].TPhrase('FRACCEPTPRESENT')
     99          Result := Tribe[pSender].TPhrase('FRACCEPTPRESENT')
    100100        else
    101           result := Tribe[pSender].TPhrase('FRACCEPTOFFER');
     101          Result := Tribe[pSender].TPhrase('FRACCEPTOFFER');
    102102      end;
    103103    scDipBreak:
    104104      begin
    105         result := Tribe[pTarget].TPhrase('FRBREAK');
    106         DoIntro := false;
     105        Result := Tribe[pTarget].TPhrase('FRBREAK');
     106        DoIntro := False;
    107107      end;
    108108    scDipOffer:
    109109      begin
    110         result := '';
     110        Result := '';
    111111        if (OppCommand = scDipOffer) and
    112112          ((OppOffer.nDeliver > 0) or (OppOffer.nCost > 0)) and
     
    115115          if (OppOffer.nDeliver + OppOffer.nCost = 1) and
    116116            (OppOffer.Price[0] and opMask = opTreaty) and
    117             (integer(OppOffer.Price[0] - opTreaty) > Treaty) then
     117            (Integer(OppOffer.Price[0] - opTreaty) > Treaty) then
    118118          // simple treaty offer
    119             result := Tribe[pSender].TPhrase('FRNOTACCEPTTREATY') + '\'
     119            Result := Tribe[pSender].TPhrase('FRNOTACCEPTTREATY') + '\'
    120120          else if OppOffer.nDeliver = 0 then
    121             result := Tribe[pSender].TPhrase('FRNOTACCEPTDEMAND_STRONG') + '\'
     121            Result := Tribe[pSender].TPhrase('FRNOTACCEPTDEMAND_STRONG') + '\'
    122122          else if OppOffer.nCost = 0 then
    123             result := Tribe[pSender].TPhrase('FRNOTACCEPTPRESENT') + '\';
     123            Result := Tribe[pSender].TPhrase('FRNOTACCEPTPRESENT') + '\';
    124124        end;
    125125
    126126        sDeliver := '';
    127         for i := 0 to Offer.nDeliver - 1 do
    128         begin
    129           sAdd := PriceToString(pSender, Offer.Price[i]);
    130           if i = 0 then
     127        for I := 0 to Offer.nDeliver - 1 do
     128        begin
     129          sAdd := PriceToString(pSender, Offer.Price[I]);
     130          if I = 0 then
    131131            sDeliver := sAdd
    132132          else
     
    134134        end;
    135135        sCost := '';
    136         for i := 0 to Offer.nCost - 1 do
    137         begin
    138           sAdd := PriceToString(pTarget, Offer.Price[Offer.nDeliver + i]);
    139           if i = 0 then
     136        for I := 0 to Offer.nCost - 1 do
     137        begin
     138          sAdd := PriceToString(pTarget, Offer.Price[Offer.nDeliver + I]);
     139          if I = 0 then
    140140            sCost := sAdd
    141141          else
     
    147147          if (OppCommand = scDipOffer) and
    148148            ((OppOffer.nDeliver = 0) and (OppOffer.nCost = 0)) then
    149             result := Tribe[pTarget].TPhrase('FRBYE')
     149            Result := Tribe[pTarget].TPhrase('FRBYE')
    150150          else
    151151          begin
    152             if (result = '') and (OppCommand = scDipOffer) and
     152            if (Result = '') and (OppCommand = scDipOffer) and
    153153              ((OppOffer.nDeliver > 0) or (OppOffer.nCost > 0)) then
    154154            begin
    155155              if (OppOffer.nDeliver = 1) and (OppOffer.Price[0] = opChoose) and
    156156                not Phrases2FallenBackToEnglish then
    157                 result := Tribe[pSender].TString
     157                Result := Tribe[pSender].TString
    158158                  (Phrases2.Lookup('FRNOTACCEPTANYOFFER')) + ' '
    159159              else if (OppOffer.nCost = 1) and
    160160                (OppOffer.Price[OppOffer.nDeliver] = opChoose) and not Phrases2FallenBackToEnglish
    161161              then
    162                 result := Tribe[pSender].TString
     162                Result := Tribe[pSender].TString
    163163                  (Phrases2.Lookup('FRNOTACCEPTANYWANT')) + ' '
    164164              else
    165                 result := Tribe[pSender].TPhrase('FRNOTACCEPTOFFER') + ' ';
     165                Result := Tribe[pSender].TPhrase('FRNOTACCEPTOFFER') + ' ';
    166166            end;
    167             result := result + Phrases.Lookup('FRDONE');
    168             DoIntro := false
     167            Result := Result + Phrases.Lookup('FRDONE');
     168            DoIntro := False
    169169          end
    170170        end
    171171        else if (Offer.nDeliver + Offer.nCost = 1) and
    172172          (Offer.Price[0] and opMask = opTreaty) and
    173           (integer(Offer.Price[0] - opTreaty) > Treaty) then
     173          (Integer(Offer.Price[0] - opTreaty) > Treaty) then
    174174        // simple treaty offer
    175175        begin
     
    177177            // trCeaseFire: result:=result+Tribe[pTarget].TPhrase('FRCEASEFIRE');
    178178            trPeace:
    179               result := result + Tribe[pTarget].TPhrase('FRPEACE');
     179              Result := Result + Tribe[pTarget].TPhrase('FRPEACE');
    180180            trFriendlyContact:
    181               result := result + Tribe[pTarget].TPhrase('FRFRIENDLY');
     181              Result := Result + Tribe[pTarget].TPhrase('FRFRIENDLY');
    182182            trAlliance:
    183               result := result + Tribe[pTarget].TPhrase('FRALLIANCE');
     183              Result := Result + Tribe[pTarget].TPhrase('FRALLIANCE');
    184184          end
    185185        end
     
    188188          if (Treaty >= trFriendlyContact) and not Phrases2FallenBackToEnglish
    189189          then
    190             result := result +
     190            Result := Result +
    191191              Format(Tribe[pTarget].TString(Phrases2.Lookup('FRDEMAND_SOFT')
    192192              ), [sCost])
    193193          else
    194194          begin
    195             result := result +
     195            Result := Result +
    196196              Format(Tribe[pTarget].TPhrase('FRDEMAND_STRONG'), [sCost]);
    197             DoIntro := false
     197            DoIntro := False
    198198          end
    199199        end
    200200        else if Offer.nCost = 0 then // present
    201           result := result + Format(Tribe[pTarget].TPhrase('FRPRESENT'),
     201          Result := Result + Format(Tribe[pTarget].TPhrase('FRPRESENT'),
    202202            [sDeliver])
    203203        else if (Offer.nDeliver = 1) and (Offer.Price[0] = opChoose) then
    204           result := result + Format(Phrases.Lookup('FRDELCHOICE'), [sCost])
     204          Result := Result + Format(Phrases.Lookup('FRDELCHOICE'), [sCost])
    205205        else if (Offer.nCost = 1) and (Offer.Price[Offer.nDeliver] = opChoose)
    206206        then
    207           result := result + Format(Phrases.Lookup('FRCOSTCHOICE'), [sDeliver])
     207          Result := Result + Format(Phrases.Lookup('FRCOSTCHOICE'), [sDeliver])
    208208        else
    209           result := result + Format(Phrases.Lookup('FROFFER'),
     209          Result := Result + Format(Phrases.Lookup('FROFFER'),
    210210            [sDeliver, sCost]);
    211211      end;
     
    213213  if DoIntro then
    214214    if Treaty < trPeace then
    215       result := Tribe[pSender].TPhrase('FRSTART_NOTREATY') + ' ' + result
     215      Result := Tribe[pSender].TPhrase('FRSTART_NOTREATY') + ' ' + Result
    216216    else
    217       result := Tribe[pSender].TPhrase('FRSTART_PEACE') + ' ' + result
     217      Result := Tribe[pSender].TPhrase('FRSTART_PEACE') + ' ' + Result
    218218end;
    219219
  • trunk/LocalPlayer/Draft.pas

    r442 r447  
    2020    procedure CloseBtnClick(Sender: TObject);
    2121    procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
    22       Shift: TShiftState; x, y: integer);
     22      Shift: TShiftState; X, Y: Integer);
    2323    procedure OKBtnClick(Sender: TObject);
    2424    procedure PaintBox1MouseUp(Sender: TObject; Button: TMouseButton;
    25       Shift: TShiftState; x, y: integer);
     25      Shift: TShiftState; X, Y: Integer);
    2626  public
    2727    procedure ShowNewContent(NewMode: TWindowMode);
     
    3030  private
    3131    Domain, MaxLines, Lines, Cut, yDomain, yFeature, yWeight, yTotal, yView,
    32       IncCap, DecCap: integer;
    33     code: array [0 .. nFeature - 1] of integer;
     32      IncCap, DecCap: Integer;
     33    Code: array [0 .. nFeature - 1] of Integer;
    3434    Template, Back: TBitmap;
    35     function IsFeatureInList(d, i: integer): boolean;
    36     procedure SetDomain(d: integer);
     35    function IsFeatureInList(D, I: Integer): Boolean;
     36    procedure SetDomain(D: Integer);
    3737  end;
    3838
     
    108108procedure TDraftDlg.OffscreenPaint;
    109109
    110   function DomainAvailable(d: integer): boolean;
    111   begin
    112     result := (upgrade[d, 0].Preq = preNone) or
    113       (MyRO.Tech[upgrade[d, 0].Preq] >= tsApplicable);
     110  function DomainAvailable(D: Integer): Boolean;
     111  begin
     112    Result := (upgrade[D, 0].Preq = preNone) or
     113      (MyRO.Tech[upgrade[D, 0].Preq] >= tsApplicable);
    114114  end;
    115115
    116116  procedure PaintTotalBars;
    117117  var
    118     i, y, dx, num, w: integer;
    119     s: string;
    120   begin
    121     with offscreen.Canvas do
     118    I, Y, dx, num, W: Integer;
     119    S: string;
     120  begin
     121    with Offscreen.Canvas do
    122122    begin
    123123      // strength bar
    124       y := yTotal;
    125       DarkGradient(offscreen.Canvas, xTotal - 6, y + 1, 184, 2);
    126       DarkGradient(offscreen.Canvas, xTotal2 + 172, y + 1, 95, 2);
    127       RisedTextOut(offscreen.Canvas, xTotal - 2, y,
     124      Y := yTotal;
     125      DarkGradient(Offscreen.Canvas, xTotal - 6, Y + 1, 184, 2);
     126      DarkGradient(Offscreen.Canvas, xTotal2 + 172, Y + 1, 95, 2);
     127      RisedTextOut(Offscreen.Canvas, xTotal - 2, Y,
    128128        Phrases.Lookup('UNITSTRENGTH'));
    129       RisedTextOut(offscreen.Canvas, xTotal + 112 + 30, y,
     129      RisedTextOut(Offscreen.Canvas, xTotal + 112 + 30, Y,
    130130        'x' + IntToStr(MyRO.DevModel.MStrength));
    131       RisedTextOut(offscreen.Canvas, xTotal2 + 148 + 30, y, '=');
    132       s := IntToStr(MyRO.DevModel.Attack) + '/' +
     131      RisedTextOut(Offscreen.Canvas, xTotal2 + 148 + 30, Y, '=');
     132      S := IntToStr(MyRO.DevModel.Attack) + '/' +
    133133        IntToStr(MyRO.DevModel.Defense);
    134       RisedTextOut(offscreen.Canvas, xTotal2 + 170 + 64 + 30 -
    135         BiColorTextWidth(offscreen.Canvas, s), y, s);
     134      RisedTextOut(Offscreen.Canvas, xTotal2 + 170 + 64 + 30 -
     135        BiColorTextWidth(Offscreen.Canvas, S), Y, S);
    136136
    137137      // transport bar
    138138      if MyRO.DevModel.MTrans > 0 then
    139139      begin
    140         y := yTotal + 19;
    141         DarkGradient(offscreen.Canvas, xTotal - 6, y + 1, 184, 1);
    142         DarkGradient(offscreen.Canvas, xTotal2 + 172, y + 1, 95, 1);
    143         RisedTextOut(offscreen.Canvas, xTotal - 2, y,
     140        Y := yTotal + 19;
     141        DarkGradient(Offscreen.Canvas, xTotal - 6, Y + 1, 184, 1);
     142        DarkGradient(Offscreen.Canvas, xTotal2 + 172, Y + 1, 95, 1);
     143        RisedTextOut(Offscreen.Canvas, xTotal - 2, Y,
    144144          Phrases.Lookup('UNITTRANSPORT'));
    145         RisedTextOut(offscreen.Canvas, xTotal + 112 + 30, y,
     145        RisedTextOut(Offscreen.Canvas, xTotal + 112 + 30, Y,
    146146          'x' + IntToStr(MyRO.DevModel.MTrans));
    147         RisedTextOut(offscreen.Canvas, xTotal2 + 148 + 30, y, '=');
     147        RisedTextOut(Offscreen.Canvas, xTotal2 + 148 + 30, Y, '=');
    148148
    149149        Font.Color := $000000;
    150150        dx := -237 - 30;
    151         for i := mcFirstNonCap - 1 downto 3 do
    152           if i in [mcSeaTrans, mcCarrier, mcAirTrans] then
     151        for I := mcFirstNonCap - 1 downto 3 do
     152          if I in [mcSeaTrans, mcCarrier, mcAirTrans] then
    153153          begin
    154             num := MyRO.DevModel.Cap[i] * MyRO.DevModel.MTrans;
     154            num := MyRO.DevModel.Cap[I] * MyRO.DevModel.MTrans;
    155155            if num > 0 then
    156156            begin
    157               inc(dx, 15);
     157              Inc(dx, 15);
    158158              Brush.Color := $C0C0C0;
    159               FrameRect(Rect(xTotal2 - 3 - dx, y + 2,
    160                 xTotal2 + 11 - dx, y + 16));
     159              FrameRect(Rect(xTotal2 - 3 - dx, Y + 2,
     160                xTotal2 + 11 - dx, Y + 16));
    161161              Brush.Style := bsClear;
    162               Sprite(offscreen, HGrSystem, xTotal2 - 1 - dx, y + 4, 10, 10,
    163                 66 + i mod 11 * 11, 137 + i div 11 * 11);
     162              Sprite(Offscreen, HGrSystem, xTotal2 - 1 - dx, Y + 4, 10, 10,
     163                66 + I mod 11 * 11, 137 + I div 11 * 11);
    164164              if num > 1 then
    165165              begin
    166                 s := IntToStr(num);
    167                 w := TextWidth(s);
    168                 inc(dx, w + 1);
     166                S := IntToStr(num);
     167                W := TextWidth(S);
     168                Inc(dx, W + 1);
    169169                Brush.Color := $FFFFFF;
    170                 FillRect(Rect(xTotal2 - 3 - dx, y + 2,
    171                   xTotal2 + w - 1 - dx, y + 16));
     170                FillRect(Rect(xTotal2 - 3 - dx, Y + 2,
     171                  xTotal2 + W - 1 - dx, Y + 16));
    172172                Brush.Style := bsClear;
    173                 Textout(xTotal2 - 3 - dx + 1, y, s);
     173                Textout(xTotal2 - 3 - dx + 1, Y, S);
    174174              end;
    175175            end;
     
    178178
    179179      // speed bar
    180       y := yTotal + 38;
    181       LoweredTextOut(offscreen.Canvas, -1, MainTexture, xTotal - 2, y,
     180      Y := yTotal + 38;
     181      LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xTotal - 2, Y,
    182182        Phrases.Lookup('UNITSPEED'));
    183       DLine(offscreen.Canvas, xTotal - 2, xTotal + 174, y + 16,
     183      DLine(Offscreen.Canvas, xTotal - 2, xTotal + 174, Y + 16,
    184184        MainTexture.ColorBevelShade, MainTexture.ColorBevelLight);
    185       DLine(offscreen.Canvas, xTotal2 + 176, xTotal2 + 263, y + 16,
     185      DLine(Offscreen.Canvas, xTotal2 + 176, xTotal2 + 263, Y + 16,
    186186        MainTexture.ColorBevelShade, MainTexture.ColorBevelLight);
    187       s := MovementToString(MyRO.DevModel.Speed);
    188       RisedTextOut(offscreen.Canvas, xTotal2 + 170 + 64 + 30 -
    189         TextWidth(s), y, s);
     187      S := MovementToString(MyRO.DevModel.Speed);
     188      RisedTextOut(Offscreen.Canvas, xTotal2 + 170 + 64 + 30 -
     189        TextWidth(S), Y, S);
    190190
    191191      // cost bar
    192       y := yTotal + 57;
    193       LoweredTextOut(offscreen.Canvas, -1, MainTexture, xTotal - 2, y,
     192      Y := yTotal + 57;
     193      LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xTotal - 2, Y,
    194194        Phrases.Lookup('UNITCOST'));
    195       LoweredTextOut(offscreen.Canvas, -1, MainTexture, xTotal + 112 + 30, y,
     195      LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xTotal + 112 + 30, Y,
    196196        'x' + IntToStr(MyRO.DevModel.MCost));
    197       LoweredTextOut(offscreen.Canvas, -1, MainTexture,
    198         xTotal2 + 148 + 30, y, '=');
    199       DLine(offscreen.Canvas, xTotal - 2, xTotal + 174, y + 16,
     197      LoweredTextOut(Offscreen.Canvas, -1, MainTexture,
     198        xTotal2 + 148 + 30, Y, '=');
     199      DLine(Offscreen.Canvas, xTotal - 2, xTotal + 174, Y + 16,
    200200        MainTexture.ColorBevelShade, MainTexture.ColorBevelLight);
    201       DLine(offscreen.Canvas, xTotal2 + 176, xTotal2 + 263, y + 16,
     201      DLine(Offscreen.Canvas, xTotal2 + 176, xTotal2 + 263, Y + 16,
    202202        MainTexture.ColorBevelShade, MainTexture.ColorBevelLight);
    203       s := IntToStr(MyRO.DevModel.Cost);
    204       RisedTextOut(offscreen.Canvas, xTotal2 + 170 + 64 + 30 - 12 -
    205         TextWidth(s), y, s);
    206       Sprite(offscreen, HGrSystem, xTotal2 + 170 + 54 + 30, y + 4, 10,
     203      S := IntToStr(MyRO.DevModel.Cost);
     204      RisedTextOut(Offscreen.Canvas, xTotal2 + 170 + 64 + 30 - 12 -
     205        TextWidth(S), Y, S);
     206      Sprite(Offscreen, HGrSystem, xTotal2 + 170 + 54 + 30, Y + 4, 10,
    207207        10, 88, 115);
    208208
    209       if G.Difficulty[me] <> 2 then
     209      if G.Difficulty[Me] <> 2 then
    210210      begin // corrected cost bar
    211         y := yTotal + 76;
    212         LoweredTextOut(offscreen.Canvas, -1, MainTexture, xTotal - 2, y,
    213           Phrases.Lookup('COSTDIFF' + char(48 + G.Difficulty[me])));
    214         LoweredTextOut(offscreen.Canvas, -1, MainTexture,
    215           xTotal2 + 148 + 30, y, '=');
    216         DLine(offscreen.Canvas, xTotal - 2, xTotal + 174, y + 16,
     211        Y := yTotal + 76;
     212        LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xTotal - 2, Y,
     213          Phrases.Lookup('COSTDIFF' + char(48 + G.Difficulty[Me])));
     214        LoweredTextOut(Offscreen.Canvas, -1, MainTexture,
     215          xTotal2 + 148 + 30, Y, '=');
     216        DLine(Offscreen.Canvas, xTotal - 2, xTotal + 174, Y + 16,
    217217          MainTexture.ColorBevelShade, MainTexture.ColorBevelLight);
    218         DLine(offscreen.Canvas, xTotal2 + 176, xTotal2 + 263, y + 16,
     218        DLine(Offscreen.Canvas, xTotal2 + 176, xTotal2 + 263, Y + 16,
    219219          MainTexture.ColorBevelShade, MainTexture.ColorBevelLight);
    220         s := IntToStr(MyRO.DevModel.Cost * BuildCostMod
    221           [G.Difficulty[me]] div 12);
    222         RisedTextOut(offscreen.Canvas, xTotal2 + 170 + 64 + 30 - 12 -
    223           TextWidth(s), y, s);
    224         Sprite(offscreen, HGrSystem, xTotal2 + 170 + 54 + 30, y + 4, 10,
     220        S := IntToStr(MyRO.DevModel.Cost * BuildCostMod
     221          [G.Difficulty[Me]] div 12);
     222        RisedTextOut(Offscreen.Canvas, xTotal2 + 170 + 64 + 30 - 12 -
     223          TextWidth(S), Y, S);
     224        Sprite(Offscreen, HGrSystem, xTotal2 + 170 + 54 + 30, Y + 4, 10,
    225225          10, 88, 115);
    226226      end;
     
    229229
    230230var
    231   i, j, x, d, n, TextColor, CapWeight, DomainCount: integer;
     231  I, J, X, D, N, TextColor, CapWeight, DomainCount: Integer;
    232232begin
    233233  inherited;
     
    253253    Template.Height - 64 - Cut);
    254254
    255   BitBltCanvas(offscreen.Canvas, 0, 0, ClientWidth, ClientHeight,
     255  BitBltCanvas(Offscreen.Canvas, 0, 0, ClientWidth, ClientHeight,
    256256    Back.Canvas, 0, 0);
    257257
    258   offscreen.Canvas.Font.Assign(UniFont[ftCaption]);
    259   RisedTextOut(offscreen.Canvas, 10, 7, Caption);
    260   offscreen.Canvas.Font.Assign(UniFont[ftSmall]);
     258  Offscreen.Canvas.Font.Assign(UniFont[ftCaption]);
     259  RisedTextOut(Offscreen.Canvas, 10, 7, Caption);
     260  Offscreen.Canvas.Font.Assign(UniFont[ftSmall]);
    261261
    262262  with MyRO.DevModel do
    263263  begin
    264264    DomainCount := 0;
    265     for d := 0 to nDomains - 1 do
    266       if DomainAvailable(d) then
    267         inc(DomainCount);
     265    for D := 0 to nDomains - 1 do
     266      if DomainAvailable(D) then
     267        Inc(DomainCount);
    268268    if DomainCount > 1 then
    269269    begin
    270       for d := 0 to nDomains - 1 do
    271         if DomainAvailable(d) then
     270      for D := 0 to nDomains - 1 do
     271        if DomainAvailable(D) then
    272272        begin
    273           x := xDomain + d * DomainPitch;
    274           if d = Domain then
    275             ImageOp_BCC(offscreen, Templates.Data, x, yDomain, 142, 246 + 37 * d, 36,
     273          X := xDomain + D * DomainPitch;
     274          if D = Domain then
     275            ImageOp_BCC(Offscreen, Templates.Data, X, yDomain, 142, 246 + 37 * D, 36,
    276276              36, 0, $00C0FF)
    277277          else
    278             ImageOp_BCC(offscreen, Templates.Data, x, yDomain, 142, 246 + 37 * d, 36,
     278            ImageOp_BCC(Offscreen, Templates.Data, X, yDomain, 142, 246 + 37 * D, 36,
    279279              36, 0, $606060);
    280280        end;
    281       Frame(offscreen.Canvas, xDomain - 11, yDomain - 3,
     281      Frame(Offscreen.Canvas, xDomain - 11, yDomain - 3,
    282282        xDomain + 2 * DomainPitch + 46, yDomain + 38, $B0B0B0, $FFFFFF);
    283       RFrame(offscreen.Canvas, xDomain - 12, yDomain - 4,
     283      RFrame(Offscreen.Canvas, xDomain - 12, yDomain - 4,
    284284        xDomain + 2 * DomainPitch + 47, yDomain + 39, $FFFFFF, $B0B0B0);
    285285    end;
     
    294294
    295295    // display weight
    296     with offscreen.Canvas do
    297     begin
    298       for i := 0 to MaxWeight - 1 do
    299         if i < Weight then
    300           ImageOp_BCC(offscreen, Templates.Data, Point(xWeight + 20 * i, yWeight),
     296    with Offscreen.Canvas do
     297    begin
     298      for I := 0 to MaxWeight - 1 do
     299        if I < Weight then
     300          ImageOp_BCC(Offscreen, Templates.Data, Point(xWeight + 20 * I, yWeight),
    301301            WeightOn.BoundsRect, 0, $949494)
    302302        else
    303           ImageOp_BCC(offscreen, Templates.Data, Point(xWeight + 20 * i, yWeight),
     303          ImageOp_BCC(Offscreen, Templates.Data, Point(xWeight + 20 * I, yWeight),
    304304            WeightOff.BoundsRect, 0, $949494);
    305305    end;
    306306
    307     with offscreen.Canvas do
    308       for i := 0 to Lines - 1 do
     307    with Offscreen.Canvas do
     308      for I := 0 to Lines - 1 do
    309309      begin
    310         if not(code[i] in AutoFeature) then
     310        if not(Code[I] in AutoFeature) then
    311311        begin
    312312          // paint +/- butttons
    313           if code[i] < mcFirstNonCap then
     313          if Code[I] < mcFirstNonCap then
    314314          begin
    315             Dump(offscreen, HGrSystem, xFeature - 21, yFeature + 2 + LinePitch *
    316               i, 12, 12, 169, 172);
    317             Dump(offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch *
    318               i, 12, 12, 169, 159);
    319             RFrame(offscreen.Canvas, xFeature - (21 + 1),
    320               yFeature + 2 + LinePitch * i - 1, xFeature - (21 - 24),
    321               yFeature + 2 + LinePitch * i + 12, MainTexture.ColorBevelShade,
     315            Dump(Offscreen, HGrSystem, xFeature - 21, yFeature + 2 + LinePitch *
     316              I, 12, 12, 169, 172);
     317            Dump(Offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch *
     318              I, 12, 12, 169, 159);
     319            RFrame(Offscreen.Canvas, xFeature - (21 + 1),
     320              yFeature + 2 + LinePitch * I - 1, xFeature - (21 - 24),
     321              yFeature + 2 + LinePitch * I + 12, MainTexture.ColorBevelShade,
    322322              MainTexture.ColorBevelLight);
    323323          end
    324324          else
    325325          begin
    326             Dump(offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch *
    327               i, 12, 12, 169, 185 + 13 * MyRO.DevModel.Cap[code[i]]);
    328             RFrame(offscreen.Canvas, xFeature - (9 + 1),
    329               yFeature + 2 + LinePitch * i - 1, xFeature - (21 - 24),
    330               yFeature + 2 + LinePitch * i + 12, MainTexture.ColorBevelShade,
     326            Dump(Offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch *
     327              I, 12, 12, 169, 185 + 13 * MyRO.DevModel.Cap[Code[I]]);
     328            RFrame(Offscreen.Canvas, xFeature - (9 + 1),
     329              yFeature + 2 + LinePitch * I - 1, xFeature - (21 - 24),
     330              yFeature + 2 + LinePitch * I + 12, MainTexture.ColorBevelShade,
    331331              MainTexture.ColorBevelLight);
    332332          end;
    333333
    334334          // paint cost
    335           LightGradient(offscreen.Canvas, xFeature + 34,
    336             yFeature + LinePitch * i, 50, HGrSystem.Data.Canvas.Pixels
     335          LightGradient(Offscreen.Canvas, xFeature + 34,
     336            yFeature + LinePitch * I, 50, HGrSystem.Data.Canvas.Pixels
    337337            [187, 137]);
    338           if (Domain = dGround) and (code[i] = mcDefense) then
     338          if (Domain = dGround) and (Code[I] = mcDefense) then
    339339            CapWeight := 2
    340340          else
    341             CapWeight := Feature[code[i]].Weight;
    342           n := CapWeight + Feature[code[i]].Cost;
    343           d := 6;
    344           while (n - 1) * d * 2 > 48 - 10 do
    345             dec(d);
    346           for j := 0 to n - 1 do
    347             if j < CapWeight then
    348               Sprite(offscreen, HGrSystem, xFeature + 54 + (j * 2 + 1 - n) * d,
    349                 yFeature + 2 + LinePitch * i + 1, 10, 10, 88, 126)
     341            CapWeight := Feature[Code[I]].Weight;
     342          N := CapWeight + Feature[Code[I]].Cost;
     343          D := 6;
     344          while (N - 1) * D * 2 > 48 - 10 do
     345            Dec(D);
     346          for J := 0 to N - 1 do
     347            if J < CapWeight then
     348              Sprite(Offscreen, HGrSystem, xFeature + 54 + (J * 2 + 1 - N) * D,
     349                yFeature + 2 + LinePitch * I + 1, 10, 10, 88, 126)
    350350            else
    351               Sprite(offscreen, HGrSystem, xFeature + 54 + (j * 2 + 1 - n) * d,
    352                 yFeature + 2 + LinePitch * i + 1, 10, 10, 88, 115);
     351              Sprite(Offscreen, HGrSystem, xFeature + 54 + (J * 2 + 1 - N) * D,
     352                yFeature + 2 + LinePitch * I + 1, 10, 10, 88, 115);
    353353        end; // if not (code[i] in AutoFeature)
    354         DarkGradient(offscreen.Canvas, xFeature + 17,
    355           yFeature + LinePitch * i, 16, 1);
    356         ScreenTools.Frame(offscreen.Canvas, xFeature + 18, yFeature + 1 + LinePitch * i,
    357           xFeature + 20 - 2 + 13, yFeature + 2 + 1 - 2 + 13 + LinePitch * i,
     354        DarkGradient(Offscreen.Canvas, xFeature + 17,
     355          yFeature + LinePitch * I, 16, 1);
     356        ScreenTools.Frame(Offscreen.Canvas, xFeature + 18, yFeature + 1 + LinePitch * I,
     357          xFeature + 20 - 2 + 13, yFeature + 2 + 1 - 2 + 13 + LinePitch * I,
    358358          $C0C0C0, $C0C0C0);
    359         Sprite(offscreen, HGrSystem, xFeature + 20, yFeature + 2 + 1 + LinePitch
    360           * i, 10, 10, 66 + code[i] mod 11 * 11, 137 + code[i] div 11 * 11);
    361 
    362         if MyRO.DevModel.Cap[code[i]] > 0 then
     359        Sprite(Offscreen, HGrSystem, xFeature + 20, yFeature + 2 + 1 + LinePitch
     360          * I, 10, 10, 66 + Code[I] mod 11 * 11, 137 + Code[I] div 11 * 11);
     361
     362        if MyRO.DevModel.Cap[Code[I]] > 0 then
    363363          TextColor := MainTexture.ColorLitText
    364364        else
    365365          TextColor := -1;
    366366
    367         if code[i] < mcFirstNonCap then
    368           LoweredTextOut(offscreen.Canvas, TextColor, MainTexture, xFeature + 7,
    369             yFeature + LinePitch * i - 1, IntToStr(MyRO.DevModel.Cap[code[i]]));
    370         LoweredTextOut(offscreen.Canvas, TextColor, MainTexture, xFeature + 88,
    371           yFeature + LinePitch * i - 1, Phrases.Lookup('FEATURES', code[i]));
     367        if Code[I] < mcFirstNonCap then
     368          LoweredTextOut(Offscreen.Canvas, TextColor, MainTexture, xFeature + 7,
     369            yFeature + LinePitch * I - 1, IntToStr(MyRO.DevModel.Cap[Code[I]]));
     370        LoweredTextOut(Offscreen.Canvas, TextColor, MainTexture, xFeature + 88,
     371          yFeature + LinePitch * I - 1, Phrases.Lookup('FEATURES', Code[I]));
    372372      end;
    373373  end;
    374374
    375375  // free features
    376   j := 0;
    377   for i := 0 to nFeature - 1 do
    378     if (i in AutoFeature) and (1 shl Domain and Feature[i].Domains <> 0) and
    379       (Feature[i].Preq <> preNA) and
    380       ((Feature[i].Preq = preSun) and (MyRO.Wonder[woSun].EffectiveOwner = me)
    381       or (Feature[i].Preq >= 0) and (MyRO.Tech[Feature[i].Preq] >= tsApplicable)
    382       ) and not((Feature[i].Preq = adSteamEngine) and
     376  J := 0;
     377  for I := 0 to nFeature - 1 do
     378    if (I in AutoFeature) and (1 shl Domain and Feature[I].Domains <> 0) and
     379      (Feature[I].Preq <> preNA) and
     380      ((Feature[I].Preq = preSun) and (MyRO.Wonder[woSun].EffectiveOwner = Me)
     381      or (Feature[I].Preq >= 0) and (MyRO.Tech[Feature[I].Preq] >= tsApplicable)
     382      ) and not((Feature[I].Preq = adSteamEngine) and
    383383      (MyRO.Tech[adNuclearPower] >= tsApplicable)) then
    384384    begin
    385       DarkGradient(offscreen.Canvas, xWeight + 4, yWeight + 32 + LinePitch
    386         * j, 16, 1);
    387       Frame(offscreen.Canvas, xWeight + 5, yWeight + 33 + LinePitch * j,
    388         xWeight + 18, yWeight + 47 + LinePitch * j, $C0C0C0, $C0C0C0);
    389       Sprite(offscreen, HGrSystem, xWeight + 7, yWeight + 36 + LinePitch * j,
    390         10, 10, 66 + i mod 11 * 11, 137 + i div 11 * 11);
    391       LoweredTextOut(offscreen.Canvas, -1, MainTexture, xWeight + 26,
    392         yWeight + 31 + LinePitch * j, Phrases.Lookup('FEATURES', i));
    393       inc(j);
    394     end;
    395 
    396   with Tribe[me].ModelPicture[MyRO.nModel] do
    397   begin
    398     FrameImage(offscreen.Canvas, BigImp, xView + 4, yView + 4, xSizeBig,
     385      DarkGradient(Offscreen.Canvas, xWeight + 4, yWeight + 32 + LinePitch
     386        * J, 16, 1);
     387      Frame(Offscreen.Canvas, xWeight + 5, yWeight + 33 + LinePitch * J,
     388        xWeight + 18, yWeight + 47 + LinePitch * J, $C0C0C0, $C0C0C0);
     389      Sprite(Offscreen, HGrSystem, xWeight + 7, yWeight + 36 + LinePitch * J,
     390        10, 10, 66 + I mod 11 * 11, 137 + I div 11 * 11);
     391      LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xWeight + 26,
     392        yWeight + 31 + LinePitch * J, Phrases.Lookup('FEATURES', I));
     393      Inc(J);
     394    end;
     395
     396  with Tribe[Me].ModelPicture[MyRO.nModel] do
     397  begin
     398    FrameImage(Offscreen.Canvas, BigImp, xView + 4, yView + 4, xSizeBig,
    399399      ySizeBig, 0, 0);
    400     Sprite(offscreen, HGr, xView, yView, 64, 44, pix mod 10 * 65 + 1,
     400    Sprite(Offscreen, HGr, xView, yView, 64, 44, pix mod 10 * 65 + 1,
    401401      pix div 10 * 49 + 1);
    402402  end;
     
    404404end;
    405405
    406 procedure TDraftDlg.SetDomain(d: integer);
    407 
    408   function Prio(fix: integer): integer;
     406procedure TDraftDlg.SetDomain(D: Integer);
     407
     408  function Prio(fix: Integer): Integer;
    409409  var
    410     FeaturePreq: integer;
     410    FeaturePreq: Integer;
    411411  begin
    412412    FeaturePreq := Feature[fix].Preq;
    413     assert(FeaturePreq <> preNA);
     413    Assert(FeaturePreq <> preNA);
    414414    if fix < mcFirstNonCap then
    415       result := 10000 + fix
     415      Result := 10000 + fix
    416416    else if FeaturePreq = preNone then
    417       result := 20000
     417      Result := 20000
    418418    else if FeaturePreq < 0 then
    419       result := 40000
     419      Result := 40000
    420420    else
    421       result := 30000 + AdvValue[FeaturePreq];
     421      Result := 30000 + AdvValue[FeaturePreq];
    422422    if not(fix in AutoFeature) then
    423       inc(result, 90000);
     423      Inc(Result, 90000);
    424424  end;
    425425
    426426var
    427   i, j, x: integer;
    428 begin
    429   Domain := d;
     427  I, J, X: Integer;
     428begin
     429  Domain := D;
    430430  Lines := 0;
    431   for i := 0 to nFeature - 1 do
    432     if IsFeatureInList(Domain, i) then
    433     begin
    434       code[Lines] := i;
    435       inc(Lines);
     431  for I := 0 to nFeature - 1 do
     432    if IsFeatureInList(Domain, I) then
     433    begin
     434      Code[Lines] := I;
     435      Inc(Lines);
    436436    end;
    437437  yFeature := yFeature0 + (MaxLines - Lines) * LinePitch div 2;
    438438
    439439  // sort features
    440   for i := 0 to Lines - 2 do
    441     for j := i + 1 to Lines - 1 do
    442       if Prio(code[i]) > Prio(code[j]) then
     440  for I := 0 to Lines - 2 do
     441    for J := I + 1 to Lines - 1 do
     442      if Prio(Code[I]) > Prio(Code[J]) then
    443443      begin // exchange
    444         x := code[i];
    445         code[i] := code[j];
    446         code[j] := x;
     444        X := Code[I];
     445        Code[I] := Code[J];
     446        Code[J] := X;
    447447      end;
    448448end;
    449449
    450 function TDraftDlg.IsFeatureInList(d, i: integer): boolean;
    451 begin
    452   result := not(i in AutoFeature) and (1 shl d and Feature[i].Domains <> 0) and
    453     (Feature[i].Preq <> preNA) and
    454     ((Feature[i].Preq = preNone) or (Feature[i].Preq = preSun) and
    455     (MyRO.Wonder[woSun].EffectiveOwner = me) or (Feature[i].Preq >= 0) and
    456     (MyRO.Tech[Feature[i].Preq] >= tsApplicable));
     450function TDraftDlg.IsFeatureInList(D, I: Integer): Boolean;
     451begin
     452  Result := not(I in AutoFeature) and (1 shl D and Feature[I].Domains <> 0) and
     453    (Feature[I].Preq <> preNA) and
     454    ((Feature[I].Preq = preNone) or (Feature[I].Preq = preSun) and
     455    (MyRO.Wonder[woSun].EffectiveOwner = Me) or (Feature[I].Preq >= 0) and
     456    (MyRO.Tech[Feature[I].Preq] >= tsApplicable));
    457457end;
    458458
    459459procedure TDraftDlg.FormShow(Sender: TObject);
    460460var
    461   count, d, i: integer;
     461  count, D, I: Integer;
    462462begin
    463463  Domain := dGround;
    464464  while (Domain < dAir) and (upgrade[Domain, 0].Preq <> preNone) and
    465465    (MyRO.Tech[upgrade[Domain, 0].Preq] < tsApplicable) do
    466     inc(Domain);
     466    Inc(Domain);
    467467
    468468  // count max number of features in any domain
    469469  MaxLines := 0;
    470   for d := 0 to nDomains - 1 do
    471     if (upgrade[d, 0].Preq = preNone) or
    472       (MyRO.Tech[upgrade[d, 0].Preq] >= tsApplicable) then
     470  for D := 0 to nDomains - 1 do
     471    if (upgrade[D, 0].Preq = preNone) or
     472      (MyRO.Tech[upgrade[D, 0].Preq] >= tsApplicable) then
    473473    begin
    474474      count := 0;
    475       for i := 0 to nFeature - 1 do
    476         if IsFeatureInList(d, i) then
    477           inc(count);
     475      for I := 0 to nFeature - 1 do
     476        if IsFeatureInList(D, I) then
     477          Inc(count);
    478478      if count > MaxLines then
    479479        MaxLines := count;
     
    493493
    494494  SetDomain(Domain);
    495   Server(sCreateDevModel, me, Domain, nil^);
     495  Server(sCreateDevModel, Me, Domain, nil^);
    496496  MyModel[MyRO.nModel] := MyRO.DevModel;
    497   InitMyModel(MyRO.nModel, false);
     497  InitMyModel(MyRO.nModel, False);
    498498  OffscreenPaint;
    499499  IncCap := -1;
     
    507507
    508508procedure TDraftDlg.PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
    509   Shift: TShiftState; x, y: integer);
     509  Shift: TShiftState; X, Y: Integer);
    510510var
    511   i, d: integer;
     511  I, D: Integer;
    512512begin
    513513  if Button = mbLeft then
    514514  begin
    515     for d := 0 to nDomains - 1 do
    516       if (d <> Domain) and ((upgrade[d, 0].Preq = preNone) or
    517         (MyRO.Tech[upgrade[d, 0].Preq] >= tsApplicable)) and
    518         (x >= xDomain + d * DomainPitch) and
    519         (x < xDomain + d * DomainPitch + 36) and (y >= yDomain) and
    520         (y < yDomain + 36) then
     515    for D := 0 to nDomains - 1 do
     516      if (D <> Domain) and ((upgrade[D, 0].Preq = preNone) or
     517        (MyRO.Tech[upgrade[D, 0].Preq] >= tsApplicable)) and
     518        (X >= xDomain + D * DomainPitch) and
     519        (X < xDomain + D * DomainPitch + 36) and (Y >= yDomain) and
     520        (Y < yDomain + 36) then
    521521      begin
    522         SetDomain(d);
    523         Server(sCreateDevModel, me, Domain, nil^);
     522        SetDomain(D);
     523        Server(sCreateDevModel, Me, Domain, nil^);
    524524        MyModel[MyRO.nModel] := MyRO.DevModel;
    525         InitMyModel(MyRO.nModel, false);
     525        InitMyModel(MyRO.nModel, False);
    526526        SmartUpdateContent;
    527527      end;
    528528
    529     if (y >= yFeature) and (y < yFeature + LinePitch * Lines) then
    530     begin
    531       i := (y - yFeature) div LinePitch;
    532       if (x >= xFeature - 21) and (x < ClientWidth) and (ssShift in Shift) then
    533         HelpDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), hkFeature, code[i])
    534       else if not(code[i] in AutoFeature) then
     529    if (Y >= yFeature) and (Y < yFeature + LinePitch * Lines) then
     530    begin
     531      I := (Y - yFeature) div LinePitch;
     532      if (X >= xFeature - 21) and (X < ClientWidth) and (ssShift in Shift) then
     533        HelpDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), hkFeature, Code[I])
     534      else if not(Code[I] in AutoFeature) then
    535535      begin
    536         if (code[i] < mcFirstNonCap) and (x >= xFeature - 21) and
    537           (x < xFeature - 21 + 12) then
     536        if (Code[I] < mcFirstNonCap) and (X >= xFeature - 21) and
     537          (X < xFeature - 21 + 12) then
    538538        begin
    539           IncCap := code[i];
    540           Dump(offscreen, HGrSystem, xFeature - 21, yFeature + 2 + LinePitch *
    541             i, 12, 12, 182, 172);
     539          IncCap := Code[I];
     540          Dump(Offscreen, HGrSystem, xFeature - 21, yFeature + 2 + LinePitch *
     541            I, 12, 12, 182, 172);
    542542          SmartInvalidate;
    543543        end
    544         else if (x >= xFeature - 9) and (x < xFeature - 9 + 12) then
     544        else if (X >= xFeature - 9) and (X < xFeature - 9 + 12) then
    545545        begin
    546           DecCap := code[i];
    547           if code[i] < mcFirstNonCap then
    548             Dump(offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch *
    549               i, 12, 12, 182, 159)
     546          DecCap := Code[I];
     547          if Code[I] < mcFirstNonCap then
     548            Dump(Offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch *
     549              I, 12, 12, 182, 159)
    550550          else
    551             Dump(offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch *
    552               i, 12, 12, 182, 185 + 13 * MyRO.DevModel.Cap[code[i]]);
     551            Dump(Offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch *
     552              I, 12, 12, 182, 185 + 13 * MyRO.DevModel.Cap[Code[I]]);
    553553          SmartInvalidate;
    554554        end;
     
    559559
    560560procedure TDraftDlg.PaintBox1MouseUp(Sender: TObject; Button: TMouseButton;
    561   Shift: TShiftState; x, y: integer);
     561  Shift: TShiftState; X, Y: Integer);
    562562var
    563   NewValue: integer;
     563  NewValue: Integer;
    564564begin
    565565  if IncCap >= 0 then
    566566  begin
    567567    NewValue := MyRO.DevModel.Cap[IncCap] + 1;
    568     Server(sSetDevModelCap + NewValue shl 4, me, IncCap, nil^);
     568    Server(sSetDevModelCap + NewValue shl 4, Me, IncCap, nil^);
    569569    MyModel[MyRO.nModel] := MyRO.DevModel;
    570     InitMyModel(MyRO.nModel, false);
     570    InitMyModel(MyRO.nModel, False);
    571571    SmartUpdateContent;
    572572    IncCap := -1;
     
    579579      if DecCap >= mcFirstNonCap then
    580580        NewValue := -NewValue;
    581       Server(sSetDevModelCap + NewValue shl 4, me, DecCap, nil^);
     581      Server(sSetDevModelCap + NewValue shl 4, Me, DecCap, nil^);
    582582      MyModel[MyRO.nModel] := MyRO.DevModel;
    583       InitMyModel(MyRO.nModel, false);
     583      InitMyModel(MyRO.nModel, False);
    584584    end;
    585585    SmartUpdateContent;
  • trunk/LocalPlayer/Enhance.pas

    r442 r447  
    3737    NoMap: TIsoMap;
    3838  public
    39     procedure ShowNewContent(NewMode: TWindowMode; TerrType: integer = -1);
     39    procedure ShowNewContent(NewMode: TWindowMode; TerrType: Integer = -1);
    4040  protected
    41     Page: integer;
     41    Page: Integer;
    4242    procedure OffscreenPaint; override;
    4343  end;
     
    5656procedure TEnhanceDlg.FormCreate(Sender: TObject);
    5757var
    58   TerrType: integer;
    59   m: TMenuItem;
     58  TerrType: Integer;
     59  M: TMenuItem;
    6060begin
    6161  inherited;
     
    7171    if TerrType <> fJungle then
    7272    begin
    73       m := TMenuItem.Create(Popup);
    74       m.RadioItem := true;
     73      M := TMenuItem.Create(Popup);
     74      M.RadioItem := True;
    7575      if TerrType = fGrass then
    76         m.Caption := Format(Phrases.Lookup('TWOTERRAINS'),
     76        M.Caption := Format(Phrases.Lookup('TWOTERRAINS'),
    7777          [Phrases.Lookup('TERRAIN', fGrass), Phrases.Lookup('TERRAIN',
    7878          fGrass + 12)])
    7979      else if TerrType = fForest then
    80         m.Caption := Format(Phrases.Lookup('TWOTERRAINS'),
     80        M.Caption := Format(Phrases.Lookup('TWOTERRAINS'),
    8181          [Phrases.Lookup('TERRAIN', fForest), Phrases.Lookup('TERRAIN',
    8282          fJungle)])
    8383      else
    84         m.Caption := Phrases.Lookup('TERRAIN', TerrType);
    85       m.Tag := TerrType;
    86       m.OnClick := TerrClick;
    87       Popup.Items.Add(m);
     84        M.Caption := Phrases.Lookup('TERRAIN', TerrType);
     85      M.Tag := TerrType;
     86      M.OnClick := TerrClick;
     87      Popup.Items.Add(M);
    8888    end;
    8989end;
     
    9696procedure TEnhanceDlg.FormPaint(Sender: TObject);
    9797var
    98   i: integer;
     98  I: Integer;
    9999begin
    100100  inherited;
     
    103103  BtnFrame(Canvas, Rect(job3.Left, job3.Top, job9.Left + job9.Width,
    104104    job3.Top + job3.Height), MainTexture);
    105   for i := 0 to ControlCount - 1 do
    106     if Controls[i] is TButtonC then
    107       BitBltCanvas(Canvas, Controls[i].Left + 2, Controls[i].Top - 11, 8, 8,
    108         HGrSystem.Data.Canvas, 121 + Controls[i].Tag mod 7 * 9,
    109         1 + Controls[i].Tag div 7 * 9);
     105  for I := 0 to ControlCount - 1 do
     106    if Controls[I] is TButtonC then
     107      BitBltCanvas(Canvas, Controls[I].Left + 2, Controls[I].Top - 11, 8, 8,
     108        HGrSystem.Data.Canvas, 121 + Controls[I].Tag mod 7 * 9,
     109        1 + Controls[I].Tag div 7 * 9);
    110110end;
    111111
     
    115115end;
    116116
    117 procedure TEnhanceDlg.ShowNewContent(NewMode: TWindowMode; TerrType: integer);
     117procedure TEnhanceDlg.ShowNewContent(NewMode: TWindowMode; TerrType: Integer);
    118118begin
    119119  if (TerrType < fGrass) or (TerrType > fMountains) then
     
    126126procedure TEnhanceDlg.OffscreenPaint;
    127127var
    128   i, stage, TerrType, TileImp, x, EndStage, Cost, LastJob: integer;
    129   s: string;
     128  I, stage, TerrType, TileImp, X, EndStage, Cost, LastJob: Integer;
     129  S: string;
    130130  Done: Set of jNone .. jTrans;
    131   TypeChanged: boolean;
     131  TypeChanged: Boolean;
    132132begin
    133133  OffscreenUser := self;
    134   offscreen.Canvas.Font.Assign(UniFont[ftSmall]);
     134  Offscreen.Canvas.Font.Assign(UniFont[ftSmall]);
    135135  FillOffscreen(0, 0, InnerWidth, InnerHeight);
    136136
    137137  EndStage := 0;
    138138  while (EndStage < 5) and (MyData.EnhancementJobs[Page, EndStage] <> jNone) do
    139     inc(EndStage);
     139    Inc(EndStage);
    140140  with NoMap do
    141     x := InnerWidth div 2 - xxt - (xxt + 3) * EndStage;
     141    X := InnerWidth div 2 - xxt - (xxt + 3) * EndStage;
    142142
    143143  TerrType := Page;
     
    149149    if stage > 0 then
    150150    begin
    151       Sprite(offscreen, HGrSystem, x - 10, 66, 14, 14, 80, 1);
     151      Sprite(Offscreen, HGrSystem, X - 10, 66, 14, 14, 80, 1);
    152152      case MyData.EnhancementJobs[Page, stage - 1] of
    153153        jRoad:
    154154          begin
    155             inc(Cost, Terrain[TerrType].MoveCost * RoadWork);
     155            Inc(Cost, Terrain[TerrType].MoveCost * RoadWork);
    156156            TileImp := TileImp or fRoad;
    157157          end;
    158158        jRR:
    159159          begin
    160             inc(Cost, Terrain[TerrType].MoveCost * RRWork);
     160            Inc(Cost, Terrain[TerrType].MoveCost * RRWork);
    161161            TileImp := TileImp or fRR;
    162162          end;
    163163        jIrr:
    164164          begin
    165             inc(Cost, Terrain[TerrType].IrrClearWork);
     165            Inc(Cost, Terrain[TerrType].IrrClearWork);
    166166            TileImp := TileImp and not fTerImp or tiIrrigation;
    167167          end;
    168168        jFarm:
    169169          begin
    170             inc(Cost, Terrain[TerrType].IrrClearWork * FarmWork);
     170            Inc(Cost, Terrain[TerrType].IrrClearWork * FarmWork);
    171171            TileImp := TileImp and not fTerImp or tiFarm;
    172172          end;
    173173        jMine:
    174174          begin
    175             inc(Cost, Terrain[TerrType].MineAfforestWork);
     175            Inc(Cost, Terrain[TerrType].MineAfforestWork);
    176176            TileImp := TileImp and not fTerImp or tiMine;
    177177          end;
    178178        jClear:
    179179          begin
    180             inc(Cost, Terrain[TerrType].IrrClearWork);
     180            Inc(Cost, Terrain[TerrType].IrrClearWork);
    181181            TerrType := Terrain[TerrType].ClearTerrain;
    182182          end;
    183183        jAfforest:
    184184          begin
    185             inc(Cost, Terrain[TerrType].MineAfforestWork);
     185            Inc(Cost, Terrain[TerrType].MineAfforestWork);
    186186            TerrType := Terrain[TerrType].AfforestTerrain;
    187187          end;
    188188        jTrans:
    189189          begin
    190             inc(Cost, Terrain[TerrType].TransWork);
     190            Inc(Cost, Terrain[TerrType].TransWork);
    191191            TerrType := Terrain[TerrType].TransTerrain;
    192192          end;
    193193      end;
    194       include(Done, MyData.EnhancementJobs[Page, stage - 1]);
     194      Include(Done, MyData.EnhancementJobs[Page, stage - 1]);
    195195    end;
    196196
    197197    with NoMap do begin
    198198      if TerrType < fForest then
    199         Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     199        Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2,
    200200          1 + TerrType * (xxt * 2 + 1), 1 + yyt)
    201201      else
    202202      begin
    203         Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     203        Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2,
    204204          1 + 2 * (xxt * 2 + 1), 1 + yyt + 2 * (yyt * 3 + 1));
    205         Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     205        Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2,
    206206          1 + 7 * (xxt * 2 + 1), 1 + yyt + 2 * (2 + TerrType - fForest) *
    207207          (yyt * 3 + 1));
    208208      end;
    209209      if TileImp and fTerImp = tiFarm then
    210         Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     210        Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2,
    211211          1 + (xxt * 2 + 1), 1 + yyt + 12 * (yyt * 3 + 1))
    212212      else if TileImp and fTerImp = tiIrrigation then
    213         Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 1,
     213        Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2, 1,
    214214          1 + yyt + 12 * (yyt * 3 + 1));
    215215      if TileImp and fRR <> 0 then
    216216      begin
    217         Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     217        Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2,
    218218          1 + 6 * (xxt * 2 + 1), 1 + yyt + 10 * (yyt * 3 + 1));
    219         Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     219        Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2,
    220220          1 + 2 * (xxt * 2 + 1), 1 + yyt + 10 * (yyt * 3 + 1));
    221221      end
    222222      else if TileImp and fRoad <> 0 then
    223223      begin
    224         Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     224        Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2,
    225225          1 + 6 * (xxt * 2 + 1), 1 + yyt + 9 * (yyt * 3 + 1));
    226         Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     226        Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2,
    227227          1 + 2 * (xxt * 2 + 1), 1 + yyt + 9 * (yyt * 3 + 1));
    228228      end;
    229229      if TileImp and fTerImp = tiMine then
    230         Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     230        Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2,
    231231          1 + 2 * (xxt * 2 + 1), 1 + yyt + 12 * (yyt * 3 + 1));
    232       inc(x, xxt * 2 + 6);
    233     end;
    234   end;
    235 
    236   for i := 0 to Popup.Items.Count - 1 do
    237     if Popup.Items[i].Tag = Page then
    238       s := Popup.Items[i].Caption;
     232      Inc(X, xxt * 2 + 6);
     233    end;
     234  end;
     235
     236  for I := 0 to Popup.Items.Count - 1 do
     237    if Popup.Items[I].Tag = Page then
     238      S := Popup.Items[I].Caption;
    239239  if Cost > 0 then
    240     s := Format(Phrases.Lookup('ENHANCE'), [s, MovementToString(Cost)]);
    241   LoweredTextOut(offscreen.Canvas, -1, MainTexture,
    242     (InnerWidth - BiColorTextWidth(offscreen.Canvas, s)) div 2, 12, s);
     240    S := Format(Phrases.Lookup('ENHANCE'), [S, MovementToString(Cost)]);
     241  LoweredTextOut(Offscreen.Canvas, -1, MainTexture,
     242    (InnerWidth - BiColorTextWidth(Offscreen.Canvas, S)) div 2, 12, S);
    243243
    244244  if EndStage > 0 then
     
    289289    (Terrain[TerrType].MineEff > 0);
    290290  job3.Visible := not TypeChanged and (Terrain[TerrType].ClearTerrain >= 0) and
    291     ((TerrType <> fDesert) or (MyRO.Wonder[woGardens].EffectiveOwner = me)) or
     291    ((TerrType <> fDesert) or (MyRO.Wonder[woGardens].EffectiveOwner = Me)) or
    292292    (LastJob = jClear);
    293293  job6.Visible := not TypeChanged and (Terrain[TerrType].AfforestTerrain >= 0)
     
    306306procedure TEnhanceDlg.ToggleBtnClick(Sender: TObject);
    307307var
    308   i: integer;
    309 begin
    310   for i := 0 to Popup.Items.Count - 1 do
    311     Popup.Items[i].Checked := Popup.Items[i].Tag = Page;
     308  I: Integer;
     309begin
     310  for I := 0 to Popup.Items.Count - 1 do
     311    Popup.Items[I].Checked := Popup.Items[I].Tag = Page;
    312312  Popup.Popup(Left + ToggleBtn.Left, Top + ToggleBtn.Top + ToggleBtn.Height);
    313313end;
     
    321321procedure TEnhanceDlg.JobClick(Sender: TObject);
    322322var
    323   stage, NewJob: integer;
     323  stage, NewJob: Integer;
    324324  Done: Set of jNone .. jTrans;
    325325
    326   procedure RemoveJob(j: integer);
     326  procedure RemoveJob(J: Integer);
    327327  begin // remove job
    328328    stage := 0;
    329329    while (stage < 5) and (MyData.EnhancementJobs[Page, stage] <> jNone) do
    330330    begin
    331       if (MyData.EnhancementJobs[Page, stage] = j) or (j = jRoad) and
    332         (MyData.EnhancementJobs[Page, stage] = jRR) or (j = jIrr) and
     331      if (MyData.EnhancementJobs[Page, stage] = J) or (J = jRoad) and
     332        (MyData.EnhancementJobs[Page, stage] = jRR) or (J = jIrr) and
    333333        (MyData.EnhancementJobs[Page, stage] = jFarm) then
    334334      begin
    335335        if stage < 4 then
    336           move(MyData.EnhancementJobs[Page, stage + 1],
     336          Move(MyData.EnhancementJobs[Page, stage + 1],
    337337            MyData.EnhancementJobs[Page, stage], 4 - stage);
    338338        MyData.EnhancementJobs[Page, 4] := jNone;
    339339      end
    340340      else
    341         inc(stage);
     341        Inc(stage);
    342342    end;
    343343  end;
     
    349349  while (stage < 5) and (MyData.EnhancementJobs[Page, stage] <> jNone) do
    350350  begin
    351     include(Done, MyData.EnhancementJobs[Page, stage]);
    352     inc(stage);
     351    Include(Done, MyData.EnhancementJobs[Page, stage]);
     352    Inc(stage);
    353353  end;
    354354  if NewJob in Done then
     
    363363    begin
    364364      MyData.EnhancementJobs[Page, stage] := jRoad;
    365       inc(stage);
     365      Inc(stage);
    366366    end;
    367367    if (NewJob = jFarm) and not(jIrr in Done) then
    368368    begin
    369369      MyData.EnhancementJobs[Page, stage] := jIrr;
    370       inc(stage);
     370      Inc(stage);
    371371    end;
    372372    MyData.EnhancementJobs[Page, stage] := NewJob;
  • trunk/LocalPlayer/Help.pas

    r431 r447  
    4141  THyperText = class(TStringList)
    4242  public
    43     procedure AddLine(s: String = ''; Format: integer = 0; Picpix: Integer = 0;
    44       LinkCategory: integer = 0; LinkIndex: integer = 0);
     43    procedure AddLine(S: String = ''; Format: Integer = 0; Picpix: Integer = 0;
     44      LinkCategory: Integer = 0; LinkIndex: Integer = 0);
    4545    procedure LineFeed;
    4646    procedure AppendList(Source: THyperText);
     
    7878    procedure CloseBtnClick(Sender: TObject);
    7979    procedure PaintBox1MouseMove(Sender: TObject; Shift: TShiftState;
    80       x, y: integer);
     80      X, Y: Integer);
    8181    procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
    82       Shift: TShiftState; x, y: integer);
     82      Shift: TShiftState; X, Y: Integer);
    8383    procedure BackBtnClick(Sender: TObject);
    8484    procedure TopBtnClick(Sender: TObject);
     
    104104    NoMap: TIsoMap;
    105105    x0: array [-2..180] of Integer;
    106     procedure PaintTerrIcon(x, y, xSrc, ySrc: Integer);
     106    procedure PaintTerrIcon(X, Y, xSrc, ySrc: Integer);
    107107    procedure ScrollBarUpdate(Sender: TObject);
    108     procedure Line(ca: TCanvas; i: Integer; lit: Boolean);
     108    procedure Line(ca: TCanvas; I: Integer; lit: Boolean);
    109109    procedure Prepare(sbPos: Integer = 0);
    110110    procedure ShowNewContentProcExecute(NewMode: TWindowMode; HelpContext: string);
     
    176176end;
    177177
    178 procedure THyperText.AddLine(s: String; Format: integer; Picpix: integer;
    179   LinkCategory: integer; LinkIndex: integer);
     178procedure THyperText.AddLine(S: String; Format: Integer; Picpix: Integer;
     179  LinkCategory: Integer; LinkIndex: Integer);
    180180var
    181181  HelpLineInfo: THelpLineInfo;
     
    187187  HelpLineInfo.Picpix := Picpix;
    188188  HelpLineInfo.Link := LinkCategory shl 8 + LinkIndex;
    189   AddObject(s, TObject(HelpLineInfo));
     189  AddObject(S, TObject(HelpLineInfo));
    190190end;
    191191
     
    263263
    264264  nTerrainHelp = 14;
    265   TerrainHelp: array [0 .. nTerrainHelp - 1] of integer = (fGrass, fGrass + 12,
     265  TerrainHelp: array [0 .. nTerrainHelp - 1] of Integer = (fGrass, fGrass + 12,
    266266    fPrairie, fForest, fJungle, fHills, fMountains, fSwamp, fTundra, fArctic,
    267267    fDesert, 3 * 12 { DeadLands } , fShore, fOcean);
    268268
    269269  nJobHelp = 8;
    270   JobHelp: array [0 .. nJobHelp - 1] of integer = (jRoad, jRR, jCanal, jIrr,
     270  JobHelp: array [0 .. nJobHelp - 1] of Integer = (jRoad, jRR, jCanal, jIrr,
    271271    jFarm, jMine, jFort, jBase);
    272272
     
    280280  CaptionLeft := BackBtn.Left + BackBtn.Width;
    281281  CaptionRight := SearchBtn.Left;
    282   inc(ModalFrameIndent, 29);
     282  Inc(ModalFrameIndent, 29);
    283283  MainText := THyperText.Create;
    284284  MainText.OwnsObjects := True;
     
    356356  if ScrollBar.Process(Msg) then begin
    357357    Sel := -1;
    358     SmartUpdateContent(true)
     358    SmartUpdateContent(True)
    359359  end;
    360360  }
     
    364364begin
    365365  if Sel <> -1 then begin
    366     Line(Canvas, Sel, false);
     366    Line(Canvas, Sel, False);
    367367    Sel := -1
    368368  end;
     
    380380end;
    381381
    382 procedure THelpDlg.Line(ca: TCanvas; i: Integer; lit: Boolean);
     382procedure THelpDlg.Line(ca: TCanvas; I: Integer; lit: Boolean);
    383383var
    384   TextColor, x, y: Integer;
     384  TextColor, X, Y: Integer;
    385385  TextSize: TSize;
    386   s: string;
    387 begin
    388   s := MainText[ScrollBar.Position + i];
    389   if s = '' then
     386  S: string;
     387begin
     388  S := MainText[ScrollBar.Position + I];
     389  if S = '' then
    390390    Exit;
    391   x := x0[i];
    392   y := 2 + i * 24;
     391  X := x0[I];
     392  Y := 2 + I * 24;
    393393  if ca = Canvas then
    394394  begin
    395     x := x + SideFrame;
    396     y := y + WideFrame
    397   end;
    398   if THelpLineInfo(MainText.Objects[ScrollBar.Position + i]).Format
     395    X := X + SideFrame;
     396    Y := Y + WideFrame
     397  end;
     398  if THelpLineInfo(MainText.Objects[ScrollBar.Position + I]).Format
    399399    in [pkCaption, pkBigTer, pkRightIcon, pkBigFeature] then
    400400  begin
    401401    ca.Font.Assign(CaptionFont);
    402402    { ca.brush.color:=CaptionColor;
    403       ca.FillRect(rect(x,i*24,x+24,i*24+24));
    404       ca.brush.color:=$FFFFFF;
    405       ca.FrameRect(rect(x+1,i*24+1,x+24-1,i*24+24-1));
     403      ca.FillRect(rect(X,I*24,X+24,I*24+24));
     404      ca.Brush.Color:=$FFFFFF;
     405      ca.FrameRect(rect(X+1,I*24+1,X+24-1,I*24+24-1));
    406406      ca.Brush.Style:=bsClear; }
    407     BitBltCanvas(ca, x, y - 4, 24, 24, HGrSystem.Data.Canvas, 1,
     407    BitBltCanvas(ca, X, Y - 4, 24, 24, HGrSystem.Data.Canvas, 1,
    408408      146);
    409     BiColorTextOut(ca, $FFFFFF, $7F007F, x + 10 - ca.Textwidth(s[1]) div 2,
    410       y - 3, s[1]);
    411     BiColorTextOut(ca, CaptionColor, $7F007F, x + 24, y - 3, copy(s, 2, 255));
     409    BiColorTextOut(ca, $FFFFFF, $7F007F, X + 10 - ca.Textwidth(S[1]) div 2,
     410      Y - 3, S[1]);
     411    BiColorTextOut(ca, CaptionColor, $7F007F, X + 24, Y - 3, Copy(S, 2, 255));
    412412    ca.Font.Assign(UniFont[ftNormal]);
    413413  end
    414   else if THelpLineInfo(MainText.Objects[ScrollBar.Position + i]).Format = pkSection
     414  else if THelpLineInfo(MainText.Objects[ScrollBar.Position + I]).Format = pkSection
    415415  then
    416416  begin
    417417    ca.Font.Assign(CaptionFont);
    418     BiColorTextOut(ca, CaptionColor, $7F007F, x, y - 3, s);
     418    BiColorTextOut(ca, CaptionColor, $7F007F, X, Y - 3, S);
    419419    ca.Font.Assign(UniFont[ftNormal]);
    420420  end
     
    426426    if ca = Canvas then
    427427    begin
    428       TextSize.cx := BiColorTextWidth(ca, s);
    429       TextSize.cy := ca.TextHeight(s);
    430       if y + TextSize.cy >= WideFrame + InnerHeight then
    431         TextSize.cy := WideFrame + InnerHeight - y;
    432       FillSeamless(ca, x, y, TextSize.cx, TextSize.cy, -SideFrame,
     428      TextSize.cx := BiColorTextWidth(ca, S);
     429      TextSize.cy := ca.TextHeight(S);
     430      if Y + TextSize.cy >= WideFrame + InnerHeight then
     431        TextSize.cy := WideFrame + InnerHeight - Y;
     432      FillSeamless(ca, X, Y, TextSize.cx, TextSize.cy, -SideFrame,
    433433        ScrollBar.Position * 24 - WideFrame, Paper);
    434434    end;
    435     BiColorTextOut(ca, TextColor, $7F007F, x, y, s);
     435    BiColorTextOut(ca, TextColor, $7F007F, X, Y, S);
    436436    if lit then
    437437      with ca do
     
    439439        Assert(ca = Canvas);
    440440        Pen.Color := TextColor;
    441         MoveTo(x + 1, y + TextSize.cy - 2);
    442         LineTo(x + TextSize.cx, y + TextSize.cy - 2);
     441        MoveTo(X + 1, Y + TextSize.cy - 2);
     442        LineTo(X + TextSize.cx, Y + TextSize.cy - 2);
    443443      end;
    444444    if (Kind = hkMisc) and (no = miscMain) then
     
    447447end;
    448448
    449 procedure THelpDlg.WaterSign(x0, y0, iix: integer);
     449procedure THelpDlg.WaterSign(x0, y0, iix: Integer);
    450450const
    451451  nHeaven = 28;
    452452  MaxSum = 9 * 9 * 255 * 75 div 100;
    453453var
    454   x, y, dx, dy, xSrc, ySrc, Sum, xx: integer;
    455   Heaven: array [0..nHeaven] of integer;
     454  X, Y, dx, dy, xSrc, ySrc, Sum, xx: Integer;
     455  Heaven: array [0..nHeaven] of Integer;
    456456  PaintPtr: TPixelPointer;
    457457  CoalPtr: TPixelPointer;
     
    471471  for dy := -1 to 1 do
    472472    ImpPtr[dy] := PixelPointer(BigImp, ScaleToNative(xSrc), ScaleToNative(ySrc));
    473   for y := 0 to ScaleToNative(ySizeBig) * 2 - 1 do begin
    474     if ((ScaleToNative(y0) + y) >= 0) and ((ScaleToNative(y0) + y) < ScaleToNative(InnerHeight)) then begin
     473  for Y := 0 to ScaleToNative(ySizeBig) * 2 - 1 do begin
     474    if ((ScaleToNative(y0) + Y) >= 0) and ((ScaleToNative(y0) + Y) < ScaleToNative(InnerHeight)) then begin
    475475      for dy := -1 to 1 do
    476         if ((Max(y + ScaleToNative(dy), 0) shr 1) >= 0) and ((Max(y + ScaleToNative(dy), 0) shr 1) < ScaleToNative(ySizeBig)) then
    477           ImpPtr[dy].SetXY(0, Max(y + ScaleToNative(dy), 0) shr 1);
    478       for x := 0 to ScaleToNative(xSizeBig * 2) - 1 do begin
     476        if ((Max(Y + ScaleToNative(dy), 0) shr 1) >= 0) and ((Max(Y + ScaleToNative(dy), 0) shr 1) < ScaleToNative(ySizeBig)) then
     477          ImpPtr[dy].SetXY(0, Max(Y + ScaleToNative(dy), 0) shr 1);
     478      for X := 0 to ScaleToNative(xSizeBig * 2) - 1 do begin
    479479        Sum := 0;
    480480        for dx := -1 to 1 do begin
    481           xx := Max((x + ScaleToNative(dx)), 0) shr 1;
     481          xx := Max((X + ScaleToNative(dx)), 0) shr 1;
    482482          for dy := -1 to 1 do begin
    483483            ImpPtr[dy].SetX(xx);
    484             if ((y + ScaleToNative(dy)) shr 1 < 0) or ((y + ScaleToNative(dy)) shr 1 >= ScaleToNative(ySizeBig)) or
    485               ((x + ScaleToNative(dx)) shr 1 < 0) or ((x + ScaleToNative(dx)) shr 1 >= ScaleToNative(xSizeBig)) or
    486               ((y + ScaleToNative(dy)) shr 1 < ScaleToNative(nHeaven)) and
     484            if ((Y + ScaleToNative(dy)) shr 1 < 0) or ((Y + ScaleToNative(dy)) shr 1 >= ScaleToNative(ySizeBig)) or
     485              ((X + ScaleToNative(dx)) shr 1 < 0) or ((X + ScaleToNative(dx)) shr 1 >= ScaleToNative(xSizeBig)) or
     486              ((Y + ScaleToNative(dy)) shr 1 < ScaleToNative(nHeaven)) and
    487487              (ImpPtr[dy].Pixel^.B shl 16 + ImpPtr[dy].Pixel^.G shl 8 +
    488               ImpPtr[dy].Pixel^.R = Heaven[(ScaleFromNative(y + ScaleToNative(dy))) shr 1]) then
     488              ImpPtr[dy].Pixel^.R = Heaven[(ScaleFromNative(Y + ScaleToNative(dy))) shr 1]) then
    489489              Sum := Sum + 9 * 255
    490490            else
     
    510510end;
    511511
    512 procedure THelpDlg.PaintTerrIcon(x, y, xSrc, ySrc: integer);
     512procedure THelpDlg.PaintTerrIcon(X, Y, xSrc, ySrc: Integer);
    513513begin
    514514  with NoMap do begin
    515     Frame(OffScreen.Canvas, x - 1, y - 1, x + xSizeBig, y + ySizeBig,
     515    Frame(OffScreen.Canvas, X - 1, Y - 1, X + xSizeBig, Y + ySizeBig,
    516516      $000000, $000000);
    517517    if 2 * yyt < 40 then begin
    518       Sprite(OffScreen, HGrTerrain, x, y, 56, 2 * yyt, xSrc, ySrc);
    519       Sprite(OffScreen, HGrTerrain, x, y + 2 * yyt, 56, 40 - 2 * yyt,
     518      Sprite(OffScreen, HGrTerrain, X, Y, 56, 2 * yyt, xSrc, ySrc);
     519      Sprite(OffScreen, HGrTerrain, X, Y + 2 * yyt, 56, 40 - 2 * yyt,
    520520        xSrc, ySrc);
    521521    end else
    522       Sprite(OffScreen, HGrTerrain, x, y, 56, 40, xSrc, ySrc);
    523     Sprite(OffScreen, HGrTerrain, x, y, xxt, yyt, xSrc + xxt, ySrc + yyt);
    524     Sprite(OffScreen, HGrTerrain, x, y + yyt, xxt, 40 - yyt, xSrc + xxt, ySrc);
    525     Sprite(OffScreen, HGrTerrain, x + xxt, y, 56 - xxt, yyt, xSrc, ySrc + yyt);
    526     Sprite(OffScreen, HGrTerrain, x + xxt, y + yyt, 56 - xxt, 40 - yyt,
     522      Sprite(OffScreen, HGrTerrain, X, Y, 56, 40, xSrc, ySrc);
     523    Sprite(OffScreen, HGrTerrain, X, Y, xxt, yyt, xSrc + xxt, ySrc + yyt);
     524    Sprite(OffScreen, HGrTerrain, X, Y + yyt, xxt, 40 - yyt, xSrc + xxt, ySrc);
     525    Sprite(OffScreen, HGrTerrain, X + xxt, Y, 56 - xxt, yyt, xSrc, ySrc + yyt);
     526    Sprite(OffScreen, HGrTerrain, X + xxt, Y + yyt, 56 - xxt, 40 - yyt,
    527527      xSrc, ySrc);
    528528  end;
     
    531531procedure THelpDlg.OffscreenPaint;
    532532var
    533   i, j, yl, srcno, ofs, cnt, y: Integer;
    534   s: string;
     533  I, J, yl, srcno, ofs, cnt, Y: Integer;
     534  S: string;
    535535  HelpLineInfo: THelpLineInfo;
    536536begin
     
    542542  begin
    543543    Font.Assign(UniFont[ftNormal]);
    544     for i := -ScrollBar.Position to InnerHeight div 24 do
    545       if ScrollBar.Position + i < MainText.Count then
     544    for I := -ScrollBar.Position to InnerHeight div 24 do
     545      if ScrollBar.Position + I < MainText.Count then
    546546      begin
    547         HelpLineInfo := THelpLineInfo(MainText.Objects[ScrollBar.Position + i]);
     547        HelpLineInfo := THelpLineInfo(MainText.Objects[ScrollBar.Position + I]);
    548548        if HelpLineInfo.Format = pkExternal then
    549549        begin
    550550          yl := ExtPic.Height;
    551           if 4 + i * 24 + yl > InnerHeight then
    552             yl := InnerHeight - (4 + i * 24);
    553           BitBltCanvas(OffScreen.Canvas, 8, 4 + i * 24, ExtPic.Width, yl, ExtPic.Canvas,
     551          if 4 + I * 24 + yl > InnerHeight then
     552            yl := InnerHeight - (4 + I * 24);
     553          BitBltCanvas(OffScreen.Canvas, 8, 4 + I * 24, ExtPic.Width, yl, ExtPic.Canvas,
    554554            0, 0);
    555555        end;
    556556      end;
    557     for i := -2 to InnerHeight div 24 do
    558       if (ScrollBar.Position + i >= 0) and (ScrollBar.Position + i < MainText.Count) then
     557    for I := -2 to InnerHeight div 24 do
     558      if (ScrollBar.Position + I >= 0) and (ScrollBar.Position + I < MainText.Count) then
    559559      begin
    560         HelpLineInfo := THelpLineInfo(MainText.Objects[ScrollBar.Position + i]);
     560        HelpLineInfo := THelpLineInfo(MainText.Objects[ScrollBar.Position + I]);
    561561        if HelpLineInfo.Link <> 0 then
    562562        begin
    563563          if (Kind = hkMisc) and (no = miscSearchResult) then
    564             Sprite(OffScreen, HGrSystem, 18, 9 + i * 24, 8, 8, 90, 16)
     564            Sprite(OffScreen, HGrSystem, 18, 9 + I * 24, 8, 8, 90, 16)
    565565          else if HelpLineInfo.Format in [pkSmallIcon_AsPreq, pkAdvIcon_AsPreq]
    566566          then
    567             Sprite(OffScreen, HGrSystem, 12, i * 24 + 5, 14, 14, 65, 20)
     567            Sprite(OffScreen, HGrSystem, 12, I * 24 + 5, 14, 14, 65, 20)
    568568          else if HelpLineInfo.Link and (hkCrossLink shl 8) <> 0 then
    569             Sprite(OffScreen, HGrSystem, 12, i * 24 + 5, 14, 14, 80, 1)
     569            Sprite(OffScreen, HGrSystem, 12, I * 24 + 5, 14, 14, 80, 1)
    570570          else if not((Kind = hkMisc) and (no = miscMain)) then
    571             Sprite(OffScreen, HGrSystem, 10, i * 24 + 6, 14, 14, 65, 1);
    572           x0[i] := 24;
     571            Sprite(OffScreen, HGrSystem, 10, I * 24 + 6, 14, 14, 65, 1);
     572          x0[I] := 24;
    573573        end
    574574        else
    575           x0[i] := 0;
     575          x0[I] := 0;
    576576        case HelpLineInfo.Format of
    577577          pkLogo:
    578578            begin
    579               Server(sGetVersion, 0, 0, j);
    580               s := Format('%d.%d.%d', [j shr 16 and $FF, j shr 8 and $FF,
    581                 j and $FF]);
    582               PaintLogo(OffScreen.Canvas, (InnerWidth - 122) div 2, i * 24 + 1,
     579              Server(sGetVersion, 0, 0, J);
     580              S := Format('%d.%d.%d', [J shr 16 and $FF, J shr 8 and $FF,
     581                J and $FF]);
     582              PaintLogo(OffScreen.Canvas, (InnerWidth - 122) div 2, I * 24 + 1,
    583583                HGrSystem.Data.Canvas.Pixels[95, 1], $000000);
    584584              Font.Assign(UniFont[ftSmall]);
    585585              BiColorTextOut(OffScreen.Canvas, $000000, $7F007F,
    586                 (InnerWidth - Textwidth(s)) div 2, i * 24 + 26, s);
     586                (InnerWidth - Textwidth(S)) div 2, I * 24 + 26, S);
    587587              Font.Assign(UniFont[ftNormal]);
    588588            end;
    589589          pkSmallIcon, pkSmallIcon_AsPreq:
    590590            begin
    591               ScreenTools.Frame(OffScreen.Canvas, 8 - 1 + x0[i], 2 - 1 + i * 24,
    592                 8 + xSizeSmall + x0[i], 2 + 20 + i * 24, $000000, $000000);
     591              ScreenTools.Frame(OffScreen.Canvas, 8 - 1 + x0[I], 2 - 1 + I * 24,
     592                8 + xSizeSmall + x0[I], 2 + 20 + I * 24, $000000, $000000);
    593593              if HelpLineInfo.Picpix = imPalace then
    594                 BitBltCanvas(OffScreen.Canvas, 8 + x0[i], 2 + i * 24,
     594                BitBltCanvas(OffScreen.Canvas, 8 + x0[I], 2 + I * 24,
    595595                  xSizeSmall, ySizeSmall, SmallImp.Canvas,
    596596                  0 * xSizeSmall, 1 * ySizeSmall)
    597597              else
    598                 BitBltCanvas(OffScreen.Canvas, 8 + x0[i], 2 + i * 24,
     598                BitBltCanvas(OffScreen.Canvas, 8 + x0[I], 2 + I * 24,
    599599                  xSizeSmall, ySizeSmall, SmallImp.Canvas,
    600600                  HelpLineInfo.Picpix mod 7 * xSizeSmall,
    601601                  (HelpLineInfo.Picpix + SystemIconLines * 7) div 7 *
    602602                  ySizeSmall);
    603               x0[i] := x0[i] + (8 + 8 + 36);
     603              x0[I] := x0[I] + (8 + 8 + 36);
    604604            end;
    605605          pkBigIcon:
    606606            begin
    607               FrameImage(OffScreen.Canvas, BigImp, x0[i] + 12, i * 24 - 7, 56,
     607              FrameImage(OffScreen.Canvas, BigImp, x0[I] + 12, I * 24 - 7, 56,
    608608                40, HelpLineInfo.Picpix mod 7 * xSizeBig,
    609609                HelpLineInfo.Picpix div 7 * ySizeBig);
    610               x0[i] := 64 + 8 + 8 + x0[i];
     610              x0[I] := 64 + 8 + 8 + x0[I];
    611611            end;
    612612          pkSpecialIcon:
     
    615615                0:
    616616                  FrameImage(OffScreen.Canvas, HGrSystem2.Data,
    617                     12 + x0[i], -7 + i * 24, 56, 40, 137, 127);
     617                    12 + x0[I], -7 + I * 24, 56, 40, 137, 127);
    618618                1:
    619619                  with NoMap do begin
    620                     PaintTerrIcon(12 + x0[i], -7 + i * 24,
     620                    PaintTerrIcon(12 + x0[I], -7 + I * 24,
    621621                      1 + 3 * (xxt * 2 + 1), 1 + yyt);
    622622                    if 2 * yyt < 40 then
    623                       Sprite(OffScreen, HGrTerrain, 12 + x0[i], -7 + 4 + i * 24,
     623                      Sprite(OffScreen, HGrTerrain, 12 + x0[I], -7 + 4 + I * 24,
    624624                        56, 2 * yyt, 1 + 3 * (xxt * 2 + 1) + xxt - 28,
    625625                        1 + yyt + 1 * (yyt * 3 + 1))
    626626                    else
    627                       Sprite(OffScreen, HGrTerrain, 12 + x0[i],
    628                         -7 + 4 + i * 24 - 4, 56, 40, 1 + 3 * (xxt * 2 + 1) + xxt
     627                      Sprite(OffScreen, HGrTerrain, 12 + x0[I],
     628                        -7 + 4 + I * 24 - 4, 56, 40, 1 + 3 * (xxt * 2 + 1) + xxt
    629629                        - 28, 1 + yyt + 1 * (yyt * 3 + 1) + yyt - 20);
    630630                  end;
    631631                2:
    632632                  with NoMap do begin
    633                     PaintTerrIcon(12 + x0[i], -7 + i * 24,
     633                    PaintTerrIcon(12 + x0[I], -7 + I * 24,
    634634                      1 + 7 * (xxt * 2 + 1), 1 + yyt + 4 * (yyt * 3 + 1));
    635635                    if 2 * yyt < 40 then
    636                       Sprite(OffScreen, HGrTerrain, 12 + x0[i], -7 + 4 + i * 24,
     636                      Sprite(OffScreen, HGrTerrain, 12 + x0[I], -7 + 4 + I * 24,
    637637                        56, 32, 1 + 4 * (xxt * 2 + 1) + xxt - 28,
    638638                        1 + yyt + 12 * (yyt * 3 + 1) + yyt - 16)
    639639                    else
    640                       Sprite(OffScreen, HGrTerrain, 12 + x0[i], -7 + 4 + i * 24,
     640                      Sprite(OffScreen, HGrTerrain, 12 + x0[I], -7 + 4 + I * 24,
    641641                        56, 32, 1 + 4 * (xxt * 2 + 1) + xxt - 28,
    642642                        1 + yyt + 12 * (yyt * 3 + 1) + yyt - 16)
    643643                  end;
    644644              end;
    645               x0[i] := 64 + 8 + 8 + x0[i];
     645              x0[I] := 64 + 8 + 8 + x0[I];
    646646            end;
    647647          pkDomain:
    648648            begin
    649               ScreenTools.Frame(OffScreen.Canvas, 8 - 1 + x0[i], 2 - 1 + i * 24,
    650                 8 + 36 + x0[i], 2 + 20 + i * 24, $000000, $000000);
    651               Dump(OffScreen, HGrSystem, 8 + x0[i], 2 + i * 24, 36, 20,
     649              ScreenTools.Frame(OffScreen.Canvas, 8 - 1 + x0[I], 2 - 1 + I * 24,
     650                8 + 36 + x0[I], 2 + 20 + I * 24, $000000, $000000);
     651              Dump(OffScreen, HGrSystem, 8 + x0[I], 2 + I * 24, 36, 20,
    652652                75 + HelpLineInfo.Picpix * 37, 295);
    653               x0[i] := x0[i] + (8 + 8 + 36);
     653              x0[I] := x0[I] + (8 + 8 + 36);
    654654            end;
    655655          pkAdvIcon, pkAdvIcon_AsPreq:
    656656            begin
    657               ScreenTools.Frame(OffScreen.Canvas, 8 - 1 + x0[i], 2 - 1 + i * 24,
    658                 8 + xSizeSmall + x0[i], 2 + ySizeSmall + i * 24,
     657              ScreenTools.Frame(OffScreen.Canvas, 8 - 1 + x0[I], 2 - 1 + I * 24,
     658                8 + xSizeSmall + x0[I], 2 + ySizeSmall + I * 24,
    659659                $000000, $000000);
    660660              if AdvIcon[HelpLineInfo.Picpix] < 84 then
    661                 BitBltCanvas(OffScreen.Canvas, 8 + x0[i], 2 + i * 24,
     661                BitBltCanvas(OffScreen.Canvas, 8 + x0[I], 2 + I * 24,
    662662                  xSizeSmall, ySizeSmall, SmallImp.Canvas,
    663663                  (AdvIcon[HelpLineInfo.Picpix] + SystemIconLines * 7) mod 7 *
     
    665665                  7) div 7 * ySizeSmall)
    666666              else
    667                 Dump(OffScreen, HGrSystem, 8 + x0[i], 2 + i * 24, 36, 20,
     667                Dump(OffScreen, HGrSystem, 8 + x0[I], 2 + I * 24, 36, 20,
    668668                  1 + (AdvIcon[HelpLineInfo.Picpix] - 84) mod 8 * 37,
    669669                  295 + (AdvIcon[HelpLineInfo.Picpix] - 84) div 8 * 21);
    670               j := AdvValue[HelpLineInfo.Picpix] div 1000;
    671               BitBltCanvas(OffScreen.Canvas, x0[i] + 4, 4 + i * 24, 14, 14,
    672                 HGrSystem.Mask.Canvas, 127 + j * 15, 85, SRCAND);
    673               Sprite(OffScreen, HGrSystem, x0[i] + 3, 3 + i * 24, 14, 14,
    674                 127 + j * 15, 85);
    675               x0[i] := x0[i] + (8 + 8 + 36);
     670              J := AdvValue[HelpLineInfo.Picpix] div 1000;
     671              BitBltCanvas(OffScreen.Canvas, x0[I] + 4, 4 + I * 24, 14, 14,
     672                HGrSystem.Mask.Canvas, 127 + J * 15, 85, SRCAND);
     673              Sprite(OffScreen, HGrSystem, x0[I] + 3, 3 + I * 24, 14, 14,
     674                127 + J * 15, 85);
     675              x0[I] := x0[I] + (8 + 8 + 36);
    676676            end;
    677677          pkRightIcon:
    678678            begin
    679679              if Imp[HelpLineInfo.Picpix].Kind <> ikWonder then
    680                 ImpImage(OffScreen.Canvas, InnerWidth - (40 + xSizeBig), i * 24,
     680                ImpImage(OffScreen.Canvas, InnerWidth - (40 + xSizeBig), I * 24,
    681681                  HelpLineInfo.Picpix, gDespotism)
    682682              else
    683                 WaterSign(InnerWidth - (40 + 2 * xSizeBig), i * 24 - 8,
     683                WaterSign(InnerWidth - (40 + 2 * xSizeBig), I * 24 - 8,
    684684                  HelpLineInfo.Picpix + 7);
    685               x0[i] := x0[i] + 8;
     685              x0[I] := x0[I] + 8;
    686686            end;
    687687          pkIllu:
    688             WaterSign(8, i * 24 - 8, HelpLineInfo.Picpix);
     688            WaterSign(8, I * 24 - 8, HelpLineInfo.Picpix);
    689689          pkBigFeature:
    690690            begin
    691691              cnt := 0;
    692               for j := nDomains - 1 downto 0 do
    693                 if 1 shl j and Feature[HelpLineInfo.Picpix].Domains <> 0 then
     692              for J := nDomains - 1 downto 0 do
     693                if 1 shl J and Feature[HelpLineInfo.Picpix].Domains <> 0 then
    694694                begin
    695                   inc(cnt);
     695                  Inc(cnt);
    696696                  Dump(OffScreen, HGrSystem, InnerWidth - 38 - 38 * cnt,
    697                     i * 24 + 1, 36, 20, 75 + j * 37, 295);
    698                   ScreenTools.Frame(OffScreen.Canvas, InnerWidth - 39 - 38 * cnt, i * 24,
    699                     InnerWidth - 2 - 38 * cnt, i * 24 + 21, $000000, $000000);
     697                    I * 24 + 1, 36, 20, 75 + J * 37, 295);
     698                  ScreenTools.Frame(OffScreen.Canvas, InnerWidth - 39 - 38 * cnt, I * 24,
     699                    InnerWidth - 2 - 38 * cnt, I * 24 + 21, $000000, $000000);
    700700                end;
    701701              DarkGradient(OffScreen.Canvas, InnerWidth - 38 - 38 * cnt,
    702                 i * 24 + 23, cnt * 38 - 2, 1);
     702                I * 24 + 23, cnt * 38 - 2, 1);
    703703              ofs := InnerWidth - (39 + 7) - 19 * cnt;
    704704              with OffScreen.Canvas do
    705705              begin
    706                 Brush.color := $C0C0C0;
    707                 FrameRect(Rect(ofs, 1 + 23 + i * 24, ofs + 14,
    708                   15 + 23 + i * 24));
     706                Brush.Color := $C0C0C0;
     707                FrameRect(Rect(ofs, 1 + 23 + I * 24, ofs + 14,
     708                  15 + 23 + I * 24));
    709709                Brush.Style := bsClear;
    710                 Sprite(OffScreen, HGrSystem, ofs + 2, 3 + 23 + i * 24, 10, 10,
     710                Sprite(OffScreen, HGrSystem, ofs + 2, 3 + 23 + I * 24, 10, 10,
    711711                  66 + HelpLineInfo.Picpix mod 11 * 11,
    712712                  137 + HelpLineInfo.Picpix div 11 * 11);
    713713              end;
    714               x0[i] := x0[i] + 8;
     714              x0[I] := x0[I] + 8;
    715715            end;
    716716          pkTer, pkBigTer:
    717717            with NoMap do begin
    718718              if HelpLineInfo.Format = pkBigTer then
    719                 y := i * 24 - 3 + yyt
     719                Y := I * 24 - 3 + yyt
    720720              else
    721                 y := i * 24 + 13;
     721                Y := I * 24 + 13;
    722722              if HelpLineInfo.Picpix >= 3 * 12 then
    723723                srcno := 2 * 9 + 6
     
    730730              if HelpLineInfo.Format = pkTer then
    731731              begin
    732                 ofs := x0[i] + 8;
    733                 x0[i] := 2 * xxt + 8 + ofs;
     732                ofs := x0[I] + 8;
     733                x0[I] := 2 * xxt + 8 + ofs;
    734734              end
    735735              else
    736736              begin
    737737                ofs := InnerWidth - (2 * xxt + 38);
    738                 x0[i] := x0[i] + 8;
     738                x0[I] := x0[I] + 8;
    739739              end;
    740740              if srcno >= fJungle then
    741741              begin
    742                 Sprite(OffScreen, HGrTerrain, ofs + 4, y - yyt + 2, xxt * 2 - 8,
     742                Sprite(OffScreen, HGrTerrain, ofs + 4, Y - yyt + 2, xxt * 2 - 8,
    743743                  yyt * 2 - 4, 5 + 2 * (xxt * 2 + 1),
    744744                  3 + yyt + 2 * (yyt * 3 + 1));
    745                 Sprite(OffScreen, HGrTerrain, ofs, y - 2 * yyt, xxt * 2,
     745                Sprite(OffScreen, HGrTerrain, ofs, Y - 2 * yyt, xxt * 2,
    746746                  yyt * 3 - 2, 1 + srcno mod 9 * (xxt * 2 + 1),
    747747                  1 + srcno div 9 * (yyt * 3 + 1));
    748748              end
    749749              else
    750                 Sprite(OffScreen, HGrTerrain, ofs + 4, y - yyt + 2, xxt * 2 - 8,
     750                Sprite(OffScreen, HGrTerrain, ofs + 4, Y - yyt + 2, xxt * 2 - 8,
    751751                  yyt * 2 - 4, 5 + srcno mod 9 * (xxt * 2 + 1),
    752752                  3 + yyt + srcno div 9 * (yyt * 3 + 1));
    753753              if HelpLineInfo.Picpix >= 3 * 12 then { rare resource }
    754                 Sprite(OffScreen, HGrTerrain, ofs, y - 2 * yyt, xxt * 2,
     754                Sprite(OffScreen, HGrTerrain, ofs, Y - 2 * yyt, xxt * 2,
    755755                  yyt * 3, 1 + 8 * (xxt * 2 + 1),
    756756                  1 + (HelpLineInfo.Picpix - 2 * 12) * (yyt * 3 + 1))
     
    764764                  srcno := 18 + 8 + (HelpLineInfo.Picpix mod 12 - 9) * 18;
    765765                srcno := srcno + HelpLineInfo.Picpix div 12 * 9;
    766                 Sprite(OffScreen, HGrTerrain, ofs, y - 2 * yyt, xxt * 2,
     766                Sprite(OffScreen, HGrTerrain, ofs, Y - 2 * yyt, xxt * 2,
    767767                  yyt * 3, 1 + srcno mod 9 * (xxt * 2 + 1),
    768768                  1 + srcno div 9 * (yyt * 3 + 1));
     
    774774              if HelpLineInfo.Picpix = 5 then
    775775              begin // display mine on hills
    776                 Sprite(OffScreen, HGrTerrain, ofs + 4, i * 24 + 13 - yyt,
     776                Sprite(OffScreen, HGrTerrain, ofs + 4, I * 24 + 13 - yyt,
    777777                  xxt * 2 - 8, yyt * 2 - 4, 5 + 2 * (xxt * 2 + 1),
    778778                  3 + yyt + 2 * (yyt * 3 + 1));
     
    781781              else
    782782                srcno := fPrairie; // display on prairie
    783               Sprite(OffScreen, HGrTerrain, ofs + 4, i * 24 + 13 - yyt,
     783              Sprite(OffScreen, HGrTerrain, ofs + 4, I * 24 + 13 - yyt,
    784784                xxt * 2 - 8, yyt * 2 - 4, 5 + srcno mod 9 * (xxt * 2 + 1),
    785785                3 + yyt + srcno div 9 * (yyt * 3 + 1));
    786786              if HelpLineInfo.Picpix = 12 then { river }
    787                 Sprite(OffScreen, HGrTerrain, ofs, i * 24 + 11 - yyt, xxt * 2,
     787                Sprite(OffScreen, HGrTerrain, ofs, I * 24 + 11 - yyt, xxt * 2,
    788788                  yyt * 2, 1 + 5 * (xxt * 2 + 1), 1 + yyt + 13 * (yyt * 3 + 1))
    789789              else if HelpLineInfo.Picpix >= 3 then { improvement 2 }
    790790              begin
    791791                if HelpLineInfo.Picpix = 6 then
    792                   Sprite(OffScreen, HGrTerrain, ofs, i * 24 + 11 - 2 * yyt,
     792                  Sprite(OffScreen, HGrTerrain, ofs, I * 24 + 11 - 2 * yyt,
    793793                    xxt * 2, yyt * 3, 1 + 7 * (xxt * 2 + 1),
    794794                    1 + 12 * (yyt * 3 + 1));
    795                 Sprite(OffScreen, HGrTerrain, ofs, i * 24 + 11 - 2 * yyt,
     795                Sprite(OffScreen, HGrTerrain, ofs, I * 24 + 11 - 2 * yyt,
    796796                  xxt * 2, yyt * 3, 1 + (HelpLineInfo.Picpix - 3) *
    797797                  (xxt * 2 + 1), 1 + 12 * (yyt * 3 + 1))
     
    799799              else { improvement 1 }
    800800              begin
    801                 Sprite(OffScreen, HGrTerrain, ofs, i * 24 + 11 - 2 * yyt,
     801                Sprite(OffScreen, HGrTerrain, ofs, I * 24 + 11 - 2 * yyt,
    802802                  xxt * 2, yyt * 3, 1 + 2 * (xxt * 2 + 1),
    803803                  1 + (9 + HelpLineInfo.Picpix) * (yyt * 3 + 1));
    804                 Sprite(OffScreen, HGrTerrain, ofs, i * 24 + 11 - 2 * yyt,
     804                Sprite(OffScreen, HGrTerrain, ofs, I * 24 + 11 - 2 * yyt,
    805805                  xxt * 2, yyt * 3, 1 + 5 * (xxt * 2 + 1),
    806806                  1 + (9 + HelpLineInfo.Picpix) * (yyt * 3 + 1))
    807807              end;
    808               x0[i] := x0[i] + 8;
     808              x0[I] := x0[I] + 8;
    809809            end;
    810810          pkModel:
    811811            begin
    812               FrameImage(OffScreen.Canvas, BigImp, x0[i] + 12, i * 24 - 7,
     812              FrameImage(OffScreen.Canvas, BigImp, x0[I] + 12, I * 24 - 7,
    813813                56, 40, 0, 0);
    814               Sprite(OffScreen, HGrStdUnits, x0[i] + 8, i * 24 - 11, 64, 44,
     814              Sprite(OffScreen, HGrStdUnits, x0[I] + 8, I * 24 - 11, 64, 44,
    815815                1 + HelpLineInfo.Picpix mod 10 * 65,
    816816                1 + HelpLineInfo.Picpix div 10 * 49);
    817               x0[i] := 64 + 8 + 8 + x0[i];
     817              x0[I] := 64 + 8 + 8 + x0[I];
    818818            end;
    819819          pkFeature:
    820820            begin
    821               DarkGradient(OffScreen.Canvas, x0[i] + 8 - 1,
    822                 7 + i * 24 - 3, 16, 1);
    823               ScreenTools.Frame(OffScreen.Canvas, x0[i] + 8, 7 + i * 24 - 2, x0[i] + 8 + 13,
    824                 7 + i * 24 - 2 + 13, $C0C0C0, $C0C0C0);
    825               Sprite(OffScreen, HGrSystem, x0[i] + 8 + 2, 7 + i * 24, 10, 10,
     821              DarkGradient(OffScreen.Canvas, x0[I] + 8 - 1,
     822                7 + I * 24 - 3, 16, 1);
     823              ScreenTools.Frame(OffScreen.Canvas, x0[I] + 8, 7 + I * 24 - 2, x0[I] + 8 + 13,
     824                7 + I * 24 - 2 + 13, $C0C0C0, $C0C0C0);
     825              Sprite(OffScreen, HGrSystem, x0[I] + 8 + 2, 7 + I * 24, 10, 10,
    826826                66 + HelpLineInfo.Picpix mod 11 * 11,
    827827                137 + HelpLineInfo.Picpix div 11 * 11);
    828               x0[i] := x0[i] + 8 + 8 + 2 + 13;
     828              x0[I] := x0[I] + 8 + 8 + 2 + 13;
    829829            end;
    830830          pkExp:
    831831            begin
    832               ScreenTools.Frame(OffScreen.Canvas, 20 - 1, 8 - 4 + i * 24, 20 + 12,
    833                 8 + 11 + i * 24, $000000, $000000);
    834               Dump(OffScreen, HGrSystem, 20, 8 - 3 + i * 24, 12, 14,
     832              ScreenTools.Frame(OffScreen.Canvas, 20 - 1, 8 - 4 + I * 24, 20 + 12,
     833                8 + 11 + I * 24, $000000, $000000);
     834              Dump(OffScreen, HGrSystem, 20, 8 - 3 + I * 24, 12, 14,
    835835                121 + HelpLineInfo.Picpix * 13, 28);
    836               x0[i] := 20 + 8 + 11;
     836              x0[I] := 20 + 8 + 11;
    837837            end;
    838838          pkAITStat:
    839839            begin
    840               Sprite(OffScreen, HGrSystem, 20, 6 + i * 24, 14, 14,
     840              Sprite(OffScreen, HGrSystem, 20, 6 + I * 24, 14, 14,
    841841                1 + HelpLineInfo.Picpix * 15, 316);
    842               x0[i] := 20 + 8 + 11;
     842              x0[I] := 20 + 8 + 11;
    843843            end;
    844844          pkGov:
    845845            begin
    846               ScreenTools.Frame(OffScreen.Canvas, 8 - 1 + x0[i], 2 - 1 + i * 24,
    847                 8 + xSizeSmall + x0[i], 2 + 20 + i * 24, $000000, $000000);
    848               BitBltCanvas(OffScreen.Canvas, 8 + x0[i], 2 + i * 24, xSizeSmall,
     846              ScreenTools.Frame(OffScreen.Canvas, 8 - 1 + x0[I], 2 - 1 + I * 24,
     847                8 + xSizeSmall + x0[I], 2 + 20 + I * 24, $000000, $000000);
     848              BitBltCanvas(OffScreen.Canvas, 8 + x0[I], 2 + I * 24, xSizeSmall,
    849849                ySizeSmall, SmallImp.Canvas, (HelpLineInfo.Picpix - 1) *
    850850                xSizeSmall, ySizeSmall);
    851               x0[i] := x0[i] + (8 + 8 + 36);
     851              x0[I] := x0[I] + (8 + 8 + 36);
    852852            end;
    853853          pkDot:
    854854            begin
    855               Sprite(OffScreen, HGrSystem, x0[i] + 18, 9 + i * 24, 8,
     855              Sprite(OffScreen, HGrSystem, x0[I] + 18, 9 + I * 24, 8,
    856856                8, 81, 16);
    857               x0[i] := 20 + 8 + 4;
     857              x0[I] := 20 + 8 + 4;
    858858            end;
    859859          pkNormal_Dot:
    860             x0[i] := 20 + 8 + 4;
     860            x0[I] := 20 + 8 + 4;
    861861          pkNormal_64:
    862             x0[i] := 64 + 8 + 8;
     862            x0[I] := 64 + 8 + 8;
    863863        else
    864           x0[i] := x0[i] + 8;
     864          x0[I] := x0[I] + 8;
    865865        end;
    866         Self.Line(OffScreen.Canvas, i, False)
     866        Self.Line(OffScreen.Canvas, I, False)
    867867      end;
    868868  end;
     
    873873begin
    874874  Sel := -1;
    875   SmartUpdateContent(true)
    876 end;
    877 
    878 procedure THelpDlg.Prepare(sbPos: integer = 0);
     875  SmartUpdateContent(True)
     876end;
     877
     878procedure THelpDlg.Prepare(sbPos: Integer = 0);
    879879var
    880   i, j, Special, Domain, Headline, TerrType, TerrSubType: integer;
    881   s: string;
    882   ps: pchar;
     880  I, J, Special, Domain, Headline, TerrType, TerrSubType: Integer;
     881  S: string;
     882  ps: PChar;
    883883  List: THyperText;
    884884  CheckSeeAlso: Boolean;
    885885
    886   procedure AddAdvance(i: integer);
    887   begin
    888     MainText.AddLine(Phrases.Lookup('ADVANCES', i), pkAdvIcon, i,
    889       hkAdv + hkCrossLink, i);
    890   end;
    891 
    892   procedure AddPreqAdv(i: integer);
    893   begin
    894     MainText.AddLine(Phrases.Lookup('ADVANCES', i), pkAdvIcon_AsPreq, i,
    895       hkAdv + hkCrossLink, i);
    896   end;
    897 
    898   procedure AddImprovement(i: integer);
    899   begin
    900     MainText.AddLine(Phrases.Lookup('IMPROVEMENTS', i), pkSmallIcon, i,
    901       hkImp + hkCrossLink, i);
    902   end;
    903 
    904   procedure AddPreqImp(i: integer);
    905   begin
    906     MainText.AddLine(Phrases.Lookup('IMPROVEMENTS', i), pkSmallIcon_AsPreq, i,
    907       hkImp + hkCrossLink, i);
    908   end;
    909 
    910   procedure AddTerrain(i: integer);
     886  procedure AddAdvance(I: Integer);
     887  begin
     888    MainText.AddLine(Phrases.Lookup('ADVANCES', I), pkAdvIcon, I,
     889      hkAdv + hkCrossLink, I);
     890  end;
     891
     892  procedure AddPreqAdv(I: Integer);
     893  begin
     894    MainText.AddLine(Phrases.Lookup('ADVANCES', I), pkAdvIcon_AsPreq, I,
     895      hkAdv + hkCrossLink, I);
     896  end;
     897
     898  procedure AddImprovement(I: Integer);
     899  begin
     900    MainText.AddLine(Phrases.Lookup('IMPROVEMENTS', I), pkSmallIcon, I,
     901      hkImp + hkCrossLink, I);
     902  end;
     903
     904  procedure AddPreqImp(I: Integer);
     905  begin
     906    MainText.AddLine(Phrases.Lookup('IMPROVEMENTS', I), pkSmallIcon_AsPreq, I,
     907      hkImp + hkCrossLink, I);
     908  end;
     909
     910  procedure AddTerrain(I: Integer);
    911911  begin
    912912    if MainText.Count > 1 then
     
    914914      MainText.LineFeed;
    915915    end;
    916     MainText.AddLine(Phrases.Lookup('TERRAIN', i), pkTer, i, hkTer, i);
    917   end;
    918 
    919   procedure AddFeature(i: integer);
    920   begin
    921     MainText.AddLine(Phrases.Lookup('FEATURES', i), pkFeature, i,
    922       hkFeature + hkCrossLink, i);
    923   end;
    924 
    925   procedure AddModel(i: integer);
     916    MainText.AddLine(Phrases.Lookup('TERRAIN', I), pkTer, I, hkTer, I);
     917  end;
     918
     919  procedure AddFeature(I: Integer);
     920  begin
     921    MainText.AddLine(Phrases.Lookup('FEATURES', I), pkFeature, I,
     922      hkFeature + hkCrossLink, I);
     923  end;
     924
     925  procedure AddModel(I: Integer);
    926926  var
    927     pix: integer;
     927    pix: Integer;
    928928    Name: string;
    929929  begin
    930930    if MainText.Count > 1 then
    931931      MainText.LineFeed;
    932     FindStdModelPicture(SpecialModelPictureCode[i], pix, Name);
    933     MainText.AddLine(Name, pkModel, pix, hkModel + hkCrossLink, i)
     932    FindStdModelPicture(SpecialModelPictureCode[I], pix, Name);
     933    MainText.AddLine(Name, pkModel, pix, hkModel + hkCrossLink, I)
    934934  end;
    935935
    936936  procedure AddStandardBlock(Item: string);
    937937  var
    938     i: integer;
     938    I: Integer;
    939939  begin
    940940    with MainText do
     
    947947      else if Item = 'TECHFORMULA' then
    948948      begin
    949         i := Difficulty;
    950         if i = 0 then
    951           i := 2;
    952         AddLine(Format(HelpText.Lookup('TECHFORMULA'), [TechFormula_M[i],
    953           TechFormula_D[i]]))
     949        I := Difficulty;
     950        if I = 0 then
     951          I := 2;
     952        AddLine(Format(HelpText.Lookup('TECHFORMULA'), [TechFormula_M[I],
     953          TechFormula_D[I]]))
    954954      end
    955955      else if Item = 'EXPERIENCE' then
    956         for i := 0 to nExp - 1 do
    957           AddLine(Phrases.Lookup('EXPERIENCE', i), pkExp, i)
     956        for I := 0 to nExp - 1 do
     957          AddLine(Phrases.Lookup('EXPERIENCE', I), pkExp, I)
    958958      else if Item = 'MODERN' then
    959         for i := 1 to 3 do
     959        for I := 1 to 3 do
    960960        begin
    961961          LineFeed;
    962           AddLine(Phrases.Lookup('TERRAIN', 3 * 12 + i), pkTer, 3 * 12 + i);
     962          AddLine(Phrases.Lookup('TERRAIN', 3 * 12 + I), pkTer, 3 * 12 + I);
    963963        end
    964964      else if Item = 'SAVED' then
    965965        AddLine(DataDir + 'Saved', pkNormal)
    966966      else if Item = 'AITSTAT' then
    967         for i := 0 to 3 do
    968           AddLine(Phrases2.Lookup('AITSTAT', i), pkAITStat, i)
     967        for I := 0 to 3 do
     968          AddLine(Phrases2.Lookup('AITSTAT', I), pkAITStat, I)
    969969    end
    970970  end;
    971971
    972   procedure DecodeItem(s: string; var Category, Index: Integer);
     972  procedure DecodeItem(S: string; var Category, Index: Integer);
    973973  var
    974     i: Integer;
    975   begin
    976     if (Length(s) > 0) and (s[1] = ':') then begin
     974    I: Integer;
     975  begin
     976    if (Length(S) > 0) and (S[1] = ':') then begin
    977977      Category := hkMisc;
    978978      Index := 0;
    979       for i := 3 to length(s) do
    980         Index := Index * 10 + Ord(s[i]) - 48;
    981       case s[2] of
     979      for I := 3 to Length(S) do
     980        Index := Index * 10 + Ord(S[I]) - 48;
     981      case S[2] of
    982982        'A': Category := hkAdv;
    983983        'B': Category := hkImp;
     
    994994    end else begin
    995995      Category := hkText;
    996       Index := HelpText.Gethandle(Copy(s, 1, 255));
     996      Index := HelpText.Gethandle(Copy(S, 1, 255));
    997997    end;
    998998  end;
    999999
    1000   procedure AddTextual(s: string);
     1000  procedure AddTextual(S: string);
    10011001  var
    1002     i: Integer;
    1003     p: Integer;
    1004     l: Integer;
     1002    I: Integer;
     1003    P: Integer;
     1004    L: Integer;
    10051005    ofs: Integer;
    10061006    CurrentFormat: Integer;
     
    10151015    RightMargin := InnerWidth - 16 - GetSystemMetrics(SM_CXVSCROLL);
    10161016    FollowFormat := pkNormal;
    1017     while s <> '' do
     1017    while S <> '' do
    10181018    begin
    10191019      Picpix := 0;
    10201020      LinkCategory := 0;
    10211021      LinkIndex := 0;
    1022       if s[1] = '$' then
     1022      if S[1] = '$' then
    10231023      begin // window caption
    1024         p := 1;
     1024        P := 1;
    10251025        repeat
    1026           inc(p)
    1027         until (p > Length(s)) or (s[p] = '\');
    1028         Caption := Copy(s, 2, p - 2);
    1029         Delete(s, 1, p);
     1026          Inc(P);
     1027        until (P > Length(S)) or (S[P] = '\');
     1028        Caption := Copy(S, 2, P - 2);
     1029        Delete(S, 1, P);
    10301030      end
    1031       else if s[1] = '&' then
     1031      else if S[1] = '&' then
    10321032      begin // standard block
    1033         p := 1;
     1033        P := 1;
    10341034        repeat
    1035           inc(p)
    1036         until (p > Length(s)) or (s[p] = '\');
    1037         AddStandardBlock(Copy(s, 2, p - 2));
    1038         Delete(s, 1, p);
     1035          Inc(P);
     1036        until (P > Length(S)) or (S[P] = '\');
     1037        AddStandardBlock(Copy(S, 2, P - 2));
     1038        Delete(S, 1, P);
    10391039      end
    1040       else if s[1] = '@' then
     1040      else if S[1] = '@' then
    10411041      begin // image
    1042         if (Length(s) >= 2) and (s[2] = '@') then
     1042        if (Length(S) >= 2) and (S[2] = '@') then
    10431043        begin // generate from icon
    10441044          Picpix := 0;
    1045           p := 3;
    1046           while (p <= Length(s)) and (s[p] <> '\') do
     1045          P := 3;
     1046          while (P <= Length(S)) and (S[P] <> '\') do
    10471047          begin
    1048             Picpix := Picpix * 10 + Ord(s[p]) - 48;
    1049             inc(p)
     1048            Picpix := Picpix * 10 + Ord(S[P]) - 48;
     1049            Inc(P);
    10501050          end;
    10511051          if (Picpix < 0) or (Picpix >= nImp) then
     
    10571057        else
    10581058        begin // external image
    1059           p := 1;
     1059          P := 1;
    10601060          repeat
    1061             Inc(p)
    1062           until (p > Length(s)) or (s[p] = '\');
     1061            Inc(P);
     1062          until (P > Length(S)) or (S[P] = '\');
    10631063          if LoadGraphicFile(ExtPic, LocalizedFilePath('Help' +
    1064             DirectorySeparator + Copy(s, 2, p - 2)) + '.png') then
     1064            DirectorySeparator + Copy(S, 2, P - 2)) + '.png') then
    10651065          begin
    10661066            MainText.AddLine('', pkExternal);
    1067             for i := 0 to (ExtPic.Height - 12) div 24 do
     1067            for I := 0 to (ExtPic.Height - 12) div 24 do
    10681068              MainText.LineFeed;
    10691069          end;
    10701070        end;
    1071         Delete(s, 1, p);
     1071        Delete(S, 1, P);
    10721072      end
    10731073      else
    10741074      begin
    1075         case s[1] of
     1075        case S[1] of
    10761076          ':', ';':
    10771077            begin // link
    1078               p := 1;
     1078              P := 1;
    10791079              repeat
    1080                 inc(p)
    1081               until (p > Length(s)) or (s[p] = '\') or (s[p] = ' ');
    1082               DecodeItem(Copy(s, 2, p - 2), LinkCategory, LinkIndex);
     1080                Inc(P)
     1081              until (P > Length(S)) or (S[P] = '\') or (S[P] = ' ');
     1082              DecodeItem(Copy(S, 2, P - 2), LinkCategory, LinkIndex);
    10831083              CurrentFormat := 0;
    10841084              if (LinkCategory <> hkText) and (LinkIndex < 200) then
     
    11121112                    end;
    11131113                end;
    1114               if s[1] = ':' then
     1114              if S[1] = ':' then
    11151115                LinkCategory := LinkCategory + hkCrossLink;
    1116               if (p > Length(s)) or (s[p] = ' ') then
    1117                 Delete(s, 1, p)
     1116              if (P > Length(S)) or (S[P] = ' ') then
     1117                Delete(S, 1, P)
    11181118              else
    1119                 Delete(s, 1, p - 1)
     1119                Delete(S, 1, P - 1)
    11201120            end;
    11211121          '!': // highlited
    1122             if (Length(s) >= 2) and (s[2] = '!') then
     1122            if (Length(S) >= 2) and (S[2] = '!') then
    11231123            begin
    11241124              if MainText.Count > 1 then
     
    11261126              FollowFormat := pkCaption;
    11271127              CurrentFormat := pkCaption;
    1128               Delete(s, 1, 2);
     1128              Delete(S, 1, 2);
    11291129            end
    11301130            else
     
    11321132              FollowFormat := pkSection;
    11331133              CurrentFormat := pkSection;
    1134               Delete(s, 1, 1);
     1134              Delete(S, 1, 1);
    11351135            end;
    11361136          '-':
     
    11381138              FollowFormat := pkNormal_Dot;
    11391139              CurrentFormat := pkDot;
    1140               Delete(s, 1, 1);
     1140              Delete(S, 1, 1);
    11411141            end;
    11421142        else
     
    11471147        else
    11481148          ofs := 8;
    1149         p := 0;
     1149        P := 0;
    11501150        repeat
    11511151          repeat
    1152             Inc(p)
    1153           until (p > Length(s)) or (s[p] = ' ') or (s[p] = '\');
    1154           if (BiColorTextWidth(OffScreen.Canvas, Copy(s, 1, p - 1)) <=
     1152            Inc(P)
     1153          until (P > Length(S)) or (S[P] = ' ') or (S[P] = '\');
     1154          if (BiColorTextWidth(OffScreen.Canvas, Copy(S, 1, P - 1)) <=
    11551155            RightMargin - ofs) then
    1156             l := p - 1
     1156            L := P - 1
    11571157          else
    11581158            Break;
    1159         until (p >= Length(s)) or (s[l + 1] = '\');
    1160         Text := Copy(s, 1, l);
    1161         if LinkCategory and $3f = hkInternet then begin
     1159        until (P >= Length(S)) or (S[L + 1] = '\');
     1160        Text := Copy(S, 1, L);
     1161        if LinkCategory and $3F = hkInternet then begin
    11621162          if LinkIndex = 1 then Text := AITemplateManual
    11631163          else if LinkIndex = 2 then Text := CevoHomepageShort
     
    11661166        MainText.AddLine(Text, CurrentFormat, Picpix, LinkCategory,
    11671167          LinkIndex);
    1168         if (l < Length(s)) and (s[l + 1] = '\') then
     1168        if (L < Length(S)) and (S[L + 1] = '\') then
    11691169          FollowFormat := pkNormal;
    1170         Delete(s, 1, l + 1);
     1170        Delete(S, 1, L + 1);
    11711171      end
    11721172    end
     
    11781178  end;
    11791179
    1180   procedure AddModelText(i: Integer);
     1180  procedure AddModelText(I: Integer);
    11811181  var
    11821182    pix: Integer;
    1183     s: string;
     1183    S: string;
    11841184  begin
    11851185    with MainText do begin
     
    11881188        LineFeed;
    11891189      end;
    1190       FindStdModelPicture(SpecialModelPictureCode[i], pix, s);
    1191       AddLine(s, pkSection);
    1192       AddLine(Format(HelpText.Lookup('STRENGTH'), [SpecialModel[i].Attack,
    1193         SpecialModel[i].Defense]), pkNormal_64);
     1190      FindStdModelPicture(SpecialModelPictureCode[I], pix, S);
     1191      AddLine(S, pkSection);
     1192      AddLine(Format(HelpText.Lookup('STRENGTH'), [SpecialModel[I].Attack,
     1193        SpecialModel[I].Defense]), pkNormal_64);
    11941194      AddLine(Format(HelpText.Lookup('SPEED'),
    1195         [MovementToString(SpecialModel[i].Speed)]), pkModel, pix);
     1195        [MovementToString(SpecialModel[I].Speed)]), pkModel, pix);
    11961196      if Difficulty = 0 then
    1197         AddLine(Format(HelpText.Lookup('BUILDCOST'), [SpecialModel[i].Cost]),
     1197        AddLine(Format(HelpText.Lookup('BUILDCOST'), [SpecialModel[I].Cost]),
    11981198          pkNormal_64)
    11991199      else
    12001200        AddLine(Format(HelpText.Lookup('BUILDCOST'),
    1201           [SpecialModel[i].Cost * BuildCostMod[Difficulty] div 12]),
     1201          [SpecialModel[I].Cost * BuildCostMod[Difficulty] div 12]),
    12021202          pkNormal_64);
    1203       s := HelpText.LookupByHandle(hSPECIALMODEL, i);
    1204       if (s <> '') and (s <> '*') then
    1205         AddTextual(s);
    1206       if SpecialModelPreq[i] >= 0 then
    1207         AddPreqAdv(SpecialModelPreq[i])
    1208       else if SpecialModelPreq[i] = preLighthouse then
     1203      S := HelpText.LookupByHandle(hSPECIALMODEL, I);
     1204      if (S <> '') and (S <> '*') then
     1205        AddTextual(S);
     1206      if SpecialModelPreq[I] >= 0 then
     1207        AddPreqAdv(SpecialModelPreq[I])
     1208      else if SpecialModelPreq[I] = preLighthouse then
    12091209        AddPreqImp(woLighthouse)
    1210       else if SpecialModelPreq[i] = preBuilder then
     1210      else if SpecialModelPreq[I] = preBuilder then
    12111211        AddPreqImp(woPyramids)
    1212       else if SpecialModelPreq[i] = preLeo then
     1212      else if SpecialModelPreq[I] = preLeo then
    12131213        AddPreqImp(woLeo);
    1214       if SpecialModelPreq[i] <> preNone then
     1214      if SpecialModelPreq[I] <> preNone then
    12151215        MainText[Count - 1] := Format(HelpText.Lookup('REQUIRED'),
    12161216          [MainText[Count - 1]]);
     
    12201220  procedure AddJobList;
    12211221  var
    1222     i, JobCost: Integer;
     1222    I, JobCost: Integer;
    12231223  begin
    12241224    with MainText do begin
    1225       for i := 0 to nJobHelp - 1 do begin
    1226         if i > 0 then begin
     1225      for I := 0 to nJobHelp - 1 do begin
     1226        if I > 0 then begin
    12271227          LineFeed;
    12281228          LineFeed;
    12291229        end;
    1230         AddLine(Phrases.Lookup('JOBRESULT', JobHelp[i]), pkSection);
     1230        AddLine(Phrases.Lookup('JOBRESULT', JobHelp[I]), pkSection);
    12311231        AddLine;
    1232         AddLine('', pkTerImp, i);
     1232        AddLine('', pkTerImp, I);
    12331233        AddLine;
    1234         AddTextual(HelpText.LookupByHandle(hJOBHELP, i));
     1234        AddTextual(HelpText.LookupByHandle(hJOBHELP, I));
    12351235        JobCost := -1;
    1236         case JobHelp[i] of
     1236        case JobHelp[I] of
    12371237          jCanal: JobCost := CanalWork;
    12381238          jFort: JobCost := FortWork;
     
    12441244        else
    12451245          AddTextual(HelpText.Lookup('JOBCOSTVAR'));
    1246         if JobPreq[JobHelp[i]] <> preNone then begin
    1247           AddPreqAdv(JobPreq[JobHelp[i]]);
     1246        if JobPreq[JobHelp[I]] <> preNone then begin
     1247          AddPreqAdv(JobPreq[JobHelp[I]]);
    12481248          MainText[Count - 1] := Format(HelpText.Lookup('REQUIRED'),
    12491249            [MainText[Count - 1]]);
     
    12551255  procedure AddGraphicCredits;
    12561256  var
    1257     i: Integer;
    1258     s: string;
     1257    I: Integer;
     1258    S: string;
    12591259    sr: TSearchRec;
    12601260    List, Plus: TStringList;
     
    12711271
    12721272    List.Sort;
    1273     i := 1;
    1274     while i < List.Count do
    1275       if List[i] = List[i - 1] then
    1276         List.Delete(i)
     1273    I := 1;
     1274    while I < List.Count do
     1275      if List[I] = List[I - 1] then
     1276        List.Delete(I)
    12771277      else
    1278         Inc(i);
    1279 
    1280     for i := 0 to List.Count - 1 do begin
    1281       s := List[i];
    1282       while BiColorTextWidth(OffScreen.Canvas, s) > InnerWidth - 16 -
     1278        Inc(I);
     1279
     1280    for I := 0 to List.Count - 1 do begin
     1281      S := List[I];
     1282      while BiColorTextWidth(OffScreen.Canvas, S) > InnerWidth - 16 -
    12831283        GetSystemMetrics(SM_CXVSCROLL) do
    1284         Delete(s, length(s), 1);
    1285       MainText.AddLine(s);
     1284        Delete(S, Length(S), 1);
     1285      MainText.AddLine(S);
    12861286    end;
    12871287    FreeAndNil(List);
     
    12901290  procedure AddSoundCredits;
    12911291  var
    1292     i: Integer;
    1293     s: string;
     1292    I: Integer;
     1293    S: string;
    12941294    List: TStringList;
    12951295  begin
    12961296    List := TStringList.Create;
    12971297    List.LoadFromFile(GetSoundsDir + DirectorySeparator + 'sound.credits.txt');
    1298     for i := 0 to List.Count - 1 do begin
    1299       s := List[i];
    1300       while BiColorTextWidth(OffScreen.Canvas, s) > InnerWidth - 16 -
     1298    for I := 0 to List.Count - 1 do begin
     1299      S := List[I];
     1300      while BiColorTextWidth(OffScreen.Canvas, S) > InnerWidth - 16 -
    13011301        GetSystemMetrics(SM_CXVSCROLL) do
    1302         Delete(s, length(s), 1);
    1303       MainText.AddLine(s);
     1302        Delete(S, Length(S), 1);
     1303      MainText.AddLine(S);
    13041304    end;
    13051305    FreeAndNil(List);
     
    13491349                  hkAdv, 200);
    13501350                LineFeed;
    1351                 FindStdModelPicture(SpecialModelPictureCode[6], i, s);
    1352                 AddLine(HelpText.Lookup('HELPTITLE_MODELLIST'), pkModel, i,
     1351                FindStdModelPicture(SpecialModelPictureCode[6], I, S);
     1352                AddLine(HelpText.Lookup('HELPTITLE_MODELLIST'), pkModel, I,
    13531353                  hkModel, 0);
    13541354                LineFeed;
     
    14021402              begin
    14031403                Caption := HelpText.Lookup('HELPTITLE_GOVLIST');
    1404                 for i := 1 to nGov do
     1404                for I := 1 to nGov do
    14051405                begin
    1406                   AddLine(Phrases.Lookup('GOVERNMENT', i mod nGov), pkSection);
     1406                  AddLine(Phrases.Lookup('GOVERNMENT', I mod nGov), pkSection);
    14071407                  LineFeed;
    1408                   if i = nGov then
     1408                  if I = nGov then
    14091409                    AddLine('', pkBigIcon, 7 * SystemIconLines + imPalace)
    14101410                  else
    1411                     AddLine('', pkBigIcon, i + 6);
     1411                    AddLine('', pkBigIcon, I + 6);
    14121412                  LineFeed;
    1413                   AddTextual(HelpText.LookupByHandle(hGOVHELP, i mod nGov));
    1414                   if i mod nGov >= 2 then
     1413                  AddTextual(HelpText.LookupByHandle(hGOVHELP, I mod nGov));
     1414                  if I mod nGov >= 2 then
    14151415                  begin
    1416                     AddPreqAdv(GovPreq[i mod nGov]);
     1416                    AddPreqAdv(GovPreq[I mod nGov]);
    14171417                    MainText[Count - 1] := Format(HelpText.Lookup('REQUIRED'),
    14181418                      [MainText[Count - 1]]);
    14191419                  end;
    1420                   if i < nGov then
     1420                  if I < nGov then
    14211421                  begin
    14221422                    LineFeed;
     
    14401440          List := THyperText.Create;
    14411441          List.OwnsObjects := True;
    1442           for j := 0 to 3 do
     1442          for J := 0 to 3 do
    14431443          begin
    1444             if j > 0 then
     1444            if J > 0 then
    14451445            begin
    14461446              LineFeed;
    14471447              LineFeed;
    14481448            end;
    1449             AddLine(HelpText.Lookup('TECHAGE', j), pkSection);
    1450             if j = 1 then
     1449            AddLine(HelpText.Lookup('TECHAGE', J), pkSection);
     1450            if J = 1 then
    14511451              AddLine(Phrases.Lookup('ADVANCES', adScience) + ' ' +
    14521452                HelpText.Lookup('BASETECH'), pkAdvIcon, adScience, hkAdv,
    14531453                adScience);
    1454             if j = 2 then
     1454            if J = 2 then
    14551455              AddLine(Phrases.Lookup('ADVANCES', adMassProduction) + ' ' +
    14561456                HelpText.Lookup('BASETECH'), pkAdvIcon, adMassProduction, hkAdv,
    14571457                adMassProduction);
    14581458            List.Clear;
    1459             for i := 0 to nAdv - 1 do
    1460               if (i <> adScience) and (i <> adMassProduction) and
    1461                 (AdvValue[i] div 1000 = j) then
    1462                 List.AddLine(Phrases.Lookup('ADVANCES', i), pkAdvIcon, i,
    1463                   hkAdv, i);
     1459            for I := 0 to nAdv - 1 do
     1460              if (I <> adScience) and (I <> adMassProduction) and
     1461                (AdvValue[I] div 1000 = J) then
     1462                List.AddLine(Phrases.Lookup('ADVANCES', I), pkAdvIcon, I,
     1463                  hkAdv, I);
    14641464            List.Sort;
    14651465            AppendList(List);
     
    14871487          else
    14881488            NextSection('PREREQ');
    1489           for i := 0 to 2 do
    1490             if AdvPreq[no, i] <> preNone then
    1491               AddPreqAdv(AdvPreq[no, i]);
     1489          for I := 0 to 2 do
     1490            if AdvPreq[no, I] <> preNone then
     1491              AddPreqAdv(AdvPreq[no, I]);
    14921492          NextSection('GOVALLOW');
    1493           for i := 2 to nGov - 1 do
    1494             if GovPreq[i] = no then
    1495               AddLine(Phrases.Lookup('GOVERNMENT', i), pkGov, i,
     1493          for I := 2 to nGov - 1 do
     1494            if GovPreq[I] = no then
     1495              AddLine(Phrases.Lookup('GOVERNMENT', I), pkGov, I,
    14961496                hkMisc + hkCrossLink, miscGovList);
    14971497          NextSection('BUILDALLOW');
    1498           for i := 0 to nWonder - 1 do
    1499             if Imp[i].Preq = no then
    1500               AddImprovement(i);
    1501           for i := nWonder to nImp - 1 do
    1502             if (Imp[i].Preq = no) and (Imp[i].Kind <> ikCommon) then
    1503               AddImprovement(i);
    1504           for i := nWonder to nImp - 1 do
    1505             if (Imp[i].Preq = no) and (Imp[i].Kind = ikCommon) then
    1506               AddImprovement(i);
     1498          for I := 0 to nWonder - 1 do
     1499            if Imp[I].Preq = no then
     1500              AddImprovement(I);
     1501          for I := nWonder to nImp - 1 do
     1502            if (Imp[I].Preq = no) and (Imp[I].Kind <> ikCommon) then
     1503              AddImprovement(I);
     1504          for I := nWonder to nImp - 1 do
     1505            if (Imp[I].Preq = no) and (Imp[I].Kind = ikCommon) then
     1506              AddImprovement(I);
    15071507          NextSection('MODELALLOW');
    1508           for i := 0 to nSpecialModel - 1 do
    1509             if SpecialModelPreq[i] = no then
    1510               AddModel(i);
     1508          for I := 0 to nSpecialModel - 1 do
     1509            if SpecialModelPreq[I] = no then
     1510              AddModel(I);
    15111511          NextSection('FEATALLOW');
    1512           for i := 0 to nFeature - 1 do
    1513             if Feature[i].Preq = no then
    1514               AddFeature(i);
     1512          for I := 0 to nFeature - 1 do
     1513            if Feature[I].Preq = no then
     1514              AddFeature(I);
    15151515          NextSection('FOLLOWADV');
    1516           for i := 0 to nAdv - 1 do
    1517             if (AdvPreq[i, 0] = no) or (AdvPreq[i, 1] = no) or
    1518               (AdvPreq[i, 2] = no) then
    1519               AddAdvance(i);
     1516          for I := 0 to nAdv - 1 do
     1517            if (AdvPreq[I, 0] = no) or (AdvPreq[I, 1] = no) or
     1518              (AdvPreq[I, 2] = no) then
     1519              AddAdvance(I);
    15201520          NextSection('UPGRADEALLOW');
    15211521          for Domain := 0 to nDomains - 1 do
    1522             for i := 1 to nUpgrade - 1 do
    1523               if upgrade[Domain, i].Preq = no then
     1522            for I := 1 to nUpgrade - 1 do
     1523              if upgrade[Domain, I].Preq = no then
    15241524              begin
    1525                 if upgrade[Domain, i].Strength > 0 then
     1525                if upgrade[Domain, I].Strength > 0 then
    15261526                  AddLine(Format(HelpText.Lookup('STRENGTHUP'),
    15271527                    [Phrases.Lookup('DOMAIN', Domain), upgrade[Domain,
    1528                     i].Strength]), pkDomain, Domain);
    1529                 if upgrade[Domain, i].Trans > 0 then
     1528                    I].Strength]), pkDomain, Domain);
     1529                if upgrade[Domain, I].Trans > 0 then
    15301530                  AddLine(Format(HelpText.Lookup('TRANSUP'),
    1531                     [Phrases.Lookup('DOMAIN', Domain), upgrade[Domain, i].Trans]
     1531                    [Phrases.Lookup('DOMAIN', Domain), upgrade[Domain, I].Trans]
    15321532                    ), pkDomain, Domain);
    15331533                if no in FutureTech then
    15341534                  AddLine(Format(HelpText.Lookup('COSTUP'),
    1535                     [upgrade[Domain, i].Cost]), pkNormal_Dot)
     1535                    [upgrade[Domain, I].Cost]), pkNormal_Dot)
    15361536                else
    15371537                  AddLine(Format(HelpText.Lookup('COSTMIN'),
    1538                     [upgrade[Domain, i].Cost]), pkNormal_Dot)
     1538                    [upgrade[Domain, I].Cost]), pkNormal_Dot)
    15391539              end;
    15401540          NextSection('EXPIRATION');
    1541           for i := 0 to nWonder - 1 do
    1542             if (Imp[i].Preq <> preNA) and (Imp[i].Expiration = no) then
    1543               AddImprovement(i);
     1541          for I := 0 to nWonder - 1 do
     1542            if (Imp[I].Preq <> preNA) and (Imp[I].Expiration = no) then
     1543              AddImprovement(I);
    15441544          NextSection('ADVEFFECT');
    1545           s := HelpText.LookupByHandle(hADVHELP, no);
    1546           if s <> '*' then
    1547             AddTextual(s);
     1545          S := HelpText.LookupByHandle(hADVHELP, no);
     1546          if S <> '*' then
     1547            AddTextual(S);
    15481548          NextSection('SEEALSO');
    1549           CheckSeeAlso := true
     1549          CheckSeeAlso := True
    15501550        end;
    15511551
     
    15571557          List := THyperText.Create;
    15581558          List.OwnsObjects := True;
    1559           for i := nWonder to nImp - 1 do
    1560             if (i <> imTrGoods) and (Imp[i].Preq <> preNA) and
    1561               (Imp[i].Kind = ikCommon) then
    1562               List.AddLine(Phrases.Lookup('IMPROVEMENTS', i), pkSmallIcon,
    1563                 i, hkImp, i);
     1559          for I := nWonder to nImp - 1 do
     1560            if (I <> imTrGoods) and (Imp[I].Preq <> preNA) and
     1561              (Imp[I].Kind = ikCommon) then
     1562              List.AddLine(Phrases.Lookup('IMPROVEMENTS', I), pkSmallIcon,
     1563                I, hkImp, I);
    15641564          List.Sort;
    15651565          AppendList(List);
     
    15701570          Caption := HelpText.Lookup('HELPTITLE_UNIQUELIST');
    15711571          // AddLine(HelpText.Lookup('HELPTITLE_UNIQUELIST'),pkSection);
    1572           for i := nWonder to nImp - 1 do
    1573             if (Imp[i].Preq <> preNA) and
    1574               ((Imp[i].Kind = ikNatLocal) or (Imp[i].Kind = ikNatGlobal)) then
    1575               AddLine(Phrases.Lookup('IMPROVEMENTS', i), pkSmallIcon, i,
    1576                 hkImp, i);
     1572          for I := nWonder to nImp - 1 do
     1573            if (Imp[I].Preq <> preNA) and
     1574              ((Imp[I].Kind = ikNatLocal) or (Imp[I].Kind = ikNatGlobal)) then
     1575              AddLine(Phrases.Lookup('IMPROVEMENTS', I), pkSmallIcon, I,
     1576                hkImp, I);
    15771577          { LineFeed;
    15781578            LineFeed;
    15791579            AddLine(HelpText.Lookup('HELPTITLE_SHIPPARTLIST'),pkSection);
    1580             for i:= nWonder to nImp-1 do
    1581             if (Imp[i].Preq<>preNA) and (Imp[i].Kind=ikShipPart) then
    1582             AddLine(Phrases.Lookup('IMPROVEMENTS',i),pkSmallIcon,i,hkImp,i); }
     1580            for I:= nWonder to nImp-1 do
     1581            if (Imp[I].Preq<>preNA) and (Imp[I].Kind=ikShipPart) then
     1582            AddLine(Phrases.Lookup('IMPROVEMENTS',I),pkSmallIcon,I,hkImp,I); }
    15831583        end
    15841584        else if no = 202 then
     
    15861586          Caption := HelpText.Lookup('HELPTITLE_WONDERLIST');
    15871587          // AddLine(HelpText.Lookup('HELPTITLE_WONDERLIST'),pkSection);
    1588           for i := 0 to nWonder - 1 do
    1589             if Imp[i].Preq <> preNA then
    1590               AddLine(Phrases.Lookup('IMPROVEMENTS', i), pkSmallIcon, i,
    1591                 hkImp, i);
     1588          for I := 0 to nWonder - 1 do
     1589            if Imp[I].Preq <> preNA then
     1590              AddLine(Phrases.Lookup('IMPROVEMENTS', I), pkSmallIcon, I,
     1591                hkImp, I);
    15921592        end
    15931593        else
     
    16271627          NextSection('COSTS');
    16281628          if Difficulty = 0 then
    1629             s := Format(HelpText.Lookup('BUILDCOST'), [Imp[no].Cost])
     1629            S := Format(HelpText.Lookup('BUILDCOST'), [Imp[no].Cost])
    16301630          else
    1631             s := Format(HelpText.Lookup('BUILDCOST'),
     1631            S := Format(HelpText.Lookup('BUILDCOST'),
    16321632              [Imp[no].Cost * BuildCostMod[Difficulty] div 12]);
    1633           AddLine(s);
     1633          AddLine(S);
    16341634          if Imp[no].Maint > 0 then
    16351635            AddLine(Format(HelpText.Lookup('MAINTCOST'), [Imp[no].Maint]));
    1636           j := 0;
    1637           for i := 0 to nImpReplacement - 1 do
    1638             if ImpReplacement[i].NewImp = no then
    1639             begin
    1640               if j = 0 then
     1636          J := 0;
     1637          for I := 0 to nImpReplacement - 1 do
     1638            if ImpReplacement[I].NewImp = no then
     1639            begin
     1640              if J = 0 then
    16411641              begin
    16421642                NextSection('REPLACE');
    16431643                AddItem('REPLACETEXT');
    1644                 j := 1;
     1644                J := 1;
    16451645              end;
    1646               AddImprovement(ImpReplacement[i].OldImp);
     1646              AddImprovement(ImpReplacement[I].OldImp);
    16471647            end;
    16481648          if Imp[no].Kind = ikShipPart then
     
    16501650            LineFeed;
    16511651            if no = imShipComp then
    1652               i := 1
     1652              I := 1
    16531653            else if no = imShipPow then
    1654               i := 2
     1654              I := 2
    16551655            else { if no=imShipHab then }
    1656               i := 3;
     1656              I := 3;
    16571657            AddLine(Format(HelpText.Lookup('RAREREQUIRED'),
    1658               [Phrases.Lookup('TERRAIN', 3 * 12 + i)]), pkTer, 3 * 12 + i);
     1658              [Phrases.Lookup('TERRAIN', 3 * 12 + I)]), pkTer, 3 * 12 + I);
    16591659          end;
    16601660          if (no < nWonder) and (Imp[no].Expiration >= 0) then
    16611661          begin
    16621662            NextSection('EXPIRATION');
    1663             s := Format(HelpText.Lookup('EXPWITH'),
     1663            S := Format(HelpText.Lookup('EXPWITH'),
    16641664              [Phrases.Lookup('ADVANCES', Imp[no].Expiration)]);
    16651665            if no = woPyramids then
    1666               s := s + ' ' + HelpText.Lookup('EXPSLAVE');
    1667             AddTextual(s);
     1666              S := S + ' ' + HelpText.Lookup('EXPSLAVE');
     1667            AddTextual(S);
    16681668          end;
    16691669          NextSection('SEEALSO');
    16701670          if (no < nWonder) and (Imp[no].Expiration >= 0) then
    16711671            AddImprovement(woEiffel);
    1672           for i := 0 to nImpReplacement - 1 do
    1673             if ImpReplacement[i].OldImp = no then
    1674               AddImprovement(ImpReplacement[i].NewImp);
     1672          for I := 0 to nImpReplacement - 1 do
     1673            if ImpReplacement[I].OldImp = no then
     1674              AddImprovement(ImpReplacement[I].NewImp);
    16751675          if no = imSupermarket then
    16761676            AddLine(HelpText.Lookup('HELPTITLE_JOBLIST'), pkNormal, 0,
    16771677              hkMisc + hkCrossLink, miscJobList);
    1678           CheckSeeAlso := true;
     1678          CheckSeeAlso := True;
    16791679        end;
    16801680
     
    16841684          Caption := HelpText.Lookup('HELPTITLE_TERLIST');
    16851685          // AddLine(HelpText.Lookup('HELPTITLE_TERLIST'),pkSection);
    1686           for i := 0 to nTerrainHelp - 1 do
    1687             AddTerrain(TerrainHelp[i]);
     1686          for I := 0 to nTerrainHelp - 1 do
     1687            AddTerrain(TerrainHelp[I]);
    16881688        end
    16891689        else
     
    17461746            begin
    17471747              LineFeed;
    1748               i := TransTerrain;
    1749               if (TerrType <> fGrass) and (i <> fGrass) then
    1750                 i := i + TerrSubType * 12;
     1748              I := TransTerrain;
     1749              if (TerrType <> fGrass) and (I <> fGrass) then
     1750                I := I + TerrSubType * 12;
    17511751              // trafo to same Special resource group
    17521752              AddLine(Format(HelpText.Lookup('TRAFO'),
    1753                 [Phrases.Lookup('TERRAIN', i)]), pkTer, i,
    1754                 hkTer + hkCrossLink, i);
     1753                [Phrases.Lookup('TERRAIN', I)]), pkTer, I,
     1754                hkTer + hkCrossLink, I);
    17551755              if no = fSwamp + 12 then
    17561756              begin
     
    17601760                  TransTerrain + 24, hkTer + hkCrossLink, TransTerrain + 24);
    17611761              end
    1762               else if i = fGrass then
     1762              else if I = fGrass then
    17631763              begin
    17641764                LineFeed;
     
    17901790                  AddLine(Phrases.Lookup('TERRAIN', no + Special * 12), pkTer,
    17911791                    no + Special * 12);
    1792                   i := FoodRes[Special] - FoodRes[0];
    1793                   if i <> 0 then
     1792                  I := FoodRes[Special] - FoodRes[0];
     1793                  if I <> 0 then
    17941794                    MainText[Count - 1] := MainText[Count - 1] +
    1795                       Format(HelpText.Lookup('SPECIALFOOD'), [i]);
    1796                   i := ProdRes[Special] - ProdRes[0];
    1797                   if i <> 0 then
     1795                      Format(HelpText.Lookup('SPECIALFOOD'), [I]);
     1796                  I := ProdRes[Special] - ProdRes[0];
     1797                  if I <> 0 then
    17981798                    MainText[Count - 1] := MainText[Count - 1] +
    1799                       Format(HelpText.Lookup('SPECIALPROD'), [i]);
    1800                   i := TradeRes[Special] - TradeRes[0];
    1801                   if i <> 0 then
     1799                      Format(HelpText.Lookup('SPECIALPROD'), [I]);
     1800                  I := TradeRes[Special] - TradeRes[0];
     1801                  if I <> 0 then
    18021802                    MainText[Count - 1] := MainText[Count - 1] +
    1803                       Format(HelpText.Lookup('SPECIALTRADE'), [i]);
     1803                      Format(HelpText.Lookup('SPECIALTRADE'), [I]);
    18041804                end;
    18051805            end;
     
    18131813              NextSection('SEEALSO');
    18141814              AddImprovement(woGardens);
    1815               CheckSeeAlso := true
     1815              CheckSeeAlso := True
    18161816            end;
    18171817          end;
     
    18371837            end;
    18381838            List.Clear;
    1839             for i := 0 to nFeature - 1 do
    1840               if Feature[i].Preq <> preNA then
     1839            for I := 0 to nFeature - 1 do
     1840              if Feature[I].Preq <> preNA then
    18411841              begin
    1842                 if i < mcFirstNonCap then
    1843                   j := 0
    1844                 else if i in AutoFeature then
    1845                   j := 2
     1842                if I < mcFirstNonCap then
     1843                  J := 0
     1844                else if I in AutoFeature then
     1845                  J := 2
    18461846                else
    1847                   j := 1;
    1848                 if j = Special then
    1849                   List.AddLine(Phrases.Lookup('FEATURES', i), pkFeature, i,
    1850                     hkFeature, i);
     1847                  J := 1;
     1848                if J = Special then
     1849                  List.AddLine(Phrases.Lookup('FEATURES', I), pkFeature, I,
     1850                    hkFeature, I);
    18511851              end;
    18521852            List.Sort;
     
    18711871          begin
    18721872            NextSection('COSTS');
    1873             s := IntToStr(Feature[no].Cost);
     1873            S := IntToStr(Feature[no].Cost);
    18741874            if Feature[no].Cost >= 0 then
    1875               s := '+' + s;
    1876             AddLine(Format(HelpText.Lookup('COSTBASE'), [s]));
     1875              S := '+' + S;
     1876            AddLine(Format(HelpText.Lookup('COSTBASE'), [S]));
    18771877            if Feature[no].Weight > 0 then
    18781878            begin
     
    19011901        begin
    19021902          Caption := HelpText.Lookup('HELPTITLE_MODELLIST');
    1903           for i := 0 to nSpecialModel - 1 do
    1904             if i <> 2 then
    1905               AddModelText(i);
     1903          for I := 0 to nSpecialModel - 1 do
     1904            if I <> 2 then
     1905              AddModelText(I);
    19061906          LineFeed;
    19071907          AddItem('MODELNOTE');
     
    19101910    end;
    19111911    if CheckSeeAlso then
    1912       for i := 0 to nSeeAlso - 1 do
    1913         if (SeeAlso[i].Kind = Kind) and (SeeAlso[i].no = no) then
    1914           case SeeAlso[i].SeeKind of
    1915             hkImp: AddImprovement(SeeAlso[i].SeeNo);
    1916             hkAdv: AddAdvance(SeeAlso[i].SeeNo);
    1917             hkFeature: AddFeature(SeeAlso[i].SeeNo);
     1912      for I := 0 to nSeeAlso - 1 do
     1913        if (SeeAlso[I].Kind = Kind) and (SeeAlso[I].no = no) then
     1914          case SeeAlso[I].SeeKind of
     1915            hkImp: AddImprovement(SeeAlso[I].SeeNo);
     1916            hkAdv: AddAdvance(SeeAlso[I].SeeNo);
     1917            hkFeature: AddFeature(SeeAlso[I].SeeNo);
    19181918          end;
    19191919    if (Headline >= 0) and (Count = Headline + 1) then
     
    19491949
    19501950procedure THelpDlg.PaintBox1MouseMove(Sender: TObject; Shift: TShiftState;
    1951   x, y: integer);
     1951  X, Y: Integer);
    19521952var
    19531953  i0, Sel0: Integer;
    19541954begin
    1955   y := y - WideFrame;
     1955  Y := Y - WideFrame;
    19561956  i0 := ScrollBar.Position;
    19571957  Sel0 := Sel;
    1958   if (x >= SideFrame) and (x < SideFrame + InnerWidth) and (y >= 0) and
    1959     (y < InnerHeight) and (y mod 24 >= 8) then
    1960     Sel := y div 24
     1958  if (X >= SideFrame) and (X < SideFrame + InnerWidth) and (Y >= 0) and
     1959    (Y < InnerHeight) and (Y mod 24 >= 8) then
     1960    Sel := Y div 24
    19611961  else
    19621962    Sel := -1;
     
    19741974
    19751975procedure THelpDlg.PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
    1976   Shift: TShiftState; x, y: integer);
     1976  Shift: TShiftState; X, Y: Integer);
    19771977begin
    19781978  if Sel >= 0 then
     
    19871987      begin
    19881988        if (Link >= $8000) and (Link and $3FFF = liInvalid) then
    1989           exit; // invalid link;
     1989          Exit; // invalid link;
    19901990        if Link >= $8000 then
    19911991          ShowNewContent(FWindowMode, hkText, Link and $3FFF)
     
    20792079procedure THelpDlg.Search(SearchString: string);
    20802080var
    2081   h, i, PrevHandle, PrevIndex, p, RightMargin: Integer;
    2082   s: string;
     2081  H, I, PrevHandle, PrevIndex, P, RightMargin: Integer;
     2082  S: string;
    20832083  mADVHELP, mIMPHELP, mFEATUREHELP: set of 0 .. 255;
    20842084  bGOVHELP, bSPECIALMODEL, bJOBHELP: Boolean;
     
    20942094  // search in generic reference
    20952095  SearchString := UpperCase(SearchString);
    2096   for i := 0 to 35 + 4 do begin
    2097     s := Phrases.Lookup('TERRAIN', i);
    2098     if pos(SearchString, UpperCase(s)) > 0 then
    2099       if i < 36 then
    2100         SearchResult.AddLine(s + ' ' + HelpText.Lookup('HELPSPEC_TER'),
    2101           pkNormal, 0, hkTer + hkCrossLink, i)
     2096  for I := 0 to 35 + 4 do begin
     2097    S := Phrases.Lookup('TERRAIN', I);
     2098    if Pos(SearchString, UpperCase(S)) > 0 then
     2099      if I < 36 then
     2100        SearchResult.AddLine(S + ' ' + HelpText.Lookup('HELPSPEC_TER'),
     2101          pkNormal, 0, hkTer + hkCrossLink, I)
    21022102      else
    21032103      begin
     
    21052105          HelpText.Lookup('HELPSPEC_TER'), pkNormal, 0,
    21062106          hkTer + hkCrossLink, 36);
    2107         if i > 36 then
     2107        if I > 36 then
    21082108          SearchResult.AddLine(Phrases.Lookup('IMPROVEMENTS',
    2109             imShipComp + i - 37) + ' ' + HelpText.Lookup('HELPSPEC_SHIPPART'),
    2110             pkNormal, 0, hkImp + hkCrossLink, imShipComp + i - 37);
     2109            imShipComp + I - 37) + ' ' + HelpText.Lookup('HELPSPEC_SHIPPART'),
     2110            pkNormal, 0, hkImp + hkCrossLink, imShipComp + I - 37);
    21112111        Break;
    21122112      end;
    21132113  end;
    2114   for i := 0 to nJobHelp - 1 do
    2115     if pos(SearchString, UpperCase(Phrases.Lookup('JOBRESULT', JobHelp[i]))) > 0
     2114  for I := 0 to nJobHelp - 1 do
     2115    if Pos(SearchString, UpperCase(Phrases.Lookup('JOBRESULT', JobHelp[I]))) > 0
    21162116    then
    21172117    begin
     
    21212121      Break;
    21222122    end;
    2123   for i := 0 to nAdv - 1 do
    2124   begin
    2125     s := Phrases.Lookup('ADVANCES', i);
    2126     if pos(SearchString, UpperCase(s)) > 0 then
     2123  for I := 0 to nAdv - 1 do
     2124  begin
     2125    S := Phrases.Lookup('ADVANCES', I);
     2126    if Pos(SearchString, UpperCase(S)) > 0 then
    21272127    begin
    2128       if i in FutureTech then
    2129         s := s + ' ' + HelpText.Lookup('HELPSPEC_FUTURE')
     2128      if I in FutureTech then
     2129        S := S + ' ' + HelpText.Lookup('HELPSPEC_FUTURE')
    21302130      else
    2131         s := s + ' ' + HelpText.Lookup('HELPSPEC_ADV');
    2132       SearchResult.AddLine(s, pkNormal, 0, hkAdv + hkCrossLink, i);
    2133       include(mADVHELP, i);
     2131        S := S + ' ' + HelpText.Lookup('HELPSPEC_ADV');
     2132      SearchResult.AddLine(S, pkNormal, 0, hkAdv + hkCrossLink, I);
     2133      Include(mADVHELP, I);
    21342134    end;
    21352135  end;
    2136   for i := 0 to nSpecialModel - 1 do
    2137   begin
    2138     FindStdModelPicture(SpecialModelPictureCode[i], h, s);
    2139     if pos(SearchString, UpperCase(s)) > 0 then
     2136  for I := 0 to nSpecialModel - 1 do
     2137  begin
     2138    FindStdModelPicture(SpecialModelPictureCode[I], H, S);
     2139    if Pos(SearchString, UpperCase(S)) > 0 then
    21402140    begin
    21412141      SearchResult.AddLine(HelpText.Lookup('HELPTITLE_MODELLIST'), pkNormal, 0,
     
    21452145    end;
    21462146  end;
    2147   for i := 0 to nFeature - 1 do
    2148   begin
    2149     s := Phrases.Lookup('FEATURES', i);
    2150     if Pos(SearchString, UpperCase(s)) > 0 then
     2147  for I := 0 to nFeature - 1 do
     2148  begin
     2149    S := Phrases.Lookup('FEATURES', I);
     2150    if Pos(SearchString, UpperCase(S)) > 0 then
    21512151    begin
    2152       if i < mcFirstNonCap then
    2153         s := s + ' ' + HelpText.Lookup('HELPSPEC_CAP')
    2154       else if i in AutoFeature then
    2155         s := s + ' ' + HelpText.Lookup('HELPSPEC_STANDARD')
     2152      if I < mcFirstNonCap then
     2153        S := S + ' ' + HelpText.Lookup('HELPSPEC_CAP')
     2154      else if I in AutoFeature then
     2155        S := S + ' ' + HelpText.Lookup('HELPSPEC_STANDARD')
    21562156      else
    2157         s := s + ' ' + HelpText.Lookup('HELPSPEC_FEATURE');
    2158       SearchResult.AddLine(s, pkNormal, 0, hkFeature + hkCrossLink, i);
    2159       Include(mFEATUREHELP, i);
     2157        S := S + ' ' + HelpText.Lookup('HELPSPEC_FEATURE');
     2158      SearchResult.AddLine(S, pkNormal, 0, hkFeature + hkCrossLink, I);
     2159      Include(mFEATUREHELP, I);
    21602160    end;
    21612161  end;
    2162   for i := 0 to nImp - 1 do
    2163   begin
    2164     s := Phrases.Lookup('IMPROVEMENTS', i);
    2165     if Pos(SearchString, UpperCase(s)) > 0 then
     2162  for I := 0 to nImp - 1 do
     2163  begin
     2164    S := Phrases.Lookup('IMPROVEMENTS', I);
     2165    if Pos(SearchString, UpperCase(S)) > 0 then
    21662166    begin
    2167       case Imp[i].Kind of
     2167      case Imp[I].Kind of
    21682168        ikWonder:
    2169           s := s + ' ' + HelpText.Lookup('HELPSPEC_WONDER');
     2169          S := S + ' ' + HelpText.Lookup('HELPSPEC_WONDER');
    21702170        ikCommon:
    2171           s := s + ' ' + HelpText.Lookup('HELPSPEC_IMP');
     2171          S := S + ' ' + HelpText.Lookup('HELPSPEC_IMP');
    21722172        ikShipPart:
    2173           s := s + ' ' + HelpText.Lookup('HELPSPEC_SHIPPART');
     2173          S := S + ' ' + HelpText.Lookup('HELPSPEC_SHIPPART');
    21742174      else
    2175         s := s + ' ' + HelpText.Lookup('HELPSPEC_NAT')
     2175        S := S + ' ' + HelpText.Lookup('HELPSPEC_NAT')
    21762176      end;
    2177       SearchResult.AddLine(s, pkNormal, 0, hkImp + hkCrossLink, i);
    2178       Include(mIMPHELP, i);
     2177      SearchResult.AddLine(S, pkNormal, 0, hkImp + hkCrossLink, I);
     2178      Include(mIMPHELP, I);
    21792179    end
    21802180  end;
    2181   for i := 0 to nGov - 1 do
    2182     if Pos(SearchString, UpperCase(Phrases.Lookup('GOVERNMENT', i))) > 0 then
     2181  for I := 0 to nGov - 1 do
     2182    if Pos(SearchString, UpperCase(Phrases.Lookup('GOVERNMENT', I))) > 0 then
    21832183    begin
    21842184      SearchResult.AddLine(HelpText.Lookup('HELPTITLE_GOVLIST'), pkNormal, 0,
     
    21892189
    21902190  // full text search
    2191   h := -1;
     2191  H := -1;
    21922192  repeat
    2193     PrevHandle := h;
    2194     PrevIndex := i;
    2195     if not HelpText.Search(SearchString, h, i) then
     2193    PrevHandle := H;
     2194    PrevIndex := I;
     2195    if not HelpText.Search(SearchString, H, I) then
    21962196      Break;
    2197     if h = hADVHELP then
     2197    if H = hADVHELP then
    21982198    begin
    2199       if (i >= 0) and ((i <> PrevIndex) or (h <> PrevHandle)) and
    2200         not(i in mADVHELP) then
     2199      if (I >= 0) and ((I <> PrevIndex) or (H <> PrevHandle)) and
     2200        not(I in mADVHELP) then
    22012201      begin
    2202         s := Phrases.Lookup('ADVANCES', i);
    2203         if i in FutureTech then
    2204           s := s + ' ' + HelpText.Lookup('HELPSPEC_FUTURE')
     2202        S := Phrases.Lookup('ADVANCES', I);
     2203        if I in FutureTech then
     2204          S := S + ' ' + HelpText.Lookup('HELPSPEC_FUTURE')
    22052205        else
    2206           s := s + ' ' + HelpText.Lookup('HELPSPEC_ADV');
    2207         SearchResult.AddLine(s, pkNormal, 0, hkAdv + hkCrossLink, i)
     2206          S := S + ' ' + HelpText.Lookup('HELPSPEC_ADV');
     2207        SearchResult.AddLine(S, pkNormal, 0, hkAdv + hkCrossLink, I)
    22082208      end;
    22092209    end
    2210     else if h = hIMPHELP then
     2210    else if H = hIMPHELP then
    22112211    begin
    2212       if (i >= 0) and ((i <> PrevIndex) or (h <> PrevHandle)) and
    2213         not(i in mIMPHELP) then
     2212      if (I >= 0) and ((I <> PrevIndex) or (H <> PrevHandle)) and
     2213        not(I in mIMPHELP) then
    22142214      begin
    2215         s := Phrases.Lookup('IMPROVEMENTS', i);
    2216         case Imp[i].Kind of
     2215        S := Phrases.Lookup('IMPROVEMENTS', I);
     2216        case Imp[I].Kind of
    22172217          ikWonder:
    2218             s := s + ' ' + HelpText.Lookup('HELPSPEC_WONDER');
     2218            S := S + ' ' + HelpText.Lookup('HELPSPEC_WONDER');
    22192219          ikCommon:
    2220             s := s + ' ' + HelpText.Lookup('HELPSPEC_IMP');
     2220            S := S + ' ' + HelpText.Lookup('HELPSPEC_IMP');
    22212221          ikShipPart:
    2222             s := s + ' ' + HelpText.Lookup('HELPSPEC_SHIPPART');
     2222            S := S + ' ' + HelpText.Lookup('HELPSPEC_SHIPPART');
    22232223        else
    2224           s := s + ' ' + HelpText.Lookup('HELPSPEC_NAT')
     2224          S := S + ' ' + HelpText.Lookup('HELPSPEC_NAT')
    22252225        end;
    2226         SearchResult.AddLine(s, pkNormal, 0, hkImp + hkCrossLink, i)
     2226        SearchResult.AddLine(S, pkNormal, 0, hkImp + hkCrossLink, I)
    22272227      end;
    22282228    end
    2229     else if h = hFEATUREHELP then
     2229    else if H = hFEATUREHELP then
    22302230    begin
    2231       if (i >= 0) and ((i <> PrevIndex) or (h <> PrevHandle)) and
    2232         not(i in mFEATUREHELP) then
     2231      if (I >= 0) and ((I <> PrevIndex) or (H <> PrevHandle)) and
     2232        not(I in mFEATUREHELP) then
    22332233      begin
    2234         s := Phrases.Lookup('FEATURES', i);
    2235         if i < mcFirstNonCap then
    2236           s := s + ' ' + HelpText.Lookup('HELPSPEC_CAP')
    2237         else if i in AutoFeature then
    2238           s := s + ' ' + HelpText.Lookup('HELPSPEC_STANDARD')
     2234        S := Phrases.Lookup('FEATURES', I);
     2235        if I < mcFirstNonCap then
     2236          S := S + ' ' + HelpText.Lookup('HELPSPEC_CAP')
     2237        else if I in AutoFeature then
     2238          S := S + ' ' + HelpText.Lookup('HELPSPEC_STANDARD')
    22392239        else
    2240           s := s + ' ' + HelpText.Lookup('HELPSPEC_FEATURE');
    2241         SearchResult.AddLine(s, pkNormal, 0, hkFeature + hkCrossLink, i);
     2240          S := S + ' ' + HelpText.Lookup('HELPSPEC_FEATURE');
     2241        SearchResult.AddLine(S, pkNormal, 0, hkFeature + hkCrossLink, I);
    22422242      end;
    22432243    end
    2244     else if h = hGOVHELP then
     2244    else if H = hGOVHELP then
    22452245    begin
    2246       if (i >= 0) and (h <> PrevHandle) and not bGOVHELP then
     2246      if (I >= 0) and (H <> PrevHandle) and not bGOVHELP then
    22472247        SearchResult.AddLine(HelpText.Lookup('HELPTITLE_GOVLIST'), pkNormal, 0,
    22482248          hkMisc + hkCrossLink, miscGovList)
    22492249    end
    2250     else if h = hSPECIALMODEL then
     2250    else if H = hSPECIALMODEL then
    22512251    begin
    2252       if (i >= 0) and (h <> PrevHandle) and not bSPECIALMODEL then
     2252      if (I >= 0) and (H <> PrevHandle) and not bSPECIALMODEL then
    22532253        SearchResult.AddLine(HelpText.Lookup('HELPTITLE_MODELLIST'), pkNormal,
    22542254          0, hkModel + hkCrossLink, 0)
    22552255    end
    2256     else if h = hJOBHELP then
     2256    else if H = hJOBHELP then
    22572257    begin
    2258       if (i >= 0) and (h <> PrevHandle) and not bJOBHELP then
     2258      if (I >= 0) and (H <> PrevHandle) and not bJOBHELP then
    22592259        SearchResult.AddLine(HelpText.Lookup('HELPTITLE_JOBLIST'), pkNormal, 0,
    22602260          hkMisc + hkCrossLink, miscJobList)
    22612261    end
    2262     else if { (h<>hMAIN) and } (h <> PrevHandle) then
     2262    else if { (h<>hMAIN) and } (H <> PrevHandle) then
    22632263    begin
    2264       s := HelpText.LookupByHandle(h);
    2265       p := Pos('$', s);
    2266       if p > 0 then
     2264      S := HelpText.LookupByHandle(H);
     2265      P := Pos('$', S);
     2266      if P > 0 then
    22672267      begin
    2268         s := Copy(s, p + 1, maxint);
    2269         p := Pos('\', s);
    2270         if p > 0 then
    2271           s := Copy(s, 1, p - 1);
    2272         SearchResult.AddLine(s, pkNormal, 0, hkText + hkCrossLink, h);
     2268        S := Copy(S, P + 1, maxint);
     2269        P := Pos('\', S);
     2270        if P > 0 then
     2271          S := Copy(S, 1, P - 1);
     2272        SearchResult.AddLine(S, pkNormal, 0, hkText + hkCrossLink, H);
    22732273      end;
    22742274    end;
     
    22782278    RightMargin := InnerWidth - 16 - GetSystemMetrics(SM_CXVSCROLL);
    22792279    OffScreen.Canvas.Font.Assign(UniFont[ftNormal]);
    2280     for i := 0 to SearchResult.Count - 1 do
     2280    for I := 0 to SearchResult.Count - 1 do
    22812281    begin
    2282       while BiColorTextWidth(OffScreen.Canvas, SearchResult[i]) >
     2282      while BiColorTextWidth(OffScreen.Canvas, SearchResult[I]) >
    22832283        RightMargin - 32 do
    2284         SearchResult[i] := copy(SearchResult[i], 1, length(SearchResult[i]) - 1)
     2284        SearchResult[I] := Copy(SearchResult[I], 1, Length(SearchResult[I]) - 1)
    22852285    end;
    22862286  end;
  • trunk/LocalPlayer/IsoEngine.pas

    r442 r447  
    1313
    1414type
    15   TInitEnemyModelEvent = function(emix: integer): boolean;
     15  TInitEnemyModelEvent = function(emix: Integer): Boolean;
    1616  TTileSize = (tsSmall, tsMedium, tsBig);
    1717
     
    3333      Dirx: array [0..7] of Integer = (1, 2, 1, 0, -1, -2, -1, 0);
    3434      Diry: array [0..7] of Integer = (-1, 0, 1, 2, 1, 0, -1, -2);
    35     procedure CityGrid(xm, ym: integer; CityAllowClick: Boolean);
    36     function IsShoreTile(Loc: integer): boolean;
     35    procedure CityGrid(xm, ym: Integer; CityAllowClick: Boolean);
     36    function IsShoreTile(Loc: Integer): Boolean;
    3737    procedure MakeDark(Line: PPixelPointer; Length: Integer);
    3838    procedure SetTileSize(AValue: TTileSize);
    39     procedure ShadeOutside(x0, y0, Width, Height, xm, ym: integer);
     39    procedure ShadeOutside(x0, y0, Width, Height, xm, ym: Integer);
    4040  protected
    4141    FOutput: TBitmap;
     
    6565    ShowDebug: Boolean;
    6666    FoW: Boolean;
    67     function Connection4(Loc, Mask, Value: integer): integer;
    68     function Connection8(Loc, Mask: integer): integer;
    69     function OceanConnection(Loc: integer): integer;
    70     procedure PaintShore(x, y, Loc: integer);
    71     procedure PaintTileExtraTerrain(x, y, Loc: integer);
    72     procedure PaintTileObjects(x, y, Loc, CityLoc, CityOwner: integer;
    73       UseBlink: boolean);
    74     procedure PaintGrid(x, y, nx, ny: integer);
    75     procedure FillRect(x, y, Width, Height, Color: integer);
    76     procedure Textout(x, y, Color: integer; const s: string);
    77     procedure Sprite(HGr: TGraphicSet; xDst, yDst, Width, Height, xGr, yGr: integer);
    78     procedure TSprite(xDst, yDst, grix: integer; PureBlack: boolean = false);
     67    function Connection4(Loc, Mask, Value: Integer): Integer;
     68    function Connection8(Loc, Mask: Integer): Integer;
     69    function OceanConnection(Loc: Integer): Integer;
     70    procedure PaintShore(X, Y, Loc: Integer);
     71    procedure PaintTileExtraTerrain(X, Y, Loc: Integer);
     72    procedure PaintTileObjects(X, Y, Loc, CityLoc, CityOwner: Integer;
     73      UseBlink: Boolean);
     74    procedure PaintGrid(X, Y, nx, ny: Integer);
     75    procedure FillRect(X, Y, Width, Height, Color: Integer);
     76    procedure Textout(X, Y, Color: Integer; const S: string);
     77    procedure Sprite(HGr: TGraphicSet; xDst, yDst, Width, Height, xGr, yGr: Integer);
     78    procedure TSprite(xDst, yDst, grix: Integer; PureBlack: Boolean = False);
    7979    procedure ApplyTileSize(ATileSize: TTileSize);
    8080  public
     
    8989    procedure Reset;
    9090    procedure SetOutput(Output: TBitmap);
    91     procedure SetPaintBounds(Left, Top, Right, Bottom: integer);
    92     procedure Paint(x, y, Loc, nx, ny, CityLoc, CityOwner: integer;
    93       UseBlink: boolean = false; CityAllowClick: boolean = false);
    94     procedure PaintUnit(x, y: integer; const UnitInfo: TUnitInfo;
    95       Status: integer);
    96     procedure PaintCity(x, y: integer; const CityInfo: TCityInfo;
    97       accessory: boolean = true);
    98     procedure BitBltBitmap(Src: TBitmap; x, y, Width, Height, xSrc, ySrc,
    99       Rop: integer);
     91    procedure SetPaintBounds(Left, Top, Right, Bottom: Integer);
     92    procedure Paint(X, Y, Loc, nx, ny, CityLoc, CityOwner: Integer;
     93      UseBlink: Boolean = False; CityAllowClick: Boolean = False);
     94    procedure PaintUnit(X, Y: Integer; const UnitInfo: TUnitInfo;
     95      Status: Integer);
     96    procedure PaintCity(X, Y: Integer; const CityInfo: TCityInfo;
     97      accessory: Boolean = True);
     98    procedure BitBltBitmap(Src: TBitmap; X, Y, Width, Height, xSrc, ySrc,
     99      Rop: Integer);
    100100    procedure AttackBegin(const ShowMove: TShowMove);
    101101    procedure AttackEffect(const ShowMove: TShowMove);
    102102    procedure AttackEnd;
    103103    procedure ReduceTerrainIconsSize;
    104     property AdviceLoc: integer read FAdviceLoc write FAdviceLoc;
     104    property AdviceLoc: Integer read FAdviceLoc write FAdviceLoc;
    105105    property TileSize: TTileSize read FTileSize write SetTileSize;
    106106  end;
     
    127127    (X: 72; Y: 36));
    128128
    129 function IsJungle(y: integer): boolean;
     129function IsJungle(Y: Integer): Boolean;
    130130procedure Init(InitEnemyModelHandler: TInitEnemyModelEvent);
    131131
     
    173173  IsoMapCache: array[TTileSize] of TIsoMapCache;
    174174
    175 function IsJungle(y: integer): boolean;
    176 begin
    177   result := (y > (G.ly - 2) div 4) and (G.ly - 1 - y > (G.ly - 2) div 4)
     175function IsJungle(Y: Integer): Boolean;
     176begin
     177  Result := (Y > (G.ly - 2) div 4) and (G.ly - 1 - Y > (G.ly - 2) div 4)
    178178end;
    179179
     
    254254  Mask24.BeginUpdate;
    255255  for ySrc := 0 to TerrainIconLines - 1 do begin
    256     for i := 0 to yyt * 3 - 1 do
    257       MaskLine[i] := PixelPointer(Mask24, ScaleToNative(0),
    258         ScaleToNative(1 + ySrc * (yyt * 3 + 1) + i));
     256    for I := 0 to yyt * 3 - 1 do
     257      MaskLine[I] := PixelPointer(Mask24, ScaleToNative(0),
     258        ScaleToNative(1 + ySrc * (yyt * 3 + 1) + I));
    259259    for xSrc := 0 to TerrainIconCols - 1 do begin
    260       i := ySrc * 9 + xSrc;
    261       TSpriteSize[i].Left := 0;
     260      I := ySrc * 9 + xSrc;
     261      TSpriteSize[I].Left := 0;
    262262      repeat
    263         Border := true;
    264         for y := 0 to yyt * 3 - 1 do begin
    265           MaskLine[y].SetX(ScaleToNative(1 + xSrc * (xxt * 2 + 1) + TSpriteSize[i].Left));
    266           if MaskLine[y].Pixel^.B = 0 then Border := false;
     263        Border := True;
     264        for Y := 0 to yyt * 3 - 1 do begin
     265          MaskLine[Y].SetX(ScaleToNative(1 + xSrc * (xxt * 2 + 1) + TSpriteSize[I].Left));
     266          if MaskLine[Y].Pixel^.B = 0 then Border := False;
    267267        end;
    268         if Border then Inc(TSpriteSize[i].Left);
    269       until not Border or (TSpriteSize[i].Left = xxt * 2 - 1);
    270       TSpriteSize[i].Top := 0;
     268        if Border then Inc(TSpriteSize[I].Left);
     269      until not Border or (TSpriteSize[I].Left = xxt * 2 - 1);
     270      TSpriteSize[I].Top := 0;
    271271      repeat
    272         Border := true;
    273         for x := 0 to xxt * 2 - 1 do begin
    274           MaskLine[TSpriteSize[i].Top].SetX(ScaleToNative(1 + xSrc * (xxt * 2 + 1) + x));
    275           if MaskLine[TSpriteSize[i].Top].Pixel^.B = 0 then Border := false;
     272        Border := True;
     273        for X := 0 to xxt * 2 - 1 do begin
     274          MaskLine[TSpriteSize[I].Top].SetX(ScaleToNative(1 + xSrc * (xxt * 2 + 1) + X));
     275          if MaskLine[TSpriteSize[I].Top].Pixel^.B = 0 then Border := False;
    276276        end;
    277         if Border then inc(TSpriteSize[i].Top);
    278       until not Border or (TSpriteSize[i].Top = yyt * 3 - 1);
    279       TSpriteSize[i].Right := xxt * 2;
     277        if Border then Inc(TSpriteSize[I].Top);
     278      until not Border or (TSpriteSize[I].Top = yyt * 3 - 1);
     279      TSpriteSize[I].Right := xxt * 2;
    280280      repeat
    281         Border := true;
    282         for y := 0 to yyt * 3 - 1 do begin
    283           MaskLine[y].SetX(ScaleToNative(xSrc * (xxt * 2 + 1) + TSpriteSize[i].Right));
    284           if MaskLine[y].Pixel^.B = 0 then Border := false;
     281        Border := True;
     282        for Y := 0 to yyt * 3 - 1 do begin
     283          MaskLine[Y].SetX(ScaleToNative(xSrc * (xxt * 2 + 1) + TSpriteSize[I].Right));
     284          if MaskLine[Y].Pixel^.B = 0 then Border := False;
    285285        end;
    286         if Border then Dec(TSpriteSize[i].Right);
    287       until not Border or (TSpriteSize[i].Right = TSpriteSize[i].Left);
    288       TSpriteSize[i].Bottom := yyt * 3;
     286        if Border then Dec(TSpriteSize[I].Right);
     287      until not Border or (TSpriteSize[I].Right = TSpriteSize[I].Left);
     288      TSpriteSize[I].Bottom := yyt * 3;
    289289      repeat
    290         Border := true;
    291         for x := 0 to xxt * 2 - 1 do begin
    292           MaskLine[TSpriteSize[i].Bottom - 1].SetX(ScaleToNative(1 + xSrc * (xxt * 2 + 1) + x));
    293           if MaskLine[TSpriteSize[i].Bottom - 1].Pixel^.B = 0 then Border := false;
     290        Border := True;
     291        for X := 0 to xxt * 2 - 1 do begin
     292          MaskLine[TSpriteSize[I].Bottom - 1].SetX(ScaleToNative(1 + xSrc * (xxt * 2 + 1) + X));
     293          if MaskLine[TSpriteSize[I].Bottom - 1].Pixel^.B = 0 then Border := False;
    294294        end;
    295         if Border then Dec(TSpriteSize[i].Bottom);
    296       until not Border or (TSpriteSize[i].Bottom = TSpriteSize[i].Top);
     295        if Border then Dec(TSpriteSize[I].Bottom);
     296      until not Border or (TSpriteSize[I].Bottom = TSpriteSize[I].Top);
    297297    end;
    298298  end;
     
    303303procedure TIsoMap.ApplyTileSize(ATileSize: TTileSize);
    304304var
    305   x: Integer;
    306   y: Integer;
     305  X: Integer;
     306  Y: Integer;
    307307  xSrc: Integer;
    308308  ySrc: Integer;
     
    361361    1 + yyt + 15 * (yyt * 3 + 1), SRCAND);
    362362
    363   for x := -1 to 6 do begin
    364     if x = -1 then begin
     363  for X := -1 to 6 do begin
     364    if X = -1 then begin
    365365      xSrc := ShoreDither * (xxt * 2 + 1) + 1;
    366366      ySrc := 1 + yyt;
    367367    end
    368     else if x = 6 then begin
     368    else if X = 6 then begin
    369369      xSrc := 1 + (xxt * 2 + 1) * 2;
    370370      ySrc := 1 + yyt + (yyt * 3 + 1) * 2;
    371371    end else begin
    372       xSrc := (x + 2) * (xxt * 2 + 1) + 1;
     372      xSrc := (X + 2) * (xxt * 2 + 1) + 1;
    373373      ySrc := 1 + yyt;
    374374    end;
    375     for y := -1 to 6 do
    376       BitBltCanvas(LandPatch.Canvas, (x + 2) * (xxt * 2), (y + 2) * yyt,
     375    for Y := -1 to 6 do
     376      BitBltCanvas(LandPatch.Canvas, (X + 2) * (xxt * 2), (Y + 2) * yyt,
    377377        xxt * 2, yyt, HGrTerrain.Data.Canvas, xSrc, ySrc);
    378     for y := -2 to 6 do
    379       BitBltCanvas(LandPatch.Canvas, (x + 2) * (xxt * 2), (y + 2) * yyt, xxt,
     378    for Y := -2 to 6 do
     379      BitBltCanvas(LandPatch.Canvas, (X + 2) * (xxt * 2), (Y + 2) * yyt, xxt,
    380380        yyt, HGrTerrain.Data.Canvas, xSrc + xxt, ySrc + yyt,
    381381        SRCPAINT);
    382     for y := -2 to 6 do
    383       BitBltCanvas(LandPatch.Canvas, (x + 2) * (xxt * 2) + xxt, (y + 2) * yyt,
     382    for Y := -2 to 6 do
     383      BitBltCanvas(LandPatch.Canvas, (X + 2) * (xxt * 2) + xxt, (Y + 2) * yyt,
    384384        xxt, yyt, HGrTerrain.Data.Canvas, xSrc, ySrc + yyt,
    385385        SRCPAINT);
    386     for y := -2 to 6 do
    387       BitBltCanvas(LandPatch.Canvas, (x + 2) * (xxt * 2), (y + 2) * yyt, xxt,
     386    for Y := -2 to 6 do
     387      BitBltCanvas(LandPatch.Canvas, (X + 2) * (xxt * 2), (Y + 2) * yyt, xxt,
    388388        yyt, DitherMask.Canvas, xxt, yyt, SRCAND);
    389     for y := -2 to 6 do
    390       BitBltCanvas(LandPatch.Canvas, (x + 2) * (xxt * 2) + xxt, (y + 2) * yyt,
     389    for Y := -2 to 6 do
     390      BitBltCanvas(LandPatch.Canvas, (X + 2) * (xxt * 2) + xxt, (Y + 2) * yyt,
    391391        xxt, yyt, DitherMask.Canvas, 0, yyt, SRCAND);
    392392  end;
    393393
    394   for y := -1 to 6 do begin
    395     if y = -1 then begin
     394  for Y := -1 to 6 do begin
     395    if Y = -1 then begin
    396396      xSrc := ShoreDither * (xxt * 2 + 1) + 1;
    397397      ySrc := 1 + yyt;
    398398    end
    399     else if y = 6 then begin
     399    else if Y = 6 then begin
    400400      xSrc := 1 + 2 * (xxt * 2 + 1);
    401401      ySrc := 1 + yyt + 2 * (yyt * 3 + 1);
    402402    end else begin
    403       xSrc := (y + 2) * (xxt * 2 + 1) + 1;
     403      xSrc := (Y + 2) * (xxt * 2 + 1) + 1;
    404404      ySrc := 1 + yyt;
    405405    end;
    406     for x := -2 to 6 do
    407       BitBltCanvas(LandMore.Canvas, (x + 2) * (xxt * 2), (y + 2) * yyt,
     406    for X := -2 to 6 do
     407      BitBltCanvas(LandMore.Canvas, (X + 2) * (xxt * 2), (Y + 2) * yyt,
    408408        xxt * 2, yyt, HGrTerrain.Data.Canvas, xSrc, ySrc);
    409     BitBltCanvas(LandMore.Canvas, xxt * 2, (y + 2) * yyt, xxt, yyt,
     409    BitBltCanvas(LandMore.Canvas, xxt * 2, (Y + 2) * yyt, xxt, yyt,
    410410      HGrTerrain.Data.Canvas, xSrc + xxt, ySrc + yyt, SRCPAINT);
    411     for x := 0 to 7 do
    412       BitBltCanvas(LandMore.Canvas, (x + 2) * (xxt * 2) - xxt, (y + 2) * yyt,
     411    for X := 0 to 7 do
     412      BitBltCanvas(LandMore.Canvas, (X + 2) * (xxt * 2) - xxt, (Y + 2) * yyt,
    413413        xxt * 2, yyt, HGrTerrain.Data.Canvas, xSrc, ySrc + yyt,
    414414        SRCPAINT);
    415     for x := -2 to 6 do
    416       BitBltCanvas(LandMore.Canvas, (x + 2) * (xxt * 2), (y + 2) * yyt,
     415    for X := -2 to 6 do
     416      BitBltCanvas(LandMore.Canvas, (X + 2) * (xxt * 2), (Y + 2) * yyt,
    417417        xxt * 2, yyt, DitherMask.Canvas, 0, 0, SRCAND);
    418418  end;
    419419
    420   for x := 0 to 3 do begin
    421     for y := 0 to 3 do begin
    422       if (x = 1) and (y = 1) then xSrc := 1
     420  for X := 0 to 3 do begin
     421    for Y := 0 to 3 do begin
     422      if (X = 1) and (Y = 1) then xSrc := 1
    423423      else
    424         xSrc := (x mod 2) * (xxt * 2 + 1) + 1;
     424        xSrc := (X mod 2) * (xxt * 2 + 1) + 1;
    425425      ySrc := 1 + yyt;
    426       if (x >= 1) = (y >= 2) then
    427         BitBltCanvas(OceanPatch.Canvas, x * (xxt * 2), y * yyt, xxt * 2, yyt,
     426      if (X >= 1) = (Y >= 2) then
     427        BitBltCanvas(OceanPatch.Canvas, X * (xxt * 2), Y * yyt, xxt * 2, yyt,
    428428          HGrTerrain.Data.Canvas, xSrc, ySrc);
    429       if (x >= 1) and ((y < 2) or (x >= 2)) then
     429      if (X >= 1) and ((Y < 2) or (X >= 2)) then
    430430      begin
    431         BitBltCanvas(OceanPatch.Canvas, x * (xxt * 2), y * yyt, xxt, yyt,
     431        BitBltCanvas(OceanPatch.Canvas, X * (xxt * 2), Y * yyt, xxt, yyt,
    432432          HGrTerrain.Data.Canvas, xSrc + xxt, ySrc + yyt,
    433433          SRCPAINT);
    434         BitBltCanvas(OceanPatch.Canvas, x * (xxt * 2) + xxt, y * yyt, xxt, yyt,
     434        BitBltCanvas(OceanPatch.Canvas, X * (xxt * 2) + xxt, Y * yyt, xxt, yyt,
    435435          HGrTerrain.Data.Canvas, xSrc, ySrc + yyt, SRCPAINT);
    436436      end;
    437       BitBltCanvas(OceanPatch.Canvas, x * (xxt * 2), y * yyt, xxt, yyt,
     437      BitBltCanvas(OceanPatch.Canvas, X * (xxt * 2), Y * yyt, xxt, yyt,
    438438        DitherMask.Canvas, xxt, yyt, SRCAND);
    439       BitBltCanvas(OceanPatch.Canvas, x * (xxt * 2) + xxt, y * yyt, xxt, yyt,
     439      BitBltCanvas(OceanPatch.Canvas, X * (xxt * 2) + xxt, Y * yyt, xxt, yyt,
    440440        DitherMask.Canvas, 0, yyt, SRCAND);
    441441    end;
    442442  end;
    443443
    444   for y := 0 to 3 do begin
    445     for x := 0 to 3 do begin
    446       if (x = 1) and (y = 1) then xSrc := 1
     444  for Y := 0 to 3 do begin
     445    for X := 0 to 3 do begin
     446      if (X = 1) and (Y = 1) then xSrc := 1
    447447      else
    448         xSrc := (y mod 2) * (xxt * 2 + 1) + 1;
     448        xSrc := (Y mod 2) * (xxt * 2 + 1) + 1;
    449449      ySrc := 1 + yyt;
    450       if (x < 1) or (y >= 2) then
    451         BitBltCanvas(OceanMore.Canvas, x * (xxt * 2), y * yyt, xxt * 2, yyt,
     450      if (X < 1) or (Y >= 2) then
     451        BitBltCanvas(OceanMore.Canvas, X * (xxt * 2), Y * yyt, xxt * 2, yyt,
    452452          HGrTerrain.Data.Canvas, xSrc, ySrc);
    453       if (x = 1) and (y < 2) or (x >= 2) and (y >= 1) then
     453      if (X = 1) and (Y < 2) or (X >= 2) and (Y >= 1) then
    454454      begin
    455         BitBltCanvas(OceanMore.Canvas, x * (xxt * 2), y * yyt, xxt, yyt,
     455        BitBltCanvas(OceanMore.Canvas, X * (xxt * 2), Y * yyt, xxt, yyt,
    456456          HGrTerrain.Data.Canvas, xSrc + xxt, ySrc + yyt,
    457457          SRCPAINT);
    458         BitBltCanvas(OceanMore.Canvas, x * (xxt * 2) + xxt, y * yyt, xxt, yyt,
     458        BitBltCanvas(OceanMore.Canvas, X * (xxt * 2) + xxt, Y * yyt, xxt, yyt,
    459459          HGrTerrain.Data.Canvas, xSrc, ySrc + yyt, SRCPAINT);
    460460      end;
    461       BitBltCanvas(OceanMore.Canvas, x * (xxt * 2), y * yyt, xxt * 2, yyt,
     461      BitBltCanvas(OceanMore.Canvas, X * (xxt * 2), Y * yyt, xxt * 2, yyt,
    462462        DitherMask.Canvas, 0, 0, SRCAND);
    463463    end;
     
    469469    HGrTerrain.Mask.Canvas, 1, 1 + yyt, SRCPAINT);
    470470
    471   for x := -1 to 6 do
    472     for y := -2 to 6 do
    473       BitBltCanvas(LandPatch.Canvas, (x + 2) * (xxt * 2), (y + 2) * yyt,
     471  for X := -1 to 6 do
     472    for Y := -2 to 6 do
     473      BitBltCanvas(LandPatch.Canvas, (X + 2) * (xxt * 2), (Y + 2) * yyt,
    474474        xxt * 2, yyt, DitherMask.Canvas, 0, 0, SRCAND);
    475475
    476   for y := -1 to 6 do
    477     for x := -2 to 7 do
    478       BitBltCanvas(LandMore.Canvas, (x + 2) * (xxt * 2) - xxt, (y + 2) * yyt,
     476  for Y := -1 to 6 do
     477    for X := -2 to 7 do
     478      BitBltCanvas(LandMore.Canvas, (X + 2) * (xxt * 2) - xxt, (Y + 2) * yyt,
    479479        xxt * 2, yyt, DitherMask.Canvas, 0, yyt, SRCAND);
    480480
     
    482482    LandMore.Canvas, 0, 0, SRCPAINT);
    483483
    484   for x := 0 to 3 do
    485     for y := 0 to 3 do
    486       BitBltCanvas(OceanPatch.Canvas, x * (xxt * 2), y * yyt, xxt * 2, yyt,
     484  for X := 0 to 3 do
     485    for Y := 0 to 3 do
     486      BitBltCanvas(OceanPatch.Canvas, X * (xxt * 2), Y * yyt, xxt * 2, yyt,
    487487        DitherMask.Canvas, 0, 0, SRCAND);
    488488
    489   for y := 0 to 3 do
    490     for x := 0 to 4 do
    491       BitBltCanvas(OceanMore.Canvas, x * (xxt * 2) - xxt, y * yyt, xxt * 2,
     489  for Y := 0 to 3 do
     490    for X := 0 to 4 do
     491      BitBltCanvas(OceanMore.Canvas, X * (xxt * 2) - xxt, Y * yyt, xxt * 2,
    492492        yyt, DitherMask.Canvas, 0, yyt, SRCAND);
    493493
     
    502502    HGrTerrain.Mask.Canvas, 1, 1 + yyt);
    503503
    504   for x := 0 to 6 do
    505     BitBltCanvas(LandPatch.Canvas, (x + 2) * (xxt * 2), yyt, xxt * 2, yyt,
     504  for X := 0 to 6 do
     505    BitBltCanvas(LandPatch.Canvas, (X + 2) * (xxt * 2), yyt, xxt * 2, yyt,
    506506      DitherMask.Canvas, 0, 0, SRCAND);
    507507  BitBltCanvas(DitherMask.Canvas, 0, 0, xxt * 2, yyt, DitherMask.Canvas,
    508508    0, 0, DSTINVERT);
    509509
    510   for y := 0 to 6 do
    511     BitBltCanvas(LandPatch.Canvas, xxt * 2, (y + 2) * yyt, xxt * 2, yyt,
     510  for Y := 0 to 6 do
     511    BitBltCanvas(LandPatch.Canvas, xxt * 2, (Y + 2) * yyt, xxt * 2, yyt,
    512512      DitherMask.Canvas, 0, 0, SRCAND);
    513513
     
    555555end;
    556556
    557 procedure TIsoMap.SetPaintBounds(Left, Top, Right, Bottom: integer);
     557procedure TIsoMap.SetPaintBounds(Left, Top, Right, Bottom: Integer);
    558558begin
    559559  FLeft := Left;
     
    563563end;
    564564
    565 procedure TIsoMap.FillRect(x, y, Width, Height, Color: integer);
    566 begin
    567   if x < FLeft then
    568   begin
    569     Width := Width - (FLeft - x);
    570     x := FLeft;
    571   end;
    572   if y < FTop then
    573   begin
    574     Height := Height - (FTop - y);
    575     y := FTop;
    576   end;
    577   if x + Width >= FRight then
    578     Width := FRight - x;
    579   if y + Height >= FBottom then
    580     Height := FBottom - y;
     565procedure TIsoMap.FillRect(X, Y, Width, Height, Color: Integer);
     566begin
     567  if X < FLeft then
     568  begin
     569    Width := Width - (FLeft - X);
     570    X := FLeft;
     571  end;
     572  if Y < FTop then
     573  begin
     574    Height := Height - (FTop - Y);
     575    Y := FTop;
     576  end;
     577  if X + Width >= FRight then
     578    Width := FRight - X;
     579  if Y + Height >= FBottom then
     580    Height := FBottom - Y;
    581581  if (Width <= 0) or (Height <= 0) then
    582     exit;
     582    Exit;
    583583
    584584  FOutput.Canvas.Brush.Color := Color;
    585   FOutput.Canvas.FillRect(Rect(x, y, x + Width, y + Height));
     585  FOutput.Canvas.FillRect(Rect(X, Y, X + Width, Y + Height));
    586586  FOutput.Canvas.Brush.Style := bsClear;
    587587end;
    588588
    589 procedure TIsoMap.Textout(x, y, Color: integer; const s: string);
     589procedure TIsoMap.Textout(X, Y, Color: Integer; const S: string);
    590590begin
    591591  FOutput.Canvas.Font.Color := Color;
    592   FOutput.Canvas.TextRect(Rect(FLeft, FTop, FRight, FBottom), x, y, s)
    593 end;
    594 
    595 procedure TIsoMap.BitBltBitmap(Src: TBitmap; x, y, Width, Height, xSrc, ySrc,
    596   Rop: integer);
    597 begin
    598   if x < FLeft then
    599   begin
    600     Width := Width - (FLeft - x);
    601     xSrc := xSrc + (FLeft - x);
    602     x := FLeft;
    603   end;
    604   if y < FTop then
    605   begin
    606     Height := Height - (FTop - y);
    607     ySrc := ySrc + (FTop - y);
    608     y := FTop;
    609   end;
    610   if x + Width >= FRight then
    611     Width := FRight - x;
    612   if y + Height >= FBottom then
    613     Height := FBottom - y;
     592  FOutput.Canvas.TextRect(Rect(FLeft, FTop, FRight, FBottom), X, Y, S)
     593end;
     594
     595procedure TIsoMap.BitBltBitmap(Src: TBitmap; X, Y, Width, Height, xSrc, ySrc,
     596  Rop: Integer);
     597begin
     598  if X < FLeft then
     599  begin
     600    Width := Width - (FLeft - X);
     601    xSrc := xSrc + (FLeft - X);
     602    X := FLeft;
     603  end;
     604  if Y < FTop then
     605  begin
     606    Height := Height - (FTop - Y);
     607    ySrc := ySrc + (FTop - Y);
     608    Y := FTop;
     609  end;
     610  if X + Width >= FRight then
     611    Width := FRight - X;
     612  if Y + Height >= FBottom then
     613    Height := FBottom - Y;
    614614  if (Width <= 0) or (Height <= 0) then
    615     exit;
    616 
    617   BitBltCanvas(FOutput.Canvas, x, y, Width, Height, Src.Canvas, xSrc, ySrc, Rop);
    618 end;
    619 
    620 procedure TIsoMap.Sprite(HGr: TGraphicSet; xDst, yDst, Width, Height, xGr, yGr: integer);
     615    Exit;
     616
     617  BitBltCanvas(FOutput.Canvas, X, Y, Width, Height, Src.Canvas, xSrc, ySrc, Rop);
     618end;
     619
     620procedure TIsoMap.Sprite(HGr: TGraphicSet; xDst, yDst, Width, Height, xGr, yGr: Integer);
    621621begin
    622622  BitBltBitmap(HGr.Mask, xDst, yDst, Width, Height, xGr, yGr, SRCAND);
     
    624624end;
    625625
    626 procedure TIsoMap.TSprite(xDst, yDst, grix: integer;
    627   PureBlack: boolean = false);
     626procedure TIsoMap.TSprite(xDst, yDst, grix: Integer;
     627  PureBlack: Boolean = False);
    628628var
    629629  Width: Integer;
    630630  Height: Integer;
    631631  xSrc: Integer;
    632   ySrc: integer;
     632  ySrc: Integer;
    633633begin
    634634  Width := TSpriteSize[grix].Right - TSpriteSize[grix].Left;
     
    653653    Height := FBottom - yDst;
    654654  if (Width <= 0) or (Height <= 0) then
    655     exit;
     655    Exit;
    656656
    657657  BitBltCanvas(FOutput.Canvas, xDst, yDst, Width, Height, MaskCanvas, xSrc, ySrc, SRCAND);
     
    660660end;
    661661
    662 procedure TIsoMap.PaintUnit(x, y: integer; const UnitInfo: TUnitInfo;
    663   Status: integer);
    664 var
    665   xsh, ysh, xGr, yGr, j, mixShow: integer;
     662procedure TIsoMap.PaintUnit(X, Y: Integer; const UnitInfo: TUnitInfo;
     663  Status: Integer);
     664var
     665  xsh, ysh, xGr, yGr, J, mixShow: Integer;
    666666begin
    667667  with UnitInfo do
    668     if (Owner = me) or (emix <> $FFFF) then
     668    if (Owner = Me) or (emix <> $FFFF) then
    669669    begin
    670670      if Job = jCity then
     
    675675        (@OnInitEnemyModel <> nil) then
    676676        if not OnInitEnemyModel(emix) then
    677           exit;
     677          Exit;
    678678      xsh := Tribe[Owner].ModelPicture[mixShow].xShield;
    679679      ysh := Tribe[Owner].ModelPicture[mixShow].yShield;
    680680{$IFNDEF SCR} if Status and usStay <> 0 then
    681         j := 19
     681        J := 19
    682682      else if Status and usRecover <> 0 then
    683         j := 16
     683        J := 16
    684684      else if Status and (usGoto or usEnhance) = usGoto or usEnhance then
    685         j := 18
     685        J := 18
    686686      else if Status and usEnhance <> 0 then
    687         j := 17
     687        J := 17
    688688      else if Status and usGoto <> 0 then
    689         j := 20
     689        J := 20
    690690      else {$ENDIF} if Job = jCity then
    691           j := jNone
     691          J := jNone
    692692        else
    693           j := Job;
     693          J := Job;
    694694      if Flags and unMulti <> 0 then
    695         Sprite(Tribe[Owner].symHGr, x + xsh - 1 + 4, y + ysh - 2, 14, 12,
     695        Sprite(Tribe[Owner].symHGr, X + xsh - 1 + 4, Y + ysh - 2, 14, 12,
    696696          33 + Tribe[Owner].sympix mod 10 * 65,
    697697          1 + Tribe[Owner].sympix div 10 * 49);
    698       Sprite(Tribe[Owner].symHGr, x + xsh - 1, y + ysh - 2, 14, 12,
     698      Sprite(Tribe[Owner].symHGr, X + xsh - 1, Y + ysh - 2, 14, 12,
    699699        18 + Tribe[Owner].sympix mod 10 * 65,
    700700        1 + Tribe[Owner].sympix div 10 * 49);
    701       FillRect(x + xsh, y + ysh + 5, 1 + Health * 11 div 100, 3,
     701      FillRect(X + xsh, Y + ysh + 5, 1 + Health * 11 div 100, 3,
    702702        ColorOfHealth(Health));
    703       if j > 0 then
     703      if J > 0 then
    704704      begin
    705         xGr := 121 + j mod 7 * 9;
    706         yGr := 1 + j div 7 * 9;
    707         BitBltBitmap(HGrSystem.Mask, x + xsh + 3, y + ysh + 9, 8, 8, xGr,
     705        xGr := 121 + J mod 7 * 9;
     706        yGr := 1 + J div 7 * 9;
     707        BitBltBitmap(HGrSystem.Mask, X + xsh + 3, Y + ysh + 9, 8, 8, xGr,
    708708          yGr, SRCAND);
    709         Sprite(HGrSystem, x + xsh + 2, y + ysh + 8, 8, 8, xGr, yGr);
     709        Sprite(HGrSystem, X + xsh + 2, Y + ysh + 8, 8, 8, xGr, yGr);
    710710      end;
    711711      with Tribe[Owner].ModelPicture[mixShow] do
    712         Sprite(HGr, x, y, 64, 48, pix mod 10 * 65 + 1, pix div 10 * 49 + 1);
     712        Sprite(HGr, X, Y, 64, 48, pix mod 10 * 65 + 1, pix div 10 * 49 + 1);
    713713      if Flags and unFortified <> 0 then
    714714      begin
    715715        { DataCanvas:=HGrTerrain.Data.Canvas;
    716716          MaskCanvas:=HGrTerrain.Mask.Canvas;
    717           TSprite(x,y+16,12*9+7); }
    718         Sprite(HGrStdUnits, x, y, xxu * 2, yyu * 2, 1 + 6 * (xxu * 2 + 1), 1);
     717          TSprite(X,Y+16,12*9+7); }
     718        Sprite(HGrStdUnits, X, Y, xxu * 2, yyu * 2, 1 + 6 * (xxu * 2 + 1), 1);
    719719      end;
    720720    end;
    721721end;
    722722
    723 procedure TIsoMap.PaintCity(x, y: integer; const CityInfo: TCityInfo;
    724   accessory: boolean);
     723procedure TIsoMap.PaintCity(X, Y: Integer; const CityInfo: TCityInfo;
     724  accessory: Boolean);
    725725var
    726726  age: Integer;
     
    733733  LabelLength: Integer;
    734734  cpic: TCityPicture;
    735   s: string;
     735  S: string;
    736736begin
    737737  age := GetAge(CityInfo.Owner);
     
    752752      (cHGr.Data.Canvas.Pixels[(xGr + 4) * 65, cpix * 49 + 48] = $00FFFF)
    753753    then
    754       Sprite(cHGr, x - xxc, y - 2 * yyc, xxc * 2, yyc * 3,
     754      Sprite(cHGr, X - xxc, Y - 2 * yyc, xxc * 2, yyc * 3,
    755755        xGr * (xxc * 2 + 1) + 1, 1 + cpix * (yyc * 3 + 1));
    756756    if ciWalled and CityInfo.Flags <> 0 then
    757       Sprite(cHGr, x - xxc, y - 2 * yyc, xxc * 2, yyc * 3,
     757      Sprite(cHGr, X - xxc, Y - 2 * yyc, xxc * 2, yyc * 3,
    758758        (xGr + 4) * (xxc * 2 + 1) + 1, 1 + cpix * (yyc * 3 + 1));
    759759  end
     
    761761  begin
    762762    if ciWalled and CityInfo.Flags <> 0 then
    763       Sprite(HGrCities, x - xxt, y - 2 * yyt, 2 * xxt, 3 * yyt,
     763      Sprite(HGrCities, X - xxt, Y - 2 * yyt, 2 * xxt, 3 * yyt,
    764764        (xGr + 4) * (2 * xxt + 1) + 1, 1 + (age - 2) * (3 * yyt + 1))
    765765    else
    766       Sprite(HGrCities, x - xxt, y - 2 * yyt, 2 * xxt, 3 * yyt,
     766      Sprite(HGrCities, X - xxt, Y - 2 * yyt, 2 * xxt, 3 * yyt,
    767767        xGr * (2 * xxt + 1) + 1, 1 + (age - 2) * (3 * yyt + 1));
    768768  end;
    769769
    770770  if not accessory then
    771     exit;
     771    Exit;
    772772
    773773  { if ciCapital and CityInfo.Flags<>0 then
    774     Sprite(Tribe[CityInfo.Owner].symHGr,x+cpic.xf,y-13+cpic.yf,13,14,
     774    Sprite(Tribe[CityInfo.Owner].symHGr,X+cpic.xf,Y-13+cpic.yf,13,14,
    775775    1+Tribe[CityInfo.Owner].sympix mod 10 *65,
    776776    1+Tribe[CityInfo.Owner].sympix div 10 *49); {capital -- paint flag }
     
    781781    begin
    782782      cpic := Tribe[CityInfo.Owner].CityPicture[xGr];
    783       xShield := x - xxc + cpic.xShield;
    784       yShield := y - 2 * yyc + cpic.yShield;
     783      xShield := X - xxc + cpic.xShield;
     784      yShield := Y - 2 * yyc + cpic.yShield;
    785785    end
    786786    else
    787787    begin
    788788      cpic := CitiesPictures.Pictures[age, xGr];
    789       xShield := x - xxt + cpic.xShield;
    790       yShield := y - 2 * yyt + cpic.yShield;
     789      xShield := X - xxt + cpic.xShield;
     790      yShield := Y - 2 * yyt + cpic.yShield;
    791791    end;
    792     s := IntToStr(CityInfo.size);
    793     LabelLength := FOutput.Canvas.TextWidth(s);
     792    S := IntToStr(CityInfo.size);
     793    LabelLength := FOutput.Canvas.TextWidth(S);
    794794    FillRect(xShield, yShield, LabelLength + 4, 16, $000000);
    795795    if MyMap[CityInfo.Loc] and (fUnit or fObserved) = fObserved then
     
    802802      LabelTextColor := $000000;
    803803    end;
    804     Textout(xShield + 2, yShield - 1, LabelTextColor, s);
    805   end;
    806 end;
    807 
    808 function PoleTile(Loc: integer): integer;
     804    Textout(xShield + 2, yShield - 1, LabelTextColor, S);
     805  end;
     806end;
     807
     808function PoleTile(Loc: Integer): Integer;
    809809begin { virtual pole tile }
    810   result := fUNKNOWN;
     810  Result := fUNKNOWN;
    811811  if Loc < -2 * G.lx then
    812812  else if Loc < -G.lx then
     
    815815      (MyMap[dLoc(Loc, -2, 2)] and fTerrain <> fUNKNOWN) and
    816816      (MyMap[dLoc(Loc, 2, 2)] and fTerrain <> fUNKNOWN) then
    817       result := fArctic;
     817      Result := fArctic;
    818818    if (MyMap[dLoc(Loc, 0, 2)] and fObserved <> 0) and
    819819      (MyMap[dLoc(Loc, -2, 2)] and fObserved <> 0) and
    820820      (MyMap[dLoc(Loc, 2, 2)] and fObserved <> 0) then
    821       result := result or fObserved;
     821      Result := Result or fObserved;
    822822  end
    823823  else if Loc < 0 then
     
    825825    if (MyMap[dLoc(Loc, -1, 1)] and fTerrain <> fUNKNOWN) and
    826826      (MyMap[dLoc(Loc, 1, 1)] and fTerrain <> fUNKNOWN) then
    827       result := fArctic;
     827      Result := fArctic;
    828828    if (MyMap[dLoc(Loc, -1, 1)] and fObserved <> 0) and
    829829      (MyMap[dLoc(Loc, 1, 1)] and fObserved <> 0) then
    830       result := result or fObserved;
     830      Result := Result or fObserved;
    831831  end
    832832  else if Loc < G.lx * (G.ly + 1) then
     
    834834    if (MyMap[dLoc(Loc, -1, -1)] and fTerrain <> fUNKNOWN) and
    835835      (MyMap[dLoc(Loc, 1, -1)] and fTerrain <> fUNKNOWN) then
    836       result := fArctic;
     836      Result := fArctic;
    837837    if (MyMap[dLoc(Loc, -1, -1)] and fObserved <> 0) and
    838838      (MyMap[dLoc(Loc, 1, -1)] and fObserved <> 0) then
    839       result := result or fObserved;
     839      Result := Result or fObserved;
    840840  end
    841841  else if Loc < G.lx * (G.ly + 2) then
     
    844844      (MyMap[dLoc(Loc, -2, -2)] and fTerrain <> fUNKNOWN) and
    845845      (MyMap[dLoc(Loc, 2, -2)] and fTerrain <> fUNKNOWN) then
    846       result := fArctic;
     846      Result := fArctic;
    847847    if (MyMap[dLoc(Loc, 0, -2)] and fObserved <> 0) and
    848848      (MyMap[dLoc(Loc, -2, -2)] and fObserved <> 0) and
    849849      (MyMap[dLoc(Loc, 2, -2)] and fObserved <> 0) then
    850       result := result or fObserved;
    851   end;
    852 end;
    853 
    854 function TIsoMap.Connection4(Loc, Mask, Value: integer): integer;
    855 begin
    856   result := 0;
     850      Result := Result or fObserved;
     851  end;
     852end;
     853
     854function TIsoMap.Connection4(Loc, Mask, Value: Integer): Integer;
     855begin
     856  Result := 0;
    857857  if dLoc(Loc, 1, -1) >= 0 then
    858858  begin
    859859    if MyMap[dLoc(Loc, 1, -1)] and Mask = Cardinal(Value) then
    860       inc(result, 1);
     860      Inc(Result, 1);
    861861    if MyMap[dLoc(Loc, -1, -1)] and Mask = Cardinal(Value) then
    862       inc(result, 8);
     862      Inc(Result, 8);
    863863  end;
    864864  if dLoc(Loc, 1, 1) < G.lx * G.ly then
    865865  begin
    866866    if MyMap[dLoc(Loc, 1, 1)] and Mask = Cardinal(Value) then
    867       inc(result, 2);
     867      Inc(Result, 2);
    868868    if MyMap[dLoc(Loc, -1, 1)] and Mask = Cardinal(Value) then
    869       inc(result, 4);
    870   end;
    871 end;
    872 
    873 function TIsoMap.Connection8(Loc, Mask: integer): integer;
     869      Inc(Result, 4);
     870  end;
     871end;
     872
     873function TIsoMap.Connection8(Loc, Mask: Integer): Integer;
    874874var
    875875  Dir: Integer;
    876876  ConnLoc: Integer;
    877877begin
    878   result := 0;
     878  Result := 0;
    879879  for Dir := 0 to 7 do
    880880  begin
     
    882882    if (ConnLoc >= 0) and (ConnLoc < G.lx * G.ly) and
    883883      (MyMap[ConnLoc] and Mask <> 0) then
    884       inc(result, 1 shl Dir);
    885   end;
    886 end;
    887 
    888 function TIsoMap.OceanConnection(Loc: integer): integer;
     884      Inc(Result, 1 shl Dir);
     885  end;
     886end;
     887
     888function TIsoMap.OceanConnection(Loc: Integer): Integer;
    889889var
    890890  Dir: Integer;
    891891  ConnLoc: Integer;
    892892begin
    893   result := 0;
     893  Result := 0;
    894894  for Dir := 0 to 7 do
    895895  begin
     
    897897    if (ConnLoc < 0) or (ConnLoc >= G.lx * G.ly) or
    898898      ((MyMap[ConnLoc] - 2) and fTerrain < 13) then
    899       inc(result, 1 shl Dir);
    900   end;
    901 end;
    902 
    903 procedure TIsoMap.PaintShore(x, y, Loc: integer);
     899      Inc(Result, 1 shl Dir);
     900  end;
     901end;
     902
     903procedure TIsoMap.PaintShore(X, Y, Loc: Integer);
    904904var
    905905  Conn: Integer;
    906906  Tile: Integer;
    907907begin
    908   if (y <= FTop - yyt * 2) or (y > FBottom) or (x <= FLeft - xxt * 2) or
    909     (x > FRight) then
    910     exit;
     908  if (Y <= FTop - yyt * 2) or (Y > FBottom) or (X <= FLeft - xxt * 2) or
     909    (X > FRight) then
     910    Exit;
    911911  if (Loc < 0) or (Loc >= G.lx * G.ly) then
    912     exit;
     912    Exit;
    913913  Tile := MyMap[Loc];
    914914  if Tile and fTerrain >= fGrass then
    915     exit;
     915    Exit;
    916916  Conn := OceanConnection(Loc);
    917917  if Conn = 0 then
    918     exit;
    919 
    920   BitBltBitmap(HGrTerrain.Data, x + xxt div 2, y, xxt, yyt,
     918    Exit;
     919
     920  BitBltBitmap(HGrTerrain.Data, X + xxt div 2, Y, xxt, yyt,
    921921    1 + (Conn shr 6 + Conn and 1 shl 2) * (xxt * 2 + 1),
    922922    1 + yyt + (16 + Tile and fTerrain) * (yyt * 3 + 1), SRCPAINT);
    923   BitBltBitmap(HGrTerrain.Data, x + xxt, y + yyt div 2, xxt, yyt,
     923  BitBltBitmap(HGrTerrain.Data, X + xxt, Y + yyt div 2, xxt, yyt,
    924924    1 + (Conn and 7) * (xxt * 2 + 1) + xxt,
    925925    1 + yyt * 2 + (16 + Tile and fTerrain) * (yyt * 3 + 1), SRCPAINT);
    926   BitBltBitmap(HGrTerrain.Data, x + xxt div 2, y + yyt, xxt, yyt,
     926  BitBltBitmap(HGrTerrain.Data, X + xxt div 2, Y + yyt, xxt, yyt,
    927927    1 + (Conn shr 2 and 7) * (xxt * 2 + 1) + xxt,
    928928    1 + yyt + (16 + Tile and fTerrain) * (yyt * 3 + 1), SRCPAINT);
    929   BitBltBitmap(HGrTerrain.Data, x, y + yyt div 2, xxt, yyt,
     929  BitBltBitmap(HGrTerrain.Data, X, Y + yyt div 2, xxt, yyt,
    930930    1 + (Conn shr 4 and 7) * (xxt * 2 + 1),
    931931    1 + yyt * 2 + (16 + Tile and fTerrain) * (yyt * 3 + 1), SRCPAINT);
    932932  Conn := Connection4(Loc, fTerrain, fUNKNOWN); { dither to black }
    933933  if Conn and 1 <> 0 then
    934     BitBltBitmap(HGrTerrain.Mask, x + xxt, y, xxt, yyt, 1 + 7 * (xxt * 2 + 1) +
     934    BitBltBitmap(HGrTerrain.Mask, X + xxt, Y, xxt, yyt, 1 + 7 * (xxt * 2 + 1) +
    935935      xxt, 1 + yyt + 15 * (yyt * 3 + 1), SRCAND);
    936936  if Conn and 2 <> 0 then
    937     BitBltBitmap(HGrTerrain.Mask, x + xxt, y + yyt, xxt, yyt,
     937    BitBltBitmap(HGrTerrain.Mask, X + xxt, Y + yyt, xxt, yyt,
    938938      1 + 7 * (xxt * 2 + 1) + xxt, 1 + yyt * 2 + 15 * (yyt * 3 + 1), SRCAND);
    939939  if Conn and 4 <> 0 then
    940     BitBltBitmap(HGrTerrain.Mask, x, y + yyt, xxt, yyt, 1 + 7 * (xxt * 2 + 1),
     940    BitBltBitmap(HGrTerrain.Mask, X, Y + yyt, xxt, yyt, 1 + 7 * (xxt * 2 + 1),
    941941      1 + yyt * 2 + 15 * (yyt * 3 + 1), SRCAND);
    942942  if Conn and 8 <> 0 then
    943     BitBltBitmap(HGrTerrain.Mask, x, y, xxt, yyt, 1 + 7 * (xxt * 2 + 1),
     943    BitBltBitmap(HGrTerrain.Mask, X, Y, xxt, yyt, 1 + 7 * (xxt * 2 + 1),
    944944      1 + yyt + 15 * (yyt * 3 + 1), SRCAND);
    945945end;
    946946
    947 procedure TIsoMap.PaintTileExtraTerrain(x, y, Loc: integer);
    948 var
    949   Dir, Conn, RRConn, yGr, Tile, yLoc: integer;
    950 begin
    951   if (Loc < 0) or (Loc >= G.lx * G.ly) or (y <= -yyt * 2) or
    952     (y > FOutput.Height) or (x <= -xxt * 2) or (x > FOutput.Width) then
    953     exit;
     947procedure TIsoMap.PaintTileExtraTerrain(X, Y, Loc: Integer);
     948var
     949  Dir, Conn, RRConn, yGr, Tile, yLoc: Integer;
     950begin
     951  if (Loc < 0) or (Loc >= G.lx * G.ly) or (Y <= -yyt * 2) or
     952    (Y > FOutput.Height) or (X <= -xxt * 2) or (X > FOutput.Width) then
     953    Exit;
    954954  Tile := MyMap[Loc];
    955955  if Tile and fTerrain = fForest then
     
    966966    then
    967967      Conn := Conn and not 9; // no connection to north
    968     TSprite(x, y, yGr + Conn mod 8 + (Conn div 8) * TerrainIconCols);
     968    TSprite(X, Y, yGr + Conn mod 8 + (Conn div 8) * TerrainIconCols);
    969969  end
    970970  else if Tile and fTerrain in [fHills, fMountains, fForest] then
     
    972972    yGr := 3 + 2 * (Tile and fTerrain - fForest);
    973973    Conn := Connection4(Loc, fTerrain, Tile and fTerrain);
    974     TSprite(x, y, Conn mod 8 + (yGr + Conn div 8) * TerrainIconCols);
     974    TSprite(X, Y, Conn mod 8 + (yGr + Conn div 8) * TerrainIconCols);
    975975  end
    976976  else if Tile and fDeadLands <> 0 then
    977     TSprite(x, y, spRow2);
     977    TSprite(X, Y, spRow2);
    978978
    979979  if ShowObjects then
    980980  begin
    981981    if Tile and fTerImp = tiFarm then
    982       TSprite(x, y, spFarmLand)
     982      TSprite(X, Y, spFarmLand)
    983983    else if Tile and fTerImp = tiIrrigation then
    984       TSprite(x, y, spIrrigation);
     984      TSprite(X, Y, spIrrigation);
    985985  end;
    986986  if Tile and fRiver <> 0 then
     
    989989      Connection4(Loc, fTerrain, fShore) or Connection4(Loc, fTerrain,
    990990      fUNKNOWN);
    991     TSprite(x, y, spRiver + Conn mod 8 + (Conn div 8) * TerrainIconCols);
     991    TSprite(X, Y, spRiver + Conn mod 8 + (Conn div 8) * TerrainIconCols);
    992992  end;
    993993
     
    997997    for Dir := 0 to 3 do
    998998      if Conn and (1 shl Dir) <> 0 then { river mouths }
    999         TSprite(x, y, spRiverMouths + Dir);
     999        TSprite(X, Y, spRiverMouths + Dir);
    10001000    if ShowObjects then
    10011001    begin
     
    10031003      for Dir := 0 to 7 do
    10041004        if Conn and (1 shl Dir) <> 0 then { canal mouths }
    1005           TSprite(x, y, spCanalMouths + 1 + Dir);
     1005          TSprite(X, Y, spCanalMouths + 1 + Dir);
    10061006    end;
    10071007  end;
     
    10151015      if Conn = 0 then begin
    10161016        if Tile and fCanal <> 0 then
    1017           TSprite(x, y, spCanal);
     1017          TSprite(X, Y, spCanal);
    10181018      end
    10191019      else
    10201020        for Dir := 0 to 7 do
    10211021          if (1 shl Dir) and Conn <> 0 then
    1022             TSprite(x, y, spCanal + 1 + Dir);
     1022            TSprite(X, Y, spCanal + 1 + Dir);
    10231023    end;
    10241024
     
    10321032      Conn := Connection8(Loc, fRoad or fRR or fCity) and not RRConn;
    10331033      if (Conn = 0) and (Tile and (fRR or fCity) = 0) then
    1034         TSprite(x, y, spRoad)
     1034        TSprite(X, Y, spRoad)
    10351035      else if Conn > 0 then
    10361036        for Dir := 0 to 7 do
    10371037          if (1 shl Dir) and Conn <> 0 then
    1038             TSprite(x, y, spRoad + 1 + Dir);
     1038            TSprite(X, Y, spRoad + 1 + Dir);
    10391039    end;
    10401040
    10411041    // Paint railroad connections
    10421042    if (Tile and fRR <> 0) and (RRConn = 0) then
    1043       TSprite(x, y, spRailRoad)
     1043      TSprite(X, Y, spRailRoad)
    10441044    else if RRConn > 0 then begin
    10451045      for Dir := 0 to 7 do
    10461046        if (1 shl Dir) and RRConn <> 0 then
    1047           TSprite(x, y, spRailRoad + 1 + Dir);
     1047          TSprite(X, Y, spRailRoad + 1 + Dir);
    10481048    end;
    10491049  end;
     
    10511051
    10521052// (x,y) is top left pixel of (2*xxt,3*yyt) rectangle
    1053 procedure TIsoMap.PaintTileObjects(x, y, Loc, CityLoc, CityOwner: integer;
    1054   UseBlink: boolean);
    1055 var
    1056   p1, p2, uix, cix, dy, Loc1, Tile, Multi, Destination: integer;
     1053procedure TIsoMap.PaintTileObjects(X, Y, Loc, CityLoc, CityOwner: Integer;
     1054  UseBlink: Boolean);
     1055var
     1056  p1, p2, uix, cix, dy, Loc1, Tile, Multi, Destination: Integer;
    10571057  CityInfo: TCityInfo;
    10581058  UnitInfo: TUnitInfo;
    1059   fog: boolean;
     1059  fog: Boolean;
    10601060  SpecialRow: Integer;
    10611061  SpecialCol: Integer;
     
    10631063  procedure NameCity;
    10641064  var
    1065     cix, xs, w: integer;
     1065    cix, xs, W: Integer;
    10661066    BehindCityInfo: TCityInfo;
    1067     s: string;
    1068     IsCapital: boolean;
     1067    S: string;
     1068    IsCapital: Boolean;
    10691069  begin
    10701070    BehindCityInfo.Loc := Loc - 2 * G.lx;
     
    10761076      IsCapital := BehindCityInfo.Flags and ciCapital <> 0;
    10771077      { if Showuix and (cix>=0) then s:=IntToStr(cix)
    1078         else } s := CityName(BehindCityInfo.ID);
    1079       w := FOutput.Canvas.TextWidth(s);
    1080       xs := x + xxt - (w + 1) div 2;
     1078        else } S := CityName(BehindCityInfo.ID);
     1079      W := FOutput.Canvas.TextWidth(S);
     1080      xs := X + xxt - (W + 1) div 2;
    10811081      if IsCapital then
    10821082        FOutput.Canvas.Font.Style := FOutput.Canvas.Font.Style + [fsUnderline];
    1083       Textout(xs + 1, y - 9, $000000, s);
    1084       Textout(xs, y - 10, $FFFFFF, s);
     1083      Textout(xs + 1, Y - 9, $000000, S);
     1084      Textout(xs, Y - 10, $FFFFFF, S);
    10851085      if IsCapital then
    10861086        FOutput.Canvas.Font.Style := FOutput.Canvas.Font.Style - [fsUnderline];
     
    10921092    if ShowObjects and not (moEditMode in MapOptions) and
    10931093      (Tile and fCity <> 0) and (CityInfo.Flags and ciSpacePort <> 0) then
    1094       TSprite(x + xxt, y - 6, spSpacePort);
     1094      TSprite(X + xxt, Y - 6, spSpacePort);
    10951095  end;
    10961096
    10971097  procedure PaintBorder;
    10981098  var
    1099     dx, dy: integer;
     1099    dx, dy: Integer;
    11001100  begin
    11011101    if ShowBorder and (Loc >= 0) and (Loc < G.lx * G.ly) and
    11021102      (Tile and fTerrain <> fUNKNOWN) then begin
    11031103      p1 := MyRO.Territory[Loc];
    1104       if (p1 >= 0) and (ShowMyBorder or (p1 <> me)) then begin
     1104      if (p1 >= 0) and (ShowMyBorder or (p1 <> Me)) then begin
    11051105        if BordersOK^ and (1 shl p1) = 0 then begin
    11061106          UnshareBitmap(Borders);
     
    11231123              if p2 <> p1 then
    11241124              begin
    1125                 BitBltBitmap(HGrTerrain.Mask, x + dx * xxt, y + dy * yyt, xxt,
     1125                BitBltBitmap(HGrTerrain.Mask, X + dx * xxt, Y + dy * yyt, xxt,
    11261126                  yyt, 1 + 8 * (xxt * 2 + 1) + dx * xxt,
    11271127                  1 + yyt + 16 * (yyt * 3 + 1) + dy * yyt, SRCAND);
    1128                 BitBltBitmap(Borders, x + dx * xxt, y + dy * yyt, xxt, yyt, dx * xxt,
     1128                BitBltBitmap(Borders, X + dx * xxt, Y + dy * yyt, xxt, yyt, dx * xxt,
    11291129                  p1 * (yyt * 2) + dy * yyt, SRCPAINT);
    11301130              end;
     
    11431143    (Tile and fCity <> 0) then
    11441144    GetCityInfo(Loc, cix, CityInfo);
    1145   if (y <= FTop - yyt * 2) or (y > FBottom) or (x <= FLeft - xxt * 2) or
    1146     (x > FRight) then
     1145  if (Y <= FTop - yyt * 2) or (Y > FBottom) or (X <= FLeft - xxt * 2) or
     1146    (X > FRight) then
    11471147  begin
    11481148    NameCity;
    11491149    ShowSpacePort;
    1150     exit;
     1150    Exit;
    11511151  end;
    11521152  if Tile and fTerrain = fUNKNOWN then
     
    11541154    NameCity;
    11551155    ShowSpacePort;
    1156     exit;
     1156    Exit;
    11571157  end; { square not discovered }
    11581158
     
    11611161
    11621162  if (Loc >= 0) and (Loc < G.lx * G.ly) and (Loc = FAdviceLoc) then
    1163     TSprite(x, y, spPlain);
     1163    TSprite(X, Y, spPlain);
    11641164
    11651165  if (Loc >= 0) and (Loc < G.lx * G.ly) and (Tile and fSpecial <> 0)
     
    11701170    SpecialRow := Tile and fSpecial shr 5;
    11711171    if SpecialCol < fForest then
    1172       TSprite(x, y, SpecialCol + SpecialRow * TerrainIconCols)
     1172      TSprite(X, Y, SpecialCol + SpecialRow * TerrainIconCols)
    11731173    else if (SpecialCol = fForest) and IsJungle(dy) then
    1174       TSprite(x, y, spJungle - 1 + SpecialRow * TerrainIconCols)
     1174      TSprite(X, Y, spJungle - 1 + SpecialRow * TerrainIconCols)
    11751175    else
    1176       TSprite(x, y, spForest - 1 + ((SpecialCol - fForest) * 2 + SpecialRow) * TerrainIconCols);
     1176      TSprite(X, Y, spForest - 1 + ((SpecialCol - fForest) * 2 + SpecialRow) * TerrainIconCols);
    11771177  end;
    11781178
     
    11801180  begin
    11811181    if Tile and fTerImp = tiMine then
    1182       TSprite(x, y, spMine);
     1182      TSprite(X, Y, spMine);
    11831183    if Tile and fTerImp = tiBase then
    1184       TSprite(x, y, spBase);
     1184      TSprite(X, Y, spBase);
    11851185    if Tile and fPoll <> 0 then
    1186       TSprite(x, y, spPollution);
     1186      TSprite(X, Y, spPollution);
    11871187    if Tile and fTerImp = tiFort then
    11881188    begin
    1189       TSprite(x, y, spFortBack);
     1189      TSprite(X, Y, spFortBack);
    11901190      if Tile and fObserved = 0 then
    1191         TSprite(x, y, spFortFront);
     1191        TSprite(X, Y, spFortFront);
    11921192    end;
    11931193  end;
    11941194  if (Tile and fDeadLands) <> 0 then
    1195     TSprite(x, y, spMinerals + (Tile shr 25 and 3) * TerrainIconCols);
     1195    TSprite(X, Y, spMinerals + (Tile shr 25 and 3) * TerrainIconCols);
    11961196
    11971197  if moEditMode in MapOptions then
     
    12051205  if fog and ShowObjects then
    12061206    if Loc < -G.lx then
    1207       Sprite(HGrTerrain, x, y + yyt, xxt * 2, yyt, 1 + 6 * (xxt * 2 + 1),
     1207      Sprite(HGrTerrain, X, Y + yyt, xxt * 2, yyt, 1 + 6 * (xxt * 2 + 1),
    12081208        1 + yyt * 2 + 15 * (yyt * 3 + 1))
    12091209    else if Loc >= G.lx * (G.ly + 1) then
    1210       Sprite(HGrTerrain, x, y, xxt * 2, yyt, 1 + 6 * (xxt * 2 + 1),
     1210      Sprite(HGrTerrain, X, Y, xxt * 2, yyt, 1 + 6 * (xxt * 2 + 1),
    12111211        1 + yyt + 15 * (yyt * 3 + 1))
    12121212    else
    1213       TSprite(x, y, spGrid, xxt <> 33);
     1213      TSprite(X, Y, spGrid, xxt <> 33);
    12141214
    12151215  if FoW and (Tile and fObserved = 0) then
     
    12241224    if (Destination = Loc) and (Destination <> MyUn[UnFocus].Loc) then
    12251225      if not UseBlink or BlinkOn then
    1226         TSprite(x, y, spBlink1)
     1226        TSprite(X, Y, spBlink1)
    12271227      else
    1228         TSprite(x, y, spBlink2)
     1228        TSprite(X, Y, spBlink2)
    12291229  end;
    12301230{$ENDIF}
     
    12321232  begin
    12331233    if Tile and fPrefStartPos <> 0 then
    1234       TSprite(x, y, spPrefStartPos)
     1234      TSprite(X, Y, spPrefStartPos)
    12351235    else if Tile and fStartPos <> 0 then
    1236       TSprite(x, y, spStartPos);
     1236      TSprite(X, Y, spStartPos);
    12371237  end
    12381238  else if ShowObjects then
    12391239  begin
    12401240    { if (CityLoc<0) and (UnFocus>=0) and (Loc=MyUn[UnFocus].Loc) then
    1241       if BlinkOn then TSprite(x,y,8+9*0)
    1242       else TSprite(x,y,8+9*1); }
     1241      if BlinkOn then TSprite(X,Y,8+9*0)
     1242      else TSprite(X,Y,8+9*1); }
    12431243
    12441244    NameCity;
    12451245    ShowSpacePort;
    12461246    if Tile and fCity <> 0 then
    1247       PaintCity(x + xxt, y + yyt, CityInfo, CityOwner < 0);
     1247      PaintCity(X + xxt, Y + yyt, CityInfo, CityOwner < 0);
    12481248
    12491249    if (Tile and fUnit <> 0) and (Loc <> AttLoc) and
     
    12591259        UnitInfo.Health := DefHealth;
    12601260      if (UnitInfo.Owner <> CityOwner) and
    1261         not((CityOwner = me) and (MyRO.Treaty[UnitInfo.Owner] = trAlliance))
     1261        not((CityOwner = Me) and (MyRO.Treaty[UnitInfo.Owner] = trAlliance))
    12621262      then
    12631263{$IFNDEF SCR} if (UnFocus >= 0) and (Loc = MyUn[UnFocus].Loc) then { active unit }
    12641264        begin
    12651265          Multi := UnitInfo.Flags and unMulti;
    1266           MakeUnitInfo(me, MyUn[UnFocus], UnitInfo);
     1266          MakeUnitInfo(Me, MyUn[UnFocus], UnitInfo);
    12671267          UnitInfo.Flags := UnitInfo.Flags or Multi;
    1268           PaintUnit(x + (xxt - xxu), y + (yyt - yyu_anchor), UnitInfo,
     1268          PaintUnit(X + (xxt - xxu), Y + (yyt - yyu_anchor), UnitInfo,
    12691269            MyUn[UnFocus].Status);
    12701270        end
    1271         else if UnitInfo.Owner = me then
     1271        else if UnitInfo.Owner = Me then
    12721272        begin
    12731273          if ClientMode = cMovieTurn then
    1274             PaintUnit(x + (xxt - xxu), y + (yyt - yyu_anchor), UnitInfo, 0)
     1274            PaintUnit(X + (xxt - xxu), Y + (yyt - yyu_anchor), UnitInfo, 0)
    12751275            // status is not set with precise timing during loading
    12761276          else
    1277             PaintUnit(x + (xxt - xxu), y + (yyt - yyu_anchor), UnitInfo,
     1277            PaintUnit(X + (xxt - xxu), Y + (yyt - yyu_anchor), UnitInfo,
    12781278              MyUn[uix].Status);
    12791279          // if Showuix then Textout(x+16,y+5,$80FF00,IntToStr(uix));
    12801280        end
    1281         else {$ENDIF} PaintUnit(x + (xxt - xxu), y + (yyt - yyu_anchor), UnitInfo, 0);
     1281        else {$ENDIF} PaintUnit(X + (xxt - xxu), Y + (yyt - yyu_anchor), UnitInfo, 0);
    12821282    end
    12831283    else if Tile and fHiddenUnit <> 0 then
    1284       Sprite(HGrStdUnits, x + (xxt - xxu), y + (yyt - yyu_anchor), xxu * 2,
     1284      Sprite(HGrStdUnits, X + (xxt - xxu), Y + (yyt - yyu_anchor), xxu * 2,
    12851285        yyu * 2, 1 + 5 * (xxu * 2 + 1), 1)
    12861286    else if Tile and fStealthUnit <> 0 then
    1287       Sprite(HGrStdUnits, x + (xxt - xxu), y + (yyt - yyu_anchor), xxu * 2,
     1287      Sprite(HGrStdUnits, X + (xxt - xxu), Y + (yyt - yyu_anchor), xxu * 2,
    12881288        yyu * 2, 1 + 5 * (xxu * 2 + 1), 1 + 1 * (yyu * 2 + 1))
    12891289  end;
     
    12911291  if ShowObjects and (Tile and fTerImp = tiFort) and (Tile and fObserved <> 0)
    12921292  then
    1293     TSprite(x, y, spFortFront);
     1293    TSprite(X, Y, spFortFront);
    12941294
    12951295  if (Loc >= 0) and (Loc < G.lx * G.ly) then
    12961296    if ShowLoc then
    1297       Textout(x + xxt - 16, y + yyt - 9, $FFFF00, IntToStr(Loc))
     1297      Textout(X + xxt - 16, Y + yyt - 9, $FFFF00, IntToStr(Loc))
    12981298    else if ShowDebug and (DebugMap <> nil) and (Loc >= 0) and
    12991299      (Loc < G.lx * G.ly) and (DebugMap[Loc] <> 0) then
    1300       Textout(x + xxt - 16, y + yyt - 9, $00E0FF,
    1301         IntToStr(integer(DebugMap[Loc])))
    1302 end;
    1303 
    1304 procedure TIsoMap.PaintGrid(x, y, nx, ny: integer);
    1305 
    1306   procedure ClippedLine(dx0, dy0: integer; mirror: boolean);
     1300      Textout(X + xxt - 16, Y + yyt - 9, $00E0FF,
     1301        IntToStr(Integer(DebugMap[Loc])))
     1302end;
     1303
     1304procedure TIsoMap.PaintGrid(X, Y, nx, ny: Integer);
     1305
     1306  procedure ClippedLine(dx0, dy0: Integer; mirror: Boolean);
    13071307  var
    1308     x0, x1, dxmin, dymin, dxmax, dymax, n: integer;
     1308    x0, x1, dxmin, dymin, dxmax, dymax, N: Integer;
    13091309  begin
    13101310    with FOutput.Canvas do
    13111311    begin
    1312       dxmin := (FLeft - x) div xxt;
    1313       dymin := (RealTop - y) div yyt;
    1314       dxmax := (FRight - x - 1) div xxt + 1;
    1315       dymax := (RealBottom - y - 1) div yyt + 1;
    1316       n := dymax - dy0;
     1312      dxmin := (FLeft - X) div xxt;
     1313      dymin := (RealTop - Y) div yyt;
     1314      dxmax := (FRight - X - 1) div xxt + 1;
     1315      dymax := (RealBottom - Y - 1) div yyt + 1;
     1316      N := dymax - dy0;
    13171317      if mirror then
    13181318      begin
    1319         if dx0 - dxmin < n then
    1320           n := dx0 - dxmin;
     1319        if dx0 - dxmin < N then
     1320          N := dx0 - dxmin;
    13211321        if dx0 > dxmax then
    13221322        begin
    1323           n := n - (dx0 - dxmax);
     1323          N := N - (dx0 - dxmax);
    13241324          dy0 := dy0 + (dx0 - dxmax);
    13251325          dx0 := dxmax
     
    13271327        if dy0 < dymin then
    13281328        begin
    1329           n := n - (dymin - dy0);
     1329          N := N - (dymin - dy0);
    13301330          dx0 := dx0 - (dymin - dy0);
    13311331          dy0 := dymin
     
    13341334      else
    13351335      begin
    1336         if dxmax - dx0 < n then
    1337           n := dxmax - dx0;
     1336        if dxmax - dx0 < N then
     1337          N := dxmax - dx0;
    13381338        if dx0 < dxmin then
    13391339        begin
    1340           n := n - (dxmin - dx0);
     1340          N := N - (dxmin - dx0);
    13411341          dy0 := dy0 + (dxmin - dx0);
    13421342          dx0 := dxmin
     
    13441344        if dy0 < dymin then
    13451345        begin
    1346           n := n - (dymin - dy0);
     1346          N := N - (dymin - dy0);
    13471347          dx0 := dx0 + (dymin - dy0);
    13481348          dy0 := dymin
    13491349        end;
    13501350      end;
    1351       if n <= 0 then
    1352         exit;
     1351      if N <= 0 then
     1352        Exit;
    13531353      if mirror then
    13541354      begin
    1355         x0 := x + dx0 * xxt - 1;
    1356         x1 := x + (dx0 - n) * xxt - 1;
     1355        x0 := X + dx0 * xxt - 1;
     1356        x1 := X + (dx0 - N) * xxt - 1;
    13571357      end
    13581358      else
    13591359      begin
    1360         x0 := x + dx0 * xxt;
    1361         x1 := x + (dx0 + n) * xxt;
     1360        x0 := X + dx0 * xxt;
     1361        x1 := X + (dx0 + N) * xxt;
    13621362      end;
    1363       moveto(x0, y + dy0 * yyt);
    1364       lineto(x1, y + (dy0 + n) * yyt);
     1363      moveto(x0, Y + dy0 * yyt);
     1364      lineto(x1, Y + (dy0 + N) * yyt);
    13651365    end;
    13661366  end;
    13671367
    13681368var
    1369   i: integer;
     1369  I: Integer;
    13701370begin
    13711371  FOutput.Canvas.pen.Color := $000000; // $FF shl (8*random(3));
    1372   for i := 0 to nx div 2 do
    1373     ClippedLine(i * 2, 0, false);
    1374   for i := 1 to (nx + 1) div 2 do
    1375     ClippedLine(i * 2, 0, true);
    1376   for i := 0 to ny div 2 do
    1377   begin
    1378     ClippedLine(0, 2 * i + 2, false);
    1379     ClippedLine(nx + 1, 2 * i + 1 + nx and 1, true);
    1380   end;
    1381 end;
    1382 
    1383 function TIsoMap.IsShoreTile(Loc: integer): boolean;
     1372  for I := 0 to nx div 2 do
     1373    ClippedLine(I * 2, 0, False);
     1374  for I := 1 to (nx + 1) div 2 do
     1375    ClippedLine(I * 2, 0, True);
     1376  for I := 0 to ny div 2 do
     1377  begin
     1378    ClippedLine(0, 2 * I + 2, False);
     1379    ClippedLine(nx + 1, 2 * I + 1 + nx and 1, True);
     1380  end;
     1381end;
     1382
     1383function TIsoMap.IsShoreTile(Loc: Integer): Boolean;
    13841384var
    13851385  Dir: Integer;
    1386   ConnLoc: integer;
    1387 begin
    1388   result := false;
     1386  ConnLoc: Integer;
     1387begin
     1388  Result := False;
    13891389  for Dir := 0 to 7 do
    13901390  begin
     
    13921392    if (ConnLoc < 0) or (ConnLoc >= G.lx * G.ly) or
    13931393      ((MyMap[ConnLoc] - 2) and fTerrain < 13) then
    1394       result := true;
     1394      Result := True;
    13951395  end;
    13961396end;
     
    14011401begin
    14021402  for I := 0 to Length - 1 do begin
    1403     Line^.Pixel^.B := (Line^.Pixel^.B shr 1) and $7f;
    1404     Line^.Pixel^.G := (Line^.Pixel^.G shr 1) and $7f;
    1405     Line^.Pixel^.R := (Line^.Pixel^.R shr 1) and $7f;
     1403    Line^.Pixel^.B := (Line^.Pixel^.B shr 1) and $7F;
     1404    Line^.Pixel^.G := (Line^.Pixel^.G shr 1) and $7F;
     1405    Line^.Pixel^.R := (Line^.Pixel^.R shr 1) and $7F;
    14061406    Line^.NextPixel;
    14071407  end;
     
    14151415end;
    14161416
    1417 procedure TIsoMap.ShadeOutside(x0, y0, Width, Height, xm, ym: integer);
     1417procedure TIsoMap.ShadeOutside(x0, y0, Width, Height, xm, ym: Integer);
    14181418const
    14191419  rShade = 3.75;
    14201420var
    1421   y, wBright: integer;
    1422   y_n, w_n: single;
     1421  Y, wBright: Integer;
     1422  y_n, w_n: Single;
    14231423  Line: TPixelPointer;
    14241424begin
    14251425  FOutput.BeginUpdate;
    14261426  Line := PixelPointer(FOutput, ScaleToNative(x0), ScaleToNative(y0));
    1427   for y := 0 to ScaleToNative(Height) - 1 do begin
    1428     y_n := (ScaleFromNative(y) + y0 - ym) / yyt;
     1427  for Y := 0 to ScaleToNative(Height) - 1 do begin
     1428    y_n := (ScaleFromNative(Y) + y0 - ym) / yyt;
    14291429    if abs(y_n) < rShade then begin
    14301430      // Darken left and right parts of elipsis
     
    14451445end;
    14461446
    1447 procedure TIsoMap.CityGrid(xm, ym: integer; CityAllowClick: Boolean);
    1448 var
    1449   i: integer;
     1447procedure TIsoMap.CityGrid(xm, ym: Integer; CityAllowClick: Boolean);
     1448var
     1449  I: Integer;
    14501450begin
    14511451  with FOutput.Canvas do
     
    14561456      pen.Color := $000000;
    14571457    pen.Width := 1;
    1458     for i := 0 to 3 do
     1458    for I := 0 to 3 do
    14591459    begin
    1460       moveto(xm - xxt * (4 - i), ym + yyt * (1 + i));
    1461       lineto(xm + xxt * (1 + i), ym - yyt * (4 - i));
    1462       moveto(xm - xxt * (4 - i), ym - yyt * (1 + i));
    1463       lineto(xm + xxt * (1 + i), ym + yyt * (4 - i));
     1460      moveto(xm - xxt * (4 - I), ym + yyt * (1 + I));
     1461      lineto(xm + xxt * (1 + I), ym - yyt * (4 - I));
     1462      moveto(xm - xxt * (4 - I), ym - yyt * (1 + I));
     1463      lineto(xm + xxt * (1 + I), ym + yyt * (4 - I));
    14641464    end;
    14651465    moveto(xm - xxt * 4, ym + yyt * 1);
     
    14751475end;
    14761476
    1477 procedure TIsoMap.Paint(x, y, Loc, nx, ny, CityLoc, CityOwner: integer;
    1478   UseBlink: boolean; CityAllowClick: boolean);
    1479 var
    1480   dx, dy, xm, ym, ALoc, BLoc, ATer, BTer, Aix, bix: integer;
    1481 begin
    1482   FoW := true;
     1477procedure TIsoMap.Paint(X, Y, Loc, nx, ny, CityLoc, CityOwner: Integer;
     1478  UseBlink: Boolean; CityAllowClick: Boolean);
     1479var
     1480  dx, dy, xm, ym, ALoc, BLoc, ATer, BTer, Aix, bix: Integer;
     1481begin
     1482  FoW := True;
    14831483  ShowLoc := moLocCodes in MapOptions;
    14841484  ShowDebug := pDebugMap >= 0;
     
    14861486  ShowCityNames := ShowObjects and (CityOwner < 0) and
    14871487    (moCityNames in MapOptions);
    1488   ShowBorder := true;
     1488  ShowBorder := True;
    14891489  ShowMyBorder := CityOwner < 0;
    14901490  ShowGrWall := (CityOwner < 0) and (moGreatWall in MapOptions);
    14911491  if ShowDebug then
    1492     Server(sGetDebugMap, me, pDebugMap, DebugMap)
     1492    Server(sGetDebugMap, Me, pDebugMap, DebugMap)
    14931493  else
    14941494    DebugMap := nil;
    14951495  with FOutput.Canvas do
    14961496  begin
    1497     RealTop := y - ((Loc + 12345 * G.lx) div G.lx - 12345) * yyt;
    1498     RealBottom := y + (G.ly - ((Loc + 12345 * G.lx) div G.lx - 12345) +
     1497    RealTop := Y - ((Loc + 12345 * G.lx) div G.lx - 12345) * yyt;
     1498    RealBottom := Y + (G.ly - ((Loc + 12345 * G.lx) div G.lx - 12345) +
    14991499      3) * yyt;
    15001500    Brush.Color := EmptySpaceColor;
     
    15731573                  bix := 0;
    15741574                end;
    1575               BitBltBitmap(OceanPatch, x + dx * xxt, y + dy * yyt, xxt, yyt,
     1575              BitBltBitmap(OceanPatch, X + dx * xxt, Y + dy * yyt, xxt, yyt,
    15761576                Aix * (xxt * 2) + (dx + dy + 1) and 1 * xxt, bix * yyt, SRCCOPY)
    15771577            end
     
    16211621                bix := Aix;
    16221622            if Aix = -1 then
    1623               BitBltBitmap(HGrTerrain.Data, x + dx * xxt, y + dy * yyt, xxt,
     1623              BitBltBitmap(HGrTerrain.Data, X + dx * xxt, Y + dy * yyt, xxt,
    16241624                yyt, 1 + 6 * (xxt * 2 + 1) + (dx + dy + 1) and 1 * xxt, 1 + yyt,
    16251625                SRCCOPY) // arctic <-> ocean
    16261626            else if bix = -1 then
    1627               BitBltBitmap(HGrTerrain.Data, x + dx * xxt, y + dy * yyt, xxt,
     1627              BitBltBitmap(HGrTerrain.Data, X + dx * xxt, Y + dy * yyt, xxt,
    16281628                yyt, 1 + 6 * (xxt * 2 + 1) + xxt - (dx + dy + 1) and 1 * xxt,
    16291629                1 + yyt * 2, SRCCOPY) // arctic <-> ocean
    16301630            else
    1631               BitBltBitmap(LandPatch, x + dx * xxt, y + dy * yyt, xxt, yyt,
     1631              BitBltBitmap(LandPatch, X + dx * xxt, Y + dy * yyt, xxt, yyt,
    16321632                Aix * (xxt * 2) + (dx + dy + 1) and 1 * xxt, bix * yyt, SRCCOPY)
    16331633          end;
     
    16391639    for dx := -1 to nx do
    16401640      if (dx + dy) and 1 = 0 then
    1641         PaintShore(x + xxt * dx, y + yyt + yyt * dy, dLoc(Loc, dx, dy));
     1641        PaintShore(X + xxt * dx, Y + yyt + yyt * dy, dLoc(Loc, dx, dy));
    16421642  for dy := -2 to ny + 1 do
    16431643    for dx := -1 to nx do
    16441644      if (dx + dy) and 1 = 0 then
    1645         PaintTileExtraTerrain(x + xxt * dx, y + yyt + yyt * dy,
     1645        PaintTileExtraTerrain(X + xxt * dx, Y + yyt + yyt * dy,
    16461646          dLoc(Loc, dx, dy));
    16471647  if CityOwner >= 0 then
     
    16531653          ALoc := dLoc(Loc, dx, dy);
    16541654          if Distance(ALoc, CityLoc) > 5 then
    1655             PaintTileObjects(x + xxt * dx, y + yyt + yyt * dy, ALoc, CityLoc,
     1655            PaintTileObjects(X + xxt * dx, Y + yyt + yyt * dy, ALoc, CityLoc,
    16561656              CityOwner, UseBlink);
    16571657        end;
     
    16601660      * G.lx) mod (2 * G.lx) - G.lx;
    16611661    dy := CityLoc div G.lx - (Loc + 666 * G.lx) div G.lx + 666;
    1662     xm := x + (dx + 1) * xxt;
    1663     ym := y + (dy + 1) * yyt + yyt;
     1662    xm := X + (dx + 1) * xxt;
     1663    ym := Y + (dy + 1) * yyt + yyt;
    16641664    ShadeOutside(FLeft, FTop, FRight - FLeft, FBottom - FTop, xm, ym);
    16651665    CityGrid(xm, ym, CityAllowClick);
     
    16701670          ALoc := dLoc(Loc, dx, dy);
    16711671          if Distance(ALoc, CityLoc) <= 5 then
    1672             PaintTileObjects(x + xxt * dx, y + yyt + yyt * dy, ALoc, CityLoc,
     1672            PaintTileObjects(X + xxt * dx, Y + yyt + yyt * dy, ALoc, CityLoc,
    16731673              CityOwner, UseBlink);
    16741674        end;
     
    16781678    if ShowLoc or (moEditMode in MapOptions) or
    16791679      (moGrid in MapOptions) then
    1680       PaintGrid(x, y, nx, ny);
     1680      PaintGrid(X, Y, nx, ny);
    16811681    for dy := -2 to ny + 1 do
    16821682      for dx := -2 to nx + 1 do
    16831683        if (dx + dy) and 1 = 0 then
    1684           PaintTileObjects(x + xxt * dx, y + yyt + yyt * dy, dLoc(Loc, dx, dy),
     1684          PaintTileObjects(X + xxt * dx, Y + yyt + yyt * dy, dLoc(Loc, dx, dy),
    16851685            CityLoc, CityOwner, UseBlink);
    16861686  end;
  • trunk/LocalPlayer/LocalPlayer.pas

    r364 r447  
    44interface
    55
    6 procedure Client(Command, Player: integer; var Data); stdcall;
    7 procedure SetAIName(p: integer; Name: string);
     6procedure Client(Command, Player: Integer; var Data); stdcall;
     7procedure SetAIName(P: Integer; Name: string);
    88
    99implementation
     
    1414
    1515var
    16   FormsCreated: boolean;
     16  FormsCreated: Boolean;
    1717
    18 procedure Client(Command, Player: integer; var Data);
     18procedure Client(Command, Player: Integer; var Data);
    1919begin
    2020  if not FormsCreated then
    2121  begin
    22     FormsCreated := true;
     22    FormsCreated := True;
    2323    // TODO: Changing application name in runtime will cause change of Linux XML registry file path
    2424//    Application.MainForm := MainScreen;
     
    4545end;
    4646
    47 procedure SetAIName(p: integer; Name: string);
     47procedure SetAIName(P: Integer; Name: string);
    4848begin
    49   MainScreen.SetAIName(p, Name);
     49  MainScreen.SetAIName(P, Name);
    5050end;
    5151
    5252initialization
    5353
    54 FormsCreated := false;
     54FormsCreated := False;
    5555
    5656end.
  • trunk/LocalPlayer/MessgEx.pas

    r442 r447  
    3939    IconKind: TMessageIconKind;
    4040    OpenSound: string;
    41     function ShowModal: integer; override;
     41    function ShowModal: Integer; override;
    4242    procedure CancelMovie;
    4343  private
    44     MovieCancelled: boolean;
    45     procedure PaintBook(ca: TCanvas; x, y, clPage, clCover: integer);
     44    MovieCancelled: Boolean;
     45    procedure PaintBook(ca: TCanvas; X, Y, clPage, clCover: Integer);
    4646    procedure PaintMyArmy;
    4747    procedure PaintEnemyArmy;
     
    5353
    5454procedure SoundMessageEx(SimpleText, SoundItem: string);
    55 procedure TribeMessage(p: integer; SimpleText, SoundItem: string);
     55procedure TribeMessage(P: Integer; SimpleText, SoundItem: string);
    5656function SimpleQuery(QueryKind: TMessageKind; SimpleText, SoundItem: string)
    57   : integer;
     57  : Integer;
    5858procedure ContextMessage(SimpleText, SoundItem: string;
    59   ContextKind, ContextNo: integer);
     59  ContextKind, ContextNo: Integer);
    6060
    6161
     
    8181procedure TMessgExDlg.FormShow(Sender: TObject);
    8282var
    83   i: integer;
     83  I: Integer;
    8484begin
    8585  if IconKind = mikEnemyArmy then
     
    150150  end;
    151151
    152   SplitText(true);
     152  SplitText(True);
    153153  ClientHeight := 72 + Border + TopSpace + Lines * MessageLineSpacing;
    154154  if GameMode = cMovie then
     
    181181      end;
    182182  end;
    183   for i := 0 to ControlCount - 1 do
    184     Controls[i].Top := ClientHeight - (34 + Border);
     183  for I := 0 to ControlCount - 1 do
     184    Controls[I].Top := ClientHeight - (34 + Border);
    185185  if Kind = mkModel then
    186186    EInput.Top := ClientHeight - (76 + Border);
    187187end;
    188188
    189 function TMessgExDlg.ShowModal: integer;
     189function TMessgExDlg.ShowModal: Integer;
    190190var
    191191  Ticks0: TDateTime;
     
    197197    if not((GameMode = cMovie) and (MovieSpeed = 4)) then
    198198    begin
    199       MovieCancelled := false;
     199      MovieCancelled := False;
    200200      Show;
    201201      Ticks0 := NowPrecise;
     
    207207      Hide;
    208208    end;
    209     result := mrOk;
     209    Result := mrOk;
    210210  end
    211211  else
    212     result := inherited;
     212    Result := inherited;
    213213  Gtk2Fix;
    214214end;
     
    216216procedure TMessgExDlg.CancelMovie;
    217217begin
    218   MovieCancelled := true;
    219 end;
    220 
    221 procedure TMessgExDlg.PaintBook(ca: TCanvas; x, y, clPage, clCover: integer);
     218  MovieCancelled := True;
     219end;
     220
     221procedure TMessgExDlg.PaintBook(ca: TCanvas; X, Y, clPage, clCover: Integer);
    222222const
    223223  xScrewed = 77;
     
    228228  TScrewed = array [0 .. wScrewed - 1, 0 .. hScrewed - 1, 0 .. 3] of Single;
    229229var
    230   ix, iy, xDst, yDst, dx, dy, xIcon, yIcon: integer;
     230  ix, iy, xDst, yDst, dx, dy, xIcon, yIcon: Integer;
    231231  BookRect: TRect;
    232   x1, xR, yR, share: single;
     232  x1, xR, yR, share: Single;
    233233  Screwed: TScrewed;
    234234  SrcPtr: TPixelPointer;
     
    284284    BookRect := SmallBook.BoundsRect;
    285285  end;
    286   x := x - BookRect.Width div 2;
     286  X := X - BookRect.Width div 2;
    287287
    288288  // paint
    289289  UnshareBitmap(LogoBuffer);
    290   BitBltCanvas(LogoBuffer.Canvas, 0, 0, BookRect.Width, BookRect.Height, ca, x, y);
     290  BitBltCanvas(LogoBuffer.Canvas, 0, 0, BookRect.Width, BookRect.Height, ca, X, Y);
    291291
    292292  if IconIndex >= 0 then
     
    301301  ImageOp_BCC(LogoBuffer, Templates.Data, Point(0, 0), BookRect, clCover, clPage);
    302302
    303   BitBltCanvas(ca, x, y, BookRect.Width, BookRect.Height, LogoBuffer.Canvas, 0, 0);
     303  BitBltCanvas(ca, X, Y, BookRect.Width, BookRect.Height, LogoBuffer.Canvas, 0, 0);
    304304end;
    305305
     
    310310procedure TMessgExDlg.PaintEnemyArmy;
    311311var
    312   emix, ix, iy, x, y, count, UnitsInLine: integer;
     312  emix, ix, iy, X, Y, count, UnitsInLine: Integer;
    313313begin
    314314  ix := 0;
     
    321321    for count := 0 to LostArmy[emix] - 1 do
    322322    begin
    323       x := ClientWidth div 2 + ix * 64 - UnitsInLine * 32;
    324       y := 26 + Border + TopSpace + Lines * MessageLineSpacing + iy * 48;
     323      X := ClientWidth div 2 + ix * 64 - UnitsInLine * 32;
     324      Y := 26 + Border + TopSpace + Lines * MessageLineSpacing + iy * 48;
    325325      with MyRO.EnemyModel[emix], Tribe[Owner].ModelPicture[mix] do
    326326      begin
    327         BitBltCanvas(Canvas, x, y, 64, 48, HGr.Mask.Canvas,
     327        BitBltCanvas(Canvas, X, Y, 64, 48, HGr.Mask.Canvas,
    328328          pix mod 10 * 65 + 1, pix div 10 * 49 + 1, SRCAND);
    329         BitBltCanvas(Canvas, x, y, 64, 48, HGr.Data.Canvas,
     329        BitBltCanvas(Canvas, X, Y, 64, 48, HGr.Data.Canvas,
    330330          pix mod 10 * 65 + 1, pix div 10 * 49 + 1, SRCPAINT);
    331331      end;
    332332
    333333      // next position
    334       inc(ix);
     334      Inc(ix);
    335335      if ix = LostUnitsPerLine then
    336336      begin // next line
    337337        ix := 0;
    338         inc(iy);
     338        Inc(iy);
    339339        if iy = 6 then
    340           exit;
     340          Exit;
    341341        UnitsInLine := nLostArmy - LostUnitsPerLine * iy;
    342342        if UnitsInLine > LostUnitsPerLine then
     
    348348procedure TMessgExDlg.FormPaint(Sender: TObject);
    349349var
    350   p1, clSaveTextLight, clSaveTextShade: integer;
     350  p1, clSaveTextLight, clSaveTextShade: Integer;
    351351begin
    352352  if (IconKind = mikImp) and (IconIndex = 27) then
     
    394394      end;
    395395    mikModel:
    396       with Tribe[me].ModelPicture[IconIndex] do
     396      with Tribe[Me].ModelPicture[IconIndex] do
    397397      begin
    398398        FrameImage(Canvas, BigImp, ClientWidth div 2 - 28, 24, xSizeBig,
     
    498498end;
    499499
    500 procedure TribeMessage(p: integer; SimpleText, SoundItem: string);
     500procedure TribeMessage(P: Integer; SimpleText, SoundItem: string);
    501501begin
    502502  with MessgExDlg do
     
    506506    Kind := mkOk;
    507507    IconKind := mikTribe;
    508     IconIndex := p;
     508    IconIndex := P;
    509509    ShowModal;
    510510  end;
     
    512512
    513513function SimpleQuery(QueryKind: TMessageKind; SimpleText, SoundItem: string)
    514   : integer;
     514  : Integer;
    515515begin
    516516  with MessgExDlg do
     
    520520    Kind := QueryKind;
    521521    ShowModal;
    522     result := ModalResult;
     522    Result := ModalResult;
    523523  end;
    524524end;
    525525
    526526procedure ContextMessage(SimpleText, SoundItem: string;
    527   ContextKind, ContextNo: integer);
     527  ContextKind, ContextNo: Integer);
    528528begin
    529529  with MessgExDlg do
  • trunk/LocalPlayer/NatStat.pas

    r442 r447  
    2525    procedure ToggleBtnClick(Sender: TObject);
    2626    procedure PlayerClick(Sender: TObject);
    27     procedure FormKeyDown(Sender: TObject; var Key: word; Shift: TShiftState);
     27    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    2828    procedure FormDestroy(Sender: TObject);
    2929    procedure ScrollUpBtnClick(Sender: TObject);
     
    3232  public
    3333    procedure CheckAge;
    34     procedure ShowNewContent(NewMode: TWindowMode; p: integer = -1);
     34    procedure ShowNewContent(NewMode: TWindowMode; P: Integer = -1);
    3535    procedure EcoChange;
    3636  protected
    3737    procedure OffscreenPaint; override;
    3838  private
    39     pView, AgePrepared, LinesDown: integer;
     39    pView, AgePrepared, LinesDown: Integer;
    4040    SelfReport, CurrentReport: PEnemyReport;
    41     ShowContact, ContactEnabled: boolean;
     41    ShowContact, ContactEnabled: Boolean;
    4242    Back, Template: TBitmap;
    4343    ReportText: TStringList;
     
    114114procedure TNatStatDlg.FormShow(Sender: TObject);
    115115begin
    116   if pView = me then
     116  if pView = Me then
    117117  begin
    118118    SelfReport.TurnOfCivilReport := MyRO.Turn;
    119119    SelfReport.TurnOfMilReport := MyRO.Turn;
    120     move(MyRO.Treaty, SelfReport.Treaty, SizeOf(SelfReport.Treaty));
     120    Move(MyRO.Treaty, SelfReport.Treaty, SizeOf(SelfReport.Treaty));
    121121    SelfReport.Government := MyRO.Government;
    122122    SelfReport.Money := MyRO.Money;
    123     CurrentReport := pointer(SelfReport);
     123    CurrentReport := Pointer(SelfReport);
    124124  end
    125125  else
    126     CurrentReport := pointer(MyRO.EnemyReport[pView]);
     126    CurrentReport := Pointer(MyRO.EnemyReport[pView]);
    127127  if CurrentReport.TurnOfCivilReport >= 0 then
    128128    GenerateReportText;
    129   ShowContact := (pView <> me) and (not supervising or (me <> 0));
    130   ContactEnabled := ShowContact and not supervising and
     129  ShowContact := (pView <> Me) and (not Supervising or (Me <> 0));
     130  ContactEnabled := ShowContact and not Supervising and
    131131    (1 shl pView and MyRO.Alive <> 0);
    132132  ContactBtn.Visible := ContactEnabled and (MyRO.Happened and phGameEnd = 0) and
     
    146146end;
    147147
    148 procedure TNatStatDlg.ShowNewContent(NewMode: TWindowMode; p: integer);
    149 begin
    150   if p < 0 then
     148procedure TNatStatDlg.ShowNewContent(NewMode: TWindowMode; P: Integer);
     149begin
     150  if P < 0 then
    151151    if ClientMode >= scContact then
    152       pView := DipMem[me].pContact
     152      pView := DipMem[Me].pContact
    153153    else
    154154    begin
     
    156156      while (pView < nPl) and ((MyRO.Treaty[pView] < trNone) or
    157157        (1 shl pView and MyRO.Alive = 0)) do
    158         inc(pView);
     158        Inc(pView);
    159159      if pView >= nPl then
    160         pView := me;
     160        pView := Me;
    161161    end
    162162  else
    163     pView := p;
     163    pView := P;
    164164  inherited ShowNewContent(NewMode);
    165165end;
     
    174174  List: ^TChart;
    175175
    176   function StatText(no: integer): string;
     176  function StatText(no: Integer): string;
    177177  var
    178     i: integer;
     178    I: Integer;
    179179  begin
    180180    if (CurrentReport.TurnOfCivilReport >= 0) and
    181       (Server(sGetChart + no shl 4, me, pView, List^) >= rExecuted) then
     181      (Server(sGetChart + no shl 4, Me, pView, List^) >= rExecuted) then
    182182    begin
    183       i := List[CurrentReport.TurnOfCivilReport];
     183      I := List[CurrentReport.TurnOfCivilReport];
    184184      case no of
    185185        stPop:
    186           result := Format(Phrases.Lookup('FRSTATPOP'), [i]);
     186          Result := Format(Phrases.Lookup('FRSTATPOP'), [I]);
    187187        stTerritory:
    188           result := Format(Phrases.Lookup('FRSTATTER'), [i]);
     188          Result := Format(Phrases.Lookup('FRSTATTER'), [I]);
    189189        stScience:
    190           result := Format(Phrases.Lookup('FRSTATTECH'), [i div nAdv]);
     190          Result := Format(Phrases.Lookup('FRSTATTECH'), [I div nAdv]);
    191191        stExplore:
    192           result := Format(Phrases.Lookup('FRSTATEXP'),
    193             [i * 100 div (G.lx * G.ly)]);
     192          Result := Format(Phrases.Lookup('FRSTATEXP'),
     193            [I * 100 div (G.lx * G.ly)]);
    194194      end;
    195195    end
     
    197197
    198198var
    199   p1, Treaty: integer;
    200   s: string;
    201   HasContact, ExtinctPart: boolean;
     199  p1, Treaty: Integer;
     200  S: string;
     201  HasContact, ExtinctPart: Boolean;
    202202begin
    203203  GetMem(List, 4 * (MyRO.Turn + 2));
     
    208208    (1 shl pView and MyRO.Alive <> 0) then
    209209  begin
    210     s := Format(Phrases.Lookup('FROLDCIVILREP'),
     210    S := Format(Phrases.Lookup('FROLDCIVILREP'),
    211211      [TurnToString(CurrentReport.TurnOfCivilReport)]);
    212     ReportText.Add('C' + s);
     212    ReportText.Add('C' + S);
    213213    ReportText.Add('');
    214214  end;
     
    223223  ReportText.Add('S' + StatText(stScience));
    224224  ReportText.Add('E' + StatText(stExplore));
    225   HasContact := false;
     225  HasContact := False;
    226226  for p1 := 0 to nPl - 1 do
    227     if (p1 <> me) and (CurrentReport.Treaty[p1] > trNoContact) then
    228       HasContact := true;
     227    if (p1 <> Me) and (CurrentReport.Treaty[p1] > trNoContact) then
     228      HasContact := True;
    229229  if HasContact then
    230230  begin
    231231    ReportText.Add('');
    232232    ReportText.Add(' ' + Phrases.Lookup('FRRELATIONS'));
    233     for ExtinctPart := false to true do
     233    for ExtinctPart := False to True do
    234234      for Treaty := trAlliance downto trNone do
    235235        for p1 := 0 to nPl - 1 do
    236           if (p1 <> me) and (CurrentReport.Treaty[p1] = Treaty) and
     236          if (p1 <> Me) and (CurrentReport.Treaty[p1] = Treaty) and
    237237            ((1 shl p1 and MyRO.Alive = 0) = ExtinctPart) then
    238238          begin
    239             s := Tribe[p1].TString(Phrases.Lookup('HAVETREATY', Treaty));
     239            S := Tribe[p1].TString(Phrases.Lookup('HAVETREATY', Treaty));
    240240            if ExtinctPart then
    241               s := '(' + s + ')';
    242             ReportText.Add(char(48 + Treaty) + s);
     241              S := '(' + S + ')';
     242            ReportText.Add(char(48 + Treaty) + S);
    243243          end;
    244244  end;
     
    250250procedure TNatStatDlg.OffscreenPaint;
    251251var
    252   i, y: integer;
    253   s: string;
    254   ps: pchar;
    255   Extinct: boolean;
     252  I, Y: Integer;
     253  S: string;
     254  ps: PChar;
     255  Extinct: Boolean;
    256256
    257257begin
     
    260260  Extinct := 1 shl pView and MyRO.Alive = 0;
    261261
    262   BitBltCanvas(offscreen.Canvas, 0, 0, ClientWidth, ClientHeight,
     262  BitBltCanvas(Offscreen.Canvas, 0, 0, ClientWidth, ClientHeight,
    263263    Back.Canvas, 0, 0);
    264264
    265   offscreen.Canvas.Font.Assign(UniFont[ftCaption]);
    266   RisedTextout(offscreen.Canvas,
     265  Offscreen.Canvas.Font.Assign(UniFont[ftCaption]);
     266  RisedTextout(Offscreen.Canvas,
    267267    40 { (ClientWidth-BiColorTextWidth(offscreen.canvas,caption)) div 2 } ,
    268268    7, Caption);
    269269
    270   offscreen.Canvas.Font.Assign(UniFont[ftNormal]);
    271 
    272   with offscreen do
     270  Offscreen.Canvas.Font.Assign(UniFont[ftNormal]);
     271
     272  with Offscreen do
    273273  begin
    274274    // show leader picture
     
    276276    if Assigned(Tribe[pView].faceHGr) then
    277277    begin
    278       Dump(offscreen, Tribe[pView].faceHGr, 18, yIcon - 4, 64, 48,
     278      Dump(Offscreen, Tribe[pView].faceHGr, 18, yIcon - 4, 64, 48,
    279279        1 + Tribe[pView].facepix mod 10 * 65,
    280280        1 + Tribe[pView].facepix div 10 * 49);
    281       frame(offscreen.Canvas, 18 - 1, yIcon - 4 - 1, 18 + 64, yIcon - 4 + 48,
     281      frame(Offscreen.Canvas, 18 - 1, yIcon - 4 - 1, 18 + 64, yIcon - 4 + 48,
    282282        $000000, $000000);
    283283    end;
    284284
    285     if (pView = me) or not Extinct then
     285    if (pView = Me) or not Extinct then
    286286      LoweredTextOut(Canvas, -1, MainTexture, xAttrib, yAttrib,
    287287        Phrases.Lookup('GOVERNMENT', CurrentReport.Government) +
    288288        Phrases.Lookup('FRAND'));
    289     if pView = me then
     289    if pView = Me then
    290290    begin
    291291      LoweredTextOut(Canvas, -1, MainTexture, xAttrib, yAttrib + 19,
     
    314314      if MyRO.Treaty[pView] = trNoContact then
    315315      begin
    316         s := Phrases.Lookup('FRNOCONTACT');
     316        S := Phrases.Lookup('FRNOCONTACT');
    317317        LoweredTextOut(Canvas, -1, MainTexture,
    318           (ClientWidth - BiColorTextWidth(Canvas, s)) div 2, yRelation + 9, s);
     318          (ClientWidth - BiColorTextWidth(Canvas, S)) div 2, yRelation + 9, S);
    319319      end
    320320      else if ShowContact then
     
    340340        FrameImage(Canvas, BigImp, xIcon, yIcon, xSizeBig, ySizeBig, 0, 200)
    341341        { else if CurrentReport.Government=gAnarchy then
    342           FrameImage(canvas,BigImp,xIcon,yIcon,xSizeBig,ySizeBig,112,400,
     342          FrameImage(Canvas,BigImp,xIcon,yIcon,xSizeBig,ySizeBig,112,400,
    343343          ContactEnabled and (MyRO.Happened and phGameEnd=0) and (ClientMode<scContact))
    344344          else
    345           FrameImage(canvas,BigImp,xIcon,yIcon,xSizeBig,ySizeBig,
     345          FrameImage(Canvas,BigImp,xIcon,yIcon,xSizeBig,ySizeBig,
    346346          56*(CurrentReport.Government-1),40,
    347347          ContactEnabled and (MyRO.Happened and phGameEnd=0) and (ClientMode<scContact)) };
     
    361361      end;
    362362
    363       y := 0;
    364       for i := 0 to ReportText.Count - 1 do
    365       begin
    366         if (i >= LinesDown) and (i < LinesDown + ReportLines) then
     363      Y := 0;
     364      for I := 0 to ReportText.Count - 1 do
     365      begin
     366        if (I >= LinesDown) and (I < LinesDown + ReportLines) then
    367367        begin
    368           s := ReportText[i];
    369           if s <> '' then
     368          S := ReportText[I];
     369          if S <> '' then
    370370          begin
    371371            // LineType:=s[1];
    372             delete(s, 1, 1);
     372            Delete(S, 1, 1);
    373373            BiColorTextOut(Canvas, Colors.Canvas.Pixels[clkMisc, cliPaperText],
    374               $7F007F, xReport + 8, yReport + LineSpacing * y, s);
     374              $7F007F, xReport + 8, yReport + LineSpacing * Y, S);
    375375          end;
    376           inc(y);
     376          Inc(Y);
    377377        end;
    378378      end;
     
    380380    else
    381381    begin
    382       s := Phrases.Lookup('FRNOCIVILREP');
    383       RisedTextout(Canvas, (ClientWidth - BiColorTextWidth(Canvas, s)) div 2,
    384         yReport + hReport div 2 - 10, s);
     382      S := Phrases.Lookup('FRNOCIVILREP');
     383      RisedTextout(Canvas, (ClientWidth - BiColorTextWidth(Canvas, S)) div 2,
     384        yReport + hReport div 2 - 10, S);
    385385    end;
    386386
    387387    if soTellAI in OptionChecked then begin
    388       Server(sGetAIInfo, me, pView, ps);
     388      Server(sGetAIInfo, Me, pView, ps);
    389389      LoweredTextOut(Canvas, -1, MainTexture, 42, 445, ps);
    390390    end else
     
    392392        Phrases2.Lookup('MENU_TELLAI'));
    393393  end;
    394   ContactBtn.SetBack(offscreen.Canvas, ContactBtn.Left, ContactBtn.Top);
     394  ContactBtn.SetBack(Offscreen.Canvas, ContactBtn.Left, ContactBtn.Top);
    395395
    396396  MarkUsedOffscreen(ClientWidth, ClientHeight);
     
    404404procedure TNatStatDlg.DialogBtnClick(Sender: TObject);
    405405var
    406   ContactResult: integer;
     406  ContactResult: Integer;
    407407begin
    408408  ContactResult := MainScreen.DipCall(scContact + pView shl 4);
     
    412412      SoundMessage(Phrases.Lookup('FRCOLDWAR'), 'MSG_DEFAULT')
    413413    else if MyRO.Government = gAnarchy then
    414       SoundMessage(Tribe[me].TPhrase('FRMYANARCHY'), 'MSG_DEFAULT')
     414      SoundMessage(Tribe[Me].TPhrase('FRMYANARCHY'), 'MSG_DEFAULT')
    415415    else if ContactResult = eAnarchy then
    416416      if MyRO.Treaty[pView] >= trPeace then
     
    428428procedure TNatStatDlg.ToggleBtnClick(Sender: TObject);
    429429var
    430   p1, StartCount: integer;
    431   m: TMenuItem;
    432   ExtinctPart: boolean;
     430  p1, StartCount: Integer;
     431  M: TMenuItem;
     432  ExtinctPart: Boolean;
    433433begin
    434434  EmptyMenu(Popup.Items);
    435435
    436436  // own nation
    437   if G.Difficulty[me] <> 0 then
    438   begin
    439     m := TMenuItem.Create(Popup);
    440     m.RadioItem := true;
    441     m.Caption := Tribe[me].TPhrase('TITLE_NATION');
    442     m.Tag := me;
    443     m.OnClick := PlayerClick;
    444     if me = pView then
    445       m.Checked := true;
    446     Popup.Items.Add(m);
     437  if G.Difficulty[Me] <> 0 then
     438  begin
     439    M := TMenuItem.Create(Popup);
     440    M.RadioItem := True;
     441    M.Caption := Tribe[Me].TPhrase('TITLE_NATION');
     442    M.Tag := Me;
     443    M.OnClick := PlayerClick;
     444    if Me = pView then
     445      M.Checked := True;
     446    Popup.Items.Add(M);
    447447  end;
    448448
    449449  // foreign nations
    450   for ExtinctPart := false to true do
     450  for ExtinctPart := False to True do
    451451  begin
    452452    StartCount := Popup.Items.Count;
     
    456456        (1 shl p1 and MyRO.Alive <> 0) and (MyRO.Treaty[p1] >= trNone) then
    457457      begin
    458         m := TMenuItem.Create(Popup);
    459         m.RadioItem := true;
    460         m.Caption := Tribe[p1].TPhrase('TITLE_NATION');
     458        M := TMenuItem.Create(Popup);
     459        M.RadioItem := True;
     460        M.Caption := Tribe[p1].TPhrase('TITLE_NATION');
    461461        if ExtinctPart then
    462           m.Caption := '(' + m.Caption + ')';
    463         m.Tag := p1;
    464         m.OnClick := PlayerClick;
     462          M.Caption := '(' + M.Caption + ')';
     463        M.Tag := p1;
     464        M.OnClick := PlayerClick;
    465465        if p1 = pView then
    466           m.Checked := true;
    467         Popup.Items.Add(m);
     466          M.Checked := True;
     467        Popup.Items.Add(M);
    468468      end;
    469469    if (StartCount > 0) and (Popup.Items.Count > StartCount) then
    470470    begin // seperator
    471       m := TMenuItem.Create(Popup);
    472       m.Caption := '-';
    473       Popup.Items.Insert(StartCount, m);
     471      M := TMenuItem.Create(Popup);
     472      M.Caption := '-';
     473      Popup.Items.Insert(StartCount, M);
    474474    end;
    475475  end;
     
    478478end;
    479479
    480 procedure TNatStatDlg.FormKeyDown(Sender: TObject; var Key: word;
     480procedure TNatStatDlg.FormKeyDown(Sender: TObject; var Key: Word;
    481481  Shift: TShiftState);
    482482var
    483   i: integer;
     483  I: Integer;
    484484begin
    485485  if Key = VK_F9 then // my key
    486486  begin // toggle nation
    487     i := 0;
     487    I := 0;
    488488    repeat
    489489      pView := (pView + 1) mod nPl;
    490       inc(i);
    491     until (i >= nPl) or (1 shl pView and MyRO.Alive <> 0) and
     490      Inc(I);
     491    until (I >= nPl) or (1 shl pView and MyRO.Alive <> 0) and
    492492      (MyRO.Treaty[pView] >= trNone);
    493     if i >= nPl then
    494       pView := me;
     493    if I >= nPl then
     494      pView := Me;
    495495    Tag := pView;
    496496    PlayerClick(self); // no, this is not nice
     
    502502procedure TNatStatDlg.EcoChange;
    503503begin
    504   if Visible and (pView = me) then
     504  if Visible and (pView = Me) then
    505505  begin
    506506    SelfReport.Government := MyRO.Government;
     
    514514  if LinesDown > 0 then
    515515  begin
    516     dec(LinesDown);
     516    Dec(LinesDown);
    517517    SmartUpdateContent;
    518518  end;
     
    523523  if LinesDown + ReportLines < ReportText.Count then
    524524  begin
    525     inc(LinesDown);
     525    Inc(LinesDown);
    526526    SmartUpdateContent;
    527527  end;
  • trunk/LocalPlayer/Nego.pas

    r442 r447  
    1515type
    1616  THistory = record
    17     n: Integer;
     17    N: Integer;
    1818    Text: array[0 .. MaxHistory - 1] of ansistring;
    1919  end;
     
    5959    procedure FormDestroy(Sender: TObject);
    6060    procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
    61       Shift: TShiftState; X, Y: integer);
     61      Shift: TShiftState; X, Y: Integer);
    6262    procedure OkBtnClick(Sender: TObject);
    6363    procedure BwdBtnClick(Sender: TObject);
     
    7878
    7979  private
    80     Page, DipCommand: integer;
     80    Page, DipCommand: Integer;
    8181    CurrentOffer: TOffer;
    8282    MyAllowed, OppoAllowed: TPriceSet;
     
    8484    History: array [0 .. nPl - 1] of THistory;
    8585    RomanFont: TFont;
    86     Costs, Delivers: array [0 .. 11] of cardinal;
     86    Costs, Delivers: array [0 .. 11] of Cardinal;
    8787    procedure ResetCurrentOffer;
    8888    procedure BuildCurrentOffer;
    8989    procedure FindAllowed;
    9090    procedure SplitText(Text: string; Bounds: TRect);
    91     procedure PaintNationPicture(X, Y, p: integer);
     91    procedure PaintNationPicture(X, Y, P: Integer);
    9292    procedure SetButtonStates;
    9393  end;
     
    183183procedure TNegoDlg.ResetCurrentOffer;
    184184var
    185   i: integer;
     185  I: Integer;
    186186begin
    187187  CurrentOffer.nDeliver := 0;
    188188  CurrentOffer.nCost := 0;
    189   for i := 0 to 11 do
    190     Costs[i] := $FFFFFFFF;
    191   for i := 0 to 11 do
    192     Delivers[i] := $FFFFFFFF;
     189  for I := 0 to 11 do
     190    Costs[I] := $FFFFFFFF;
     191  for I := 0 to 11 do
     192    Delivers[I] := $FFFFFFFF;
    193193end;
    194194
     
    201201  else
    202202    PassBtn.SmartHint := Phrases.Lookup('BTN_PASS');
    203   case MyRO.Treaty[DipMem[me].pContact] of
     203  case MyRO.Treaty[DipMem[Me].pContact] of
    204204    trNone:
    205205      begin
     
    237237begin
    238238  if ClientMode <> scDipStart then
    239     with History[me] do
    240     begin
    241       if n = MaxHistory then
    242       begin
    243         move(Text[2], Text[0], (MaxHistory - 2) * sizeof(integer));
    244         dec(n, 2);
     239    with History[Me] do
     240    begin
     241      if N = MaxHistory then
     242      begin
     243        Move(Text[2], Text[0], (MaxHistory - 2) * SizeOf(Integer));
     244        Dec(N, 2);
    245245      end;
    246       Text[n] := copy(DipCommandToString(DipMem[me].pContact, me,
    247         DipMem[me].FormerTreaty, DipMem[me].SentCommand, ClientMode,
    248         DipMem[me].SentOffer, ReceivedOffer), 1, 255);
    249       inc(n);
     246      Text[N] := Copy(DipCommandToString(DipMem[Me].pContact, Me,
     247        DipMem[Me].FormerTreaty, DipMem[Me].SentCommand, ClientMode,
     248        DipMem[Me].SentOffer, ReceivedOffer), 1, 255);
     249      Inc(N);
    250250    end;
    251   assert(History[me].n mod 2 = 1);
    252 
    253   Page := History[me].n;
     251  Assert(History[Me].N mod 2 = 1);
     252
     253  Page := History[Me].N;
    254254  FindAllowed;
    255255  ResetCurrentOffer;
     
    283283procedure TNegoDlg.SplitText(Text: string; Bounds: TRect);
    284284var
    285   nLines, Line, Start, Stop, OrdinaryStop, Indent, Y: integer;
    286   s: string;
    287   preview, Dot: boolean;
     285  nLines, Line, Start, Stop, OrdinaryStop, Indent, Y: Integer;
     286  S: string;
     287  preview, Dot: Boolean;
    288288begin
    289289  nLines := 0;
    290   for preview := true downto false do
     290  for preview := True downto False do
    291291  begin
    292292    Start := 1;
     
    295295    while Start < Length(Text) do
    296296    begin
    297       Dot := false;
     297      Dot := False;
    298298      if (Start = 1) or (Text[Start - 1] = '\') then
    299299        if Text[Start] = '-' then
    300300        begin
    301301          Indent := ListIndent;
    302           inc(Start);
     302          Inc(Start);
    303303          if Start = Length(Text) then
    304             break;
    305           Dot := true;
     304            Break;
     305          Dot := True;
    306306        end
    307307        else
     
    310310      while (Stop < Length(Text)) and (Text[Stop] <> '\') do
    311311      begin
    312         inc(Stop);
     312        Inc(Stop);
    313313        if BiColorTextWidth(Offscreen.Canvas,
    314           copy(Text, Start, Stop - Start + 1)) > Bounds.Right - Bounds.Left -
     314          Copy(Text, Start, Stop - Start + 1)) > Bounds.Right - Bounds.Left -
    315315          PaperBorder_Left - PaperBorder_Right - Indent then
    316316        begin
    317           dec(Stop);
    318           break
     317          Dec(Stop);
     318          Break
    319319        end;
    320320      end;
     
    324324        while (Text[OrdinaryStop + 1] <> ' ') and
    325325          (Text[OrdinaryStop + 1] <> '\') do
    326           dec(OrdinaryStop);
     326          Dec(OrdinaryStop);
    327327        if (OrdinaryStop + 1 - Start) * 2 >= Stop - Start then
    328328          Stop := OrdinaryStop
     
    334334          Sprite(Offscreen, HGrSystem, Bounds.Left + PaperBorder_Left +
    335335            (ListIndent - 14), Y + 7, 8, 8, 90, 16);
    336         s := copy(Text, Start, Stop - Start + 1);
     336        S := Copy(Text, Start, Stop - Start + 1);
    337337        BiColorTextOut(Offscreen.Canvas, Colors.Canvas.Pixels[clkMisc,
    338338          cliPaperText], $7F007F, Bounds.Left + PaperBorder_Left +
    339           Indent, Y, s);
     339          Indent, Y, S);
    340340      end;
    341       inc(Line);
     341      Inc(Line);
    342342      Start := Stop + 2;
    343343    end;
     
    348348procedure TNegoDlg.FindAllowed;
    349349var
    350   i: integer;
     350  I: Integer;
    351351begin
    352352  CommandAllowed := [scDipOffer - scDipStart];
    353353  if ClientMode <> scDipBreak then
    354     include(CommandAllowed, scDipBreak - scDipStart);
    355   if MyRO.Treaty[DipMem[me].pContact] >= trPeace then
    356     include(CommandAllowed, scDipCancelTreaty - scDipStart);
    357   if (ClientMode = scDipOffer) and (Server(scDipAccept - sExecute, me, 0, nil^)
     354    Include(CommandAllowed, scDipBreak - scDipStart);
     355  if MyRO.Treaty[DipMem[Me].pContact] >= trPeace then
     356    Include(CommandAllowed, scDipCancelTreaty - scDipStart);
     357  if (ClientMode = scDipOffer) and (Server(scDipAccept - sExecute, Me, 0, nil^)
    358358    >= rExecuted) then
    359     include(CommandAllowed, scDipAccept - scDipStart);
     359    Include(CommandAllowed, scDipAccept - scDipStart);
    360360
    361361  MyAllowed := [opChoose shr 24, opMoney shr 24];
    362362  OppoAllowed := [opChoose shr 24, opMoney shr 24];
    363   if not IsCivilReportNew(DipMem[me].pContact) then
     363  if not IsCivilReportNew(DipMem[Me].pContact) then
    364364  begin // no up-to-date civil report
    365365    MyAllowed := MyAllowed + [opCivilReport shr 24];
    366     for i := 0 to nAdv - 1 do
    367       if MyRO.Tech[i] >= tsApplicable then
     366    for I := 0 to nAdv - 1 do
     367      if MyRO.Tech[I] >= tsApplicable then
    368368      begin
    369369        MyAllowed := MyAllowed + [opAllTech shr 24];
    370         break
     370        Break
    371371      end;
    372372    OppoAllowed := OppoAllowed + [opCivilReport shr 24, opAllTech shr 24];
     
    374374  else
    375375  begin // check techs
    376     for i := 0 to nAdv - 1 do
    377       if not(i in FutureTech) then
    378         if (MyRO.Tech[i] < tsSeen) and
    379           (MyRO.EnemyReport[DipMem[me].pContact].Tech[i] >= tsApplicable) then
     376    for I := 0 to nAdv - 1 do
     377      if not(I in FutureTech) then
     378        if (MyRO.Tech[I] < tsSeen) and
     379          (MyRO.EnemyReport[DipMem[Me].pContact].Tech[I] >= tsApplicable) then
    380380          OppoAllowed := OppoAllowed + [opAllTech shr 24]
    381         else if (MyRO.EnemyReport[DipMem[me].pContact].Tech[i] < tsSeen) and
    382           (MyRO.Tech[i] >= tsApplicable) then
     381        else if (MyRO.EnemyReport[DipMem[Me].pContact].Tech[I] < tsSeen) and
     382          (MyRO.Tech[I] >= tsApplicable) then
    383383          MyAllowed := MyAllowed + [opAllTech shr 24];
    384384  end;
    385   if not IsMilReportNew(DipMem[me].pContact) then
     385  if not IsMilReportNew(DipMem[Me].pContact) then
    386386  begin // no up-to-date military report
    387387    MyAllowed := MyAllowed + [opMilReport shr 24];
     
    397397      OppoAllowed := OppoAllowed + [opAllModel shr 24];
    398398  end;
    399   if MyRO.Treaty[DipMem[me].pContact] < trAlliance then
     399  if MyRO.Treaty[DipMem[Me].pContact] < trAlliance then
    400400  begin
    401401    MyAllowed := MyAllowed + [opTreaty shr 24, opMap shr 24];
     
    407407    OppoAllowed:=OppoAllowed+[opLowTreaty shr 24];
    408408    end; }
    409   for i := 0 to nShipPart - 1 do
    410   begin
    411     if MyRO.Ship[me].Parts[i] > 0 then
    412       include(MyAllowed, opShipParts shr 24);
    413     if MyRO.Ship[DipMem[me].pContact].Parts[i] > 0 then
    414       include(OppoAllowed, opShipParts shr 24);
    415   end;
    416   MyAllowed := MyAllowed - DipMem[me].DeliveredPrices *
     409  for I := 0 to nShipPart - 1 do
     410  begin
     411    if MyRO.Ship[Me].Parts[I] > 0 then
     412      Include(MyAllowed, opShipParts shr 24);
     413    if MyRO.Ship[DipMem[Me].pContact].Parts[I] > 0 then
     414      Include(OppoAllowed, opShipParts shr 24);
     415  end;
     416  MyAllowed := MyAllowed - DipMem[Me].DeliveredPrices *
    417417    [opAllTech shr 24, opAllModel shr 24, opCivilReport shr 24,
    418418    opMilReport shr 24, opMap shr 24];
    419   OppoAllowed := OppoAllowed - DipMem[me].ReceivedPrices *
     419  OppoAllowed := OppoAllowed - DipMem[Me].ReceivedPrices *
    420420    [opAllTech shr 24, opAllModel shr 24, opCivilReport shr 24,
    421421    opMilReport shr 24, opMap shr 24];
    422422end;
    423423
    424 procedure TNegoDlg.PaintNationPicture(X, Y, p: integer);
     424procedure TNegoDlg.PaintNationPicture(X, Y, P: Integer);
    425425begin
    426426  with Offscreen.Canvas do
    427427  begin
    428428    Pen.Color := $000000;
    429     Brush.Color := Tribe[p].Color;
     429    Brush.Color := Tribe[P].Color;
    430430    Rectangle(X - 6, Y - 1, X + 70, Y + 49);
    431431    Brush.Color := $000000;
    432     Tribe[p].InitAge(GetAge(p));
    433     if Assigned(Tribe[p].faceHGr) then
    434       Dump(Offscreen, Tribe[p].faceHGr, X, Y, 64, 48,
    435         1 + Tribe[p].facepix mod 10 * 65, 1 + Tribe[p].facepix div 10 * 49)
     432    Tribe[P].InitAge(GetAge(P));
     433    if Assigned(Tribe[P].faceHGr) then
     434      Dump(Offscreen, Tribe[P].faceHGr, X, Y, 64, 48,
     435        1 + Tribe[P].facepix mod 10 * 65, 1 + Tribe[P].facepix div 10 * 49)
    436436    else
    437437      FillRect(Rect(X, Y, X + 64, Y + 48));
     
    443443procedure TNegoDlg.SetButtonStates;
    444444var
    445   cix: integer;
    446   IsActionPage: boolean;
    447 begin
    448   IsActionPage := Page = History[me].n;
     445  cix: Integer;
     446  IsActionPage: Boolean;
     447begin
     448  IsActionPage := Page = History[Me].N;
    449449
    450450  AcceptBtn.Possible := IsActionPage and
     
    483483procedure TNegoDlg.OffscreenPaint;
    484484var
    485   i, cred: integer;
    486   s: string;
    487   OkEnabled: boolean;
     485  I, cred: Integer;
     486  S: string;
     487  OkEnabled: Boolean;
    488488begin
    489489  if (OffscreenUser <> nil) and (OffscreenUser <> self) then
     
    492492  OffscreenUser := self;
    493493
    494   if (DipCommand >= 0) and (Page = History[me].n) then
    495     History[me].Text[History[me].n] :=
    496       copy(DipCommandToString(me, DipMem[me].pContact,
    497       MyRO.Treaty[DipMem[me].pContact], ClientMode, DipCommand, ReceivedOffer,
     494  if (DipCommand >= 0) and (Page = History[Me].N) then
     495    History[Me].Text[History[Me].N] :=
     496      Copy(DipCommandToString(Me, DipMem[Me].pContact,
     497      MyRO.Treaty[DipMem[Me].pContact], ClientMode, DipCommand, ReceivedOffer,
    498498      CurrentOffer), 1, 255);
    499499
    500   FwdBtn.Visible := Page < History[me].n;
     500  FwdBtn.Visible := Page < History[Me].N;
    501501  BwdBtn.Visible := Page >= 2;
    502   if Page < History[me].n then
    503     OkEnabled := false
     502  if Page < History[Me].N then
     503    OkEnabled := False
    504504  else if DipCommand = scDipOffer then
    505     OkEnabled := Server(scDipOffer - sExecute, me, 0, CurrentOffer) >= rExecuted
     505    OkEnabled := Server(scDipOffer - sExecute, Me, 0, CurrentOffer) >= rExecuted
    506506  else
    507507    OkEnabled := DipCommand >= 0;
     
    532532    yPad1 + 41 + 42 * 2, $FFFFFF, $B0B0B0);
    533533
    534   PaintNationPicture(xNationPicture0, yNationPicture, DipMem[me].pContact);
    535   PaintNationPicture(xNationPicture1, yNationPicture, me);
    536 
    537   if History[me].Text[Page - 1] <> '' then
     534  PaintNationPicture(xNationPicture0, yNationPicture, DipMem[Me].pContact);
     535  PaintNationPicture(xNationPicture1, yNationPicture, Me);
     536
     537  if History[Me].Text[Page - 1] <> '' then
    538538  begin
    539539    FillSeamless(Offscreen.Canvas, xText0, yText0, wText, hText, 0, 0, Paper);
    540     i := Page - 1;
    541     if History[me].Text[0] = '' then
    542       dec(i);
    543     if i < 16 then
     540    I := Page - 1;
     541    if History[Me].Text[0] = '' then
     542      Dec(I);
     543    if I < 16 then
    544544    begin
    545545      Offscreen.Canvas.Font.Assign(RomanFont);
    546546      Offscreen.Canvas.TextOut
    547         (xText0 + (wText - Offscreen.Canvas.TextWidth(RomanNo[i])) div 2,
    548         yText0 + (hText - Offscreen.Canvas.TextHeight(RomanNo[i])) div 2,
    549         RomanNo[i]);
     547        (xText0 + (wText - Offscreen.Canvas.TextWidth(RomanNo[I])) div 2,
     548        yText0 + (hText - Offscreen.Canvas.TextHeight(RomanNo[I])) div 2,
     549        RomanNo[I]);
    550550    end
    551551  end;
    552552  FillSeamless(Offscreen.Canvas, xText1, yText1, wText, hText, 0, 0, Paper);
    553   i := Page;
    554   if History[me].Text[0] = '' then
    555     dec(i);
    556   if i < 16 then
     553  I := Page;
     554  if History[Me].Text[0] = '' then
     555    Dec(I);
     556  if I < 16 then
    557557  begin
    558558    Offscreen.Canvas.Font.Assign(RomanFont);
    559559    Offscreen.Canvas.TextOut
    560       (xText1 + (wText - Offscreen.Canvas.TextWidth(RomanNo[i])) div 2,
    561       yText1 + (hText - Offscreen.Canvas.TextHeight(RomanNo[i])) div 2,
    562       RomanNo[i]);
     560      (xText1 + (wText - Offscreen.Canvas.TextWidth(RomanNo[I])) div 2,
     561      yText1 + (hText - Offscreen.Canvas.TextHeight(RomanNo[I])) div 2,
     562      RomanNo[I]);
    563563  end;
    564564  with Offscreen.Canvas do
    565565  begin
    566566    Brush.Color := MainTexture.ColorBevelShade;
    567     if History[me].Text[Page - 1] <> '' then
     567    if History[Me].Text[Page - 1] <> '' then
    568568    begin
    569569      FillRect(Rect(xText0 + wText, yText0 + PaperShade,
     
    583583  { if Page=History[me].n then
    584584    begin // show attitude
    585     s:=Phrases.Lookup('ATTITUDE',MyRO.EnemyReport[DipMem[me].pContact].Attitude);
     585    S:=Phrases.Lookup('ATTITUDE',MyRO.EnemyReport[DipMem[Me].pContact].Attitude);
    586586    //LoweredTextOut(Offscreen.Canvas,-1,MainTexture,
    587587    RisedTextOut(Offscreen.Canvas,xText0+wText div 2-
    588     BiColorTextWidth(Offscreen.Canvas,s) div 2,yAttitude,s);
    589     s:=Phrases.Lookup('ATTITUDE',MyRO.Attitude[DipMem[me].pContact]);
     588    BiColorTextWidth(Offscreen.Canvas,S) div 2,yAttitude,S);
     589    S:=Phrases.Lookup('ATTITUDE',MyRO.Attitude[DipMem[Me].pContact]);
    590590    //LoweredTextOut(Offscreen.Canvas,-1,MainTexture,
    591591    RisedTextOut(Offscreen.Canvas,xText1+wText div 2-
    592     BiColorTextWidth(Offscreen.Canvas,s) div 2,yAttitude,s);
     592    BiColorTextWidth(Offscreen.Canvas,S) div 2,yAttitude,S);
    593593    end; }
    594594
    595   if History[me].Text[Page - 1] <> '' then
    596     SplitText(History[me].Text[Page - 1], Rect(xText0, yText0, xText0 + wText,
     595  if History[Me].Text[Page - 1] <> '' then
     596    SplitText(History[Me].Text[Page - 1], Rect(xText0, yText0, xText0 + wText,
    597597      yText0 + hText));
    598   if (Page < History[me].n) or OkEnabled then
    599     SplitText(History[me].Text[Page], Rect(xText1, yText1, xText1 + wText,
     598  if (Page < History[Me].N) or OkEnabled then
     599    SplitText(History[Me].Text[Page], Rect(xText1, yText1, xText1 + wText,
    600600      yText1 + hText));
    601601
    602602  // show credibility
    603603  Offscreen.Canvas.Font.Assign(UniFont[ftTiny]);
    604   cred := MyRO.EnemyReport[DipMem[me].pContact].Credibility;
     604  cred := MyRO.EnemyReport[DipMem[Me].pContact].Credibility;
    605605  case cred of
    606606    0 .. 49:
    607       i := 3;
     607      I := 3;
    608608    50 .. 90:
    609       i := 0;
     609      I := 0;
    610610    91 .. 100:
    611       i := 1;
    612   end;
    613   PaintProgressBar(Offscreen.Canvas, i, xCred0, yCred0 + 17, (cred + 2) div 5,
     611      I := 1;
     612  end;
     613  PaintProgressBar(Offscreen.Canvas, I, xCred0, yCred0 + 17, (cred + 2) div 5,
    614614    0, 20, MainTexture);
    615   s := IntToStr(cred);
     615  S := IntToStr(cred);
    616616  RisedTextOut(Offscreen.Canvas, xCred0 + 10 -
    617     (BiColorTextWidth(Offscreen.Canvas, s) + 1) div 2, yCred0, s);
     617    (BiColorTextWidth(Offscreen.Canvas, S) + 1) div 2, yCred0, S);
    618618  case MyRO.Credibility of
    619619    0 .. 49:
    620       i := 3;
     620      I := 3;
    621621    50 .. 90:
    622       i := 0;
     622      I := 0;
    623623    91 .. 100:
    624       i := 1;
    625   end;
    626   PaintProgressBar(Offscreen.Canvas, i, xCred1, yCred1 + 17,
     624      I := 1;
     625  end;
     626  PaintProgressBar(Offscreen.Canvas, I, xCred1, yCred1 + 17,
    627627    (MyRO.Credibility + 2) div 5, 0, 20, MainTexture);
    628   s := IntToStr(MyRO.Credibility);
     628  S := IntToStr(MyRO.Credibility);
    629629  RisedTextOut(Offscreen.Canvas, xCred1 + 10 -
    630     (BiColorTextWidth(Offscreen.Canvas, s) + 1) div 2, yCred1, s);
     630    (BiColorTextWidth(Offscreen.Canvas, S) + 1) div 2, yCred1, S);
    631631
    632632  MarkUsedOffscreen(ClientWidth, ClientHeight);
     
    635635procedure TNegoDlg.Initiate;
    636636begin
    637   History[me].n := 1;
    638   History[me].Text[0] := '';
     637  History[Me].N := 1;
     638  History[Me].Text[0] := '';
    639639end;
    640640
    641641procedure TNegoDlg.Respond;
    642642begin
    643   History[me].n := 0;
     643  History[Me].N := 0;
    644644end;
    645645
    646646procedure TNegoDlg.FormMouseDown(Sender: TObject; Button: TMouseButton;
    647   Shift: TShiftState; X, Y: integer);
     647  Shift: TShiftState; X, Y: Integer);
    648648begin
    649649  if (X >= xNationPicture0) and (X < xNationPicture0 + 64) and
    650650    (Y >= yNationPicture) and (Y < yNationPicture + 48) then
    651     NatStatDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), DipMem[me].pContact)
     651    NatStatDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), DipMem[Me].pContact)
    652652  else if (X >= xNationPicture1) and (X < xNationPicture1 + 64) and
    653653    (Y >= yNationPicture) and (Y < yNationPicture + 48) then
    654     NatStatDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), me)
     654    NatStatDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), Me)
    655655end;
    656656
    657657procedure TNegoDlg.BwdBtnClick(Sender: TObject);
    658658begin
    659   dec(Page, 2);
     659  Dec(Page, 2);
    660660  SetButtonStates;
    661661  SmartUpdateContent;
     
    664664procedure TNegoDlg.FwdBtnClick(Sender: TObject);
    665665begin
    666   inc(Page, 2);
     666  Inc(Page, 2);
    667667  SetButtonStates;
    668668  SmartUpdateContent;
     
    671671procedure TNegoDlg.OkBtnClick(Sender: TObject);
    672672begin
    673   inc(History[me].n);
     673  Inc(History[Me].N);
    674674  if DipCommand = scDipOffer then
    675675    MainScreen.OfferCall(CurrentOffer)
     
    697697procedure TNegoDlg.BuildCurrentOffer;
    698698var
    699   i: integer;
     699  I: Integer;
    700700begin
    701701  CurrentOffer.nDeliver := 0;
    702702  CurrentOffer.nCost := 0;
    703   for i := 0 to 11 do
    704     if Delivers[i] <> $FFFFFFFF then
    705     begin
    706       CurrentOffer.Price[CurrentOffer.nDeliver] := Delivers[i];
    707       inc(CurrentOffer.nDeliver);
     703  for I := 0 to 11 do
     704    if Delivers[I] <> $FFFFFFFF then
     705    begin
     706      CurrentOffer.Price[CurrentOffer.nDeliver] := Delivers[I];
     707      Inc(CurrentOffer.nDeliver);
    708708    end;
    709   for i := 0 to 11 do
    710     if Costs[i] <> $FFFFFFFF then
     709  for I := 0 to 11 do
     710    if Costs[I] <> $FFFFFFFF then
    711711    begin
    712712      CurrentOffer.Price[CurrentOffer.nDeliver + CurrentOffer.nCost] :=
    713         Costs[i];
    714       inc(CurrentOffer.nCost);
     713        Costs[I];
     714      Inc(CurrentOffer.nCost);
    715715    end;
    716716end;
     
    718718procedure TNegoDlg.WantClick(Sender: TObject);
    719719var
    720   a, i, max: integer;
    721   Price: cardinal;
    722 begin
    723   if (Page <> History[me].n) or (ClientMode = scDipCancelTreaty) or
     720  A, I, Max: Integer;
     721  Price: Cardinal;
     722begin
     723  if (Page <> History[Me].N) or (ClientMode = scDipCancelTreaty) or
    724724    (ClientMode = scDipBreak) then
    725     exit;
     725    Exit;
    726726  if Costs[TButtonN(Sender).Tag and $FF] <> $FFFFFFFF then
    727727    Price := $FFFFFFFF // toggle off
     
    731731    begin
    732732      SimpleMessage(Phrases.Lookup('MAX2WANTS'));
    733       exit
     733      Exit
    734734    end;
    735735    Price := ButtonPrice[TButtonN(Sender).Tag and $FF];
    736736    if not(Price shr 24 in OppoAllowed) then
    737       exit;
     737      Exit;
    738738    case Price of
    739739      opCivilReport, opMilReport:
    740         inc(Price, DipMem[me].pContact shl 16 + MyRO.Turn);
     740        Inc(Price, DipMem[Me].pContact shl 16 + MyRO.Turn);
    741741        // !!! choose player and year!
    742742      opMoney:
     
    747747          InputDlg.ShowModal;
    748748          if InputDlg.ModalResult <> mrOK then
    749             exit;
    750           val(InputDlg.EInput.Text, a, i);
    751           if (i <> 0) or (a <= 0) or (a >= MaxMoneyPrice) then
    752             exit;
    753           inc(Price, a);
     749            Exit;
     750          val(InputDlg.EInput.Text, A, I);
     751          if (I <> 0) or (A <= 0) or (A >= MaxMoneyPrice) then
     752            Exit;
     753          Inc(Price, A);
    754754        end;
    755755      opShipParts:
     
    765765              ShowModal;
    766766              if ModalResult <> mrOK then
    767                 exit
     767                Exit
    768768            end;
    769769          ModalSelectDlg.ShowNewContent(wmModal, kEShipPart);
    770           if ModalSelectDlg.result < 0 then
    771             exit;
    772           inc(Price, ModalSelectDlg.result shl 16);
    773           max := MyRO.Ship[DipMem[me].pContact].Parts[ModalSelectDlg.result];
     770          if ModalSelectDlg.Result < 0 then
     771            Exit;
     772          Inc(Price, ModalSelectDlg.Result shl 16);
     773          Max := MyRO.Ship[DipMem[Me].pContact].Parts[ModalSelectDlg.Result];
    774774          InputDlg.Caption := Phrases.Lookup('TITLE_NUMBER');
    775775          InputDlg.EInput.Text := '';
     
    777777          InputDlg.ShowModal;
    778778          if InputDlg.ModalResult <> mrOK then
    779             exit;
    780           val(InputDlg.EInput.Text, a, i);
    781           if (i <> 0) or (a <= 0) then
    782             exit;
    783           if a > max then
    784             a := max;
    785           if a > MaxShipPartPrice then
    786             a := MaxShipPartPrice;
    787           inc(Price, a);
     779            Exit;
     780          val(InputDlg.EInput.Text, A, I);
     781          if (I <> 0) or (A <= 0) then
     782            Exit;
     783          if A > Max then
     784            A := Max;
     785          if A > MaxShipPartPrice then
     786            A := MaxShipPartPrice;
     787          Inc(Price, A);
    788788        end;
    789789      opAllTech:
    790790        begin // choose technology
    791791          ModalSelectDlg.ShowNewContent(wmModal, kChooseETech);
    792           if ModalSelectDlg.result < 0 then
    793             exit;
    794           if ModalSelectDlg.result = adAll then
     792          if ModalSelectDlg.Result < 0 then
     793            Exit;
     794          if ModalSelectDlg.Result = adAll then
    795795            Price := opAllTech
    796796          else
    797             Price := OpTech + ModalSelectDlg.result;
     797            Price := OpTech + ModalSelectDlg.Result;
    798798        end;
    799799      opAllModel:
    800800        begin // choose model
    801801          ModalSelectDlg.ShowNewContent(wmModal, kChooseEModel);
    802           if ModalSelectDlg.result < 0 then
    803             exit;
    804           if ModalSelectDlg.result = mixAll then
     802          if ModalSelectDlg.Result < 0 then
     803            Exit;
     804          if ModalSelectDlg.Result = mixAll then
    805805            Price := opAllModel
    806806          else
    807             Price := OpModel + MyRO.EnemyModel[ModalSelectDlg.result].mix;
     807            Price := OpModel + MyRO.EnemyModel[ModalSelectDlg.Result].mix;
    808808        end;
    809809      opTreaty:
    810810        begin
    811           if MyRO.Treaty[DipMem[me].pContact] < trPeace then
     811          if MyRO.Treaty[DipMem[Me].pContact] < trPeace then
    812812            Price := opTreaty + trPeace
    813813          else
    814             Price := opTreaty + MyRO.Treaty[DipMem[me].pContact] + 1;
     814            Price := opTreaty + MyRO.Treaty[DipMem[Me].pContact] + 1;
    815815        end;
    816816      { opLowTreaty:
    817817        begin
    818         if MyRO.Treaty[DipMem[me].pContact]=trNone then Price:=opTreaty+trCeaseFire
    819         else Price:=opTreaty+MyRO.Treaty[DipMem[me].pContact]-1;
     818        if MyRO.Treaty[DipMem[Me].pContact]=trNone then Price:=opTreaty+trCeaseFire
     819        else Price:=opTreaty+MyRO.Treaty[DipMem[Me].pContact]-1;
    820820        end }
    821821    end;
     
    831831procedure TNegoDlg.OfferClick(Sender: TObject);
    832832var
    833   a, i, max: integer;
    834   Price: cardinal;
    835 begin
    836   if (Page <> History[me].n) or (ClientMode = scDipCancelTreaty) or
     833  A, I, Max: Integer;
     834  Price: Cardinal;
     835begin
     836  if (Page <> History[Me].N) or (ClientMode = scDipCancelTreaty) or
    837837    (ClientMode = scDipBreak) then
    838     exit;
     838    Exit;
    839839  if Delivers[TButtonN(Sender).Tag and $FF] <> $FFFFFFFF then
    840840    Price := $FFFFFFFF // toggle off
     
    844844    begin
    845845      SimpleMessage(Phrases.Lookup('MAX2OFFERS'));
    846       exit;
     846      Exit;
    847847    end;
    848848    Price := ButtonPrice[TButtonN(Sender).Tag and $FF];
    849849    if not(Price shr 24 in MyAllowed) then
    850       exit;
     850      Exit;
    851851    case Price of
    852852      opCivilReport, opMilReport:
    853         inc(Price, me shl 16 + MyRO.Turn); // !!! choose player and year!
     853        Inc(Price, Me shl 16 + MyRO.Turn); // !!! choose player and year!
    854854      opMoney:
    855855        begin // choose amount
     
    859859          InputDlg.ShowModal;
    860860          if InputDlg.ModalResult <> mrOK then
    861             exit;
    862           val(InputDlg.EInput.Text, a, i);
    863           if (i <> 0) or (a <= 0) or (a >= MaxMoneyPrice) then
    864             exit;
    865           if (Price = opMoney) and (a > MyRO.Money) then
    866             a := MyRO.Money;
    867           inc(Price, a);
     861            Exit;
     862          val(InputDlg.EInput.Text, A, I);
     863          if (I <> 0) or (A <= 0) or (A >= MaxMoneyPrice) then
     864            Exit;
     865          if (Price = opMoney) and (A > MyRO.Money) then
     866            A := MyRO.Money;
     867          Inc(Price, A);
    868868        end;
    869869      opShipParts:
    870870        begin // choose type and number
    871871          ModalSelectDlg.ShowNewContent(wmModal, kShipPart);
    872           if ModalSelectDlg.result < 0 then
    873             exit;
    874           inc(Price, ModalSelectDlg.result shl 16);
    875           max := MyRO.Ship[me].Parts[ModalSelectDlg.result];
     872          if ModalSelectDlg.Result < 0 then
     873            Exit;
     874          Inc(Price, ModalSelectDlg.Result shl 16);
     875          Max := MyRO.Ship[Me].Parts[ModalSelectDlg.Result];
    876876          InputDlg.Caption := Phrases.Lookup('TITLE_NUMBER');
    877877          InputDlg.EInput.Text := '';
     
    879879          InputDlg.ShowModal;
    880880          if InputDlg.ModalResult <> mrOK then
    881             exit;
    882           val(InputDlg.EInput.Text, a, i);
    883           if (i <> 0) or (a <= 0) then
    884             exit;
    885           if a > max then
    886             a := max;
    887           if a > MaxShipPartPrice then
    888             a := MaxShipPartPrice;
    889           inc(Price, a);
     881            Exit;
     882          val(InputDlg.EInput.Text, A, I);
     883          if (I <> 0) or (A <= 0) then
     884            Exit;
     885          if A > Max then
     886            A := Max;
     887          if A > MaxShipPartPrice then
     888            A := MaxShipPartPrice;
     889          Inc(Price, A);
    890890        end;
    891891      opAllTech:
    892892        begin // choose technology
    893893          ModalSelectDlg.ShowNewContent(wmModal, kChooseTech);
    894           if ModalSelectDlg.result < 0 then
    895             exit;
    896           if ModalSelectDlg.result = adAll then
     894          if ModalSelectDlg.Result < 0 then
     895            Exit;
     896          if ModalSelectDlg.Result = adAll then
    897897            Price := opAllTech
    898898          else
    899             Price := OpTech + ModalSelectDlg.result;
     899            Price := OpTech + ModalSelectDlg.Result;
    900900        end;
    901901      opAllModel:
    902902        begin // choose model
    903903          ModalSelectDlg.ShowNewContent(wmModal, kChooseModel);
    904           if ModalSelectDlg.result < 0 then
    905             exit;
    906           if ModalSelectDlg.result = mixAll then
     904          if ModalSelectDlg.Result < 0 then
     905            Exit;
     906          if ModalSelectDlg.Result = mixAll then
    907907            Price := opAllModel
    908908          else
    909             Price := OpModel + ModalSelectDlg.result;
     909            Price := OpModel + ModalSelectDlg.Result;
    910910        end;
    911911      opTreaty:
    912912        begin
    913           if MyRO.Treaty[DipMem[me].pContact] < trPeace then
     913          if MyRO.Treaty[DipMem[Me].pContact] < trPeace then
    914914            Price := opTreaty + trPeace
    915915          else
    916             Price := opTreaty + MyRO.Treaty[DipMem[me].pContact] + 1;
     916            Price := opTreaty + MyRO.Treaty[DipMem[Me].pContact] + 1;
    917917        end;
    918918      { opLowTreaty:
    919919        begin
    920         if MyRO.Treaty[DipMem[me].pContact]=trNone then Price:=opTreaty+trCeaseFire
    921         else Price:=opTreaty+MyRO.Treaty[DipMem[me].pContact]-1;
     920        if MyRO.Treaty[DipMem[Me].pContact]=trNone then Price:=opTreaty+trCeaseFire
     921        else Price:=opTreaty+MyRO.Treaty[DipMem[Me].pContact]-1;
    922922        end }
    923923    end;
     
    933933procedure TNegoDlg.FastBtnClick(Sender: TObject);
    934934var
    935   NewCommand: cardinal;
    936 begin
    937   if Page <> History[me].n then
    938     exit;
     935  NewCommand: Cardinal;
     936begin
     937  if Page <> History[Me].N then
     938    Exit;
    939939  NewCommand := TButtonN(Sender).Tag and $FF + scDipStart;
    940940  if not(NewCommand - scDipStart in CommandAllowed) then
    941     exit;
     941    Exit;
    942942  if (NewCommand = scDipCancelTreaty) and
    943     (MyRO.Turn < MyRO.LastCancelTreaty[DipMem[me].pContact] + CancelTreatyTurns)
     943    (MyRO.Turn < MyRO.LastCancelTreaty[DipMem[Me].pContact] + CancelTreatyTurns)
    944944  then
    945945  begin
    946946    SimpleMessage(Phrases.Lookup('CANCELTREATYRUSH'));
    947     exit;
     947    Exit;
    948948  end;
    949949  if (NewCommand = scDipOffer) and ((ClientMode = scDipCancelTreaty) or
  • trunk/LocalPlayer/PVSB.pas

    r442 r447  
    3030    procedure Init(Max, PageSize: Integer);
    3131    procedure SetPos(Pos: Integer);
    32     function Process(const Msg: TMessage): boolean;
     32    function Process(const Msg: TMessage): Boolean;
    3333    function ProcessMouseWheel(Delta: Integer): Boolean;
    34     procedure Show(Visible: boolean);
     34    procedure Show(Visible: Boolean);
    3535    procedure EndSB;
    3636    procedure SetBorderSpacing(Top, Right, Bottom: Integer);
     
    6363end;
    6464
    65 function TPVScrollBar.Process(const Msg: TMessage): boolean;
     65function TPVScrollBar.Process(const Msg: TMessage): Boolean;
    6666var
    67   NewPos: integer;
     67  NewPos: Integer;
    6868begin
    6969    if Max < ScrollBar.PageSize then
    70       result := false
     70      Result := False
    7171    else
    7272    begin
    7373      if (Msg.wParam and $ffff) in [SB_THUMBPOSITION, SB_THUMBTRACK] then
    7474      begin
    75         result := ((Msg.wParam shr 16) and $ffff) <> ScrollBar.Position;
     75        Result := ((Msg.wParam shr 16) and $ffff) <> ScrollBar.Position;
    7676        ScrollBar.Position := (Msg.wParam shr 16) and $ffff;
    7777      end else begin
     
    9292        if NewPos > Max - ScrollBar.PageSize + 1 then
    9393          NewPos := Max - ScrollBar.PageSize + 1;
    94         result := NewPos <> ScrollBar.Position;
     94        Result := NewPos <> ScrollBar.Position;
    9595        if (NewPos <> ScrollBar.Position) or ((Msg.wParam and $ffff) = SB_ENDSCROLL) then
    9696        begin
     
    103103function TPVScrollBar.ProcessMouseWheel(Delta: Integer): Boolean;
    104104var
    105   NewPos: integer;
     105  NewPos: Integer;
    106106begin
    107107    if Max < ScrollBar.PageSize then Result := False
     
    118118end;
    119119
    120 procedure TPVScrollBar.Show(Visible: boolean);
     120procedure TPVScrollBar.Show(Visible: Boolean);
    121121begin
    122122  if not Visible or (Max < ScrollBar.PageSize) then
  • trunk/LocalPlayer/Rates.pas

    r442 r447  
    4646procedure TRatesDlg.OffscreenPaint;
    4747var
    48   p, x, y, current, max, i: integer;
    49   s, s1: string;
     48  P, X, Y, current, Max, I: Integer;
     49  S, s1: string;
    5050begin
    5151  if (OffscreenUser <> nil) and (OffscreenUser <> self) then
     
    6464  BtnFrame(Offscreen.Canvas, CloseBtn.BoundsRect, MainTexture);
    6565  Offscreen.Canvas.Font.Assign(UniFont[ftCaption]);
    66   s := Phrases.Lookup('TITLE_RATES');
     66  S := Phrases.Lookup('TITLE_RATES');
    6767  RisedTextOut(Offscreen.Canvas,
    68     (ClientWidth - BiColorTextWidth(Offscreen.Canvas, s)) div 2 - 1, 7, s);
    69 
    70   if MyRO.Wonder[woLiberty].EffectiveOwner = me then
    71     s := Phrases.Lookup('NORATES')
    72   else
    73     s := Phrases.Lookup('RATES');
     68    (ClientWidth - BiColorTextWidth(Offscreen.Canvas, S)) div 2 - 1, 7, S);
     69
     70  if MyRO.Wonder[woLiberty].EffectiveOwner = Me then
     71    S := Phrases.Lookup('NORATES')
     72  else
     73    S := Phrases.Lookup('RATES');
    7474  Offscreen.Canvas.Font.Assign(UniFont[ftNormal]);
    75   p := pos('\', s);
    76   if p = 0 then
    77     RisedTextOut(Offscreen.Canvas, (ClientWidth - BiColorTextWidth(Canvas, s))
    78       div 2, 114, s)
    79   else
    80   begin
    81     s1 := copy(s, 1, p - 1);
     75  P := Pos('\', S);
     76  if P = 0 then
     77    RisedTextOut(Offscreen.Canvas, (ClientWidth - BiColorTextWidth(Canvas, S))
     78      div 2, 114, S)
     79  else
     80  begin
     81    s1 := Copy(S, 1, P - 1);
    8282    RisedTextOut(Offscreen.Canvas,
    8383      (ClientWidth - BiColorTextWidth(Offscreen.Canvas, s1)) div 2,
    8484      114 - MessageLineSpacing div 2, s1);
    85     s1 := copy(s, p + 1, 255);
     85    s1 := Copy(S, P + 1, 255);
    8686    RisedTextOut(Offscreen.Canvas,
    8787      (ClientWidth - BiColorTextWidth(Offscreen.Canvas, s1)) div 2,
     
    9090  Offscreen.Canvas.Font.Assign(UniFont[ftSmall]);
    9191
    92   if MyRO.Wonder[woLiberty].EffectiveOwner = me then
     92  if MyRO.Wonder[woLiberty].EffectiveOwner = Me then
    9393  begin
    9494    GlowFrame(Offscreen, ClientWidth div 2 - xSizeBig div 2, 52, xSizeBig,
    95       ySizeBig, Tribe[me].Color);
     95      ySizeBig, Tribe[Me].Color);
    9696    BitBltCanvas(Offscreen.Canvas, ClientWidth div 2 - xSizeBig div 2, 52,
    9797      xSizeBig, ySizeBig, BigImp.Canvas, (woLiberty mod 7) * xSizeBig,
     
    102102    // ImageOp_CBC(Offscreen,Templates,260,40,145,112,36,36,$404000,$8B8BEB);
    103103
    104     s := Phrases.Lookup('SCIENCE');
    105     RisedTextOut(Offscreen.Canvas,
    106       16 + 120 - BiColorTextWidth(Offscreen.Canvas, s), 44, s);
    107     s := Format('%d%%', [100 - MyRO.TaxRate - MyRO.LuxRate]);
    108     RisedTextOut(Offscreen.Canvas,
    109       16 + 120 - BiColorTextWidth(Offscreen.Canvas, s), 60, s);
     104    S := Phrases.Lookup('SCIENCE');
     105    RisedTextOut(Offscreen.Canvas,
     106      16 + 120 - BiColorTextWidth(Offscreen.Canvas, S), 44, S);
     107    S := Format('%d%%', [100 - MyRO.TaxRate - MyRO.LuxRate]);
     108    RisedTextOut(Offscreen.Canvas,
     109      16 + 120 - BiColorTextWidth(Offscreen.Canvas, S), 60, S);
    110110    // PaintProgressBar(Offscreen.Canvas,2,16,81,(100-MyRO.LuxRate-MyRO.TaxRate)*120 div 100,0,120,MainTexture);
    111111
    112112    // reverse progress bar for science
    113     x := 16;
    114     y := 81;
     113    X := 16;
     114    Y := 81;
    115115    current := (100 - MyRO.LuxRate - MyRO.TaxRate) * 120 div 100;
    116     max := 120;
    117     Frame(Offscreen.Canvas, x - 1, y - 1, x + max, y + 7, $000000, $000000);
    118     RFrame(Offscreen.Canvas, x - 2, y - 2, x + max + 1, y + 8,
     116    Max := 120;
     117    Frame(Offscreen.Canvas, X - 1, Y - 1, X + Max, Y + 7, $000000, $000000);
     118    RFrame(Offscreen.Canvas, X - 2, Y - 2, X + Max + 1, Y + 8,
    119119      MainTexture.ColorBevelShade, MainTexture.ColorBevelLight);
    120120    with Offscreen.Canvas do
    121121    begin
    122       for i := 0 to current div 8 - 1 do
    123         BitBltCanvas(Offscreen.Canvas, x + max - 8 - i * 8, y, 8, 7,
     122      for I := 0 to current div 8 - 1 do
     123        BitBltCanvas(Offscreen.Canvas, X + Max - 8 - I * 8, Y, 8, 7,
    124124          HGrSystem.Data.Canvas, 104, 9 + 8 * 2);
    125       BitBltCanvas(Offscreen.Canvas, x + max - current, y, current - 8 * (current div 8), 7,
     125      BitBltCanvas(Offscreen.Canvas, X + Max - current, Y, current - 8 * (current div 8), 7,
    126126        HGrSystem.Data.Canvas, 104, 9 + 8 * 2);
    127127      Brush.Color := $000000;
    128       FillRect(Rect(x, y, x + max - current, y + 7));
     128      FillRect(Rect(X, Y, X + Max - current, Y + 7));
    129129      Brush.Style := bsClear;
    130130    end;
    131131
    132132    RisedTextOut(Offscreen.Canvas, 16 + 160, 44, Phrases.Lookup('LUX'));
    133     s := Format('%d%%', [MyRO.LuxRate]);
    134     RisedTextOut(Offscreen.Canvas,
    135       16 + 160 { +120-BiColorTextWidth(Offscreen.Canvas,s) } , 60, s);
     133    S := Format('%d%%', [MyRO.LuxRate]);
     134    RisedTextOut(Offscreen.Canvas,
     135      16 + 160 { +120-BiColorTextWidth(Offscreen.Canvas,s) } , 60, S);
    136136    PaintProgressBar(Offscreen.Canvas, 5, 16 + 160, 81,
    137137      MyRO.LuxRate * 120 div 100, 0, 120, MainTexture);
     
    144144    MainTexture.ColorBevelLight);
    145145  RisedTextOut(Offscreen.Canvas, 16 + 80, 164, Phrases.Lookup('TAXRATE'));
    146   s := Format('%d%%', [MyRO.TaxRate]);
     146  S := Format('%d%%', [MyRO.TaxRate]);
    147147  RisedTextOut(Offscreen.Canvas,
    148     16 + 80 { +120-BiColorTextWidth(Offscreen.Canvas,s) } , 180, s);
     148    16 + 80 { +120-BiColorTextWidth(Offscreen.Canvas,s) } , 180, S);
    149149  PaintProgressBar(Offscreen.Canvas, 0, 16 + 80, 201,
    150150    MyRO.TaxRate * 120 div 100, 0, 120, MainTexture);
     
    164164begin
    165165  Caption := Phrases.Lookup('TITLE_RATES');
    166   if MyRO.Wonder[woLiberty].EffectiveOwner = me then
    167   begin
    168     ScienceBtn.Visible := false;
    169     LuxBtn.Visible := false;
     166  if MyRO.Wonder[woLiberty].EffectiveOwner = Me then
     167  begin
     168    ScienceBtn.Visible := False;
     169    LuxBtn.Visible := False;
    170170  end
    171171  else
    172172  begin
    173     ScienceBtn.Visible := true;
    174     LuxBtn.Visible := true;
     173    ScienceBtn.Visible := True;
     174    LuxBtn.Visible := True;
    175175  end;
    176176  OffscreenPaint;
     
    184184procedure TRatesDlg.TaxLuxBtnClick(Sender: TObject);
    185185var
    186   NewTax, NewLux: integer;
     186  NewTax, NewLux: Integer;
    187187begin
    188188  NewTax := MyRO.TaxRate div 10;
     
    191191  begin
    192192    if NewTax < 10 then
    193       inc(NewTax);
     193      Inc(NewTax);
    194194    if NewTax + NewLux > 10 then
    195       dec(NewLux);
     195      Dec(NewLux);
    196196  end
    197197  else if (Sender = TaxDownBtn) and (NewTax > 0) then
    198     dec(NewTax)
     198    Dec(NewTax)
    199199  else if (Sender = ScienceBtn) and (NewLux > 0) then
    200     dec(NewLux)
     200    Dec(NewLux)
    201201  else if (Sender = LuxBtn) and (NewLux + NewTax < 100) then
    202     inc(NewLux);
    203   if Server(sSetRates, me, NewTax + NewLux shl 4, nil^) <> eNotChanged then
     202    Inc(NewLux);
     203  if Server(sSetRates, Me, NewTax + NewLux shl 4, nil^) <> eNotChanged then
    204204  begin
    205205    CityOptimizer_BeginOfTurn;
    206206    SmartUpdateContent;
    207     MainScreen.UpdateViews(true);
     207    MainScreen.UpdateViews(True);
    208208  end;
    209209end;
  • trunk/LocalPlayer/Select.pas

    r442 r447  
    3131      WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
    3232    procedure PaintBox1MouseMove(Sender: TObject; Shift: TShiftState;
    33       x, y: integer);
     33      X, Y: Integer);
    3434    procedure FormCreate(Sender: TObject);
    3535    procedure FormDestroy(Sender: TObject);
    3636    procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
    37       Shift: TShiftState; x, y: integer);
     37      Shift: TShiftState; X, Y: Integer);
    3838    procedure FormPaint(Sender: TObject);
    3939    procedure CloseBtnClick(Sender: TObject);
    40     procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
     40    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    4141    procedure FormShow(Sender: TObject);
    4242    procedure ModeBtnClick(Sender: TObject);
    4343    procedure ToggleBtnClick(Sender: TObject);
    44     procedure FormKeyDown(Sender: TObject; var Key: word; Shift: TShiftState);
     44    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    4545    procedure PlayerClick(Sender: TObject);
    4646  private
     
    5959    Lines: array [0 .. MaxLayer - 1] of Integer;
    6060    FirstShrinkedLine: array [0 .. MaxLayer - 1] of Integer;
    61     code: array [0 .. MaxLayer - 1, 0 .. 4095] of Integer;
     61    Code: array [0 .. MaxLayer - 1, 0 .. 4095] of Integer;
    6262    Column: array [0 .. nPl - 1] of Integer;
    6363    Closable: Boolean;
     
    6666    procedure ScrollBarUpdate(Sender: TObject);
    6767    procedure InitLines;
    68     procedure line(ca: TCanvas; l: integer; NonText, lit: boolean);
    69     function RenameCity(cix: integer): boolean;
    70     function RenameModel(mix: integer): boolean;
     68    procedure Line(ca: TCanvas; L: Integer; NonText, lit: Boolean);
     69    function RenameCity(cix: Integer): Boolean;
     70    function RenameModel(mix: Integer): Boolean;
    7171    procedure OnScroll(var Msg: TMessage); message WM_VSCROLL;
    7272    procedure OnMouseLeave(var Msg: TMessage); message CM_MOUSELEAVE;
    7373  public
    74     result: integer;
    75     function OnlyChoice(TestKind: TListKind): integer;
     74    Result: Integer;
     75    function OnlyChoice(TestKind: TListKind): Integer;
    7676    // -2=empty, -1=ambiguous, other=only choice
    7777    procedure OffscreenPaint; override;
    7878    procedure ShowNewContent(NewMode: TWindowMode; ListKind: TListKind);
    79     procedure ShowNewContent_CityProject(NewMode: TWindowMode; cix: integer);
    80     procedure ShowNewContent_MilReport(NewMode: TWindowMode; p: integer);
     79    procedure ShowNewContent_CityProject(NewMode: TWindowMode; cix: Integer);
     80    procedure ShowNewContent_MilReport(NewMode: TWindowMode; P: Integer);
    8181    procedure EcoChange;
    8282    procedure TechChange;
     
    135135procedure TListDlg.CloseBtnClick(Sender: TObject);
    136136begin
    137   Closable := true;
     137  Closable := True;
    138138  Close;
    139139end;
    140140
    141 procedure TListDlg.FormCloseQuery(Sender: TObject; var CanClose: boolean);
     141procedure TListDlg.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    142142begin
    143143  CanClose := Closable or not(Kind in MustChooseKind);
     
    149149  if ScrollBar.Process(Msg) then  begin
    150150    Selected := -2;
    151     SmartUpdateContent(true);
     151    SmartUpdateContent(True);
    152152  end;
    153153  }
     
    158158  if not Closable and (Selected <> -2) then
    159159  begin
    160     line(Canvas, Selected, false, false);
     160    Line(Canvas, Selected, False, False);
    161161    Selected := -2;
    162162  end;
     
    165165procedure TListDlg.FormPaint(Sender: TObject);
    166166var
    167   s: string;
     167  S: string;
    168168begin
    169169  inherited;
    170170  Canvas.Font.Assign(UniFont[ftNormal]);
    171171  if Selected <> -2 then
    172     line(Canvas, Selected, false, true);
    173   s := '';
     172    Line(Canvas, Selected, False, True);
     173  S := '';
    174174  if (Kind = kAdvance) and (MyData.FarTech <> adNone) then
    175     s := Format(Phrases.Lookup('TECHFOCUS'),
     175    S := Format(Phrases.Lookup('TECHFOCUS'),
    176176      [Phrases.Lookup('ADVANCES', MyData.FarTech)])
    177177  else if Kind = kModels then
    178     s := Tribe[me].TPhrase('SHORTNAME')
     178    S := Tribe[Me].TPhrase('SHORTNAME')
    179179  else if Kind = kEModels then
    180     s := Tribe[pView].TPhrase('SHORTNAME') + ' (' +
     180    S := Tribe[pView].TPhrase('SHORTNAME') + ' (' +
    181181      TurnToString(MyRO.EnemyReport[pView].TurnOfMilReport) + ')';
    182   if s <> '' then
     182  if S <> '' then
    183183    LoweredTextOut(Canvas, -1, MainTexture,
    184       (ClientWidth - BiColorTextWidth(Canvas, s)) div 2, 31, s);
     184      (ClientWidth - BiColorTextWidth(Canvas, S)) div 2, 31, S);
    185185  if not MultiPage and (Kind in [kProject, kAdvance, kFarAdvance]) and not Phrases2FallenBackToEnglish
    186186  then
    187187  begin
    188     s := Phrases2.Lookup('SHIFTCLICK');
     188    S := Phrases2.Lookup('SHIFTCLICK');
    189189    LoweredTextOut(Canvas, -2, MainTexture,
    190       (ClientWidth - BiColorTextWidth(Canvas, s)) div 2, ClientHeight - 29, s);
    191   end;
    192 end;
    193 
    194 procedure TListDlg.line(ca: TCanvas; l: integer; NonText, lit: boolean);
     190      (ClientWidth - BiColorTextWidth(Canvas, S)) div 2, ClientHeight - 29, S);
     191  end;
     192end;
     193
     194procedure TListDlg.Line(ca: TCanvas; L: Integer; NonText, lit: Boolean);
    195195// paint a line
    196196
    197   procedure DisplayProject(x, y, pix: integer);
     197  procedure DisplayProject(X, Y, pix: Integer);
    198198  begin
    199199    if pix and (cpType or cpImp) = 0 then
    200       with Tribe[me].ModelPicture[pix and cpIndex] do
    201         Sprite(offscreen, HGr, x, y, 64, 48, pix mod 10 * 65 + 1,
     200      with Tribe[Me].ModelPicture[pix and cpIndex] do
     201        Sprite(Offscreen, HGr, X, Y, 64, 48, pix mod 10 * 65 + 1,
    202202          pix div 10 * 49 + 1)
    203203    else
    204204    begin
    205       Frame(offscreen.Canvas, x + (16 - 1), y + (16 - 2), x + (16 + xSizeSmall),
    206         y + (16 - 1 + ySizeSmall), MainTexture.ColorBevelLight,
     205      Frame(Offscreen.Canvas, X + (16 - 1), Y + (16 - 2), X + (16 + xSizeSmall),
     206        Y + (16 - 1 + ySizeSmall), MainTexture.ColorBevelLight,
    207207        MainTexture.ColorBevelShade);
    208208      if pix and cpType = 0 then
    209209        if (pix and cpIndex = imPalace) and (MyRO.Government <> gAnarchy) then
    210           BitBltCanvas(offscreen.Canvas, x + 16, y + (16 - 1), xSizeSmall,
     210          BitBltCanvas(Offscreen.Canvas, X + 16, Y + (16 - 1), xSizeSmall,
    211211            ySizeSmall, SmallImp.Canvas, (MyRO.Government - 1) *
    212212            xSizeSmall, ySizeSmall)
    213213        else
    214           BitBltCanvas(offscreen.Canvas, x + 16, y + (16 - 1), xSizeSmall,
     214          BitBltCanvas(Offscreen.Canvas, X + 16, Y + (16 - 1), xSizeSmall,
    215215            ySizeSmall, SmallImp.Canvas, pix and cpIndex mod 7 *
    216216            xSizeSmall, (pix and cpIndex + SystemIconLines * 7) div 7 *
    217217            ySizeSmall)
    218218      else
    219         BitBltCanvas(offscreen.Canvas, x + 16, y + (16 - 1), xSizeSmall,
     219        BitBltCanvas(Offscreen.Canvas, X + 16, Y + (16 - 1), xSizeSmall,
    220220          ySizeSmall, SmallImp.Canvas, (3 + pix and cpIndex) *
    221221          xSizeSmall, 0);
     
    223223  end;
    224224
    225   procedure ReplaceText(x, y, Color: integer; s: string);
     225  procedure ReplaceText(X, Y, Color: Integer; S: string);
    226226  var
    227227    TextSize: TSize;
     
    229229    if ca = Canvas then
    230230    begin
    231       TextSize.cx := BiColorTextWidth(ca, s);
    232       TextSize.cy := ca.TextHeight(s);
    233       if y + TextSize.cy >= TitleHeight + InnerHeight then
    234         TextSize.cy := TitleHeight + InnerHeight - y;
    235       Fill(ca, x, y, TextSize.cx, TextSize.cy, (Maintexture.Width - ClientWidth)
     231      TextSize.cx := BiColorTextWidth(ca, S);
     232      TextSize.cy := ca.TextHeight(S);
     233      if Y + TextSize.cy >= TitleHeight + InnerHeight then
     234        TextSize.cy := TitleHeight + InnerHeight - Y;
     235      Fill(ca, X, Y, TextSize.cx, TextSize.cy, (Maintexture.Width - ClientWidth)
    236236        div 2, (Maintexture.Height - ClientHeight) div 2);
    237237    end;
    238     LoweredTextOut(ca, Color, MainTexture, x, y, s);
     238    LoweredTextOut(ca, Color, MainTexture, X, Y, S);
    239239  end;
    240240
    241241var
    242   icon, ofs, x, y, y0, lix, i, j, TextColor, Available, first, test,
    243     FutureCount, growth, TrueFood, TrueProd: integer;
     242  icon, ofs, X, Y, y0, lix, I, J, TextColor, Available, first, Test,
     243    FutureCount, growth, TrueFood, TrueProd: Integer;
    244244  CityReport: TCityReportNew;
    245245  mox: ^TModelInfo;
    246   s, number: string;
    247   CanGrow: boolean;
    248 begin
    249   lix := code[Layer, ScrollBar.Position + l];
    250   y0 := 2 + (l + 1) * LineDistance;
    251   if ScrollBar.Position + l >= FirstShrinkedLine[Layer] then
    252     ofs := (ScrollBar.Position + l - FirstShrinkedLine[Layer]) and 1 * 33
     246  S, number: string;
     247  CanGrow: Boolean;
     248begin
     249  lix := Code[Layer, ScrollBar.Position + L];
     250  y0 := 2 + (L + 1) * LineDistance;
     251  if ScrollBar.Position + L >= FirstShrinkedLine[Layer] then
     252    ofs := (ScrollBar.Position + L - FirstShrinkedLine[Layer]) and 1 * 33
    253253  else { if FirstShrinkedLine[Layer]<Lines[Layer] then }
    254254    ofs := 33;
     
    257257    with MyCity[lix] do
    258258    begin
    259       x := 104 - 76;
    260       y := y0;
     259      X := 104 - 76;
     260      Y := y0;
    261261      if ca = Canvas then
    262262      begin
    263         x := x + SideFrame;
    264         y := y + TitleHeight;
     263        X := X + SideFrame;
     264        Y := Y + TitleHeight;
    265265      end;
    266266      if lit then
     
    268268      else
    269269        TextColor := -1;
    270       s := CityName(ID);
    271       while BiColorTextWidth(ca, s) > CityNameSpace do
    272         delete(s, length(s), 1);
    273       ReplaceText(x + 15, y, TextColor, s);
     270      S := CityName(ID);
     271      while BiColorTextWidth(ca, S) > CityNameSpace do
     272        Delete(S, Length(S), 1);
     273      ReplaceText(X + 15, Y, TextColor, S);
    274274
    275275      if NonText then
    276         with offscreen.Canvas do
     276        with Offscreen.Canvas do
    277277        begin // city size
    278           brush.Color := $000000;
    279           fillrect(rect(x - 4 - 11, y + 1, x - 4 + 13, y + 21));
    280           brush.Color := $FFFFFF;
    281           fillrect(rect(x - 4 - 12, y, x - 4 + 12, y + 20));
    282           brush.style := bsClear;
     278          Brush.Color := $000000;
     279          FillRect(rect(X - 4 - 11, Y + 1, X - 4 + 13, Y + 21));
     280          Brush.Color := $FFFFFF;
     281          FillRect(rect(X - 4 - 12, Y, X - 4 + 12, Y + 20));
     282          Brush.style := bsClear;
    283283          Font.Color := $000000;
    284           s := inttostr(MyCity[lix].Size);
    285           TextOut(x - 4 - textwidth(s) div 2, y, s);
     284          S := IntToStr(MyCity[lix].Size);
     285          TextOut(X - 4 - textwidth(S) div 2, Y, S);
    286286        end;
    287287
     
    289289      begin
    290290        first := -1;
    291         for j := 0 to nCityEventPriority - 1 do
    292           if (Flags and CityRepMask and CityEventPriority[j] <> 0) then
    293           begin
    294             first := j;
     291        for J := 0 to nCityEventPriority - 1 do
     292          if (Flags and CityRepMask and CityEventPriority[J] <> 0) then
     293          begin
     294            first := J;
    295295            Break;
    296296          end;
    297297        if first >= 0 then
    298298        begin
    299           i := 0;
    300           test := 1;
    301           while test < CityEventPriority[first] do
    302           begin
    303             inc(i);
    304             inc(test, test);
    305           end;
    306           s := CityEventName(i);
     299          I := 0;
     300          Test := 1;
     301          while Test < CityEventPriority[first] do
     302          begin
     303            Inc(I);
     304            Inc(Test, Test);
     305          end;
     306          S := CityEventName(I);
    307307          { if CityEventPriority[first]=chNoGrowthWarning then
    308308            if Built[imAqueduct]=0 then
    309             s:=Format(s,[Phrases.Lookup('IMPROVEMENTS',imAqueduct)])
    310             else begin s:=Format(s,[Phrases.Lookup('IMPROVEMENTS',imSewer)]); i:=17 end; }
    311           ReplaceText(x + (CityNameSpace + 4 + 40 + 18 + 8), y, TextColor, s);
     309            S:=Format(S,[Phrases.Lookup('IMPROVEMENTS',imAqueduct)])
     310            else begin S:=Format(S,[Phrases.Lookup('IMPROVEMENTS',imSewer)]); I:=17 end; }
     311          ReplaceText(X + (CityNameSpace + 4 + 40 + 18 + 8), Y, TextColor, S);
    312312          if NonText then
    313313          begin
    314             Sprite(offscreen, HGrSystem, 105 - 76 + CityNameSpace + 4 + 40,
    315               y0 + 1, 18, 18, 1 + i mod 3 * 19, 1 + i div 3 * 19);
    316             x := InnerWidth - 26;
    317             for j := nCityEventPriority - 1 downto first + 1 do
    318               if (Flags and CityRepMask and CityEventPriority[j] <> 0) then
     314            Sprite(Offscreen, HGrSystem, 105 - 76 + CityNameSpace + 4 + 40,
     315              y0 + 1, 18, 18, 1 + I mod 3 * 19, 1 + I div 3 * 19);
     316            X := InnerWidth - 26;
     317            for J := nCityEventPriority - 1 downto first + 1 do
     318              if (Flags and CityRepMask and CityEventPriority[J] <> 0) then
    319319              begin
    320                 i := 0;
    321                 test := 1;
    322                 while test < CityEventPriority[j] do
     320                I := 0;
     321                Test := 1;
     322                while Test < CityEventPriority[J] do
    323323                begin
    324                   inc(i);
    325                   inc(test, test);
     324                  Inc(I);
     325                  Inc(Test, Test);
    326326                end;
    327                 if (CityEventPriority[j] = chNoGrowthWarning) and
     327                if (CityEventPriority[J] = chNoGrowthWarning) and
    328328                  (Built[imAqueduct] > 0) then
    329                   i := 17;
    330                 Sprite(offscreen, HGrSystem, x, y0 + 1, 18, 18,
    331                   1 + i mod 3 * 19, 1 + i div 3 * 19);
    332                 dec(x, 20);
     329                  I := 17;
     330                Sprite(Offscreen, HGrSystem, X, y0 + 1, 18, 18,
     331                  1 + I mod 3 * 19, 1 + I div 3 * 19);
     332                Dec(X, 20);
    333333              end;
    334334          end;
     
    340340        CityReport.HypoTaxRate := -1;
    341341        CityReport.HypoLuxuryRate := -1;
    342         Server(sGetCityReportNew, me, lix, CityReport);
     342        Server(sGetCityReportNew, Me, lix, CityReport);
    343343        TrueFood := Food;
    344344        TrueProd := Prod;
    345         if supervising then
     345        if Supervising then
    346346        begin // normalize city from after-turn state
    347           dec(TrueFood, CityReport.FoodSurplus);
     347          Dec(TrueFood, CityReport.FoodSurplus);
    348348          if TrueFood < 0 then
    349349            TrueFood := 0; // shouldn't happen
    350           dec(TrueProd, CityReport.Production);
     350          Dec(TrueProd, CityReport.Production);
    351351          if TrueProd < 0 then
    352352            TrueProd := 0; // shouldn't happen
    353353        end;
    354354
    355         s := ''; // disorder info
     355        S := ''; // disorder info
    356356        if Flags and chCaptured <> 0 then
    357           s := Phrases.Lookup('CITYEVENTS', 14)
     357          S := Phrases.Lookup('CITYEVENTS', 14)
    358358        else if CityReport.HappinessBalance < 0 then
    359           s := Phrases.Lookup('CITYEVENTS', 0);
    360         if s <> '' then
     359          S := Phrases.Lookup('CITYEVENTS', 0);
     360        if S <> '' then
    361361        begin { disorder }
    362362          if NonText then
    363363          begin
    364             DarkGradient(offscreen.Canvas, 99 + 31 + CityNameSpace + 4,
     364            DarkGradient(Offscreen.Canvas, 99 + 31 + CityNameSpace + 4,
    365365              y0 + 2, 131, 3);
    366366            ca.Font.Assign(UniFont[ftSmall]);
    367             RisedTextout(offscreen.Canvas, 103 + CityNameSpace + 4 + 31,
    368               y0 + 1, s);
     367            RisedTextout(Offscreen.Canvas, 103 + CityNameSpace + 4 + 31,
     368              y0 + 1, S);
    369369            ca.Font.Assign(UniFont[ftNormal]);
    370370          end;
     
    373373        begin
    374374          { s:=IntToStr(CityReport.FoodSurplus);
    375             ReplaceText(x+(CityNameSpace+4+48)-BiColorTextWidth(ca,s),y,TextColor,s); }
    376           s := inttostr(CityReport.Science);
    377           ReplaceText(x + CityNameSpace + 4 + 370 + 48 - BiColorTextWidth(ca,
    378             s), y, TextColor, s);
    379           s := inttostr(CityReport.Production);
    380           ReplaceText(x + CityNameSpace + 4 + 132 - BiColorTextWidth(ca, s), y,
    381             TextColor, s);
     375            ReplaceText(X+(CityNameSpace+4+48)-BiColorTextWidth(ca,S),Y,TextColor,S); }
     376          S := IntToStr(CityReport.Science);
     377          ReplaceText(X + CityNameSpace + 4 + 370 + 48 - BiColorTextWidth(ca,
     378            S), Y, TextColor, S);
     379          S := IntToStr(CityReport.Production);
     380          ReplaceText(X + CityNameSpace + 4 + 132 - BiColorTextWidth(ca, S), Y,
     381            TextColor, S);
    382382          if NonText then
    383383          begin
    384384            // Sprite(offscreen,HGrSystem,x+CityNameSpace+4+333+1,y+6,10,10,66,115);
    385             Sprite(offscreen, HGrSystem, x + CityNameSpace + 4 + 370 + 48 + 1,
    386               y + 6, 10, 10, 77, 126);
    387             Sprite(offscreen, HGrSystem, x + CityNameSpace + 4 + 132 + 1, y + 6,
     385            Sprite(Offscreen, HGrSystem, X + CityNameSpace + 4 + 370 + 48 + 1,
     386              Y + 6, 10, 10, 77, 126);
     387            Sprite(Offscreen, HGrSystem, X + CityNameSpace + 4 + 132 + 1, Y + 6,
    388388              10, 10, 88, 115);
    389389          end;
    390390        end;
    391         s := inttostr(CityTaxBalance(lix, CityReport));
    392         ReplaceText(x + CityNameSpace + 4 + 370 - BiColorTextWidth(ca, s), y,
    393           TextColor, s);
     391        S := IntToStr(CityTaxBalance(lix, CityReport));
     392        ReplaceText(X + CityNameSpace + 4 + 370 - BiColorTextWidth(ca, S), Y,
     393          TextColor, S);
    394394        // if Project and (cpImp+cpIndex)<>cpImp+imTrGoods then
    395395        // ReplaceText(x+CityNameSpace+4+333+1,y,TextColor,Format('%d/%d',[TrueProd,CityReport.ProjectCost]));
    396396        if NonText then
    397397        begin
    398           Sprite(offscreen, HGrSystem, x + CityNameSpace + 4 + 370 + 1, y + 6,
     398          Sprite(Offscreen, HGrSystem, X + CityNameSpace + 4 + 370 + 1, Y + 6,
    399399            10, 10, 132, 115);
    400400
     
    404404            ((Size < NeedAqueductSize) or (Built[imAqueduct] = 1) and
    405405            (Size < NeedSewerSize) or (Built[imSewer] = 1));
    406           PaintRelativeProgressBar(offscreen.Canvas, 1, x + 15 + CityNameSpace +
    407             4, y + 7, 68, TrueFood, CutCityFoodSurplus(CityReport.FoodSurplus,
     406          PaintRelativeProgressBar(Offscreen.Canvas, 1, X + 15 + CityNameSpace +
     407            4, Y + 7, 68, TrueFood, CutCityFoodSurplus(CityReport.FoodSurplus,
    408408            (MyRO.Government <> gAnarchy) and (Flags and chCaptured = 0),
    409409            MyRO.Government, Size), CityReport.Storage, CanGrow, MainTexture);
     
    411411          if Project <> cpImp + imTrGoods then
    412412          begin
    413             DisplayProject(ofs + 104 - 76 + x - 28 + CityNameSpace + 4 + 206 -
     413            DisplayProject(ofs + 104 - 76 + X - 28 + CityNameSpace + 4 + 206 -
    414414              60, y0 - 15, Project);
    415415
     
    419419              (Flags and chCaptured <> 0) then
    420420              growth := 0;
    421             PaintRelativeProgressBar(offscreen.Canvas, 4,
    422               x + CityNameSpace + 4 + 304 - 60 + 9, y + 7, 68, TrueProd, growth,
    423               CityReport.ProjectCost, true, MainTexture);
     421            PaintRelativeProgressBar(Offscreen.Canvas, 4,
     422              X + CityNameSpace + 4 + 304 - 60 + 9, Y + 7, 68, TrueProd, growth,
     423              CityReport.ProjectCost, True, MainTexture);
    424424          end;
    425425        end;
     
    428428  else if Kind in [kModels, kEModels] then
    429429  begin
    430     x := 104;
    431     y := y0;
     430    X := 104;
     431    Y := y0;
    432432    if ca = Canvas then
    433433    begin
    434       x := x + SideFrame;
    435       y := y + TitleHeight;
     434      X := X + SideFrame;
     435      Y := Y + TitleHeight;
    436436    end;
    437437    if lit then
     
    442442    begin
    443443      Available := 0;
    444       for j := 0 to MyRO.nUn - 1 do
    445         if (MyUn[j].Loc >= 0) and (MyUn[j].mix = lix) then
    446           inc(Available);
     444      for J := 0 to MyRO.nUn - 1 do
     445        if (MyUn[J].Loc >= 0) and (MyUn[J].mix = lix) then
     446          Inc(Available);
    447447      if MainScreen.mNames.Checked then
    448         s := Tribe[me].ModelName[lix]
     448        S := Tribe[Me].ModelName[lix]
    449449      else
    450         s := Format(Tribe[me].TPhrase('GENMODEL'), [lix]);
     450        S := Format(Tribe[Me].TPhrase('GENMODEL'), [lix]);
    451451      if NonText then
    452452        DisplayProject(8 + ofs, y0 - 15, lix);
     
    456456      Available := MyRO.EnemyReport[pView].UnCount[lix];
    457457      if MainScreen.mNames.Checked then
    458         s := Tribe[pView].ModelName[lix]
     458        S := Tribe[pView].ModelName[lix]
    459459      else
    460         s := Format(Tribe[pView].TPhrase('GENMODEL'), [lix]);
     460        S := Format(Tribe[pView].TPhrase('GENMODEL'), [lix]);
    461461      if NonText then
    462462        with Tribe[pView].ModelPicture[lix] do
    463           Sprite(offscreen, HGr, 8 + ofs, y0 - 15, 64, 48, pix mod 10 * 65 + 1,
     463          Sprite(Offscreen, HGr, 8 + ofs, y0 - 15, 64, 48, pix mod 10 * 65 + 1,
    464464            pix div 10 * 49 + 1);
    465465    end;
    466466    if Available > 0 then
    467       ReplaceText(x + 32 - BiColorTextWidth(ca, inttostr(Available)), y,
    468         TextColor, inttostr(Available));
    469     ReplaceText(x + 40, y, TextColor, s);
     467      ReplaceText(X + 32 - BiColorTextWidth(ca, IntToStr(Available)), Y,
     468        TextColor, IntToStr(Available));
     469    ReplaceText(X + 40, Y, TextColor, S);
    470470  end
    471471  else
     
    474474      kAllEModels, kChooseEModel:
    475475        if lix = mixAll then
    476           s := Phrases.Lookup('PRICECAT_ALLMODEL')
     476          S := Phrases.Lookup('PRICECAT_ALLMODEL')
    477477        else
    478478        begin
     
    480480          if MainScreen.mNames.Checked then
    481481          begin
    482             s := Tribe[mox.Owner].ModelName[mox.mix];
    483             if (Kind = kAllEModels) and (code[1, ScrollBar.Position + l] = 0) then
    484               s := Format(Tribe[mox.Owner].TPhrase('OWNED'), [s]);
     482            S := Tribe[mox.Owner].ModelName[mox.mix];
     483            if (Kind = kAllEModels) and (Code[1, ScrollBar.Position + L] = 0) then
     484              S := Format(Tribe[mox.Owner].TPhrase('OWNED'), [S]);
    485485          end
    486486          else
    487             s := Format(Tribe[mox.Owner].TPhrase('GENMODEL'), [mox.mix]);
     487            S := Format(Tribe[mox.Owner].TPhrase('GENMODEL'), [mox.mix]);
    488488          if NonText then
    489489            with Tribe[mox.Owner].ModelPicture[mox.mix] do
    490               Sprite(offscreen, HGr, 8 + ofs, y0 - 15, 64, 48,
     490              Sprite(Offscreen, HGr, 8 + ofs, y0 - 15, 64, 48,
    491491                pix mod 10 * 65 + 1, pix div 10 * 49 + 1);
    492492        end;
    493493      kChooseModel:
    494494        if lix = mixAll then
    495           s := Phrases.Lookup('PRICECAT_ALLMODEL')
     495          S := Phrases.Lookup('PRICECAT_ALLMODEL')
    496496        else
    497497        begin
    498           s := Tribe[me].ModelName[lix];
     498          S := Tribe[Me].ModelName[lix];
    499499          if NonText then
    500500            DisplayProject(8 + ofs, y0 - 15, lix);
     
    503503        begin
    504504          if lix and cpType <> 0 then
    505             s := Phrases.Lookup('CITYTYPE', lix and cpIndex)
     505            S := Phrases.Lookup('CITYTYPE', lix and cpIndex)
    506506          else if lix and cpImp = 0 then
    507507            with MyModel[lix and cpIndex] do
    508508            begin
    509               s := Tribe[me].ModelName[lix and cpIndex];
     509              S := Tribe[Me].ModelName[lix and cpIndex];
    510510              if lix and cpConscripts <> 0 then
    511                 s := Format(Phrases.Lookup('CONSCRIPTS'), [s]);
     511                S := Format(Phrases.Lookup('CONSCRIPTS'), [S]);
    512512            end
    513513          else
    514514          begin
    515             s := Phrases.Lookup('IMPROVEMENTS', lix and cpIndex);
     515            S := Phrases.Lookup('IMPROVEMENTS', lix and cpIndex);
    516516            if (Imp[lix and cpIndex].Kind in [ikNatLocal, ikNatGlobal]) and
    517517              (MyRO.NatBuilt[lix and cpIndex] > 0) or
     
    519519              (MyCity[cixProject].Built[imPower] + MyCity[cixProject].Built
    520520              [imHydro] + MyCity[cixProject].Built[imNuclear] > 0) then
    521               s := Format(Phrases.Lookup('NATEXISTS'), [s]);
     521              S := Format(Phrases.Lookup('NATEXISTS'), [S]);
    522522          end;
    523523          if NonText then
     
    527527        begin
    528528          if lix = adAll then
    529             s := Phrases.Lookup('PRICECAT_ALLTECH')
     529            S := Phrases.Lookup('PRICECAT_ALLTECH')
    530530          else
    531531          begin
    532532            if lix = adNexus then
    533               s := Phrases.Lookup('NEXUS')
     533              S := Phrases.Lookup('NEXUS')
    534534            else if lix = adNone then
    535               s := Phrases.Lookup('NOFARTECH')
     535              S := Phrases.Lookup('NOFARTECH')
    536536            else if lix = adMilitary then
    537               s := Phrases.Lookup('INITUNIT')
     537              S := Phrases.Lookup('INITUNIT')
    538538            else
    539539            begin
    540               s := Phrases.Lookup('ADVANCES', lix);
     540              S := Phrases.Lookup('ADVANCES', lix);
    541541              if (Kind = kAdvance) and (lix in FutureTech) then
    542542                if MyRO.Tech[lix] < tsApplicable then
    543                   s := s + ' 1'
     543                  S := S + ' 1'
    544544                else
    545                   s := s + ' ' + inttostr(MyRO.Tech[lix] + 1);
     545                  S := S + ' ' + IntToStr(MyRO.Tech[lix] + 1);
    546546            end;
    547             if BiColorTextWidth(ca, s) > TechNameSpace + 8 then
     547            if BiColorTextWidth(ca, S) > TechNameSpace + 8 then
    548548            begin
    549549              repeat
    550                 delete(s, length(s), 1);
    551               until BiColorTextWidth(ca, s) <= TechNameSpace + 5;
    552               s := s + '.';
     550                Delete(S, Length(S), 1);
     551              until BiColorTextWidth(ca, S) <= TechNameSpace + 5;
     552              S := S + '.';
    553553            end;
    554554
     
    557557              if lix = adNexus then
    558558              begin
    559                 Frame(offscreen.Canvas, (8 + 16 - 1), y0 - 1, (8 + 16 + 36),
     559                Frame(Offscreen.Canvas, (8 + 16 - 1), y0 - 1, (8 + 16 + 36),
    560560                  y0 + 20, MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
    561                 Dump(offscreen, HGrSystem, (8 + 16), y0, 36, 20, 223, 295)
     561                Dump(Offscreen, HGrSystem, (8 + 16), y0, 36, 20, 223, 295)
    562562              end
    563563              else if lix = adNone then
    564564              begin
    565                 Frame(offscreen.Canvas, (8 + 16 - 1), y0 - 1, (8 + 16 + 36),
     565                Frame(Offscreen.Canvas, (8 + 16 - 1), y0 - 1, (8 + 16 + 36),
    566566                  y0 + 20, MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
    567                 Dump(offscreen, HGrSystem, (8 + 16), y0, 36, 20, 260, 295)
     567                Dump(Offscreen, HGrSystem, (8 + 16), y0, 36, 20, 260, 295)
    568568              end
    569569              else if lix = adMilitary then
    570570              begin
    571                 Frame(offscreen.Canvas, (8 + 16 - 1), y0 - 1, (8 + 16 + 36),
     571                Frame(Offscreen.Canvas, (8 + 16 - 1), y0 - 1, (8 + 16 + 36),
    572572                  y0 + 20, MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
    573                 Dump(offscreen, HGrSystem, (8 + 16), y0, 36, 20, 38, 295)
     573                Dump(Offscreen, HGrSystem, (8 + 16), y0, 36, 20, 38, 295)
    574574              end
    575575              else
    576576              begin
    577                 Frame(offscreen.Canvas, (8 + 16 - 1), y0 - 1,
     577                Frame(Offscreen.Canvas, (8 + 16 - 1), y0 - 1,
    578578                  (8 + 16 + xSizeSmall), y0 + ySizeSmall,
    579579                  MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
    580580                if AdvIcon[lix] < 84 then
    581                   BitBltCanvas(offscreen.Canvas, (8 + 16), y0, xSizeSmall,
     581                  BitBltCanvas(Offscreen.Canvas, (8 + 16), y0, xSizeSmall,
    582582                    ySizeSmall, SmallImp.Canvas,
    583583                    (AdvIcon[lix] + SystemIconLines * 7) mod 7 * xSizeSmall,
     
    585585                    ySizeSmall)
    586586                else
    587                   Dump(offscreen, HGrSystem, (8 + 16), y0, 36, 20,
     587                  Dump(Offscreen, HGrSystem, (8 + 16), y0, 36, 20,
    588588                    1 + (AdvIcon[lix] - 84) mod 8 * 37,
    589589                    295 + (AdvIcon[lix] - 84) div 8 * 21);
    590                 j := AdvValue[lix] div 1000;
    591                 BitBltCanvas(offscreen.Canvas, (8 + 16 - 4), y0 + 2, 14, 14,
    592                   HGrSystem.Mask.Canvas, 127 + j * 15,
     590                J := AdvValue[lix] div 1000;
     591                BitBltCanvas(Offscreen.Canvas, (8 + 16 - 4), y0 + 2, 14, 14,
     592                  HGrSystem.Mask.Canvas, 127 + J * 15,
    593593                  85, SRCAND);
    594                 Sprite(offscreen, HGrSystem, (8 + 16 - 5), y0 + 1, 14, 14,
    595                   127 + j * 15, 85);
     594                Sprite(Offscreen, HGrSystem, (8 + 16 - 5), y0 + 1, 14, 14,
     595                  127 + J * 15, 85);
    596596              end;
    597597            end;
     
    600600          if NonText and (Kind in [kAdvance, kScience]) then
    601601          begin // show research state
    602             for j := 0 to nColumn - 1 do
     602            for J := 0 to nColumn - 1 do
    603603            begin
    604604              FutureCount := 0;
    605               if j = 0 then // own science
     605              if J = 0 then // own science
    606606                if lix = MyRO.ResearchTech then
    607607                begin
    608                   Server(sGetTechCost, me, 0, icon);
     608                  Server(sGetTechCost, Me, 0, icon);
    609609                  icon := 4 + MyRO.Research * 4 div icon;
    610610                  if icon > 4 + 3 then
     
    625625                  icon := -1
    626626              else
    627                 with MyRO.EnemyReport[Column[j]]^ do // enemy science
    628                   if (MyRO.Alive and (1 shl Column[j]) <> 0) and
     627                with MyRO.EnemyReport[Column[J]]^ do // enemy science
     628                  if (MyRO.Alive and (1 shl Column[J]) <> 0) and
    629629                    (TurnOfCivilReport >= 0) and (lix = ResearchTech) and
    630630                    ((lix = adMilitary) or (lix in FutureTech) or
     
    649649                    icon := -1;
    650650              if icon >= 0 then
    651                 Sprite(offscreen, HGrSystem, 104 - 33 + 15 + 3 + TechNameSpace +
    652                   24 * j, y0 + 3, 14, 14, 67 + icon * 15, 85)
     651                Sprite(Offscreen, HGrSystem, 104 - 33 + 15 + 3 + TechNameSpace +
     652                  24 * J, y0 + 3, 14, 14, 67 + icon * 15, 85)
    653653              else if (Kind = kScience) and (FutureCount > 0) then
    654654              begin
    655                 number := inttostr(FutureCount);
    656                 RisedTextout(ca, 104 - 33 + 15 + 10 + TechNameSpace + 24 * j -
     655                number := IntToStr(FutureCount);
     656                RisedTextout(ca, 104 - 33 + 15 + 10 + TechNameSpace + 24 * J -
    657657                  BiColorTextWidth(ca, number) div 2, y0, number);
    658658              end;
     
    661661        end; // kAdvance, kScience
    662662      kTribe:
    663         s := TribeNames[lix];
     663        S := TribeNames[lix];
    664664      kShipPart:
    665665        begin
    666           s := Phrases.Lookup('IMPROVEMENTS', imShipComp + lix) + ' (' +
    667             inttostr(MyRO.Ship[me].Parts[lix]) + ')';
     666          S := Phrases.Lookup('IMPROVEMENTS', imShipComp + lix) + ' (' +
     667            IntToStr(MyRO.Ship[Me].Parts[lix]) + ')';
    668668          if NonText then
    669669            DisplayProject(8 + ofs, y0 - 15, cpImp + imShipComp + lix);
     
    671671      kEShipPart:
    672672        begin
    673           s := Phrases.Lookup('IMPROVEMENTS', imShipComp + lix) + ' (' +
    674             inttostr(MyRO.Ship[DipMem[me].pContact].Parts[lix]) + ')';
     673          S := Phrases.Lookup('IMPROVEMENTS', imShipComp + lix) + ' (' +
     674            IntToStr(MyRO.Ship[DipMem[Me].pContact].Parts[lix]) + ')';
    675675          if NonText then
    676676            DisplayProject(8 + ofs, y0 - 15, cpImp + imShipComp + lix);
     
    678678      kGov:
    679679        begin
    680           s := Phrases.Lookup('GOVERNMENT', lix);
     680          S := Phrases.Lookup('GOVERNMENT', lix);
    681681          if NonText then
    682682          begin
    683             Frame(offscreen.Canvas, 8 + 16 - 1, y0 - 15 + (16 - 2),
     683            Frame(Offscreen.Canvas, 8 + 16 - 1, y0 - 15 + (16 - 2),
    684684              8 + 16 + xSizeSmall, y0 - 15 + (16 - 1 + ySizeSmall),
    685685              MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
    686             BitBltCanvas(offscreen.Canvas, 8 + 16, y0 - 15 + (16 - 1),
     686            BitBltCanvas(Offscreen.Canvas, 8 + 16, y0 - 15 + (16 - 1),
    687687              xSizeSmall, ySizeSmall, SmallImp.Canvas,
    688688              (lix - 1) * xSizeSmall, ySizeSmall);
     
    690690        end;
    691691      kMission:
    692         s := Phrases.Lookup('SPYMISSION', lix);
     692        S := Phrases.Lookup('SPYMISSION', lix);
    693693    end;
    694694    case Kind of
    695695      kTribe, kMission: // center text
    696696        if Lines[0] > MaxLines then
    697           x := (InnerWidth - GetSystemMetrics(SM_CXVSCROLL)) div 2 -
    698             BiColorTextWidth(ca, s) div 2
     697          X := (InnerWidth - GetSystemMetrics(SM_CXVSCROLL)) div 2 -
     698            BiColorTextWidth(ca, S) div 2
    699699        else
    700           x := InnerWidth div 2 - BiColorTextWidth(ca, s) div 2;
     700          X := InnerWidth div 2 - BiColorTextWidth(ca, S) div 2;
    701701      kAdvance, kFarAdvance, kScience, kChooseTech, kChooseETech,
    702702        kStealTech, kGov:
    703         x := 104 - 33;
     703        X := 104 - 33;
    704704      kAllEModels:
    705         x := 104;
     705        X := 104;
    706706    else
    707       x := 104 + 15;
     707      X := 104 + 15;
    708708    end;
    709     y := y0;
     709    Y := y0;
    710710    if ca = Canvas then
    711711    begin
    712       x := x + SideFrame;
    713       y := y + TitleHeight;
     712      X := X + SideFrame;
     713      Y := Y + TitleHeight;
    714714    end;
    715715    if lit then
     
    718718      TextColor := -1;
    719719    { if Kind=kTribe then ReplaceText_Tribe(x,y,TextColor,
    720       integer(TribeNames.Objects[lix]),s)
    721       else } ReplaceText(x, y, TextColor, s);
     720      Integer(TribeNames.Objects[lix]),S)
     721      else } ReplaceText(X, Y, TextColor, S);
    722722  end;
    723723end;
     
    725725procedure TListDlg.OffscreenPaint;
    726726var
    727   i, j: integer;
     727  I, J: Integer;
    728728begin
    729729  case Kind of
    730730    kCities:
    731       Caption := Tribe[me].TPhrase('TITLE_CITIES');
     731      Caption := Tribe[Me].TPhrase('TITLE_CITIES');
    732732    kCityEvents:
    733733      Caption := Format(Phrases.Lookup('TITLE_EVENTS'),
     
    736736
    737737  inherited;
    738   offscreen.Canvas.Font.Assign(UniFont[ftNormal]);
     738  Offscreen.Canvas.Font.Assign(UniFont[ftNormal]);
    739739  FillOffscreen(0, 0, InnerWidth, InnerHeight);
    740   with offscreen.Canvas do
     740  with Offscreen.Canvas do
    741741  begin
    742742    if Kind = kScience then
    743       for i := 1 to nColumn - 1 do
     743      for I := 1 to nColumn - 1 do
    744744      begin
    745745        Pen.Color := $000000;
    746         MoveTo(104 - 33 + 15 + TechNameSpace + 24 * i, 0);
    747         LineTo(104 - 33 + 15 + TechNameSpace + 24 * i, InnerHeight);
    748         MoveTo(104 - 33 + 15 + TechNameSpace + 9 * 2 + 24 * i, 0);
    749         LineTo(104 - 33 + 15 + TechNameSpace + 9 * 2 + 24 * i, InnerHeight);
    750         if MyRO.EnemyReport[Column[i]].TurnOfCivilReport >= MyRO.Turn - 1 then
    751         begin
    752           brush.Color := Tribe[Column[i]].Color;
    753           fillrect(rect(104 - 33 + 14 + TechNameSpace + 24 * i + 1 * 2, 0,
    754             104 - 33 + 17 + TechNameSpace + 24 * i + 8 * 2, InnerHeight));
    755           brush.style := bsClear;
     746        MoveTo(104 - 33 + 15 + TechNameSpace + 24 * I, 0);
     747        LineTo(104 - 33 + 15 + TechNameSpace + 24 * I, InnerHeight);
     748        MoveTo(104 - 33 + 15 + TechNameSpace + 9 * 2 + 24 * I, 0);
     749        LineTo(104 - 33 + 15 + TechNameSpace + 9 * 2 + 24 * I, InnerHeight);
     750        if MyRO.EnemyReport[Column[I]].TurnOfCivilReport >= MyRO.Turn - 1 then
     751        begin
     752          Brush.Color := Tribe[Column[I]].Color;
     753          FillRect(rect(104 - 33 + 14 + TechNameSpace + 24 * I + 1 * 2, 0,
     754            104 - 33 + 17 + TechNameSpace + 24 * I + 8 * 2, InnerHeight));
     755          Brush.style := bsClear;
    756756        end
    757757        else
    758758        begin // colored player columns
    759           Pen.Color := Tribe[Column[i]].Color;
    760           for j := 1 to 8 do
    761           begin
    762             MoveTo(104 - 33 + 15 + TechNameSpace + 24 * i + j * 2, 0);
    763             LineTo(104 - 33 + 15 + TechNameSpace + 24 * i + j * 2, InnerHeight);
    764           end;
    765         end;
    766       end;
    767 
    768     for i := -1 to DispLines do
    769       if (i + ScrollBar.Position >= 0) and (i + ScrollBar.Position < Lines[Layer]) then
    770         Self.line(offscreen.Canvas, i, true, false);
     759          Pen.Color := Tribe[Column[I]].Color;
     760          for J := 1 to 8 do
     761          begin
     762            MoveTo(104 - 33 + 15 + TechNameSpace + 24 * I + J * 2, 0);
     763            LineTo(104 - 33 + 15 + TechNameSpace + 24 * I + J * 2, InnerHeight);
     764          end;
     765        end;
     766      end;
     767
     768    for I := -1 to DispLines do
     769      if (I + ScrollBar.Position >= 0) and (I + ScrollBar.Position < Lines[Layer]) then
     770        Self.Line(Offscreen.Canvas, I, True, False);
    771771  end;
    772772  MarkUsedOffscreen(InnerWidth, 8 + 48 + DispLines * LineDistance);
     
    774774
    775775procedure TListDlg.PaintBox1MouseMove(Sender: TObject; Shift: TShiftState;
    776   x, y: integer);
     776  X, Y: Integer);
    777777var
    778   i0, Sel0, iColumn, OldScienceNation, xScreen: integer;
    779   s: string;
    780 begin
    781   y := y - TitleHeight;
     778  i0, Sel0, iColumn, OldScienceNation, xScreen: Integer;
     779  S: string;
     780begin
     781  Y := Y - TitleHeight;
    782782  i0 := ScrollBar.Position;
    783783  Sel0 := Selected;
    784   if (x >= SideFrame) and (x < SideFrame + InnerWidth) and (y >= 0) and
    785     (y < InnerHeight) and (y mod LineDistance >= 4) and (y mod LineDistance < 20)
     784  if (X >= SideFrame) and (X < SideFrame + InnerWidth) and (Y >= 0) and
     785    (Y < InnerHeight) and (Y mod LineDistance >= 4) and (Y mod LineDistance < 20)
    786786  then
    787     Selected := y div LineDistance - 1
     787    Selected := Y div LineDistance - 1
    788788  else
    789789    Selected := -2;
     
    794794  begin
    795795    if Sel0 <> -2 then
    796       line(Canvas, Sel0, false, false);
     796      Line(Canvas, Sel0, False, False);
    797797    if Selected <> -2 then
    798       line(Canvas, Selected, false, true);
     798      Line(Canvas, Selected, False, True);
    799799  end;
    800800
     
    803803    OldScienceNation := ScienceNation;
    804804    ScienceNation := -1;
    805     if (x >= SideFrame + (104 - 33 + 15 + TechNameSpace)) and
    806       ((x - SideFrame - (104 - 33 + 15 + TechNameSpace)) mod 24 <= 18) and
    807       (y >= 0) and (y < InnerHeight) then
     805    if (X >= SideFrame + (104 - 33 + 15 + TechNameSpace)) and
     806      ((X - SideFrame - (104 - 33 + 15 + TechNameSpace)) mod 24 <= 18) and
     807      (Y >= 0) and (Y < InnerHeight) then
    808808    begin
    809       iColumn := (x - SideFrame - (104 - 33 + 15 + TechNameSpace)) div 24;
     809      iColumn := (X - SideFrame - (104 - 33 + 15 + TechNameSpace)) div 24;
    810810      if (iColumn >= 1) and (iColumn < nColumn) then
    811811        ScienceNation := Column[iColumn];
     
    818818      if ScienceNation >= 0 then
    819819      begin
    820         s := Tribe[ScienceNation].TPhrase('SHORTNAME');
     820        S := Tribe[ScienceNation].TPhrase('SHORTNAME');
    821821        if MyRO.Alive and (1 shl ScienceNation) = 0 then
    822           s := Format(Phrases.Lookup('SCIENCEREPORT_EXTINCT'), [s]) // extinct
     822          S := Format(Phrases.Lookup('SCIENCEREPORT_EXTINCT'), [S]) // extinct
    823823        else if MyRO.EnemyReport[ScienceNation].TurnOfCivilReport < MyRO.Turn - 1
    824824        then
    825           s := s + ' (' + TurnToString(MyRO.EnemyReport[ScienceNation]
     825          S := S + ' (' + TurnToString(MyRO.EnemyReport[ScienceNation]
    826826            .TurnOfCivilReport) + ')'; // old report
    827         xScreen := (ClientWidth - BiColorTextWidth(Canvas, s)) div 2;
     827        xScreen := (ClientWidth - BiColorTextWidth(Canvas, S)) div 2;
    828828        LoweredTextOut(Canvas, -1, MainTexture, xScreen + 10,
    829           ClientHeight - 29, s);
     829          ClientHeight - 29, S);
    830830        BitBltCanvas(ScienceNationDotBuffer.Canvas, 0, 0, ScienceNationDot.Width,
    831831          ScienceNationDot.Height, Canvas, xScreen - 10, ClientHeight - 27);
     
    853853end;
    854854
    855 function TListDlg.RenameCity(cix: integer): boolean;
     855function TListDlg.RenameCity(cix: Integer): Boolean;
    856856var
    857857  CityNameInfo: TCityNameInfo;
     
    870870        (CityNameInfo.GetCommandDataSize - 1 - CommandDataMaxSize), MaxInt);
    871871    Server(CommandWithData(cSetCityName, CityNameInfo.GetCommandDataSize),
    872       me, 0, CityNameInfo);
     872      Me, 0, CityNameInfo);
    873873    if CityDlg.Visible then
    874874    begin
     
    882882end;
    883883
    884 function TListDlg.RenameModel(mix: integer): boolean;
     884function TListDlg.RenameModel(mix: Integer): Boolean;
    885885var
    886886  ModelNameInfo: TModelNameInfo;
    887887begin
    888888  InputDlg.Caption := Phrases.Lookup('TITLE_MODELNAME');
    889   InputDlg.EInput.Text := Tribe[me].ModelName[mix];
     889  InputDlg.EInput.Text := Tribe[Me].ModelName[mix];
    890890  InputDlg.CenterToRect(BoundsRect);
    891891  InputDlg.ShowModal;
    892892  if (InputDlg.ModalResult = mrOK) and (InputDlg.EInput.Text <> '') and
    893     (InputDlg.EInput.Text <> Tribe[me].ModelName[mix]) then
     893    (InputDlg.EInput.Text <> Tribe[Me].ModelName[mix]) then
    894894  begin
    895895    ModelNameInfo.mix := mix;
     
    899899        (ModelNameInfo.GetCommandDataSize - 1 - CommandDataMaxSize), MaxInt);
    900900    Server(CommandWithData(cSetModelName, ModelNameInfo.GetCommandDataSize),
    901       me, 0, ModelNameInfo);
     901      Me, 0, ModelNameInfo);
    902902    if UnitStatDlg.Visible then
    903903    begin
     
    905905      UnitStatDlg.Invalidate;
    906906    end;
    907     result := true;
     907    Result := True;
    908908  end
    909909  else
    910     result := false;
     910    Result := False;
    911911end;
    912912
    913913procedure TListDlg.PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
    914   Shift: TShiftState; x, y: integer);
     914  Shift: TShiftState; X, Y: Integer);
    915915var
    916   lix: integer;
     916  lix: Integer;
    917917begin
    918918  if ScrollBar.Position + Selected >= 0 then
    919     lix := code[Layer, ScrollBar.Position + Selected];
     919    lix := Code[Layer, ScrollBar.Position + Selected];
    920920  if Kind in [kScience, kCities, kCityEvents, kModels, kEModels, kAllEModels]
    921921  then
    922     include(Shift, ssShift); // don't close list window
     922    Include(Shift, ssShift); // don't close list window
    923923  if (ssLeft in Shift) and not(ssShift in Shift) then
    924924  begin
    925925    if Selected <> -2 then
    926926    begin
    927       result := lix;
    928       Closable := true;
     927      Result := lix;
     928      Closable := True;
    929929      Close;
    930930    end;
     
    937937          MainScreen.ZoomToCity(MyCity[lix].Loc);
    938938        kCityEvents:
    939           MainScreen.ZoomToCity(MyCity[lix].Loc, false, MyCity[lix].Flags and
     939          MainScreen.ZoomToCity(MyCity[lix].Loc, False, MyCity[lix].Flags and
    940940            CityRepMask);
    941941        kModels, kChooseModel:
     
    944944        kEModels:
    945945          UnitStatDlg.ShowNewContent_EnemyModel(wmPersistent,
    946             code[1, ScrollBar.Position + Selected]);
     946            Code[1, ScrollBar.Position + Selected]);
    947947        kAllEModels, kChooseEModel:
    948948          if lix <> mixAll then
     
    987987procedure TListDlg.InitLines;
    988988var
    989   required: array [0 .. nAdv - 1] of integer;
    990 
    991   procedure TryAddImpLine(Layer, Project: integer);
    992   begin
    993     if Server(sSetCityProject - sExecute, me, cixProject, Project) >= rExecuted
     989  required: array [0 .. nAdv - 1] of Integer;
     990
     991  procedure TryAddImpLine(Layer, Project: Integer);
     992  begin
     993    if Server(sSetCityProject - sExecute, Me, cixProject, Project) >= rExecuted
    994994    then
    995995    begin
    996       code[Layer, Lines[Layer]] := Project;
    997       inc(Lines[Layer]);
     996      Code[Layer, Lines[Layer]] := Project;
     997      Inc(Lines[Layer]);
    998998    end;
    999999  end;
     
    10011001  procedure SortTechs;
    10021002  var
    1003     i, j, swap: integer;
     1003    I, J, swap: Integer;
    10041004  begin // sort by advancedness
    1005     for i := 0 to Lines[0] - 2 do
    1006       if code[0, i] < adMilitary then
    1007         for j := i + 1 to Lines[0] - 1 do
    1008           if AdvValue[code[0, i]] * nAdv + code[0, i] < AdvValue[code[0, j]] *
    1009             nAdv + code[0, j] then
    1010           begin
    1011             swap := code[0, i];
    1012             code[0, i] := code[0, j];
    1013             code[0, j] := swap;
     1005    for I := 0 to Lines[0] - 2 do
     1006      if Code[0, I] < adMilitary then
     1007        for J := I + 1 to Lines[0] - 1 do
     1008          if AdvValue[Code[0, I]] * nAdv + Code[0, I] < AdvValue[Code[0, J]] *
     1009            nAdv + Code[0, J] then
     1010          begin
     1011            swap := Code[0, I];
     1012            Code[0, I] := Code[0, J];
     1013            Code[0, J] := swap;
    10141014          end;
    10151015  end;
     
    10171017  procedure SortCities;
    10181018  var
    1019     i, j, swap: integer;
    1020   begin
    1021     for i := 0 to Lines[0] - 2 do
    1022       for j := i + 1 to Lines[0] - 1 do
    1023         if CityName(MyCity[code[0, i]].ID) > CityName(MyCity[code[0, j]].ID)
     1019    I, J, swap: Integer;
     1020  begin
     1021    for I := 0 to Lines[0] - 2 do
     1022      for J := I + 1 to Lines[0] - 1 do
     1023        if CityName(MyCity[Code[0, I]].ID) > CityName(MyCity[Code[0, J]].ID)
    10241024        then
    10251025        begin
    1026           swap := code[0, i];
    1027           code[0, i] := code[0, j];
    1028           code[0, j] := swap;
     1026          swap := Code[0, I];
     1027          Code[0, I] := Code[0, J];
     1028          Code[0, J] := swap;
    10291029        end;
    10301030  end;
    10311031
    10321032  function ModelSortValue(const mi: TModelInfo;
    1033     MixPlayers: boolean = false): integer;
    1034   begin
    1035     result := (mi.Domain + 1) shl 28 - mi.mix;
     1033    MixPlayers: Boolean = False): Integer;
     1034  begin
     1035    Result := (mi.Domain + 1) shl 28 - mi.mix;
    10361036    if MixPlayers then
    1037       dec(result, ModelCode(mi) shl 16);
     1037      Dec(Result, ModelCode(mi) shl 16);
    10381038  end;
    10391039
    10401040  procedure SortModels;
    10411041  var
    1042     i, j, swap: integer;
     1042    I, J, swap: Integer;
    10431043  begin // sort by code[2]
    1044     for i := 0 to Lines[0] - 2 do
    1045       for j := i + 1 to Lines[0] - 1 do
    1046         if code[2, i] > code[2, j] then
    1047         begin
    1048           swap := code[0, i];
    1049           code[0, i] := code[0, j];
    1050           code[0, j] := swap;
    1051           swap := code[1, i];
    1052           code[1, i] := code[1, j];
    1053           code[1, j] := swap;
    1054           swap := code[2, i];
    1055           code[2, i] := code[2, j];
    1056           code[2, j] := swap;
    1057         end;
    1058   end;
    1059 
    1060   procedure MarkPreqs(i: integer);
    1061   begin
    1062     required[i] := 1;
    1063     if MyRO.Tech[i] < tsSeen then
     1044    for I := 0 to Lines[0] - 2 do
     1045      for J := I + 1 to Lines[0] - 1 do
     1046        if Code[2, I] > Code[2, J] then
     1047        begin
     1048          swap := Code[0, I];
     1049          Code[0, I] := Code[0, J];
     1050          Code[0, J] := swap;
     1051          swap := Code[1, I];
     1052          Code[1, I] := Code[1, J];
     1053          Code[1, J] := swap;
     1054          swap := Code[2, I];
     1055          Code[2, I] := Code[2, J];
     1056          Code[2, J] := swap;
     1057        end;
     1058  end;
     1059
     1060  procedure MarkPreqs(I: Integer);
     1061  begin
     1062    required[I] := 1;
     1063    if MyRO.Tech[I] < tsSeen then
    10641064    begin
    1065       if (AdvPreq[i, 0] >= 0) then
    1066         MarkPreqs(AdvPreq[i, 0]);
    1067       if (AdvPreq[i, 1] >= 0) then
    1068         MarkPreqs(AdvPreq[i, 1]);
     1065      if (AdvPreq[I, 0] >= 0) then
     1066        MarkPreqs(AdvPreq[I, 0]);
     1067      if (AdvPreq[I, 1] >= 0) then
     1068        MarkPreqs(AdvPreq[I, 1]);
    10691069    end;
    10701070  end;
    10711071
    10721072var
    1073   Loc1, i, j, p1, dx, dy, mix, emix, EnemyType, TestEnemyType: integer;
     1073  Loc1, I, J, p1, dx, dy, mix, emix, EnemyType, TestEnemyType: Integer;
    10741074  mi: TModelInfo;
    10751075  PPicture, PTestPicture: ^TModelPicture;
    1076   ModelOk: array [0 .. 4095] of boolean;
    1077   ok: boolean;
    1078 begin
    1079   for i := 0 to MaxLayer - 1 do
    1080   begin
    1081     Lines[i] := 0;
    1082     FirstShrinkedLine[i] := MaxInt;
     1076  ModelOk: array [0 .. 4095] of Boolean;
     1077  ok: Boolean;
     1078begin
     1079  for I := 0 to MaxLayer - 1 do
     1080  begin
     1081    Lines[I] := 0;
     1082    FirstShrinkedLine[I] := MaxInt;
    10831083  end;
    10841084  case Kind of
     
    10861086      begin
    10871087        // improvements
    1088         code[0, 0] := cpImp + imTrGoods;
     1088        Code[0, 0] := cpImp + imTrGoods;
    10891089        Lines[0] := 1;
    1090         for i := nWonder to nImp - 1 do
    1091           if Imp[i].Kind = ikCommon then
    1092             TryAddImpLine(0, i + cpImp);
    1093         for i := nWonder to nImp - 1 do
    1094           if not(Imp[i].Kind in [ikCommon, ikTrGoods]) and
    1095             ((MyRO.NatBuilt[i] = 0) or (Imp[i].Kind = ikNatLocal)) then
    1096             TryAddImpLine(0, i + cpImp);
    1097         for i := 0 to nCityType - 1 do
    1098           if MyData.ImpOrder[i, 0] >= 0 then
    1099           begin
    1100             code[0, Lines[0]] := cpType + i;
    1101             inc(Lines[0]);
     1090        for I := nWonder to nImp - 1 do
     1091          if Imp[I].Kind = ikCommon then
     1092            TryAddImpLine(0, I + cpImp);
     1093        for I := nWonder to nImp - 1 do
     1094          if not(Imp[I].Kind in [ikCommon, ikTrGoods]) and
     1095            ((MyRO.NatBuilt[I] = 0) or (Imp[I].Kind = ikNatLocal)) then
     1096            TryAddImpLine(0, I + cpImp);
     1097        for I := 0 to nCityType - 1 do
     1098          if MyData.ImpOrder[I, 0] >= 0 then
     1099          begin
     1100            Code[0, Lines[0]] := cpType + I;
     1101            Inc(Lines[0]);
    11021102          end;
    11031103
    11041104        // wonders
    1105         for i := 0 to nWonder - 1 do
    1106           TryAddImpLine(1, i + cpImp);
     1105        for I := 0 to nWonder - 1 do
     1106          TryAddImpLine(1, I + cpImp);
    11071107
    11081108        // units
    1109         for i := 0 to MyRO.nModel - 1 do
     1109        for I := 0 to MyRO.nModel - 1 do
    11101110        begin
    11111111          { if MyModel[i].Kind=mkSlaves then
    1112             ok:= MyRO.Wonder[woPyramids].EffectiveOwner=me
    1113             else } if MyModel[i].Domain = dSea then
    1114           begin
    1115             ok := false;
     1112            ok:= MyRO.Wonder[woPyramids].EffectiveOwner=Me
     1113            else } if MyModel[I].Domain = dSea then
     1114          begin
     1115            ok := False;
    11161116            for dx := -2 to 2 do
    11171117              for dy := -2 to 2 do
     
    11221122                    ((MyMap[Loc1] and fTerrain = fShore) or
    11231123                    (MyMap[Loc1] and fCanal > 0)) then
    1124                     ok := true;
     1124                    ok := True;
    11251125                end;
    11261126          end
    11271127          else
    1128             ok := true;
     1128            ok := True;
    11291129          if ok then
    11301130          begin
    1131             if MyModel[i].Status and msObsolete = 0 then
     1131            if MyModel[I].Status and msObsolete = 0 then
    11321132            begin
    1133               code[2, Lines[2]] := i;
    1134               inc(Lines[2]);
     1133              Code[2, Lines[2]] := I;
     1134              Inc(Lines[2]);
    11351135            end;
    1136             if MyModel[i].Status and msAllowConscripts <> 0 then
     1136            if MyModel[I].Status and msAllowConscripts <> 0 then
    11371137            begin
    1138               code[2, Lines[2]] := i + cpConscripts;
    1139               inc(Lines[2]);
     1138              Code[2, Lines[2]] := I + cpConscripts;
     1139              Inc(Lines[2]);
    11401140            end;
    11411141          end;
     
    11511151          MarkPreqs(MyData.FarTech);
    11521152        end;
    1153         for i := 0 to nAdv - 1 do
    1154           if ((i in FutureTech) or (MyRO.Tech[i] < tsApplicable)) and
    1155             (Server(sSetResearch - sExecute, me, i, nil^) >= rExecuted) and
    1156             ((MyData.FarTech = adNone) or (required[i] > 0)) then
    1157           begin
    1158             code[0, Lines[0]] := i;
    1159             inc(Lines[0]);
     1153        for I := 0 to nAdv - 1 do
     1154          if ((I in FutureTech) or (MyRO.Tech[I] < tsApplicable)) and
     1155            (Server(sSetResearch - sExecute, Me, I, nil^) >= rExecuted) and
     1156            ((MyData.FarTech = adNone) or (required[I] > 0)) then
     1157          begin
     1158            Code[0, Lines[0]] := I;
     1159            Inc(Lines[0]);
    11601160          end;
    11611161        SortTechs;
    11621162        if Lines[0] = 0 then // no more techs -- offer nexus
    11631163        begin
    1164           code[0, Lines[0]] := adNexus;
    1165           inc(Lines[0]);
    1166         end;
    1167         ok := false;
    1168         for i := 0 to nDomains - 1 do
    1169           if (upgrade[i, 0].Preq = preNone) or
    1170             (MyRO.Tech[upgrade[i, 0].Preq] >= tsApplicable) then
    1171             ok := true;
     1164          Code[0, Lines[0]] := adNexus;
     1165          Inc(Lines[0]);
     1166        end;
     1167        ok := False;
     1168        for I := 0 to nDomains - 1 do
     1169          if (upgrade[I, 0].Preq = preNone) or
     1170            (MyRO.Tech[upgrade[I, 0].Preq] >= tsApplicable) then
     1171            ok := True;
    11721172        if ok then { new unit class }
    11731173        begin
    1174           code[0, Lines[0]] := adMilitary;
    1175           inc(Lines[0]);
     1174          Code[0, Lines[0]] := adMilitary;
     1175          Inc(Lines[0]);
    11761176        end;
    11771177      end;
    11781178    kFarAdvance:
    11791179      begin
    1180         code[0, Lines[0]] := adNone;
    1181         inc(Lines[0]);
    1182         for i := 0 to nAdv - 1 do
    1183           if not(i in FutureTech) and (MyRO.Tech[i] < tsApplicable) and
    1184             ((AdvValue[i] < 2000) or (MyRO.Tech[adMassProduction] > tsNA)) and
    1185             ((AdvValue[i] < 1000) or (MyRO.Tech[adScience] > tsNA)) then
    1186           begin
    1187             code[0, Lines[0]] := i;
    1188             inc(Lines[0]);
     1180        Code[0, Lines[0]] := adNone;
     1181        Inc(Lines[0]);
     1182        for I := 0 to nAdv - 1 do
     1183          if not(I in FutureTech) and (MyRO.Tech[I] < tsApplicable) and
     1184            ((AdvValue[I] < 2000) or (MyRO.Tech[adMassProduction] > tsNA)) and
     1185            ((AdvValue[I] < 1000) or (MyRO.Tech[adScience] > tsNA)) then
     1186          begin
     1187            Code[0, Lines[0]] := I;
     1188            Inc(Lines[0]);
    11891189          end;
    11901190        SortTechs;
     
    11921192    kChooseTech:
    11931193      begin
    1194         for i := 0 to nAdv - 1 do
    1195           if not(i in FutureTech) and (MyRO.Tech[i] >= tsApplicable) and
    1196             (MyRO.EnemyReport[DipMem[me].pContact].Tech[i] < tsSeen) then
    1197           begin
    1198             code[0, Lines[0]] := i;
    1199             inc(Lines[0]);
     1194        for I := 0 to nAdv - 1 do
     1195          if not(I in FutureTech) and (MyRO.Tech[I] >= tsApplicable) and
     1196            (MyRO.EnemyReport[DipMem[Me].pContact].Tech[I] < tsSeen) then
     1197          begin
     1198            Code[0, Lines[0]] := I;
     1199            Inc(Lines[0]);
    12001200          end;
    12011201        SortTechs;
    12021202        // if Lines[0]>1 then
    12031203        begin
    1204           code[0, Lines[0]] := adAll;
    1205           inc(Lines[0]);
     1204          Code[0, Lines[0]] := adAll;
     1205          Inc(Lines[0]);
    12061206        end;
    12071207      end;
    12081208    kChooseETech:
    12091209      begin
    1210         for i := 0 to nAdv - 1 do
    1211           if not(i in FutureTech) and (MyRO.Tech[i] < tsSeen) and
    1212             (MyRO.EnemyReport[DipMem[me].pContact].Tech[i] >= tsApplicable) then
    1213           begin
    1214             code[0, Lines[0]] := i;
    1215             inc(Lines[0]);
     1210        for I := 0 to nAdv - 1 do
     1211          if not(I in FutureTech) and (MyRO.Tech[I] < tsSeen) and
     1212            (MyRO.EnemyReport[DipMem[Me].pContact].Tech[I] >= tsApplicable) then
     1213          begin
     1214            Code[0, Lines[0]] := I;
     1215            Inc(Lines[0]);
    12161216          end;
    12171217        SortTechs;
    12181218        // if Lines[0]>1 then
    12191219        begin
    1220           code[0, Lines[0]] := adAll;
    1221           inc(Lines[0]);
     1220          Code[0, Lines[0]] := adAll;
     1221          Inc(Lines[0]);
    12221222        end;
    12231223      end;
    12241224    kStealTech:
    12251225      begin
    1226         for i := 0 to nAdv - 1 do
    1227           if Server(sStealTech - sExecute, me, i, nil^) >= rExecuted then
    1228           begin
    1229             code[0, Lines[0]] := i;
    1230             inc(Lines[0]);
     1226        for I := 0 to nAdv - 1 do
     1227          if Server(sStealTech - sExecute, Me, I, nil^) >= rExecuted then
     1228          begin
     1229            Code[0, Lines[0]] := I;
     1230            Inc(Lines[0]);
    12311231          end;
    12321232        SortTechs;
     
    12341234    kScience:
    12351235      begin
    1236         Column[0] := me;
     1236        Column[0] := Me;
    12371237        nColumn := 1;
    12381238        for EnemyType := 0 to 2 do
     
    12521252              begin
    12531253                Column[nColumn] := p1;
    1254                 inc(nColumn);
     1254                Inc(nColumn);
    12551255              end;
    12561256            end;
    1257         for i := 0 to nAdv - 1 do
    1258         begin
    1259           ok := (MyRO.Tech[i] <> tsNA) or (MyRO.ResearchTech = i);
    1260           for j := 1 to nColumn - 1 do
    1261             with MyRO.EnemyReport[Column[j]]^ do
    1262               if (Tech[i] <> tsNA) or (TurnOfCivilReport >= 0) and
    1263                 (ResearchTech = i) then
    1264                 ok := true;
     1257        for I := 0 to nAdv - 1 do
     1258        begin
     1259          ok := (MyRO.Tech[I] <> tsNA) or (MyRO.ResearchTech = I);
     1260          for J := 1 to nColumn - 1 do
     1261            with MyRO.EnemyReport[Column[J]]^ do
     1262              if (Tech[I] <> tsNA) or (TurnOfCivilReport >= 0) and
     1263                (ResearchTech = I) then
     1264                ok := True;
    12651265          if ok then
    12661266          begin
    1267             code[0, Lines[0]] := i;
    1268             inc(Lines[0]);
     1267            Code[0, Lines[0]] := I;
     1268            Inc(Lines[0]);
    12691269          end;
    12701270        end;
     
    12721272
    12731273        ok := MyRO.ResearchTech = adMilitary;
    1274         for j := 1 to nColumn - 1 do
    1275           with MyRO.EnemyReport[Column[j]]^ do
    1276             if (MyRO.Alive and (1 shl Column[j]) <> 0) and
     1274        for J := 1 to nColumn - 1 do
     1275          with MyRO.EnemyReport[Column[J]]^ do
     1276            if (MyRO.Alive and (1 shl Column[J]) <> 0) and
    12771277              (TurnOfCivilReport >= 0) and (ResearchTech = adMilitary) then
    1278               ok := true;
     1278              ok := True;
    12791279        if ok then
    12801280        begin
    1281           code[0, Lines[0]] := adMilitary;
    1282           inc(Lines[0]);
     1281          Code[0, Lines[0]] := adMilitary;
     1282          Inc(Lines[0]);
    12831283        end
    12841284      end;
     
    12861286      begin
    12871287        if ClientMode < scContact then
    1288           for i := 0 to MyRO.nCity - 1 do
    1289             if MyCity[i].Loc >= 0 then
     1288          for I := 0 to MyRO.nCity - 1 do
     1289            if MyCity[I].Loc >= 0 then
    12901290            begin
    1291               code[0, Lines[0]] := i;
    1292               inc(Lines[0]);
     1291              Code[0, Lines[0]] := I;
     1292              Inc(Lines[0]);
    12931293            end;
    12941294        SortCities;
     
    12971297    kCityEvents:
    12981298      begin
    1299         for i := 0 to MyRO.nCity - 1 do
    1300           if (MyCity[i].Loc >= 0) and (MyCity[i].Flags and CityRepMask <> 0)
     1299        for I := 0 to MyRO.nCity - 1 do
     1300          if (MyCity[I].Loc >= 0) and (MyCity[I].Flags and CityRepMask <> 0)
    13011301          then
    13021302          begin
    1303             code[0, Lines[0]] := i;
    1304             inc(Lines[0]);
     1303            Code[0, Lines[0]] := I;
     1304            Inc(Lines[0]);
    13051305          end;
    13061306        SortCities;
     
    13091309    { kChooseECity:
    13101310      begin
    1311       for i:=0 to MyRO.nEnemyCity-1 do
    1312       if (MyRO.EnemyCity[i].Loc>=0)
    1313       and (MyRO.EnemyCity[i].owner=DipMem[me].pContact) then
    1314       begin code[0,Lines[0]]:=i; inc(Lines[0]); end;
     1311      for I:=0 to MyRO.nEnemyCity-1 do
     1312      if (MyRO.EnemyCity[I].Loc>=0)
     1313      and (MyRO.EnemyCity[I].owner=DipMem[Me].pContact) then
     1314      begin Code[0,Lines[0]]:=I; Inc(Lines[0]); end;
    13151315      FirstShrinkedLine:=0
    13161316      end; }
     
    13191319        for mix := 0 to MyRO.nModel - 1 do
    13201320        begin
    1321           code[0, mix] := mix;
    1322           MakeModelInfo(me, mix, MyModel[mix], mi);
    1323           code[2, mix] := ModelSortValue(mi);
     1321          Code[0, mix] := mix;
     1322          MakeModelInfo(Me, mix, MyModel[mix], mi);
     1323          Code[2, mix] := ModelSortValue(mi);
    13241324        end;
    13251325        Lines[0] := MyRO.nModel;
     
    13311331        for mix := 3 to MyRO.nModel - 1 do
    13321332        begin // check if opponent already has this model
    1333           MakeModelInfo(me, mix, MyModel[mix], mi);
    1334           ok := true;
     1333          MakeModelInfo(Me, mix, MyModel[mix], mi);
     1334          ok := True;
    13351335          for emix := 0 to MyRO.nEnemyModel - 1 do
    1336             if (MyRO.EnemyModel[emix].Owner = DipMem[me].pContact) and
     1336            if (MyRO.EnemyModel[emix].Owner = DipMem[Me].pContact) and
    13371337              IsSameModel(MyRO.EnemyModel[emix], mi) then
    1338               ok := false;
     1338              ok := False;
    13391339          if ok then
    13401340          begin
    1341             code[0, Lines[0]] := mix;
    1342             MakeModelInfo(me, mix, MyModel[mix], mi);
    1343             code[2, Lines[0]] := ModelSortValue(mi);
    1344             inc(Lines[0]);
     1341            Code[0, Lines[0]] := mix;
     1342            MakeModelInfo(Me, mix, MyModel[mix], mi);
     1343            Code[2, Lines[0]] := ModelSortValue(mi);
     1344            Inc(Lines[0]);
    13451345          end;
    13461346        end;
     
    13481348        // if Lines[0]>1 then
    13491349        begin
    1350           code[0, Lines[0]] := mixAll;
    1351           inc(Lines[0]);;
     1350          Code[0, Lines[0]] := mixAll;
     1351          Inc(Lines[0]);;
    13521352        end;
    13531353        FirstShrinkedLine[0] := 0;
     
    13561356      begin
    13571357        if MyRO.TestFlags and tfUncover <> 0 then
    1358           Server(sGetModels, me, 0, nil^);
     1358          Server(sGetModels, Me, 0, nil^);
    13591359        for emix := 0 to MyRO.nEnemyModel - 1 do
    1360           ModelOk[emix] := MyRO.EnemyModel[emix].Owner = DipMem[me].pContact;
     1360          ModelOk[emix] := MyRO.EnemyModel[emix].Owner = DipMem[Me].pContact;
    13611361        for mix := 0 to MyRO.nModel - 1 do
    13621362        begin // don't list models I already have
    1363           MakeModelInfo(me, mix, MyModel[mix], mi);
     1363          MakeModelInfo(Me, mix, MyModel[mix], mi);
    13641364          for emix := 0 to MyRO.nEnemyModel - 1 do
    13651365            ModelOk[emix] := ModelOk[emix] and
     
    13691369          if ModelOk[emix] then
    13701370          begin
    1371             if not Assigned(Tribe[DipMem[me].pContact].ModelPicture
     1371            if not Assigned(Tribe[DipMem[Me].pContact].ModelPicture
    13721372              [MyRO.EnemyModel[emix].mix].HGr) then
    13731373              InitEnemyModel(emix);
    1374             code[0, Lines[0]] := emix;
    1375             code[2, Lines[0]] := ModelSortValue(MyRO.EnemyModel[emix]);
    1376             inc(Lines[0]);
     1374            Code[0, Lines[0]] := emix;
     1375            Code[2, Lines[0]] := ModelSortValue(MyRO.EnemyModel[emix]);
     1376            Inc(Lines[0]);
    13771377          end;
    13781378        SortModels;
    13791379        // if not IsMilReportNew(DipMem[me].pContact) or (Lines[0]>1) then
    13801380        begin
    1381           code[0, Lines[0]] := mixAll;
    1382           inc(Lines[0]);
     1381          Code[0, Lines[0]] := mixAll;
     1382          Inc(Lines[0]);
    13831383        end;
    13841384        FirstShrinkedLine[0] := 0;
     
    13861386    kEModels:
    13871387      begin
    1388         for i := 0 to MyRO.EnemyReport[pView].nModelCounted - 1 do
    1389         begin
    1390           code[1, Lines[0]] := MyRO.nEnemyModel - 1;
    1391           while (code[1, Lines[0]] >= 0) and
    1392             not((MyRO.EnemyModel[code[1, Lines[0]]].Owner = pView) and
    1393             (MyRO.EnemyModel[code[1, Lines[0]]].mix = i)) do
    1394             dec(code[1, Lines[0]]);
    1395           if not Assigned(Tribe[pView].ModelPicture[i].HGr) then
    1396             InitEnemyModel(code[1, Lines[0]]);
    1397           code[0, Lines[0]] := i;
    1398           code[2, Lines[0]] :=
    1399             ModelSortValue(MyRO.EnemyModel[code[1, Lines[0]]]);
    1400           inc(Lines[0]);
     1388        for I := 0 to MyRO.EnemyReport[pView].nModelCounted - 1 do
     1389        begin
     1390          Code[1, Lines[0]] := MyRO.nEnemyModel - 1;
     1391          while (Code[1, Lines[0]] >= 0) and
     1392            not((MyRO.EnemyModel[Code[1, Lines[0]]].Owner = pView) and
     1393            (MyRO.EnemyModel[Code[1, Lines[0]]].mix = I)) do
     1394            Dec(Code[1, Lines[0]]);
     1395          if not Assigned(Tribe[pView].ModelPicture[I].HGr) then
     1396            InitEnemyModel(Code[1, Lines[0]]);
     1397          Code[0, Lines[0]] := I;
     1398          Code[2, Lines[0]] :=
     1399            ModelSortValue(MyRO.EnemyModel[Code[1, Lines[0]]]);
     1400          Inc(Lines[0]);
    14011401        end;
    14021402        SortModels;
     
    14051405    kAllEModels:
    14061406      begin
    1407         if (MyRO.TestFlags and tfUncover <> 0) or (G.Difficulty[me] = 0) then
    1408           Server(sGetModels, me, 0, nil^);
     1407        if (MyRO.TestFlags and tfUncover <> 0) or (G.Difficulty[Me] = 0) then
     1408          Server(sGetModels, Me, 0, nil^);
    14091409        for emix := 0 to MyRO.nEnemyModel - 1 do
    14101410          if (MyRO.EnemyModel[emix].mix >= 3) and
     
    14161416            if not Assigned(PPicture.HGr) then
    14171417              InitEnemyModel(emix);
    1418             ok := true;
     1418            ok := True;
    14191419            if MainScreen.mNames.Checked then
    1420               for j := 0 to Lines[0] - 1 do
     1420              for J := 0 to Lines[0] - 1 do
    14211421              begin
    1422                 PTestPicture := @Tribe[MyRO.EnemyModel[code[0, j]].Owner]
    1423                   .ModelPicture[MyRO.EnemyModel[code[0, j]].mix];
     1422                PTestPicture := @Tribe[MyRO.EnemyModel[Code[0, J]].Owner]
     1423                  .ModelPicture[MyRO.EnemyModel[Code[0, J]].mix];
    14241424                if (PPicture.HGr = PTestPicture.HGr) and
    14251425                  (PPicture.pix = PTestPicture.pix) and
    14261426                  (ModelHash(MyRO.EnemyModel[emix])
    1427                   = ModelHash(MyRO.EnemyModel[code[0, j]])) then
     1427                  = ModelHash(MyRO.EnemyModel[Code[0, J]])) then
    14281428                begin
    1429                   code[1, j] := 1;
    1430                   ok := false;
     1429                  Code[1, J] := 1;
     1430                  ok := False;
    14311431                  Break;
    14321432                end;
     
    14341434            if ok then
    14351435            begin
    1436               code[0, Lines[0]] := emix;
    1437               code[1, Lines[0]] := 0;
    1438               code[2, Lines[0]] := ModelSortValue(MyRO.EnemyModel[emix], true);
    1439               inc(Lines[0]);
     1436              Code[0, Lines[0]] := emix;
     1437              Code[1, Lines[0]] := 0;
     1438              Code[2, Lines[0]] := ModelSortValue(MyRO.EnemyModel[emix], True);
     1439              Inc(Lines[0]);
    14401440            end;
    14411441          end;
     
    14441444      end;
    14451445    kTribe:
    1446       for i := 0 to TribeNames.Count - 1 do
    1447       begin
    1448         code[0, Lines[0]] := i;
    1449         inc(Lines[0]);
     1446      for I := 0 to TribeNames.Count - 1 do
     1447      begin
     1448        Code[0, Lines[0]] := I;
     1449        Inc(Lines[0]);
    14501450      end;
    14511451    (* kDeliver:
    1452       if MyRO.Treaty[DipMem[me].pContact]<trAlliance then
     1452      if MyRO.Treaty[DipMem[Me].pContact]<trAlliance then
    14531453      begin // suggest next treaty level
    1454       code[0,Lines[0]]:=opTreaty+MyRO.Treaty[DipMem[me].pContact]+1;
    1455       inc(Lines[0]);
    1456       end;
    1457       if MyRO.Treaty[DipMem[me].pContact]=trNone then
     1454      Code[0,Lines[0]]:=opTreaty+MyRO.Treaty[DipMem[Me].pContact]+1;
     1455      Inc(Lines[0]);
     1456      end;
     1457      if MyRO.Treaty[DipMem[Me].pContact]=trNone then
    14581458      begin // suggest peace
    1459       code[0,Lines[0]]:=opTreaty+trPeace;
    1460       inc(Lines[0]);
    1461       end;
    1462       if MyRO.Treaty[DipMem[me].pContact]>trNone then
     1459      Code[0,Lines[0]]:=opTreaty+trPeace;
     1460      Inc(Lines[0]);
     1461      end;
     1462      if MyRO.Treaty[DipMem[Me].pContact]>trNone then
    14631463      begin // suggest next treaty level
    1464       code[0,Lines[0]]:=opTreaty+MyRO.Treaty[DipMem[me].pContact]-1;
    1465       inc(Lines[0]);
     1464      Code[0,Lines[0]]:=opTreaty+MyRO.Treaty[DipMem[Me].pContact]-1;
     1465      Inc(Lines[0]);
    14661466      end; *)
    14671467    kShipPart:
    14681468      begin
    14691469        Lines[0] := 0;
    1470         for i := 0 to nShipPart - 1 do
    1471           if MyRO.Ship[me].Parts[i] > 0 then
    1472           begin
    1473             code[0, Lines[0]] := i;
    1474             inc(Lines[0]);
     1470        for I := 0 to nShipPart - 1 do
     1471          if MyRO.Ship[Me].Parts[I] > 0 then
     1472          begin
     1473            Code[0, Lines[0]] := I;
     1474            Inc(Lines[0]);
    14751475          end;
    14761476      end;
     
    14781478      begin
    14791479        Lines[0] := 0;
    1480         for i := 0 to nShipPart - 1 do
    1481           if MyRO.Ship[DipMem[me].pContact].Parts[i] > 0 then
    1482           begin
    1483             code[0, Lines[0]] := i;
    1484             inc(Lines[0]);
     1480        for I := 0 to nShipPart - 1 do
     1481          if MyRO.Ship[DipMem[Me].pContact].Parts[I] > 0 then
     1482          begin
     1483            Code[0, Lines[0]] := I;
     1484            Inc(Lines[0]);
    14851485          end;
    14861486      end;
    14871487    kGov:
    1488       for i := 1 to nGov - 1 do
    1489         if (GovPreq[i] <> preNA) and
    1490           ((GovPreq[i] = preNone) or (MyRO.Tech[GovPreq[i]] >= tsApplicable))
     1488      for I := 1 to nGov - 1 do
     1489        if (GovPreq[I] <> preNA) and
     1490          ((GovPreq[I] = preNone) or (MyRO.Tech[GovPreq[I]] >= tsApplicable))
    14911491        then
    14921492        begin
    1493           code[0, Lines[0]] := i;
    1494           inc(Lines[0]);
     1493          Code[0, Lines[0]] := I;
     1494          Inc(Lines[0]);
    14951495        end;
    14961496    kMission:
    1497       for i := 0 to nSpyMission - 1 do
    1498       begin
    1499         code[0, Lines[0]] := i;
    1500         inc(Lines[0]);
     1497      for I := 0 to nSpyMission - 1 do
     1498      begin
     1499        Code[0, Lines[0]] := I;
     1500        Inc(Lines[0]);
    15011501      end;
    15021502  end;
     
    15051505    if Lines[0] + Lines[1] + Lines[2] <= MaxLines then
    15061506    begin
    1507       for i := 0 to Lines[1] - 1 do // add wonders to first page
    1508       begin
    1509         code[0, Lines[0]] := code[1, i];
    1510         inc(Lines[0]);
     1507      for I := 0 to Lines[1] - 1 do // add wonders to first page
     1508      begin
     1509        Code[0, Lines[0]] := Code[1, I];
     1510        Inc(Lines[0]);
    15111511      end;
    15121512      Lines[1] := 0;
    15131513      FirstShrinkedLine[0] := Lines[0];
    1514       for i := 0 to Lines[2] - 1 do // add models to first page
    1515       begin
    1516         code[0, Lines[0]] := code[2, i];
    1517         inc(Lines[0]);
     1514      for I := 0 to Lines[2] - 1 do // add models to first page
     1515      begin
     1516        Code[0, Lines[0]] := Code[2, I];
     1517        Inc(Lines[0]);
    15181518      end;
    15191519      Lines[2] := 0;
     
    15211521end;
    15221522
    1523 function TListDlg.OnlyChoice(TestKind: TListKind): integer;
     1523function TListDlg.OnlyChoice(TestKind: TListKind): Integer;
    15241524begin
    15251525  Kind := TestKind;
    15261526  InitLines;
    15271527  if Lines[0] = 0 then
    1528     result := -2
     1528    Result := -2
    15291529  else if Lines[0] > 1 then
    1530     result := -1
     1530    Result := -1
    15311531  else
    1532     result := code[0, 0];
     1532    Result := Code[0, 0];
    15331533end;
    15341534
    15351535procedure TListDlg.FormShow(Sender: TObject);
    15361536var
    1537   i: integer;
    1538 begin
    1539   result := -1;
    1540   Closable := false;
     1537  I: Integer;
     1538begin
     1539  Result := -1;
     1540  Closable := False;
    15411541
    15421542  if Kind = kTribe then
     
    15541554  InitLines;
    15551555
    1556   MultiPage := false;
    1557   for i := 1 to MaxLayer - 1 do
    1558     if Lines[i] > 0 then
    1559       MultiPage := true;
     1556  MultiPage := False;
     1557  for I := 1 to MaxLayer - 1 do
     1558    if Lines[I] > 0 then
     1559      MultiPage := True;
    15601560  WideBottom := MultiPage or (Kind = kScience) or
    15611561    not Phrases2FallenBackToEnglish and
     
    15711571
    15721572  DispLines := Lines[0];
    1573   for i := 0 to MaxLayer - 1 do
    1574     if Lines[i] > DispLines then
    1575       DispLines := Lines[i];
     1573  for I := 0 to MaxLayer - 1 do
     1574    if Lines[I] > DispLines then
     1575      DispLines := Lines[I];
    15761576  if WideBottom then
    15771577  begin
     
    15881588    ClientHeight := InnerHeight + TitleHeight + NarrowFrame;
    15891589  end;
    1590   assert(ClientHeight <= Maintexture.Height);
     1590  Assert(ClientHeight <= Maintexture.Height);
    15911591
    15921592  TechNameSpace := 224;
     
    16491649    Layer0Btn.Top := ClientHeight - 31;
    16501650    Layer0Btn.Left := ClientWidth div 2 - (12 + 29);
    1651     Layer0Btn.Down := true;
     1651    Layer0Btn.Down := True;
    16521652    Layer1Btn.Top := ClientHeight - 31;
    16531653    Layer1Btn.Left := ClientWidth div 2 - (12 - 29);
    1654     Layer1Btn.Down := false;
     1654    Layer1Btn.Down := False;
    16551655    Layer2Btn.Top := ClientHeight - 31;
    16561656    Layer2Btn.Left := ClientWidth div 2 - 12;
    1657     Layer2Btn.Down := false;
     1657    Layer2Btn.Down := False;
    16581658  end;
    16591659
     
    16681668procedure TListDlg.ShowNewContent(NewMode: TWindowMode; ListKind: TListKind);
    16691669var
    1670   i: integer;
    1671   ShowFocus, forceclose: boolean;
     1670  I: Integer;
     1671  ShowFocus, forceclose: Boolean;
    16721672begin
    16731673  forceclose := (ListKind <> Kind) and
     
    17331733  if Kind = kAdvance then // show focus button?
    17341734    if MyData.FarTech <> adNone then
    1735       ShowFocus := true
     1735      ShowFocus := True
    17361736    else
    17371737    begin
    1738       ShowFocus := false;
    1739       for i := 0 to nAdv - 1 do
    1740         if not(i in FutureTech) and (MyRO.Tech[i] < tsApplicable) and
    1741           ((AdvValue[i] < 2000) or (MyRO.Tech[adMassProduction] > tsNA)) and
    1742           ((AdvValue[i] < 1000) or (MyRO.Tech[adScience] > tsNA)) and
    1743           (Server(sSetResearch - sExecute, me, i, nil^) < rExecuted) then
    1744           ShowFocus := true;
     1738      ShowFocus := False;
     1739      for I := 0 to nAdv - 1 do
     1740        if not(I in FutureTech) and (MyRO.Tech[I] < tsApplicable) and
     1741          ((AdvValue[I] < 2000) or (MyRO.Tech[adMassProduction] > tsNA)) and
     1742          ((AdvValue[I] < 1000) or (MyRO.Tech[adScience] > tsNA)) and
     1743          (Server(sSetResearch - sExecute, Me, I, nil^) < rExecuted) then
     1744          ShowFocus := True;
    17451745    end;
    1746   ToggleBtn.Visible := (Kind = kCities) and not supervising or (Kind = kAdvance)
     1746  ToggleBtn.Visible := (Kind = kCities) and not Supervising or (Kind = kAdvance)
    17471747    and ShowFocus or (Kind = kModels) or (Kind = kEModels);
    17481748  CloseBtn.Visible := not(Kind in MustChooseKind);
     
    17511751end;
    17521752
    1753 procedure TListDlg.ShowNewContent_CityProject(NewMode: TWindowMode; cix: integer);
     1753procedure TListDlg.ShowNewContent_CityProject(NewMode: TWindowMode; cix: Integer);
    17541754begin
    17551755  cixProject := cix;
     
    17571757end;
    17581758
    1759 procedure TListDlg.ShowNewContent_MilReport(NewMode: TWindowMode; p: integer);
    1760 begin
    1761   pView := p;
    1762   if p = me then
     1759procedure TListDlg.ShowNewContent_MilReport(NewMode: TWindowMode; P: Integer);
     1760begin
     1761  pView := P;
     1762  if P = Me then
    17631763    ShowNewContent(NewMode, kModels)
    17641764  else
     
    17681768procedure TListDlg.PlayerClick(Sender: TObject);
    17691769begin
    1770   if TComponent(Sender).Tag = me then
     1770  if TComponent(Sender).Tag = Me then
    17711771    Kind := kModels
    17721772  else
     
    17961796procedure TListDlg.ToggleBtnClick(Sender: TObject);
    17971797var
    1798   p1: integer;
    1799   m: TMenuItem;
     1798  p1: Integer;
     1799  M: TMenuItem;
    18001800begin
    18011801  case Kind of
    18021802    kAdvance:
    18031803      begin
    1804         result := adFar;
    1805         Closable := true;
     1804        Result := adFar;
     1805        Closable := True;
    18061806        Close;
    18071807      end;
     
    18181818      begin
    18191819        EmptyMenu(Popup.Items);
    1820         if G.Difficulty[me] > 0 then
    1821         begin
    1822           m := TMenuItem.Create(Popup);
    1823           m.RadioItem := true;
    1824           m.Caption := Tribe[me].TPhrase('SHORTNAME');
    1825           m.Tag := me;
    1826           m.OnClick := PlayerClick;
     1820        if G.Difficulty[Me] > 0 then
     1821        begin
     1822          M := TMenuItem.Create(Popup);
     1823          M.RadioItem := True;
     1824          M.Caption := Tribe[Me].TPhrase('SHORTNAME');
     1825          M.Tag := Me;
     1826          M.OnClick := PlayerClick;
    18271827          if Kind = kModels then
    1828             m.Checked := true;
    1829           Popup.Items.Add(m);
     1828            M.Checked := True;
     1829          Popup.Items.Add(M);
    18301830        end;
    18311831        for p1 := 0 to nPl - 1 do
    1832           if (p1 <> me) and (MyRO.EnemyReport[p1] <> nil) and
     1832          if (p1 <> Me) and (MyRO.EnemyReport[p1] <> nil) and
    18331833            (MyRO.EnemyReport[p1].TurnOfMilReport >= 0) then
    18341834          begin
    1835             m := TMenuItem.Create(Popup);
    1836             m.RadioItem := true;
    1837             m.Caption := Tribe[p1].TPhrase('SHORTNAME');
    1838             m.Tag := p1;
    1839             m.OnClick := PlayerClick;
     1835            M := TMenuItem.Create(Popup);
     1836            M.RadioItem := True;
     1837            M.Caption := Tribe[p1].TPhrase('SHORTNAME');
     1838            M.Tag := p1;
     1839            M.OnClick := PlayerClick;
    18401840            if (Kind = kEModels) and (p1 = pView) then
    1841               m.Checked := true;
    1842             Popup.Items.Add(m);
     1841              M.Checked := True;
     1842            Popup.Items.Add(M);
    18431843          end;
    18441844        Popup.Popup(Left + ToggleBtn.Left, Top + ToggleBtn.Top +
     
    18481848end;
    18491849
    1850 procedure TListDlg.FormKeyDown(Sender: TObject; var Key: word;
     1850procedure TListDlg.FormKeyDown(Sender: TObject; var Key: Word;
    18511851  Shift: TShiftState);
    18521852begin
     
    18941894begin
    18951895  Selected := -2;
    1896   SmartUpdateContent(true);
     1896  SmartUpdateContent(True);
    18971897end;
    18981898
  • trunk/LocalPlayer/TechTree.pas

    r426 r447  
    5555  yLegendPitch = 32;
    5656
    57 function min(a, b: Integer): Integer;
    58 begin
    59   if a < b then
    60     result := a
     57function Min(A, B: Integer): Integer;
     58begin
     59  if A < B then
     60    Result := A
    6161  else
    62     result := b;
    63 end;
    64 
    65 function max(a, b: Integer): Integer;
    66 begin
    67   if a > b then
    68     result := a
     62    Result := B;
     63end;
     64
     65function Max(A, B: Integer): Integer;
     66begin
     67  if A > B then
     68    Result := A
    6969  else
    70     result := b;
     70    Result := B;
    7171end;
    7272
     
    8484procedure TTechTreeDlg.FormPaint(Sender: TObject);
    8585var
    86   X, w: Integer;
     86  X, W: Integer;
    8787begin
    8888  with Canvas do begin
    8989    // black border
    90     brush.color := $000000;
    91     fillrect(rect(0, 0, BlackBorder, ClientHeight));
    92     fillrect(rect(BlackBorder, 0, ClientWidth - BlackBorder, BlackBorder));
    93     fillrect(rect(ClientWidth - BlackBorder, 0, ClientWidth, ClientHeight));
    94     fillrect(rect(BlackBorder, ClientHeight - BlackBorder,
     90    Brush.Color := $000000;
     91    FillRect(rect(0, 0, BlackBorder, ClientHeight));
     92    FillRect(rect(BlackBorder, 0, ClientWidth - BlackBorder, BlackBorder));
     93    FillRect(rect(ClientWidth - BlackBorder, 0, ClientWidth, ClientHeight));
     94    FillRect(rect(BlackBorder, ClientHeight - BlackBorder,
    9595      ClientWidth - BlackBorder, ClientHeight));
    9696
    9797    // texturize empty space
    98     brush.color := $FFFFFF;
     98    Brush.Color := $FFFFFF;
    9999    if xOffset > 0 then
    100100      FillRectSeamless(Canvas, BlackBorder, BlackBorder, BlackBorder + xOffset,
     
    105105        ClientWidth - BlackBorder, ClientHeight - BlackBorder,
    106106        -BlackBorder - xOffset, -BlackBorder - yOffset, Paper);
    107     X := max(BlackBorder, BlackBorder + xOffset);
    108     w := min(BlackBorder + xOffset + Image.width, ClientWidth - BlackBorder);
     107    X := Max(BlackBorder, BlackBorder + xOffset);
     108    W := Min(BlackBorder + xOffset + Image.width, ClientWidth - BlackBorder);
    109109    if yOffset > 0 then
    110       FillRectSeamless(Canvas, X, BlackBorder, w, BlackBorder + yOffset,
     110      FillRectSeamless(Canvas, X, BlackBorder, W, BlackBorder + yOffset,
    111111        -BlackBorder - xOffset, -BlackBorder - yOffset, Paper);
    112112    if yOffset + Image.height < ClientHeight - 2 * BlackBorder then
    113       FillRectSeamless(Canvas, X, BlackBorder + yOffset + Image.height, w,
     113      FillRectSeamless(Canvas, X, BlackBorder + yOffset + Image.height, W,
    114114        ClientHeight - BlackBorder, -BlackBorder - xOffset,
    115115        -BlackBorder - yOffset, Paper);
    116116  end;
    117   BitBltCanvas(Canvas, max(BlackBorder, BlackBorder + xOffset),
    118     max(BlackBorder, BlackBorder + yOffset),
    119     min(Image.width, min(Image.width + xOffset,
    120     min(ClientWidth - 2 * BlackBorder, ClientWidth - 2 * BlackBorder - xOffset))
    121     ), min(Image.height, min(Image.height + yOffset,
    122     min(ClientHeight - 2 * BlackBorder, ClientHeight - 2 * BlackBorder -
    123     yOffset))), Image.Canvas, max(0, -xOffset),
    124     max(0, -yOffset));
     117  BitBltCanvas(Canvas, Max(BlackBorder, BlackBorder + xOffset),
     118    Max(BlackBorder, BlackBorder + yOffset),
     119    Min(Image.width, Min(Image.width + xOffset,
     120    Min(ClientWidth - 2 * BlackBorder, ClientWidth - 2 * BlackBorder - xOffset))
     121    ), Min(Image.height, Min(Image.height + yOffset,
     122    Min(ClientHeight - 2 * BlackBorder, ClientHeight - 2 * BlackBorder -
     123    yOffset))), Image.Canvas, Max(0, -xOffset),
     124    Max(0, -yOffset));
    125125end;
    126126
     
    128128var
    129129  X, Y, ad: Integer;
    130   s: string;
     130  S: string;
    131131  NewWidth: Integer;
    132132  NewHeight: Integer;
     
    142142      // write advance names
    143143      Font.Assign(UniFont[ftSmall]);
    144       Font.color := clBlack;
    145       brush.Style := bsClear;
     144      Font.Color := clBlack;
     145      Brush.Style := bsClear;
    146146      for X := 0 to (Image.width - xStart) div xPitch do
    147147        for Y := 0 to (Image.height - yStart) div yPitch do
     
    150150          if ad and $FFFF00 = 0 then
    151151          begin
    152             s := Phrases.Lookup('ADVANCES', ad);
    153             while TextWidth(s) > 112 do
    154               Delete(s, Length(s), 1);
    155             TextOut(xStart + X * xPitch + 2, yStart + Y * yPitch, s);
     152            S := Phrases.Lookup('ADVANCES', ad);
     153            while TextWidth(S) > 112 do
     154              Delete(S, Length(S), 1);
     155            TextOut(xStart + X * xPitch + 2, yStart + Y * yPitch, S);
    156156            Pixels[xStart + X * xPitch + 10, yStart + Y * yPitch - 1]
    157157              := TransparentColor2;
     
    191191  if Button = mbLeft then
    192192  begin
    193     dragging := true;
     193    dragging := True;
    194194    xDown := X;
    195195    yDown := Y;
     
    200200  Shift: TShiftState; X, Y: Integer);
    201201begin
    202   dragging := false;
     202  dragging := False;
    203203end;
    204204
  • trunk/LocalPlayer/Term.pas

    r442 r447  
    232232    procedure Timer1Timer(Sender: TObject);
    233233    procedure MapBoxMouseDown(Sender: TObject; Button: TMouseButton;
    234       Shift: TShiftState; x, y: integer);
     234      Shift: TShiftState; X, Y: Integer);
    235235    procedure EOTClick(Sender: TObject);
    236236    procedure PanelBoxMouseDown(Sender: TObject; Button: TMouseButton;
    237       Shift: TShiftState; x, y: integer);
    238     procedure FormKeyDown(Sender: TObject; var Key: word; Shift: TShiftState);
     237      Shift: TShiftState; X, Y: Integer);
     238    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    239239    procedure mDisbandOrUtilizeClick(Sender: TObject);
    240240    procedure FormResize(Sender: TObject);
    241241    procedure PanelBtnClick(Sender: TObject);
    242     procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
     242    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    243243    procedure Toggle(Sender: TObject);
    244244    procedure PanelBoxMouseMove(Sender: TObject; Shift: TShiftState;
    245       x, y: integer);
     245      X, Y: Integer);
    246246    procedure PanelBoxMouseUp(Sender: TObject; Button: TMouseButton;
    247       Shift: TShiftState; x, y: integer);
     247      Shift: TShiftState; X, Y: Integer);
    248248    procedure MapBoxMouseMove(Sender: TObject; Shift: TShiftState;
    249       x, y: integer);
     249      X, Y: Integer);
    250250    procedure mShowClick(Sender: TObject);
    251251    procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
    252       Shift: TShiftState; x, y: integer);
    253     procedure FormMouseMove(Sender: TObject; Shift: TShiftState; x, y: integer);
     252      Shift: TShiftState; X, Y: Integer);
     253    procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
    254254    procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
    255       Shift: TShiftState; x, y: integer);
     255      Shift: TShiftState; X, Y: Integer);
    256256    procedure FormPaint(Sender: TObject);
    257257    procedure mRepClicked(Sender: TObject);
     
    263263    procedure mNamesClick(Sender: TObject);
    264264    procedure MapBtnClick(Sender: TObject);
    265     procedure FormKeyUp(Sender: TObject; var Key: word; Shift: TShiftState);
     265    procedure FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
    266266    procedure CreateUnitClick(Sender: TObject);
    267267    procedure mSoundOffClick(Sender: TObject);
     
    324324    NoMap: TIsoMap;
    325325    NoMapPanel: TIsoMap;
    326     function ChooseUnusedTribe: integer;
     326    function ChooseUnusedTribe: Integer;
    327327    function DoJob(j0: Integer): Integer;
    328328    procedure GetTribeList;
    329329    procedure InitModule;
    330330    procedure DoneModule;
    331     procedure InitTurn(NewPlayer: integer);
     331    procedure InitTurn(NewPlayer: Integer);
    332332    procedure SaveMenuItemsState;
    333333    procedure ScrollBarUpdate(Sender: TObject);
     
    341341    procedure FocusNextUnit(Dir: Integer = 1);
    342342    procedure NextUnit(NearLoc: Integer; AutoTurn: Boolean);
    343     procedure Scroll(dx, dy: integer);
    344     procedure SetMapPos(Loc: integer; MapPos: TPoint);
    345     procedure Centre(Loc: integer);
    346     procedure SetTroopLoc(Loc: integer);
    347     procedure ProcessRect(x0, y0, nx, ny, Options: integer);
    348     procedure PaintLoc(Loc: integer; Radius: integer = 0);
    349     procedure PaintLoc_BeforeMove(FromLoc: integer);
    350     procedure PaintLocTemp(Loc: integer; Style: TPaintLocTempStyle = pltsNormal);
    351     procedure PaintBufferToScreen(xMap, yMap, width, height: integer);
     343    procedure Scroll(dx, dy: Integer);
     344    procedure SetMapPos(Loc: Integer; MapPos: TPoint);
     345    procedure Centre(Loc: Integer);
     346    procedure SetTroopLoc(Loc: Integer);
     347    procedure ProcessRect(x0, y0, nx, ny, Options: Integer);
     348    procedure PaintLoc(Loc: Integer; Radius: Integer = 0);
     349    procedure PaintLoc_BeforeMove(FromLoc: Integer);
     350    procedure PaintLocTemp(Loc: Integer; Style: TPaintLocTempStyle = pltsNormal);
     351    procedure PaintBufferToScreen(xMap, yMap, width, height: Integer);
    352352    procedure PaintDestination;
    353     procedure SetUnFocus(uix: integer);
    354     function MoveUnit(dx, dy: integer; Options: integer = 0): integer;
    355     procedure MoveToLoc(Loc: integer; CheckSuicide: boolean);
    356     procedure MoveOnScreen(ShowMove: TShowMove; Step0, Step1, nStep: integer;
    357       Restore: boolean = true);
    358     procedure FocusOnLoc(Loc: integer; Options: integer = 0);
    359     function EndTurn(WasSkipped: boolean = false): boolean;
     353    procedure SetUnFocus(uix: Integer);
     354    function MoveUnit(dx, dy: Integer; Options: Integer = 0): Integer;
     355    procedure MoveToLoc(Loc: Integer; CheckSuicide: Boolean);
     356    procedure MoveOnScreen(ShowMove: TShowMove; Step0, Step1, nStep: Integer;
     357      Restore: Boolean = True);
     358    procedure FocusOnLoc(Loc: Integer; Options: Integer = 0);
     359    function EndTurn(WasSkipped: Boolean = False): Boolean;
    360360    procedure EndNego;
    361     function IsPanelPixel(x, y: integer): boolean;
     361    function IsPanelPixel(X, Y: Integer): Boolean;
    362362    procedure InitPopup(Popup: TPopupMenu);
    363363    procedure SetMapOptions;
     
    365365    procedure CheckTerrainBtnVisible;
    366366    procedure RememberPeaceViolation;
    367     procedure SetDebugMap(p: integer);
    368     procedure SetViewpoint(p: integer);
    369     function LocationOfScreenPixel(x, y: integer): Integer;
     367    procedure SetDebugMap(P: Integer);
     368    procedure SetViewpoint(P: Integer);
     369    function LocationOfScreenPixel(X, Y: Integer): Integer;
    370370    function GetCenterLoc: Integer;
    371371    procedure SetTileSizeCenter(TileSize: TTileSize);
    372372    procedure SetTileSize(TileSize: TTileSize; Loc: Integer; MapPos: TPoint);
    373     procedure RectInvalidate(Left, Top, Rigth, Bottom: integer);
     373    procedure RectInvalidate(Left, Top, Rigth, Bottom: Integer);
    374374    procedure ShowEnemyShipChange(ShowShipChange: TShowShipChange);
    375     procedure SmartRectInvalidate(Left, Top, Rigth, Bottom: integer);
     375    procedure SmartRectInvalidate(Left, Top, Rigth, Bottom: Integer);
    376376    procedure LoadSettings;
    377377    procedure SaveSettings;
     
    381381    procedure UpdateKeyShortcuts;
    382382    procedure SetFullScreen(Active: Boolean);
    383     procedure PaintZoomedTile(dst: TBitmap; x, y, Loc: integer);
     383    procedure PaintZoomedTile(dst: TBitmap; X, Y, Loc: Integer);
    384384  public
    385385    UsedOffscreenWidth: Integer;
     
    387387    Offscreen: TBitmap;
    388388    OffscreenUser: TForm;
    389     procedure Client(Command, NewPlayer: integer; var Data);
    390     procedure SetAIName(p: integer; Name: string);
    391     function ZoomToCity(Loc: integer; NextUnitOnClose: boolean = false;
    392       ShowEvent: integer = 0): boolean;
    393     procedure CityClosed(Activateuix: integer; StepFocus: boolean = false;
    394       SelectFocus: boolean = false);
    395     function DipCall(Command: integer): integer;
    396     function OfferCall(var Offer: TOffer): integer;
    397     procedure UpdateViews(UpdateCityScreen: boolean = false);
    398     function ContactRefused(p: integer; Item: String): boolean;
     389    procedure Client(Command, NewPlayer: Integer; var Data);
     390    procedure SetAIName(P: Integer; Name: string);
     391    function ZoomToCity(Loc: Integer; NextUnitOnClose: Boolean = False;
     392      ShowEvent: Integer = 0): Boolean;
     393    procedure CityClosed(Activateuix: Integer; StepFocus: Boolean = False;
     394      SelectFocus: Boolean = False);
     395    function DipCall(Command: Integer): Integer;
     396    function OfferCall(var Offer: TOffer): Integer;
     397    procedure UpdateViews(UpdateCityScreen: Boolean = False);
     398    function ContactRefused(P: Integer; Item: String): Boolean;
    399399  end;
    400400
     
    407407
    408408  TTribeInfo = record
    409     trix: integer;
     409    trix: Integer;
    410410    FileName: ShortString;
    411411    function GetCommandDataSize: Byte;
     
    415415
    416416  TCityNameInfo = record
    417     ID: integer;
     417    ID: Integer;
    418418    NewName: ShortString;
    419419    function GetCommandDataSize: Byte;
     
    423423
    424424  TModelNameInfo = record
    425     mix: integer;
     425    mix: Integer;
    426426    NewName: ShortString;
    427427    function GetCommandDataSize: Byte;
     
    472472  usToldNoReturn = $100;
    473473  usPersistent = usStay or usGoto or usEnhance or usRecover or
    474     integer($FFFF0000);
     474    Integer($FFFF0000);
    475475
    476476  { model status flags }
     
    486486  adNexus = $803;
    487487
    488   SpecialModelPictureCode: array [0 .. nSpecialModel - 1] of integer = (10,
     488  SpecialModelPictureCode: array [0 .. nSpecialModel - 1] of Integer = (10,
    489489    11, 40, 41, 21, 30, { 50,51, } 64, 74, { 71, } 73);
    490490
     
    499499
    500500  nCityEventPriority = 16;
    501   CityEventPriority: array [0 .. nCityEventPriority - 1] of integer =
     501  CityEventPriority: array [0 .. nCityEventPriority - 1] of Integer =
    502502    (chDisorder, chImprovementLost, chUnitLost, chAllImpsMade, chProduction,
    503503    chOldWonder, chNoSettlerProd, chPopDecrease, chProductionSabotaged,
     
    574574  DipMem: array [0 .. nPl - 1] of TDipMem;
    575575
    576 function CityEventName(i: integer): string;
    577 function RoughCredibility(Credibility: integer): integer;
    578 
    579 function InitEnemyModel(emix: integer): boolean;
     576function CityEventName(I: Integer): string;
     577function RoughCredibility(Credibility: Integer): Integer;
     578
     579function InitEnemyModel(emix: Integer): Boolean;
    580580procedure InitAllEnemyModels;
    581 procedure InitMyModel(mix: integer; final: boolean);
    582 
    583 procedure ImpImage(ca: TCanvas; x, y, iix: integer; Government: integer = -1;
    584   IsControl: boolean = false);
     581procedure InitMyModel(mix: Integer; final: Boolean);
     582
     583procedure ImpImage(ca: TCanvas; X, Y, iix: Integer; Government: Integer = -1;
     584  IsControl: Boolean = False);
    585585procedure HelpOnTerrain(Loc: Integer; NewMode: TWindowMode);
    586586function AlignUp(Value, Alignment: Integer): Integer;
     
    610610  MoveTime = 300; // {time for moving a unit in ms}
    611611  WaitAfterShowMove = 32;
    612   FastScrolling = false; // causes problems with overlapping windows
     612  FastScrolling = False; // causes problems with overlapping windows
    613613
    614614  nBrushTypes = 26;
     
    648648  CurrentMoveInfo: TCurrentMoveInfo;
    649649
    650 function CityEventName(i: integer): string;
    651 begin
    652   if i = 14 then // chAllImpsMade
     650function CityEventName(I: Integer): string;
     651begin
     652  if I = 14 then // chAllImpsMade
    653653    if not Phrases2FallenBackToEnglish then
    654       result := Phrases2.Lookup('CITYEVENT_ALLIMPSMADE')
     654      Result := Phrases2.Lookup('CITYEVENT_ALLIMPSMADE')
    655655    else
    656       result := Phrases.Lookup('CITYEVENTS', 1)
     656      Result := Phrases.Lookup('CITYEVENTS', 1)
    657657  else
    658     result := Phrases.Lookup('CITYEVENTS', i);
     658    Result := Phrases.Lookup('CITYEVENTS', I);
    659659end;
    660660
     
    666666  TBuffer = array [0 .. 99999, 0 .. 2] of Integer;
    667667var
    668   Sum, Cnt, dx, dy, nx, ny, ix, iy, ir, x, y, c, ch: Integer;
     668  Sum, Cnt, dx, dy, nx, ny, ix, iy, ir, X, Y, C, ch: Integer;
    669669  xdivider, ydivider: Integer;
    670670  Resampled: ^TBuffer;
     
    682682      PixelPtr := PixelPointer(BigImp, ScaleToNative(ix * xSizeBig),
    683683        ScaleToNative(Cut + iy * ySizeBig));
    684       for y := 0 to ScaleToNative(ySizeBig - 2 * Cut) - 1 do begin
    685         ydivider := (ScaleFromNative(y) * ySizeSmall div (ySizeBig - 2 * Cut) + 1) *
    686           (ySizeBig - 2 * Cut) - ScaleFromNative(y) * ySizeSmall;
     684      for Y := 0 to ScaleToNative(ySizeBig - 2 * Cut) - 1 do begin
     685        ydivider := (ScaleFromNative(Y) * ySizeSmall div (ySizeBig - 2 * Cut) + 1) *
     686          (ySizeBig - 2 * Cut) - ScaleFromNative(Y) * ySizeSmall;
    687687        if ydivider > ySizeSmall then
    688688          ydivider := ySizeSmall;
    689         for x := 0 to ScaleToNative(xSizeBig) - 1 do begin
    690           ir := ix * xSizeSmall + iy * nx * ySizeSmall + ScaleFromNative(x) *
    691             xSizeSmall div xSizeBig + ScaleFromNative(y) *
     689        for X := 0 to ScaleToNative(xSizeBig) - 1 do begin
     690          ir := ix * xSizeSmall + iy * nx * ySizeSmall + ScaleFromNative(X) *
     691            xSizeSmall div xSizeBig + ScaleFromNative(Y) *
    692692            ySizeSmall div (ySizeBig - 2 * Cut) * nx;
    693           xdivider := (ScaleFromNative(x) * xSizeSmall div xSizeBig + 1) *
    694             xSizeBig - ScaleFromNative(x) * xSizeSmall;
     693          xdivider := (ScaleFromNative(X) * xSizeSmall div xSizeBig + 1) *
     694            xSizeBig - ScaleFromNative(X) * xSizeSmall;
    695695          if xdivider > xSizeSmall then
    696696            xdivider := xSizeSmall;
    697697          for ch := 0 to 2 do begin
    698             c := PixelPtr.Pixel^.Planes[ch];
    699             Inc(Resampled[ir, ch], c * xdivider * ydivider);
     698            C := PixelPtr.Pixel^.Planes[ch];
     699            Inc(Resampled[ir, ch], C * xdivider * ydivider);
    700700            if xdivider < xSizeSmall then
    701               Inc(Resampled[ir + 1, ch], c * (xSizeSmall - xdivider) *
     701              Inc(Resampled[ir + 1, ch], C * (xSizeSmall - xdivider) *
    702702                ydivider);
    703703            if ydivider < ySizeSmall then
    704704              Inc(Resampled[ir + nx, ch],
    705                 c * xdivider * (ySizeSmall - ydivider));
     705                C * xdivider * (ySizeSmall - ydivider));
    706706            if (xdivider < xSizeSmall) and (ydivider < ySizeSmall) then
    707               Inc(Resampled[ir + nx + 1, ch], c * (xSizeSmall - xdivider) *
     707              Inc(Resampled[ir + nx + 1, ch], C * (xSizeSmall - xdivider) *
    708708                (ySizeSmall - ydivider));
    709709          end;
     
    719719  SmallImp.BeginUpdate;
    720720  PixelPtr := PixelPointer(SmallImp);
    721   for y := 0 to ScaleToNative(ny) - 1 do begin
    722     for x := 0 to ScaleToNative(nx) - 1 do begin
     721  for Y := 0 to ScaleToNative(ny) - 1 do begin
     722    for X := 0 to ScaleToNative(nx) - 1 do begin
    723723      for ch := 0 to 2 do begin
    724724        Sum := 0;
    725725        Cnt := 0;
    726726        for dy := -1 to 1 do
    727           if ((dy >= 0) or (ScaleFromNative(y) mod ySizeSmall > 0)) and
    728             ((dy <= 0) or (ScaleFromNative(y) mod ySizeSmall < ySizeSmall - 1)) then
     727          if ((dy >= 0) or (ScaleFromNative(Y) mod ySizeSmall > 0)) and
     728            ((dy <= 0) or (ScaleFromNative(Y) mod ySizeSmall < ySizeSmall - 1)) then
    729729            for dx := -1 to 1 do
    730               if ((dx >= 0) or (ScaleFromNative(x) mod xSizeSmall > 0)) and
    731                 ((dx <= 0) or (ScaleFromNative(x) mod xSizeSmall < xSizeSmall - 1)) then
     730              if ((dx >= 0) or (ScaleFromNative(X) mod xSizeSmall > 0)) and
     731                ((dx <= 0) or (ScaleFromNative(X) mod xSizeSmall < xSizeSmall - 1)) then
    732732              begin
    733                 Inc(Sum, Resampled[ScaleFromNative(x) + dx + nx * (ScaleFromNative(y) + dy), ch]);
     733                Inc(Sum, Resampled[ScaleFromNative(X) + dx + nx * (ScaleFromNative(Y) + dy), ch]);
    734734                Inc(Cnt);
    735735              end;
    736         Sum := ((Cnt * Sharpen + 800) * Resampled[ScaleFromNative(x) + nx * ScaleFromNative(y), ch] - Sum *
     736        Sum := ((Cnt * Sharpen + 800) * Resampled[ScaleFromNative(X) + nx * ScaleFromNative(Y), ch] - Sum *
    737737          Sharpen) div (800 * xSizeBig * (ySizeBig - 2 * Cut));
    738738        if Sum < 0 then Sum := 0;
     
    748748end;
    749749
    750 procedure ImpImage(ca: TCanvas; x, y, iix: integer; Government: integer;
    751   IsControl: boolean);
     750procedure ImpImage(ca: TCanvas; X, Y, iix: Integer; Government: Integer;
     751  IsControl: Boolean);
    752752begin
    753753  if Government < 0 then
     
    755755  if (iix = imPalace) and (Government <> gAnarchy) then
    756756    iix := Government - 8;
    757   FrameImage(ca, BigImp, x, y, xSizeBig, ySizeBig, (iix + SystemIconLines * 7)
     757  FrameImage(ca, BigImp, X, Y, xSizeBig, ySizeBig, (iix + SystemIconLines * 7)
    758758    mod 7 * xSizeBig, (iix + SystemIconLines * 7) div 7 * ySizeBig, IsControl);
    759759end;
     
    778778{ *** tribe management procedures *** }
    779779
    780 function RoughCredibility(Credibility: integer): integer;
     780function RoughCredibility(Credibility: Integer): Integer;
    781781begin
    782782  case Credibility of
    783783    0 .. 69:
    784       result := 0;
     784      Result := 0;
    785785    70 .. 89:
    786       result := 1;
     786      Result := 1;
    787787    90 .. 99:
    788       result := 2;
     788      Result := 2;
    789789    100:
    790       result := 3;
    791   end;
    792 end;
    793 
    794 procedure ChooseModelPicture(p, mix, code, Hash, Turn: integer;
    795   ForceNew, final: boolean);
     790      Result := 3;
     791  end;
     792end;
     793
     794procedure ChooseModelPicture(P, mix, Code, Hash, Turn: Integer;
     795  ForceNew, final: Boolean);
    796796var
    797   i: integer;
     797  I: Integer;
    798798  Picture: TModelPictureInfo;
    799   IsNew: boolean;
    800 begin
    801   Picture.trix := p;
     799  IsNew: Boolean;
     800begin
     801  Picture.trix := P;
    802802  Picture.mix := mix;
    803   if code = 74 then
     803  if Code = 74 then
    804804  begin // use correct pictures for slaves
    805     if Tribe[p].mixSlaves < 0 then
    806       if not TribeOriginal[p] then
    807         Tribe[p].mixSlaves := mix
     805    if Tribe[P].mixSlaves < 0 then
     806      if not TribeOriginal[P] then
     807        Tribe[P].mixSlaves := mix
    808808      else
    809809      begin
    810         i := mix + p shl 16;
    811         Server(cSetSlaveIndex, 0, 0, i);
     810        I := mix + P shl 16;
     811        Server(cSetSlaveIndex, 0, 0, I);
    812812      end;
    813813    if ToldSlavery = 1 then
     
    817817    Picture.Hash := 0;
    818818    Picture.GrName := 'StdUnits.png';
    819     IsNew := true;
     819    IsNew := True;
    820820  end
    821821  else
    822822  begin
    823823    Picture.Hash := Hash;
    824     IsNew := Tribe[p].ChooseModelPicture(Picture, code, Turn, ForceNew);
     824    IsNew := Tribe[P].ChooseModelPicture(Picture, Code, Turn, ForceNew);
    825825  end;
    826826  if final then
    827     if not TribeOriginal[p] then
    828       Tribe[p].SetModelPicture(Picture, IsNew)
     827    if not TribeOriginal[P] then
     828      Tribe[P].SetModelPicture(Picture, IsNew)
    829829    else if IsNew then
    830830      Server(CommandWithData(cSetNewModelPicture, Picture.GetCommandDataSize),
     
    834834        0, 0, Picture)
    835835  else
    836     with Tribe[p].ModelPicture[mix] do
     836    with Tribe[P].ModelPicture[mix] do
    837837    begin
    838838      HGr := LoadGraphicSet(Picture.GrName);
     
    841841end;
    842842
    843 function InitEnemyModel(emix: integer): boolean;
     843function InitEnemyModel(emix: Integer): Boolean;
    844844begin
    845845  if GameMode = cMovie then
    846846  begin
    847     result := false;
    848     exit;
     847    Result := False;
     848    Exit;
    849849  end;
    850850  with MyRO.EnemyModel[emix] do
    851851    ChooseModelPicture(Owner, mix, ModelCode(MyRO.EnemyModel[emix]),
    852       ModelHash(MyRO.EnemyModel[emix]), MyRO.Turn, false, true);
    853   result := true;
     852      ModelHash(MyRO.EnemyModel[emix]), MyRO.Turn, False, True);
     853  Result := True;
    854854end;
    855855
    856856procedure InitAllEnemyModels;
    857857var
    858   emix: integer;
     858  emix: Integer;
    859859begin
    860860  for emix := 0 to MyRO.nEnemyModel - 1 do
     
    864864end;
    865865
    866 procedure InitMyModel(mix: integer; final: boolean);
     866procedure InitMyModel(mix: Integer; final: Boolean);
    867867var
    868868  mi: TModelInfo;
    869869begin
    870870  if (GameMode = cMovie) and (MyModel[mix].Kind < $08) then
    871     exit;
     871    Exit;
    872872  // don't exit for special units because cSetModelPicture comes after TellNewModels
    873   MakeModelInfo(me, mix, MyModel[mix], mi);
    874   ChooseModelPicture(me, mix, ModelCode(mi), ModelHash(mi), MyRO.Turn,
    875     false, final);
    876 end;
    877 
    878 function AttackSound(code: integer): string;
    879 begin
    880   result := 'ATTACK_' + char(48 + code div 100 mod 10) +
    881     char(48 + code div 10 mod 10) + char(48 + code mod 10);
    882 end;
    883 
    884 procedure CheckToldNoReturn(uix: integer);
     873  MakeModelInfo(Me, mix, MyModel[mix], mi);
     874  ChooseModelPicture(Me, mix, ModelCode(mi), ModelHash(mi), MyRO.Turn,
     875    False, final);
     876end;
     877
     878function AttackSound(Code: Integer): string;
     879begin
     880  Result := 'ATTACK_' + char(48 + Code div 100 mod 10) +
     881    char(48 + Code div 10 mod 10) + char(48 + Code mod 10);
     882end;
     883
     884procedure CheckToldNoReturn(uix: Integer);
    885885// check whether aircraft survived low-fuel warning
    886886begin
    887   assert(not supervising);
     887  Assert(not Supervising);
    888888  with MyUn[uix] do
    889889    if (Status and usToldNoReturn <> 0) and
     
    893893end;
    894894
    895 function CreateTribe(p: integer; FileName: string; Original: boolean): boolean;
     895function CreateTribe(P: Integer; FileName: string; Original: Boolean): Boolean;
    896896begin
    897897  FileName := LocalizedFilePath('Tribes' + DirectorySeparator + FileName +
     
    903903  end;
    904904
    905   TribeOriginal[p] := Original;
    906   Tribe[p] := TTribe.Create(FileName);
    907   with Tribe[p] do
     905  TribeOriginal[P] := Original;
     906  Tribe[P] := TTribe.Create(FileName);
     907  with Tribe[P] do
    908908  begin
    909909    if (GameMode = cNewGame) or not Original then
    910910    begin
    911       Term.ChooseModelPicture(p, 0, 010, 1, 0, true, true);
    912       Term.ChooseModelPicture(p, 1, 040, 1, 0, true, true);
    913       Term.ChooseModelPicture(p, 2, 041, 1, 0, true, true);
    914       Term.ChooseModelPicture(p, -1, 017, 1, 0, true, true);
    915     end;
    916     DipMem[p].pContact := -1;
    917   end;
    918   result := true;
     911      Term.ChooseModelPicture(P, 0, 010, 1, 0, True, True);
     912      Term.ChooseModelPicture(P, 1, 040, 1, 0, True, True);
     913      Term.ChooseModelPicture(P, 2, 041, 1, 0, True, True);
     914      Term.ChooseModelPicture(P, -1, 017, 1, 0, True, True);
     915    end;
     916    DipMem[P].pContact := -1;
     917  end;
     918  Result := True;
    919919end;
    920920
    921921procedure TellNewContacts;
    922922var
    923   p1: integer;
    924 begin
    925   if not supervising then
     923  p1: Integer;
     924begin
     925  if not Supervising then
    926926    for p1 := 0 to nPl - 1 do
    927       if (p1 <> me) and (1 shl p1 and MyData.ToldContact = 0) and
     927      if (p1 <> Me) and (1 shl p1 and MyData.ToldContact = 0) and
    928928        (1 shl p1 and MyRO.Alive <> 0) and (MyRO.Treaty[p1] > trNoContact) then
    929929      begin
     
    935935procedure TellNewModels;
    936936var
    937   mix: integer;
     937  mix: Integer;
    938938  ModelNameInfo: TModelNameInfo;
    939939begin
    940   if supervising then
    941     exit;
    942   with Tribe[me] do
     940  if Supervising then
     941    Exit;
     942  with Tribe[Me] do
    943943    while MyData.ToldModels < MyRO.nModel do
    944944    begin { new Unit class available }
     
    951951      end;
    952952      if not Assigned(ModelPicture[MyData.ToldModels].HGr) then
    953         InitMyModel(MyData.ToldModels, true);
     953        InitMyModel(MyData.ToldModels, True);
    954954      { only run if no researched model }
    955955      with MessgExDlg do
     
    983983             (ModelNameInfo.GetCommandDataSize - 1 - CommandDataMaxSize), MaxInt);
    984984          Server(CommandWithData(cSetModelName, ModelNameInfo.GetCommandDataSize),
    985             me, 0, ModelNameInfo);
     985            Me, 0, ModelNameInfo);
    986986        end;
    987987      end;
     
    992992            MyModel[mix].Status := MyModel[mix].Status or msObsolete;
    993993      end;
    994       inc(MyData.ToldModels);
     994      Inc(MyData.ToldModels);
    995995    end;
    996996end;
     
    10171017end;
    10181018
    1019 procedure TMainScreen.PaintZoomedTile(dst: TBitmap; x, y, Loc: integer);
    1020 
    1021   procedure TSprite(xDst, yDst, xSrc, ySrc: integer);
     1019procedure TMainScreen.PaintZoomedTile(dst: TBitmap; X, Y, Loc: Integer);
     1020
     1021  procedure TSprite(xDst, yDst, xSrc, ySrc: Integer);
    10221022  begin
    10231023    with NoMapPanel do
    1024       Sprite(dst, HGrTerrain, x + xDst, y + yDst, xxt * 2, yyt * 3,
     1024      Sprite(dst, HGrTerrain, X + xDst, Y + yDst, xxt * 2, yyt * 3,
    10251025        1 + xSrc * (xxt * 2 + 1), 1 + ySrc * (yyt * 3 + 1));
    10261026  end;
    10271027
    1028   procedure TSprite4(xSrc, ySrc: integer);
     1028  procedure TSprite4(xSrc, ySrc: Integer);
    10291029  begin
    10301030    with NoMapPanel do begin
    1031       Sprite(dst, HGrTerrain, x + xxt, y + yyt + 2, xxt * 2, yyt * 2 - 2,
     1031      Sprite(dst, HGrTerrain, X + xxt, Y + yyt + 2, xxt * 2, yyt * 2 - 2,
    10321032        1 + xSrc * (xxt * 2 + 1), 3 + yyt + ySrc * (yyt * 3 + 1));
    1033       Sprite(dst, HGrTerrain, x + 4, y + 2 * yyt, xxt * 2 - 4, yyt * 2,
     1033      Sprite(dst, HGrTerrain, X + 4, Y + 2 * yyt, xxt * 2 - 4, yyt * 2,
    10341034        5 + xSrc * (xxt * 2 + 1), 1 + yyt + ySrc * (yyt * 3 + 1));
    1035       Sprite(dst, HGrTerrain, x + xxt * 2, y + 2 * yyt, xxt * 2 - 4, yyt * 2,
     1035      Sprite(dst, HGrTerrain, X + xxt * 2, Y + 2 * yyt, xxt * 2 - 4, yyt * 2,
    10361036        1 + xSrc * (xxt * 2 + 1), 1 + yyt + ySrc * (yyt * 3 + 1));
    1037       Sprite(dst, HGrTerrain, x + xxt, y + yyt * 3, xxt * 2, yyt * 2 - 2,
     1037      Sprite(dst, HGrTerrain, X + xxt, Y + yyt * 3, xxt * 2, yyt * 2 - 2,
    10381038        1 + xSrc * (xxt * 2 + 1), 1 + yyt + ySrc * (yyt * 3 + 1));
    10391039    end;
     
    10411041
    10421042var
    1043   cix, ySrc, Tile: integer;
     1043  cix, ySrc, Tile: Integer;
    10441044begin
    10451045  with NoMapPanel do begin
     
    10551055        cix := MyRO.nCity - 1;
    10561056        while (cix >= 0) and (MyCity[cix].Loc <> Loc) do
    1057           dec(cix);
    1058         assert(cix >= 0);
     1057          Dec(cix);
     1058        Assert(cix >= 0);
    10591059        if MyCity[cix].Built[imSupermarket] > 0 then
    10601060          Tile := Tile or tiFarm
     
    11471147end;
    11481148
    1149 function ChooseResearch: boolean;
     1149function ChooseResearch: Boolean;
    11501150var
    1151   ChosenResearch: integer;
     1151  ChosenResearch: Integer;
    11521152begin
    11531153  if (MyData.FarTech <> adNone) and (MyRO.Tech[MyData.FarTech] >= tsApplicable)
     
    11581158    repeat
    11591159      ModalSelectDlg.ShowNewContent(wmModal, kAdvance);
    1160       if ModalSelectDlg.result < 0 then
    1161       begin
    1162         result := false;
    1163         exit;
    1164       end;
    1165       ChosenResearch := ModalSelectDlg.result;
     1160      if ModalSelectDlg.Result < 0 then
     1161      begin
     1162        Result := False;
     1163        Exit;
     1164      end;
     1165      ChosenResearch := ModalSelectDlg.Result;
    11661166      if ChosenResearch = adMilitary then
    11671167      begin
    11681168        DraftDlg.ShowNewContent(wmModal);
    11691169        if DraftDlg.ModalResult <> mrOK then
    1170           Tribe[me].ModelPicture[MyRO.nModel].HGr := nil;
     1170          Tribe[Me].ModelPicture[MyRO.nModel].HGr := nil;
    11711171      end;
    11721172    until (ChosenResearch <> adMilitary) or (DraftDlg.ModalResult = mrOK);
    11731173
    11741174    if ChosenResearch = adMilitary then
    1175       InitMyModel(MyRO.nModel, true)
     1175      InitMyModel(MyRO.nModel, True)
    11761176    else if ChosenResearch = adFar then
    11771177    begin
    11781178      ModalSelectDlg.ShowNewContent(wmModal, kFarAdvance);
    1179       if ModalSelectDlg.result >= 0 then
    1180         if (ModalSelectDlg.result = adNone) or
    1181           (Server(sSetResearch - sExecute, me, ModalSelectDlg.result, nil^) <
     1179      if ModalSelectDlg.Result >= 0 then
     1180        if (ModalSelectDlg.Result = adNone) or
     1181          (Server(sSetResearch - sExecute, Me, ModalSelectDlg.Result, nil^) <
    11821182          rExecuted) then
    1183           MyData.FarTech := ModalSelectDlg.result
     1183          MyData.FarTech := ModalSelectDlg.Result
    11841184        else
    11851185        begin
    1186           ChosenResearch := ModalSelectDlg.result;
     1186          ChosenResearch := ModalSelectDlg.Result;
    11871187          // can be researched immediately
    11881188          MyData.FarTech := adNone;
     
    11931193    MyData.FarTech := adNexus
    11941194  else
    1195     Server(sSetResearch, me, ChosenResearch, nil^);
     1195    Server(sSetResearch, Me, ChosenResearch, nil^);
    11961196  ListDlg.TechChange;
    1197   result := true;
     1197  Result := True;
    11981198end;
    11991199
     
    12231223(* ** client function handling ** *)
    12241224
    1225 function TMainScreen.DipCall(Command: integer): integer;
     1225function TMainScreen.DipCall(Command: Integer): Integer;
    12261226var
    1227   i: integer;
    1228   IsTreatyDeal: boolean;
    1229 begin
    1230   result := Server(Command, me, 0, nil^);
    1231   if result >= rExecuted then
     1227  I: Integer;
     1228  IsTreatyDeal: Boolean;
     1229begin
     1230  Result := Server(Command, Me, 0, nil^);
     1231  if Result >= rExecuted then
    12321232  begin
    12331233    if Command and $FF0F = scContact then
    12341234    begin
    1235       DipMem[me].pContact := Command shr 4 and $F;
     1235      DipMem[Me].pContact := Command shr 4 and $F;
    12361236      NegoDlg.Initiate;
    1237       DipMem[me].DeliveredPrices := [];
    1238       DipMem[me].ReceivedPrices := [];
    1239     end;
    1240 
    1241     DipMem[me].SentCommand := Command;
    1242     DipMem[me].FormerTreaty := MyRO.Treaty[DipMem[me].pContact];
     1237      DipMem[Me].DeliveredPrices := [];
     1238      DipMem[Me].ReceivedPrices := [];
     1239    end;
     1240
     1241    DipMem[Me].SentCommand := Command;
     1242    DipMem[Me].FormerTreaty := MyRO.Treaty[DipMem[Me].pContact];
    12431243    if Command = scDipCancelTreaty then
    12441244      Play('CANCELTREATY')
    12451245    else if Command = scDipAccept then
    12461246    begin // remember delivered and received prices
    1247       for i := 0 to ReceivedOffer.nDeliver - 1 do
    1248         include(DipMem[me].ReceivedPrices, ReceivedOffer.Price[i] shr 24);
    1249       for i := 0 to ReceivedOffer.nCost - 1 do
    1250         include(DipMem[me].DeliveredPrices,
    1251           ReceivedOffer.Price[ReceivedOffer.nDeliver + i] shr 24);
    1252       IsTreatyDeal := false;
    1253       for i := 0 to ReceivedOffer.nDeliver + ReceivedOffer.nCost - 1 do
    1254         if ReceivedOffer.Price[i] and opMask = opTreaty then
    1255           IsTreatyDeal := true;
     1247      for I := 0 to ReceivedOffer.nDeliver - 1 do
     1248        Include(DipMem[Me].ReceivedPrices, ReceivedOffer.Price[I] shr 24);
     1249      for I := 0 to ReceivedOffer.nCost - 1 do
     1250        Include(DipMem[Me].DeliveredPrices,
     1251          ReceivedOffer.Price[ReceivedOffer.nDeliver + I] shr 24);
     1252      IsTreatyDeal := False;
     1253      for I := 0 to ReceivedOffer.nDeliver + ReceivedOffer.nCost - 1 do
     1254        if ReceivedOffer.Price[I] and opMask = opTreaty then
     1255          IsTreatyDeal := True;
    12561256      if IsTreatyDeal then
    12571257        Play('NEWTREATY')
     
    12601260    end;
    12611261    CityDlg.CloseAction := None;
    1262     if G.RO[DipMem[me].pContact] <> nil then
     1262    if G.RO[DipMem[Me].pContact] <> nil then
    12631263    begin // close windows for next player
    12641264      ApplyToVisibleForms(faClose);
     
    12741274end;
    12751275
    1276 function TMainScreen.OfferCall(var Offer: TOffer): integer;
    1277 begin
    1278   result := Server(scDipOffer, me, 0, Offer);
    1279   if result >= rExecuted then
    1280   begin
    1281     DipMem[me].SentCommand := scDipOffer;
    1282     DipMem[me].FormerTreaty := MyRO.Treaty[DipMem[me].pContact];
    1283     DipMem[me].SentOffer := Offer;
     1276function TMainScreen.OfferCall(var Offer: TOffer): Integer;
     1277begin
     1278  Result := Server(scDipOffer, Me, 0, Offer);
     1279  if Result >= rExecuted then
     1280  begin
     1281    DipMem[Me].SentCommand := scDipOffer;
     1282    DipMem[Me].FormerTreaty := MyRO.Treaty[DipMem[Me].pContact];
     1283    DipMem[Me].SentOffer := Offer;
    12841284    CityDlg.CloseAction := None;
    1285     if G.RO[DipMem[me].pContact] <> nil then
     1285    if G.RO[DipMem[Me].pContact] <> nil then
    12861286    begin // close windows for next player
    12871287      ApplyToVisibleForms(faClose);
     
    12971297end;
    12981298
    1299 procedure TMainScreen.SetUnFocus(uix: integer);
     1299procedure TMainScreen.SetUnFocus(uix: Integer);
    13001300var
    1301   Loc0: integer;
    1302 begin
    1303   assert(not((uix >= 0) and supervising));
     1301  Loc0: Integer;
     1302begin
     1303  Assert(not((uix >= 0) and Supervising));
    13041304  if uix <> UnFocus then
    13051305  begin
    1306     DestinationMarkON := false;
     1306    DestinationMarkON := False;
    13071307    PaintDestination;
    13081308    if uix >= 0 then
    13091309      UnStartLoc := MyUn[uix].Loc;
    1310     BlinkON := false;
     1310    BlinkON := False;
    13111311    BlinkTime := -1;
    13121312    if UnFocus >= 0 then
     
    13281328procedure TMainScreen.CheckTerrainBtnVisible;
    13291329var
    1330   Tile: integer;
     1330  Tile: Integer;
    13311331  mox: ^TModel;
    13321332begin
     
    13401340  end
    13411341  else
    1342     TerrainBtn.Visible := false;
     1342    TerrainBtn.Visible := False;
    13431343end;
    13441344
     
    13481348  begin
    13491349    MovieSpeed1Btn.Down := MovieSpeed = 1;
    1350     MovieSpeed1Btn.Visible := true;
     1350    MovieSpeed1Btn.Visible := True;
    13511351    MovieSpeed2Btn.Down := MovieSpeed = 2;
    1352     MovieSpeed2Btn.Visible := true;
     1352    MovieSpeed2Btn.Visible := True;
    13531353    MovieSpeed3Btn.Down := MovieSpeed = 3;
    1354     MovieSpeed3Btn.Visible := true;
     1354    MovieSpeed3Btn.Visible := True;
    13551355    MovieSpeed4Btn.Down := MovieSpeed = 4;
    1356     MovieSpeed4Btn.Visible := true;
     1356    MovieSpeed4Btn.Visible := True;
    13571357  end
    13581358  else
    13591359  begin
    1360     MovieSpeed1Btn.Visible := false;
    1361     MovieSpeed2Btn.Visible := false;
    1362     MovieSpeed3Btn.Visible := false;
    1363     MovieSpeed4Btn.Visible := false;
     1360    MovieSpeed1Btn.Visible := False;
     1361    MovieSpeed2Btn.Visible := False;
     1362    MovieSpeed3Btn.Visible := False;
     1363    MovieSpeed4Btn.Visible := False;
    13641364  end;
    13651365end;
     
    13751375end;
    13761376
    1377 procedure TMainScreen.UpdateViews(UpdateCityScreen: boolean);
     1377procedure TMainScreen.UpdateViews(UpdateCityScreen: Boolean);
    13781378begin
    13791379  SumCities(TaxSum, ScienceSum);
     
    13851385end;
    13861386
    1387 procedure TMainScreen.SetAIName(p: integer; Name: string);
     1387procedure TMainScreen.SetAIName(P: Integer; Name: string);
    13881388begin
    13891389  if Name = '' then
    13901390  begin
    1391     if AILogo[p] <> nil then
    1392     begin
    1393       FreeAndNil(AILogo[p]);
     1391    if AILogo[P] <> nil then
     1392    begin
     1393      FreeAndNil(AILogo[P]);
    13941394    end;
    13951395  end
    13961396  else
    13971397  begin
    1398     if AILogo[p] = nil then
    1399       AILogo[p] := TBitmap.Create;
    1400     if not LoadGraphicFile(AILogo[p], HomeDir + Name + '.png', [gfNoError]) then
    1401     begin
    1402       FreeAndNil(AILogo[p]);
    1403     end;
    1404   end;
    1405 end;
    1406 
    1407 function TMainScreen.ContactRefused(p: integer; Item: String): boolean;
     1398    if AILogo[P] = nil then
     1399      AILogo[P] := TBitmap.Create;
     1400    if not LoadGraphicFile(AILogo[P], HomeDir + Name + '.png', [gfNoError]) then
     1401    begin
     1402      FreeAndNil(AILogo[P]);
     1403    end;
     1404  end;
     1405end;
     1406
     1407function TMainScreen.ContactRefused(P: Integer; Item: String): Boolean;
    14081408// return whether treaty was cancelled
    14091409var
    1410   s: string;
    1411 begin
    1412   assert(MyRO.Treaty[p] >= trPeace);
    1413   s := Tribe[p].TPhrase(Item);
    1414   if MyRO.Turn < MyRO.LastCancelTreaty[p] + CancelTreatyTurns then
    1415   begin
    1416     SimpleMessage(s);
    1417     result := false;
     1410  S: string;
     1411begin
     1412  Assert(MyRO.Treaty[P] >= trPeace);
     1413  S := Tribe[P].TPhrase(Item);
     1414  if MyRO.Turn < MyRO.LastCancelTreaty[P] + CancelTreatyTurns then
     1415  begin
     1416    SimpleMessage(S);
     1417    Result := False;
    14181418  end
    14191419  else
    14201420  begin
    1421     case MyRO.Treaty[p] of
     1421    case MyRO.Treaty[P] of
    14221422      trPeace:
    1423         s := s + ' ' + Phrases.Lookup('FRCANCELQUERY_PEACE');
     1423        S := S + ' ' + Phrases.Lookup('FRCANCELQUERY_PEACE');
    14241424      trFriendlyContact:
    1425         s := s + ' ' + Phrases.Lookup('FRCANCELQUERY_FRIENDLY');
     1425        S := S + ' ' + Phrases.Lookup('FRCANCELQUERY_FRIENDLY');
    14261426      trAlliance:
    1427         s := s + ' ' + Phrases.Lookup('FRCANCELQUERY_ALLIANCE');
    1428     end;
    1429     result := SimpleQuery(mkYesNo, s, 'NEGO_REJECTED') = mrOK;
    1430     if result then
     1427        S := S + ' ' + Phrases.Lookup('FRCANCELQUERY_ALLIANCE');
     1428    end;
     1429    Result := SimpleQuery(mkYesNo, S, 'NEGO_REJECTED') = mrOK;
     1430    if Result then
    14311431    begin
    14321432      Play('CANCELTREATY');
    1433       Server(sCancelTreaty, me, 0, nil^);
    1434       if MyRO.Treaty[p] = trNone then
     1433      Server(sCancelTreaty, Me, 0, nil^);
     1434      if MyRO.Treaty[P] = trNone then
    14351435        CityOptimizer_BeginOfTurn;
    14361436      // peace treaty was cancelled -- use formerly forbidden tiles
    1437       MapValid := false;
     1437      MapValid := False;
    14381438      PaintAllMaps;
    14391439    end;
     
    14431443procedure TMainScreen.RememberPeaceViolation;
    14441444var
    1445   uix, p1: integer;
     1445  uix, p1: Integer;
    14461446begin
    14471447  MyData.PeaceEvaHappened := 0;
     
    14511451      begin
    14521452        p1 := MyRO.Territory[Loc];
    1453         if (p1 <> me) and (p1 >= 0) and
     1453        if (p1 <> Me) and (p1 >= 0) and
    14541454          (MyRO.Turn = MyRO.EvaStart[p1] + (PeaceEvaTurns - 1)) then
    14551455          MyData.PeaceEvaHappened := MyData.PeaceEvaHappened or (1 shl p1);
     
    14891489
    14901490var
    1491   i, cix, mix: integer;
    1492   need: boolean;
     1491  I, cix, mix: Integer;
     1492  need: Boolean;
    14931493  mi: TModelInfo;
    14941494begin
    14951495  if (sbStart in Check) and not (sbStart in SoundPreloadDone) then begin
    1496     for i := 0 to nStartBlock - 1 do
    1497       PreparePlay(StartBlock[i]);
     1496    for I := 0 to nStartBlock - 1 do
     1497      PreparePlay(StartBlock[I]);
    14981498    SoundPreloadDone := SoundPreloadDone + [sbStart];
    14991499  end;
    15001500  if (sbWonder in Check) and not (sbWonder in SoundPreloadDone) then begin
    1501     need := false;
    1502     for i := 0 to nWonder - 1 do
    1503       if MyRO.Wonder[i].CityID <> WonderNotBuiltYet then
    1504         need := true;
     1501    need := False;
     1502    for I := 0 to nWonder - 1 do
     1503      if MyRO.Wonder[I].CityID <> WonderNotBuiltYet then
     1504        need := True;
    15051505    if need then begin
    1506       for i := 0 to nWonderBlock - 1 do
    1507         PreparePlay(WonderBlock[i]);
     1506      for I := 0 to nWonderBlock - 1 do
     1507        PreparePlay(WonderBlock[I]);
    15081508      SoundPreloadDone := SoundPreloadDone + [sbWonder];
    15091509    end;
     
    15111511  if ((sbScience in Check) and not (sbScience in SoundPreloadDone)) and
    15121512    (MyRO.Tech[adScience] >= tsApplicable) then begin
    1513     for i := 0 to nScienceBlock - 1 do
    1514       PreparePlay(ScienceBlock[i]);
     1513    for I := 0 to nScienceBlock - 1 do
     1514      PreparePlay(ScienceBlock[I]);
    15151515    SoundPreloadDone := SoundPreloadDone + [sbScience];
    15161516  end;
    15171517  if ((sbContact in Check) and not (sbContact in SoundPreloadDone)) and
    15181518    (MyRO.nEnemyModel + MyRO.nEnemyCity > 0) then begin
    1519     for i := 0 to nContactBlock - 1 do
    1520       PreparePlay(ContactBlock[i]);
     1519    for I := 0 to nContactBlock - 1 do
     1520      PreparePlay(ContactBlock[I]);
    15211521    SoundPreloadDone := SoundPreloadDone + [sbContact];
    15221522  end;
     
    15291529      with MyCity[cix] do
    15301530        if (Loc >= 0) and (Flags and CityRepMask <> 0) then
    1531           for i := 0 to 12 do
    1532             if 1 shl i and Flags and CityRepMask <> 0 then
    1533               PreparePlay(CityEventSoundItem[i]);
     1531          for I := 0 to 12 do
     1532            if 1 shl I and Flags and CityRepMask <> 0 then
     1533              PreparePlay(CityEventSoundItem[I]);
    15341534    for mix := 0 to MyRO.nModel - 1 do
    15351535      with MyModel[mix] do
    15361536        if Attack > 0 then
    15371537        begin
    1538           MakeModelInfo(me, mix, MyModel[mix], mi);
     1538          MakeModelInfo(Me, mix, MyModel[mix], mi);
    15391539          PreparePlay(AttackSound(ModelCode(mi)));
    15401540        end;
     
    15471547  Color: TColor;
    15481548  Name: string;
    1549   ok: boolean;
     1549  ok: Boolean;
    15501550begin
    15511551  UnusedTribeFiles.Clear;
     
    15671567end;
    15681568
    1569 function TMainScreen.ChooseUnusedTribe: integer;
     1569function TMainScreen.ChooseUnusedTribe: Integer;
    15701570var
    1571   i: Integer;
    1572   j: Integer;
     1571  I: Integer;
     1572  J: Integer;
    15731573  ColorDistance: Integer;
    15741574  BestColorDistance: Integer;
     
    15761576  CountBest: Integer;
    15771577begin
    1578   assert(UnusedTribeFiles.Count > 0);
    1579   result := -1;
     1578  Assert(UnusedTribeFiles.Count > 0);
     1579  Result := -1;
    15801580  BestColorDistance := -1;
    1581   for j := 0 to UnusedTribeFiles.Count - 1 do
     1581  for J := 0 to UnusedTribeFiles.Count - 1 do
    15821582  begin
    15831583    ColorDistance := 250; // consider differences more than this infinite
    1584     for i := 0 to nPl - 1 do
    1585       if Tribe[i] <> nil then
    1586       begin
    1587         TestColorDistance := abs(integer(UnusedTribeFiles.Objects[j])
    1588           shr 16 and $FF - Tribe[i].Color shr 16 and $FF) +
    1589           abs(integer(UnusedTribeFiles.Objects[j]) shr 8 and
    1590           $FF - Tribe[i].Color shr 8 and $FF) * 3 +
    1591           abs(integer(UnusedTribeFiles.Objects[j]) and
    1592           $FF - Tribe[i].Color and $FF) * 2;
     1584    for I := 0 to nPl - 1 do
     1585      if Tribe[I] <> nil then
     1586      begin
     1587        TestColorDistance := abs(Integer(UnusedTribeFiles.Objects[J])
     1588          shr 16 and $FF - Tribe[I].Color shr 16 and $FF) +
     1589          abs(Integer(UnusedTribeFiles.Objects[J]) shr 8 and
     1590          $FF - Tribe[I].Color shr 8 and $FF) * 3 +
     1591          abs(Integer(UnusedTribeFiles.Objects[J]) and
     1592          $FF - Tribe[I].Color and $FF) * 2;
    15931593        if TestColorDistance < ColorDistance then
    15941594          ColorDistance := TestColorDistance;
     
    16011601    if ColorDistance = BestColorDistance then
    16021602    begin
    1603       inc(CountBest);
     1603      Inc(CountBest);
    16041604      if DelphiRandom(CountBest) = 0 then
    1605         result := j;
     1605        Result := J;
    16061606    end;
    16071607  end;
     
    16101610procedure TMainScreen.ShowEnemyShipChange(ShowShipChange: TShowShipChange);
    16111611var
    1612   i, TestCost, MostCost: integer;
    1613   Ship1Plus, Ship2Plus: boolean;
     1612  I, TestCost, MostCost: Integer;
     1613  Ship1Plus, Ship2Plus: Boolean;
    16141614begin
    16151615  with ShowShipChange, MessgExDlg do
     
    16341634        begin
    16351635          OpenSound := 'SHIP_TRADED';
    1636           Ship1Plus := false;
    1637           Ship2Plus := false;
    1638           for i := 0 to nShipPart - 1 do
     1636          Ship1Plus := False;
     1637          Ship2Plus := False;
     1638          for I := 0 to nShipPart - 1 do
    16391639          begin
    1640             if Ship1Change[i] > 0 then
    1641               Ship1Plus := true;
    1642             if Ship2Change[i] > 0 then
    1643               Ship2Plus := true;
     1640            if Ship1Change[I] > 0 then
     1641              Ship1Plus := True;
     1642            if Ship2Change[I] > 0 then
     1643              Ship2Plus := True;
    16441644          end;
    16451645          if Ship1Plus and Ship2Plus then
     
    16681668    begin
    16691669      MostCost := 0;
    1670       for i := 0 to nShipPart - 1 do
    1671       begin
    1672         TestCost := abs(Ship1Change[i]) * Imp[imShipComp + i].Cost;
     1670      for I := 0 to nShipPart - 1 do
     1671      begin
     1672        TestCost := abs(Ship1Change[I]) * Imp[imShipComp + I].Cost;
    16731673        if TestCost > MostCost then
    16741674        begin
    16751675          MostCost := TestCost;
    1676           IconIndex := imShipComp + i;
     1676          IconIndex := imShipComp + I;
    16771677        end;
    16781678      end;
     
    16861686procedure TMainScreen.InitModule;
    16871687var
    1688   i, j, Domain: integer;
     1688  I, J, Domain: Integer;
    16891689begin
    16901690  { search icons for advances: }
    1691   for i := 0 to nAdv - 1 do
    1692     if i in FutureTech then
    1693       AdvIcon[i] := 96 + i - futResearchTechnology
     1691  for I := 0 to nAdv - 1 do
     1692    if I in FutureTech then
     1693      AdvIcon[I] := 96 + I - futResearchTechnology
    16941694    else
    16951695    begin
    1696       AdvIcon[i] := -1;
     1696      AdvIcon[I] := -1;
    16971697      for Domain := 0 to nDomains - 1 do
    1698         for j := 0 to nUpgrade - 1 do
    1699           if upgrade[Domain, j].Preq = i then
    1700             if AdvIcon[i] >= 0 then
    1701               AdvIcon[i] := 85
     1698        for J := 0 to nUpgrade - 1 do
     1699          if upgrade[Domain, J].Preq = I then
     1700            if AdvIcon[I] >= 0 then
     1701              AdvIcon[I] := 85
    17021702            else
    1703               AdvIcon[i] := 86 + Domain;
    1704       for j := 0 to nFeature - 1 do
    1705         if Feature[j].Preq = i then
     1703              AdvIcon[I] := 86 + Domain;
     1704      for J := 0 to nFeature - 1 do
     1705        if Feature[J].Preq = I then
    17061706          for Domain := 0 to nDomains - 1 do
    1707             if 1 shl Domain and Feature[j].Domains <> 0 then
    1708               if (AdvIcon[i] >= 0) and (AdvIcon[i] <> 86 + Domain) then
    1709                 AdvIcon[i] := 85
     1707            if 1 shl Domain and Feature[J].Domains <> 0 then
     1708              if (AdvIcon[I] >= 0) and (AdvIcon[I] <> 86 + Domain) then
     1709                AdvIcon[I] := 85
    17101710              else
    1711                 AdvIcon[i] := 86 + Domain;
    1712       for j := nWonder to nImp - 1 do
    1713         if Imp[j].Preq = i then
    1714           AdvIcon[i] := j;
    1715       for j := nWonder to nImp - 1 do
    1716         if (Imp[j].Preq = i) and (Imp[j].Kind <> ikCommon) then
    1717           AdvIcon[i] := j;
    1718       for j := 0 to nJob - 1 do
    1719         if i = JobPreq[j] then
    1720           AdvIcon[i] := 84;
    1721       for j := 0 to nWonder - 1 do
    1722         if Imp[j].Preq = i then
    1723           AdvIcon[i] := j;
    1724       if AdvIcon[i] < 0 then
    1725         if AdvValue[i] < 1000 then
    1726           AdvIcon[i] := -7
     1711                AdvIcon[I] := 86 + Domain;
     1712      for J := nWonder to nImp - 1 do
     1713        if Imp[J].Preq = I then
     1714          AdvIcon[I] := J;
     1715      for J := nWonder to nImp - 1 do
     1716        if (Imp[J].Preq = I) and (Imp[J].Kind <> ikCommon) then
     1717          AdvIcon[I] := J;
     1718      for J := 0 to nJob - 1 do
     1719        if I = JobPreq[J] then
     1720          AdvIcon[I] := 84;
     1721      for J := 0 to nWonder - 1 do
     1722        if Imp[J].Preq = I then
     1723          AdvIcon[I] := J;
     1724      if AdvIcon[I] < 0 then
     1725        if AdvValue[I] < 1000 then
     1726          AdvIcon[I] := -7
    17271727        else
    1728           AdvIcon[i] := 24 + AdvValue[i] div 1000;
    1729       for j := 2 to nGov - 1 do
    1730         if GovPreq[j] = i then
    1731           AdvIcon[i] := j - 8;
     1728          AdvIcon[I] := 24 + AdvValue[I] div 1000;
     1729      for J := 2 to nGov - 1 do
     1730        if GovPreq[J] = I then
     1731          AdvIcon[I] := J - 8;
    17321732    end;
    17331733  AdvIcon[adConscription] := 86 + dGround;
    17341734
    17351735  UnusedTribeFiles := tstringlist.Create;
    1736   UnusedTribeFiles.Sorted := true;
     1736  UnusedTribeFiles.Sorted := True;
    17371737  TribeNames := tstringlist.Create;
    17381738
    17391739  IsoEngine.Init(InitEnemyModel);
    17401740  // non-default tile size is missing a file, switch to default
    1741   MainMap.SetOutput(offscreen);
     1741  MainMap.SetOutput(Offscreen);
    17421742
    17431743  HGrStdUnits := LoadGraphicSet('StdUnits.png');
     
    17461746  InitSmallImp;
    17471747  SoundPreloadDone := [];
    1748   StartRunning := false;
    1749   StayOnTop_Ensured := false;
     1748  StartRunning := False;
     1749  StayOnTop_Ensured := False;
    17501750
    17511751  sb := TPVScrollbar.Create(Self);
     
    17611761end;
    17621762
    1763 procedure TMainScreen.InitTurn(NewPlayer: integer);
     1763procedure TMainScreen.InitTurn(NewPlayer: Integer);
    17641764const
    17651765  nAdvBookIcon = 16;
    17661766  AdvBookIcon: array [0 .. nAdvBookIcon - 1] of record Adv,
    1767     Icon: integer end = ((Adv: adPolyTheism; Icon: woZeus),
     1767    Icon: Integer end = ((Adv: adPolyTheism; Icon: woZeus),
    17681768    (Adv: adBronzeWorking; Icon: woColossus), (Adv: adMapMaking;
    17691769    Icon: woLighthouse), (Adv: adPoetry; Icon: imTheater), (Adv: adMonotheism;
     
    17771777  sbAll = [sbStart, sbWonder, sbScience, sbContact, sbTurn];
    17781778var
    1779   p1, i, ad, uix, cix, MoveOptions, MoveResult, Loc1,
     1779  p1, I, ad, uix, cix, MoveOptions, MoveResult, Loc1,
    17801780    NewAgeCenterTo, Winners, NewGovAvailable, dx,
    1781     dy: integer;
     1781    dy: Integer;
    17821782  MoveAdviceData: TMoveAdviceData;
    17831783  Picture: TModelPictureInfo;
    1784   s, Item, Item2: string;
     1784  S, Item, Item2: string;
    17851785  UpdatePanel, OwnWonder, ok, Stop, ShowCityList, WondersOnly,
    1786     AllowCityScreen: boolean;
    1787 begin
    1788   if IsMultiPlayerGame and (NewPlayer <> me) then
    1789   begin
    1790     UnitInfoBtn.Visible := false;
    1791     UnitBtn.Visible := false;
    1792     TerrainBtn.Visible := false;
    1793     EOT.Visible := false;
    1794   end;
    1795   if IsMultiPlayerGame and (NewPlayer <> me) and
     1786    AllowCityScreen: Boolean;
     1787begin
     1788  if IsMultiPlayerGame and (NewPlayer <> Me) then
     1789  begin
     1790    UnitInfoBtn.Visible := False;
     1791    UnitBtn.Visible := False;
     1792    TerrainBtn.Visible := False;
     1793    EOT.Visible := False;
     1794  end;
     1795  if IsMultiPlayerGame and (NewPlayer <> Me) and
    17961796    (G.RO[0].Happened and phShipComplete = 0) then
    17971797  begin // inter player screen
    1798     for i := 0 to ControlCount - 1 do
    1799       if Controls[i] is TButtonC then
    1800         Controls[i].Visible := false;
    1801     me := -1;
     1798    for I := 0 to ControlCount - 1 do
     1799      if Controls[I] is TButtonC then
     1800        Controls[I].Visible := False;
     1801    Me := -1;
    18021802    MainTexture.Age := -1;
    18031803    with Panel.Canvas do
     
    18151815    Invalidate;
    18161816
    1817     s := TurnToString(G.RO[0].Turn);
    1818     if supervising then
    1819       SimpleMessage(Format(Phrases.Lookup('SUPERTURN'), [s]))
     1817    S := TurnToString(G.RO[0].Turn);
     1818    if Supervising then
     1819      SimpleMessage(Format(Phrases.Lookup('SUPERTURN'), [S]))
    18201820    else
    1821       SimpleMessage(Format(Tribe[NewPlayer].TPhrase('TURN'), [s]));
    1822   end;
    1823   for i := 0 to ControlCount - 1 do
    1824     if Controls[i] is TButtonC then
    1825       Controls[i].Visible := true;
     1821      SimpleMessage(Format(Tribe[NewPlayer].TPhrase('TURN'), [S]));
     1822  end;
     1823  for I := 0 to ControlCount - 1 do
     1824    if Controls[I] is TButtonC then
     1825      Controls[I].Visible := True;
    18261826
    18271827  ItsMeAgain(NewPlayer);
    18281828  MyData := G.RO[NewPlayer].Data;
    1829   if not supervising then
     1829  if not Supervising then
    18301830    SoundPreload(sbAll);
    1831   if (me = 0) and ((MyRO.Turn = 0) or (ClientMode = cResume)) then
     1831  if (Me = 0) and ((MyRO.Turn = 0) or (ClientMode = cResume)) then
    18321832    Invalidate; // colorize empty space
    18331833
    1834   if not supervising then
     1834  if not Supervising then
    18351835  begin
    18361836
     
    18421842      else }
    18431843    begin
    1844       Age := GetAge(me);
     1844      Age := GetAge(Me);
    18451845      if MainTexture.Age <> Age then begin
    18461846        MainTexture.Age := Age;
     
    18691869  NatStatDlg.CheckAge;
    18701870  UnitStatDlg.CheckAge;
    1871   HelpDlg.Difficulty := G.Difficulty[me];
     1871  HelpDlg.Difficulty := G.Difficulty[Me];
    18721872
    18731873  UnFocus := -1;
    18741874  MarkCityLoc := -1;
    1875   BlinkON := false;
     1875  BlinkON := False;
    18761876  BlinkTime := -1;
    1877   Tracking := false;
    1878   TurnComplete := false;
     1877  Tracking := False;
     1878  TurnComplete := False;
    18791879
    18801880  if (ToldSlavery < 0) or
     
    18961896          Hash := 0;
    18971897          GrName := 'StdUnits.png';
    1898           Tribe[p1].SetModelPicture(Picture, true);
     1898          Tribe[p1].SetModelPicture(Picture, True);
    18991899        end;
    19001900  end;
    19011901
    1902   if not supervising and (ClientMode = cTurn) then
     1902  if not Supervising and (ClientMode = cTurn) then
    19031903  begin
    19041904    for cix := 0 to MyRO.nCity - 1 do
     
    19151915  if ClientMode = cMovieTurn then
    19161916  begin
    1917     UnitInfoBtn.Visible := false;
    1918     UnitBtn.Visible := false;
    1919     TerrainBtn.Visible := false;
     1917    UnitInfoBtn.Visible := False;
     1918    UnitBtn.Visible := False;
     1919    TerrainBtn.Visible := False;
    19201920    EOT.Hint := Phrases.Lookup('BTN_STOP');
    1921     EOT.Visible := true;
     1921    EOT.Visible := True;
    19221922  end
    19231923  else if ClientMode < scContact then
     
    19261926    UnitBtn.Visible := UnFocus >= 0;
    19271927    CheckTerrainBtnVisible;
    1928     TurnComplete := supervising;
     1928    TurnComplete := Supervising;
    19291929    EOT.Hint := Phrases.Lookup('BTN_ENDTURN');
    1930     EOT.Visible := Server(sTurn - sExecute, me, 0, nil^) >= rExecuted;
     1930    EOT.Visible := Server(sTurn - sExecute, Me, 0, nil^) >= rExecuted;
    19311931  end
    19321932  else
    19331933  begin
    1934     UnitInfoBtn.Visible := false;
    1935     UnitBtn.Visible := false;
    1936     TerrainBtn.Visible := false;
     1934    UnitInfoBtn.Visible := False;
     1935    UnitBtn.Visible := False;
     1936    TerrainBtn.Visible := False;
    19371937    EOT.Hint := Phrases.Lookup('BTN_NEGO');
    1938     EOT.Visible := true;
     1938    EOT.Visible := True;
    19391939  end;
    19401940  SetTroopLoc(-1);
    1941   MapValid := false;
     1941  MapValid := False;
    19421942  NewAgeCenterTo := 0;
    1943   if ((MyRO.Turn = 0) and not supervising or IsMultiPlayerGame or
     1943  if ((MyRO.Turn = 0) and not Supervising or IsMultiPlayerGame or
    19441944    (ClientMode = cResume)) and (MyRO.nCity > 0) then
    19451945  begin
     
    19861986        begin
    19871987          OpenSound := 'MSG_GAMEOVER';
    1988           MessgText := Tribe[me].TPhrase('GAMEOVER');
     1988          MessgText := Tribe[Me].TPhrase('GAMEOVER');
    19891989          IconKind := mikBigIcon;
    19901990          IconIndex := 8;
     
    19971997            begin
    19981998              Winners := Winners or 1 shl p1;
    1999               for i := 0 to nShipPart - 1 do
    2000                 if MyRO.Ship[p1].Parts[i] < ShipNeed[i] then
     1999              for I := 0 to nShipPart - 1 do
     2000                if MyRO.Ship[p1].Parts[I] < ShipNeed[I] then
    20012001                  Winners := Winners and not(1 shl p1);
    20022002            end;
    2003           assert(Winners <> 0);
    2004           if Winners and (1 shl me) <> 0 then
     2003          Assert(Winners <> 0);
     2004          if Winners and (1 shl Me) <> 0 then
    20052005          begin
    2006             s := '';
     2006            S := '';
    20072007            for p1 := 0 to nPl - 1 do
    2008               if (p1 <> me) and (1 shl p1 and Winners <> 0) then
    2009                 if s = '' then
    2010                   s := Tribe[p1].TPhrase('SHORTNAME')
     2008              if (p1 <> Me) and (1 shl p1 and Winners <> 0) then
     2009                if S = '' then
     2010                  S := Tribe[p1].TPhrase('SHORTNAME')
    20112011                else
    2012                   s := Format(Phrases.Lookup('SHAREDWIN_CONCAT'),
    2013                     [s, Tribe[p1].TPhrase('SHORTNAME')]);
     2012                  S := Format(Phrases.Lookup('SHAREDWIN_CONCAT'),
     2013                    [S, Tribe[p1].TPhrase('SHORTNAME')]);
    20142014
    20152015            OpenSound := 'MSG_YOUWIN';
    2016             MessgText := Tribe[me].TPhrase('MYSPACESHIP');
    2017             if s <> '' then
     2016            MessgText := Tribe[Me].TPhrase('MYSPACESHIP');
     2017            if S <> '' then
    20182018              MessgText := MessgText + '\' +
    2019                 Format(Phrases.Lookup('SHAREDWIN'), [s]);
     2019                Format(Phrases.Lookup('SHAREDWIN'), [S]);
    20202020            IconKind := mikBigIcon;
    20212021            IconIndex := 9;
     
    20232023          else
    20242024          begin
    2025             assert(me = 0);
     2025            Assert(Me = 0);
    20262026            OpenSound := 'MSG_GAMEOVER';
    20272027            MessgText := '';
     
    20352035        else { if MyRO.Happened and fTimeUp<>0 then }
    20362036        begin
    2037           assert(me = 0);
     2037          Assert(Me = 0);
    20382038          OpenSound := 'MSG_GAMEOVER';
    2039           if not supervising then
    2040             MessgText := Tribe[me].TPhrase('TIMEUP')
     2039          if not Supervising then
     2040            MessgText := Tribe[Me].TPhrase('TIMEUP')
    20412041          else
    20422042            MessgText := Phrases.Lookup('TIMEUPSUPER');
     
    20502050          p1 := 0;
    20512051          while (p1 < nPl - 1) and (Winners and (1 shl p1) = 0) do
    2052             inc(p1);
     2052            Inc(p1);
    20532053          if MyRO.Happened and phShipComplete = 0 then
    20542054            DiaDlg.ShowNewContent_Charts(wmModal);
    20552055        end;
    2056         TurnComplete := true;
    2057         exit;
    2058       end;
    2059     if not supervising and (1 shl me and MyRO.Alive = 0) then
    2060     begin
    2061       TurnComplete := true;
    2062       exit;
     2056        TurnComplete := True;
     2057        Exit;
     2058      end;
     2059    if not Supervising and (1 shl Me and MyRO.Alive = 0) then
     2060    begin
     2061      TurnComplete := True;
     2062      Exit;
    20632063    end;
    20642064
    20652065    if (ClientMode = cContinue) and
    2066       (DipMem[me].SentCommand and $FF0F = scContact) then
     2066      (DipMem[Me].SentCommand and $FF0F = scContact) then
    20672067      // contact was refused
    2068       if MyRO.Treaty[DipMem[me].pContact] >= trPeace then
    2069         ContactRefused(DipMem[me].pContact, 'FRREJECTED')
     2068      if MyRO.Treaty[DipMem[Me].pContact] >= trPeace then
     2069        ContactRefused(DipMem[Me].pContact, 'FRREJECTED')
    20702070      else
    2071         SoundMessage(Tribe[DipMem[me].pContact].TPhrase('FRREJECTED'),
     2071        SoundMessage(Tribe[DipMem[Me].pContact].TPhrase('FRREJECTED'),
    20722072          'NEGO_REJECTED');
    20732073
    2074     if not supervising and (Age > MyData.ToldAge) and
     2074    if not Supervising and (Age > MyData.ToldAge) and
    20752075      ((Age > 0) or (ClientMode <> cMovieTurn)) then
    20762076      with MessgExDlg do
     
    20802080          if Phrases2FallenBackToEnglish then
    20812081          begin
    2082             s := Tribe[me].TPhrase('AGE0');
     2082            S := Tribe[Me].TPhrase('AGE0');
    20832083            MessgText :=
    2084               Format(s, [TurnToString(MyRO.Turn), CityName(MyCity[0].ID)]);
     2084              Format(S, [TurnToString(MyRO.Turn), CityName(MyCity[0].ID)]);
    20852085          end
    20862086          else
    20872087          begin
    2088             s := Tribe[me].TString(Phrases2.Lookup('AGE0'));
    2089             MessgText := Format(s, [TurnToString(MyRO.Turn)]);
     2088            S := Tribe[Me].TString(Phrases2.Lookup('AGE0'));
     2089            MessgText := Format(S, [TurnToString(MyRO.Turn)]);
    20902090          end;
    20912091        end
    20922092        else
    20932093        begin
    2094           s := Tribe[me].TPhrase('AGE' + char(48 + Age));
    2095           MessgText := Format(s, [TurnToString(MyRO.Turn)]);
     2094          S := Tribe[Me].TPhrase('AGE' + char(48 + Age));
     2095          MessgText := Format(S, [TurnToString(MyRO.Turn)]);
    20962096        end;
    20972097        IconKind := mikAge;
     
    21152115          begin
    21162116            OpenSound := 'MSG_EXTINCT';
    2117             s := Tribe[p1].TPhrase('EXTINCT');
    2118             MessgText := Format(s, [TurnToString(MyRO.Turn)]);
    2119             if MyRO.Alive = 1 shl me then
     2117            S := Tribe[p1].TPhrase('EXTINCT');
     2118            MessgText := Format(S, [TurnToString(MyRO.Turn)]);
     2119            if MyRO.Alive = 1 shl Me then
    21202120              MessgText := MessgText + Phrases.Lookup('EXTINCTALL');
    21212121            Kind := mkOk;
     
    21242124            ShowModal;
    21252125          end;
    2126       if (ClientMode <> cMovieTurn) and not supervising then
     2126      if (ClientMode <> cMovieTurn) and not Supervising then
    21272127        DiaDlg.ShowNewContent_Charts(wmModal);
    21282128    end;
    21292129
    21302130    // tell changes of own credibility
    2131     if not supervising then
     2131    if not Supervising then
    21322132    begin
    21332133      if RoughCredibility(MyRO.Credibility) <>
     
    21362136        if RoughCredibility(MyRO.Credibility) >
    21372137          RoughCredibility(MyData.ToldOwnCredibility) then
    2138           s := Phrases.Lookup('CREDUP')
     2138          S := Phrases.Lookup('CREDUP')
    21392139        else
    2140           s := Phrases.Lookup('CREDDOWN');
    2141         TribeMessage(me, Format(s, [Phrases.Lookup('CREDIBILITY',
     2140          S := Phrases.Lookup('CREDDOWN');
     2141        TribeMessage(Me, Format(S, [Phrases.Lookup('CREDIBILITY',
    21422142          RoughCredibility(MyRO.Credibility))]), '');
    21432143      end;
     
    21452145    end;
    21462146
    2147     for i := 0 to nWonder - 1 do
    2148     begin
    2149       OwnWonder := false;
     2147    for I := 0 to nWonder - 1 do
     2148    begin
     2149      OwnWonder := False;
    21502150      for cix := 0 to MyRO.nCity - 1 do
    2151         if (MyCity[cix].Loc >= 0) and (MyCity[cix].ID = MyRO.Wonder[i].CityID)
     2151        if (MyCity[cix].Loc >= 0) and (MyCity[cix].ID = MyRO.Wonder[I].CityID)
    21522152        then
    2153           OwnWonder := true;
    2154       if MyRO.Wonder[i].CityID <> MyData.ToldWonders[i].CityID then
    2155       begin
    2156         if MyRO.Wonder[i].CityID = WonderDestroyed then
     2153          OwnWonder := True;
     2154      if MyRO.Wonder[I].CityID <> MyData.ToldWonders[I].CityID then
     2155      begin
     2156        if MyRO.Wonder[I].CityID = WonderDestroyed then
    21572157          with MessgExDlg do
    21582158          begin { tell about destroyed wonders }
    21592159            OpenSound := 'WONDER_DESTROYED';
    21602160            MessgText := Format(Phrases.Lookup('WONDERDEST'),
    2161               [Phrases.Lookup('IMPROVEMENTS', i)]);
     2161              [Phrases.Lookup('IMPROVEMENTS', I)]);
    21622162            Kind := mkOkHelp;
    21632163            HelpKind := hkImp;
    2164             HelpNo := i;
     2164            HelpNo := I;
    21652165            IconKind := mikImp;
    2166             IconIndex := i;
     2166            IconIndex := I;
    21672167            ShowModal;
    21682168          end
    21692169        else
    21702170        begin
    2171           if i = woManhattan then
    2172             if MyRO.Wonder[i].EffectiveOwner > me then
     2171          if I = woManhattan then
     2172            if MyRO.Wonder[I].EffectiveOwner > Me then
    21732173              MyData.ColdWarStart := MyRO.Turn - 1
    21742174            else
     
    21772177            with MessgExDlg do
    21782178            begin { tell about newly built wonders }
    2179               if i = woManhattan then
     2179              if I = woManhattan then
    21802180              begin
    21812181                OpenSound := 'MSG_COLDWAR';
    2182                 s := Tribe[MyRO.Wonder[i].EffectiveOwner].TPhrase('COLDWAR');
     2182                S := Tribe[MyRO.Wonder[I].EffectiveOwner].TPhrase('COLDWAR');
    21832183              end
    2184               else if MyRO.Wonder[i].EffectiveOwner >= 0 then
     2184              else if MyRO.Wonder[I].EffectiveOwner >= 0 then
    21852185              begin
    21862186                OpenSound := 'WONDER_BUILT';
    2187                 s := Tribe[MyRO.Wonder[i].EffectiveOwner]
     2187                S := Tribe[MyRO.Wonder[I].EffectiveOwner]
    21882188                  .TPhrase('WONDERBUILT');
    21892189              end
     
    21912191              begin
    21922192                OpenSound := 'MSG_DEFAULT';
    2193                 s := Phrases.Lookup('WONDERBUILTEXP');
     2193                S := Phrases.Lookup('WONDERBUILTEXP');
    21942194                // already expired when built
    21952195              end;
    2196               MessgText := Format(s, [Phrases.Lookup('IMPROVEMENTS', i),
    2197                 CityName(MyRO.Wonder[i].CityID)]);
     2196              MessgText := Format(S, [Phrases.Lookup('IMPROVEMENTS', I),
     2197                CityName(MyRO.Wonder[I].CityID)]);
    21982198              Kind := mkOkHelp;
    21992199              HelpKind := hkImp;
    2200               HelpNo := i;
     2200              HelpNo := I;
    22012201              IconKind := mikImp;
    2202               IconIndex := i;
     2202              IconIndex := I;
    22032203              ShowModal;
    22042204            end;
    22052205        end;
    22062206      end
    2207       else if (MyRO.Wonder[i].EffectiveOwner <> MyData.ToldWonders[i]
    2208         .EffectiveOwner) and (MyRO.Wonder[i].CityID > WonderDestroyed) then
    2209         if MyRO.Wonder[i].EffectiveOwner < 0 then
     2207      else if (MyRO.Wonder[I].EffectiveOwner <> MyData.ToldWonders[I]
     2208        .EffectiveOwner) and (MyRO.Wonder[I].CityID > WonderDestroyed) then
     2209        if MyRO.Wonder[I].EffectiveOwner < 0 then
    22102210        begin
    2211           if i <> woMIR then
     2211          if I <> woMIR then
    22122212            with MessgExDlg do
    22132213            begin { tell about expired wonders }
    22142214              OpenSound := 'WONDER_EXPIRED';
    22152215              MessgText := Format(Phrases.Lookup('WONDEREXP'),
    2216                 [Phrases.Lookup('IMPROVEMENTS', i),
    2217                 CityName(MyRO.Wonder[i].CityID)]);
     2216                [Phrases.Lookup('IMPROVEMENTS', I),
     2217                CityName(MyRO.Wonder[I].CityID)]);
    22182218              Kind := mkOkHelp;
    22192219              HelpKind := hkImp;
    2220               HelpNo := i;
     2220              HelpNo := I;
    22212221              IconKind := mikImp;
    2222               IconIndex := i;
     2222              IconIndex := I;
    22232223              ShowModal;
    22242224            end;
    22252225        end
    2226         else if (MyData.ToldWonders[i].EffectiveOwner >= 0) and not OwnWonder
     2226        else if (MyData.ToldWonders[I].EffectiveOwner >= 0) and not OwnWonder
    22272227        then
    22282228          with MessgExDlg do
    22292229          begin { tell about capture of wonders }
    22302230            OpenSound := 'WONDER_CAPTURED';
    2231             s := Tribe[MyRO.Wonder[i].EffectiveOwner].TPhrase('WONDERCAPT');
    2232             MessgText := Format(s, [Phrases.Lookup('IMPROVEMENTS', i),
    2233               CityName(MyRO.Wonder[i].CityID)]);
     2231            S := Tribe[MyRO.Wonder[I].EffectiveOwner].TPhrase('WONDERCAPT');
     2232            MessgText := Format(S, [Phrases.Lookup('IMPROVEMENTS', I),
     2233              CityName(MyRO.Wonder[I].CityID)]);
    22342234            Kind := mkOkHelp;
    22352235            HelpKind := hkImp;
    2236             HelpNo := i;
     2236            HelpNo := I;
    22372237            IconKind := mikImp;
    2238             IconIndex := i;
     2238            IconIndex := I;
    22392239            ShowModal;
    22402240          end;
     
    22502250  end; // ClientMode<>cResume
    22512251  MyData.ToldAlive := MyRO.Alive;
    2252   move(MyRO.Wonder, MyData.ToldWonders, SizeOf(MyData.ToldWonders));
     2252  Move(MyRO.Wonder, MyData.ToldWonders, SizeOf(MyData.ToldWonders));
    22532253
    22542254  NewGovAvailable := -1;
     
    22742274          IconKind := mikBook;
    22752275          IconIndex := -1;
    2276           for i := 0 to nAdvBookIcon - 1 do
    2277             if AdvBookIcon[i].Adv = ad then
    2278               IconIndex := AdvBookIcon[i].Icon;
     2276          for I := 0 to nAdvBookIcon - 1 do
     2277            if AdvBookIcon[I].Adv = ad then
     2278              IconIndex := AdvBookIcon[I].Icon;
    22792279          ShowModal;
    22802280          MyData.ToldTech[ad] := MyRO.Tech[ad];
    2281           for i := gMonarchy to nGov - 1 do
    2282             if GovPreq[i] = ad then
    2283               NewGovAvailable := i;
     2281          for I := gMonarchy to nGov - 1 do
     2282            if GovPreq[I] = ad then
     2283              NewGovAvailable := I;
    22842284        end;
    22852285  end;
    22862286
    2287   ShowCityList := false;
     2287  ShowCityList := False;
    22882288  if ClientMode = cTurn then
    22892289  begin
     
    22912291      ChooseResearch;
    22922292
    2293     UpdatePanel := false;
     2293    UpdatePanel := False;
    22942294    if MyRO.Happened and phChangeGov <> 0 then
    22952295    begin
    22962296      ModalSelectDlg.ShowNewContent(wmModal, kGov);
    22972297      Play('NEWGOV');
    2298       Server(sSetGovernment, me, ModalSelectDlg.result, nil^);
     2298      Server(sSetGovernment, Me, ModalSelectDlg.Result, nil^);
    22992299      CityOptimizer_BeginOfTurn;
    2300       UpdatePanel := true;
     2300      UpdatePanel := True;
    23012301    end;
    23022302  end; // ClientMode=cTurn
    23032303
    2304   if not supervising and ((ClientMode = cTurn) or (ClientMode = cMovieTurn))
     2304  if not Supervising and ((ClientMode = cTurn) or (ClientMode = cMovieTurn))
    23052305  then
    23062306    for cix := 0 to MyRO.nCity - 1 do
     
    23122312  begin
    23132313    // tell what happened in cities
    2314     for WondersOnly := true downto false do
     2314    for WondersOnly := True downto False do
    23152315      for cix := 0 to MyRO.nCity - 1 do
    23162316        with MyCity[cix] do
     
    23232323              begin { tell about newly built wonder }
    23242324                OpenSound := 'WONDER_BUILT';
    2325                 s := Tribe[me].TPhrase('WONDERBUILTOWN');
     2325                S := Tribe[Me].TPhrase('WONDERBUILTOWN');
    23262326                MessgText :=
    2327                   Format(s, [Phrases.Lookup('IMPROVEMENTS',
     2327                  Format(S, [Phrases.Lookup('IMPROVEMENTS',
    23282328                  Project0 and cpIndex), CityName(ID)]);
    23292329                Kind := mkOkHelp;
     
    23342334                ShowModal;
    23352335              end;
    2336             if not supervising and (ClientMode = cTurn) then
     2336            if not Supervising and (ClientMode = cTurn) then
    23372337            begin
    2338               AllowCityScreen := true;
     2338              AllowCityScreen := True;
    23392339              if (Status and 7 <> 0) and
    23402340                (Project and (cpImp + cpIndex) = cpImp + imTrGoods) then
     
    23422342                begin
    23432343                  if AutoBuild(cix, MyData.ImpOrder[Status and 7 - 1]) then
    2344                     AllowCityScreen := false
     2344                    AllowCityScreen := False
    23452345                  else if Flags and chProduction <> 0 then
    23462346                    Flags := (Flags and not chProduction) or chAllImpsMade
     
    23702370                  CityDlg.ShowNewContent(wmModal, MyCity[cix].Loc,
    23712371                    Flags and CityRepMask);
    2372                   UpdatePanel := true;
     2372                  UpdatePanel := True;
    23732373                end;
    23742374              end
     
    23762376              begin
    23772377                if Flags and CityRepMask <> 0 then
    2378                   ShowCityList := true;
     2378                  ShowCityList := True;
    23792379              end;
    23802380            end;
     
    23962396        begin
    23972397          Play('REVOLUTION');
    2398           Server(sRevolution, me, 0, nil^);
     2398          Server(sRevolution, Me, 0, nil^);
    23992399        end;
    24002400      end;
     
    24302430    Application.ProcessMessages;
    24312431
    2432     if not supervising then
     2432    if not Supervising then
    24332433      for uix := 0 to MyRO.nUn - 1 do
    24342434        with MyUn[uix] do
     
    24582458              begin // !!! Shinkansen
    24592459                MoveResult := eOK;
    2460                 ok := true;
    2461                 for i := 0 to MoveAdviceData.nStep - 1 do
     2460                ok := True;
     2461                for I := 0 to MoveAdviceData.nStep - 1 do
    24622462                begin
    2463                   Loc1 := dLoc(Loc, MoveAdviceData.dx[i],
    2464                     MoveAdviceData.dy[i]);
     2463                  Loc1 := dLoc(Loc, MoveAdviceData.dx[I],
     2464                    MoveAdviceData.dy[I]);
    24652465                  if (MyMap[Loc1] and (fCity or fOwned) = fCity)
    24662466                  // don't capture cities during auto move
     
    24682468                  // don't attack during auto move
    24692469                  begin
    2470                     ok := false;
     2470                    ok := False;
    24712471                    Break
    24722472                  end
     
    24752475                    if (Loc1 = MoveAdviceData.ToLoc) or
    24762476                      (MoveAdviceData.ToLoc = maNextCity) and
    2477                       (MyMap[dLoc(Loc, MoveAdviceData.dx[i],
    2478                       MoveAdviceData.dy[i])] and fCity <> 0) then
     2477                      (MyMap[dLoc(Loc, MoveAdviceData.dx[I],
     2478                      MoveAdviceData.dy[I])] and fCity <> 0) then
    24792479                      MoveOptions := muAutoNoWait
    24802480                    else
    24812481                      MoveOptions := 0;
    2482                     MoveResult := MoveUnit(MoveAdviceData.dx[i],
    2483                       MoveAdviceData.dy[i], MoveOptions);
     2482                    MoveResult := MoveUnit(MoveAdviceData.dx[I],
     2483                      MoveAdviceData.dy[I], MoveOptions);
    24842484                    if (MoveResult < rExecuted) or (MoveResult = eEnemySpotted)
    24852485                    then
    24862486                    begin
    2487                       ok := false;
     2487                      ok := False;
    24882488                      Break
    24892489                    end;
     
    24972497              begin
    24982498                MoveResult := eOK;
    2499                 Stop := true;
     2499                Stop := True;
    25002500              end;
    25012501
     
    25202520  end; // ClientMode=cTurn
    25212521
    2522   HaveStrategyAdvice := false;
     2522  HaveStrategyAdvice := False;
    25232523  // (GameMode<>cMovie) and not supervising
    25242524  // and AdvisorDlg.HaveStrategyAdvice;
    2525   GoOnPhase := true;
    2526   if supervising or (GameMode = cMovie) then
     2525  GoOnPhase := True;
     2526  if Supervising or (GameMode = cMovie) then
    25272527  begin
    25282528    SetTroopLoc(-1);
     
    25392539      SetUnFocus(-1)
    25402540    else
    2541       NextUnit(-1, false);
     2541      NextUnit(-1, False);
    25422542    if UnFocus < 0 then
    25432543    begin
     
    25562556end;
    25572557
    2558 procedure TMainScreen.Client(Command, NewPlayer: integer; var Data);
     2558procedure TMainScreen.Client(Command, NewPlayer: Integer; var Data);
    25592559var
    2560   i, j, p1, mix, ToLoc, AnimationSpeed, ShowMoveDomain, cix, ecix: integer;
     2560  I, J, p1, mix, ToLoc, AnimationSpeed, ShowMoveDomain, cix, ecix: Integer;
    25612561  Color: TColor;
    2562   Name, s: string;
     2562  Name, S: string;
    25632563  TribeInfo: TTribeInfo;
    25642564  mi: TModelInfo;
    2565   SkipTurn, IsAlpine, IsTreatyDeal: boolean;
     2565  SkipTurn, IsAlpine, IsTreatyDeal: Boolean;
    25662566begin
    25672567  case Command of
    25682568    cTurn, cResume, cContinue, cMovieTurn, scContact, scDipStart .. scDipBreak:
    25692569      begin
    2570         supervising := G.Difficulty[NewPlayer] = 0;
     2570        Supervising := G.Difficulty[NewPlayer] = 0;
    25712571        ArrangeMidPanel;
    25722572      end
     
    25742574  case Command of
    25752575    cDebugMessage:
    2576       LogDlg.Add(NewPlayer, G.RO[0].Turn, pchar(@Data));
     2576      LogDlg.Add(NewPlayer, G.RO[0].Turn, PChar(@Data));
    25772577
    25782578    cShowNego:
    25792579      with TShowNegoData(Data) do
    25802580      begin
    2581         s := Format('P%d to P%d: ', [pSender, pTarget]);
     2581        S := Format('P%d to P%d: ', [pSender, pTarget]);
    25822582        if (Action = scDipOffer) and (Offer.nDeliver + Offer.nCost > 0) then
    25832583        begin
    2584           s := s + 'Offer ';
    2585           for i := 0 to Offer.nDeliver + Offer.nCost - 1 do
     2584          S := S + 'Offer ';
     2585          for I := 0 to Offer.nDeliver + Offer.nCost - 1 do
    25862586          begin
    2587             if i = Offer.nDeliver then
    2588               s := s + ' for '
    2589             else if i > 0 then
    2590               s := s + '+';
    2591             case Offer.Price[i] and opMask of
     2587            if I = Offer.nDeliver then
     2588              S := S + ' for '
     2589            else if I > 0 then
     2590              S := S + '+';
     2591            case Offer.Price[I] and opMask of
    25922592              opChoose:
    2593                 s := s + 'Price of choice';
     2593                S := S + 'Price of choice';
    25942594              opCivilReport:
    2595                 s := s + 'State report';
     2595                S := S + 'State report';
    25962596              opMilReport:
    2597                 s := s + 'Military report';
     2597                S := S + 'Military report';
    25982598              opMap:
    2599                 s := s + 'Map';
     2599                S := S + 'Map';
    26002600              opTreaty:
    2601                 s := s + 'Treaty';
     2601                S := S + 'Treaty';
    26022602              opShipParts:
    2603                 s := s + 'Ship part';
     2603                S := S + 'Ship part';
    26042604              opMoney:
    2605                 s := s + IntToStr(Offer.Price[i] and $FFFFFF) + 'o';
     2605                S := S + IntToStr(Offer.Price[I] and $FFFFFF) + 'o';
    26062606              opTribute:
    2607                 s := s + IntToStr(Offer.Price[i] and $FFFFFF) + 'o tribute';
     2607                S := S + IntToStr(Offer.Price[I] and $FFFFFF) + 'o tribute';
    26082608              opTech:
    2609                 s := s + Phrases.Lookup('ADVANCES', Offer.Price[i] and $FFFFFF);
     2609                S := S + Phrases.Lookup('ADVANCES', Offer.Price[I] and $FFFFFF);
    26102610              opAllTech:
    2611                 s := s + 'All advances';
     2611                S := S + 'All advances';
    26122612              opModel:
    2613                 s := s + Tribe[pSender].ModelName[Offer.Price[i] and $FFFFFF];
     2613                S := S + Tribe[pSender].ModelName[Offer.Price[I] and $FFFFFF];
    26142614              opAllModel:
    2615                 s := s + 'All models';
     2615                S := S + 'All models';
    26162616            end;
    26172617          end;
    2618           LogDlg.Add(NewPlayer, G.RO[0].Turn, pchar(s));
     2618          LogDlg.Add(NewPlayer, G.RO[0].Turn, PChar(S));
    26192619        end
    26202620        else if Action = scDipAccept then
    26212621        begin
    2622           s := s + '--- ACCEPTED! ---';
    2623           LogDlg.Add(NewPlayer, G.RO[0].Turn, pchar(s));
     2622          S := S + '--- ACCEPTED! ---';
     2623          LogDlg.Add(NewPlayer, G.RO[0].Turn, PChar(S));
    26242624        end;
    26252625      end;
     
    26572657          AdvisorDlg.NewGame(Data); }
    26582658        GenerateNames := mNames.Checked;
    2659         GameOK := true;
     2659        GameOK := True;
    26602660        G := TNewGameData(Data);
    2661         me := -1;
     2661        Me := -1;
    26622662        pLogo := -1;
    26632663        ClientMode := -1;
    26642664        SetMapOptions;
    26652665        MainMap.pDebugMap := -1;
    2666         idle := false;
     2666        Idle := False;
    26672667        FillChar(Jump, SizeOf(Jump), 0);
    26682668        if StartRunning then
     
    26872687              ToldContact := 0;
    26882688              ToldOwnCredibility := InitialCredibility;
    2689               for i := 0 to nPl - 1 do
    2690                 if G.Difficulty[i] > 0 then
    2691                   inc(ToldAlive, 1 shl i);
     2689              for I := 0 to nPl - 1 do
     2690                if G.Difficulty[I] > 0 then
     2691                  Inc(ToldAlive, 1 shl I);
    26922692              PeaceEvaHappened := 0;
    2693               for i := 0 to nWonder - 1 do
    2694                 with ToldWonders[i] do
     2693              for I := 0 to nWonder - 1 do
     2694                with ToldWonders[I] do
    26952695                begin
    26962696                  CityID := -1;
     
    27192719        Age := 0;
    27202720        MovieSpeed := 1;
    2721         LogDlg.mSlot.Visible := true;
     2721        LogDlg.mSlot.Visible := True;
    27222722        LogDlg.Host := self;
    27232723        HelpDlg.ClearHistory;
     
    27252725
    27262726        MiniMap.Size := Point(G.lx, G.ly);
    2727         for i := 0 to nPl - 1 do
     2727        for I := 0 to nPl - 1 do
    27282728        begin
    2729           Tribe[i] := nil;
    2730           TribeOriginal[i] := false;
     2729          Tribe[I] := nil;
     2730          TribeOriginal[I] := False;
    27312731        end;
    27322732        ToldSlavery := -1;
    2733         RepaintOnResize := false;
    2734         Closable := false;
    2735         FirstMovieTurn := true;
     2733        RepaintOnResize := False;
     2734        Closable := False;
     2735        FirstMovieTurn := True;
    27362736
    27372737        MenuArea.Visible := GameMode <> cMovie;
     
    27442744      if NewPlayer = 0 then
    27452745      begin
    2746         i := 0;
     2746        I := 0;
    27472747        for p1 := 0 to nPl - 1 do
    27482748          if (G.Difficulty[p1] > 0) and (Tribe[p1] = nil) then
    2749             inc(i);
    2750         if i > UnusedTribeFiles.Count then
     2749            Inc(I);
     2750        if I > UnusedTribeFiles.Count then
    27512751        begin
    2752           GameOK := false;
     2752          GameOK := False;
    27532753          SimpleMessage(Phrases.Lookup('TOOFEWTRIBES'));
    27542754        end
     
    27612761              TribeInfo.trix := p1;
    27622762              TribeNames.Clear;
    2763               for j := 0 to UnusedTribeFiles.Count - 1 do
     2763              for J := 0 to UnusedTribeFiles.Count - 1 do
    27642764              begin
    2765                 GetTribeInfo(UnusedTribeFiles[j], Name, Color);
     2765                GetTribeInfo(UnusedTribeFiles[J], Name, Color);
    27662766                TribeNames.AddObject(Name, TObject(Color));
    27672767              end;
    2768               assert(TribeNames.Count > 0);
     2768              Assert(TribeNames.Count > 0);
    27692769              ModalSelectDlg.ShowNewContent(wmModal, kTribe);
    27702770              Application.ProcessMessages;
    2771               TribeInfo.FileName := UnusedTribeFiles[ModalSelectDlg.result];
    2772               UnusedTribeFiles.Delete(ModalSelectDlg.result);
     2771              TribeInfo.FileName := UnusedTribeFiles[ModalSelectDlg.Result];
     2772              UnusedTribeFiles.Delete(ModalSelectDlg.Result);
    27732773
    27742774              if GameMode = cLoadGame then
    2775                 CreateTribe(TribeInfo.trix, TribeInfo.FileName, false)
     2775                CreateTribe(TribeInfo.trix, TribeInfo.FileName, False)
    27762776              else
    27772777                Server(CommandWithData(cSetTribe, TribeInfo.GetCommandDataSize),
     
    27832783            then
    27842784            begin // autoselect enemy tribes
    2785               j := ChooseUnusedTribe;
    2786               TribeInfo.FileName := UnusedTribeFiles[j];
    2787               UnusedTribeFiles.Delete(j);
     2785              J := ChooseUnusedTribe;
     2786              TribeInfo.FileName := UnusedTribeFiles[J];
     2787              UnusedTribeFiles.Delete(J);
    27882788              TribeInfo.trix := p1;
    27892789              if GameMode = cLoadGame then
    2790                 CreateTribe(TribeInfo.trix, TribeInfo.FileName, false)
     2790                CreateTribe(TribeInfo.trix, TribeInfo.FileName, False)
    27912791              else
    27922792                Server(CommandWithData(cSetTribe, TribeInfo.GetCommandDataSize),
     
    28082808          LogDlg.Close;
    28092809        LogDlg.List.Clear;
    2810         StartRunning := not idle and (Jump[0] > 0); // AI called Reload
    2811         me := -1;
    2812         idle := false;
     2810        StartRunning := not Idle and (Jump[0] > 0); // AI called Reload
     2811        Me := -1;
     2812        Idle := False;
    28132813        ClientMode := -1;
    2814         UnitInfoBtn.Visible := false;
    2815         UnitBtn.Visible := false;
    2816         TerrainBtn.Visible := false;
    2817         MovieSpeed1Btn.Visible := false;
    2818         MovieSpeed2Btn.Visible := false;
    2819         MovieSpeed3Btn.Visible := false;
    2820         MovieSpeed4Btn.Visible := false;
    2821         EOT.Visible := false;
    2822         for i := 0 to ControlCount - 1 do
    2823           if Controls[i] is TButtonC then
    2824             Controls[i].Visible := false;
     2814        UnitInfoBtn.Visible := False;
     2815        UnitBtn.Visible := False;
     2816        TerrainBtn.Visible := False;
     2817        MovieSpeed1Btn.Visible := False;
     2818        MovieSpeed2Btn.Visible := False;
     2819        MovieSpeed3Btn.Visible := False;
     2820        MovieSpeed4Btn.Visible := False;
     2821        EOT.Visible := False;
     2822        for I := 0 to ControlCount - 1 do
     2823          if Controls[I] is TButtonC then
     2824            Controls[I].Visible := False;
    28252825        sb.Init(0, 1);
    28262826        for p1 := 0 to nPl - 1 do
     
    28282828            FreeAndNil(Tribe[p1]);
    28292829        Tribes.Done;
    2830         RepaintOnResize := false;
    2831         Closable := true;
     2830        RepaintOnResize := False;
     2831        Closable := True;
    28322832        Close;
    28332833        { if (GameMode=cNewGame) or (GameMode=cLoadGame) then
     
    28522852        Show;
    28532853        Update;
    2854         RepaintOnResize := true;
     2854        RepaintOnResize := True;
    28552855        xw := 0;
    28562856        yw := ywcenter;
    28572857        if not StayOnTop_Ensured then
    28582858        begin
    2859           StayOnTop_Ensured := true;
     2859          StayOnTop_Ensured := True;
    28602860          CityDlg.StayOnTop_Workaround;
    28612861          CityTypeDlg.StayOnTop_Workaround;
     
    28762876    cShowTurnChange:
    28772877      begin
    2878         if integer(Data) >= 0 then
     2878        if Integer(Data) >= 0 then
    28792879        begin
    2880           pLogo := integer(Data);
     2880          pLogo := Integer(Data);
    28812881          if G.RO[pLogo] = nil then
    28822882          begin
     
    29052905              ItsMeAgain(p1);
    29062906              for mix := 0 to MyRO.nModel - 1 do
    2907                 if not Assigned(Tribe[me].ModelPicture[mix].HGr) then
    2908                   InitMyModel(mix, true);
     2907                if not Assigned(Tribe[Me].ModelPicture[mix].HGr) then
     2908                  InitMyModel(mix, True);
    29092909            end;
    2910           me := -1;
     2910          Me := -1;
    29112911        end;
    29122912
     
    29172917            Jump[pTurn] := 0
    29182918          else
    2919             dec(Jump[pTurn]);
     2919            Dec(Jump[pTurn]);
    29202920        SkipTurn := Jump[pTurn] > 0;
    29212921        if SkipTurn then
     
    29262926          MiniMapPaint;
    29272927          InitAllEnemyModels; // necessary for correct replay
    2928           if not EndTurn(true) then
    2929             SkipTurn := false;
     2928          if not EndTurn(True) then
     2929            SkipTurn := False;
    29302930        end;
    29312931        if not SkipTurn then
     
    29342934            NegoDlg.Visible then
    29352935            NegoDlg.Close;
    2936           skipped := false; // always show my moves during my turn
    2937           idle := true;
     2936          skipped := False; // always show my moves during my turn
     2937          Idle := True;
    29382938          InitTurn(NewPlayer);
    2939           DipMem[me].pContact := -1;
    2940           (* if (me=0) and (MyRO.Alive and (1 shl me)=0)} then
     2939          DipMem[Me].pContact := -1;
     2940          (* if (Me=0) and (MyRO.Alive and (1 shl Me)=0)} then
    29412941            begin
    29422942            if SimpleQuery(Phrases.Lookup('RESIGN'))=mrIgnore then
    2943             Server(sResign,me,0,nil^)
    2944             else Server(sBreak,me,0,nil^)
     2943            Server(sResign,Me,0,nil^)
     2944            else Server(sBreak,Me,0,nil^)
    29452945            end
    29462946            else Play('TURNSTART'); *)
     
    29532953        pTurn := NewPlayer;
    29542954        pLogo := -1;
    2955         skipped := false; // always show my moves during my turn
    2956         idle := true;
     2955        skipped := False; // always show my moves during my turn
     2956        Idle := True;
    29572957        if FirstMovieTurn then
    29582958        begin
    29592959          CheckMovieSpeedBtnState;
    2960           FirstMovieTurn := false;
     2960          FirstMovieTurn := False;
    29612961        end;
    29622962        InitTurn(NewPlayer);
     
    29752975        pTurn := -1;
    29762976        pLogo := -1;
    2977         MapValid := false;
     2977        MapValid := False;
    29782978        ClientMode := -1;
    2979         idle := false;
    2980         skipped := false;
     2979        Idle := False;
     2980        skipped := False;
    29812981      end;
    29822982
     
    29882988        ItsMeAgain(0);
    29892989        MyData := nil;
    2990         UnitInfoBtn.Visible := false;
    2991         UnitBtn.Visible := false;
    2992         TerrainBtn.Visible := false;
    2993         MovieSpeed1Btn.Visible := false;
    2994         MovieSpeed2Btn.Visible := false;
    2995         MovieSpeed3Btn.Visible := false;
    2996         MovieSpeed4Btn.Visible := false;
    2997         EOT.Visible := false;
     2990        UnitInfoBtn.Visible := False;
     2991        UnitBtn.Visible := False;
     2992        TerrainBtn.Visible := False;
     2993        MovieSpeed1Btn.Visible := False;
     2994        MovieSpeed2Btn.Visible := False;
     2995        MovieSpeed3Btn.Visible := False;
     2996        MovieSpeed4Btn.Visible := False;
     2997        EOT.Visible := False;
    29982998        HelpDlg.Difficulty := 0;
    29992999        BrushType := fGrass;
    30003000        BrushLoc := -1;
    3001         Edited := false;
     3001        Edited := False;
    30023002        UnFocus := -1;
    30033003        MarkCityLoc := -1;
    3004         Tracking := false;
    3005         TurnComplete := false;
    3006         MapValid := false;
     3004        Tracking := False;
     3005        TurnComplete := False;
     3006        MapValid := False;
    30073007        FormResize(nil); // calculate geometrics and paint all
    30083008        SetTroopLoc(-1);
    3009         idle := true;
     3009        Idle := True;
    30103010      end;
    30113011
     
    30173017    scContact:
    30183018      begin
    3019         DipMem[NewPlayer].pContact := integer(Data);
     3019        DipMem[NewPlayer].pContact := Integer(Data);
    30203020        if Jump[NewPlayer] > 0 then
    30213021          DipCall(scReject)
     
    30243024          ClientMode := Command;
    30253025          InitTurn(NewPlayer);
    3026           MyData.ToldContact := MyData.ToldContact or (1 shl integer(Data));
     3026          MyData.ToldContact := MyData.ToldContact or (1 shl Integer(Data));
    30273027          // don't tell about new nation when already contacted by them
    30283028          with MessgExDlg do
    30293029          begin
    3030             OpenSound := 'CONTACT_' + char(48 + MyRO.EnemyReport[integer(Data)
     3030            OpenSound := 'CONTACT_' + char(48 + MyRO.EnemyReport[Integer(Data)
    30313031              ].Attitude);
    3032             MessgText := Tribe[integer(Data)].TPhrase('FRCONTACT');
     3032            MessgText := Tribe[Integer(Data)].TPhrase('FRCONTACT');
    30333033            Kind := mkYesNo;
    30343034            IconKind := mikTribe;
    3035             IconIndex := integer(Data);
     3035            IconIndex := Integer(Data);
    30363036            ShowModal;
    30373037            if ModalResult = mrOK then
    30383038            begin
    30393039              NegoDlg.Respond;
    3040               DipMem[me].DeliveredPrices := [];
    3041               DipMem[me].ReceivedPrices := [];
     3040              DipMem[Me].DeliveredPrices := [];
     3041              DipMem[Me].ReceivedPrices := [];
    30423042              DipCall(scDipStart);
    30433043            end
     
    30673067        else if Command = scDipAccept then
    30683068        begin // remember delivered and received prices
    3069           for i := 0 to DipMem[me].SentOffer.nDeliver - 1 do
    3070             include(DipMem[me].DeliveredPrices,
    3071               DipMem[me].SentOffer.Price[i] shr 24);
    3072           for i := 0 to DipMem[me].SentOffer.nCost - 1 do
    3073             include(DipMem[me].ReceivedPrices,
    3074               DipMem[me].SentOffer.Price[DipMem[me].SentOffer.nDeliver +
    3075               i] shr 24);
    3076           IsTreatyDeal := false;
    3077           for i := 0 to ReceivedOffer.nDeliver + ReceivedOffer.nCost - 1 do
    3078             if DipMem[me].SentOffer.Price[i] and opMask = opTreaty then
    3079               IsTreatyDeal := true;
     3069          for I := 0 to DipMem[Me].SentOffer.nDeliver - 1 do
     3070            Include(DipMem[Me].DeliveredPrices,
     3071              DipMem[Me].SentOffer.Price[I] shr 24);
     3072          for I := 0 to DipMem[Me].SentOffer.nCost - 1 do
     3073            Include(DipMem[Me].ReceivedPrices,
     3074              DipMem[Me].SentOffer.Price[DipMem[Me].SentOffer.nDeliver +
     3075              I] shr 24);
     3076          IsTreatyDeal := False;
     3077          for I := 0 to ReceivedOffer.nDeliver + ReceivedOffer.nCost - 1 do
     3078            if DipMem[Me].SentOffer.Price[I] and opMask = opTreaty then
     3079              IsTreatyDeal := True;
    30803080          if IsTreatyDeal then
    30813081            Play('NEWTREATY')
     
    30843084        end;
    30853085        NegoDlg.Start;
    3086         idle := true;
     3086        Idle := True;
    30873087      end;
    30883088
     
    30903090      if not IsMultiPlayerGame then
    30913091      begin
    3092         case G.RO[NewPlayer].Treaty[integer(Data)] of
     3092        case G.RO[NewPlayer].Treaty[Integer(Data)] of
    30933093          trPeace:
    3094             s := Tribe[integer(Data)].TPhrase('FRCANCELBYREJECT_PEACE');
     3094            S := Tribe[Integer(Data)].TPhrase('FRCANCELBYREJECT_PEACE');
    30953095          trFriendlyContact:
    3096             s := Tribe[integer(Data)].TPhrase('FRCANCELBYREJECT_FRIENDLY');
     3096            S := Tribe[Integer(Data)].TPhrase('FRCANCELBYREJECT_FRIENDLY');
    30973097          trAlliance:
    3098             s := Tribe[integer(Data)].TPhrase('FRCANCELBYREJECT_ALLIANCE');
     3098            S := Tribe[Integer(Data)].TPhrase('FRCANCELBYREJECT_ALLIANCE');
    30993099        end;
    3100         TribeMessage(integer(Data), s, 'CANCELTREATY');
     3100        TribeMessage(Integer(Data), S, 'CANCELTREATY');
    31013101      end;
    31023102
    31033103    cShowCancelTreatyByAlliance:
    3104       if idle and (NewPlayer = me) then
    3105         TribeMessage(integer(Data), Tribe[integer(Data)
     3104      if Idle and (NewPlayer = Me) then
     3105        TribeMessage(Integer(Data), Tribe[Integer(Data)
    31063106          ].TPhrase('FRENEMYALLIANCE'), 'CANCELTREATY');
    31073107
    31083108    cShowSupportAllianceAgainst:
    31093109      if not IsMultiPlayerGame and (Jump[0] = 0) then
    3110         TribeMessage(integer(Data) and $F, Tribe[integer(Data) and $F]
    3111           .TPhrase('FRMYALLIANCE1') + ' ' + Tribe[integer(Data) shr 4]
     3110        TribeMessage(Integer(Data) and $F, Tribe[Integer(Data) and $F]
     3111          .TPhrase('FRMYALLIANCE1') + ' ' + Tribe[Integer(Data) shr 4]
    31123112          .TPhrase('FRMYALLIANCE2'), 'CANCELTREATY');
    31133113
    31143114    cShowPeaceViolation:
    31153115      if not IsMultiPlayerGame and (Jump[0] = 0) then
    3116         TribeMessage(integer(Data),
    3117           Format(Tribe[integer(Data)].TPhrase('EVIOLATION'),
     3116        TribeMessage(Integer(Data),
     3117          Format(Tribe[Integer(Data)].TPhrase('EVIOLATION'),
    31183118          [TurnToString(MyRO.Turn + PeaceEvaTurns - 1)]), 'MSG_WITHDRAW');
    31193119
     
    31223122
    31233123    cShowUnitChanged, cShowCityChanged, cShowAfterMove, cShowAfterAttack:
    3124       if (idle and (NewPlayer = me) or not idle and not skipped) and
     3124      if (Idle and (NewPlayer = Me) or not Idle and not skipped) and
    31253125        not((GameMode = cMovie) and (MovieSpeed = 4)) then
    31263126      begin
    3127         assert(NewPlayer = me);
    3128         if not idle or (GameMode = cMovie) then
     3127        Assert(NewPlayer = Me);
     3128        if not Idle or (GameMode = cMovie) then
    31293129          Application.ProcessMessages;
    31303130        if Command = cShowCityChanged then
    31313131        begin
    3132           CurrentMoveInfo.DoShow := false;
    3133           if idle then
    3134             CurrentMoveInfo.DoShow := true
     3132          CurrentMoveInfo.DoShow := False;
     3133          if Idle then
     3134            CurrentMoveInfo.DoShow := True
    31353135          else if CurrentMoveInfo.IsAlly then
    31363136            CurrentMoveInfo.DoShow := not mAlNoMoves.Checked
     
    31403140        else if Command = cShowUnitChanged then
    31413141        begin
    3142           CurrentMoveInfo.DoShow := false;
    3143           if idle then
     3142          CurrentMoveInfo.DoShow := False;
     3143          if Idle then
    31443144            CurrentMoveInfo.DoShow := not mEffectiveMovesOnly.Checked
    31453145          else if CurrentMoveInfo.IsAlly then
     
    31553155        begin
    31563156          if Command = cShowCityChanged then
    3157             MapValid := false;
    3158           FocusOnLoc(integer(Data), flImmUpdate);
     3157            MapValid := False;
     3158          FocusOnLoc(Integer(Data), flImmUpdate);
    31593159          // OldUnFocus:=UnFocus;
    31603160          // UnFocus:=-1;
    31613161          if Command = cShowAfterMove then
    3162             PaintLoc(integer(Data), CurrentMoveInfo.AfterMovePaintRadius)
     3162            PaintLoc(Integer(Data), CurrentMoveInfo.AfterMovePaintRadius)
    31633163            // show discovered areas
    31643164          else
    3165             PaintLoc(integer(Data), 1);
     3165            PaintLoc(Integer(Data), 1);
    31663166          // UnFocus:=OldUnFocus;
    31673167          if (Command = cShowAfterAttack) and
     
    31733173            Update; // remove message box from screen
    31743174          end
    3175           else if not idle then
     3175          else if not Idle then
    31763176            if Command = cShowCityChanged then
    31773177              Sleep(MoveTime * WaitAfterShowMove div 16)
    31783178            else if (Command = cShowUnitChanged) and
    3179               (MyMap[integer(Data)] and fUnit <> 0) then
     3179              (MyMap[Integer(Data)] and fUnit <> 0) then
    31803180              Sleep(MoveTime * WaitAfterShowMove div 32)
    31813181        end // if CurrentMoveInfo.DoShow
    31823182        else
    3183           MapValid := false;
     3183          MapValid := False;
    31843184      end;
    31853185
    31863186    cShowMoving, cShowCapturing:
    3187       if (idle and (NewPlayer = me) or not idle and not skipped and
     3187      if (Idle and (NewPlayer = Me) or not Idle and not skipped and
    31883188        (TShowMove(Data).emix <> $FFFF)) and
    31893189        not((GameMode = cMovie) and (MovieSpeed = 4)) then
    31903190      begin
    3191         assert(NewPlayer = me);
    3192         if not idle or (GameMode = cMovie) then
     3191        Assert(NewPlayer = Me);
     3192        if not Idle or (GameMode = cMovie) then
    31933193          Application.ProcessMessages;
    31943194        with TShowMove(Data) do
    31953195        begin
    3196           CurrentMoveInfo.DoShow := false;
    3197           if not idle and (not Assigned(Tribe[Owner].ModelPicture[mix].HGr)) then
     3196          CurrentMoveInfo.DoShow := False;
     3197          if not Idle and (not Assigned(Tribe[Owner].ModelPicture[mix].HGr)) then
    31983198            InitEnemyModel(emix);
    31993199
    32003200          ToLoc := dLoc(FromLoc, dx, dy);
    3201           if idle then
     3201          if Idle then
    32023202          begin // own unit -- make discovered land visible
    3203             assert(Owner = me); // no foreign moves during my turn!
     3203            Assert(Owner = Me); // no foreign moves during my turn!
    32043204            CurrentMoveInfo.DoShow := not mEffectiveMovesOnly.Checked or
    32053205              (Command = cShowCapturing);
     
    32343234                else
    32353235                  CurrentMoveInfo.AfterMovePaintRadius := 1;
    3236                 if (MyRO.Wonder[woShinkansen].EffectiveOwner = me) and
     3236                if (MyRO.Wonder[woShinkansen].EffectiveOwner = Me) and
    32373237                  (Domain = dGround) and
    32383238                  (MyMap[FromLoc] and (fRR or fCity) <> 0) and
     
    32493249            CurrentMoveInfo.IsAlly := MyRO.Treaty[Owner] = trAlliance;
    32503250            if GameMode = cMovie then
    3251               CurrentMoveInfo.DoShow := true
     3251              CurrentMoveInfo.DoShow := True
    32523252            else if CurrentMoveInfo.IsAlly then
    32533253              CurrentMoveInfo.DoShow := not mAlNoMoves.Checked and
     
    32653265                  cix := MyRO.nCity - 1;
    32663266                  while (cix >= 0) and (MyCity[cix].Loc <> ToLoc) do
    3267                     dec(cix);
    3268                   s := CityName(MyCity[cix].ID);
     3267                    Dec(cix);
     3268                  S := CityName(MyCity[cix].ID);
    32693269                end
    32703270                else
     
    32723272                  ecix := MyRO.nEnemyCity - 1;
    32733273                  while (ecix >= 0) and (MyRO.EnemyCity[ecix].Loc <> ToLoc) do
    3274                     dec(ecix);
    3275                   s := CityName(MyRO.EnemyCity[ecix].ID);
     3274                    Dec(ecix);
     3275                  S := CityName(MyRO.EnemyCity[ecix].ID);
    32763276                end;
    32773277                TribeMessage(Owner, Format(Tribe[Owner].TPhrase('CAPTURE'),
    3278                   [s]), '');
     3278                  [S]), '');
    32793279                Update; // remove message box from screen
    32803280              end;
     
    33613361          end // if CurrentMoveInfo.DoShow
    33623362          else
    3363             MapValid := false;
     3363            MapValid := False;
    33643364        end;
    33653365      end;
    33663366
    33673367    cShowAttacking:
    3368       if (idle and (NewPlayer = me) or not idle and not skipped and
     3368      if (Idle and (NewPlayer = Me) or not Idle and not skipped and
    33693369        (TShowMove(Data).emix <> $FFFF)) and
    33703370        not((GameMode = cMovie) and (MovieSpeed = 4)) then
    33713371      begin
    3372         assert(NewPlayer = me);
    3373         if not idle or (GameMode = cMovie) then
     3372        Assert(NewPlayer = Me);
     3373        if not Idle or (GameMode = cMovie) then
    33743374          Application.ProcessMessages;
    33753375        with TShowMove(Data) do
    33763376        begin
    33773377          CurrentMoveInfo.AfterAttackExpeller := -1;
    3378           CurrentMoveInfo.DoShow := false;
    3379           if idle then
    3380             CurrentMoveInfo.DoShow := true // own unit -- always show attacks
     3378          CurrentMoveInfo.DoShow := False;
     3379          if Idle then
     3380            CurrentMoveInfo.DoShow := True // own unit -- always show attacks
    33813381          else
    33823382          begin
     
    33983398              cix := MyRO.nCity - 1;
    33993399              while (cix >= 0) and (MyCity[cix].Loc <> ToLoc) do
    3400                 dec(cix);
     3400                Dec(cix);
    34013401              if MyCity[cix].Status and csToldBombard = 0 then
    34023402              begin
    3403                 if not supervising then
     3403                if not Supervising then
    34043404                  MyCity[cix].Status := MyCity[cix].Status or csToldBombard;
    3405                 s := CityName(MyCity[cix].ID);
     3405                S := CityName(MyCity[cix].ID);
    34063406                SoundMessageEx(Format(Tribe[Owner].TPhrase('BOMBARD'),
    3407                   [s]), '');
     3407                  [S]), '');
    34083408                Update; // remove message box from screen
    34093409              end;
     
    34143414            if Flags and umExpelling <> 0 then
    34153415              Play('MOVE_EXPEL')
    3416             else if Owner = me then
     3416            else if Owner = Me then
    34173417            begin
    3418               MakeModelInfo(me, mix, MyModel[mix], mi);
     3418              MakeModelInfo(Me, mix, MyModel[mix], mi);
    34193419              Play(AttackSound(ModelCode(mi)));
    34203420            end
     
    34413441              MoveOnScreen(TShowMove(Data), 10, 0, 16);
    34423442            end
    3443             else if not idle then
     3443            else if not Idle then
    34443444              Sleep(MoveTime div 2);
    34453445            MainMap.AttackEnd;
    34463446          end // if CurrentMoveInfo.DoShow
    34473447          else
    3448             MapValid := false;
     3448            MapValid := False;
    34493449        end;
    34503450      end;
     
    34553455      else
    34563456      begin
    3457         s := Phrases.Lookup('FOREIGNINFO');
     3457        S := Phrases.Lookup('FOREIGNINFO');
    34583458        for p1 := 0 to nPl - 1 do
    34593459          if 3 shl (p1 * 2) and Cardinal(Data) <> 0 then
    3460             s := s + '\' + Tribe[p1].TPhrase('SHORTNAME');
    3461         SoundMessageEx(s, '');
     3460            S := S + '\' + Tribe[p1].TPhrase('SHORTNAME');
     3461        SoundMessageEx(S, '');
    34623462      end;
    34633463
     
    34713471        begin
    34723472          MessgText := Format(Phrases.Lookup('GRLIB_GENERAL'),
    3473             [Phrases.Lookup('ADVANCES', integer(Data))]);
     3473            [Phrases.Lookup('ADVANCES', Integer(Data))]);
    34743474          OpenSound := 'NEWADVANCE_GRLIB';
    34753475          Kind := mkOk;
     
    34813481    cRefreshDebugMap:
    34823482      begin
    3483         if integer(Data) = MainMap.pDebugMap then
     3483        if Integer(Data) = MainMap.pDebugMap then
    34843484        begin
    3485           MapValid := false;
     3485          MapValid := False;
    34863486          MainOffscreenPaint;
    34873487          Update;
     
    34943494        cSetTribe:
    34953495          with TTribeInfo(Data) do begin
    3496             i := UnusedTribeFiles.Count - 1;
    3497             while (i >= 0) and
    3498               (AnsiCompareFileName(UnusedTribeFiles[i], FileName) <> 0) do
    3499               dec(i);
    3500             if i >= 0 then
    3501               UnusedTribeFiles.Delete(i);
    3502             CreateTribe(trix, FileName, true);
     3496            I := UnusedTribeFiles.Count - 1;
     3497            while (I >= 0) and
     3498              (AnsiCompareFileName(UnusedTribeFiles[I], FileName) <> 0) do
     3499              Dec(I);
     3500            if I >= 0 then
     3501              UnusedTribeFiles.Delete(I);
     3502            CreateTribe(trix, FileName, True);
    35033503          end;
    35043504        cSetNewModelPicture:
     
    35113511              (TModelPictureInfo(Data), False);
    35123512        cSetSlaveIndex:
    3513           Tribe[integer(Data) shr 16].mixSlaves := integer(Data) and $FFFF;
     3513          Tribe[Integer(Data) shr 16].mixSlaves := Integer(Data) and $FFFF;
    35143514        cSetCityName:
    35153515          with TCityNameInfo(Data) do
     
    35283528procedure TMainScreen.FormCreate(Sender: TObject);
    35293529var
    3530   i, j: integer;
     3530  I, J: Integer;
    35313531begin
    35323532  NoMap := TIsoMap.Create;
     
    35703570
    35713571  // tag-controlled language
    3572   for i := 0 to ComponentCount - 1 do
    3573     if Components[i].Tag and $FF <> 0 then
    3574       if Components[i] is TMenuItem then begin
    3575         TMenuItem(Components[i]).Caption := Phrases.Lookup('CONTROLS',
    3576           -1 + Components[i].Tag and $FF);
    3577         for j := 0 to Length(SaveOption) - 1 do
    3578           if Components[i].Tag and $FF = SaveOption[j] then
    3579             TMenuItem(Components[i]).Checked := TSaveOption(j) in OptionChecked;
     3572  for I := 0 to ComponentCount - 1 do
     3573    if Components[I].Tag and $FF <> 0 then
     3574      if Components[I] is TMenuItem then begin
     3575        TMenuItem(Components[I]).Caption := Phrases.Lookup('CONTROLS',
     3576          -1 + Components[I].Tag and $FF);
     3577        for J := 0 to Length(SaveOption) - 1 do
     3578          if Components[I].Tag and $FF = SaveOption[J] then
     3579            TMenuItem(Components[I]).Checked := TSaveOption(J) in OptionChecked;
    35803580      end else
    3581       if Components[i] is TButtonBase then begin
    3582         TButtonBase(Components[i]).Hint := Phrases.Lookup('CONTROLS',
    3583           -1 + Components[i].Tag and $FF);
    3584         if (Components[i] is TButtonC) and
    3585           (TButtonC(Components[i]).ButtonIndex <> 1) then
    3586           TButtonC(Components[i]).ButtonIndex :=
    3587             Integer(MapOptionChecked) shr (Components[i].Tag shr 8) and 1 + 2
     3581      if Components[I] is TButtonBase then begin
     3582        TButtonBase(Components[I]).Hint := Phrases.Lookup('CONTROLS',
     3583          -1 + Components[I].Tag and $FF);
     3584        if (Components[I] is TButtonC) and
     3585          (TButtonC(Components[I]).ButtonIndex <> 1) then
     3586          TButtonC(Components[I]).ButtonIndex :=
     3587            Integer(MapOptionChecked) shr (Components[I].Tag shr 8) and 1 + 2
    35883588      end;
    35893589
     
    35983598    ManagementArea.Hint := Phrases2.Lookup('BTN_MANAGE');
    35993599  end;
    3600   for i := 0 to mRep.Count - 1 do
    3601   begin
    3602     j := mRep[i].Tag shr 8;
    3603     mRep[i].Caption := CityEventName(j);
    3604     mRep[i].Checked := CityRepMask and (1 shl j) <> 0;
     3600  for I := 0 to mRep.Count - 1 do
     3601  begin
     3602    J := mRep[I].Tag shr 8;
     3603    mRep[I].Caption := CityEventName(J);
     3604    mRep[I].Checked := CityRepMask and (1 shl J) <> 0;
    36053605  end;
    36063606
     
    36213621    else Buffer.height := 3 * ySizeBig;
    36223622  Buffer.Canvas.Font.Assign(UniFont[ftSmall]);
    3623   for i := 0 to nPl - 1 do
    3624     AILogo[i] := nil;
     3623  for I := 0 to nPl - 1 do
     3624    AILogo[I] := nil;
    36253625  Canvas.Font.Assign(UniFont[ftSmall]);
    36263626  InitButtons;
     
    36393639  FreeAndNil(Panel);
    36403640  for I := 0 to nPl - 1 do
    3641     if AILogo[i] <> nil then
     3641    if AILogo[I] <> nil then
    36423642      FreeAndNil(AILogo[I]);
    36433643  FreeAndNil(Offscreen);
     
    36993699    Status := Status and ($FFFF - usRecover - usGoto - usEnhance);
    37003700    if Job > jNone then
    3701       Server(sStartJob + jNone shl 4, me, UnFocus, nil^);
     3701      Server(sStartJob + jNone shl 4, Me, UnFocus, nil^);
    37023702  end;
    37033703end;
     
    37253725      if DoJob(jCity) = eCity then
    37263726      begin
    3727         MapValid := false;
     3727        MapValid := False;
    37283728        PaintAll;
    3729         ZoomToCity(Loc0, true, chFounded);
     3729        ZoomToCity(Loc0, True, chFounded);
    37303730      end;
    37313731    end else begin
    37323732      CityOptimizer_BeforeRemoveUnit(UnFocus);
    3733       ServerResult := Server(sAddToCity, me, UnFocus, nil^);
     3733      ServerResult := Server(sAddToCity, Me, UnFocus, nil^);
    37343734      if ServerResult >= rExecuted then
    37353735      begin
    37363736        cix := MyRO.nCity - 1;
    37373737        while (cix >= 0) and (MyCity[cix].Loc <> Loc0) do
    3738           dec(cix);
    3739         assert(cix >= 0);
     3738          Dec(cix);
     3739        Assert(cix >= 0);
    37403740        CityOptimizer_CityChange(cix);
    37413741        CityOptimizer_AfterRemoveUnit; // does nothing here
    37423742        SetTroopLoc(Loc0);
    3743         UpdateViews(true);
    3744         DestinationMarkON := false;
     3743        UpdateViews(True);
     3744        DestinationMarkON := False;
    37453745        PaintDestination;
    37463746        UnFocus := -1;
    37473747        PaintLoc(Loc0);
    3748         NextUnit(UnStartLoc, true);
     3748        NextUnit(UnStartLoc, True);
    37493749      end
    37503750      else if ServerResult = eMaxSize then
     
    38293829      Destination := Status shr 16;
    38303830    Status := Status and not(usStay or usRecover) or usWaiting;
    3831     MoveToLoc(Destination, true);
     3831    MoveToLoc(Destination, True);
    38323832  end;
    38333833end;
     
    38503850    begin
    38513851      cixOldHome := Home;
    3852       if Server(sSetUnitHome, me, UnFocus, nil^) >= rExecuted then
     3852      if Server(sSetUnitHome, Me, UnFocus, nil^) >= rExecuted then
    38533853      begin
    38543854        CityOptimizer_CityChange(cixOldHome);
    38553855        CityOptimizer_CityChange(Home);
    3856         UpdateViews(true);
     3856        UpdateViews(True);
    38573857      end
    38583858      else
     
    38623862    begin
    38633863      Status := Status and not(usStay or usRecover or usEnhance);
    3864       MoveToLoc(maNextCity, true);
     3864      MoveToLoc(maNextCity, True);
    38653865    end;
    38663866  end;
     
    38823882procedure TMainScreen.mJumpClick(Sender: TObject);
    38833883begin
    3884   if supervising then
     3884  if Supervising then
    38853885    Jump[0] := 20
    38863886  else
    3887     Jump[me] := 20;
    3888   EndTurn(true);
     3887    Jump[Me] := 20;
     3888  EndTurn(True);
    38893889end;
    38903890
     
    38953895  if UnFocus >= 0 then
    38963896  with MyUn[UnFocus] do begin
    3897     i := Server(sLoadUnit, me, UnFocus, nil^);
    3898     if i >= rExecuted then
     3897    I := Server(sLoadUnit, Me, UnFocus, nil^);
     3898    if I >= rExecuted then
    38993899    begin
    39003900      if MyModel[mix].Domain = dAir then
     
    39023902      else
    39033903        Play('MOVE_LOAD');
    3904       DestinationMarkON := false;
     3904      DestinationMarkON := False;
    39053905      PaintDestination;
    39063906      Status := Status and ($FFFF - usWaiting - usStay - usRecover - usGoto - usEnhance);
    3907       NextUnit(UnStartLoc, true);
     3907      NextUnit(UnStartLoc, True);
    39083908    end
    3909     else if i = eNoTime_Load then
     3909    else if I = eNoTime_Load then
    39103910      if MyModel[mix].Domain = dAir then
    39113911        SoundMessage(Phrases.Lookup('NOTIMELOADAIR'), 'NOMOVE_TIME')
     
    39423942  with MyUn[UnFocus] do begin
    39433943    Status := Status and not usWaiting;
    3944     NextUnit(UnStartLoc, true);
     3944    NextUnit(UnStartLoc, True);
    39453945  end;
    39463946end;
     
    39713971  if not Edited or (SimpleQuery(mkYesNo, Phrases.Lookup('MAP_RANDOM'), '')
    39723972      = mrOK) then begin
    3973     Server(sRandomMap, me, 0, nil^);
    3974     Edited := true;
    3975     MapValid := false;
     3973    Server(sRandomMap, Me, 0, nil^);
     3974    Edited := True;
     3975    MapValid := False;
    39763976    PaintAllMaps;
    39773977  end;
     
    39823982  if UnFocus >= 0 then
    39833983  with MyUn[UnFocus] do begin
    3984     DestinationMarkON := false;
     3984    DestinationMarkON := False;
    39853985    PaintDestination;
    39863986    Status := Status and ($FFFF - usStay - usGoto - usEnhance) or usRecover;
    39873987    if Job > jNone then
    3988       Server(sStartJob + jNone shl 4, me, UnFocus, nil^);
    3989     NextUnit(UnStartLoc, true);
     3988      Server(sStartJob + jNone shl 4, Me, UnFocus, nil^);
     3989    NextUnit(UnStartLoc, True);
    39903990  end;
    39913991end;
     
    39993999      QueryText := Phrases.Lookup('MAP_CLOSE');
    40004000      case SimpleQuery(mkYesNoCancel, QueryText, '') of
    4001         mrIgnore: Server(sAbandonMap, me, 0, nil^);
    4002         mrOK: Server(sSaveMap, me, 0, nil^);
     4001        mrIgnore: Server(sAbandonMap, Me, 0, nil^);
     4002        mrOK: Server(sSaveMap, Me, 0, nil^);
    40034003      end;
    40044004    end else
    4005       Server(sAbandonMap, me, 0, nil^);
     4005      Server(sAbandonMap, Me, 0, nil^);
    40064006  end else begin
    40074007    if Server(sGetGameChanged, 0, 0, nil^) = eOK then begin
     
    40224022  I: Integer;
    40234023begin
    4024   AltGovs := false;
    4025     for i := 2 to nGov - 1 do
    4026       if (GovPreq[i] <> preNA) and
    4027         ((GovPreq[i] = preNone) or (MyRO.Tech[GovPreq[i]] >= tsApplicable)) then
    4028         AltGovs := true;
     4024  AltGovs := False;
     4025    for I := 2 to nGov - 1 do
     4026      if (GovPreq[I] <> preNA) and
     4027        ((GovPreq[I] = preNone) or (MyRO.Tech[GovPreq[I]] >= tsApplicable)) then
     4028        AltGovs := True;
    40294029
    40304030    if not AltGovs then
     
    40324032    else
    40334033    begin
    4034       RevolutionChanged := false;
     4034      RevolutionChanged := False;
    40354035      if MyRO.Happened and phChangeGov <> 0 then
    40364036      begin
    40374037        ModalSelectDlg.ShowNewContent(wmModal, kGov);
    4038         if ModalSelectDlg.result >= 0 then
     4038        if ModalSelectDlg.Result >= 0 then
    40394039        begin
    40404040          Play('NEWGOV');
    4041           Server(sSetGovernment, me, ModalSelectDlg.result, nil^);
     4041          Server(sSetGovernment, Me, ModalSelectDlg.Result, nil^);
    40424042          CityOptimizer_BeginOfTurn;
    4043           RevolutionChanged := true;
     4043          RevolutionChanged := True;
    40444044        end;
    40454045      end
     
    40474047      with MessgExDlg do
    40484048      begin // revolution!
    4049         MessgExDlg.MessgText := Tribe[me].TPhrase('REVOLUTION');
     4049        MessgExDlg.MessgText := Tribe[Me].TPhrase('REVOLUTION');
    40504050        MessgExDlg.Kind := mkYesNo;
    40514051        MessgExDlg.IconKind := mikPureIcon;
     
    40554055        begin
    40564056          Play('REVOLUTION');
    4057           Server(sRevolution, me, 0, nil^);
    4058           RevolutionChanged := true;
     4057          Server(sRevolution, Me, 0, nil^);
     4058          RevolutionChanged := True;
    40594059          if NatStatDlg.Visible then
    40604060            NatStatDlg.Close;
     
    40644064      end;
    40654065      if RevolutionChanged then
    4066         UpdateViews(true);
     4066        UpdateViews(True);
    40674067    end;
    40684068end;
     
    40844084procedure TMainScreen.mRunClick(Sender: TObject);
    40854085begin
    4086   if supervising then
     4086  if Supervising then
    40874087    Jump[0] := 999999
    40884088  else
    4089     Jump[me] := 999999;
    4090   EndTurn(true);
     4089    Jump[Me] := 999999;
     4090  EndTurn(True);
    40914091end;
    40924092
     
    41004100  if UnFocus >= 0 then
    41014101    with TUn(MyUn[UnFocus]) do
    4102       Server(sSelectTransport, me, UnFocus, nil^);
     4102      Server(sSelectTransport, Me, UnFocus, nil^);
    41034103end;
    41044104
     
    41124112  if UnFocus >= 0 then
    41134113  with TUn(MyUn[UnFocus]) do begin
    4114     DestinationMarkON := false;
     4114    DestinationMarkON := False;
    41154115    PaintDestination;
    41164116    Status := Status and ($FFFF - usRecover - usGoto - usEnhance) or usStay;
    41174117    if Job > jNone then
    4118       Server(sStartJob + jNone shl 4, me, UnFocus, nil^);
    4119     NextUnit(UnStartLoc, true);
     4118      Server(sStartJob + jNone shl 4, Me, UnFocus, nil^);
     4119    NextUnit(UnStartLoc, True);
    41204120  end;
    41214121end;
     
    41374137  I: Integer;
    41384138begin
    4139   if G.Difficulty[me] > 0 then
    4140     ListDlg.ShowNewContent_MilReport(wmPersistent, me)
     4139  if G.Difficulty[Me] > 0 then
     4140    ListDlg.ShowNewContent_MilReport(wmPersistent, Me)
    41414141  else
    41424142  begin
    4143     i := 1;
    4144     while (i < nPl) and (1 shl i and MyRO.Alive = 0) do
    4145       inc(i);
    4146     if i < nPl then
    4147       ListDlg.ShowNewContent_MilReport(wmPersistent, i);
     4143    I := 1;
     4144    while (I < nPl) and (1 shl I and MyRO.Alive = 0) do
     4145      Inc(I);
     4146    if I < nPl then
     4147      ListDlg.ShowNewContent_MilReport(wmPersistent, I);
    41484148  end;
    41494149end;
     
    41604160    if Master >= 0 then begin
    41614161      OldMaster := Master;
    4162       i := Server(sUnloadUnit, me, UnFocus, nil^);
    4163       if i >= rExecuted then
     4162      I := Server(sUnloadUnit, Me, UnFocus, nil^);
     4163      if I >= rExecuted then
    41644164      begin
    41654165        if MyModel[mix].Domain = dAir then
     
    41734173        Status := Status and not usWaiting;
    41744174        if MyModel[mix].Domain <> dAir then
    4175           NextUnit(Loc, true)
     4175          NextUnit(Loc, True)
    41764176        else
    41774177          PanelPaint;
    41784178      end
    4179       else if i = eNoTime_Load then
     4179      else if I = eNoTime_Load then
    41804180        if MyModel[mix].Domain = dAir then
    41814181          SoundMessage(Phrases.Lookup('NOTIMELOADAIR'), 'NOMOVE_TIME')
     
    41864186      NewFocus := -1;
    41874187      uix := UnFocus;
    4188       for i := 1 to MyRO.nUn - 1 do
     4188      for I := 1 to MyRO.nUn - 1 do
    41894189      begin
    41904190        uix := (uix + MyRO.nUn - 1) mod MyRO.nUn;
    41914191        if (MyUn[uix].Master = UnFocus) and
    4192           (MyUn[uix].Movement = integer(MyModel[MyUn[uix].mix].speed)) then
     4192          (MyUn[uix].Movement = Integer(MyModel[MyUn[uix].mix].speed)) then
    41934193        begin
    41944194          MyUn[uix].Status := MyUn[uix].Status or usWaiting;
     
    42104210  if UnFocus >= 0 then
    42114211  with MyUn[UnFocus] do begin
    4212     DestinationMarkON := false;
     4212    DestinationMarkON := False;
    42134213    PaintDestination;
    42144214    Status := Status and ($FFFF - usStay - usRecover - usGoto - usEnhance) or usWaiting;
    42154215  end;
    4216   NextUnit(-1, false);
     4216  NextUnit(-1, False);
    42174217end;
    42184218
     
    42294229procedure TMainScreen.FormResize(Sender: TObject);
    42304230var
    4231   MiniFrame, MaxMapWidth: integer;
     4231  MiniFrame, MaxMapWidth: Integer;
    42324232begin
    42334233  SmallScreen := ClientWidth < 1024;
     
    43074307  begin
    43084308    RectInvalidate(0, TopBarHeight, ClientWidth, TopBarHeight + MapHeight);
    4309     MapValid := false;
     4309    MapValid := False;
    43104310    PaintAll;
    43114311  end;
    43124312end;
    43134313
    4314 procedure TMainScreen.FormCloseQuery(Sender: TObject; var CanClose: boolean);
     4314procedure TMainScreen.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    43154315begin
    43164316  CanClose := Closable;
    4317   if not Closable and idle and (me = 0) and (ClientMode < scContact) then
     4317  if not Closable and Idle and (Me = 0) and (ClientMode < scContact) then
    43184318    mResign.Click;
    43194319end;
     
    43374337  begin
    43384338    MessgExDlg.CancelMovie;
    4339     Server(sBreak, me, 0, nil^);
     4339    Server(sBreak, Me, 0, nil^);
    43404340  end
    43414341  else if ClientMode < 0 then
    4342     skipped := true
     4342    skipped := True
    43434343  else if ClientMode >= scContact then
    43444344    NegoDlg.ShowNewContent(wmPersistent)
     
    43464346  begin
    43474347    Jump[pTurn] := 0;
    4348     StartRunning := false;
     4348    StartRunning := False;
    43494349  end
    43504350  else
     
    43594359  else
    43604360  with MainMap do begin
    4361     if supervising then
     4361    if Supervising then
    43624362      xTerrain := xMidPanel + 2 * xxt + 14
    43634363    else if ClientWidth < 1280 then
     
    43664366      xTerrain := ClientWidth div 2;
    43674367    xTroop := xTerrain + 2 * xxt + 12;
    4368     if SmallScreen and not supervising then
     4368    if SmallScreen and not Supervising then
    43694369      xTroop := xRightPanel + 10 - 3 * 66 -
    43704370        GetSystemMetrics(SM_CXVSCROLL) - 19 - 4;
     
    43754375end;
    43764376
    4377 function TMainScreen.EndTurn(WasSkipped: boolean): boolean;
    4378 
    4379   function IsResourceUnused(cix, NeedFood, NeedProd: integer): boolean;
     4377function TMainScreen.EndTurn(WasSkipped: Boolean): Boolean;
     4378
     4379  function IsResourceUnused(cix, NeedFood, NeedProd: Integer): Boolean;
    43804380  var
    4381     dx, dy, fix: integer;
     4381    dx, dy, fix: Integer;
    43824382    CityAreaInfo: TCityAreaInfo;
    43834383    TileInfo: TTileInfo;
    43844384  begin
    4385     Server(sGetCityAreaInfo, me, cix, CityAreaInfo);
     4385    Server(sGetCityAreaInfo, Me, cix, CityAreaInfo);
    43864386    for dy := -3 to 3 do
    43874387      for dx := -3 to 3 do
     
    43934393          begin
    43944394            TileInfo.ExplCity := cix;
    4395             Server(sGetHypoCityTileInfo, me, dLoc(MyCity[cix].Loc, dx, dy),
     4395            Server(sGetHypoCityTileInfo, Me, dLoc(MyCity[cix].Loc, dx, dy),
    43964396              TileInfo);
    43974397            if (TileInfo.Food >= NeedFood) and (TileInfo.Prod >= NeedProd) then
    43984398            begin
    4399               result := true;
    4400               exit
     4399              Result := True;
     4400              Exit
    44014401            end;
    44024402          end
    44034403        end;
    4404     result := false;
     4404    Result := False;
    44054405  end;
    44064406
    44074407var
    4408   p1, uix, cix, CenterLoc: integer;
     4408  p1, uix, cix, CenterLoc: Integer;
    44094409  MsgItem: string;
    44104410  CityReport: TCityReport;
    44114411  PlaneReturnData: TPlaneReturnData;
    4412   Zoom: boolean;
    4413 begin
    4414   result := false;
     4412  Zoom: Boolean;
     4413begin
     4414  Result := False;
    44154415  if ClientMode >= scDipOffer then
    44164416    Exit;
    44174417
    4418   if supervising and (me <> 0) then begin
     4418  if Supervising and (Me <> 0) then begin
    44194419    ApplyToVisibleForms(faClose);
    44204420    ItsMeAgain(0);
     
    44354435          PlaneReturnData.Loc := Loc;
    44364436          PlaneReturnData.Movement := 0; // end turn without further movement?
    4437           if Server(sGetPlaneReturn, me, uix, PlaneReturnData) = eNoWay then
     4437          if Server(sGetPlaneReturn, Me, uix, PlaneReturnData) = eNoWay then
    44384438          begin
    44394439            CenterLoc := Loc + G.lx * 6;
    44404440            // centering the unit itself would make it covered by the query dialog
    44414441            while CenterLoc >= G.lx * G.ly do
    4442               dec(CenterLoc, G.lx * 2);
     4442              Dec(CenterLoc, G.lx * 2);
    44434443            Centre(CenterLoc);
    44444444            SetTroopLoc(-1);
     
    44554455              SetTroopLoc(Loc);
    44564456              PanelPaint;
    4457               exit;
     4457              Exit;
    44584458            end;
    44594459            MyUn[uix].Status := MyUn[uix].Status or usToldNoReturn;
     
    44614461        end;
    44624462
    4463     if not supervising and (MyRO.TestFlags and tfImmImprove = 0) and
     4463    if not Supervising and (MyRO.TestFlags and tfImmImprove = 0) and
    44644464      (MyRO.Government <> gAnarchy) and (MyRO.Money + TaxSum < 0) and
    44654465      (MyRO.TaxRate < 100) then // low funds!
     
    44734473        ShowModal;
    44744474        if ModalResult <> mrOK then
    4475           exit;
     4475          Exit;
    44764476      end;
    44774477
     
    44814481          if (Loc >= 0) and (Flags and chCaptured = 0) then
    44824482          begin
    4483             Zoom := false;
     4483            Zoom := False;
    44844484            CityReport.HypoTiles := -1;
    44854485            CityReport.HypoTax := -1;
    44864486            CityReport.HypoLux := -1;
    4487             Server(sGetCityReport, me, cix, CityReport);
     4487            Server(sGetCityReport, Me, cix, CityReport);
    44884488
    44894489            if (CityReport.Working - CityReport.Happy > Size shr 1) and
     
    45764576    else
    45774577      EOT.Hint := Phrases.Lookup('BTN_SKIP');
    4578     result := true;
     4578    Result := True;
    45794579    SetTroopLoc(-1);
    45804580    pTurn := -1;
    45814581    pLogo := -1;
    4582     UnitInfoBtn.Visible := false;
    4583     UnitBtn.Visible := false;
    4584     TerrainBtn.Visible := false;
     4582    UnitInfoBtn.Visible := False;
     4583    UnitBtn.Visible := False;
     4584    TerrainBtn.Visible := False;
    45854585    EOT.ButtonIndex := eotCancel;
    4586     EOT.Visible := true;
    4587     MapValid := false;
     4586    EOT.Visible := True;
     4587    MapValid := False;
    45884588    PanelPaint;
    45894589    Update;
    45904590    ClientMode := -1;
    4591     idle := false;
     4591    Idle := False;
    45924592    skipped := WasSkipped;
    45934593    for p1 := 1 to nPl - 1 do
    45944594      if G.RO[p1] <> nil then
    4595         skipped := true; // don't show enemy moves in hotseat mode
     4595        skipped := True; // don't show enemy moves in hotseat mode
    45964596  end
    45974597  else
     
    46034603  if NegoDlg.Visible then
    46044604    NegoDlg.Close;
    4605   HaveStrategyAdvice := false;
     4605  HaveStrategyAdvice := False;
    46064606  // AdvisorDlg.HaveStrategyAdvice;
    46074607  // negotiation might have changed advices
    46084608  EOT.ButtonIndex := eotCancel;
    4609   EOT.Visible := true;
     4609  EOT.Visible := True;
    46104610  PanelPaint;
    46114611  Update;
    46124612  ClientMode := -1;
    4613   idle := false;
    4614 end;
    4615 
    4616 procedure TMainScreen.ProcessRect(x0, y0, nx, ny, Options: integer);
     4613  Idle := False;
     4614end;
     4615
     4616procedure TMainScreen.ProcessRect(x0, y0, nx, ny, Options: Integer);
    46174617var
    4618   xs, ys, xl, yl: integer;
     4618  xs, ys, xl, yl: Integer;
    46194619begin
    46204620  with MainMap do begin
     
    46254625    while abs(2 * (xs + G.lx * (xxt * 2)) + xl - MapWidth) <
    46264626      abs(2 * xs + xl - MapWidth) do
    4627         inc(xs, G.lx * (xxt * 2));
     4627        Inc(xs, G.lx * (xxt * 2));
    46284628    ys := (y0 - yw) * yyt - yyt;
    46294629    if xs + xl > MapWidth then
     
    46324632      yl := MapHeight - ys;
    46334633    if (xl <= 0) or (yl <= 0) then
    4634       exit;
     4634      Exit;
    46354635    if Options and prPaint <> 0 then begin
    46364636      if Options and prAutoBounds <> 0 then
     
    46444644end;
    46454645
    4646 procedure TMainScreen.PaintLoc(Loc: integer; Radius: integer = 0);
     4646procedure TMainScreen.PaintLoc(Loc: Integer; Radius: Integer = 0);
    46474647var
    4648   yLoc, x0: integer;
     4648  yLoc, x0: Integer;
    46494649begin
    46504650  if MapValid then begin
    46514651    yLoc := (Loc + G.lx * 1024) div G.lx - 1024;
    46524652    x0 := (Loc + (yLoc and 1 - 2 * Radius + G.lx * 1024) div 2) mod G.lx;
    4653     offscreen.Canvas.Font.Assign(UniFont[ftSmall]);
     4653    Offscreen.Canvas.Font.Assign(UniFont[ftSmall]);
    46544654    ProcessRect(x0, yLoc - 2 * Radius, 4 * Radius + 1, 4 * Radius + 1,
    46554655      prPaint or prAutoBounds or prInvalidate);
     
    46584658end;
    46594659
    4660 procedure TMainScreen.PaintLocTemp(Loc: integer; Style: TPaintLocTempStyle);
     4660procedure TMainScreen.PaintLocTemp(Loc: Integer; Style: TPaintLocTempStyle);
    46614661var
    4662   y0, x0, xMap, yMap: integer;
     4662  y0, x0, xMap, yMap: Integer;
    46634663begin
    46644664  with NoMap do begin
    46654665    if not MapValid then
    4666       exit;
     4666      Exit;
    46674667    Buffer.Canvas.Font.Assign(UniFont[ftSmall]);
    46684668    y0 := Loc div G.lx;
     
    46724672    while abs(2 * (xMap + G.lx * (xxt * 2)) + 2 * xxt - MapWidth) <
    46734673      abs(2 * xMap + 2 * xxt - MapWidth) do
    4674       inc(xMap, G.lx * (xxt * 2));
     4674      Inc(xMap, G.lx * (xxt * 2));
    46754675    yMap := (y0 - yw) * yyt - yyt;
    46764676    NoMap.SetOutput(Buffer);
     
    46844684// panel protusions are added
    46854685// NoMap must be set to buffer and bounds before
    4686 procedure TMainScreen.PaintBufferToScreen(xMap, yMap, width, height: integer);
     4686procedure TMainScreen.PaintBufferToScreen(xMap, yMap, width, height: Integer);
    46874687begin
    46884688  if xMap + width > MapWidth then
     
    46924692  if (width <= 0) or (height <= 0) or (width + xMap <= 0) or (height + yMap <= 0)
    46934693  then
    4694     exit;
     4694    Exit;
    46954695
    46964696  NoMap.BitBltBitmap(Panel, -xMap - MapOffset, -yMap + MapHeight - overlap, xMidPanel,
     
    47194719end;
    47204720
    4721 procedure TMainScreen.PaintLoc_BeforeMove(FromLoc: integer);
     4721procedure TMainScreen.PaintLoc_BeforeMove(FromLoc: Integer);
    47224722var
    4723   yLoc, x0: integer;
     4723  yLoc, x0: Integer;
    47244724begin
    47254725  if MapValid then
     
    47274727    yLoc := (FromLoc + G.lx * 1024) div G.lx - 1024;
    47284728    x0 := (FromLoc + (yLoc and 1 + G.lx * 1024) div 2) mod G.lx;
    4729     offscreen.Canvas.Font.Assign(UniFont[ftSmall]);
     4729    Offscreen.Canvas.Font.Assign(UniFont[ftSmall]);
    47304730    ProcessRect(x0, yLoc, 1, 1, prPaint or prAutoBounds);
    47314731  end
     
    47344734procedure TMainScreen.PaintDestination;
    47354735var
    4736   Destination: integer;
     4736  Destination: Integer;
    47374737begin
    47384738  if (UnFocus >= 0) and (MyUn[UnFocus].Status and usGoto <> 0) then
     
    47554755procedure TMainScreen.MainOffscreenPaint;
    47564756var
    4757   ProcessOptions: integer;
     4757  ProcessOptions: Integer;
    47584758  rec: TRect;
    4759   DoInvalidate: boolean;
    4760 begin
    4761   if me < 0 then
    4762     with offscreen.Canvas do
     4759  DoInvalidate: Boolean;
     4760begin
     4761  if Me < 0 then
     4762    with Offscreen.Canvas do
    47634763    begin
    47644764      Brush.Color := $000000;
     
    47664766      Brush.Style := bsClear;
    47674767      OffscreenUser := self;
    4768       exit;
     4768      Exit;
    47694769    end;
    47704770
     
    47774777    if MapValid and (xwd = xw) and (ywd = yw) then
    47784778      MainMap.SetPaintBounds(0, 0, UsedOffscreenWidth, UsedOffscreenHeight);
    4779     MapValid := false;
     4779    MapValid := False;
    47804780    OffscreenUser := self;
    47814781  end;
     
    47904790      (ywd - yw > MapHeight div yyt) then
    47914791    begin
    4792       offscreen.Canvas.Font.Assign(UniFont[ftSmall]);
     4792      Offscreen.Canvas.Font.Assign(UniFont[ftSmall]);
    47934793      ProcessRect(xw, yw, MapWidth div xxt, MapHeight div yyt,
    47944794        prPaint or prInvalidate);
    47954795    end else begin
    47964796      if (xwd = xw) and (ywd = yw) then
    4797         exit; { map window not moved }
    4798       offscreen.Canvas.Font.Assign(UniFont[ftSmall]);
     4797        Exit; { map window not moved }
     4798      Offscreen.Canvas.Font.Assign(UniFont[ftSmall]);
    47994799      rec := Rect(0, 0, MapWidth, MapHeight);
    48004800{$IFDEF WINDOWS}
    4801       ScrollDC(offscreen.Canvas.Handle, (xwd - xw) * (xxt * 2), (ywd - yw) * yyt,
     4801      ScrollDC(Offscreen.Canvas.Handle, (xwd - xw) * (xxt * 2), (ywd - yw) * yyt,
    48024802        rec, rec, 0, nil);
    48034803{$ENDIF}
    48044804{$IFDEF UNIX}
    4805       ScrollDC(offscreen.Canvas, (xwd - xw) * (xxt * 2), (ywd - yw) * yyt,
     4805      ScrollDC(Offscreen.Canvas, (xwd - xw) * (xxt * 2), (ywd - yw) * yyt,
    48064806        rec, rec, 0, nil);
    48074807{$ENDIF}
    4808       for DoInvalidate := false to FastScrolling do begin
     4808      for DoInvalidate := False to FastScrolling do begin
    48094809        if DoInvalidate then begin
    48104810          rec.Bottom := MapHeight - overlap;
     
    48634863  xwd := xw;
    48644864  ywd := yw;
    4865   MapValid := true;
     4865  MapValid := True;
    48664866end;
    48674867
     
    49204920  function MovementToString(var Un: TUn): string;
    49214921  begin
    4922     result := ScreenTools.MovementToString(Un.Movement);
     4922    Result := ScreenTools.MovementToString(Un.Movement);
    49234923    if Un.Master >= 0 then
    4924       result := '(' + result + ')'
     4924      Result := '(' + Result + ')'
    49254925    else if (MyModel[Un.mix].Domain = dAir) and
    49264926      (MyModel[Un.mix].Kind <> mkSpecial_Glider) then
    4927       result := Format('%s(%d)', [result, Un.Fuel]);
     4927      Result := Format('%s(%d)', [Result, Un.Fuel]);
    49284928  end;
    49294929
    49304930var
    4931   i, uix, uixDefender, x, xSrc, ySrc, xSrcBase, ySrcBase, CostFactor, Count,
     4931  I, uix, uixDefender, X, xSrc, ySrc, xSrcBase, ySrcBase, CostFactor, Count,
    49324932    mixShow, xTreasurySection, xResearchSection, JobFocus, TrueMoney,
    4933     TrueResearch: integer;
     4933    TrueResearch: Integer;
    49344934  Tile: Cardinal;
    4935   s: string;
     4935  S: string;
    49364936  unx: TUn;
    49374937  UnitInfo: TUnitInfo;
    49384938  JobProgressData: TJobProgressData;
    4939   Prio: boolean;
     4939  Prio: Boolean;
    49404940begin
    49414941  if not Assigned(MyRO) then Exit;
     
    50145014    CopyMiniToPanel;
    50155015    if ClientMode <> cEditMap then // MapBtn icons
    5016       for i := 0 to 5 do
    5017         if i <> 3 then
    5018           Dump(Panel, HGrSystem, xMini + G.lx - 42 + 16 * i, PanelHeight - 26,
    5019             8, 8, 121 + i * 9, 61);
     5016      for I := 0 to 5 do
     5017        if I <> 3 then
     5018          Dump(Panel, HGrSystem, xMini + G.lx - 42 + 16 * I, PanelHeight - 26,
     5019            8, 8, 121 + I * 9, 61);
    50205020
    50215021    if ClientMode = cEditMap then
    50225022    begin
    5023       for i := 0 to TrRow - 1 do
    5024         trix[i] := -1;
     5023      for I := 0 to TrRow - 1 do
     5024        trix[I] := -1;
    50255025      Count := 0;
    5026       for i := 0 to nBrushTypes - 1 do
     5026      for I := 0 to nBrushTypes - 1 do
    50275027      begin // display terrain types
    50285028        if (Count >= TrRow * sb.Position) and (Count < TrRow * (sb.Position + 1))
    50295029        then
    50305030        begin
    5031           trix[Count - TrRow * sb.Position] := BrushTypes[i];
    5032           x := (Count - TrRow * sb.Position) * TrPitch;
     5031          trix[Count - TrRow * sb.Position] := BrushTypes[I];
     5032          X := (Count - TrRow * sb.Position) * TrPitch;
    50335033          xSrcBase := -1;
    5034           case BrushTypes[i] of
     5034          case BrushTypes[I] of
    50355035            0 .. 8:
    50365036              begin
    5037                 xSrc := BrushTypes[i];
     5037                xSrc := BrushTypes[I];
    50385038                ySrc := 0
    50395039              end;
     
    50435043                ySrcBase := 2;
    50445044                xSrc := 0;
    5045                 ySrc := 2 * integer(BrushTypes[i]) - 15
     5045                ySrc := 2 * Integer(BrushTypes[I]) - 15
    50465046              end;
    50475047            fRiver:
     
    50765076                ySrcBase := 2;
    50775077                xSrc := 8;
    5078                 ySrc := 12 + BrushTypes[i] shr 25;
     5078                ySrc := 12 + BrushTypes[I] shr 25;
    50795079              end;
    50805080            tiIrrigation, tiFarm, tiMine, tiBase:
    50815081              begin
    5082                 xSrc := BrushTypes[i] shr 12 - 1;
     5082                xSrc := BrushTypes[I] shr 12 - 1;
    50835083                ySrc := 12
    50845084              end;
     
    51035103          with MainMap do begin
    51045104            if xSrcBase >= 0 then
    5105               Sprite(Panel, HGrTerrain, xTroop + 2 + x, yTroop + 9 - yyt, xxt * 2,
     5105              Sprite(Panel, HGrTerrain, xTroop + 2 + X, yTroop + 9 - yyt, xxt * 2,
    51065106                yyt * 3, 1 + xSrcBase * (xxt * 2 + 1),
    51075107                1 + ySrcBase * (yyt * 3 + 1));
    5108             Sprite(Panel, HGrTerrain, xTroop + 2 + x, yTroop + 9 - yyt, xxt * 2,
     5108            Sprite(Panel, HGrTerrain, xTroop + 2 + X, yTroop + 9 - yyt, xxt * 2,
    51095109              yyt * 3, 1 + xSrc * (xxt * 2 + 1), 1 + ySrc * (yyt * 3 + 1));
    5110             if BrushTypes[i] = BrushType then begin
    5111               ScreenTools.Frame(Panel.Canvas, xTroop + 2 + x,
    5112                 yTroop + 7 - yyt div 2, xTroop + 2 * xxt + x,
     5110            if BrushTypes[I] = BrushType then begin
     5111              ScreenTools.Frame(Panel.Canvas, xTroop + 2 + X,
     5112                yTroop + 7 - yyt div 2, xTroop + 2 * xxt + X,
    51135113                yTroop + 2 * yyt + 11, $000000, $000000);
    5114               ScreenTools.Frame(Panel.Canvas, xTroop + 1 + x,
    5115                 yTroop + 6 - yyt div 2, xTroop + 2 * xxt - 1 + x,
     5114              ScreenTools.Frame(Panel.Canvas, xTroop + 1 + X,
     5115                yTroop + 6 - yyt div 2, xTroop + 2 * xxt - 1 + X,
    51165116                yTroop + 2 * yyt + 10, MainTexture.ColorMark, MainTexture.ColorMark);
    51175117            end;
    51185118          end;
    51195119        end;
    5120         inc(Count)
     5120        Inc(Count)
    51215121      end;
    51225122      case BrushType of
    51235123        fDesert, fPrairie, fTundra, fArctic, fSwamp, fHills, fMountains:
    5124           s := Phrases.Lookup('TERRAIN', BrushType);
     5124          S := Phrases.Lookup('TERRAIN', BrushType);
    51255125        fShore:
    5126           s := Format(Phrases.Lookup('TWOTERRAINS'),
     5126          S := Format(Phrases.Lookup('TWOTERRAINS'),
    51275127            [Phrases.Lookup('TERRAIN', fOcean), Phrases.Lookup('TERRAIN',
    51285128            fShore)]);
    51295129        fGrass:
    5130           s := Format(Phrases.Lookup('TWOTERRAINS'),
     5130          S := Format(Phrases.Lookup('TWOTERRAINS'),
    51315131            [Phrases.Lookup('TERRAIN', fGrass), Phrases.Lookup('TERRAIN',
    51325132            fGrass + 12)]);
    51335133        fForest:
    5134           s := Format(Phrases.Lookup('TWOTERRAINS'),
     5134          S := Format(Phrases.Lookup('TWOTERRAINS'),
    51355135            [Phrases.Lookup('TERRAIN', fForest), Phrases.Lookup('TERRAIN',
    51365136            fJungle)]);
    51375137        fRiver:
    5138           s := Phrases.Lookup('RIVER');
     5138          S := Phrases.Lookup('RIVER');
    51395139        fDeadLands, fDeadLands or fCobalt, fDeadLands or fUranium,
    51405140          fDeadLands or fMercury:
    5141           s := Phrases.Lookup('TERRAIN', 3 * 12 + BrushType shr 25);
     5141          S := Phrases.Lookup('TERRAIN', 3 * 12 + BrushType shr 25);
    51425142        fPrefStartPos:
    5143           s := Phrases.Lookup('MAP_PREFSTART');
     5143          S := Phrases.Lookup('MAP_PREFSTART');
    51445144        fStartPos:
    5145           s := Phrases.Lookup('MAP_START');
     5145          S := Phrases.Lookup('MAP_START');
    51465146        fPoll:
    5147           s := Phrases.Lookup('POLL');
     5147          S := Phrases.Lookup('POLL');
    51485148      else // terrain improvements
    51495149        begin
    51505150          case BrushType of
    51515151            fRoad:
    5152               i := 1;
     5152              I := 1;
    51535153            fRR:
    5154               i := 2;
     5154              I := 2;
    51555155            tiIrrigation:
    5156               i := 4;
     5156              I := 4;
    51575157            tiFarm:
    5158               i := 5;
     5158              I := 5;
    51595159            tiMine:
    5160               i := 7;
     5160              I := 7;
    51615161            fCanal:
    5162               i := 8;
     5162              I := 8;
    51635163            tiFort:
    5164               i := 10;
     5164              I := 10;
    51655165            tiBase:
    5166               i := 12;
     5166              I := 12;
    51675167          end;
    5168           s := Phrases.Lookup('JOBRESULT', i);
     5168          S := Phrases.Lookup('JOBRESULT', I);
    51695169        end
    51705170      end;
    51715171      LoweredTextOut(Panel.Canvas, -1, MainTexture, xTroop + 1,
    5172         PanelHeight - 19, s);
     5172        PanelHeight - 19, S);
    51735173    end
    51745174    else if TroopLoc >= 0 then
     
    51835183          else
    51845184            mixShow := mix;
    5185           with Tribe[me].ModelPicture[mixShow] do
     5185          with Tribe[Me].ModelPicture[mixShow] do
    51865186          begin
    51875187            Sprite(Panel, HGr, xMidPanel + 7 + 12, yTroop + 1, 64, 48,
     
    51935193
    51945194          MakeBlue(Panel, xMidPanel + 7 + 12 + 10, yTroop - 13, 44, 12);
    5195           s := MovementToString(MyUn[UnFocus]);
     5195          S := MovementToString(MyUn[UnFocus]);
    51965196          RisedTextOut(Panel.Canvas, xMidPanel + 7 + 12 + 32 -
    5197             BiColorTextWidth(Panel.Canvas, s) div 2, yTroop - 16, s);
    5198 
    5199           s := IntToStr(Health) + '%';
     5197            BiColorTextWidth(Panel.Canvas, S) div 2, yTroop - 16, S);
     5198
     5199          S := IntToStr(Health) + '%';
    52005200          LightGradient(Panel.Canvas, xMidPanel + 7 + 12 + 7, PanelHeight - 22,
    52015201            (Health + 1) div 2, (ColorOfHealth(Health) and $FEFEFE shr 2) * 3);
     
    52045204              div 2, PanelHeight - 22, 50 - (Health + 1) div 2, $000000);
    52055205          RisedTextOut(Panel.Canvas, xMidPanel + 7 + 12 + 32 -
    5206             BiColorTextWidth(Panel.Canvas, s) div 2, PanelHeight - 23, s);
     5206            BiColorTextWidth(Panel.Canvas, S) div 2, PanelHeight - 23, S);
    52075207
    52085208          FrameImage(Panel.Canvas, HGrSystem.Data,
     
    52105210            121 + Exp div ExpCost * 13, 28);
    52115211          if Job = jCity then
    5212             s := Tribe[me].ModelName[-1]
     5212            S := Tribe[Me].ModelName[-1]
    52135213          else
    5214             s := Tribe[me].ModelName[mix];
     5214            S := Tribe[Me].ModelName[mix];
    52155215          if Home >= 0 then
    52165216          begin
    52175217            LoweredTextOut(Panel.Canvas, -1, MainTexture,
    5218               xMidPanel + 7 + xUnitText + 18, yTroop + 5, s);
     5218              xMidPanel + 7 + xUnitText + 18, yTroop + 5, S);
    52195219            LoweredTextOut(Panel.Canvas, -1, MainTexture,
    52205220              xMidPanel + 7 + xUnitText + 18, yTroop + 21,
     
    52235223          else
    52245224            LoweredTextOut(Panel.Canvas, -1, MainTexture,
    5225               xMidPanel + 7 + xUnitText + 18, yTroop + 13, s);
     5225              xMidPanel + 7 + xUnitText + 18, yTroop + 13, S);
    52265226        end;
    52275227
    52285228      if (UnFocus >= 0) and (MyUn[UnFocus].Loc <> TroopLoc) then
    52295229      begin // divide panel
    5230         if SmallScreen and not supervising then
    5231           x := xTroop - 8
     5230        if SmallScreen and not Supervising then
     5231          X := xTroop - 8
    52325232        else
    5233           x := xTroop - 152;
     5233          X := xTroop - 152;
    52345234        Pen.Color := MainTexture.ColorBevelShade;
    5235         MoveTo(x - 1, PanelHeight - MidPanelHeight + 2);
    5236         LineTo(x - 1, PanelHeight);
     5235        MoveTo(X - 1, PanelHeight - MidPanelHeight + 2);
     5236        LineTo(X - 1, PanelHeight);
    52375237        Pen.Color := MainTexture.ColorBevelLight;
    5238         MoveTo(x, PanelHeight - MidPanelHeight + 2);
    5239         LineTo(x, PanelHeight);
    5240       end;
    5241 
    5242       for i := 0 to 23 do
    5243         trix[i] := -1;
     5238        MoveTo(X, PanelHeight - MidPanelHeight + 2);
     5239        LineTo(X, PanelHeight);
     5240      end;
     5241
     5242      for I := 0 to 23 do
     5243        trix[I] := -1;
    52445244      if MyMap[TroopLoc] and fUnit <> 0 then
    52455245      begin
     
    52515251            LoweredTextOut(Panel.Canvas, -1, MainTexture, xTroop + 10,
    52525252              PanelHeight - 24, Phrases.Lookup('PRESENT'));
    5253             Server(sGetDefender, me, TroopLoc, uixDefender);
     5253            Server(sGetDefender, Me, TroopLoc, uixDefender);
    52545254            Count := 0;
    5255             for Prio := true downto false do
     5255            for Prio := True downto False do
    52565256              for uix := 0 to MyRO.nUn - 1 do
    52575257                if (uix = uixDefender) = Prio then
     
    52645264                    begin
    52655265                      trix[Count - TrRow * sb.Position] := uix;
    5266                       MakeUnitInfo(me, unx, UnitInfo);
    5267                       x := (Count - TrRow * sb.Position) * TrPitch;
     5266                      MakeUnitInfo(Me, unx, UnitInfo);
     5267                      X := (Count - TrRow * sb.Position) * TrPitch;
    52685268                      if uix = UnFocus then
    52695269                      begin
    5270                         ScreenTools.Frame(Panel.Canvas, xTroop + 4 + x,
    5271                           yTroop + 3, xTroop + 64 + x, yTroop + 47,
     5270                        ScreenTools.Frame(Panel.Canvas, xTroop + 4 + X,
     5271                          yTroop + 3, xTroop + 64 + X, yTroop + 47,
    52725272                          $000000, $000000);
    5273                         ScreenTools.Frame(Panel.Canvas, xTroop + 3 + x,
    5274                           yTroop + 2, xTroop + 63 + x, yTroop + 46,
     5273                        ScreenTools.Frame(Panel.Canvas, xTroop + 3 + X,
     5274                          yTroop + 2, xTroop + 63 + X, yTroop + 46,
    52755275                          MainTexture.ColorMark, MainTexture.ColorMark);
    52765276                      end
    52775277                      else if (unx.Master >= 0) and (unx.Master = UnFocus) then
    52785278                      begin
    5279                         CFrame(Panel.Canvas, xTroop + 4 + x, yTroop + 3,
    5280                           xTroop + 64 + x, yTroop + 47, 8, $000000);
    5281                         CFrame(Panel.Canvas, xTroop + 3 + x, yTroop + 2,
    5282                           xTroop + 63 + x, yTroop + 46, 8, MainTexture.ColorMark);
     5279                        CFrame(Panel.Canvas, xTroop + 4 + X, yTroop + 3,
     5280                          xTroop + 64 + X, yTroop + 47, 8, $000000);
     5281                        CFrame(Panel.Canvas, xTroop + 3 + X, yTroop + 2,
     5282                          xTroop + 63 + X, yTroop + 46, 8, MainTexture.ColorMark);
    52835283                      end;
    52845284                      NoMapPanel.SetOutput(Panel);
    5285                       NoMapPanel.PaintUnit(xTroop + 2 + x, yTroop + 1, UnitInfo,
     5285                      NoMapPanel.PaintUnit(xTroop + 2 + X, yTroop + 1, UnitInfo,
    52865286                        unx.Status);
    52875287                      if (ClientMode < scContact) and
     
    52895289                        (unx.Status and (usStay or usRecover or usGoto) <> 0))
    52905290                      then
    5291                         Sprite(Panel, HGrSystem, xTroop + 2 + 60 - 20 + x,
     5291                        Sprite(Panel, HGrSystem, xTroop + 2 + 60 - 20 + X,
    52925292                          yTroop + 35, 20, 20, 81, 25);
    52935293
    5294                       if not supervising then
     5294                      if not Supervising then
    52955295                      begin
    5296                         MakeBlue(Panel, xTroop + 2 + 10 + x,
     5296                        MakeBlue(Panel, xTroop + 2 + 10 + X,
    52975297                          yTroop - 13, 44, 12);
    5298                         s := MovementToString(unx);
     5298                        S := MovementToString(unx);
    52995299                        RisedTextOut(Panel.Canvas,
    5300                           xTroop + x + 34 - BiColorTextWidth(Panel.Canvas, s)
    5301                           div 2, yTroop - 16, s);
     5300                          xTroop + X + 34 - BiColorTextWidth(Panel.Canvas, S)
     5301                          div 2, yTroop - 16, S);
    53025302                      end;
    53035303                    end;
    5304                     inc(Count)
     5304                    Inc(Count)
    53055305                  end;
    53065306                end; // for uix:=0 to MyRO.nUn-1
    5307             assert(Count = TrCnt);
     5307            Assert(Count = TrCnt);
    53085308          end;
    53095309        end
     
    53125312          LoweredTextOut(Panel.Canvas, -1, MainTexture, xTroop + 8,
    53135313            PanelHeight - 24, Phrases.Lookup('PRESENT'));
    5314           Server(sGetUnits, me, TroopLoc, Count);
    5315           for i := 0 to Count - 1 do
    5316             if (i >= TrRow * sb.Position) and (i < TrRow * (sb.Position + 1)) then
     5314          Server(sGetUnits, Me, TroopLoc, Count);
     5315          for I := 0 to Count - 1 do
     5316            if (I >= TrRow * sb.Position) and (I < TrRow * (sb.Position + 1)) then
    53175317            begin // display enemy units
    5318               trix[i - TrRow * sb.Position] := i;
    5319               x := (i - TrRow * sb.Position) * TrPitch;
     5318              trix[I - TrRow * sb.Position] := I;
     5319              X := (I - TrRow * sb.Position) * TrPitch;
    53205320              NoMapPanel.SetOutput(Panel);
    5321               NoMapPanel.PaintUnit(xTroop + 2 + x, yTroop + 1,
    5322                 MyRO.EnemyUn[MyRO.nEnemyUn + i], 0);
     5321              NoMapPanel.PaintUnit(xTroop + 2 + X, yTroop + 1,
     5322                MyRO.EnemyUn[MyRO.nEnemyUn + I], 0);
    53235323            end;
    53245324        end;
    53255325      end;
    5326       if not SmallScreen or supervising then
     5326      if not SmallScreen or Supervising then
    53275327      begin // show terrain and improvements
    53285328        with NoMapPanel do
     
    53305330        if (UnFocus >= 0) and (MyUn[UnFocus].Job <> jNone) then begin
    53315331          JobFocus := MyUn[UnFocus].Job;
    5332           Server(sGetJobProgress, me, MyUn[UnFocus].Loc, JobProgressData);
     5332          Server(sGetJobProgress, Me, MyUn[UnFocus].Loc, JobProgressData);
    53335333          MakeBlue(Panel, xTerrain - 72, 148 - 17, 144, 31);
    53345334          PaintRelativeProgressBar(Panel.Canvas, 3, xTerrain - 68, 148 + 3, 63,
    53355335            JobProgressData[JobFocus].Done,
    53365336            JobProgressData[JobFocus].NextTurnPlus,
    5337             JobProgressData[JobFocus].Required, true, MainTexture);
    5338           s := Format('%s/%s',
     5337            JobProgressData[JobFocus].Required, True, MainTexture);
     5338          S := Format('%s/%s',
    53395339            [ScreenTools.MovementToString(JobProgressData[JobFocus].Done),
    53405340            ScreenTools.MovementToString(JobProgressData[JobFocus].Required)]);
    5341           RisedTextOut(Panel.Canvas, xTerrain + 6, 148 - 3, s);
     5341          RisedTextOut(Panel.Canvas, xTerrain + 6, 148 - 3, S);
    53425342          Tile := MyMap[MyUn[UnFocus].Loc];
    53435343          if (JobFocus = jRoad) and (Tile and fRiver <> 0) then
     
    53545354              JobFocus := nJob + 4
    53555355          end;
    5356           s := Phrases.Lookup('JOBRESULT', JobFocus);
     5356          S := Phrases.Lookup('JOBRESULT', JobFocus);
    53575357          RisedTextOut(Panel.Canvas, xTerrain - BiColorTextWidth(Panel.Canvas,
    5358             s) div 2, 148 - 19, s);
     5358            S) div 2, 148 - 19, S);
    53595359        end;
    53605360        if MyMap[TroopLoc] and (fTerrain or fSpecial) = fGrass or fSpecial1 then
    5361           s := Phrases.Lookup('TERRAIN', fGrass + 12)
     5361          S := Phrases.Lookup('TERRAIN', fGrass + 12)
    53625362        else if MyMap[TroopLoc] and fDeadLands <> 0 then
    5363           s := Phrases.Lookup('TERRAIN', 3 * 12)
     5363          S := Phrases.Lookup('TERRAIN', 3 * 12)
    53645364        else if (MyMap[TroopLoc] and fTerrain = fForest) and
    53655365          IsJungle(TroopLoc div G.lx) then
    5366           s := Phrases.Lookup('TERRAIN', fJungle)
     5366          S := Phrases.Lookup('TERRAIN', fJungle)
    53675367        else
    5368           s := Phrases.Lookup('TERRAIN', MyMap[TroopLoc] and fTerrain);
    5369         RisedTextOut(Panel.Canvas, xTerrain - BiColorTextWidth(Panel.Canvas, s)
    5370           div 2, 99, s);
     5368          S := Phrases.Lookup('TERRAIN', MyMap[TroopLoc] and fTerrain);
     5369        RisedTextOut(Panel.Canvas, xTerrain - BiColorTextWidth(Panel.Canvas, S)
     5370          div 2, 99, S);
    53715371      end;
    53725372
     
    53795379  end;
    53805380
    5381   for i := 0 to ControlCount - 1 do
    5382     if Controls[i] is TButtonB then
    5383       with TButtonB(Controls[i]) do
     5381  for I := 0 to ControlCount - 1 do
     5382    if Controls[I] is TButtonB then
     5383      with TButtonB(Controls[I]) do
    53845384      begin
    53855385        if Visible then
     
    53975397  if ClientMode <> cEditMap then
    53985398  begin
    5399     for i := 0 to ControlCount - 1 do
    5400       if Controls[i] is TButtonC then
    5401         with TButtonC(Controls[i]) do
     5399    for I := 0 to ControlCount - 1 do
     5400      if Controls[I] is TButtonC then
     5401        with TButtonC(Controls[I]) do
    54025402        begin
    54035403          Dump(Panel, HGrSystem, Left, Top - self.ClientHeight + PanelHeight,
     
    54395439    TrueMoney := MyRO.Money;
    54405440    TrueResearch := MyRO.Research;
    5441     if supervising then
     5441    if Supervising then
    54425442    begin // normalize values from after-turn state
    5443       dec(TrueMoney, TaxSum);
     5443      Dec(TrueMoney, TaxSum);
    54445444      if TrueMoney < 0 then
    54455445        TrueMoney := 0; // shouldn't happen
    5446       dec(TrueResearch, ScienceSum);
     5446      Dec(TrueResearch, ScienceSum);
    54475447      if TrueResearch < 0 then
    54485448        TrueResearch := 0; // shouldn't happen
     
    54525452    ImageOp_BCC(TopBar, Templates.Data, Point(xTreasurySection + 8, 1), TreasuryIcon.BoundsRect,
    54535453      $40A040, $4030C0);
    5454     s := IntToStr(TrueMoney);
     5454    S := IntToStr(TrueMoney);
    54555455    LoweredTextOut(TopBar.Canvas, -1, MainTexture, xTreasurySection + 48, 0,
    5456       s + '%c');
     5456      S + '%c');
    54575457    if MyRO.Government <> gAnarchy then
    54585458    begin
     
    54605460        $0000C0, $0080C0);
    54615461      if TaxSum >= 0 then
    5462         s := Format(Phrases.Lookup('MONEYGAINPOS'), [TaxSum])
     5462        S := Format(Phrases.Lookup('MONEYGAINPOS'), [TaxSum])
    54635463      else
    5464         s := Format(Phrases.Lookup('MONEYGAINNEG'), [TaxSum]);
     5464        S := Format(Phrases.Lookup('MONEYGAINNEG'), [TaxSum]);
    54655465      LoweredTextOut(TopBar.Canvas, -1, MainTexture, xTreasurySection + 48 +
    5466         15, 18, s);
     5466        15, 18, S);
    54675467    end;
    54685468
     
    54845484      else
    54855485        CostFactor := 2;
    5486       Server(sGetTechCost, me, 0, i);
     5486      Server(sGetTechCost, Me, 0, I);
    54875487      CostFactor := CostFactor * 22; // length of progress bar
    54885488      PaintRelativeProgressBar(TopBar.Canvas, 2, xResearchSection + 48 + 1, 26,
    5489         CostFactor, TrueResearch, ScienceSum, i, true, MainTexture);
     5489        CostFactor, TrueResearch, ScienceSum, I, True, MainTexture);
    54905490
    54915491      if MyRO.ResearchTech < 0 then
    5492         s := Phrases.Lookup('SCIENCE')
     5492        S := Phrases.Lookup('SCIENCE')
    54935493      else if MyRO.ResearchTech = adMilitary then
    5494         s := Phrases.Lookup('INITUNIT')
     5494        S := Phrases.Lookup('INITUNIT')
    54955495      else
    54965496      begin
    5497         s := Phrases.Lookup('ADVANCES', MyRO.ResearchTech);
     5497        S := Phrases.Lookup('ADVANCES', MyRO.ResearchTech);
    54985498        if MyRO.ResearchTech in FutureTech then
    54995499          if MyRO.Tech[MyRO.ResearchTech] >= 1 then
    5500             s := s + ' ' + IntToStr(MyRO.Tech[MyRO.ResearchTech] + 1)
     5500            S := S + ' ' + IntToStr(MyRO.Tech[MyRO.ResearchTech] + 1)
    55015501          else
    5502             s := s + ' 1';
     5502            S := S + ' 1';
    55035503      end;
    55045504      if ScienceSum > 0 then
    55055505      begin
    55065506        { j:=(i-MyRO.Research-1) div ScienceSum +1;
    5507           if j<1 then j:=1;
    5508           if j>1 then
    5509           s:=Format(Phrases.Lookup('TECHWAIT'),[s,j]); }
     5507          if J<1 then J:=1;
     5508          if J>1 then
     5509          S:=Format(Phrases.Lookup('TECHWAIT'),[S,J]); }
    55105510        LoweredTextOut(TopBar.Canvas, -1, MainTexture,
    5511           xResearchSection + 48, 0, s);
     5511          xResearchSection + 48, 0, S);
    55125512      end
    55135513      else
    55145514        LoweredTextOut(TopBar.Canvas, -1, MainTexture,
    5515           xResearchSection + 48, 0, s);
     5515          xResearchSection + 48, 0, S);
    55165516    end
    55175517    else
     
    55215521      ImageOp_BCC(TopBar, Templates.Data, Point(xResearchSection + 48 + CostFactor + 11,
    55225522        22), ChangeIcon.BoundsRect, $0000C0, $0080C0);
    5523       s := Format(Phrases.Lookup('TECHGAIN'), [ScienceSum]);
     5523      S := Format(Phrases.Lookup('TECHGAIN'), [ScienceSum]);
    55245524      LoweredTextOut(TopBar.Canvas, -1, MainTexture, xResearchSection + 48 +
    5525         CostFactor + 26, 18, s);
     5525        CostFactor + 26, 18, S);
    55265526    end;
    55275527  end;
     
    55295529  begin
    55305530    TopBar.Canvas.Font.Assign(UniFont[ftCaption]);
    5531     s := TurnToString(MyRO.Turn);
     5531    S := TurnToString(MyRO.Turn);
    55325532    RisedTextOut(TopBar.Canvas,
    5533       40 + (xTreasurySection - 40 - BiColorTextWidth(TopBar.Canvas, s))
    5534       div 2, 6, s);
     5533      40 + (xTreasurySection - 40 - BiColorTextWidth(TopBar.Canvas, S))
     5534      div 2, 6, S);
    55355535    TopBar.Canvas.Font.Assign(UniFont[ftNormal]);
    55365536  end;
     
    55405540procedure TMainScreen.FocusNextUnit(Dir: Integer);
    55415541var
    5542   i, uix, NewFocus: Integer;
     5542  I, uix, NewFocus: Integer;
    55435543begin
    55445544  if ClientMode >= scContact then
     
    55475547  PaintDestination;
    55485548  NewFocus := -1;
    5549   for i := 1 to MyRO.nUn do begin
    5550     uix := (UnFocus + i * Dir + MyRO.nUn) mod MyRO.nUn;
     5549  for I := 1 to MyRO.nUn do begin
     5550    uix := (UnFocus + I * Dir + MyRO.nUn) mod MyRO.nUn;
    55515551    if (MyUn[uix].Loc >= 0) and (MyUn[uix].Status and usStay = 0) then begin
    55525552      NewFocus := uix;
     
    55615561end;
    55625562
    5563 procedure TMainScreen.FocusOnLoc(Loc: integer; Options: integer = 0);
     5563procedure TMainScreen.FocusOnLoc(Loc: Integer; Options: Integer = 0);
    55645564var
    5565   dx: integer;
    5566   Outside, Changed: boolean;
     5565  dx: Integer;
     5566  Outside, Changed: Boolean;
    55675567begin
    55685568  with MainMap do begin
     
    55725572      (Loc div G.lx >= yw + (MapHeight - 1) div yyt - 2));
    55735573  end;
    5574   Changed := true;
     5574  Changed := True;
    55755575  if Outside then begin
    55765576    Centre(Loc);
     
    55805580    PaintAllMaps
    55815581  else
    5582     Changed := false;
     5582    Changed := False;
    55835583  if Options and flRepaintPanel <> 0 then
    55845584    PanelPaint;
     
    55905590var
    55915591  Dist, TestDist: Single;
    5592   i, uix, NewFocus: Integer;
     5592  I, uix, NewFocus: Integer;
    55935593  GotoOnly: Boolean;
    55945594begin
     
    56005600  for GotoOnly := GoOnPhase downto False do begin
    56015601    NewFocus := -1;
    5602     for i := 1 to MyRO.nUn do begin
    5603       uix := (UnFocus + i) mod MyRO.nUn;
     5602    for I := 1 to MyRO.nUn do begin
     5603      uix := (UnFocus + I) mod MyRO.nUn;
    56045604      if (MyUn[uix].Loc >= 0) and (MyUn[uix].Job = jNone) and
    56055605        (MyUn[uix].Status and (usStay or usRecover or usWaiting) = usWaiting)
     
    56405640end;
    56415641
    5642 procedure TMainScreen.Scroll(dx, dy: integer);
     5642procedure TMainScreen.Scroll(dx, dy: Integer);
    56435643begin
    56445644  xw := (xw + G.lx + dx) mod G.lx;
     
    56645664procedure TMainScreen.Timer1Timer(Sender: TObject);
    56655665var
    5666   dx, dy, ScrollSpeed: integer;
    5667 begin
    5668   if idle and (me >= 0) and (GameMode <> cMovie) then
     5666  dx, dy, ScrollSpeed: Integer;
     5667begin
     5668  if Idle and (Me >= 0) and (GameMode <> cMovie) then
    56695669    if (fsModal in Screen.ActiveForm.FormState) or
    56705670      (Screen.ActiveForm is TBufferedDrawDlg) and
     
    56745674      if not BlinkON then
    56755675      begin
    5676         BlinkON := true;
     5676        BlinkON := True;
    56775677        if UnFocus >= 0 then
    56785678          PaintLocTemp(MyUn[UnFocus].Loc)
    5679         else if TurnComplete and not supervising then
     5679        else if TurnComplete and not Supervising then
    56805680          EOT.SetButtonIndexFast(eotBlinkOn);
    56815681      end;
     
    56895689        dx := 0;
    56905690        dy := 0;
    5691         if Mouse.CursorPos.y < Screen.height - PanelHeight then
    5692           if Mouse.CursorPos.x = 0 then
     5691        if Mouse.CursorPos.Y < Screen.height - PanelHeight then
     5692          if Mouse.CursorPos.X = 0 then
    56935693            dx := -ScrollSpeed // scroll left
    5694           else if Mouse.CursorPos.x = Screen.width - 1 then
     5694          else if Mouse.CursorPos.X = Screen.width - 1 then
    56955695            dx := ScrollSpeed; // scroll right
    5696         if Mouse.CursorPos.y = 0 then
     5696        if Mouse.CursorPos.Y = 0 then
    56975697          dy := -ScrollSpeed // scroll up
    5698         else if (Mouse.CursorPos.y = Screen.height - 1) and
    5699           (Mouse.CursorPos.x >= TerrainBtn.Left + TerrainBtn.width) and
    5700           (Mouse.CursorPos.x < xRightPanel + 10 - 8) then
     5698        else if (Mouse.CursorPos.Y = Screen.height - 1) and
     5699          (Mouse.CursorPos.X >= TerrainBtn.Left + TerrainBtn.width) and
     5700          (Mouse.CursorPos.X < xRightPanel + 10 - 8) then
    57015701          dy := ScrollSpeed; // scroll down
    57025702        if (dx <> 0) or (dy <> 0) then
     
    57115711      BlinkTime := (BlinkTime + 1) mod (BlinkOnTime + BlinkOffTime);
    57125712      BlinkON := BlinkTime >= BlinkOffTime;
    5713       DestinationMarkON := true;
     5713      DestinationMarkON := True;
    57145714      if UnFocus >= 0 then
    57155715      begin
     
    57225722        end;
    57235723      end
    5724       else if TurnComplete and not supervising then
     5724      else if TurnComplete and not Supervising then
    57255725      begin
    57265726        if BlinkTime = 0 then
     
    57325732end;
    57335733
    5734 procedure TMainScreen.SetMapPos(Loc: integer; MapPos: TPoint);
     5734procedure TMainScreen.SetMapPos(Loc: Integer; MapPos: TPoint);
    57355735begin
    57365736  with MainMap do begin
     
    57505750end;
    57515751
    5752 procedure TMainScreen.Centre(Loc: integer);
     5752procedure TMainScreen.Centre(Loc: Integer);
    57535753begin
    57545754  SetMapPos(Loc, Point(MapWidth div 2, MapHeight div 2));
    57555755end;
    57565756
    5757 function TMainScreen.ZoomToCity(Loc: integer; NextUnitOnClose: boolean = false;
    5758   ShowEvent: integer = 0): boolean;
    5759 begin
    5760   result := MyMap[Loc] and (fOwned or fSpiedOut) <> 0;
    5761   if result then
     5757function TMainScreen.ZoomToCity(Loc: Integer; NextUnitOnClose: Boolean = False;
     5758  ShowEvent: Integer = 0): Boolean;
     5759begin
     5760  Result := MyMap[Loc] and (fOwned or fSpiedOut) <> 0;
     5761  if Result then
    57625762    with CityDlg do
    57635763    begin
     
    57855785end;
    57865786
    5787 function TMainScreen.LocationOfScreenPixel(x, y: integer): Integer;
     5787function TMainScreen.LocationOfScreenPixel(X, Y: Integer): Integer;
    57885788var
    5789   qx, qy: integer;
     5789  qx, qy: Integer;
    57905790begin
    57915791  with MainMap do begin
    5792     qx := (x * (yyt * 2) + y * (xxt * 2) + xxt * yyt * 2) div (xxt * yyt * 4) - 1;
    5793     qy := (y * (xxt * 2) - x * (yyt * 2) - xxt * yyt * 2 + 4000 * xxt * yyt)
     5792    qx := (X * (yyt * 2) + Y * (xxt * 2) + xxt * yyt * 2) div (xxt * yyt * 4) - 1;
     5793    qy := (Y * (xxt * 2) - X * (yyt * 2) - xxt * yyt * 2 + 4000 * xxt * yyt)
    57945794      div (xxt * yyt * 4) - 999;
    57955795    Result := (xw + (qx - qy + 2048) div 2 - 1024 + G.lx) mod G.lx + G.lx *
     
    58055805
    58065806procedure TMainScreen.MapBoxMouseDown(Sender: TObject; Button: TMouseButton;
    5807   Shift: TShiftState; x, y: integer);
     5807  Shift: TShiftState; X, Y: Integer);
    58085808var
    5809   i, uix, emix, p1, dx, dy, MouseLoc: integer;
     5809  I, uix, emix, p1, dx, dy, MouseLoc: Integer;
    58105810  EditTileData: TEditTileData;
    5811   m, m2: TMenuItem;
     5811  M, m2: TMenuItem;
    58125812  MoveAdviceData: TMoveAdviceData;
    5813   DoCenter: boolean;
     5813  DoCenter: Boolean;
    58145814begin
    58155815  if GameMode = cMovie then
    5816     exit;
     5816    Exit;
    58175817
    58185818  if CityDlg.Visible then
     
    58205820  if UnitStatDlg.Visible then
    58215821    UnitStatDlg.Close;
    5822   MouseLoc := LocationOfScreenPixel(x, y);
     5822  MouseLoc := LocationOfScreenPixel(X, Y);
    58235823  if (MouseLoc < 0) or (MouseLoc >= G.lx * G.ly) then
    5824     exit;
     5824    Exit;
    58255825  if (Button = mbLeft) and not(ssShift in Shift) then
    58265826  begin
    5827     DoCenter := true;
     5827    DoCenter := True;
    58285828    if ClientMode = cEditMap then
    58295829    begin
    5830       DoCenter := false;
     5830      DoCenter := False;
    58315831      EditTileData.Loc := MouseLoc;
    58325832      if ssCtrl in Shift then // toggle special resource
     
    58665866      else
    58675867        EditTileData.NewTile := MyMap[MouseLoc] xor BrushType;
    5868       Server(sEditTile, me, 0, EditTileData);
    5869       Edited := true;
     5868      Server(sEditTile, Me, 0, EditTileData);
     5869      Edited := True;
    58705870      BrushLoc := MouseLoc;
    58715871      PaintLoc(MouseLoc, 2);
     
    58935893      begin
    58945894        ZoomToCity(MouseLoc);
    5895         DoCenter := false;
     5895        DoCenter := False;
    58965896      end
    58975897      else
    58985898      begin
    58995899        UnitStatDlg.ShowNewContent_EnemyCity(wmPersistent, MouseLoc);
    5900         DoCenter := false;
     5900        DoCenter := False;
    59015901      end;
    59025902    end
     
    59045904      if MyMap[MouseLoc] and fOwned <> 0 then
    59055905      begin
    5906         DoCenter := false;
    5907         if not supervising and (ClientMode < scContact) then
     5906        DoCenter := False;
     5907        if not Supervising and (ClientMode < scContact) then
    59085908        begin // not in negotiation mode
    59095909          if (UnFocus >= 0) and (MyUn[UnFocus].Loc = MouseLoc) then
    59105910          begin // rotate
    59115911            uix := (UnFocus + 1) mod MyRO.nUn;
    5912             i := MyRO.nUn - 1;
    5913             while i > 0 do
     5912            I := MyRO.nUn - 1;
     5913            while I > 0 do
    59145914            begin
    59155915              if (MyUn[uix].Loc = MouseLoc) and (MyUn[uix].Job = jNone) and
     
    59175917                usWaiting) = usWaiting) then
    59185918                Break;
    5919               dec(i);
     5919              Dec(I);
    59205920              uix := (uix + 1) mod MyRO.nUn;
    59215921            end;
    5922             if i = 0 then
     5922            if I = 0 then
    59235923              uix := UnFocus;
    59245924          end
    59255925          else
    5926             Server(sGetDefender, me, MouseLoc, uix);
     5926            Server(sGetDefender, Me, MouseLoc, uix);
    59275927          if uix <> UnFocus then
    59285928            SetUnFocus(uix);
    5929           TurnComplete := false;
     5929          TurnComplete := False;
    59305930          EOT.ButtonIndex := eotGray;
    59315931        end;
     
    59355935      else if (MyMap[MouseLoc] and fSpiedOut <> 0) and not(ssCtrl in Shift) then
    59365936      begin
    5937         DoCenter := false;
     5937        DoCenter := False;
    59385938        SetTroopLoc(MouseLoc);
    59395939        PanelPaint;
     
    59415941      else
    59425942      begin
    5943         DoCenter := false;
     5943        DoCenter := False;
    59445944        UnitStatDlg.ShowNewContent_EnemyLoc(wmPersistent, MouseLoc);
    59455945      end;
     
    59535953    not(ssShift in Shift) then
    59545954  begin
    5955     if supervising then
     5955    if Supervising then
    59565956    begin
    59575957      EditLoc := MouseLoc;
    5958       Server(sGetModels, me, 0, nil^);
     5958      Server(sGetModels, Me, 0, nil^);
    59595959      EmptyMenu(mCreateUnit);
    59605960      for p1 := 0 to nPl - 1 do
    59615961        if 1 shl p1 and MyRO.Alive <> 0 then
    59625962        begin
    5963           m := TMenuItem.Create(mCreateUnit);
    5964           m.Caption := Tribe[p1].TPhrase('SHORTNAME');
     5963          M := TMenuItem.Create(mCreateUnit);
     5964          M.Caption := Tribe[p1].TPhrase('SHORTNAME');
    59655965          for emix := MyRO.nEnemyModel - 1 downto 0 do
    59665966            if (MyRO.EnemyModel[emix].Owner = p1) and
    5967               (Server(sCreateUnit - sExecute + p1 shl 4, me,
     5967              (Server(sCreateUnit - sExecute + p1 shl 4, Me,
    59685968              MyRO.EnemyModel[emix].mix, MouseLoc) >= rExecuted) then
    59695969            begin
    59705970              if not Assigned(Tribe[p1].ModelPicture[MyRO.EnemyModel[emix].mix].HGr) then
    59715971                InitEnemyModel(emix);
    5972               m2 := TMenuItem.Create(m);
     5972              m2 := TMenuItem.Create(M);
    59735973              m2.Caption := Tribe[p1].ModelName[MyRO.EnemyModel[emix].mix];
    59745974              m2.Tag := p1 shl 16 + MyRO.EnemyModel[emix].mix;
    59755975              m2.OnClick := CreateUnitClick;
    5976               m.Add(m2);
     5976              M.Add(m2);
    59775977            end;
    5978           m.Visible := m.Count > 0;
    5979           mCreateUnit.Add(m);
     5978          M.Visible := M.Count > 0;
     5979          mCreateUnit.Add(M);
    59805980        end;
    59815981      if FullScreen then
    5982         EditPopup.Popup(Left + x, Top + y)
     5982        EditPopup.Popup(Left + X, Top + Y)
    59835983      else
    5984         EditPopup.Popup(Left + x + 4,
    5985           Top + y + GetSystemMetrics(SM_CYCAPTION) + 4);
     5984        EditPopup.Popup(Left + X + 4,
     5985          Top + Y + GetSystemMetrics(SM_CYCAPTION) + 4);
    59865986    end
    59875987    else if (UnFocus >= 0) and (MyUn[UnFocus].Loc <> MouseLoc) then
     
    59945994        if abs(dx) + abs(dy) < 3 then
    59955995        begin
    5996           DestinationMarkON := false;
     5996          DestinationMarkON := False;
    59975997          PaintDestination;
    59985998          Status := Status and ($FFFF - usStay - usRecover - usGoto - usEnhance)
     
    60076007            with MyUn[UnFocus], BattleDlg.Forecast do
    60086008            begin
    6009               pAtt := me;
     6009              pAtt := Me;
    60106010              mixAtt := mix;
    60116011              HealthAtt := Health;
     
    60146014            end;
    60156015            BattleDlg.Forecast.Movement := MyUn[UnFocus].Movement;
    6016             if (Server(sGetBattleForecastEx, me, MouseLoc, BattleDlg.Forecast)
     6016            if (Server(sGetBattleForecastEx, Me, MouseLoc, BattleDlg.Forecast)
    60176017              >= rExecuted) and (BattleDlg.Forecast.EndHealthAtt <= 0) then
    60186018            begin
    60196019              BattleDlg.uix := UnFocus;
    60206020              BattleDlg.ToLoc := MouseLoc;
    6021               BattleDlg.IsSuicideQuery := true;
     6021              BattleDlg.IsSuicideQuery := True;
    60226022              BattleDlg.ShowModal;
    60236023              if BattleDlg.ModalResult <> mrOK then
    6024                 exit;
     6024                Exit;
    60256025            end;
    60266026          end;
    6027           DestinationMarkON := false;
     6027          DestinationMarkON := False;
    60286028          PaintDestination;
    60296029          Status := Status and not(usStay or usRecover or usEnhance) or
    60306030            usWaiting;
    6031           MoveToLoc(MouseLoc, false); { goto }
     6031          MoveToLoc(MouseLoc, False); { goto }
    60326032        end;
    60336033      end;
     
    60366036    (MyModel[MyUn[UnFocus].mix].Kind in [mkSettler, mkSlaves]) then
    60376037  begin
    6038     DestinationMarkON := false;
     6038    DestinationMarkON := False;
    60396039    PaintDestination;
    60406040    MyUn[UnFocus].Status := MyUn[UnFocus].Status and
     
    60426042    uix := UnFocus;
    60436043    if MouseLoc <> MyUn[uix].Loc then
    6044       MoveToLoc(MouseLoc, true); { goto }
     6044      MoveToLoc(MouseLoc, True); { goto }
    60456045    if (UnFocus = uix) and (MyUn[uix].Loc = MouseLoc) then
    60466046      mEnhance.Click;
     
    60556055    with MyUn[UnFocus], BattleDlg.Forecast do
    60566056    begin
    6057       pAtt := me;
     6057      pAtt := Me;
    60586058      mixAtt := mix;
    60596059      HealthAtt := Health;
     
    60626062    end;
    60636063    BattleDlg.Forecast.Movement := MyUn[UnFocus].Movement;
    6064     if Server(sGetBattleForecastEx, me, MouseLoc, BattleDlg.Forecast) >= rExecuted
     6064    if Server(sGetBattleForecastEx, Me, MouseLoc, BattleDlg.Forecast) >= rExecuted
    60656065    then
    60666066    begin
    60676067      BattleDlg.uix := UnFocus;
    60686068      BattleDlg.ToLoc := MouseLoc;
    6069       BattleDlg.Left := x - BattleDlg.width div 2;
     6069      BattleDlg.Left := X - BattleDlg.width div 2;
    60706070      if BattleDlg.Left < 0 then
    60716071        BattleDlg.Left := 0
    60726072      else if BattleDlg.Left + BattleDlg.width > Screen.width then
    60736073        BattleDlg.Left := Screen.width - BattleDlg.width;
    6074       BattleDlg.Top := y - BattleDlg.height div 2;
     6074      BattleDlg.Top := Y - BattleDlg.height div 2;
    60756075      if BattleDlg.Top < 0 then
    60766076        BattleDlg.Top := 0
    60776077      else if BattleDlg.Top + BattleDlg.height > Screen.height then
    60786078        BattleDlg.Top := Screen.height - BattleDlg.height;
    6079       BattleDlg.IsSuicideQuery := false;
     6079      BattleDlg.IsSuicideQuery := False;
    60806080      BattleDlg.Show;
    60816081    end;
     
    60836083end;
    60846084
    6085 function TMainScreen.MoveUnit(dx, dy: integer; Options: integer): integer;
     6085function TMainScreen.MoveUnit(dx, dy: Integer; Options: Integer): Integer;
    60866086// move focused unit to adjacent tile
    60876087var
    6088   i, cix, uix, euix, FromLoc, ToLoc, DirCode, UnFocus0, Defender, Mission, p1,
    6089     NewTiles, cixChanged: integer;
     6088  I, cix, uix, euix, FromLoc, ToLoc, DirCode, UnFocus0, Defender, Mission, p1,
     6089    NewTiles, cixChanged: Integer;
    60906090  OldToTile: Cardinal;
    60916091  CityCaptured, IsAttack, OldUnrest, NewUnrest, NeedEcoUpdate, NeedRepaintPanel,
    6092     ToTransport, ToShip: boolean;
     6092    ToTransport, ToShip: Boolean;
    60936093  PlaneReturnData: TPlaneReturnData;
    60946094  QueryItem: string;
    60956095begin
    6096   result := eInvalid;
     6096  Result := eInvalid;
    60976097  UnFocus0 := UnFocus;
    60986098  FromLoc := MyUn[UnFocus].Loc;
     
    61006100  if (ToLoc < 0) or (ToLoc >= G.lx * G.ly) then
    61016101  begin
    6102     result := eInvalid;
    6103     exit;
     6102    Result := eInvalid;
     6103    Exit;
    61046104  end;
    61056105  if MyMap[ToLoc] and fStealthUnit <> 0 then
    61066106  begin
    61076107    SoundMessage(Phrases.Lookup('ATTACKSTEALTH'), '');
    6108     exit;
     6108    Exit;
    61096109  end;
    61106110  if MyMap[ToLoc] and fHiddenUnit <> 0 then
    61116111  begin
    61126112    SoundMessage(Phrases.Lookup('ATTACKSUB'), '');
    6113     exit;
     6113    Exit;
    61146114  end;
    61156115
     
    61216121    begin
    61226122      SoundMessage(Phrases.Lookup('NOATTACKER'), '');
    6123       exit;
     6123      Exit;
    61246124    end;
    61256125    euix := MyRO.nEnemyUn - 1;
    61266126    while (euix >= 0) and (MyRO.EnemyUn[euix].Loc <> ToLoc) do
    6127       dec(euix);
     6127      Dec(euix);
    61286128  end;
    61296129
    61306130  DirCode := dx and 7 shl 4 + dy and 7 shl 7;
    6131   result := Server(sMoveUnit - sExecute + DirCode, me, UnFocus, nil^);
    6132   if (result < rExecuted) and (MyUn[UnFocus].Job > jNone) then
    6133     Server(sStartJob + jNone shl 4, me, UnFocus, nil^);
    6134   if (result < rExecuted) and (result <> eNoTime_Move) then
    6135   begin
    6136     case result of
     6131  Result := Server(sMoveUnit - sExecute + DirCode, Me, UnFocus, nil^);
     6132  if (Result < rExecuted) and (MyUn[UnFocus].Job > jNone) then
     6133    Server(sStartJob + jNone shl 4, Me, UnFocus, nil^);
     6134  if (Result < rExecuted) and (Result <> eNoTime_Move) then
     6135  begin
     6136    case Result of
    61376137      eNoTime_Load:
    61386138        if MyModel[MyUn[UnFocus].mix].Domain = dAir then
     
    61706170            (MyMap[ToLoc] and (fUnit or fOwned) = fUnit or fOwned) then
    61716171          begin // false load attempt
    6172             ToShip := false;
    6173             ToTransport := false;
     6172            ToShip := False;
     6173            ToTransport := False;
    61746174            for uix := 0 to MyRO.nUn - 1 do
    61756175              if (MyUn[uix].Loc = ToLoc) and
    61766176                (MyModel[MyUn[uix].mix].Domain = dSea) then
    61776177              begin
    6178                 ToShip := true;
     6178                ToShip := True;
    61796179                if MyModel[MyUn[uix].mix].Cap[mcSeaTrans] > 0 then
    6180                   ToTransport := true;
     6180                  ToTransport := True;
    61816181              end;
    61826182            if ToTransport then
     
    61936193      Play('NOMOVE_DEFAULT');
    61946194    end;
    6195     exit;
    6196   end;
    6197 
    6198   if ((result = eWon) or (result = eLost) or (result = eBloody)) and
     6195    Exit;
     6196  end;
     6197
     6198  if ((Result = eWon) or (Result = eLost) or (Result = eBloody)) and
    61996199    (MyUn[UnFocus].Movement < 100) and
    62006200    (MyModel[MyUn[UnFocus].mix].Cap[mcWill] = 0) then
     
    62036203      [MyUn[UnFocus].Movement]), 'NOMOVE_TIME') <> mrOK then
    62046204    begin
    6205       result := eInvalid;
    6206       exit;
     6205      Result := eInvalid;
     6206      Exit;
    62076207    end;
    62086208    Update; // remove message box from screen
    62096209  end;
    62106210
    6211   OldUnrest := false;
    6212   NewUnrest := false;
    6213   if (result >= rExecuted) and (result and rUnitRemoved = 0) and
     6211  OldUnrest := False;
     6212  NewUnrest := False;
     6213  if (Result >= rExecuted) and (Result and rUnitRemoved = 0) and
    62146214    (MyMap[ToLoc] and (fUnit or fOwned) <> fUnit) then
    62156215  begin
     
    62216221      begin
    62226222        QueryItem := 'UNREST_NOTOWN';
    6223         p1 := me;
     6223        p1 := Me;
    62246224      end
    62256225      else
     
    62386238        if ModalResult <> mrOK then
    62396239        begin
    6240           result := eInvalid;
    6241           exit;
     6240          Result := eInvalid;
     6241          Exit;
    62426242        end;
    62436243      end;
     
    62466246  end;
    62476247
    6248   if (result >= rExecuted) and (MyModel[MyUn[UnFocus].mix].Domain = dAir) and
     6248  if (Result >= rExecuted) and (MyModel[MyUn[UnFocus].mix].Domain = dAir) and
    62496249    (MyUn[UnFocus].Status and usToldNoReturn = 0) then
    62506250  begin // can plane return?
     
    62666266        PlaneReturnData.Movement := MyUn[UnFocus].Movement - 150;
    62676267    end;
    6268     if Server(sGetPlaneReturn, me, UnFocus, PlaneReturnData) = eNoWay then
     6268    if Server(sGetPlaneReturn, Me, UnFocus, PlaneReturnData) = eNoWay then
    62696269    begin
    62706270      if MyModel[MyUn[UnFocus].mix].Kind = mkSpecial_Glider then
     
    62756275        <> mrOK then
    62766276      begin
    6277         result := eInvalid;
    6278         exit;
     6277        Result := eInvalid;
     6278        Exit;
    62796279      end;
    62806280      Update; // remove message box from screen
     
    62836283  end;
    62846284
    6285   if result = eMissionDone then
     6285  if Result = eMissionDone then
    62866286  begin
    62876287    ModalSelectDlg.ShowNewContent(wmModal, kMission);
    62886288    Update; // dialog still on screen
    6289     Mission := ModalSelectDlg.result;
     6289    Mission := ModalSelectDlg.Result;
    62906290    if Mission < 0 then
    6291       exit;
    6292     Server(sSetSpyMission + Mission shl 4, me, 0, nil^);
    6293   end;
    6294 
    6295   CityCaptured := false;
    6296   if result = eNoTime_Move then
     6291      Exit;
     6292    Server(sSetSpyMission + Mission shl 4, Me, 0, nil^);
     6293  end;
     6294
     6295  CityCaptured := False;
     6296  if Result = eNoTime_Move then
    62976297    Play('NOMOVE_TIME')
    62986298  else
    62996299  begin
    6300     NeedEcoUpdate := false;
    6301     DestinationMarkON := false;
     6300    NeedEcoUpdate := False;
     6301    DestinationMarkON := False;
    63026302    PaintDestination;
    6303     if result and rUnitRemoved <> 0 then
     6303    if Result and rUnitRemoved <> 0 then
    63046304      CityOptimizer_BeforeRemoveUnit(UnFocus);
    6305     IsAttack := (result = eBombarded) or (result <> eMissionDone) and
     6305    IsAttack := (Result = eBombarded) or (Result <> eMissionDone) and
    63066306      (MyMap[ToLoc] and (fUnit or fOwned) = fUnit);
    63076307    if not IsAttack then
     
    63096309      cix := MyRO.nCity - 1; { look for own city at dest location }
    63106310      while (cix >= 0) and (MyCity[cix].Loc <> ToLoc) do
    6311         dec(cix);
    6312       if (result <> eMissionDone) and (MyMap[ToLoc] and fCity <> 0) and (cix < 0)
     6311        Dec(cix);
     6312      if (Result <> eMissionDone) and (MyMap[ToLoc] and fCity <> 0) and (cix < 0)
    63136313      then
    6314         CityCaptured := true;
    6315       result := Server(sMoveUnit + DirCode, me, UnFocus, nil^);
    6316       case result of
     6314        CityCaptured := True;
     6315      Result := Server(sMoveUnit + DirCode, Me, UnFocus, nil^);
     6316      case Result of
    63176317        eHiddenUnit:
    63186318          begin
     
    63326332        rExecuted .. maxint:
    63336333          begin
    6334             if result and rUnitRemoved <> 0 then
     6334            if Result and rUnitRemoved <> 0 then
    63356335              UnFocus := -1 // unit died
    63366336            else
    63376337            begin
    6338               assert(UnFocus >= 0);
     6338              Assert(UnFocus >= 0);
    63396339              MyUn[UnFocus].Status := MyUn[UnFocus].Status and
    63406340                not(usStay or usRecover);
     
    63466346              begin // borders have moved, unrest might have changed in any city
    63476347                CityOptimizer_BeginOfTurn;
    6348                 NeedEcoUpdate := true;
     6348                NeedEcoUpdate := True;
    63496349              end
    63506350              else
     
    63566356                    if MyUn[uix].Master = UnFocus then
    63576357                      CityOptimizer_CityChange(MyUn[uix].Home);
    6358                   NeedEcoUpdate := true;
     6358                  NeedEcoUpdate := True;
    63596359                end;
    63606360                if (MyRO.Government = gDespotism) and
     
    63666366                    while (cixChanged >= 0) and
    63676367                      (MyCity[cixChanged].Loc <> FromLoc) do
    6368                       dec(cixChanged);
    6369                     assert(cixChanged >= 0);
     6368                      Dec(cixChanged);
     6369                    Assert(cixChanged >= 0);
    63706370                    if cixChanged >= 0 then
    63716371                    begin
    63726372                      CityOptimizer_CityChange(cixChanged);
    6373                       NeedEcoUpdate := true;
     6373                      NeedEcoUpdate := True;
    63746374                    end;
    63756375                  end;
     
    63796379                    while (cixChanged >= 0) and
    63806380                      (MyCity[cixChanged].Loc <> ToLoc) do
    6381                       dec(cixChanged);
    6382                     assert(cixChanged >= 0);
     6381                      Dec(cixChanged);
     6382                    Assert(cixChanged >= 0);
    63836383                    if cixChanged >= 0 then
    63846384                    begin
    63856385                      CityOptimizer_CityChange(cixChanged);
    6386                       NeedEcoUpdate := true;
     6386                      NeedEcoUpdate := True;
    63876387                    end;
    63886388                  end;
     
    63926392          end;
    63936393      else
    6394         assert(false);
     6394        Assert(False);
    63956395      end;
    63966396      SetTroopLoc(ToLoc);
     
    63986398    else
    63996399    begin { enemy unit -- attack }
    6400       if result = eBombarded then
     6400      if Result = eBombarded then
    64016401        Defender := MyRO.Territory[ToLoc]
    64026402      else
     
    64056405        if SimpleQuery(mkYesNo,Phrases.Lookup('FRCANCELQUERY_CEASEFIRE'),
    64066406        'MSG_DEFAULT')<>mrOK then
    6407         exit; }
    6408       if (Options and muNoSuicideCheck = 0) and (result and rUnitRemoved <> 0)
    6409         and (result <> eMissionDone) then
     6407        Exit; }
     6408      if (Options and muNoSuicideCheck = 0) and (Result and rUnitRemoved <> 0)
     6409        and (Result <> eMissionDone) then
    64106410      begin // suicide query
    64116411        with MyUn[UnFocus], BattleDlg.Forecast do
    64126412        begin
    6413           pAtt := me;
     6413          pAtt := Me;
    64146414          mixAtt := mix;
    64156415          HealthAtt := Health;
     
    64186418        end;
    64196419        BattleDlg.Forecast.Movement := MyUn[UnFocus].Movement;
    6420         Server(sGetBattleForecastEx, me, ToLoc, BattleDlg.Forecast);
     6420        Server(sGetBattleForecastEx, Me, ToLoc, BattleDlg.Forecast);
    64216421        BattleDlg.uix := UnFocus;
    64226422        BattleDlg.ToLoc := ToLoc;
    6423         BattleDlg.IsSuicideQuery := true;
     6423        BattleDlg.IsSuicideQuery := True;
    64246424        BattleDlg.ShowModal;
    64256425        if BattleDlg.ModalResult <> mrOK then
    6426           exit;
     6426          Exit;
    64276427      end;
    64286428
    64296429      cixChanged := -1;
    6430       if (result and rUnitRemoved <> 0) and (MyRO.Government = gDespotism) and
     6430      if (Result and rUnitRemoved <> 0) and (MyRO.Government = gDespotism) and
    64316431        (MyModel[MyUn[UnFocus].mix].Kind = mkSpecial_TownGuard) and
    64326432        (MyMap[FromLoc] and fCity <> 0) then
     
    64346434        cixChanged := MyRO.nCity - 1;
    64356435        while (cixChanged >= 0) and (MyCity[cixChanged].Loc <> FromLoc) do
    6436           dec(cixChanged);
    6437         assert(cixChanged >= 0);
    6438       end;
    6439 
    6440       for i := 0 to MyRO.nEnemyModel - 1 do
    6441         LostArmy[i] := MyRO.EnemyModel[i].Lost;
     6436          Dec(cixChanged);
     6437        Assert(cixChanged >= 0);
     6438      end;
     6439
     6440      for I := 0 to MyRO.nEnemyModel - 1 do
     6441        LostArmy[I] := MyRO.EnemyModel[I].Lost;
    64426442      OldToTile := MyMap[ToLoc];
    6443       result := Server(sMoveUnit + DirCode, me, UnFocus, nil^);
     6443      Result := Server(sMoveUnit + DirCode, Me, UnFocus, nil^);
    64446444      nLostArmy := 0;
    6445       for i := 0 to MyRO.nEnemyModel - 1 do
    6446       begin
    6447         LostArmy[i] := MyRO.EnemyModel[i].Lost - LostArmy[i];
    6448         inc(nLostArmy, LostArmy[i]);
    6449       end;
    6450       if result and rUnitRemoved <> 0 then
     6445      for I := 0 to MyRO.nEnemyModel - 1 do
     6446      begin
     6447        LostArmy[I] := MyRO.EnemyModel[I].Lost - LostArmy[I];
     6448        Inc(nLostArmy, LostArmy[I]);
     6449      end;
     6450      if Result and rUnitRemoved <> 0 then
    64516451      begin
    64526452        UnFocus := -1;
     
    64576457      begin // city was destroyed, borders have moved, unrest might have changed in any city
    64586458        CityOptimizer_BeginOfTurn;
    6459         NeedEcoUpdate := true;
     6459        NeedEcoUpdate := True;
    64606460      end
    64616461      else
     
    64646464        begin
    64656465          CityOptimizer_CityChange(cixChanged);
    6466           NeedEcoUpdate := true;
     6466          NeedEcoUpdate := True;
    64676467        end;
    6468         if (result = eWon) or (result = eBloody) or (result = eExpelled) then
     6468        if (Result = eWon) or (Result = eBloody) or (Result = eExpelled) then
    64696469        begin
    64706470          CityOptimizer_TileBecomesAvailable(ToLoc);
    6471           NeedEcoUpdate := true;
     6471          NeedEcoUpdate := True;
    64726472        end;
    64736473      end;
     
    64846484      end;
    64856485    end;
    6486     if result and rUnitRemoved <> 0 then
     6486    if Result and rUnitRemoved <> 0 then
    64876487    begin
    64886488      CityOptimizer_AfterRemoveUnit;
    64896489      ListDlg.RemoveUnit;
    6490       NeedEcoUpdate := true;
     6490      NeedEcoUpdate := True;
    64916491    end;
    64926492    if NeedEcoUpdate then
    64936493    begin
    6494       UpdateViews(true);
     6494      UpdateViews(True);
    64956495      Update;
    64966496    end;
    64976497  end;
    64986498
    6499   if result = eMissionDone then
     6499  if Result = eMissionDone then
    65006500  begin
    65016501    p1 := MyRO.Territory[ToLoc];
     
    65036503      smStealMap:
    65046504        begin
    6505           MapValid := false;
     6505          MapValid := False;
    65066506          PaintAllMaps
    65076507        end;
     
    65166516    CheckToldNoReturn(UnFocus);
    65176517
    6518   NeedRepaintPanel := false;
    6519   if result >= rExecuted then
     6518  NeedRepaintPanel := False;
     6519  if Result >= rExecuted then
    65206520  begin
    65216521    if CityCaptured and (MyMap[ToLoc] and fCity = 0) then
    65226522    begin // city destroyed
    6523       for i := 0 to nWonder - 1 do { tell about destroyed wonders }
    6524         if (MyRO.Wonder[i].CityID = WonderDestroyed) and (MyData.ToldWonders[i].CityID <> WonderDestroyed)
     6523      for I := 0 to nWonder - 1 do { tell about destroyed wonders }
     6524        if (MyRO.Wonder[I].CityID = WonderDestroyed) and (MyData.ToldWonders[I].CityID <> WonderDestroyed)
    65256525        then
    65266526          with MessgExDlg do
    65276527          begin
    65286528            if WondersDlg.Visible then
    6529               WondersDlg.SmartUpdateContent(false);
     6529              WondersDlg.SmartUpdateContent(False);
    65306530            OpenSound := 'WONDER_DESTROYED';
    65316531            MessgText := Format(Phrases.Lookup('WONDERDEST'),
    6532               [Phrases.Lookup('IMPROVEMENTS', i)]);
     6532              [Phrases.Lookup('IMPROVEMENTS', I)]);
    65336533            Kind := mkOkHelp;
    65346534            HelpKind := hkImp;
    6535             HelpNo := i;
     6535            HelpNo := I;
    65366536            IconKind := mikImp;
    6537             IconIndex := i;
     6537            IconIndex := I;
    65386538            ShowModal;
    6539             MyData.ToldWonders[i] := MyRO.Wonder[i];
     6539            MyData.ToldWonders[I] := MyRO.Wonder[I];
    65406540          end;
    65416541    end;
     
    65436543    begin // city captured
    65446544      ListDlg.AddCity;
    6545       for i := 0 to nWonder - 1 do { tell about capture of wonders }
    6546         if MyRO.City[MyRO.nCity - 1].Built[i] > 0 then
     6545      for I := 0 to nWonder - 1 do { tell about capture of wonders }
     6546        if MyRO.City[MyRO.nCity - 1].Built[I] > 0 then
    65476547          with MessgExDlg do
    65486548          begin
    65496549            if WondersDlg.Visible then
    6550               WondersDlg.SmartUpdateContent(false);
     6550              WondersDlg.SmartUpdateContent(False);
    65516551            OpenSound := 'WONDER_CAPTURED';
    6552             MessgText := Format(Tribe[me].TPhrase('WONDERCAPTOWN'),
    6553               [Phrases.Lookup('IMPROVEMENTS', i)]);
     6552            MessgText := Format(Tribe[Me].TPhrase('WONDERCAPTOWN'),
     6553              [Phrases.Lookup('IMPROVEMENTS', I)]);
    65546554            Kind := mkOkHelp;
    65556555            HelpKind := hkImp;
    6556             HelpNo := i;
     6556            HelpNo := I;
    65576557            IconKind := mikImp;
    6558             IconIndex := i;
     6558            IconIndex := I;
    65596559            ShowModal;
    6560             MyData.ToldWonders[i] := MyRO.Wonder[i];
     6560            MyData.ToldWonders[I] := MyRO.Wonder[I];
    65616561          end;
    65626562
     
    65646564      begin { Temple of Zeus -- choose advance to steal }
    65656565        ModalSelectDlg.ShowNewContent(wmModal, kStealTech);
    6566         Server(sStealTech, me, ModalSelectDlg.result, nil^);
     6566        Server(sStealTech, Me, ModalSelectDlg.Result, nil^);
    65676567      end;
    65686568      TellNewModels;
     
    65706570      cix := MyRO.nCity - 1;
    65716571      while (cix >= 0) and (MyCity[cix].Loc <> ToLoc) do
    6572         dec(cix);
    6573       assert(cix >= 0);
     6572        Dec(cix);
     6573      Assert(cix >= 0);
    65746574      MyCity[cix].Status := MyCity[cix].Status and not csResourceWeightsMask or
    65756575        (3 shl 4);
    65766576      // captured city, set to maximum growth
    65776577      NewTiles := 1 shl 13; { exploit central tile only }
    6578       Server(sSetCityTiles, me, cix, NewTiles);
     6578      Server(sSetCityTiles, Me, cix, NewTiles);
    65796579    end
    65806580    else
    6581       NeedRepaintPanel := true;
     6581      NeedRepaintPanel := True;
    65826582  end;
    65836583  TellNewContacts;
     
    65936593  if Options and (muAutoNoWait or muAutoNext) <> 0 then
    65946594  begin
    6595     if (UnFocus >= 0) and ((result = eNoTime_Move) or UnitExhausted(UnFocus) or
     6595    if (UnFocus >= 0) and ((Result = eNoTime_Move) or UnitExhausted(UnFocus) or
    65966596      (MyUn[UnFocus].Master >= 0) or (MyModel[MyUn[UnFocus].mix].Domain = dAir)
    65976597      and ((MyMap[MyUn[UnFocus].Loc] and fCity <> 0)
     
    66076607        end
    66086608        else
    6609           NextUnit(UnStartLoc, true);
     6609          NextUnit(UnStartLoc, True);
    66106610    end
    66116611    else if (UnFocus < 0) and (Options and muAutoNext <> 0) then
    6612       NextUnit(UnStartLoc, result <> eMissionDone);
     6612      NextUnit(UnStartLoc, Result <> eMissionDone);
    66136613  end;
    66146614
     
    66186618    else
    66196619    begin
    6620       assert(result <> eMissionDone);
     6620      Assert(Result <> eMissionDone);
    66216621      CheckTerrainBtnVisible;
    66226622      FocusOnLoc(ToLoc, flRepaintPanel or flImmUpdate);
    66236623    end;
    66246624
    6625   if (result >= rExecuted) and CityCaptured and (MyMap[ToLoc] and fCity <> 0)
     6625  if (Result >= rExecuted) and CityCaptured and (MyMap[ToLoc] and fCity <> 0)
    66266626  then
    66276627    ZoomToCity(ToLoc, UnFocus < 0, chCaptured); // show captured city
     
    66296629
    66306630procedure TMainScreen.MoveOnScreen(ShowMove: TShowMove;
    6631   Step0, Step1, nStep: integer; Restore: boolean = true);
     6631  Step0, Step1, nStep: Integer; Restore: Boolean = True);
    66326632var
    66336633  ToLoc, xFromLoc, yFromLoc, xToLoc, yToLoc, xFrom, yFrom, xTo, yTo, xMin, yMin,
    6634     xRange, yRange, xw1, Step, xMoving, yMoving, SliceCount: integer;
     6634    xRange, yRange, xw1, Step, xMoving, yMoving, SliceCount: Integer;
    66356635  UnitInfo: TUnitInfo;
    66366636  Ticks0, Ticks: TDateTime;
    66376637begin
    6638   Timer1.Enabled := false;
     6638  Timer1.Enabled := False;
    66396639  Ticks0 := NowPrecise;
    66406640  with ShowMove do
     
    66456645    UnitInfo.Job := jNone;
    66466646    UnitInfo.Flags := Flags;
    6647     if Owner <> me then
     6647    if Owner <> Me then
    66486648      UnitInfo.emix := emix;
    66496649
     
    66646664        * xxt - MapWidth) < abs(((xFromLoc - xw1) * 2 + yFromLoc and 1 + 1) * xxt
    66656665        * 2 + dx * xxt - MapWidth) do
    6666         dec(xw1, G.lx);
     6666        Dec(xw1, G.lx);
    66676667
    66686668      xTo := (xToLoc - xw1) * (xxt * 2) + yToLoc and 1 * xxt + (xxt - xxu);
     
    66846684        yRange := yFrom - yTo;
    66856685      end;
    6686       inc(xRange, xxt * 2);
    6687       inc(yRange, yyt * 3);
     6686      Inc(xRange, xxt * 2);
     6687      Inc(yRange, yyt * 3);
    66886688    end;
    66896689
     
    66946694    begin
    66956695      BitBltCanvas(Buffer.Canvas, 0, 0, xRange, yRange,
    6696         offscreen.Canvas, xMin, yMin);
     6696        Offscreen.Canvas, xMin, yMin);
    66976697      if Step1 <> Step0 then
    66986698      begin
     
    67236723          < MoveTime) then
    67246724        begin
    6725           if not idle or (GameMode = cMovie) then
     6725          if not Idle or (GameMode = cMovie) then
    67266726            Application.ProcessMessages;
    67276727          Sleep(1);
    6728           inc(SliceCount)
     6728          Inc(SliceCount)
    67296729        end;
    67306730        Ticks := NowPrecise;
     
    67356735  if Restore then
    67366736  begin
    6737     BitBltCanvas(Buffer.Canvas, 0, 0, xRange, yRange, offscreen.Canvas, xMin, yMin);
     6737    BitBltCanvas(Buffer.Canvas, 0, 0, xRange, yRange, Offscreen.Canvas, xMin, yMin);
    67386738    PaintBufferToScreen(xMin, yMin, xRange, yRange);
    67396739  end;
    67406740  BlinkTime := -1;
    6741   Timer1.Enabled := true;
    6742 end;
    6743 
    6744 procedure TMainScreen.MoveToLoc(Loc: integer; CheckSuicide: boolean);
     6741  Timer1.Enabled := True;
     6742end;
     6743
     6744procedure TMainScreen.MoveToLoc(Loc: Integer; CheckSuicide: Boolean);
    67456745// path finder: move focused unit to loc, start multi-turn goto if too far
    67466746var
    6747   uix, i, MoveOptions, NextLoc, MoveResult: integer;
     6747  uix, I, MoveOptions, NextLoc, MoveResult: Integer;
    67486748  MoveAdviceData: TMoveAdviceData;
    67496749  StopReason: (None, Arrived, Dead, NoTime, EnemySpotted, MoveError);
    67506750begin
    67516751  if MyUn[UnFocus].Job > jNone then
    6752     Server(sStartJob + jNone shl 4, me, UnFocus, nil^);
     6752    Server(sStartJob + jNone shl 4, Me, UnFocus, nil^);
    67536753  if GetMoveAdvice(UnFocus, Loc, MoveAdviceData) >= rExecuted then
    67546754  begin
     
    67566756    StopReason := None;
    67576757    repeat
    6758       for i := 0 to MoveAdviceData.nStep - 1 do
    6759       begin
    6760         if i = MoveAdviceData.nStep - 1 then
     6758      for I := 0 to MoveAdviceData.nStep - 1 do
     6759      begin
     6760        if I = MoveAdviceData.nStep - 1 then
    67616761          MoveOptions := muAutoNext
    67626762        else
    67636763          MoveOptions := 0;
    6764         NextLoc := dLoc(MyUn[uix].Loc, MoveAdviceData.dx[i],
    6765           MoveAdviceData.dy[i]);
     6764        NextLoc := dLoc(MyUn[uix].Loc, MoveAdviceData.dx[I],
     6765          MoveAdviceData.dy[I]);
    67666766        if (NextLoc = Loc) or (Loc = maNextCity) and
    67676767          (MyMap[NextLoc] and fCity <> 0) then
     
    67696769        if not CheckSuicide and (NextLoc = Loc) then
    67706770          MoveOptions := MoveOptions or muNoSuicideCheck;
    6771         MoveResult := MoveUnit(MoveAdviceData.dx[i], MoveAdviceData.dy[i],
     6771        MoveResult := MoveUnit(MoveAdviceData.dx[I], MoveAdviceData.dy[I],
    67726772          MoveOptions);
    67736773        if MoveResult < rExecuted then
     
    67816781      end;
    67826782      if (StopReason = None) and ((MoveAdviceData.nStep < 25) or
    6783         (MyRO.Wonder[woShinkansen].EffectiveOwner <> me)) then
     6783        (MyRO.Wonder[woShinkansen].EffectiveOwner <> Me)) then
    67846784        StopReason := NoTime;
    67856785      if StopReason <> None then
     
    67876787      if GetMoveAdvice(UnFocus, Loc, MoveAdviceData) < rExecuted then
    67886788      begin
    6789         assert(false);
     6789        Assert(False);
    67906790        Break;
    67916791      end;
    6792     until false;
     6792    until False;
    67936793
    67946794    case StopReason of
    67956795      None:
    6796         assert(false);
     6796        Assert(False);
    67976797      Arrived:
    67986798        MyUn[uix].Status := MyUn[uix].Status and ($FFFF - usGoto);
    67996799      Dead:
    68006800        if UnFocus < 0 then
    6801           NextUnit(UnStartLoc, false);
     6801          NextUnit(UnStartLoc, False);
    68026802    else
    68036803      begin // multi-turn goto
     
    68126812        begin
    68136813          MyUn[uix].Status := MyUn[uix].Status and not usWaiting;
    6814           NextUnit(UnStartLoc, true);
     6814          NextUnit(UnStartLoc, True);
    68156815        end;
    68166816      end;
     
    68206820
    68216821procedure TMainScreen.PanelBoxMouseDown(Sender: TObject; Button: TMouseButton;
    6822   Shift: TShiftState; x, y: integer);
     6822  Shift: TShiftState; X, Y: Integer);
    68236823var
    6824   i, xMouse, MouseLoc, p1: integer;
     6824  I, xMouse, MouseLoc, p1: Integer;
    68256825begin
    68266826  if GameMode = cMovie then
    6827     exit;
     6827    Exit;
    68286828
    68296829  if Button = mbLeft then
    68306830  begin
    6831     if (x >= xMini + 2) and (y >= yMini + 2) and (x < xMini + 2 + 2 * G.lx) and
    6832       (y < yMini + 2 + G.ly) then
     6831    if (X >= xMini + 2) and (Y >= yMini + 2) and (X < xMini + 2 + 2 * G.lx) and
     6832      (Y < yMini + 2 + G.ly) then
    68336833      if ssShift in Shift then
    68346834      begin
    68356835        with MainMap do
    6836           xMouse := (xwMini + (x - (xMini + 2) + MapWidth div (xxt * 2) + G.lx)
     6836          xMouse := (xwMini + (X - (xMini + 2) + MapWidth div (xxt * 2) + G.lx)
    68376837            div 2) mod G.lx;
    6838         MouseLoc := xMouse + G.lx * (y - (yMini + 2));
     6838        MouseLoc := xMouse + G.lx * (Y - (yMini + 2));
    68396839        if MyMap[MouseLoc] and fTerrain <> fUNKNOWN then
    68406840        begin
    68416841          p1 := MyRO.Territory[MouseLoc];
    6842           if (p1 = me) or (p1 >= 0) and (MyRO.Treaty[p1] >= trNone) then
     6842          if (p1 = Me) or (p1 >= 0) and (MyRO.Treaty[p1] >= trNone) then
    68436843            NatStatDlg.ShowNewContent(wmPersistent, p1);
    68446844        end;
     
    68506850        if UnitStatDlg.Visible then
    68516851          UnitStatDlg.Close;
    6852         Tracking := true;
    6853         PanelBoxMouseMove(Sender, Shift + [ssLeft], x, y);
     6852        Tracking := True;
     6853        PanelBoxMouseMove(Sender, Shift + [ssLeft], X, Y);
    68546854      end
    6855     else if (ClientMode <> cEditMap) and (x >= ClientWidth - xPalace) and
    6856       (y >= yPalace) and (x < ClientWidth - xPalace + xSizeBig) and
    6857       (y < yPalace + ySizeBig) then
     6855    else if (ClientMode <> cEditMap) and (X >= ClientWidth - xPalace) and
     6856      (Y >= yPalace) and (X < ClientWidth - xPalace + xSizeBig) and
     6857      (Y < yPalace + ySizeBig) then
    68586858    begin
    68596859      InitPopup(StatPopup);
     
    68666866          GetSystemMetrics(SM_CYCAPTION) + 3)
    68676867    end
    6868     (* else if (x>=xAdvisor-3) and (y>=yAdvisor-3)
    6869       and (x<xAdvisor+16+3) and (y<yAdvisor+16+3) and HaveStrategyAdvice then
     6868    (* else if (X>=xAdvisor-3) and (Y>=yAdvisor-3)
     6869      and (X<xAdvisor+16+3) and (Y<yAdvisor+16+3) and HaveStrategyAdvice then
    68706870      AdviceBtnClick *)
    6871     else if (x >= xTroop + 1) and (y >= yTroop + 1) and
    6872       (x < xTroop + TrRow * TrPitch) and (y <= yTroop + 55) then
    6873     begin
    6874       i := (x - xTroop - 1) div TrPitch;
    6875       if trix[i] >= 0 then
     6871    else if (X >= xTroop + 1) and (Y >= yTroop + 1) and
     6872      (X < xTroop + TrRow * TrPitch) and (Y <= yTroop + 55) then
     6873    begin
     6874      I := (X - xTroop - 1) div TrPitch;
     6875      if trix[I] >= 0 then
    68766876        if ClientMode = cEditMap then
    68776877        begin
    6878           BrushType := trix[i];
     6878          BrushType := trix[I];
    68796879          PanelPaint
    68806880        end
     
    68846884            if ssShift in Shift then
    68856885              UnitStatDlg.ShowNewContent_OwnModel(wmPersistent,
    6886                 MyUn[trix[i]].mix)
    6887             else if not supervising and (ClientMode < scContact) and
    6888               (x - xTroop - 1 - i * TrPitch >= 60 - 20) and (y >= yTroop + 35)
    6889               and ((MyUn[trix[i]].Job > jNone) or (MyUn[trix[i]].Status and
     6886                MyUn[trix[I]].mix)
     6887            else if not Supervising and (ClientMode < scContact) and
     6888              (X - xTroop - 1 - I * TrPitch >= 60 - 20) and (Y >= yTroop + 35)
     6889              and ((MyUn[trix[I]].Job > jNone) or (MyUn[trix[I]].Status and
    68906890              (usStay or usRecover or usGoto) <> 0)) then
    68916891            begin // wake up
    6892               MyUn[trix[i]].Status := MyUn[trix[i]].Status and
     6892              MyUn[trix[I]].Status := MyUn[trix[I]].Status and
    68936893                ($FFFF - usStay - usRecover - usGoto - usEnhance) or usWaiting;
    6894               if MyUn[trix[i]].Job > jNone then
    6895                 Server(sStartJob + jNone shl 4, me, trix[i], nil^);
     6894              if MyUn[trix[I]].Job > jNone then
     6895                Server(sStartJob + jNone shl 4, Me, trix[I], nil^);
    68966896              if (UnFocus < 0) and not CityDlg.Visible then
    68976897              begin
    6898                 SetUnFocus(trix[i]);
    6899                 SetTroopLoc(MyUn[trix[i]].Loc);
     6898                SetUnFocus(trix[I]);
     6899                SetTroopLoc(MyUn[trix[I]].Loc);
    69006900                FocusOnLoc(TroopLoc, flRepaintPanel)
    69016901              end
     
    69036903              begin
    69046904                if CityDlg.Visible and (CityDlg.RestoreUnFocus < 0) then
    6905                   CityDlg.RestoreUnFocus := trix[i];
     6905                  CityDlg.RestoreUnFocus := trix[I];
    69066906                PanelPaint;
    69076907              end
     
    69096909            else if (ClientMode < scContact) then
    69106910            begin
    6911               if supervising then
    6912                 UnitStatDlg.ShowNewContent_OwnUnit(wmPersistent, trix[i])
     6911              if Supervising then
     6912                UnitStatDlg.ShowNewContent_OwnUnit(wmPersistent, trix[I])
    69136913              else if CityDlg.Visible then
    69146914              begin
     
    69166916                CityDlg.Close;
    69176917                SumCities(TaxSum, ScienceSum);
    6918                 SetUnFocus(trix[i]);
     6918                SetUnFocus(trix[I]);
    69196919              end
    69206920              else
    69216921              begin
    6922                 DestinationMarkON := false;
     6922                DestinationMarkON := False;
    69236923                PaintDestination;
    6924                 UnFocus := trix[i];
     6924                UnFocus := trix[I];
    69256925                UnStartLoc := TroopLoc;
    69266926                BlinkTime := 0;
    6927                 BlinkON := false;
     6927                BlinkON := False;
    69286928                PaintLoc(TroopLoc);
    69296929              end;
    69306930              if UnFocus >= 0 then
    69316931              begin
    6932                 UnitInfoBtn.Visible := true;
    6933                 UnitBtn.Visible := true;
    6934                 TurnComplete := false;
     6932                UnitInfoBtn.Visible := True;
     6933                UnitBtn.Visible := True;
     6934                TurnComplete := False;
    69356935                EOT.ButtonIndex := eotGray;
    69366936              end;
     
    69396939            end;
    69406940          end
    6941           else if Server(sGetUnits, me, TroopLoc, TrCnt) >= rExecuted then
     6941          else if Server(sGetUnits, Me, TroopLoc, TrCnt) >= rExecuted then
    69426942            if ssShift in Shift then
    69436943              UnitStatDlg.ShowNewContent_EnemyModel(wmPersistent,
    6944                 MyRO.EnemyUn[MyRO.nEnemyUn + trix[i]].emix) // model info
     6944                MyRO.EnemyUn[MyRO.nEnemyUn + trix[I]].emix) // model info
    69456945            else
    69466946              UnitStatDlg.ShowNewContent_EnemyUnit(wmPersistent,
    6947                 MyRO.nEnemyUn + trix[i]); // unit info
    6948     end;
    6949   end;
    6950 end;
    6951 
    6952 procedure TMainScreen.SetTroopLoc(Loc: integer);
     6947                MyRO.nEnemyUn + trix[I]); // unit info
     6948    end;
     6949  end;
     6950end;
     6951
     6952procedure TMainScreen.SetTroopLoc(Loc: Integer);
    69536953var
    6954   trixFocus, uix, uixDefender: integer;
    6955   Prio: boolean;
     6954  trixFocus, uix, uixDefender: Integer;
     6955  Prio: Boolean;
    69566956begin
    69576957  TroopLoc := Loc;
     
    69656965    if MyMap[Loc] and fOwned <> 0 then
    69666966    begin // count own units here
    6967       Server(sGetDefender, me, TroopLoc, uixDefender);
    6968       for Prio := true downto false do
     6967      Server(sGetDefender, Me, TroopLoc, uixDefender);
     6968      for Prio := True downto False do
    69696969        for uix := 0 to MyRO.nUn - 1 do
    69706970          if ((uix = uixDefender) = Prio) and (MyUn[uix].Loc = Loc) then
     
    69726972            if uix = UnFocus then
    69736973              trixFocus := TrCnt;
    6974             inc(TrCnt);
     6974            Inc(TrCnt);
    69756975          end;
    69766976    end
    69776977    else // count enemy units here
    6978       Server(sGetUnits, me, Loc, TrCnt);
     6978      Server(sGetUnits, Me, Loc, TrCnt);
    69796979  if TrCnt = 0 then
    69806980    sb.Init(0, 1)
     
    69876987end;
    69886988
    6989 (* procedure TMainScreen.ShowMoveHint(ToLoc: integer; Force: boolean = false);
     6989(* procedure TMainScreen.ShowMoveHint(ToLoc: Integer; Force: Boolean = False);
    69906990  var
    6991   Step,Loc,x0,y0,xs,ys: integer;
     6991  Step,Loc,x0,y0,xs,ys: Integer;
    69926992  Info: string;
    69936993  InfoSize: TSize;
     
    70027002  MoveAdvice.MoreTurns:=0;
    70037003  MoveAdvice.MaxHostile_MovementLeft:=MyUn[UnFocus].Health-50;
    7004   if Server(sGetMoveAdvice,me,UnFocus,MoveAdvice)<rExecuted then
     7004  if Server(sGetMoveAdvice,Me,UnFocus,MoveAdvice)<rExecuted then
    70057005  ToLoc:=-1
    70067006  end;
    7007   if (ToLoc=MoveHintToLoc) and not Force then exit;
     7007  if (ToLoc=MoveHintToLoc) and not Force then Exit;
    70087008  if (ToLoc<>MoveHintToLoc) and (MoveHintToLoc>=0) then
    70097009  begin invalidate; update end; // clear old hint from screen
    70107010  MoveHintToLoc:=ToLoc;
    7011   if ToLoc<0 then exit;
    7012 
    7013   with canvas do
     7011  if ToLoc<0 then Exit;
     7012
     7013  with Canvas do
    70147014  begin
    70157015  Pen.Color:=$80C0FF;
     
    70227022  xs:=(x0-xw)*66+y0 and 1*33-G.lx*66;
    70237023  while abs(2*(xs+G.lx*66)-MapWidth)<abs(2*xs-MapWidth) do
    7024   inc(xs,G.lx*66);
     7024  Inc(xs,G.lx*66);
    70257025  ys:=(y0-yw)*16;
    70267026  if Step=0 then moveto(xs+33,ys+16)
     
    70307030  end;
    70317031  Brush.Color:=$80C0FF;
    7032   Info:=' '+inttostr(88)+' ';
     7032  Info:=' '+IntToStr(88)+' ';
    70337033  InfoSize:=TextExtent(Info);
    70347034  TextOut(xs+33-InfoSize.cx div 2, ys+16-InfoSize.cy div 2, Info);
     
    70377037  end; *)
    70387038
    7039 procedure TMainScreen.SetDebugMap(p: integer);
    7040 begin
    7041   MainMap.pDebugMap := p;
     7039procedure TMainScreen.SetDebugMap(P: Integer);
     7040begin
     7041  MainMap.pDebugMap := P;
    70427042  MapOptions := MapOptions - [moLocCodes];
    7043   mLocCodes.Checked := false;
    7044   MapValid := false;
     7043  mLocCodes.Checked := False;
     7044  MapValid := False;
    70457045  MainOffscreenPaint;
    70467046end;
    70477047
    7048 procedure TMainScreen.SetViewpoint(p: integer);
     7048procedure TMainScreen.SetViewpoint(P: Integer);
    70497049var
    7050   i: Integer;
    7051 begin
    7052   if supervising and (G.RO[0].Turn > 0) and
    7053     ((p = 0) or (1 shl p and G.RO[0].Alive <> 0)) then
     7050  I: Integer;
     7051begin
     7052  if Supervising and (G.RO[0].Turn > 0) and
     7053    ((P = 0) or (1 shl P and G.RO[0].Alive <> 0)) then
    70547054  begin
    70557055    ApplyToVisibleForms(faClose);
    7056     ItsMeAgain(p);
     7056    ItsMeAgain(P);
    70577057    SumCities(TaxSum, ScienceSum);
    7058     for i := 0 to MyRO.nModel - 1 do
    7059       if not Assigned(Tribe[me].ModelPicture[i].HGr) then
    7060         InitMyModel(i, True);
     7058    for I := 0 to MyRO.nModel - 1 do
     7059      if not Assigned(Tribe[Me].ModelPicture[I].HGr) then
     7060        InitMyModel(I, True);
    70617061
    70627062    SetTroopLoc(-1);
     
    71467146end;
    71477147
    7148 procedure TMainScreen.FormKeyDown(Sender: TObject; var Key: word;
     7148procedure TMainScreen.FormKeyDown(Sender: TObject; var Key: Word;
    71497149  Shift: TShiftState);
    71507150
     
    71567156  end;
    71577157
    7158   procedure SetViewpointMe(p: Integer);
    7159   begin
    7160     if p = me then SetViewpoint(p)
    7161       else SetViewpoint(p);
     7158  procedure SetViewpointMe(P: Integer);
     7159  begin
     7160    if P = Me then SetViewpoint(P)
     7161      else SetViewpoint(P);
    71627162  end;
    71637163
     
    71957195         'A':
    71967196          begin // auto symmetry
    7197           Server($7F0,me,0,nil^);
    7198           MapValid:=false;
     7197          Server($7F0,Me,0,nil^);
     7198          MapValid:=False;
    71997199          PaintAll;
    72007200          end;
     
    72037203          dy:=0;
    72047204          for dx:=G.lx to G.lx*(G.ly-1)-1 do
    7205           if MyMap[dx] and fTerrain>=fGrass then inc(dy);
     7205          if MyMap[dx] and fTerrain>=fGrass then Inc(dy);
    72067206          dy:=dy
    72077207          end;
     
    73307330function TMainScreen.DoJob(j0: Integer): Integer;
    73317331var
    7332   Loc0, Movement0: integer;
     7332  Loc0, Movement0: Integer;
    73337333begin
    73347334  with MyUn[UnFocus] do
    73357335  begin
    7336     DestinationMarkON := false;
     7336    DestinationMarkON := False;
    73377337    PaintDestination;
    73387338    Loc0 := Loc;
    73397339    Movement0 := Movement;
    73407340    if j0 < 0 then
    7341       result := ProcessEnhancement(UnFocus, MyData.EnhancementJobs)
     7341      Result := ProcessEnhancement(UnFocus, MyData.EnhancementJobs)
    73427342      // terrain enhancement
    73437343    else
    7344       result := Server(sStartJob + j0 shl 4, me, UnFocus, nil^);
    7345     if result >= rExecuted then
    7346     begin
    7347       if result = eDied then
     7344      Result := Server(sStartJob + j0 shl 4, Me, UnFocus, nil^);
     7345    if Result >= rExecuted then
     7346    begin
     7347      if Result = eDied then
    73487348        UnFocus := -1;
    73497349      PaintLoc(Loc0);
    73507350      if UnFocus >= 0 then
    73517351      begin
    7352         if (j0 < 0) and (result <> eJobDone) then
     7352        if (j0 < 0) and (Result <> eJobDone) then
    73537353          // multi-turn terrain enhancement
    73547354          Status := Status and ($FFFF - usStay - usRecover - usGoto) or
     
    73607360        begin
    73617361          Status := Status and not usWaiting;
    7362           NextUnit(UnStartLoc, true);
     7362          NextUnit(UnStartLoc, True);
    73637363        end
    73647364        else
     
    73667366      end
    73677367      else
    7368         NextUnit(UnStartLoc, true);
    7369     end;
    7370   end;
    7371   case result of
     7368        NextUnit(UnStartLoc, True);
     7369    end;
     7370  end;
     7371  case Result of
    73727372    eNoBridgeBuilding:
    73737373      SoundMessage(Phrases.Lookup('NOBB'), 'INVALID');
     
    73787378        'NOMOVE_TREATY');
    73797379  else
    7380     if result < rExecuted then
     7380    if Result < rExecuted then
    73817381      Play('INVALID');
    73827382  end;
     
    73907390  with TUn(MyUn[UnFocus]) do begin
    73917391    if (Sender = mUtilize) and
    7392       not(Server(sRemoveUnit - sExecute, me, UnFocus, nil^) = eUtilized) then
     7392      not(Server(sRemoveUnit - sExecute, Me, UnFocus, nil^) = eUtilized) then
    73937393    begin
    73947394      SimpleMessage(Phrases2.Lookup('SHIP_UTILIZE'));
    73957395      // freight for colony ship is the only case in which the command is
    73967396      // available to player though not valid
    7397       exit;
     7397      Exit;
    73987398    end;
    73997399    if (Sender = mUtilize) and (Health < 100) then
    74007400      if SimpleQuery(mkYesNo, Phrases.Lookup('DAMAGED_UTILIZE'), '') <> mrOK
    74017401      then
    7402         exit;
     7402        Exit;
    74037403    Loc0 := Loc;
    74047404    CityOptimizer_BeforeRemoveUnit(UnFocus);
    7405     if Server(sRemoveUnit, me, UnFocus, nil^) = eUtilized then
     7405    if Server(sRemoveUnit, Me, UnFocus, nil^) = eUtilized then
    74067406      Play('CITY_UTILIZE')
    74077407    else
     
    74097409    CityOptimizer_AfterRemoveUnit;
    74107410    SetTroopLoc(Loc0);
    7411     UpdateViews(true);
    7412     DestinationMarkON := false;
     7411    UpdateViews(True);
     7412    DestinationMarkON := False;
    74137413    PaintDestination;
    74147414    UnFocus := -1;
    74157415    PaintLoc(Loc0);
    7416     NextUnit(UnStartLoc, true);
     7416    NextUnit(UnStartLoc, True);
    74177417  end;
    74187418end;
     
    74207420procedure TMainScreen.InitPopup(Popup: TPopupMenu);
    74217421var
    7422   i, p1, Tile, Test: integer;
    7423   NoSuper, extended, Multi, NeedSep, HaveCities: boolean;
    7424   LastSep, m: TMenuItem;
     7422  I, p1, Tile, Test: Integer;
     7423  NoSuper, Extended, Multi, NeedSep, HaveCities: Boolean;
     7424  LastSep, M: TMenuItem;
    74257425  mox: ^TModel;
    74267426begin
    7427   NoSuper := not supervising and (1 shl me and MyRO.Alive <> 0);
    7428   HaveCities := false;
    7429   for i := 0 to MyRO.nCity - 1 do
    7430     if MyCity[i].Loc >= 0 then
    7431     begin
    7432       HaveCities := true;
     7427  NoSuper := not Supervising and (1 shl Me and MyRO.Alive <> 0);
     7428  HaveCities := False;
     7429  for I := 0 to MyRO.nCity - 1 do
     7430    if MyCity[I].Loc >= 0 then
     7431    begin
     7432      HaveCities := True;
    74337433      Break;
    74347434    end;
     
    74367436  begin
    74377437    mTechTree.Visible := ClientMode <> cEditMap;
    7438     mResign.Enabled := supervising or (me = 0) and (ClientMode < scContact);
     7438    mResign.Enabled := Supervising or (Me = 0) and (ClientMode < scContact);
    74397439    mRandomMap.Visible := (ClientMode = cEditMap) and
    7440       (Server(sMapGeneratorRequest, me, 0, nil^) = eOK);
     7440      (Server(sMapGeneratorRequest, Me, 0, nil^) = eOK);
    74417441    mOptions.Visible := ClientMode <> cEditMap;
    74427442    mManip.Visible := ClientMode <> cEditMap;
     
    74527452      case SoundMode of
    74537453        smOff:
    7454           mSoundOff.Checked := true;
     7454          mSoundOff.Checked := True;
    74557455        smOn:
    7456           mSoundOn.Checked := true;
     7456          mSoundOn.Checked := True;
    74577457        smOnAlt:
    7458           mSoundOnAlt.Checked := true;
    7459       end;
    7460 
    7461       for i := 0 to nTestFlags - 1 do
    7462         mManip[i].Checked := MyRO.TestFlags and (1 shl i) <> 0;
    7463       mManip.Enabled := supervising or (me = 0);
    7464 
    7465       Multi := false;
     7458          mSoundOnAlt.Checked := True;
     7459      end;
     7460
     7461      for I := 0 to nTestFlags - 1 do
     7462        mManip[I].Checked := MyRO.TestFlags and (1 shl I) <> 0;
     7463      mManip.Enabled := Supervising or (Me = 0);
     7464
     7465      Multi := False;
    74667466      for p1 := 1 to nPl - 1 do
    74677467        if G.RO[p1] <> nil then
    7468           Multi := true;
     7468          Multi := True;
    74697469      mEnemyMovement.Visible := not Multi;
    74707470    end;
     
    74727472    if NoSuper and (ClientMode < scContact) then
    74737473    begin
    7474       mCityTypes.Enabled := false;
     7474      mCityTypes.Enabled := False;
    74757475      // check if city types already usefull:
    74767476      if MyRO.nCity > 0 then
    7477         for i := nWonder to nImp - 1 do
    7478           if (i <> imTrGoods) and (Imp[i].Kind = ikCommon) and
    7479             (Imp[i].Preq <> preNA) and
    7480             ((Imp[i].Preq = preNone) or (MyRO.Tech[Imp[i].Preq] >= tsApplicable))
     7477        for I := nWonder to nImp - 1 do
     7478          if (I <> imTrGoods) and (Imp[I].Kind = ikCommon) and
     7479            (Imp[I].Preq <> preNA) and
     7480            ((Imp[I].Preq = preNone) or (MyRO.Tech[Imp[I].Preq] >= tsApplicable))
    74817481          then
    74827482          begin
    7483             mCityTypes.Enabled := true;
     7483            mCityTypes.Enabled := True;
    74847484            Break
    74857485          end;
    74867486    end;
    7487     mViewpoint.Visible := (ClientMode <> cEditMap) and supervising;
     7487    mViewpoint.Visible := (ClientMode <> cEditMap) and Supervising;
    74887488    mViewpoint.Enabled := G.RO[0].Turn > 0;
    7489     if supervising then
     7489    if Supervising then
    74907490    begin
    74917491      EmptyMenu(mViewpoint);
     
    74937493        if (p1 = 0) or (1 shl p1 and G.RO[0].Alive <> 0) then
    74947494        begin
    7495           m := TMenuItem.Create(mViewpoint);
     7495          M := TMenuItem.Create(mViewpoint);
    74967496          if p1 = 0 then
    7497             m.Caption := Phrases.Lookup('SUPER')
     7497            M.Caption := Phrases.Lookup('SUPER')
    74987498          else
    7499             m.Caption := Tribe[p1].TString(Phrases2.Lookup('BELONG'));
    7500           m.Tag := p1;
    7501           m.OnClick := ViewpointClick;
     7499            M.Caption := Tribe[p1].TString(Phrases2.Lookup('BELONG'));
     7500          M.Tag := p1;
     7501          M.OnClick := ViewpointClick;
    75027502          if p1 < 10 then
    7503             m.ShortCut := ShortCut(48 + p1, [ssCtrl]);
    7504           m.RadioItem := true;
    7505           if p1 = me then
    7506             m.Checked := true;
    7507           mViewpoint.Add(m);
     7503            M.ShortCut := ShortCut(48 + p1, [ssCtrl]);
     7504          M.RadioItem := True;
     7505          if p1 = Me then
     7506            M.Checked := True;
     7507          mViewpoint.Add(M);
    75087508        end
    75097509    end;
    7510     mDebugMap.Visible := (ClientMode <> cEditMap) and supervising;
    7511     if supervising then
     7510    mDebugMap.Visible := (ClientMode <> cEditMap) and Supervising;
     7511    if Supervising then
    75127512    begin
    75137513      EmptyMenu(mDebugMap);
     
    75157515        if (p1 = 0) or (1 shl p1 and G.RO[0].Alive <> 0) then
    75167516        begin
    7517           m := TMenuItem.Create(mDebugMap);
     7517          M := TMenuItem.Create(mDebugMap);
    75187518          if p1 = 0 then
    7519             m.Caption := Phrases2.Lookup('MENU_DEBUGMAPOFF')
     7519            M.Caption := Phrases2.Lookup('MENU_DEBUGMAPOFF')
    75207520          else
    7521             m.Caption := Tribe[p1].TString(Phrases2.Lookup('BELONG'));
     7521            M.Caption := Tribe[p1].TString(Phrases2.Lookup('BELONG'));
    75227522          if p1 = 0 then
    7523             m.Tag := -1
     7523            M.Tag := -1
    75247524          else
    7525             m.Tag := p1;
    7526           m.OnClick := DebugMapClick;
     7525            M.Tag := p1;
     7526          M.OnClick := DebugMapClick;
    75277527          if p1 < 10 then
    7528             m.ShortCut := ShortCut(48 + p1, [ssAlt]);
    7529           m.RadioItem := true;
    7530           if m.Tag = MainMap.pDebugMap then
    7531             m.Checked := true;
    7532           mDebugMap.Add(m);
     7528            M.ShortCut := ShortCut(48 + p1, [ssAlt]);
     7529          M.RadioItem := True;
     7530          if M.Tag = MainMap.pDebugMap then
     7531            M.Checked := True;
     7532          mDebugMap.Add(M);
    75337533        end;
    75347534    end;
     
    75457545      (ClientMode < scContact);
    75467546    mUnitStat.Enabled := NoSuper or (MyRO.Turn > 0);
    7547     mCityStat.Visible := 1 shl me and MyRO.Alive <> 0;
     7547    mCityStat.Visible := 1 shl Me and MyRO.Alive <> 0;
    75487548    mCityStat.Enabled := HaveCities;
    7549     mScienceStat.Visible := true;
     7549    mScienceStat.Visible := True;
    75507550    mScienceStat.Enabled := not NoSuper or (MyRO.ResearchTech >= 0) or
    75517551      (MyRO.Happened and phTech <> 0) or (MyRO.Happened and phGameEnd <> 0)
     
    75547554    mEUnitStat.Enabled := MyRO.nEnemyModel > 0;
    75557555    { mWonders.Enabled:= false;
    7556       for i:=0 to nWonder - 1 do if MyRO.Wonder[i].CityID <> WonderNotBuiltYet then
    7557       mWonders.Enabled:=true; }
     7556      for I:=0 to nWonder - 1 do if MyRO.Wonder[I].CityID <> WonderNotBuiltYet then
     7557      mWonders.Enabled:=True; }
    75587558    mDiagram.Enabled := MyRO.Turn >= 2;
    7559     mShips.Enabled := false;
     7559    mShips.Enabled := False;
    75607560    for p1 := 0 to nPl - 1 do
    75617561      if MyRO.Ship[p1].Parts[spComp] + MyRO.Ship[p1].Parts[spPow] +
    75627562        MyRO.Ship[p1].Parts[spHab] > 0 then
    7563         mShips.Enabled := true;
     7563        mShips.Enabled := True;
    75647564  end
    75657565  else if Popup = UnitPopup then
     
    75677567    mox := @MyModel[MyUn[UnFocus].mix];
    75687568    Tile := MyMap[MyUn[UnFocus].Loc];
    7569     extended := Tile and fCity = 0;
    7570     if extended then
     7569    Extended := Tile and fCity = 0;
     7570    if Extended then
    75717571    begin
    75727572      mCity.Caption := Phrases.Lookup('BTN_FOUND');
     
    75797579    end;
    75807580
    7581     extended := extended and ((mox.Kind = mkSettler) or (mox.Kind = mkSlaves)
     7581    Extended := Extended and ((mox.Kind = mkSettler) or (mox.Kind = mkSlaves)
    75827582      and (MyRO.Wonder[woPyramids].EffectiveOwner >= 0)) and
    75837583      (MyUn[UnFocus].Master < 0) and (Tile and fDeadLands = 0);
    75847584    if (mox.Kind = mkFreight) and (Tile and fCity <> 0) and
    75857585      not Phrases2FallenBackToEnglish or
    7586       (Server(sRemoveUnit - sExecute, me, UnFocus, nil^) = eUtilized) then
    7587     begin
    7588       mDisband.Visible := false;
    7589       mUtilize.Visible := true;
     7586      (Server(sRemoveUnit - sExecute, Me, UnFocus, nil^) = eUtilized) then
     7587    begin
     7588      mDisband.Visible := False;
     7589      mUtilize.Visible := True;
    75907590      if mox.Kind = mkFreight then
    75917591        mUtilize.Caption := Phrases.Lookup('UTILIZE')
     
    75957595    else
    75967596    begin
    7597       mDisband.Visible := true;
    7598       mUtilize.Visible := false
     7597      mDisband.Visible := True;
     7598      mUtilize.Visible := False
    75997599    end;
    76007600    mGoOn.Visible := MyUn[UnFocus].Status and (usGoto or usWaiting) = usGoto or
     
    76037603    mRecover.Visible := (MyUn[UnFocus].Health < 100) and
    76047604      (Tile and fTerrain >= fGrass) and
    7605       ((MyRO.Wonder[woGardens].EffectiveOwner = me) or
     7605      ((MyRO.Wonder[woGardens].EffectiveOwner = Me) or
    76067606      (Tile and fTerrain <> fArctic) and (Tile and fTerrain <> fDesert)) and
    76077607      not((mox.Domain = dAir) and (Tile and fCity = 0) and
     
    76097609    mStay.Visible := not((mox.Domain = dAir) and (Tile and fCity = 0) and
    76107610      (Tile and fTerImp <> tiBase));
    7611     mCity.Visible := extended and (mox.Kind = mkSettler) or
     7611    mCity.Visible := Extended and (mox.Kind = mkSettler) or
    76127612      (Tile and fCity <> 0) and ((mox.Kind in [mkSettler, mkSlaves]) or
    76137613      (MyUn[UnFocus].Flags and unConscripts <> 0));
     
    76177617      (MyUn[UnFocus].Status and (usRecover or usGoto) <> 0);
    76187618
    7619     Test := Server(sLoadUnit - sExecute, me, UnFocus, nil^);
     7619    Test := Server(sLoadUnit - sExecute, Me, UnFocus, nil^);
    76207620    mLoad.Visible := (Test >= rExecuted) or (Test = eNoTime_Load);
    76217621    mUnload.Visible := (MyUn[UnFocus].Master >= 0) or
    76227622      (MyUn[UnFocus].TroopLoad + MyUn[UnFocus].AirLoad > 0);
    7623     mSelectTransport.Visible := Server(sSelectTransport - sExecute, me, UnFocus,
     7623    mSelectTransport.Visible := Server(sSelectTransport - sExecute, Me, UnFocus,
    76247624      nil^) >= rExecuted;
    76257625  end
     
    76287628    mox := @MyModel[MyUn[UnFocus].mix];
    76297629    Tile := MyMap[MyUn[UnFocus].Loc];
    7630     extended := Tile and fCity = 0;
     7630    Extended := Tile and fCity = 0;
    76317631
    76327632    if (Tile and fRiver <> 0) and (MyRO.Tech[adBridgeBuilding] >= tsApplicable)
     
    76487648      mClear.Caption := Phrases.Lookup('BTN_DRAIN');
    76497649
    7650     extended := extended and ((mox.Kind = mkSettler) or (mox.Kind = mkSlaves)
     7650    Extended := Extended and ((mox.Kind = mkSettler) or (mox.Kind = mkSlaves)
    76517651      and (MyRO.Wonder[woPyramids].EffectiveOwner >= 0)) and
    76527652      (MyUn[UnFocus].Master < 0);
    7653     if extended then
     7653    if Extended then
    76547654    begin
    76557655      mRoad.Visible := JobTest(UnFocus, jRoad, [eNoBridgeBuilding, eTreaty]);
     
    76717671    else
    76727672    begin
    7673       for i := 0 to Popup.Items.Count - 1 do
    7674         Popup.Items[i].Visible := false;
     7673      for I := 0 to Popup.Items.Count - 1 do
     7674        Popup.Items[I].Visible := False;
    76757675    end;
    76767676  end;
     
    76787678  // set menu seperators
    76797679  LastSep := nil;
    7680   NeedSep := false;
    7681   for i := 0 to Popup.Items.Count - 1 do
    7682     if Popup.Items[i].Caption = '-' then
    7683     begin
    7684       Popup.Items[i].Visible := NeedSep;
     7680  NeedSep := False;
     7681  for I := 0 to Popup.Items.Count - 1 do
     7682    if Popup.Items[I].Caption = '-' then
     7683    begin
     7684      Popup.Items[I].Visible := NeedSep;
    76857685      if NeedSep then
    7686         LastSep := Popup.Items[i];
    7687       NeedSep := false
     7686        LastSep := Popup.Items[I];
     7687      NeedSep := False
    76887688    end
    7689     else if Popup.Items[i].Visible then
    7690       NeedSep := true;
     7689    else if Popup.Items[I].Visible then
     7690      NeedSep := True;
    76917691  if (LastSep <> nil) and not NeedSep then
    7692     LastSep.Visible := false
     7692    LastSep.Visible := False
    76937693end;
    76947694
     
    77097709end;
    77107710
    7711 procedure TMainScreen.CityClosed(Activateuix: integer; StepFocus: boolean;
    7712   SelectFocus: boolean);
    7713 begin
    7714   if supervising then
     7711procedure TMainScreen.CityClosed(Activateuix: Integer; StepFocus: Boolean;
     7712  SelectFocus: Boolean);
     7713begin
     7714  if Supervising then
    77157715  begin
    77167716    SetTroopLoc(-1);
     
    77297729    end
    77307730    else if StepFocus then
    7731       NextUnit(TroopLoc, true)
     7731      NextUnit(TroopLoc, True)
    77327732    else
    77337733    begin
     
    77447744
    77457745procedure TMainScreen.PanelBoxMouseMove(Sender: TObject; Shift: TShiftState;
    7746   x, y: integer);
     7746  X, Y: Integer);
    77477747var
    7748   xCentre, yCentre: integer;
     7748  xCentre, yCentre: Integer;
    77497749begin
    77507750  if Tracking and (ssLeft in Shift) then
    77517751  with MainMap do begin
    7752     if (x >= xMini + 2) and (y >= yMini + 2) and (x < xMini + 2 + 2 * G.lx) and
    7753       (y < yMini + 2 + G.ly) then
    7754     begin
    7755       xCentre := (xwMini + (x - xMini - 2) div 2 + G.lx div 2 +
     7752    if (X >= xMini + 2) and (Y >= yMini + 2) and (X < xMini + 2 + 2 * G.lx) and
     7753      (Y < yMini + 2 + G.ly) then
     7754    begin
     7755      xCentre := (xwMini + (X - xMini - 2) div 2 + G.lx div 2 +
    77567756        MapWidth div (xxt * 4)) mod G.lx;
    7757       yCentre := (y - yMini - 2);
     7757      yCentre := (Y - yMini - 2);
    77587758      xw := (xCentre - MapWidth div (xxt * 4) + G.lx) mod G.lx;
    77597759      if ywmax <= 0 then
     
    77697769      BitBltCanvas(Buffer.Canvas, 0, 0, G.lx * 2, G.ly, MiniMap.Bitmap.Canvas, 0, 0);
    77707770      if ywmax <= 0 then
    7771         Frame(Buffer.Canvas, x - xMini - 2 - MapWidth div (xxt * 2), 0,
    7772           x - xMini - 2 + MapWidth div (xxt * 2) - 1, G.ly - 1,
     7771        Frame(Buffer.Canvas, X - xMini - 2 - MapWidth div (xxt * 2), 0,
     7772          X - xMini - 2 + MapWidth div (xxt * 2) - 1, G.ly - 1,
    77737773          MainTexture.ColorMark, MainTexture.ColorMark)
    77747774      else
    7775         Frame(Buffer.Canvas, x - xMini - 2 - MapWidth div (xxt * 2), yw,
    7776           x - xMini - 2 + MapWidth div (xxt * 2) - 1, yw + MapHeight div yyt -
     7775        Frame(Buffer.Canvas, X - xMini - 2 - MapWidth div (xxt * 2), yw,
     7776          X - xMini - 2 + MapWidth div (xxt * 2) - 1, yw + MapHeight div yyt -
    77777777          2, MainTexture.ColorMark, MainTexture.ColorMark);
    77787778      BitBltCanvas(Panel.Canvas, xMini + 2, yMini + 2, G.lx * 2, G.ly,
     
    77867786  end
    77877787  else
    7788     Tracking := false;
     7788    Tracking := False;
    77897789end;
    77907790
    77917791procedure TMainScreen.PanelBoxMouseUp(Sender: TObject; Button: TMouseButton;
    7792   Shift: TShiftState; x, y: integer);
     7792  Shift: TShiftState; X, Y: Integer);
    77937793begin
    77947794  if Tracking then
    77957795  begin
    7796     Tracking := false;
     7796    Tracking := False;
    77977797    xwMini := xw;
    77987798    ywMini := yw;
     
    78037803
    78047804procedure TMainScreen.MapBoxMouseMove(Sender: TObject; Shift: TShiftState;
    7805   x, y: integer);
     7805  X, Y: Integer);
    78067806var
    7807   MouseLoc: integer;
    7808 begin
    7809   xMouse := x;
    7810   yMouse := y;
     7807  MouseLoc: Integer;
     7808begin
     7809  xMouse := X;
     7810  yMouse := Y;
    78117811  if (ClientMode = cEditMap) and (ssLeft in Shift) and not Tracking then
    78127812  begin
    7813     MouseLoc := LocationOfScreenPixel(x, y);
     7813    MouseLoc := LocationOfScreenPixel(X, Y);
    78147814    if MouseLoc <> BrushLoc then
    7815       MapBoxMouseDown(nil, mbLeft, Shift, x, y);
     7815      MapBoxMouseDown(nil, mbLeft, Shift, X, Y);
    78167816  end
    7817   (* else if idle and (UnFocus>=0) then
     7817  (* else if Idle and (UnFocus>=0) then
    78187818    begin
    78197819    qx:=(xMouse*32+yMouse*66+16*66) div(32*66)-1;
     
    78287828  TMenuItem(Sender).Checked := not TMenuItem(Sender).Checked;
    78297829  SetMapOptions;
    7830   MapValid := false;
     7830  MapValid := False;
    78317831  PaintAllMaps;
    78327832end;
     
    78347834procedure TMainScreen.mNamesClick(Sender: TObject);
    78357835var
    7836   p1: integer;
     7836  p1: Integer;
    78377837begin
    78387838  mNames.Checked := not mNames.Checked;
     
    78447844      else
    78457845        Tribe[p1].NumberName := p1;
    7846   MapValid := false;
     7846  MapValid := False;
    78477847  PaintAll;
    78487848end;
    78497849
    7850 function TMainScreen.IsPanelPixel(x, y: integer): boolean;
    7851 begin
    7852   result := (y >= TopBarHeight + MapHeight) or (y >= ClientHeight - PanelHeight)
    7853     and ((x < xMidPanel) or (x >= xRightPanel));
     7850function TMainScreen.IsPanelPixel(X, Y: Integer): Boolean;
     7851begin
     7852  Result := (Y >= TopBarHeight + MapHeight) or (Y >= ClientHeight - PanelHeight)
     7853    and ((X < xMidPanel) or (X >= xRightPanel));
    78547854end;
    78557855
    78567856procedure TMainScreen.FormMouseDown(Sender: TObject; Button: TMouseButton;
    7857   Shift: TShiftState; x, y: integer);
    7858 begin
    7859   if idle then
    7860     if (x < 40) and (y < 40) then
     7857  Shift: TShiftState; X, Y: Integer);
     7858begin
     7859  if Idle then
     7860    if (X < 40) and (Y < 40) then
    78617861    begin
    78627862      if GameMode <> cMovie then
     
    78707870      end;
    78717871    end
    7872     else if IsPanelPixel(x, y) then
    7873       PanelBoxMouseDown(Sender, Button, Shift, x,
    7874         y - (ClientHeight - PanelHeight))
    7875     else if (y >= TopBarHeight) and (x >= MapOffset) and
    7876       (x < MapOffset + MapWidth) then
    7877       MapBoxMouseDown(Sender, Button, Shift, x - MapOffset, y - TopBarHeight)
     7872    else if IsPanelPixel(X, Y) then
     7873      PanelBoxMouseDown(Sender, Button, Shift, X,
     7874        Y - (ClientHeight - PanelHeight))
     7875    else if (Y >= TopBarHeight) and (X >= MapOffset) and
     7876      (X < MapOffset + MapWidth) then
     7877      MapBoxMouseDown(Sender, Button, Shift, X - MapOffset, Y - TopBarHeight)
    78787878end;
    78797879
    78807880procedure TMainScreen.FormMouseMove(Sender: TObject; Shift: TShiftState;
    7881   x, y: integer);
    7882 begin
    7883   if idle then
    7884     if IsPanelPixel(x, y) then
    7885       PanelBoxMouseMove(Sender, Shift, x, y - (ClientHeight - PanelHeight))
    7886     else if (y >= TopBarHeight) and (x >= MapOffset) and
    7887       (x < MapOffset + MapWidth) then
    7888       MapBoxMouseMove(Sender, Shift, x - MapOffset, y - TopBarHeight);
     7881  X, Y: Integer);
     7882begin
     7883  if Idle then
     7884    if IsPanelPixel(X, Y) then
     7885      PanelBoxMouseMove(Sender, Shift, X, Y - (ClientHeight - PanelHeight))
     7886    else if (Y >= TopBarHeight) and (X >= MapOffset) and
     7887      (X < MapOffset + MapWidth) then
     7888      MapBoxMouseMove(Sender, Shift, X - MapOffset, Y - TopBarHeight);
    78897889end;
    78907890
    78917891procedure TMainScreen.FormMouseUp(Sender: TObject; Button: TMouseButton;
    7892   Shift: TShiftState; x, y: integer);
    7893 begin
    7894   if idle then
    7895     PanelBoxMouseUp(Sender, Button, Shift, x, y - (ClientHeight - PanelHeight));
     7892  Shift: TShiftState; X, Y: Integer);
     7893begin
     7894  if Idle then
     7895    PanelBoxMouseUp(Sender, Button, Shift, X, Y - (ClientHeight - PanelHeight));
    78967896end;
    78977897
     
    79027902    with Canvas do
    79037903    begin // pillarbox, make left and right border black
    7904       if me < 0 then
     7904      if Me < 0 then
    79057905        Brush.Color := $000000
    79067906      else
     
    79297929    end;
    79307930  BitBltCanvas(Canvas, MapOffset, TopBarHeight, MapWidth, MapHeight - overlap,
    7931     offscreen.Canvas, 0, 0);
     7931    Offscreen.Canvas, 0, 0);
    79327932  BitBltCanvas(Canvas, 0, 0, ClientWidth, TopBarHeight, TopBar.Canvas,
    79337933    0, 0);
    79347934  if xMidPanel > MapOffset then
    79357935    BitBltCanvas(Canvas, xMidPanel, TopBarHeight + MapHeight - overlap,
    7936       ClientWidth div 2 - xMidPanel, overlap, offscreen.Canvas,
     7936      ClientWidth div 2 - xMidPanel, overlap, Offscreen.Canvas,
    79377937      xMidPanel - MapOffset, MapHeight - overlap)
    79387938  else
    79397939    BitBltCanvas(Canvas, MapOffset, TopBarHeight + MapHeight - overlap,
    7940       ClientWidth div 2 - MapOffset, overlap, offscreen.Canvas, 0,
     7940      ClientWidth div 2 - MapOffset, overlap, Offscreen.Canvas, 0,
    79417941      MapHeight - overlap);
    79427942  if xRightPanel < MapOffset + MapWidth then
    79437943    BitBltCanvas(Canvas, ClientWidth div 2, TopBarHeight + MapHeight - overlap,
    7944       xRightPanel - ClientWidth div 2, overlap, offscreen.Canvas,
     7944      xRightPanel - ClientWidth div 2, overlap, Offscreen.Canvas,
    79457945      ClientWidth div 2 - MapOffset, MapHeight - overlap)
    79467946  else
    79477947    BitBltCanvas(Canvas, ClientWidth div 2, TopBarHeight + MapHeight - overlap,
    79487948      MapOffset + MapWidth - ClientWidth div 2, overlap,
    7949       offscreen.Canvas, ClientWidth div 2 - MapOffset,
     7949      Offscreen.Canvas, ClientWidth div 2 - MapOffset,
    79507950      MapHeight - overlap);
    79517951  BitBltCanvas(Canvas, 0, TopBarHeight + MapHeight - overlap, xMidPanel,
     
    79607960end;
    79617961
    7962 procedure TMainScreen.RectInvalidate(Left, Top, Rigth, Bottom: integer);
     7962procedure TMainScreen.RectInvalidate(Left, Top, Rigth, Bottom: Integer);
    79637963var
    79647964  r0: HRgn;
    79657965begin
    79667966  r0 := CreateRectRgn(Left, Top, Rigth, Bottom);
    7967   InvalidateRgn(Handle, r0, false);
     7967  InvalidateRgn(Handle, r0, False);
    79687968  DeleteObject(r0);
    79697969end;
    79707970
    7971 procedure TMainScreen.SmartRectInvalidate(Left, Top, Rigth, Bottom: integer);
     7971procedure TMainScreen.SmartRectInvalidate(Left, Top, Rigth, Bottom: Integer);
    79727972var
    7973   i: integer;
     7973  I: Integer;
    79747974  r0, r1: HRgn;
    79757975begin
    79767976  r0 := CreateRectRgn(Left, Top, Rigth, Bottom);
    7977   for i := 0 to ControlCount - 1 do
    7978     if not(Controls[i] is TArea) and Controls[i].Visible then
    7979     begin
    7980       with Controls[i].BoundsRect do
     7977  for I := 0 to ControlCount - 1 do
     7978    if not(Controls[I] is TArea) and Controls[I].Visible then
     7979    begin
     7980      with Controls[I].BoundsRect do
    79817981        r1 := CreateRectRgn(Left, Top, Right, Bottom);
    79827982      CombineRgn(r0, r0, r1, RGN_DIFF);
    79837983      DeleteObject(r1);
    79847984    end;
    7985   InvalidateRgn(Handle, r0, false);
     7985  InvalidateRgn(Handle, r0, False);
    79867986  DeleteObject(r0);
    79877987end;
     
    80488048procedure TMainScreen.FormClose(Sender: TObject; var Action: TCloseAction);
    80498049begin
    8050   Timer1.Enabled := false;
     8050  Timer1.Enabled := False;
    80518051end;
    80528052
    80538053procedure TMainScreen.Radio(Sender: TObject);
    80548054begin
    8055   TMenuItem(Sender).Checked := true;
     8055  TMenuItem(Sender).Checked := True;
    80568056end;
    80578057
    80588058procedure TMainScreen.mManipClick(Sender: TObject);
    80598059var
    8060   Flag: integer;
     8060  Flag: Integer;
    80618061begin
    80628062  with TMenuItem(Sender) do
     
    80708070      Play('CHEAT');
    80718071    end;
    8072     if not supervising then
     8072    if not Supervising then
    80738073    begin
    80748074      if Flag = tfUncover then
    80758075      begin
    8076         MapValid := false;
     8076        MapValid := False;
    80778077        PaintAllMaps;
    80788078      end
     
    80988098  else
    80998099  begin
    8100     MapValid := false;
     8100    MapValid := False;
    81018101    PaintAllMaps;
    81028102  end; // update main map
     
    81178117  end;
    81188118  SetMapOptions;
    8119   MapValid := false;
     8119  MapValid := False;
    81208120  PaintAllMaps;
    81218121end;
     
    81358135  end;
    81368136  SetMapOptions;
    8137   MapValid := false;
     8137  MapValid := False;
    81388138  PaintAllMaps;
    81398139end;
    81408140
    8141 procedure TMainScreen.FormKeyUp(Sender: TObject; var Key: word;
     8141procedure TMainScreen.FormKeyUp(Sender: TObject; var Key: Word;
    81428142  Shift: TShiftState);
    81438143begin
    8144   if idle and (Key = VK_APPS) then
     8144  if Idle and (Key = VK_APPS) then
    81458145  begin
    81468146    InitPopup(GamePopup);
     
    81508150      GamePopup.Popup(Left + 4, Top + GetSystemMetrics(SM_CYCAPTION) + 4 +
    81518151        TopBarHeight - 1);
    8152     exit;
     8152    Exit;
    81538153  end; // windows menu button calls game menu
    81548154end;
     
    81568156procedure TMainScreen.CreateUnitClick(Sender: TObject);
    81578157var
    8158   p1, mix: integer;
     8158  p1, mix: Integer;
    81598159begin
    81608160  p1 := TComponent(Sender).Tag shr 16;
    81618161  mix := TComponent(Sender).Tag and $FFFF;
    8162   if Server(sCreateUnit + p1 shl 4, me, mix, EditLoc) >= rExecuted then
     8162  if Server(sCreateUnit + p1 shl 4, Me, mix, EditLoc) >= rExecuted then
    81638163    PaintLoc(EditLoc);
    81648164end;
     
    81818181{ procedure TMainScreen.AdviceBtnClick;
    81828182  var
    8183   OldAdviceLoc: integer;
    8184   begin
    8185   DestinationMarkON:=false;
     8183  OldAdviceLoc: Integer;
     8184  begin
     8185  DestinationMarkON:=False;
    81868186  PaintDestination;
    81878187  AdvisorDlg.GiveStrategyAdvice;
     
    81938193{ procedure TMainScreen.SetAdviceLoc(Loc: integer; AvoidRect: TRect);
    81948194  var
    8195   OldAdviceLoc,x,y: integer;
     8195  OldAdviceLoc,X,Y: Integer;
    81968196  begin
    81978197  if Loc<>MainMap.AdviceLoc then
     
    81998199  if Loc>=0 then
    82008200  begin // center
    8201   y:=Loc div G.lx;
    8202   x:=(Loc+G.lx - AvoidRect.Right div (2*66)) mod G.lx;
    8203   Centre(y*G.lx+x);
     8201  Y:=Loc div G.lx;
     8202  X:=(Loc+G.lx - AvoidRect.Right div (2*66)) mod G.lx;
     8203  Centre(Y*G.lx+X);
    82048204  PaintAllMaps;
    82058205  end;
     
    82598259procedure TMainScreen.SaveMenuItemsState;
    82608260var
    8261   i, j: integer;
     8261  I, J: Integer;
    82628262begin
    82638263  if soTellAI in OptionChecked then OptionChecked := [soTellAI]
    82648264    else OptionChecked := [];
    8265   for i := 0 to ComponentCount - 1 do
    8266     if Components[i] is TMenuItem then
    8267       for j := 0 to Length(SaveOption) - 1 do
    8268         if TMenuItem(Components[i]).Checked and
    8269           (TMenuItem(Components[i]).Tag = SaveOption[j]) then
    8270           OptionChecked := OptionChecked + [TSaveOption(j)];
     8265  for I := 0 to ComponentCount - 1 do
     8266    if Components[I] is TMenuItem then
     8267      for J := 0 to Length(SaveOption) - 1 do
     8268        if TMenuItem(Components[I]).Checked and
     8269          (TMenuItem(Components[I]).Tag = SaveOption[J]) then
     8270          OptionChecked := OptionChecked + [TSaveOption(J)];
    82718271end;
    82728272
     
    82808280  with Reg do
    82818281  try
    8282     OpenKey(AppRegistryKey, true);
     8282    OpenKey(AppRegistryKey, True);
    82838283    WriteInteger('TileSize', Integer(MainMap.TileSize));
    82848284    WriteInteger('OptionChecked', Integer(OptionChecked));
    82858285    WriteInteger('MapOptionChecked', Integer(MapOptionChecked));
    8286     WriteInteger('CityReport', integer(CityRepMask));
     8286    WriteInteger('CityReport', Integer(CityRepMask));
    82878287  finally
    82888288    Free;
  • trunk/LocalPlayer/Tribes.pas

    r438 r447  
    4949    constructor Create(FileName: string);
    5050    destructor Destroy; override;
    51     function GetCityName(i: Integer): string;
    52 {$IFNDEF SCR} procedure SetCityName(i: Integer; NewName: string); {$ENDIF}
     51    function GetCityName(I: Integer): string;
     52{$IFNDEF SCR} procedure SetCityName(I: Integer; NewName: string); {$ENDIF}
    5353{$IFNDEF SCR} function TString(Template: string): string;
    5454    function TPhrase(Item: string): string; {$ENDIF}
     
    7474procedure FindStdModelPicture(Code: Integer; var pix: Integer; var Name: string);
    7575function GetTribeInfo(FileName: string; var Name: string; var Color: TColor): Boolean;
    76 procedure FindPosition(HGr: TGraphicSet; x, y, xmax, ymax: Integer; Mark: TColor;
     76procedure FindPosition(HGr: TGraphicSet; X, Y, xmax, ymax: Integer; Mark: TColor;
    7777  var xp, yp: Integer);
    7878
     
    215215function Get: string;
    216216var
    217   p: Integer;
     217  P: Integer;
    218218begin
    219219  while (Input <> '') and ((Input[1] = ' ') or (Input[1] = #9)) do
    220220    Delete(Input, 1, 1);
    221   p := Pos(',', Input);
    222   if p = 0 then
    223     p := Length(Input) + 1;
    224   Result := Copy(Input, 1, p - 1);
    225   Delete(Input, 1, p);
     221  P := Pos(',', Input);
     222  if P = 0 then
     223    P := Length(Input) + 1;
     224  Result := Copy(Input, 1, P - 1);
     225  Delete(Input, 1, P);
    226226end;
    227227
    228228function GetNum: Integer;
    229229var
    230   i: Integer;
    231 begin
    232   Val(Get, Result, i);
    233   if i <> 0 then
     230  I: Integer;
     231begin
     232  Val(Get, Result, I);
     233  if I <> 0 then
    234234    Result := 0;
    235235end;
     
    237237procedure FindStdModelPicture(Code: Integer; var pix: Integer; var Name: string);
    238238var
    239   i: Integer;
    240 begin
    241   for i := 0 to StdUnitScript.Count - 1 do
     239  I: Integer;
     240begin
     241  for I := 0 to StdUnitScript.Count - 1 do
    242242  begin // look through StdUnits
    243     Input := StdUnitScript[i];
     243    Input := StdUnitScript[I];
    244244    pix := GetNum;
    245245    if Code = GetNum then
     
    340340end;
    341341
    342 procedure FindPosition(HGr: TGraphicSet; x, y, xmax, ymax: Integer; Mark: TColor;
     342procedure FindPosition(HGr: TGraphicSet; X, Y, xmax, ymax: Integer; Mark: TColor;
    343343  var xp, yp: Integer);
    344344begin
    345345  xp := 0;
    346   while (xp < xmax) and (HGr.Data.Canvas.Pixels[x + 1 + xp, y] <> Mark) do
     346  while (xp < xmax) and (HGr.Data.Canvas.Pixels[X + 1 + xp, Y] <> Mark) do
    347347    Inc(xp);
    348348  yp := 0;
    349   while (yp < ymax) and (HGr.Data.Canvas.Pixels[x, y + 1 + yp] <> Mark) do
     349  while (yp < ymax) and (HGr.Data.Canvas.Pixels[X, Y + 1 + yp] <> Mark) do
    350350    Inc(yp);
    351351end;
    352352
    353 function TTribe.GetCityName(i: Integer): string;
     353function TTribe.GetCityName(I: Integer): string;
    354354begin
    355355  Result := '';
    356   if nCityLines > i then
    357   begin
    358     Result := Script[CityLine0 + i];
     356  if nCityLines > I then
     357  begin
     358    Result := Script[CityLine0 + I];
    359359    while (Result <> '') and ((Result[1] = ' ') or (Result[1] = #9)) do
    360360      Delete(Result, 1, 1);
     
    362362{$IFNDEF SCR}
    363363  else
    364     Result := Format(TPhrase('GENCITY'), [i + 1]);
     364    Result := Format(TPhrase('GENCITY'), [I + 1]);
    365365{$ENDIF}
    366366end;
    367367
    368368{$IFNDEF SCR}
    369 procedure TTribe.SetCityName(i: Integer; NewName: string);
    370 begin
    371   while nCityLines <= i do
     369procedure TTribe.SetCityName(I: Integer; NewName: string);
     370begin
     371  while nCityLines <= I do
    372372  begin
    373373    Script.Insert(CityLine0 + nCityLines, Format(TPhrase('GENCITY'),
     
    375375    Inc(nCityLines);
    376376  end;
    377   Script[CityLine0 + i] := NewName;
     377  Script[CityLine0 + I] := NewName;
    378378end;
    379379
    380380function TTribe.TString(Template: string): string;
    381381var
    382   p: Integer;
     382  P: Integer;
    383383  Variant: Char;
    384384  CaseUp: Boolean;
    385385begin
    386386  repeat
    387     p := pos('#', Template);
    388     if (p = 0) or (p = Length(Template)) then
     387    P := Pos('#', Template);
     388    if (P = 0) or (P = Length(Template)) then
    389389      Break;
    390     Variant := Template[p + 1];
     390    Variant := Template[P + 1];
    391391    CaseUp := Variant in ['A' .. 'Z'];
    392392    if CaseUp then
    393393      Inc(Variant, 32);
    394     Delete(Template, p, 2);
     394    Delete(Template, P, 2);
    395395    if Variant in ['a' .. 'z'] then
    396396    begin
    397397      if NumberName < 0 then
    398         Insert(Name[Variant], Template, p)
     398        Insert(Name[Variant], Template, P)
    399399      else
    400         Insert(Format('P%d', [NumberName]), Template, p);
    401       if CaseUp and (Length(Template) >= p) and
    402         (Template[p] in ['a' .. 'z', #$E0 .. #$FF]) then
    403         Dec(Template[p], 32);
     400        Insert(Format('P%d', [NumberName]), Template, P);
     401      if CaseUp and (Length(Template) >= P) and
     402        (Template[P] in ['a' .. 'z', #$E0 .. #$FF]) then
     403        Dec(Template[P], 32);
    404404    end
    405405  until False;
     
    418418  TLine = array [0 .. 649, 0 .. 2] of Byte;
    419419var
    420   i, x, Gray: Integer;
     420  I, X, Gray: Integer;
    421421  Item: string;
    422422begin
     
    426426  with Script do
    427427  begin
    428     i := 0;
    429     while (i < Count) and (Copy(Strings[i], 1, 6) <>
     428    I := 0;
     429    while (I < Count) and (Copy(Strings[I], 1, 6) <>
    430430        '#AGE' + char(48 + Age) + ' ') do
    431       Inc(i);
    432     if i < Count then
    433     begin
    434       Input := Strings[i];
     431      Inc(I);
     432    if I < Count then
     433    begin
     434      Input := Strings[I];
    435435      system.Delete(Input, 1, 6);
    436436      Item := Get;
     
    448448          end;
    449449        cHGr := LoadGraphicSet(Item + '.png');
    450         for x := 0 to 3 do
    451           with CityPicture[x] do begin
    452             FindPosition(cHGr, x * 65, cpix * 49, 63, 47, $00FFFF,
     450        for X := 0 to 3 do
     451          with CityPicture[X] do begin
     452            FindPosition(cHGr, X * 65, cpix * 49, 63, 47, $00FFFF,
    453453              xShield, yShield);
    454454            // FindPosition(cHGr,x*65,cpix*49,$FFFFFF,xf,yf);
     
    486486procedure TTribe.SetModelPicture(const Info: TModelPictureInfo; IsNew: Boolean);
    487487var
    488   i: Integer;
     488  I: Integer;
    489489  ok: Boolean;
    490490begin
     
    493493    if not IsNew then
    494494    begin
    495       i := nPictureList - 1;
    496       while (i >= 0) and (PictureList[i].Hash <> Info.Hash) do
    497         Dec(i);
    498       assert(i >= 0);
    499       assert(PictureList[i].HGr = LoadGraphicSet(GrName));
    500       assert(PictureList[i].pix = pix);
    501       ModelPicture[mix].HGr := PictureList[i].HGr;
    502       ModelPicture[mix].pix := PictureList[i].pix;
    503       ModelName[mix] := PictureList[i].ModelName;
     495      I := nPictureList - 1;
     496      while (I >= 0) and (PictureList[I].Hash <> Info.Hash) do
     497        Dec(I);
     498      Assert(I >= 0);
     499      Assert(PictureList[I].HGr = LoadGraphicSet(GrName));
     500      Assert(PictureList[I].pix = pix);
     501      ModelPicture[mix].HGr := PictureList[I].HGr;
     502      ModelPicture[mix].pix := PictureList[I].pix;
     503      ModelName[mix] := PictureList[I].ModelName;
    504504    end
    505505    else
     
    515515      // read model name from tribe script
    516516      ok := False;
    517       for i := 0 to Script.Count - 1 do
    518       begin
    519         Input := Script[i];
     517      for I := 0 to Script.Count - 1 do
     518      begin
     519        Input := Script[I];
    520520        if Input = '#UNITS ' + ExtractFileNameOnly(GrName) then
    521521          ok := True
     
    531531      if ModelName[mix] = '' then
    532532      begin // read model name from StdUnits.txt
    533         for i := 0 to StdUnitScript.Count - 1 do
     533        for I := 0 to StdUnitScript.Count - 1 do
    534534        begin
    535           Input := StdUnitScript[i];
     535          Input := StdUnitScript[I];
    536536          if GetNum = pix then
    537537          begin
     
    567567  Code, Turn: Integer; ForceNew: Boolean): Boolean;
    568568var
    569   i: Integer;
     569  I: Integer;
    570570  Cnt: Integer;
    571571  HGr: TGraphicSet;
     
    606606  if not ForceNew and (Picture.Hash > 0) then
    607607  begin
    608     for i := 0 to nPictureList - 1 do
    609       if PictureList[i].Hash = Picture.Hash then
    610       begin
    611         Picture.GrName := PictureList[i].HGr.Name;
    612         Picture.pix := PictureList[i].pix;
     608    for I := 0 to nPictureList - 1 do
     609      if PictureList[I].Hash = Picture.Hash then
     610      begin
     611        Picture.GrName := PictureList[I].HGr.Name;
     612        Picture.pix := PictureList[I].pix;
    613613        Result := False;
    614614        Exit;
     
    622622  TestPic.GrName := 'StdUnits.png';
    623623  HGr := HGrStdUnits;
    624   for i := 0 to StdUnitScript.Count - 1 do
     624  for I := 0 to StdUnitScript.Count - 1 do
    625625  begin // look through StdUnits
    626     Input := StdUnitScript[i];
     626    Input := StdUnitScript[I];
    627627    Check;
    628628  end;
    629629
    630630  ok := False;
    631   for i := 0 to Script.Count - 1 do
     631  for I := 0 to Script.Count - 1 do
    632632  begin // look through units defined in tribe script
    633     Input := Script[i];
     633    Input := Script[I];
    634634    if Copy(Input, 1, 6) = '#UNITS' then
    635635    begin
  • trunk/LocalPlayer/UKeyBindings.pas

    r424 r447  
    397397end.
    398398
     399
  • trunk/LocalPlayer/UnitStat.pas

    r442 r447  
    2828  public
    2929    procedure CheckAge;
    30     procedure ShowNewContent_OwnModel(NewMode: TWindowMode; mix: integer);
    31     procedure ShowNewContent_OwnUnit(NewMode: TWindowMode; uix: integer);
    32     procedure ShowNewContent_EnemyUnit(NewMode: TWindowMode; euix: integer);
    33     procedure ShowNewContent_EnemyLoc(NewMode: TWindowMode; Loc: integer);
    34     procedure ShowNewContent_EnemyModel(NewMode: TWindowMode; emix: integer);
    35     procedure ShowNewContent_EnemyCity(NewMode: TWindowMode; Loc: integer);
     30    procedure ShowNewContent_OwnModel(NewMode: TWindowMode; mix: Integer);
     31    procedure ShowNewContent_OwnUnit(NewMode: TWindowMode; uix: Integer);
     32    procedure ShowNewContent_EnemyUnit(NewMode: TWindowMode; euix: Integer);
     33    procedure ShowNewContent_EnemyLoc(NewMode: TWindowMode; Loc: Integer);
     34    procedure ShowNewContent_EnemyModel(NewMode: TWindowMode; emix: Integer);
     35    procedure ShowNewContent_EnemyCity(NewMode: TWindowMode; Loc: Integer);
    3636
    3737  protected
    3838    mixShow, // for dkOwnModel
    39     uixShow, euixShow, ecixShow, UnitLoc, AgePrepared: integer;
     39    uixShow, euixShow, ecixShow, UnitLoc, AgePrepared: Integer;
    4040    // for dkEnemyUnit, euixShow=-1 ->
    4141    mox: ^TModelInfo; // for dkEnemyModel
     
    121121procedure TUnitStatDlg.FormShow(Sender: TObject);
    122122var
    123   owner, mix: integer;
    124   IsSpecialUnit: boolean;
     123  owner, mix: Integer;
     124  IsSpecialUnit: Boolean;
    125125begin
    126126  if Kind in [dkEnemyUnit, dkEnemyCityDefense, dkEnemyCity] then
     
    132132        euixShow := MyRO.nEnemyUn - 1;
    133133        while (euixShow >= 0) and (MyRO.EnemyUn[euixShow].Loc <> UnitLoc) do
    134           dec(euixShow);
    135         assert(euixShow >= 0);
     134          Dec(euixShow);
     135        Assert(euixShow >= 0);
    136136      end;
    137137      with MyRO.EnemyUn[euixShow] do
     
    148148      ecixShow := MyRO.nEnemyCity - 1;
    149149      while (ecixShow >= 0) and (MyRO.EnemyCity[ecixShow].Loc <> UnitLoc) do
    150         dec(ecixShow);
    151       assert(ecixShow >= 0);
     150        Dec(ecixShow);
     151      Assert(ecixShow >= 0);
    152152    end;
    153153  end;
     
    178178  end;
    179179
    180   SwitchBtn.Visible := not supervising and (Kind = dkOwnModel);
    181   ConscriptsBtn.Visible := not supervising and (Kind = dkOwnModel) and
     180  SwitchBtn.Visible := not Supervising and (Kind = dkOwnModel);
     181  ConscriptsBtn.Visible := not Supervising and (Kind = dkOwnModel) and
    182182    (MyRO.Tech[adConscription] >= tsApplicable) and
    183183    (MyModel[mixShow].Domain = dGround) and (MyModel[mixShow].Kind < mkScout);
    184   IsSpecialUnit := false;
     184  IsSpecialUnit := False;
    185185  if Kind in [dkEnemyCity, dkEnemyCityDefense] then
    186186    Caption := CityName(MyRO.EnemyCity[ecixShow].ID)
     
    190190      dkOwnModel:
    191191        begin
    192           owner := me;
     192          owner := Me;
    193193          mix := mixShow;
    194194          IsSpecialUnit := MyModel[mix].Kind >= $10;
     
    196196      dkOwnUnit:
    197197        begin
    198           owner := me;
     198          owner := Me;
    199199          mix := MyUn[uixShow].mix;
    200200          IsSpecialUnit := MyModel[mix].Kind >= $10;
     
    218218end;
    219219
    220 procedure TUnitStatDlg.ShowNewContent_OwnModel(NewMode: TWindowMode; mix: integer);
     220procedure TUnitStatDlg.ShowNewContent_OwnModel(NewMode: TWindowMode; mix: Integer);
    221221begin
    222222  Kind := dkOwnModel;
     
    225225end;
    226226
    227 procedure TUnitStatDlg.ShowNewContent_OwnUnit(NewMode: TWindowMode; uix: integer);
     227procedure TUnitStatDlg.ShowNewContent_OwnUnit(NewMode: TWindowMode; uix: Integer);
    228228begin
    229229  Kind := dkOwnUnit;
     
    232232end;
    233233
    234 procedure TUnitStatDlg.ShowNewContent_EnemyUnit(NewMode: TWindowMode; euix: integer);
     234procedure TUnitStatDlg.ShowNewContent_EnemyUnit(NewMode: TWindowMode; euix: Integer);
    235235begin
    236236  Kind := dkEnemyUnit;
     
    240240end;
    241241
    242 procedure TUnitStatDlg.ShowNewContent_EnemyLoc(NewMode: TWindowMode; Loc: integer);
     242procedure TUnitStatDlg.ShowNewContent_EnemyLoc(NewMode: TWindowMode; Loc: Integer);
    243243begin
    244244  Kind := dkEnemyUnit;
     
    248248end;
    249249
    250 procedure TUnitStatDlg.ShowNewContent_EnemyModel(NewMode: TWindowMode; emix: integer);
     250procedure TUnitStatDlg.ShowNewContent_EnemyModel(NewMode: TWindowMode; emix: Integer);
    251251begin
    252252  Kind := dkEnemyModel;
     
    255255end;
    256256
    257 procedure TUnitStatDlg.ShowNewContent_EnemyCity(NewMode: TWindowMode; Loc: integer);
     257procedure TUnitStatDlg.ShowNewContent_EnemyCity(NewMode: TWindowMode; Loc: Integer);
    258258begin
    259259  if MyMap[Loc] and fUnit <> 0 then
     
    286286  PPicture: ^TModelPicture;
    287287
    288   function IsToCount(emix: integer): boolean;
     288  function IsToCount(emix: Integer): Boolean;
    289289  var
    290290    PTestPicture: ^TModelPicture;
     
    294294      PTestPicture := @Tribe[MyRO.EnemyModel[emix].owner].ModelPicture
    295295        [MyRO.EnemyModel[emix].mix];
    296       result := (PPicture.HGr = PTestPicture.HGr) and
     296      Result := (PPicture.HGr = PTestPicture.HGr) and
    297297        (PPicture.pix = PTestPicture.pix) and
    298298        (ModelHash(mox^) = ModelHash(MyRO.EnemyModel[emix]));
    299299    end
    300300    else
    301       result := (MyRO.EnemyModel[emix].owner = mox.owner) and
     301      Result := (MyRO.EnemyModel[emix].owner = mox.owner) and
    302302        (MyRO.EnemyModel[emix].mix = mox.mix);
    303303  end;
    304304
    305   procedure FeatureBar(dst: TBitmap; x, y: integer; const mi: TModelInfo;
     305  procedure FeatureBar(dst: TBitmap; X, Y: Integer; const mi: TModelInfo;
    306306    T: TTexture);
    307307  var
    308     i, w, dx, num: integer;
    309     s: string;
    310   begin
    311     DarkGradient(dst.Canvas, x - 6, y + 1, 180, 1);
     308    I, W, dx, num: Integer;
     309    S: string;
     310  begin
     311    DarkGradient(dst.Canvas, X - 6, Y + 1, 180, 1);
    312312    with dst.Canvas do
    313313      if mi.Kind >= $10 then
    314314      begin
    315         s := Phrases.Lookup('UNITSPECIAL');
     315        S := Phrases.Lookup('UNITSPECIAL');
    316316        Font.Color := $000000;
    317         Textout(x - 1, y + 1, s);
     317        Textout(X - 1, Y + 1, S);
    318318        Font.Color := $B0B0B0;
    319         Textout(x - 2, y, s);
     319        Textout(X - 2, Y, S);
    320320      end
    321321      else
     
    323323        Font.Color := $000000;
    324324        dx := 2;
    325         for i := 3 to nFeature - 1 do
     325        for I := 3 to nFeature - 1 do
    326326        begin
    327327          num := 0;
    328           case i of
     328          case I of
    329329            mcSeaTrans:
    330330              if mi.Domain = dSea then
     
    342342                num := mi.TTrans;
    343343            mcFirstNonCap .. nFeature - 1:
    344               if mi.Cap and (1 shl (i - mcFirstNonCap)) <> 0 then
     344              if mi.Cap and (1 shl (I - mcFirstNonCap)) <> 0 then
    345345                num := 1
    346346          end;
    347347          if (num > 0) and
    348             ((i <> mcSE) or (mi.Cap and (1 shl (mcNP - mcFirstNonCap)) = 0))
     348            ((I <> mcSE) or (mi.Cap and (1 shl (mcNP - mcFirstNonCap)) = 0))
    349349          then
    350350          begin
    351351            if num > 1 then
    352352            begin
    353               s := IntToStr(num);
    354               w := TextWidth(s);
     353              S := IntToStr(num);
     354              W := TextWidth(S);
    355355              Brush.Color := $FFFFFF;
    356               FillRect(Rect(x - 3 + dx, y + 2, x + w - 1 + dx, y + 16));
     356              FillRect(Rect(X - 3 + dx, Y + 2, X + W - 1 + dx, Y + 16));
    357357              Brush.Style := bsClear;
    358               Textout(x - 3 + dx + 1, y, s);
    359               inc(dx, w + 1)
     358              Textout(X - 3 + dx + 1, Y, S);
     359              Inc(dx, W + 1)
    360360            end;
    361361            Brush.Color := $C0C0C0;
    362             FrameRect(Rect(x - 3 + dx, y + 2, x + 11 + dx, y + 16));
     362            FrameRect(Rect(X - 3 + dx, Y + 2, X + 11 + dx, Y + 16));
    363363            Brush.Style := bsClear;
    364             Sprite(dst, HGrSystem, x - 1 + dx, y + 4, 10, 10,
    365               66 + i mod 11 * 11, 137 + i div 11 * 11);
    366             inc(dx, 15)
     364            Sprite(dst, HGrSystem, X - 1 + dx, Y + 4, 10, 10,
     365              66 + I mod 11 * 11, 137 + I div 11 * 11);
     366            Inc(dx, 15)
    367367          end;
    368368        end;
     
    370370  end; { featurebar }
    371371
    372   procedure NumberBarS(dst: TBitmap; x, y: integer; Cap, s: string; T: TTexture);
    373   begin
    374     DLine(dst.Canvas, x - 2, x + 170, y + 16, T.ColorBevelShade, T.ColorBevelLight);
    375     LoweredTextOut(dst.Canvas, -1, T, x - 2, y, Cap);
    376     RisedTextout(dst.Canvas, x + 170 - BiColorTextWidth(dst.Canvas, s), y, s);
     372  procedure NumberBarS(dst: TBitmap; X, Y: Integer; Cap, S: string; T: TTexture);
     373  begin
     374    DLine(dst.Canvas, X - 2, X + 170, Y + 16, T.ColorBevelShade, T.ColorBevelLight);
     375    LoweredTextOut(dst.Canvas, -1, T, X - 2, Y, Cap);
     376    RisedTextout(dst.Canvas, X + 170 - BiColorTextWidth(dst.Canvas, S), Y, S);
    377377  end;
    378378
    379379var
    380   i, j, x, y, cix, uix, emix, InProd, Available, Destroyed, Loc, Cnt, yView,
    381     yTotal, yCaption: integer;
    382   s: string;
     380  I, J, X, Y, cix, uix, emix, InProd, Available, Destroyed, Loc, Cnt, yView,
     381    yTotal, yCaption: Integer;
     382  S: string;
    383383  ui: TUnitInfo;
    384384  mi: TModelInfo;
     
    389389    dkOwnModel:
    390390      begin
    391         BitBltCanvas(offscreen.Canvas, 0, 0, wCommon, hOwnModel,
     391        BitBltCanvas(Offscreen.Canvas, 0, 0, wCommon, hOwnModel,
    392392          Back.Canvas, 0, 0);
    393393        yView := 13;
     
    396396    dkEnemyModel:
    397397      begin
    398         BitBltCanvas(offscreen.Canvas, 0, 0, wCommon, hEnemyModel,
     398        BitBltCanvas(Offscreen.Canvas, 0, 0, wCommon, hEnemyModel,
    399399          Back.Canvas, wCommon, 0);
    400400        yView := 13;
     
    403403    dkEnemyUnit, dkOwnUnit:
    404404      begin
    405         BitBltCanvas(offscreen.Canvas, 0, 0, wCommon, hEnemyUnit,
     405        BitBltCanvas(Offscreen.Canvas, 0, 0, wCommon, hEnemyUnit,
    406406          Back.Canvas, 2 * wCommon, 0);
    407407        yView := 13;
     
    410410    dkEnemyCityDefense:
    411411      begin
    412         BitBltCanvas(offscreen.Canvas, 0, 0, wCommon, hEnemyCityDefense,
     412        BitBltCanvas(Offscreen.Canvas, 0, 0, wCommon, hEnemyCityDefense,
    413413          Back.Canvas, 3 * wCommon, 0);
    414414        yView := 171;
     
    417417    dkEnemyCity:
    418418      begin
    419         BitBltCanvas(offscreen.Canvas, 0, 0, wCommon, hEnemyCity,
     419        BitBltCanvas(Offscreen.Canvas, 0, 0, wCommon, hEnemyCity,
    420420          Back.Canvas, 4 * wCommon, 0);
    421421      end;
     
    427427  begin // show city defense facilities
    428428    Cnt := 0;
    429     for i := 0 to 3 do
    430       if MyRO.EnemyCity[ecixShow].Flags and (2 shl i) <> 0 then
    431         inc(Cnt);
    432     x := (wCommon - Cnt * xSizeSmall) div 2 - (Cnt - 1) * 2;
    433     for i := 0 to 3 do
    434       if MyRO.EnemyCity[ecixShow].Flags and (2 shl i) <> 0 then
    435       begin
    436         case i of
    437           0: j := imWalls;
    438           1: j := imCoastalFort;
    439           2: j := imMissileBat;
    440           3: j := imBunker
     429    for I := 0 to 3 do
     430      if MyRO.EnemyCity[ecixShow].Flags and (2 shl I) <> 0 then
     431        Inc(Cnt);
     432    X := (wCommon - Cnt * xSizeSmall) div 2 - (Cnt - 1) * 2;
     433    for I := 0 to 3 do
     434      if MyRO.EnemyCity[ecixShow].Flags and (2 shl I) <> 0 then
     435      begin
     436        case I of
     437          0: J := imWalls;
     438          1: J := imCoastalFort;
     439          2: J := imMissileBat;
     440          3: J := imBunker
    441441        end;
    442         Frame(offscreen.Canvas, x - 1, yImp - 1, x + xSizeSmall,
     442        Frame(Offscreen.Canvas, X - 1, yImp - 1, X + xSizeSmall,
    443443          yImp + ySizeSmall, MainTexture.ColorBevelLight,
    444444          MainTexture.ColorBevelShade);
    445         BitBltCanvas(offscreen.Canvas, x, yImp, xSizeSmall, ySizeSmall,
    446           SmallImp.Canvas, j mod 7 * xSizeSmall,
    447           (j + SystemIconLines * 7) div 7 * ySizeSmall);
    448         inc(x, xSizeSmall + 4);
     445        BitBltCanvas(Offscreen.Canvas, X, yImp, xSizeSmall, ySizeSmall,
     446          SmallImp.Canvas, J mod 7 * xSizeSmall,
     447          (J + SystemIconLines * 7) div 7 * ySizeSmall);
     448        Inc(X, xSizeSmall + 4);
    449449      end;
    450450  end;
     
    454454    PPicture := @Tribe[mox.owner].ModelPicture[mox.mix];
    455455    Available := 0;
    456     if G.Difficulty[me] = 0 then // supervisor -- count stacked units too
     456    if G.Difficulty[Me] = 0 then // supervisor -- count stacked units too
    457457      for Loc := 0 to G.lx * G.ly - 1 do
    458458      begin
    459459        if MyMap[Loc] and fUnit <> 0 then
    460460        begin
    461           Server(sGetUnits, me, Loc, Cnt);
     461          Server(sGetUnits, Me, Loc, Cnt);
    462462          for uix := 0 to Cnt - 1 do
    463463            if IsToCount(MyRO.EnemyUn[MyRO.nEnemyUn + uix].emix) then
    464               inc(Available);
     464              Inc(Available);
    465465        end;
    466466      end
     
    469469        if (MyRO.EnemyUn[uix].Loc >= 0) and IsToCount(MyRO.EnemyUn[uix].emix)
    470470        then
    471           inc(Available);
     471          Inc(Available);
    472472    Destroyed := 0;
    473473    for emix := 0 to MyRO.nEnemyModel - 1 do
    474474      if IsToCount(emix) then
    475         inc(Destroyed, MyRO.EnemyModel[emix].Lost);
     475        Inc(Destroyed, MyRO.EnemyModel[emix].Lost);
    476476  end
    477477  else
     
    480480    for uix := 0 to MyRO.nUn - 1 do
    481481      if (MyUn[uix].Loc >= 0) and (MyUn[uix].mix = mixShow) then
    482         inc(Available);
     482        Inc(Available);
    483483    InProd := 0;
    484484    for cix := 0 to MyRO.nCity - 1 do
    485485      if (MyCity[cix].Loc >= 0) and
    486486        (MyCity[cix].Project and (cpImp + cpIndex) = mixShow) then
    487         inc(InProd);
    488   end;
    489 
    490   offscreen.Canvas.Font.Assign(UniFont[ftSmall]);
     487        Inc(InProd);
     488  end;
     489
     490  Offscreen.Canvas.Font.Assign(UniFont[ftSmall]);
    491491  if Kind in [dkEnemyCityDefense, dkEnemyCity] then
    492492  begin
    493     NoMap.SetOutput(offscreen);
    494     NoMap.PaintCity(ClientWidth div 2, 53, MyRO.EnemyCity[ecixShow], false);
    495 
    496     s := Tribe[MyRO.EnemyCity[ecixShow].owner].TPhrase('UNITOWNER');
    497     LoweredTextOut(offscreen.Canvas, -1, MainTexture,
    498       (ClientWidth - BiColorTextWidth(offscreen.Canvas, s)) div 2, 105, s);
     493    NoMap.SetOutput(Offscreen);
     494    NoMap.PaintCity(ClientWidth div 2, 53, MyRO.EnemyCity[ecixShow], False);
     495
     496    S := Tribe[MyRO.EnemyCity[ecixShow].owner].TPhrase('UNITOWNER');
     497    LoweredTextOut(Offscreen.Canvas, -1, MainTexture,
     498      (ClientWidth - BiColorTextWidth(Offscreen.Canvas, S)) div 2, 105, S);
    499499  end;
    500500
     
    502502  begin // show unit stats
    503503    if Kind = dkOwnModel then
    504       MakeModelInfo(me, mixShow, MyModel[mixShow], mi)
     504      MakeModelInfo(Me, mixShow, MyModel[mixShow], mi)
    505505    else if Kind = dkOwnUnit then
    506506    begin
    507       MakeUnitInfo(me, MyUn[uixShow], ui);
    508       MakeModelInfo(me, MyUn[uixShow].mix, MyModel[MyUn[uixShow].mix], mi);
     507      MakeUnitInfo(Me, MyUn[uixShow], ui);
     508      MakeModelInfo(Me, MyUn[uixShow].mix, MyModel[MyUn[uixShow].mix], mi);
    509509    end
    510510    else
     
    522522          { Frame(offscreen.canvas,xView-1,yView-1,xView+64,yView+48,
    523523            MainTexture.ColorBevelShade,MainTexture.ColorBevelLight);
    524             RFrame(offscreen.canvas,xView-2,yView-2,xView+65,yView+49,
     524            RFrame(Offscreen.Canvas,xView-2,yView-2,xView+65,yView+49,
    525525            MainTexture.ColorBevelShade,MainTexture.ColorBevelLight); }
    526           with offscreen.Canvas do
     526          with Offscreen.Canvas do
    527527          begin
    528528            Brush.Color := HGrSystem.Data.Canvas.Pixels[98, 67];
    529             offscreen.Canvas.FillRect(Rect(xView, yView, xView + 64,
     529            Offscreen.Canvas.FillRect(Rect(xView, yView, xView + 64,
    530530              yView + 16));
    531531            Brush.Style := bsClear;
     
    534534          if MyMap[Loc] and fTerrain >= fForest then
    535535          begin
    536             x := 1 + 2 * (xxt * 2 + 1);
    537             y := 1 + yyt + 2 * (yyt * 3 + 1);
     536            X := 1 + 2 * (xxt * 2 + 1);
     537            Y := 1 + yyt + 2 * (yyt * 3 + 1);
    538538          end
    539539          else
    540540          begin
    541             x := integer(MyMap[Loc] and fTerrain) * (xxt * 2 + 1) + 1;
    542             y := 1 + yyt;
     541            X := Integer(MyMap[Loc] and fTerrain) * (xxt * 2 + 1) + 1;
     542            Y := 1 + yyt;
    543543          end;
    544           for j := -1 to 1 do
    545             for i := -1 to 1 do
    546               if (i + j) and 1 = 0 then
     544          for J := -1 to 1 do
     545            for I := -1 to 1 do
     546              if (I + J) and 1 = 0 then
    547547              begin
    548                 Sprite(Buffer, HGrTerrain, i * xxt, j * yyt, xxt * 2,
    549                   yyt * 2, x, y);
     548                Sprite(Buffer, HGrTerrain, I * xxt, J * yyt, xxt * 2,
     549                  yyt * 2, X, Y);
    550550                if MyMap[Loc] and (fTerrain or fSpecial) = fGrass or fSpecial1
    551551                then
    552                   Sprite(Buffer, HGrTerrain, i * xxt, j * yyt, xxt * 2, yyt * 2,
     552                  Sprite(Buffer, HGrTerrain, I * xxt, J * yyt, xxt * 2, yyt * 2,
    553553                    1 + 2 * (xxt * 2 + 1), 1 + yyt + 1 * (yyt * 3 + 1))
    554554                else if (MyMap[Loc] and fTerrain = fForest) and
    555555                  IsJungle(Loc div G.lx) then
    556                   Sprite(Buffer, HGrTerrain, i * xxt, j * yyt, xxt * 2, yyt * 2,
     556                  Sprite(Buffer, HGrTerrain, I * xxt, J * yyt, xxt * 2, yyt * 2,
    557557                    1 + 7 * (xxt * 2 + 1), 1 + yyt + 19 * (yyt * 3 + 1))
    558558                else if MyMap[Loc] and fTerrain >= fForest then
    559                   Sprite(Buffer, HGrTerrain, i * xxt, j * yyt, xxt * 2, yyt * 2,
     559                  Sprite(Buffer, HGrTerrain, I * xxt, J * yyt, xxt * 2, yyt * 2,
    560560                    1 + 7 * (xxt * 2 + 1),
    561                     1 + yyt + 2 * integer(2 + MyMap[Loc] and fTerrain - fForest)
     561                    1 + yyt + 2 * Integer(2 + MyMap[Loc] and fTerrain - fForest)
    562562                    * (yyt * 3 + 1));
    563563              end;
    564           BitBltCanvas(offscreen.Canvas, xView, yView + 16, 64, 32,
     564          BitBltCanvas(Offscreen.Canvas, xView, yView + 16, 64, 32,
    565565            Buffer.Canvas, 1, 0);
    566566
    567567          // show unit, experience and health
    568           Sprite(offscreen, HGr, xView, yView, 64, 48, pix mod 10 * 65 + 1,
     568          Sprite(Offscreen, HGr, xView, yView, 64, 48, pix mod 10 * 65 + 1,
    569569            pix div 10 * 49 + 1);
    570570          if Flags and unFortified <> 0 then
    571             Sprite(offscreen, HGrStdUnits, xView, yView, xxu * 2, yyu * 2,
     571            Sprite(Offscreen, HGrStdUnits, xView, yView, xxu * 2, yyu * 2,
    572572              1 + 6 * (xxu * 2 + 1), 1);
    573           FrameImage(offscreen.Canvas, HGrSystem.Data, xView - 20,
     573          FrameImage(Offscreen.Canvas, HGrSystem.Data, xView - 20,
    574574            yView + 5, 12, 14, 121 + Exp div ExpCost * 13, 28);
    575575          if Health < 100 then
    576576          begin
    577             s := IntToStr(Health) + '%';
    578             LightGradient(offscreen.Canvas, xView - 45, yView + 24, 38,
     577            S := IntToStr(Health) + '%';
     578            LightGradient(Offscreen.Canvas, xView - 45, yView + 24, 38,
    579579              (ColorOfHealth(Health) and $FEFEFE shr 2) * 3);
    580             RisedTextout(offscreen.Canvas, xView - 45 + 20 -
    581               BiColorTextWidth(offscreen.Canvas, s) div 2, yView + 23, s);
     580            RisedTextout(Offscreen.Canvas, xView - 45 + 20 -
     581              BiColorTextWidth(Offscreen.Canvas, S) div 2, yView + 23, S);
    582582          end;
    583583
    584584          if Kind = dkEnemyUnit then
    585585          begin
    586             s := Tribe[mox.owner].TPhrase('UNITOWNER');
    587             LoweredTextOut(offscreen.Canvas, -1, MainTexture,
    588               (ClientWidth - BiColorTextWidth(offscreen.Canvas, s)) div 2,
    589               yView + 80, s);
     586            S := Tribe[mox.owner].TPhrase('UNITOWNER');
     587            LoweredTextOut(Offscreen.Canvas, -1, MainTexture,
     588              (ClientWidth - BiColorTextWidth(Offscreen.Canvas, S)) div 2,
     589              yView + 80, S);
    590590          end;
    591591        end
    592592      else
    593593      begin
    594         FrameImage(offscreen.Canvas, BigImp, xView + 4, yView, 56, 40, 0, 0);
    595         Sprite(offscreen, HGr, xView, yView - 4, 64, 44, pix mod 10 * 65 + 1,
     594        FrameImage(Offscreen.Canvas, BigImp, xView + 4, yView, 56, 40, 0, 0);
     595        Sprite(Offscreen, HGr, xView, yView - 4, 64, 44, pix mod 10 * 65 + 1,
    596596          pix div 10 * 49 + 1);
    597597      end;
    598598
    599       DarkGradient(offscreen.Canvas, xTotal - 6, yTotal + 1, 180, 2);
    600       RisedTextout(offscreen.Canvas, xTotal - 2, yTotal,
     599      DarkGradient(Offscreen.Canvas, xTotal - 6, yTotal + 1, 180, 2);
     600      RisedTextout(Offscreen.Canvas, xTotal - 2, yTotal,
    601601        Phrases.Lookup('UNITSTRENGTH'));
    602       s := IntToStr(mi.Attack) + '/' + IntToStr(mi.Defense);
    603       RisedTextout(offscreen.Canvas,
    604         xTotal + 170 - BiColorTextWidth(offscreen.Canvas, s), yTotal, s);
    605       FeatureBar(offscreen, xTotal, yTotal + 19, mi, MainTexture);
    606       NumberBarS(offscreen, xTotal, yTotal + 38, Phrases.Lookup('UNITSPEED'),
     602      S := IntToStr(mi.Attack) + '/' + IntToStr(mi.Defense);
     603      RisedTextout(Offscreen.Canvas,
     604        xTotal + 170 - BiColorTextWidth(Offscreen.Canvas, S), yTotal, S);
     605      FeatureBar(Offscreen, xTotal, yTotal + 19, mi, MainTexture);
     606      NumberBarS(Offscreen, xTotal, yTotal + 38, Phrases.Lookup('UNITSPEED'),
    607607        MovementToString(mi.Speed), MainTexture);
    608       LoweredTextOut(offscreen.Canvas, -1, MainTexture, xTotal - 2, yTotal + 57,
     608      LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xTotal - 2, yTotal + 57,
    609609        Phrases.Lookup('UNITCOST'));
    610       DLine(offscreen.Canvas, xTotal - 2, xTotal + 170, yTotal + 57 + 16,
     610      DLine(Offscreen.Canvas, xTotal - 2, xTotal + 170, yTotal + 57 + 16,
    611611        MainTexture.ColorBevelShade, MainTexture.ColorBevelLight);
    612       if G.Difficulty[me] = 0 then
    613         s := IntToStr(mi.cost)
     612      if G.Difficulty[Me] = 0 then
     613        S := IntToStr(mi.cost)
    614614      else
    615         s := IntToStr(mi.cost * BuildCostMod[G.Difficulty[me]] div 12);
    616       RisedTextout(offscreen.Canvas,
    617         xTotal + 159 - BiColorTextWidth(offscreen.Canvas, s), yTotal + 57, s);
    618       Sprite(offscreen, HGrSystem, xTotal + 160, yTotal + 57 + 5, 10,
     615        S := IntToStr(mi.cost * BuildCostMod[G.Difficulty[Me]] div 12);
     616      RisedTextout(Offscreen.Canvas,
     617        xTotal + 159 - BiColorTextWidth(Offscreen.Canvas, S), yTotal + 57, S);
     618      Sprite(Offscreen, HGrSystem, xTotal + 160, yTotal + 57 + 5, 10,
    619619        10, 88, 115);
    620620
     
    624624        begin
    625625          if MyModel[mixShow].Kind = mkEnemyDeveloped then
    626             LoweredTextOut(offscreen.Canvas, -1, MainTexture, xTotal - 2,
     626            LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xTotal - 2,
    627627              (yTotal + StatDown - 19), Phrases.Lookup('UNITADOPT'))
    628628          else
    629             LoweredTextOut(offscreen.Canvas, -1, MainTexture, xTotal - 2,
     629            LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xTotal - 2,
    630630              (yTotal + StatDown - 19), Phrases.Lookup('UNITINTRO'));
    631           DLine(offscreen.Canvas, xTotal - 2, xTotal + 170,
     631          DLine(Offscreen.Canvas, xTotal - 2, xTotal + 170,
    632632            (yTotal + StatDown - 19) + 16, MainTexture.ColorTextShade,
    633633            MainTexture.ColorTextLight);
    634           s := TurnToString(MyModel[mixShow].IntroTurn);
    635           RisedTextout(offscreen.Canvas,
    636             xTotal + 170 - BiColorTextWidth(offscreen.Canvas, s),
    637             (yTotal + StatDown - 19), s);
     634          S := TurnToString(MyModel[mixShow].IntroTurn);
     635          RisedTextout(Offscreen.Canvas,
     636            xTotal + 170 - BiColorTextWidth(Offscreen.Canvas, S),
     637            (yTotal + StatDown - 19), S);
    638638        end;
    639639
    640         NumberBar(offscreen, xTotal, yTotal + StatDown,
     640        NumberBar(Offscreen, xTotal, yTotal + StatDown,
    641641          Phrases.Lookup('UNITBUILT'), MyModel[mixShow].Built, MainTexture);
    642642        if MyModel[mixShow].Lost > 0 then
    643           NumberBar(offscreen, xTotal, yTotal + StatDown + 19,
     643          NumberBar(Offscreen, xTotal, yTotal + StatDown + 19,
    644644            Phrases.Lookup('UNITLOST'), MyModel[mixShow].Lost, MainTexture);
    645645        if InProd > 0 then
    646           NumberBar(offscreen, xTotal, yTotal + StatDown + 57,
     646          NumberBar(Offscreen, xTotal, yTotal + StatDown + 57,
    647647            Phrases.Lookup('UNITINPROD'), InProd, MainTexture);
    648648        if Available > 0 then
    649           NumberBar(offscreen, xTotal, yTotal + StatDown + 38,
     649          NumberBar(Offscreen, xTotal, yTotal + StatDown + 38,
    650650            Phrases.Lookup('UNITAVAILABLE'), Available, MainTexture);
    651651
     
    674674      begin
    675675        if Destroyed > 0 then
    676           NumberBar(offscreen, xTotal, yTotal + StatDown - 19,
     676          NumberBar(Offscreen, xTotal, yTotal + StatDown - 19,
    677677            Phrases.Lookup('UNITDESTROYED'), Destroyed, MainTexture);
    678678        if Available > 0 then
    679           NumberBar(offscreen, xTotal, yTotal + StatDown,
     679          NumberBar(Offscreen, xTotal, yTotal + StatDown,
    680680            Phrases.Lookup('UNITKNOWN'), Available, MainTexture);
    681681      end;
     
    683683  end;
    684684
    685   offscreen.Canvas.Font.Assign(UniFont[ftNormal]);
     685  Offscreen.Canvas.Font.Assign(UniFont[ftNormal]);
    686686  case Kind of
    687687    dkOwnModel, dkEnemyModel:
     
    692692      yCaption := 79;
    693693  end;
    694   RisedTextout(offscreen.Canvas,
    695     (ClientWidth - BiColorTextWidth(offscreen.Canvas, Caption)) div 2,
     694  RisedTextout(Offscreen.Canvas,
     695    (ClientWidth - BiColorTextWidth(Offscreen.Canvas, Caption)) div 2,
    696696    yCaption, Caption);
    697697end;
  • trunk/LocalPlayer/Wonders.pas

    r442 r447  
    2323    Selection: Integer;
    2424    Center: TPoint;
    25     procedure DarkIcon(i: Integer);
    26     procedure Glow(i, GlowColor: Integer);
     25    procedure DarkIcon(I: Integer);
     26    procedure Glow(I, GlowColor: Integer);
    2727    procedure PaintBackgroundShape;
    2828  public
     
    116116  for Y := 0 to Height - 1 do begin
    117117    for X := 0 to Width - 1 do begin
    118       r := X * X * ((Height div 4) * (Height div 4)) + Y * Y * ((Width div 4) * (Width div 4));
     118      R := X * X * ((Height div 4) * (Height div 4)) + Y * Y * ((Width div 4) * (Width div 4));
    119119      ax := ((1 shl 16 div (Height div 4)) * (Width div 4)) * Y;
    120       if (r < ScaleToNative(8) * Height * Width * Width) and
    121         ((r >= (Height div 4) * (Height div 2) * (Width div 2) * (Width div 2)) and (ax < amax2 * X) and
     120      if (R < ScaleToNative(8) * Height * Width * Width) and
     121        ((R >= (Height div 4) * (Height div 2) * (Width div 2) * (Width div 2)) and (ax < amax2 * X) and
    122122        ((ax < amax0 * X) or (ax > amin2 * X)) or (ax > amin1 * X) and
    123123        ((ax < amax1 * X) or (ax > amin3 * X))) then begin
    124124        for ch := 0 to 2 do begin
    125           c := Line[0].Pixel^.Planes[ch] - Darken;
    126           if c < 0 then Line[0].Pixel^.Planes[ch] := 0
    127             else Line[0].Pixel^.Planes[ch] := c;
    128           c := Line[1].Pixel^.Planes[ch] - Darken;
    129           if c < 0 then Line[1].Pixel^.Planes[ch] := 0
    130             else Line[1].Pixel^.Planes[ch] := c;
    131           c := Line[2].Pixel^.Planes[ch] - Darken;
    132           if c < 0 then Line[2].Pixel^.Planes[ch] := 0
    133             else Line[2].Pixel^.Planes[ch] := c;
    134           c := Line[3].Pixel^.Planes[ch] - Darken;
    135           if c < 0 then Line[3].Pixel^.Planes[ch] := 0
    136             else Line[3].Pixel^.Planes[ch] := c;
     125          C := Line[0].Pixel^.Planes[ch] - Darken;
     126          if C < 0 then Line[0].Pixel^.Planes[ch] := 0
     127            else Line[0].Pixel^.Planes[ch] := C;
     128          C := Line[1].Pixel^.Planes[ch] - Darken;
     129          if C < 0 then Line[1].Pixel^.Planes[ch] := 0
     130            else Line[1].Pixel^.Planes[ch] := C;
     131          C := Line[2].Pixel^.Planes[ch] - Darken;
     132          if C < 0 then Line[2].Pixel^.Planes[ch] := 0
     133            else Line[2].Pixel^.Planes[ch] := C;
     134          C := Line[3].Pixel^.Planes[ch] - Darken;
     135          if C < 0 then Line[3].Pixel^.Planes[ch] := 0
     136            else Line[3].Pixel^.Planes[ch] := C;
    137137        end;
    138138      end;
     
    150150end;
    151151
    152 procedure TWondersDlg.DarkIcon(i: Integer);
    153 var
    154   X, Y, ch, x0Dst, y0Dst, x0Src, y0Src, darken, c: Integer;
     152procedure TWondersDlg.DarkIcon(I: Integer);
     153var
     154  X, Y, ch, x0Dst, y0Dst, x0Src, y0Src, darken, C: Integer;
    155155  Src, Dst: TPixelPointer;
    156156begin
    157157  Offscreen.BeginUpdate;
    158   x0Dst := ClientWidth div 2 - xSizeBig div 2 + RingPosition[i].X;
    159   y0Dst := ClientHeight div 2 - ySizeBig div 2 + RingPosition[i].Y;
    160   x0Src := (i mod 7) * xSizeBig;
    161   y0Src := (i div 7 + SystemIconLines) * ySizeBig;
     158  x0Dst := ClientWidth div 2 - xSizeBig div 2 + RingPosition[I].X;
     159  y0Dst := ClientHeight div 2 - ySizeBig div 2 + RingPosition[I].Y;
     160  x0Src := (I mod 7) * xSizeBig;
     161  y0Src := (I div 7 + SystemIconLines) * ySizeBig;
    162162  Src := PixelPointer(BigImp, ScaleToNative(x0Src), ScaleToNative(y0Src));
    163163  Dst := PixelPointer(Offscreen, ScaleToNative(x0Dst), ScaleToNative(y0Dst));
     
    167167        15 + (255 - Src.Pixel^.R) * 9) div 128;
    168168      for ch := 0 to 2 do begin
    169         c := Dst.Pixel^.Planes[ch] - Darken;
    170         if c < 0 then Dst.Pixel^.Planes[ch] := 0
    171           else Dst.Pixel^.Planes[ch] := c;
     169        C := Dst.Pixel^.Planes[ch] - Darken;
     170        if C < 0 then Dst.Pixel^.Planes[ch] := 0
     171          else Dst.Pixel^.Planes[ch] := C;
    172172      end;
    173173      Src.NextPixel;
     
    180180end;
    181181
    182 procedure TWondersDlg.Glow(i, GlowColor: Integer);
     182procedure TWondersDlg.Glow(I, GlowColor: Integer);
    183183begin
    184184  GlowFrame(Offscreen,
    185     ClientWidth div 2 - xSizeBig div 2 + RingPosition[i].X,
    186     ClientHeight div 2 - ySizeBig div 2 + RingPosition[i].Y,
     185    ClientWidth div 2 - xSizeBig div 2 + RingPosition[I].X,
     186    ClientHeight div 2 - ySizeBig div 2 + RingPosition[I].Y,
    187187    xSizeBig, ySizeBig, GlowColor);
    188188end;
Note: See TracChangeset for help on using the changeset viewer.