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

Legend:

Unmodified
Added
Removed
  • trunk/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;
Note: See TracChangeset for help on using the changeset viewer.