Changeset 447 for trunk/LocalPlayer/Term.pas
- Timestamp:
- May 19, 2022, 10:39:34 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LocalPlayer/Term.pas
r442 r447 232 232 procedure Timer1Timer(Sender: TObject); 233 233 procedure MapBoxMouseDown(Sender: TObject; Button: TMouseButton; 234 Shift: TShiftState; x, y: integer);234 Shift: TShiftState; X, Y: Integer); 235 235 procedure EOTClick(Sender: TObject); 236 236 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); 239 239 procedure mDisbandOrUtilizeClick(Sender: TObject); 240 240 procedure FormResize(Sender: TObject); 241 241 procedure PanelBtnClick(Sender: TObject); 242 procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);242 procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); 243 243 procedure Toggle(Sender: TObject); 244 244 procedure PanelBoxMouseMove(Sender: TObject; Shift: TShiftState; 245 x, y: integer);245 X, Y: Integer); 246 246 procedure PanelBoxMouseUp(Sender: TObject; Button: TMouseButton; 247 Shift: TShiftState; x, y: integer);247 Shift: TShiftState; X, Y: Integer); 248 248 procedure MapBoxMouseMove(Sender: TObject; Shift: TShiftState; 249 x, y: integer);249 X, Y: Integer); 250 250 procedure mShowClick(Sender: TObject); 251 251 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); 254 254 procedure FormMouseUp(Sender: TObject; Button: TMouseButton; 255 Shift: TShiftState; x, y: integer);255 Shift: TShiftState; X, Y: Integer); 256 256 procedure FormPaint(Sender: TObject); 257 257 procedure mRepClicked(Sender: TObject); … … 263 263 procedure mNamesClick(Sender: TObject); 264 264 procedure MapBtnClick(Sender: TObject); 265 procedure FormKeyUp(Sender: TObject; var Key: word; Shift: TShiftState);265 procedure FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); 266 266 procedure CreateUnitClick(Sender: TObject); 267 267 procedure mSoundOffClick(Sender: TObject); … … 324 324 NoMap: TIsoMap; 325 325 NoMapPanel: TIsoMap; 326 function ChooseUnusedTribe: integer;326 function ChooseUnusedTribe: Integer; 327 327 function DoJob(j0: Integer): Integer; 328 328 procedure GetTribeList; 329 329 procedure InitModule; 330 330 procedure DoneModule; 331 procedure InitTurn(NewPlayer: integer);331 procedure InitTurn(NewPlayer: Integer); 332 332 procedure SaveMenuItemsState; 333 333 procedure ScrollBarUpdate(Sender: TObject); … … 341 341 procedure FocusNextUnit(Dir: Integer = 1); 342 342 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); 352 352 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; 360 360 procedure EndNego; 361 function IsPanelPixel( x, y: integer): boolean;361 function IsPanelPixel(X, Y: Integer): Boolean; 362 362 procedure InitPopup(Popup: TPopupMenu); 363 363 procedure SetMapOptions; … … 365 365 procedure CheckTerrainBtnVisible; 366 366 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; 370 370 function GetCenterLoc: Integer; 371 371 procedure SetTileSizeCenter(TileSize: TTileSize); 372 372 procedure SetTileSize(TileSize: TTileSize; Loc: Integer; MapPos: TPoint); 373 procedure RectInvalidate(Left, Top, Rigth, Bottom: integer);373 procedure RectInvalidate(Left, Top, Rigth, Bottom: Integer); 374 374 procedure ShowEnemyShipChange(ShowShipChange: TShowShipChange); 375 procedure SmartRectInvalidate(Left, Top, Rigth, Bottom: integer);375 procedure SmartRectInvalidate(Left, Top, Rigth, Bottom: Integer); 376 376 procedure LoadSettings; 377 377 procedure SaveSettings; … … 381 381 procedure UpdateKeyShortcuts; 382 382 procedure SetFullScreen(Active: Boolean); 383 procedure PaintZoomedTile(dst: TBitmap; x, y, Loc: integer);383 procedure PaintZoomedTile(dst: TBitmap; X, Y, Loc: Integer); 384 384 public 385 385 UsedOffscreenWidth: Integer; … … 387 387 Offscreen: TBitmap; 388 388 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; 399 399 end; 400 400 … … 407 407 408 408 TTribeInfo = record 409 trix: integer;409 trix: Integer; 410 410 FileName: ShortString; 411 411 function GetCommandDataSize: Byte; … … 415 415 416 416 TCityNameInfo = record 417 ID: integer;417 ID: Integer; 418 418 NewName: ShortString; 419 419 function GetCommandDataSize: Byte; … … 423 423 424 424 TModelNameInfo = record 425 mix: integer;425 mix: Integer; 426 426 NewName: ShortString; 427 427 function GetCommandDataSize: Byte; … … 472 472 usToldNoReturn = $100; 473 473 usPersistent = usStay or usGoto or usEnhance or usRecover or 474 integer($FFFF0000);474 Integer($FFFF0000); 475 475 476 476 { model status flags } … … 486 486 adNexus = $803; 487 487 488 SpecialModelPictureCode: array [0 .. nSpecialModel - 1] of integer = (10,488 SpecialModelPictureCode: array [0 .. nSpecialModel - 1] of Integer = (10, 489 489 11, 40, 41, 21, 30, { 50,51, } 64, 74, { 71, } 73); 490 490 … … 499 499 500 500 nCityEventPriority = 16; 501 CityEventPriority: array [0 .. nCityEventPriority - 1] of integer =501 CityEventPriority: array [0 .. nCityEventPriority - 1] of Integer = 502 502 (chDisorder, chImprovementLost, chUnitLost, chAllImpsMade, chProduction, 503 503 chOldWonder, chNoSettlerProd, chPopDecrease, chProductionSabotaged, … … 574 574 DipMem: array [0 .. nPl - 1] of TDipMem; 575 575 576 function CityEventName( i: integer): string;577 function RoughCredibility(Credibility: integer): integer;578 579 function InitEnemyModel(emix: integer): boolean;576 function CityEventName(I: Integer): string; 577 function RoughCredibility(Credibility: Integer): Integer; 578 579 function InitEnemyModel(emix: Integer): Boolean; 580 580 procedure 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);581 procedure InitMyModel(mix: Integer; final: Boolean); 582 583 procedure ImpImage(ca: TCanvas; X, Y, iix: Integer; Government: Integer = -1; 584 IsControl: Boolean = False); 585 585 procedure HelpOnTerrain(Loc: Integer; NewMode: TWindowMode); 586 586 function AlignUp(Value, Alignment: Integer): Integer; … … 610 610 MoveTime = 300; // {time for moving a unit in ms} 611 611 WaitAfterShowMove = 32; 612 FastScrolling = false; // causes problems with overlapping windows612 FastScrolling = False; // causes problems with overlapping windows 613 613 614 614 nBrushTypes = 26; … … 648 648 CurrentMoveInfo: TCurrentMoveInfo; 649 649 650 function CityEventName( i: integer): string;651 begin 652 if i= 14 then // chAllImpsMade650 function CityEventName(I: Integer): string; 651 begin 652 if I = 14 then // chAllImpsMade 653 653 if not Phrases2FallenBackToEnglish then 654 result := Phrases2.Lookup('CITYEVENT_ALLIMPSMADE')654 Result := Phrases2.Lookup('CITYEVENT_ALLIMPSMADE') 655 655 else 656 result := Phrases.Lookup('CITYEVENTS', 1)656 Result := Phrases.Lookup('CITYEVENTS', 1) 657 657 else 658 result := Phrases.Lookup('CITYEVENTS', i);658 Result := Phrases.Lookup('CITYEVENTS', I); 659 659 end; 660 660 … … 666 666 TBuffer = array [0 .. 99999, 0 .. 2] of Integer; 667 667 var 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; 669 669 xdivider, ydivider: Integer; 670 670 Resampled: ^TBuffer; … … 682 682 PixelPtr := PixelPointer(BigImp, ScaleToNative(ix * xSizeBig), 683 683 ScaleToNative(Cut + iy * ySizeBig)); 684 for y:= 0 to ScaleToNative(ySizeBig - 2 * Cut) - 1 do begin685 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; 687 687 if ydivider > ySizeSmall then 688 688 ydivider := ySizeSmall; 689 for x:= 0 to ScaleToNative(xSizeBig) - 1 do begin690 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) * 692 692 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; 695 695 if xdivider > xSizeSmall then 696 696 xdivider := xSizeSmall; 697 697 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); 700 700 if xdivider < xSizeSmall then 701 Inc(Resampled[ir + 1, ch], c* (xSizeSmall - xdivider) *701 Inc(Resampled[ir + 1, ch], C * (xSizeSmall - xdivider) * 702 702 ydivider); 703 703 if ydivider < ySizeSmall then 704 704 Inc(Resampled[ir + nx, ch], 705 c* xdivider * (ySizeSmall - ydivider));705 C * xdivider * (ySizeSmall - ydivider)); 706 706 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) * 708 708 (ySizeSmall - ydivider)); 709 709 end; … … 719 719 SmallImp.BeginUpdate; 720 720 PixelPtr := PixelPointer(SmallImp); 721 for y:= 0 to ScaleToNative(ny) - 1 do begin722 for x:= 0 to ScaleToNative(nx) - 1 do begin721 for Y := 0 to ScaleToNative(ny) - 1 do begin 722 for X := 0 to ScaleToNative(nx) - 1 do begin 723 723 for ch := 0 to 2 do begin 724 724 Sum := 0; 725 725 Cnt := 0; 726 726 for dy := -1 to 1 do 727 if ((dy >= 0) or (ScaleFromNative( y) mod ySizeSmall > 0)) and728 ((dy <= 0) or (ScaleFromNative( y) mod ySizeSmall < ySizeSmall - 1)) then727 if ((dy >= 0) or (ScaleFromNative(Y) mod ySizeSmall > 0)) and 728 ((dy <= 0) or (ScaleFromNative(Y) mod ySizeSmall < ySizeSmall - 1)) then 729 729 for dx := -1 to 1 do 730 if ((dx >= 0) or (ScaleFromNative( x) mod xSizeSmall > 0)) and731 ((dx <= 0) or (ScaleFromNative( x) mod xSizeSmall < xSizeSmall - 1)) then730 if ((dx >= 0) or (ScaleFromNative(X) mod xSizeSmall > 0)) and 731 ((dx <= 0) or (ScaleFromNative(X) mod xSizeSmall < xSizeSmall - 1)) then 732 732 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]); 734 734 Inc(Cnt); 735 735 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 * 737 737 Sharpen) div (800 * xSizeBig * (ySizeBig - 2 * Cut)); 738 738 if Sum < 0 then Sum := 0; … … 748 748 end; 749 749 750 procedure ImpImage(ca: TCanvas; x, y, iix: integer; Government: integer;751 IsControl: boolean);750 procedure ImpImage(ca: TCanvas; X, Y, iix: Integer; Government: Integer; 751 IsControl: Boolean); 752 752 begin 753 753 if Government < 0 then … … 755 755 if (iix = imPalace) and (Government <> gAnarchy) then 756 756 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) 758 758 mod 7 * xSizeBig, (iix + SystemIconLines * 7) div 7 * ySizeBig, IsControl); 759 759 end; … … 778 778 { *** tribe management procedures *** } 779 779 780 function RoughCredibility(Credibility: integer): integer;780 function RoughCredibility(Credibility: Integer): Integer; 781 781 begin 782 782 case Credibility of 783 783 0 .. 69: 784 result := 0;784 Result := 0; 785 785 70 .. 89: 786 result := 1;786 Result := 1; 787 787 90 .. 99: 788 result := 2;788 Result := 2; 789 789 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; 792 end; 793 794 procedure ChooseModelPicture(P, mix, Code, Hash, Turn: Integer; 795 ForceNew, final: Boolean); 796 796 var 797 i: integer;797 I: Integer; 798 798 Picture: TModelPictureInfo; 799 IsNew: boolean;800 begin 801 Picture.trix := p;799 IsNew: Boolean; 800 begin 801 Picture.trix := P; 802 802 Picture.mix := mix; 803 if code = 74 then803 if Code = 74 then 804 804 begin // use correct pictures for slaves 805 if Tribe[ p].mixSlaves < 0 then806 if not TribeOriginal[ p] then807 Tribe[ p].mixSlaves := mix805 if Tribe[P].mixSlaves < 0 then 806 if not TribeOriginal[P] then 807 Tribe[P].mixSlaves := mix 808 808 else 809 809 begin 810 i := mix + pshl 16;811 Server(cSetSlaveIndex, 0, 0, i);810 I := mix + P shl 16; 811 Server(cSetSlaveIndex, 0, 0, I); 812 812 end; 813 813 if ToldSlavery = 1 then … … 817 817 Picture.Hash := 0; 818 818 Picture.GrName := 'StdUnits.png'; 819 IsNew := true;819 IsNew := True; 820 820 end 821 821 else 822 822 begin 823 823 Picture.Hash := Hash; 824 IsNew := Tribe[ p].ChooseModelPicture(Picture, code, Turn, ForceNew);824 IsNew := Tribe[P].ChooseModelPicture(Picture, Code, Turn, ForceNew); 825 825 end; 826 826 if final then 827 if not TribeOriginal[ p] then828 Tribe[ p].SetModelPicture(Picture, IsNew)827 if not TribeOriginal[P] then 828 Tribe[P].SetModelPicture(Picture, IsNew) 829 829 else if IsNew then 830 830 Server(CommandWithData(cSetNewModelPicture, Picture.GetCommandDataSize), … … 834 834 0, 0, Picture) 835 835 else 836 with Tribe[ p].ModelPicture[mix] do836 with Tribe[P].ModelPicture[mix] do 837 837 begin 838 838 HGr := LoadGraphicSet(Picture.GrName); … … 841 841 end; 842 842 843 function InitEnemyModel(emix: integer): boolean;843 function InitEnemyModel(emix: Integer): Boolean; 844 844 begin 845 845 if GameMode = cMovie then 846 846 begin 847 result := false;848 exit;847 Result := False; 848 Exit; 849 849 end; 850 850 with MyRO.EnemyModel[emix] do 851 851 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; 854 854 end; 855 855 856 856 procedure InitAllEnemyModels; 857 857 var 858 emix: integer;858 emix: Integer; 859 859 begin 860 860 for emix := 0 to MyRO.nEnemyModel - 1 do … … 864 864 end; 865 865 866 procedure InitMyModel(mix: integer; final: boolean);866 procedure InitMyModel(mix: Integer; final: Boolean); 867 867 var 868 868 mi: TModelInfo; 869 869 begin 870 870 if (GameMode = cMovie) and (MyModel[mix].Kind < $08) then 871 exit;871 Exit; 872 872 // 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); 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); 885 885 // check whether aircraft survived low-fuel warning 886 886 begin 887 assert(not supervising);887 Assert(not Supervising); 888 888 with MyUn[uix] do 889 889 if (Status and usToldNoReturn <> 0) and … … 893 893 end; 894 894 895 function CreateTribe( p: integer; FileName: string; Original: boolean): boolean;895 function CreateTribe(P: Integer; FileName: string; Original: Boolean): Boolean; 896 896 begin 897 897 FileName := LocalizedFilePath('Tribes' + DirectorySeparator + FileName + … … 903 903 end; 904 904 905 TribeOriginal[ p] := Original;906 Tribe[ p] := TTribe.Create(FileName);907 with Tribe[ p] do905 TribeOriginal[P] := Original; 906 Tribe[P] := TTribe.Create(FileName); 907 with Tribe[P] do 908 908 begin 909 909 if (GameMode = cNewGame) or not Original then 910 910 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; 919 919 end; 920 920 921 921 procedure TellNewContacts; 922 922 var 923 p1: integer;924 begin 925 if not supervising then923 p1: Integer; 924 begin 925 if not Supervising then 926 926 for p1 := 0 to nPl - 1 do 927 if (p1 <> me) and (1 shl p1 and MyData.ToldContact = 0) and927 if (p1 <> Me) and (1 shl p1 and MyData.ToldContact = 0) and 928 928 (1 shl p1 and MyRO.Alive <> 0) and (MyRO.Treaty[p1] > trNoContact) then 929 929 begin … … 935 935 procedure TellNewModels; 936 936 var 937 mix: integer;937 mix: Integer; 938 938 ModelNameInfo: TModelNameInfo; 939 939 begin 940 if supervising then941 exit;942 with Tribe[ me] do940 if Supervising then 941 Exit; 942 with Tribe[Me] do 943 943 while MyData.ToldModels < MyRO.nModel do 944 944 begin { new Unit class available } … … 951 951 end; 952 952 if not Assigned(ModelPicture[MyData.ToldModels].HGr) then 953 InitMyModel(MyData.ToldModels, true);953 InitMyModel(MyData.ToldModels, True); 954 954 { only run if no researched model } 955 955 with MessgExDlg do … … 983 983 (ModelNameInfo.GetCommandDataSize - 1 - CommandDataMaxSize), MaxInt); 984 984 Server(CommandWithData(cSetModelName, ModelNameInfo.GetCommandDataSize), 985 me, 0, ModelNameInfo);985 Me, 0, ModelNameInfo); 986 986 end; 987 987 end; … … 992 992 MyModel[mix].Status := MyModel[mix].Status or msObsolete; 993 993 end; 994 inc(MyData.ToldModels);994 Inc(MyData.ToldModels); 995 995 end; 996 996 end; … … 1017 1017 end; 1018 1018 1019 procedure TMainScreen.PaintZoomedTile(dst: TBitmap; x, y, Loc: integer);1020 1021 procedure TSprite(xDst, yDst, xSrc, ySrc: integer);1019 procedure TMainScreen.PaintZoomedTile(dst: TBitmap; X, Y, Loc: Integer); 1020 1021 procedure TSprite(xDst, yDst, xSrc, ySrc: Integer); 1022 1022 begin 1023 1023 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, 1025 1025 1 + xSrc * (xxt * 2 + 1), 1 + ySrc * (yyt * 3 + 1)); 1026 1026 end; 1027 1027 1028 procedure TSprite4(xSrc, ySrc: integer);1028 procedure TSprite4(xSrc, ySrc: Integer); 1029 1029 begin 1030 1030 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, 1032 1032 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, 1034 1034 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, 1036 1036 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, 1038 1038 1 + xSrc * (xxt * 2 + 1), 1 + yyt + ySrc * (yyt * 3 + 1)); 1039 1039 end; … … 1041 1041 1042 1042 var 1043 cix, ySrc, Tile: integer;1043 cix, ySrc, Tile: Integer; 1044 1044 begin 1045 1045 with NoMapPanel do begin … … 1055 1055 cix := MyRO.nCity - 1; 1056 1056 while (cix >= 0) and (MyCity[cix].Loc <> Loc) do 1057 dec(cix);1058 assert(cix >= 0);1057 Dec(cix); 1058 Assert(cix >= 0); 1059 1059 if MyCity[cix].Built[imSupermarket] > 0 then 1060 1060 Tile := Tile or tiFarm … … 1147 1147 end; 1148 1148 1149 function ChooseResearch: boolean;1149 function ChooseResearch: Boolean; 1150 1150 var 1151 ChosenResearch: integer;1151 ChosenResearch: Integer; 1152 1152 begin 1153 1153 if (MyData.FarTech <> adNone) and (MyRO.Tech[MyData.FarTech] >= tsApplicable) … … 1158 1158 repeat 1159 1159 ModalSelectDlg.ShowNewContent(wmModal, kAdvance); 1160 if ModalSelectDlg. result < 0 then1161 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; 1166 1166 if ChosenResearch = adMilitary then 1167 1167 begin 1168 1168 DraftDlg.ShowNewContent(wmModal); 1169 1169 if DraftDlg.ModalResult <> mrOK then 1170 Tribe[ me].ModelPicture[MyRO.nModel].HGr := nil;1170 Tribe[Me].ModelPicture[MyRO.nModel].HGr := nil; 1171 1171 end; 1172 1172 until (ChosenResearch <> adMilitary) or (DraftDlg.ModalResult = mrOK); 1173 1173 1174 1174 if ChosenResearch = adMilitary then 1175 InitMyModel(MyRO.nModel, true)1175 InitMyModel(MyRO.nModel, True) 1176 1176 else if ChosenResearch = adFar then 1177 1177 begin 1178 1178 ModalSelectDlg.ShowNewContent(wmModal, kFarAdvance); 1179 if ModalSelectDlg. result >= 0 then1180 if (ModalSelectDlg. result = adNone) or1181 (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^) < 1182 1182 rExecuted) then 1183 MyData.FarTech := ModalSelectDlg. result1183 MyData.FarTech := ModalSelectDlg.Result 1184 1184 else 1185 1185 begin 1186 ChosenResearch := ModalSelectDlg. result;1186 ChosenResearch := ModalSelectDlg.Result; 1187 1187 // can be researched immediately 1188 1188 MyData.FarTech := adNone; … … 1193 1193 MyData.FarTech := adNexus 1194 1194 else 1195 Server(sSetResearch, me, ChosenResearch, nil^);1195 Server(sSetResearch, Me, ChosenResearch, nil^); 1196 1196 ListDlg.TechChange; 1197 result := true;1197 Result := True; 1198 1198 end; 1199 1199 … … 1223 1223 (* ** client function handling ** *) 1224 1224 1225 function TMainScreen.DipCall(Command: integer): integer;1225 function TMainScreen.DipCall(Command: Integer): Integer; 1226 1226 var 1227 i: integer;1228 IsTreatyDeal: boolean;1229 begin 1230 result := Server(Command, me, 0, nil^);1231 if result >= rExecuted then1227 I: Integer; 1228 IsTreatyDeal: Boolean; 1229 begin 1230 Result := Server(Command, Me, 0, nil^); 1231 if Result >= rExecuted then 1232 1232 begin 1233 1233 if Command and $FF0F = scContact then 1234 1234 begin 1235 DipMem[ me].pContact := Command shr 4 and $F;1235 DipMem[Me].pContact := Command shr 4 and $F; 1236 1236 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]; 1243 1243 if Command = scDipCancelTreaty then 1244 1244 Play('CANCELTREATY') 1245 1245 else if Command = scDipAccept then 1246 1246 begin // remember delivered and received prices 1247 for i:= 0 to ReceivedOffer.nDeliver - 1 do1248 include(DipMem[me].ReceivedPrices, ReceivedOffer.Price[i] shr 24);1249 for i:= 0 to ReceivedOffer.nCost - 1 do1250 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 do1254 if ReceivedOffer.Price[ i] and opMask = opTreaty then1255 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; 1256 1256 if IsTreatyDeal then 1257 1257 Play('NEWTREATY') … … 1260 1260 end; 1261 1261 CityDlg.CloseAction := None; 1262 if G.RO[DipMem[ me].pContact] <> nil then1262 if G.RO[DipMem[Me].pContact] <> nil then 1263 1263 begin // close windows for next player 1264 1264 ApplyToVisibleForms(faClose); … … 1274 1274 end; 1275 1275 1276 function TMainScreen.OfferCall(var Offer: TOffer): integer;1277 begin 1278 result := Server(scDipOffer, me, 0, Offer);1279 if result >= rExecuted then1280 begin 1281 DipMem[ me].SentCommand := scDipOffer;1282 DipMem[ me].FormerTreaty := MyRO.Treaty[DipMem[me].pContact];1283 DipMem[ me].SentOffer := Offer;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; 1284 1284 CityDlg.CloseAction := None; 1285 if G.RO[DipMem[ me].pContact] <> nil then1285 if G.RO[DipMem[Me].pContact] <> nil then 1286 1286 begin // close windows for next player 1287 1287 ApplyToVisibleForms(faClose); … … 1297 1297 end; 1298 1298 1299 procedure TMainScreen.SetUnFocus(uix: integer);1299 procedure TMainScreen.SetUnFocus(uix: Integer); 1300 1300 var 1301 Loc0: integer;1302 begin 1303 assert(not((uix >= 0) and supervising));1301 Loc0: Integer; 1302 begin 1303 Assert(not((uix >= 0) and Supervising)); 1304 1304 if uix <> UnFocus then 1305 1305 begin 1306 DestinationMarkON := false;1306 DestinationMarkON := False; 1307 1307 PaintDestination; 1308 1308 if uix >= 0 then 1309 1309 UnStartLoc := MyUn[uix].Loc; 1310 BlinkON := false;1310 BlinkON := False; 1311 1311 BlinkTime := -1; 1312 1312 if UnFocus >= 0 then … … 1328 1328 procedure TMainScreen.CheckTerrainBtnVisible; 1329 1329 var 1330 Tile: integer;1330 Tile: Integer; 1331 1331 mox: ^TModel; 1332 1332 begin … … 1340 1340 end 1341 1341 else 1342 TerrainBtn.Visible := false;1342 TerrainBtn.Visible := False; 1343 1343 end; 1344 1344 … … 1348 1348 begin 1349 1349 MovieSpeed1Btn.Down := MovieSpeed = 1; 1350 MovieSpeed1Btn.Visible := true;1350 MovieSpeed1Btn.Visible := True; 1351 1351 MovieSpeed2Btn.Down := MovieSpeed = 2; 1352 MovieSpeed2Btn.Visible := true;1352 MovieSpeed2Btn.Visible := True; 1353 1353 MovieSpeed3Btn.Down := MovieSpeed = 3; 1354 MovieSpeed3Btn.Visible := true;1354 MovieSpeed3Btn.Visible := True; 1355 1355 MovieSpeed4Btn.Down := MovieSpeed = 4; 1356 MovieSpeed4Btn.Visible := true;1356 MovieSpeed4Btn.Visible := True; 1357 1357 end 1358 1358 else 1359 1359 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; 1364 1364 end; 1365 1365 end; … … 1375 1375 end; 1376 1376 1377 procedure TMainScreen.UpdateViews(UpdateCityScreen: boolean);1377 procedure TMainScreen.UpdateViews(UpdateCityScreen: Boolean); 1378 1378 begin 1379 1379 SumCities(TaxSum, ScienceSum); … … 1385 1385 end; 1386 1386 1387 procedure TMainScreen.SetAIName( p: integer; Name: string);1387 procedure TMainScreen.SetAIName(P: Integer; Name: string); 1388 1388 begin 1389 1389 if Name = '' then 1390 1390 begin 1391 if AILogo[ p] <> nil then1392 begin 1393 FreeAndNil(AILogo[ p]);1391 if AILogo[P] <> nil then 1392 begin 1393 FreeAndNil(AILogo[P]); 1394 1394 end; 1395 1395 end 1396 1396 else 1397 1397 begin 1398 if AILogo[ p] = nil then1399 AILogo[ p] := TBitmap.Create;1400 if not LoadGraphicFile(AILogo[ p], HomeDir + Name + '.png', [gfNoError]) then1401 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; 1405 end; 1406 1407 function TMainScreen.ContactRefused(P: Integer; Item: String): Boolean; 1408 1408 // return whether treaty was cancelled 1409 1409 var 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 then1415 begin 1416 SimpleMessage( s);1417 result := false;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; 1418 1418 end 1419 1419 else 1420 1420 begin 1421 case MyRO.Treaty[ p] of1421 case MyRO.Treaty[P] of 1422 1422 trPeace: 1423 s := s+ ' ' + Phrases.Lookup('FRCANCELQUERY_PEACE');1423 S := S + ' ' + Phrases.Lookup('FRCANCELQUERY_PEACE'); 1424 1424 trFriendlyContact: 1425 s := s+ ' ' + Phrases.Lookup('FRCANCELQUERY_FRIENDLY');1425 S := S + ' ' + Phrases.Lookup('FRCANCELQUERY_FRIENDLY'); 1426 1426 trAlliance: 1427 s := s+ ' ' + Phrases.Lookup('FRCANCELQUERY_ALLIANCE');1428 end; 1429 result := SimpleQuery(mkYesNo, s, 'NEGO_REJECTED') = mrOK;1430 if result then1427 S := S + ' ' + Phrases.Lookup('FRCANCELQUERY_ALLIANCE'); 1428 end; 1429 Result := SimpleQuery(mkYesNo, S, 'NEGO_REJECTED') = mrOK; 1430 if Result then 1431 1431 begin 1432 1432 Play('CANCELTREATY'); 1433 Server(sCancelTreaty, me, 0, nil^);1434 if MyRO.Treaty[ p] = trNone then1433 Server(sCancelTreaty, Me, 0, nil^); 1434 if MyRO.Treaty[P] = trNone then 1435 1435 CityOptimizer_BeginOfTurn; 1436 1436 // peace treaty was cancelled -- use formerly forbidden tiles 1437 MapValid := false;1437 MapValid := False; 1438 1438 PaintAllMaps; 1439 1439 end; … … 1443 1443 procedure TMainScreen.RememberPeaceViolation; 1444 1444 var 1445 uix, p1: integer;1445 uix, p1: Integer; 1446 1446 begin 1447 1447 MyData.PeaceEvaHappened := 0; … … 1451 1451 begin 1452 1452 p1 := MyRO.Territory[Loc]; 1453 if (p1 <> me) and (p1 >= 0) and1453 if (p1 <> Me) and (p1 >= 0) and 1454 1454 (MyRO.Turn = MyRO.EvaStart[p1] + (PeaceEvaTurns - 1)) then 1455 1455 MyData.PeaceEvaHappened := MyData.PeaceEvaHappened or (1 shl p1); … … 1489 1489 1490 1490 var 1491 i, cix, mix: integer;1492 need: boolean;1491 I, cix, mix: Integer; 1492 need: Boolean; 1493 1493 mi: TModelInfo; 1494 1494 begin 1495 1495 if (sbStart in Check) and not (sbStart in SoundPreloadDone) then begin 1496 for i:= 0 to nStartBlock - 1 do1497 PreparePlay(StartBlock[ i]);1496 for I := 0 to nStartBlock - 1 do 1497 PreparePlay(StartBlock[I]); 1498 1498 SoundPreloadDone := SoundPreloadDone + [sbStart]; 1499 1499 end; 1500 1500 if (sbWonder in Check) and not (sbWonder in SoundPreloadDone) then begin 1501 need := false;1502 for i:= 0 to nWonder - 1 do1503 if MyRO.Wonder[ i].CityID <> WonderNotBuiltYet then1504 need := true;1501 need := False; 1502 for I := 0 to nWonder - 1 do 1503 if MyRO.Wonder[I].CityID <> WonderNotBuiltYet then 1504 need := True; 1505 1505 if need then begin 1506 for i:= 0 to nWonderBlock - 1 do1507 PreparePlay(WonderBlock[ i]);1506 for I := 0 to nWonderBlock - 1 do 1507 PreparePlay(WonderBlock[I]); 1508 1508 SoundPreloadDone := SoundPreloadDone + [sbWonder]; 1509 1509 end; … … 1511 1511 if ((sbScience in Check) and not (sbScience in SoundPreloadDone)) and 1512 1512 (MyRO.Tech[adScience] >= tsApplicable) then begin 1513 for i:= 0 to nScienceBlock - 1 do1514 PreparePlay(ScienceBlock[ i]);1513 for I := 0 to nScienceBlock - 1 do 1514 PreparePlay(ScienceBlock[I]); 1515 1515 SoundPreloadDone := SoundPreloadDone + [sbScience]; 1516 1516 end; 1517 1517 if ((sbContact in Check) and not (sbContact in SoundPreloadDone)) and 1518 1518 (MyRO.nEnemyModel + MyRO.nEnemyCity > 0) then begin 1519 for i:= 0 to nContactBlock - 1 do1520 PreparePlay(ContactBlock[ i]);1519 for I := 0 to nContactBlock - 1 do 1520 PreparePlay(ContactBlock[I]); 1521 1521 SoundPreloadDone := SoundPreloadDone + [sbContact]; 1522 1522 end; … … 1529 1529 with MyCity[cix] do 1530 1530 if (Loc >= 0) and (Flags and CityRepMask <> 0) then 1531 for i:= 0 to 12 do1532 if 1 shl iand Flags and CityRepMask <> 0 then1533 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]); 1534 1534 for mix := 0 to MyRO.nModel - 1 do 1535 1535 with MyModel[mix] do 1536 1536 if Attack > 0 then 1537 1537 begin 1538 MakeModelInfo( me, mix, MyModel[mix], mi);1538 MakeModelInfo(Me, mix, MyModel[mix], mi); 1539 1539 PreparePlay(AttackSound(ModelCode(mi))); 1540 1540 end; … … 1547 1547 Color: TColor; 1548 1548 Name: string; 1549 ok: boolean;1549 ok: Boolean; 1550 1550 begin 1551 1551 UnusedTribeFiles.Clear; … … 1567 1567 end; 1568 1568 1569 function TMainScreen.ChooseUnusedTribe: integer;1569 function TMainScreen.ChooseUnusedTribe: Integer; 1570 1570 var 1571 i: Integer;1572 j: Integer;1571 I: Integer; 1572 J: Integer; 1573 1573 ColorDistance: Integer; 1574 1574 BestColorDistance: Integer; … … 1576 1576 CountBest: Integer; 1577 1577 begin 1578 assert(UnusedTribeFiles.Count > 0);1579 result := -1;1578 Assert(UnusedTribeFiles.Count > 0); 1579 Result := -1; 1580 1580 BestColorDistance := -1; 1581 for j:= 0 to UnusedTribeFiles.Count - 1 do1581 for J := 0 to UnusedTribeFiles.Count - 1 do 1582 1582 begin 1583 1583 ColorDistance := 250; // consider differences more than this infinite 1584 for i:= 0 to nPl - 1 do1585 if Tribe[ i] <> nil then1586 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 and1590 $FF - Tribe[ i].Color shr 8 and $FF) * 3 +1591 abs( integer(UnusedTribeFiles.Objects[j]) and1592 $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; 1593 1593 if TestColorDistance < ColorDistance then 1594 1594 ColorDistance := TestColorDistance; … … 1601 1601 if ColorDistance = BestColorDistance then 1602 1602 begin 1603 inc(CountBest);1603 Inc(CountBest); 1604 1604 if DelphiRandom(CountBest) = 0 then 1605 result := j;1605 Result := J; 1606 1606 end; 1607 1607 end; … … 1610 1610 procedure TMainScreen.ShowEnemyShipChange(ShowShipChange: TShowShipChange); 1611 1611 var 1612 i, TestCost, MostCost: integer;1613 Ship1Plus, Ship2Plus: boolean;1612 I, TestCost, MostCost: Integer; 1613 Ship1Plus, Ship2Plus: Boolean; 1614 1614 begin 1615 1615 with ShowShipChange, MessgExDlg do … … 1634 1634 begin 1635 1635 OpenSound := 'SHIP_TRADED'; 1636 Ship1Plus := false;1637 Ship2Plus := false;1638 for i:= 0 to nShipPart - 1 do1636 Ship1Plus := False; 1637 Ship2Plus := False; 1638 for I := 0 to nShipPart - 1 do 1639 1639 begin 1640 if Ship1Change[ i] > 0 then1641 Ship1Plus := true;1642 if Ship2Change[ i] > 0 then1643 Ship2Plus := true;1640 if Ship1Change[I] > 0 then 1641 Ship1Plus := True; 1642 if Ship2Change[I] > 0 then 1643 Ship2Plus := True; 1644 1644 end; 1645 1645 if Ship1Plus and Ship2Plus then … … 1668 1668 begin 1669 1669 MostCost := 0; 1670 for i:= 0 to nShipPart - 1 do1671 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; 1673 1673 if TestCost > MostCost then 1674 1674 begin 1675 1675 MostCost := TestCost; 1676 IconIndex := imShipComp + i;1676 IconIndex := imShipComp + I; 1677 1677 end; 1678 1678 end; … … 1686 1686 procedure TMainScreen.InitModule; 1687 1687 var 1688 i, j, Domain: integer;1688 I, J, Domain: Integer; 1689 1689 begin 1690 1690 { search icons for advances: } 1691 for i:= 0 to nAdv - 1 do1692 if iin FutureTech then1693 AdvIcon[ i] := 96 + i- futResearchTechnology1691 for I := 0 to nAdv - 1 do 1692 if I in FutureTech then 1693 AdvIcon[I] := 96 + I - futResearchTechnology 1694 1694 else 1695 1695 begin 1696 AdvIcon[ i] := -1;1696 AdvIcon[I] := -1; 1697 1697 for Domain := 0 to nDomains - 1 do 1698 for j:= 0 to nUpgrade - 1 do1699 if upgrade[Domain, j].Preq = ithen1700 if AdvIcon[ i] >= 0 then1701 AdvIcon[ i] := 851698 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 1702 1702 else 1703 AdvIcon[ i] := 86 + Domain;1704 for j:= 0 to nFeature - 1 do1705 if Feature[ j].Preq = ithen1703 AdvIcon[I] := 86 + Domain; 1704 for J := 0 to nFeature - 1 do 1705 if Feature[J].Preq = I then 1706 1706 for Domain := 0 to nDomains - 1 do 1707 if 1 shl Domain and Feature[ j].Domains <> 0 then1708 if (AdvIcon[ i] >= 0) and (AdvIcon[i] <> 86 + Domain) then1709 AdvIcon[ i] := 851707 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 1710 1710 else 1711 AdvIcon[ i] := 86 + Domain;1712 for j:= nWonder to nImp - 1 do1713 if Imp[ j].Preq = ithen1714 AdvIcon[ i] := j;1715 for j:= nWonder to nImp - 1 do1716 if (Imp[ j].Preq = i) and (Imp[j].Kind <> ikCommon) then1717 AdvIcon[ i] := j;1718 for j:= 0 to nJob - 1 do1719 if i = JobPreq[j] then1720 AdvIcon[ i] := 84;1721 for j:= 0 to nWonder - 1 do1722 if Imp[ j].Preq = ithen1723 AdvIcon[ i] := j;1724 if AdvIcon[ i] < 0 then1725 if AdvValue[ i] < 1000 then1726 AdvIcon[ i] := -71711 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 1727 1727 else 1728 AdvIcon[ i] := 24 + AdvValue[i] div 1000;1729 for j:= 2 to nGov - 1 do1730 if GovPreq[ j] = ithen1731 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; 1732 1732 end; 1733 1733 AdvIcon[adConscription] := 86 + dGround; 1734 1734 1735 1735 UnusedTribeFiles := tstringlist.Create; 1736 UnusedTribeFiles.Sorted := true;1736 UnusedTribeFiles.Sorted := True; 1737 1737 TribeNames := tstringlist.Create; 1738 1738 1739 1739 IsoEngine.Init(InitEnemyModel); 1740 1740 // non-default tile size is missing a file, switch to default 1741 MainMap.SetOutput( offscreen);1741 MainMap.SetOutput(Offscreen); 1742 1742 1743 1743 HGrStdUnits := LoadGraphicSet('StdUnits.png'); … … 1746 1746 InitSmallImp; 1747 1747 SoundPreloadDone := []; 1748 StartRunning := false;1749 StayOnTop_Ensured := false;1748 StartRunning := False; 1749 StayOnTop_Ensured := False; 1750 1750 1751 1751 sb := TPVScrollbar.Create(Self); … … 1761 1761 end; 1762 1762 1763 procedure TMainScreen.InitTurn(NewPlayer: integer);1763 procedure TMainScreen.InitTurn(NewPlayer: Integer); 1764 1764 const 1765 1765 nAdvBookIcon = 16; 1766 1766 AdvBookIcon: array [0 .. nAdvBookIcon - 1] of record Adv, 1767 Icon: integer end = ((Adv: adPolyTheism; Icon: woZeus),1767 Icon: Integer end = ((Adv: adPolyTheism; Icon: woZeus), 1768 1768 (Adv: adBronzeWorking; Icon: woColossus), (Adv: adMapMaking; 1769 1769 Icon: woLighthouse), (Adv: adPoetry; Icon: imTheater), (Adv: adMonotheism; … … 1777 1777 sbAll = [sbStart, sbWonder, sbScience, sbContact, sbTurn]; 1778 1778 var 1779 p1, i, ad, uix, cix, MoveOptions, MoveResult, Loc1,1779 p1, I, ad, uix, cix, MoveOptions, MoveResult, Loc1, 1780 1780 NewAgeCenterTo, Winners, NewGovAvailable, dx, 1781 dy: integer;1781 dy: Integer; 1782 1782 MoveAdviceData: TMoveAdviceData; 1783 1783 Picture: TModelPictureInfo; 1784 s, Item, Item2: string;1784 S, Item, Item2: string; 1785 1785 UpdatePanel, OwnWonder, ok, Stop, ShowCityList, WondersOnly, 1786 AllowCityScreen: boolean;1787 begin 1788 if IsMultiPlayerGame and (NewPlayer <> me) then1789 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) and1786 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 1796 1796 (G.RO[0].Happened and phShipComplete = 0) then 1797 1797 begin // inter player screen 1798 for i:= 0 to ControlCount - 1 do1799 if Controls[ i] is TButtonC then1800 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; 1802 1802 MainTexture.Age := -1; 1803 1803 with Panel.Canvas do … … 1815 1815 Invalidate; 1816 1816 1817 s:= TurnToString(G.RO[0].Turn);1818 if supervising then1819 SimpleMessage(Format(Phrases.Lookup('SUPERTURN'), [ s]))1817 S := TurnToString(G.RO[0].Turn); 1818 if Supervising then 1819 SimpleMessage(Format(Phrases.Lookup('SUPERTURN'), [S])) 1820 1820 else 1821 SimpleMessage(Format(Tribe[NewPlayer].TPhrase('TURN'), [ s]));1822 end; 1823 for i:= 0 to ControlCount - 1 do1824 if Controls[ i] is TButtonC then1825 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; 1826 1826 1827 1827 ItsMeAgain(NewPlayer); 1828 1828 MyData := G.RO[NewPlayer].Data; 1829 if not supervising then1829 if not Supervising then 1830 1830 SoundPreload(sbAll); 1831 if ( me = 0) and ((MyRO.Turn = 0) or (ClientMode = cResume)) then1831 if (Me = 0) and ((MyRO.Turn = 0) or (ClientMode = cResume)) then 1832 1832 Invalidate; // colorize empty space 1833 1833 1834 if not supervising then1834 if not Supervising then 1835 1835 begin 1836 1836 … … 1842 1842 else } 1843 1843 begin 1844 Age := GetAge( me);1844 Age := GetAge(Me); 1845 1845 if MainTexture.Age <> Age then begin 1846 1846 MainTexture.Age := Age; … … 1869 1869 NatStatDlg.CheckAge; 1870 1870 UnitStatDlg.CheckAge; 1871 HelpDlg.Difficulty := G.Difficulty[ me];1871 HelpDlg.Difficulty := G.Difficulty[Me]; 1872 1872 1873 1873 UnFocus := -1; 1874 1874 MarkCityLoc := -1; 1875 BlinkON := false;1875 BlinkON := False; 1876 1876 BlinkTime := -1; 1877 Tracking := false;1878 TurnComplete := false;1877 Tracking := False; 1878 TurnComplete := False; 1879 1879 1880 1880 if (ToldSlavery < 0) or … … 1896 1896 Hash := 0; 1897 1897 GrName := 'StdUnits.png'; 1898 Tribe[p1].SetModelPicture(Picture, true);1898 Tribe[p1].SetModelPicture(Picture, True); 1899 1899 end; 1900 1900 end; 1901 1901 1902 if not supervising and (ClientMode = cTurn) then1902 if not Supervising and (ClientMode = cTurn) then 1903 1903 begin 1904 1904 for cix := 0 to MyRO.nCity - 1 do … … 1915 1915 if ClientMode = cMovieTurn then 1916 1916 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; 1920 1920 EOT.Hint := Phrases.Lookup('BTN_STOP'); 1921 EOT.Visible := true;1921 EOT.Visible := True; 1922 1922 end 1923 1923 else if ClientMode < scContact then … … 1926 1926 UnitBtn.Visible := UnFocus >= 0; 1927 1927 CheckTerrainBtnVisible; 1928 TurnComplete := supervising;1928 TurnComplete := Supervising; 1929 1929 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; 1931 1931 end 1932 1932 else 1933 1933 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; 1937 1937 EOT.Hint := Phrases.Lookup('BTN_NEGO'); 1938 EOT.Visible := true;1938 EOT.Visible := True; 1939 1939 end; 1940 1940 SetTroopLoc(-1); 1941 MapValid := false;1941 MapValid := False; 1942 1942 NewAgeCenterTo := 0; 1943 if ((MyRO.Turn = 0) and not supervising or IsMultiPlayerGame or1943 if ((MyRO.Turn = 0) and not Supervising or IsMultiPlayerGame or 1944 1944 (ClientMode = cResume)) and (MyRO.nCity > 0) then 1945 1945 begin … … 1986 1986 begin 1987 1987 OpenSound := 'MSG_GAMEOVER'; 1988 MessgText := Tribe[ me].TPhrase('GAMEOVER');1988 MessgText := Tribe[Me].TPhrase('GAMEOVER'); 1989 1989 IconKind := mikBigIcon; 1990 1990 IconIndex := 8; … … 1997 1997 begin 1998 1998 Winners := Winners or 1 shl p1; 1999 for i:= 0 to nShipPart - 1 do2000 if MyRO.Ship[p1].Parts[ i] < ShipNeed[i] then1999 for I := 0 to nShipPart - 1 do 2000 if MyRO.Ship[p1].Parts[I] < ShipNeed[I] then 2001 2001 Winners := Winners and not(1 shl p1); 2002 2002 end; 2003 assert(Winners <> 0);2004 if Winners and (1 shl me) <> 0 then2003 Assert(Winners <> 0); 2004 if Winners and (1 shl Me) <> 0 then 2005 2005 begin 2006 s:= '';2006 S := ''; 2007 2007 for p1 := 0 to nPl - 1 do 2008 if (p1 <> me) and (1 shl p1 and Winners <> 0) then2009 if s= '' then2010 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') 2011 2011 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')]); 2014 2014 2015 2015 OpenSound := 'MSG_YOUWIN'; 2016 MessgText := Tribe[ me].TPhrase('MYSPACESHIP');2017 if s<> '' then2016 MessgText := Tribe[Me].TPhrase('MYSPACESHIP'); 2017 if S <> '' then 2018 2018 MessgText := MessgText + '\' + 2019 Format(Phrases.Lookup('SHAREDWIN'), [ s]);2019 Format(Phrases.Lookup('SHAREDWIN'), [S]); 2020 2020 IconKind := mikBigIcon; 2021 2021 IconIndex := 9; … … 2023 2023 else 2024 2024 begin 2025 assert(me = 0);2025 Assert(Me = 0); 2026 2026 OpenSound := 'MSG_GAMEOVER'; 2027 2027 MessgText := ''; … … 2035 2035 else { if MyRO.Happened and fTimeUp<>0 then } 2036 2036 begin 2037 assert(me = 0);2037 Assert(Me = 0); 2038 2038 OpenSound := 'MSG_GAMEOVER'; 2039 if not supervising then2040 MessgText := Tribe[ me].TPhrase('TIMEUP')2039 if not Supervising then 2040 MessgText := Tribe[Me].TPhrase('TIMEUP') 2041 2041 else 2042 2042 MessgText := Phrases.Lookup('TIMEUPSUPER'); … … 2050 2050 p1 := 0; 2051 2051 while (p1 < nPl - 1) and (Winners and (1 shl p1) = 0) do 2052 inc(p1);2052 Inc(p1); 2053 2053 if MyRO.Happened and phShipComplete = 0 then 2054 2054 DiaDlg.ShowNewContent_Charts(wmModal); 2055 2055 end; 2056 TurnComplete := true;2057 exit;2058 end; 2059 if not supervising and (1 shl me and MyRO.Alive = 0) then2060 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; 2063 2063 end; 2064 2064 2065 2065 if (ClientMode = cContinue) and 2066 (DipMem[ me].SentCommand and $FF0F = scContact) then2066 (DipMem[Me].SentCommand and $FF0F = scContact) then 2067 2067 // contact was refused 2068 if MyRO.Treaty[DipMem[ me].pContact] >= trPeace then2069 ContactRefused(DipMem[ me].pContact, 'FRREJECTED')2068 if MyRO.Treaty[DipMem[Me].pContact] >= trPeace then 2069 ContactRefused(DipMem[Me].pContact, 'FRREJECTED') 2070 2070 else 2071 SoundMessage(Tribe[DipMem[ me].pContact].TPhrase('FRREJECTED'),2071 SoundMessage(Tribe[DipMem[Me].pContact].TPhrase('FRREJECTED'), 2072 2072 'NEGO_REJECTED'); 2073 2073 2074 if not supervising and (Age > MyData.ToldAge) and2074 if not Supervising and (Age > MyData.ToldAge) and 2075 2075 ((Age > 0) or (ClientMode <> cMovieTurn)) then 2076 2076 with MessgExDlg do … … 2080 2080 if Phrases2FallenBackToEnglish then 2081 2081 begin 2082 s := Tribe[me].TPhrase('AGE0');2082 S := Tribe[Me].TPhrase('AGE0'); 2083 2083 MessgText := 2084 Format( s, [TurnToString(MyRO.Turn), CityName(MyCity[0].ID)]);2084 Format(S, [TurnToString(MyRO.Turn), CityName(MyCity[0].ID)]); 2085 2085 end 2086 2086 else 2087 2087 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)]); 2090 2090 end; 2091 2091 end 2092 2092 else 2093 2093 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)]); 2096 2096 end; 2097 2097 IconKind := mikAge; … … 2115 2115 begin 2116 2116 OpenSound := 'MSG_EXTINCT'; 2117 s:= Tribe[p1].TPhrase('EXTINCT');2118 MessgText := Format( s, [TurnToString(MyRO.Turn)]);2119 if MyRO.Alive = 1 shl me then2117 S := Tribe[p1].TPhrase('EXTINCT'); 2118 MessgText := Format(S, [TurnToString(MyRO.Turn)]); 2119 if MyRO.Alive = 1 shl Me then 2120 2120 MessgText := MessgText + Phrases.Lookup('EXTINCTALL'); 2121 2121 Kind := mkOk; … … 2124 2124 ShowModal; 2125 2125 end; 2126 if (ClientMode <> cMovieTurn) and not supervising then2126 if (ClientMode <> cMovieTurn) and not Supervising then 2127 2127 DiaDlg.ShowNewContent_Charts(wmModal); 2128 2128 end; 2129 2129 2130 2130 // tell changes of own credibility 2131 if not supervising then2131 if not Supervising then 2132 2132 begin 2133 2133 if RoughCredibility(MyRO.Credibility) <> … … 2136 2136 if RoughCredibility(MyRO.Credibility) > 2137 2137 RoughCredibility(MyData.ToldOwnCredibility) then 2138 s:= Phrases.Lookup('CREDUP')2138 S := Phrases.Lookup('CREDUP') 2139 2139 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', 2142 2142 RoughCredibility(MyRO.Credibility))]), ''); 2143 2143 end; … … 2145 2145 end; 2146 2146 2147 for i:= 0 to nWonder - 1 do2148 begin 2149 OwnWonder := false;2147 for I := 0 to nWonder - 1 do 2148 begin 2149 OwnWonder := False; 2150 2150 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) 2152 2152 then 2153 OwnWonder := true;2154 if MyRO.Wonder[ i].CityID <> MyData.ToldWonders[i].CityID then2155 begin 2156 if MyRO.Wonder[ i].CityID = WonderDestroyed then2153 OwnWonder := True; 2154 if MyRO.Wonder[I].CityID <> MyData.ToldWonders[I].CityID then 2155 begin 2156 if MyRO.Wonder[I].CityID = WonderDestroyed then 2157 2157 with MessgExDlg do 2158 2158 begin { tell about destroyed wonders } 2159 2159 OpenSound := 'WONDER_DESTROYED'; 2160 2160 MessgText := Format(Phrases.Lookup('WONDERDEST'), 2161 [Phrases.Lookup('IMPROVEMENTS', i)]);2161 [Phrases.Lookup('IMPROVEMENTS', I)]); 2162 2162 Kind := mkOkHelp; 2163 2163 HelpKind := hkImp; 2164 HelpNo := i;2164 HelpNo := I; 2165 2165 IconKind := mikImp; 2166 IconIndex := i;2166 IconIndex := I; 2167 2167 ShowModal; 2168 2168 end 2169 2169 else 2170 2170 begin 2171 if i= woManhattan then2172 if MyRO.Wonder[ i].EffectiveOwner > me then2171 if I = woManhattan then 2172 if MyRO.Wonder[I].EffectiveOwner > Me then 2173 2173 MyData.ColdWarStart := MyRO.Turn - 1 2174 2174 else … … 2177 2177 with MessgExDlg do 2178 2178 begin { tell about newly built wonders } 2179 if i= woManhattan then2179 if I = woManhattan then 2180 2180 begin 2181 2181 OpenSound := 'MSG_COLDWAR'; 2182 s := Tribe[MyRO.Wonder[i].EffectiveOwner].TPhrase('COLDWAR');2182 S := Tribe[MyRO.Wonder[I].EffectiveOwner].TPhrase('COLDWAR'); 2183 2183 end 2184 else if MyRO.Wonder[ i].EffectiveOwner >= 0 then2184 else if MyRO.Wonder[I].EffectiveOwner >= 0 then 2185 2185 begin 2186 2186 OpenSound := 'WONDER_BUILT'; 2187 s := Tribe[MyRO.Wonder[i].EffectiveOwner]2187 S := Tribe[MyRO.Wonder[I].EffectiveOwner] 2188 2188 .TPhrase('WONDERBUILT'); 2189 2189 end … … 2191 2191 begin 2192 2192 OpenSound := 'MSG_DEFAULT'; 2193 s:= Phrases.Lookup('WONDERBUILTEXP');2193 S := Phrases.Lookup('WONDERBUILTEXP'); 2194 2194 // already expired when built 2195 2195 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)]); 2198 2198 Kind := mkOkHelp; 2199 2199 HelpKind := hkImp; 2200 HelpNo := i;2200 HelpNo := I; 2201 2201 IconKind := mikImp; 2202 IconIndex := i;2202 IconIndex := I; 2203 2203 ShowModal; 2204 2204 end; 2205 2205 end; 2206 2206 end 2207 else if (MyRO.Wonder[ i].EffectiveOwner <> MyData.ToldWonders[i]2208 .EffectiveOwner) and (MyRO.Wonder[ i].CityID > WonderDestroyed) then2209 if MyRO.Wonder[ i].EffectiveOwner < 0 then2207 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 2210 2210 begin 2211 if i<> woMIR then2211 if I <> woMIR then 2212 2212 with MessgExDlg do 2213 2213 begin { tell about expired wonders } 2214 2214 OpenSound := 'WONDER_EXPIRED'; 2215 2215 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)]); 2218 2218 Kind := mkOkHelp; 2219 2219 HelpKind := hkImp; 2220 HelpNo := i;2220 HelpNo := I; 2221 2221 IconKind := mikImp; 2222 IconIndex := i;2222 IconIndex := I; 2223 2223 ShowModal; 2224 2224 end; 2225 2225 end 2226 else if (MyData.ToldWonders[ i].EffectiveOwner >= 0) and not OwnWonder2226 else if (MyData.ToldWonders[I].EffectiveOwner >= 0) and not OwnWonder 2227 2227 then 2228 2228 with MessgExDlg do 2229 2229 begin { tell about capture of wonders } 2230 2230 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)]); 2234 2234 Kind := mkOkHelp; 2235 2235 HelpKind := hkImp; 2236 HelpNo := i;2236 HelpNo := I; 2237 2237 IconKind := mikImp; 2238 IconIndex := i;2238 IconIndex := I; 2239 2239 ShowModal; 2240 2240 end; … … 2250 2250 end; // ClientMode<>cResume 2251 2251 MyData.ToldAlive := MyRO.Alive; 2252 move(MyRO.Wonder, MyData.ToldWonders, SizeOf(MyData.ToldWonders));2252 Move(MyRO.Wonder, MyData.ToldWonders, SizeOf(MyData.ToldWonders)); 2253 2253 2254 2254 NewGovAvailable := -1; … … 2274 2274 IconKind := mikBook; 2275 2275 IconIndex := -1; 2276 for i:= 0 to nAdvBookIcon - 1 do2277 if AdvBookIcon[ i].Adv = ad then2278 IconIndex := AdvBookIcon[ i].Icon;2276 for I := 0 to nAdvBookIcon - 1 do 2277 if AdvBookIcon[I].Adv = ad then 2278 IconIndex := AdvBookIcon[I].Icon; 2279 2279 ShowModal; 2280 2280 MyData.ToldTech[ad] := MyRO.Tech[ad]; 2281 for i:= gMonarchy to nGov - 1 do2282 if GovPreq[ i] = ad then2283 NewGovAvailable := i;2281 for I := gMonarchy to nGov - 1 do 2282 if GovPreq[I] = ad then 2283 NewGovAvailable := I; 2284 2284 end; 2285 2285 end; 2286 2286 2287 ShowCityList := false;2287 ShowCityList := False; 2288 2288 if ClientMode = cTurn then 2289 2289 begin … … 2291 2291 ChooseResearch; 2292 2292 2293 UpdatePanel := false;2293 UpdatePanel := False; 2294 2294 if MyRO.Happened and phChangeGov <> 0 then 2295 2295 begin 2296 2296 ModalSelectDlg.ShowNewContent(wmModal, kGov); 2297 2297 Play('NEWGOV'); 2298 Server(sSetGovernment, me, ModalSelectDlg.result, nil^);2298 Server(sSetGovernment, Me, ModalSelectDlg.Result, nil^); 2299 2299 CityOptimizer_BeginOfTurn; 2300 UpdatePanel := true;2300 UpdatePanel := True; 2301 2301 end; 2302 2302 end; // ClientMode=cTurn 2303 2303 2304 if not supervising and ((ClientMode = cTurn) or (ClientMode = cMovieTurn))2304 if not Supervising and ((ClientMode = cTurn) or (ClientMode = cMovieTurn)) 2305 2305 then 2306 2306 for cix := 0 to MyRO.nCity - 1 do … … 2312 2312 begin 2313 2313 // tell what happened in cities 2314 for WondersOnly := true downto false do2314 for WondersOnly := True downto False do 2315 2315 for cix := 0 to MyRO.nCity - 1 do 2316 2316 with MyCity[cix] do … … 2323 2323 begin { tell about newly built wonder } 2324 2324 OpenSound := 'WONDER_BUILT'; 2325 s := Tribe[me].TPhrase('WONDERBUILTOWN');2325 S := Tribe[Me].TPhrase('WONDERBUILTOWN'); 2326 2326 MessgText := 2327 Format( s, [Phrases.Lookup('IMPROVEMENTS',2327 Format(S, [Phrases.Lookup('IMPROVEMENTS', 2328 2328 Project0 and cpIndex), CityName(ID)]); 2329 2329 Kind := mkOkHelp; … … 2334 2334 ShowModal; 2335 2335 end; 2336 if not supervising and (ClientMode = cTurn) then2336 if not Supervising and (ClientMode = cTurn) then 2337 2337 begin 2338 AllowCityScreen := true;2338 AllowCityScreen := True; 2339 2339 if (Status and 7 <> 0) and 2340 2340 (Project and (cpImp + cpIndex) = cpImp + imTrGoods) then … … 2342 2342 begin 2343 2343 if AutoBuild(cix, MyData.ImpOrder[Status and 7 - 1]) then 2344 AllowCityScreen := false2344 AllowCityScreen := False 2345 2345 else if Flags and chProduction <> 0 then 2346 2346 Flags := (Flags and not chProduction) or chAllImpsMade … … 2370 2370 CityDlg.ShowNewContent(wmModal, MyCity[cix].Loc, 2371 2371 Flags and CityRepMask); 2372 UpdatePanel := true;2372 UpdatePanel := True; 2373 2373 end; 2374 2374 end … … 2376 2376 begin 2377 2377 if Flags and CityRepMask <> 0 then 2378 ShowCityList := true;2378 ShowCityList := True; 2379 2379 end; 2380 2380 end; … … 2396 2396 begin 2397 2397 Play('REVOLUTION'); 2398 Server(sRevolution, me, 0, nil^);2398 Server(sRevolution, Me, 0, nil^); 2399 2399 end; 2400 2400 end; … … 2430 2430 Application.ProcessMessages; 2431 2431 2432 if not supervising then2432 if not Supervising then 2433 2433 for uix := 0 to MyRO.nUn - 1 do 2434 2434 with MyUn[uix] do … … 2458 2458 begin // !!! Shinkansen 2459 2459 MoveResult := eOK; 2460 ok := true;2461 for i:= 0 to MoveAdviceData.nStep - 1 do2460 ok := True; 2461 for I := 0 to MoveAdviceData.nStep - 1 do 2462 2462 begin 2463 Loc1 := dLoc(Loc, MoveAdviceData.dx[ i],2464 MoveAdviceData.dy[ i]);2463 Loc1 := dLoc(Loc, MoveAdviceData.dx[I], 2464 MoveAdviceData.dy[I]); 2465 2465 if (MyMap[Loc1] and (fCity or fOwned) = fCity) 2466 2466 // don't capture cities during auto move … … 2468 2468 // don't attack during auto move 2469 2469 begin 2470 ok := false;2470 ok := False; 2471 2471 Break 2472 2472 end … … 2475 2475 if (Loc1 = MoveAdviceData.ToLoc) or 2476 2476 (MoveAdviceData.ToLoc = maNextCity) and 2477 (MyMap[dLoc(Loc, MoveAdviceData.dx[ i],2478 MoveAdviceData.dy[ i])] and fCity <> 0) then2477 (MyMap[dLoc(Loc, MoveAdviceData.dx[I], 2478 MoveAdviceData.dy[I])] and fCity <> 0) then 2479 2479 MoveOptions := muAutoNoWait 2480 2480 else 2481 2481 MoveOptions := 0; 2482 MoveResult := MoveUnit(MoveAdviceData.dx[ i],2483 MoveAdviceData.dy[ i], MoveOptions);2482 MoveResult := MoveUnit(MoveAdviceData.dx[I], 2483 MoveAdviceData.dy[I], MoveOptions); 2484 2484 if (MoveResult < rExecuted) or (MoveResult = eEnemySpotted) 2485 2485 then 2486 2486 begin 2487 ok := false;2487 ok := False; 2488 2488 Break 2489 2489 end; … … 2497 2497 begin 2498 2498 MoveResult := eOK; 2499 Stop := true;2499 Stop := True; 2500 2500 end; 2501 2501 … … 2520 2520 end; // ClientMode=cTurn 2521 2521 2522 HaveStrategyAdvice := false;2522 HaveStrategyAdvice := False; 2523 2523 // (GameMode<>cMovie) and not supervising 2524 2524 // and AdvisorDlg.HaveStrategyAdvice; 2525 GoOnPhase := true;2526 if supervising or (GameMode = cMovie) then2525 GoOnPhase := True; 2526 if Supervising or (GameMode = cMovie) then 2527 2527 begin 2528 2528 SetTroopLoc(-1); … … 2539 2539 SetUnFocus(-1) 2540 2540 else 2541 NextUnit(-1, false);2541 NextUnit(-1, False); 2542 2542 if UnFocus < 0 then 2543 2543 begin … … 2556 2556 end; 2557 2557 2558 procedure TMainScreen.Client(Command, NewPlayer: integer; var Data);2558 procedure TMainScreen.Client(Command, NewPlayer: Integer; var Data); 2559 2559 var 2560 i, j, p1, mix, ToLoc, AnimationSpeed, ShowMoveDomain, cix, ecix: integer;2560 I, J, p1, mix, ToLoc, AnimationSpeed, ShowMoveDomain, cix, ecix: Integer; 2561 2561 Color: TColor; 2562 Name, s: string;2562 Name, S: string; 2563 2563 TribeInfo: TTribeInfo; 2564 2564 mi: TModelInfo; 2565 SkipTurn, IsAlpine, IsTreatyDeal: boolean;2565 SkipTurn, IsAlpine, IsTreatyDeal: Boolean; 2566 2566 begin 2567 2567 case Command of 2568 2568 cTurn, cResume, cContinue, cMovieTurn, scContact, scDipStart .. scDipBreak: 2569 2569 begin 2570 supervising := G.Difficulty[NewPlayer] = 0;2570 Supervising := G.Difficulty[NewPlayer] = 0; 2571 2571 ArrangeMidPanel; 2572 2572 end … … 2574 2574 case Command of 2575 2575 cDebugMessage: 2576 LogDlg.Add(NewPlayer, G.RO[0].Turn, pchar(@Data));2576 LogDlg.Add(NewPlayer, G.RO[0].Turn, PChar(@Data)); 2577 2577 2578 2578 cShowNego: 2579 2579 with TShowNegoData(Data) do 2580 2580 begin 2581 s:= Format('P%d to P%d: ', [pSender, pTarget]);2581 S := Format('P%d to P%d: ', [pSender, pTarget]); 2582 2582 if (Action = scDipOffer) and (Offer.nDeliver + Offer.nCost > 0) then 2583 2583 begin 2584 s := s+ 'Offer ';2585 for i:= 0 to Offer.nDeliver + Offer.nCost - 1 do2584 S := S + 'Offer '; 2585 for I := 0 to Offer.nDeliver + Offer.nCost - 1 do 2586 2586 begin 2587 if i= Offer.nDeliver then2588 s := s+ ' for '2589 else if i> 0 then2590 s := s+ '+';2591 case Offer.Price[ i] and opMask of2587 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 2592 2592 opChoose: 2593 s := s+ 'Price of choice';2593 S := S + 'Price of choice'; 2594 2594 opCivilReport: 2595 s := s+ 'State report';2595 S := S + 'State report'; 2596 2596 opMilReport: 2597 s := s+ 'Military report';2597 S := S + 'Military report'; 2598 2598 opMap: 2599 s := s+ 'Map';2599 S := S + 'Map'; 2600 2600 opTreaty: 2601 s := s+ 'Treaty';2601 S := S + 'Treaty'; 2602 2602 opShipParts: 2603 s := s+ 'Ship part';2603 S := S + 'Ship part'; 2604 2604 opMoney: 2605 s := s + IntToStr(Offer.Price[i] and $FFFFFF) + 'o';2605 S := S + IntToStr(Offer.Price[I] and $FFFFFF) + 'o'; 2606 2606 opTribute: 2607 s := s + IntToStr(Offer.Price[i] and $FFFFFF) + 'o tribute';2607 S := S + IntToStr(Offer.Price[I] and $FFFFFF) + 'o tribute'; 2608 2608 opTech: 2609 s := s + Phrases.Lookup('ADVANCES', Offer.Price[i] and $FFFFFF);2609 S := S + Phrases.Lookup('ADVANCES', Offer.Price[I] and $FFFFFF); 2610 2610 opAllTech: 2611 s := s+ 'All advances';2611 S := S + 'All advances'; 2612 2612 opModel: 2613 s := s + Tribe[pSender].ModelName[Offer.Price[i] and $FFFFFF];2613 S := S + Tribe[pSender].ModelName[Offer.Price[I] and $FFFFFF]; 2614 2614 opAllModel: 2615 s := s+ 'All models';2615 S := S + 'All models'; 2616 2616 end; 2617 2617 end; 2618 LogDlg.Add(NewPlayer, G.RO[0].Turn, pchar(s));2618 LogDlg.Add(NewPlayer, G.RO[0].Turn, PChar(S)); 2619 2619 end 2620 2620 else if Action = scDipAccept then 2621 2621 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)); 2624 2624 end; 2625 2625 end; … … 2657 2657 AdvisorDlg.NewGame(Data); } 2658 2658 GenerateNames := mNames.Checked; 2659 GameOK := true;2659 GameOK := True; 2660 2660 G := TNewGameData(Data); 2661 me := -1;2661 Me := -1; 2662 2662 pLogo := -1; 2663 2663 ClientMode := -1; 2664 2664 SetMapOptions; 2665 2665 MainMap.pDebugMap := -1; 2666 idle := false;2666 Idle := False; 2667 2667 FillChar(Jump, SizeOf(Jump), 0); 2668 2668 if StartRunning then … … 2687 2687 ToldContact := 0; 2688 2688 ToldOwnCredibility := InitialCredibility; 2689 for i:= 0 to nPl - 1 do2690 if G.Difficulty[ i] > 0 then2691 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); 2692 2692 PeaceEvaHappened := 0; 2693 for i:= 0 to nWonder - 1 do2694 with ToldWonders[ i] do2693 for I := 0 to nWonder - 1 do 2694 with ToldWonders[I] do 2695 2695 begin 2696 2696 CityID := -1; … … 2719 2719 Age := 0; 2720 2720 MovieSpeed := 1; 2721 LogDlg.mSlot.Visible := true;2721 LogDlg.mSlot.Visible := True; 2722 2722 LogDlg.Host := self; 2723 2723 HelpDlg.ClearHistory; … … 2725 2725 2726 2726 MiniMap.Size := Point(G.lx, G.ly); 2727 for i:= 0 to nPl - 1 do2727 for I := 0 to nPl - 1 do 2728 2728 begin 2729 Tribe[ i] := nil;2730 TribeOriginal[ i] := false;2729 Tribe[I] := nil; 2730 TribeOriginal[I] := False; 2731 2731 end; 2732 2732 ToldSlavery := -1; 2733 RepaintOnResize := false;2734 Closable := false;2735 FirstMovieTurn := true;2733 RepaintOnResize := False; 2734 Closable := False; 2735 FirstMovieTurn := True; 2736 2736 2737 2737 MenuArea.Visible := GameMode <> cMovie; … … 2744 2744 if NewPlayer = 0 then 2745 2745 begin 2746 i:= 0;2746 I := 0; 2747 2747 for p1 := 0 to nPl - 1 do 2748 2748 if (G.Difficulty[p1] > 0) and (Tribe[p1] = nil) then 2749 inc(i);2750 if i> UnusedTribeFiles.Count then2749 Inc(I); 2750 if I > UnusedTribeFiles.Count then 2751 2751 begin 2752 GameOK := false;2752 GameOK := False; 2753 2753 SimpleMessage(Phrases.Lookup('TOOFEWTRIBES')); 2754 2754 end … … 2761 2761 TribeInfo.trix := p1; 2762 2762 TribeNames.Clear; 2763 for j:= 0 to UnusedTribeFiles.Count - 1 do2763 for J := 0 to UnusedTribeFiles.Count - 1 do 2764 2764 begin 2765 GetTribeInfo(UnusedTribeFiles[ j], Name, Color);2765 GetTribeInfo(UnusedTribeFiles[J], Name, Color); 2766 2766 TribeNames.AddObject(Name, TObject(Color)); 2767 2767 end; 2768 assert(TribeNames.Count > 0);2768 Assert(TribeNames.Count > 0); 2769 2769 ModalSelectDlg.ShowNewContent(wmModal, kTribe); 2770 2770 Application.ProcessMessages; 2771 TribeInfo.FileName := UnusedTribeFiles[ModalSelectDlg. result];2772 UnusedTribeFiles.Delete(ModalSelectDlg. result);2771 TribeInfo.FileName := UnusedTribeFiles[ModalSelectDlg.Result]; 2772 UnusedTribeFiles.Delete(ModalSelectDlg.Result); 2773 2773 2774 2774 if GameMode = cLoadGame then 2775 CreateTribe(TribeInfo.trix, TribeInfo.FileName, false)2775 CreateTribe(TribeInfo.trix, TribeInfo.FileName, False) 2776 2776 else 2777 2777 Server(CommandWithData(cSetTribe, TribeInfo.GetCommandDataSize), … … 2783 2783 then 2784 2784 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); 2788 2788 TribeInfo.trix := p1; 2789 2789 if GameMode = cLoadGame then 2790 CreateTribe(TribeInfo.trix, TribeInfo.FileName, false)2790 CreateTribe(TribeInfo.trix, TribeInfo.FileName, False) 2791 2791 else 2792 2792 Server(CommandWithData(cSetTribe, TribeInfo.GetCommandDataSize), … … 2808 2808 LogDlg.Close; 2809 2809 LogDlg.List.Clear; 2810 StartRunning := not idle and (Jump[0] > 0); // AI called Reload2811 me := -1;2812 idle := false;2810 StartRunning := not Idle and (Jump[0] > 0); // AI called Reload 2811 Me := -1; 2812 Idle := False; 2813 2813 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 do2823 if Controls[ i] is TButtonC then2824 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; 2825 2825 sb.Init(0, 1); 2826 2826 for p1 := 0 to nPl - 1 do … … 2828 2828 FreeAndNil(Tribe[p1]); 2829 2829 Tribes.Done; 2830 RepaintOnResize := false;2831 Closable := true;2830 RepaintOnResize := False; 2831 Closable := True; 2832 2832 Close; 2833 2833 { if (GameMode=cNewGame) or (GameMode=cLoadGame) then … … 2852 2852 Show; 2853 2853 Update; 2854 RepaintOnResize := true;2854 RepaintOnResize := True; 2855 2855 xw := 0; 2856 2856 yw := ywcenter; 2857 2857 if not StayOnTop_Ensured then 2858 2858 begin 2859 StayOnTop_Ensured := true;2859 StayOnTop_Ensured := True; 2860 2860 CityDlg.StayOnTop_Workaround; 2861 2861 CityTypeDlg.StayOnTop_Workaround; … … 2876 2876 cShowTurnChange: 2877 2877 begin 2878 if integer(Data) >= 0 then2878 if Integer(Data) >= 0 then 2879 2879 begin 2880 pLogo := integer(Data);2880 pLogo := Integer(Data); 2881 2881 if G.RO[pLogo] = nil then 2882 2882 begin … … 2905 2905 ItsMeAgain(p1); 2906 2906 for mix := 0 to MyRO.nModel - 1 do 2907 if not Assigned(Tribe[ me].ModelPicture[mix].HGr) then2908 InitMyModel(mix, true);2907 if not Assigned(Tribe[Me].ModelPicture[mix].HGr) then 2908 InitMyModel(mix, True); 2909 2909 end; 2910 me := -1;2910 Me := -1; 2911 2911 end; 2912 2912 … … 2917 2917 Jump[pTurn] := 0 2918 2918 else 2919 dec(Jump[pTurn]);2919 Dec(Jump[pTurn]); 2920 2920 SkipTurn := Jump[pTurn] > 0; 2921 2921 if SkipTurn then … … 2926 2926 MiniMapPaint; 2927 2927 InitAllEnemyModels; // necessary for correct replay 2928 if not EndTurn( true) then2929 SkipTurn := false;2928 if not EndTurn(True) then 2929 SkipTurn := False; 2930 2930 end; 2931 2931 if not SkipTurn then … … 2934 2934 NegoDlg.Visible then 2935 2935 NegoDlg.Close; 2936 skipped := false; // always show my moves during my turn2937 idle := true;2936 skipped := False; // always show my moves during my turn 2937 Idle := True; 2938 2938 InitTurn(NewPlayer); 2939 DipMem[ me].pContact := -1;2940 (* if ( me=0) and (MyRO.Alive and (1 shl me)=0)} then2939 DipMem[Me].pContact := -1; 2940 (* if (Me=0) and (MyRO.Alive and (1 shl Me)=0)} then 2941 2941 begin 2942 2942 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^) 2945 2945 end 2946 2946 else Play('TURNSTART'); *) … … 2953 2953 pTurn := NewPlayer; 2954 2954 pLogo := -1; 2955 skipped := false; // always show my moves during my turn2956 idle := true;2955 skipped := False; // always show my moves during my turn 2956 Idle := True; 2957 2957 if FirstMovieTurn then 2958 2958 begin 2959 2959 CheckMovieSpeedBtnState; 2960 FirstMovieTurn := false;2960 FirstMovieTurn := False; 2961 2961 end; 2962 2962 InitTurn(NewPlayer); … … 2975 2975 pTurn := -1; 2976 2976 pLogo := -1; 2977 MapValid := false;2977 MapValid := False; 2978 2978 ClientMode := -1; 2979 idle := false;2980 skipped := false;2979 Idle := False; 2980 skipped := False; 2981 2981 end; 2982 2982 … … 2988 2988 ItsMeAgain(0); 2989 2989 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; 2998 2998 HelpDlg.Difficulty := 0; 2999 2999 BrushType := fGrass; 3000 3000 BrushLoc := -1; 3001 Edited := false;3001 Edited := False; 3002 3002 UnFocus := -1; 3003 3003 MarkCityLoc := -1; 3004 Tracking := false;3005 TurnComplete := false;3006 MapValid := false;3004 Tracking := False; 3005 TurnComplete := False; 3006 MapValid := False; 3007 3007 FormResize(nil); // calculate geometrics and paint all 3008 3008 SetTroopLoc(-1); 3009 idle := true;3009 Idle := True; 3010 3010 end; 3011 3011 … … 3017 3017 scContact: 3018 3018 begin 3019 DipMem[NewPlayer].pContact := integer(Data);3019 DipMem[NewPlayer].pContact := Integer(Data); 3020 3020 if Jump[NewPlayer] > 0 then 3021 3021 DipCall(scReject) … … 3024 3024 ClientMode := Command; 3025 3025 InitTurn(NewPlayer); 3026 MyData.ToldContact := MyData.ToldContact or (1 shl integer(Data));3026 MyData.ToldContact := MyData.ToldContact or (1 shl Integer(Data)); 3027 3027 // don't tell about new nation when already contacted by them 3028 3028 with MessgExDlg do 3029 3029 begin 3030 OpenSound := 'CONTACT_' + char(48 + MyRO.EnemyReport[ integer(Data)3030 OpenSound := 'CONTACT_' + char(48 + MyRO.EnemyReport[Integer(Data) 3031 3031 ].Attitude); 3032 MessgText := Tribe[ integer(Data)].TPhrase('FRCONTACT');3032 MessgText := Tribe[Integer(Data)].TPhrase('FRCONTACT'); 3033 3033 Kind := mkYesNo; 3034 3034 IconKind := mikTribe; 3035 IconIndex := integer(Data);3035 IconIndex := Integer(Data); 3036 3036 ShowModal; 3037 3037 if ModalResult = mrOK then 3038 3038 begin 3039 3039 NegoDlg.Respond; 3040 DipMem[ me].DeliveredPrices := [];3041 DipMem[ me].ReceivedPrices := [];3040 DipMem[Me].DeliveredPrices := []; 3041 DipMem[Me].ReceivedPrices := []; 3042 3042 DipCall(scDipStart); 3043 3043 end … … 3067 3067 else if Command = scDipAccept then 3068 3068 begin // remember delivered and received prices 3069 for i := 0 to DipMem[me].SentOffer.nDeliver - 1 do3070 include(DipMem[me].DeliveredPrices,3071 DipMem[ me].SentOffer.Price[i] shr 24);3072 for i := 0 to DipMem[me].SentOffer.nCost - 1 do3073 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 do3078 if DipMem[ me].SentOffer.Price[i] and opMask = opTreaty then3079 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; 3080 3080 if IsTreatyDeal then 3081 3081 Play('NEWTREATY') … … 3084 3084 end; 3085 3085 NegoDlg.Start; 3086 idle := true;3086 Idle := True; 3087 3087 end; 3088 3088 … … 3090 3090 if not IsMultiPlayerGame then 3091 3091 begin 3092 case G.RO[NewPlayer].Treaty[ integer(Data)] of3092 case G.RO[NewPlayer].Treaty[Integer(Data)] of 3093 3093 trPeace: 3094 s := Tribe[integer(Data)].TPhrase('FRCANCELBYREJECT_PEACE');3094 S := Tribe[Integer(Data)].TPhrase('FRCANCELBYREJECT_PEACE'); 3095 3095 trFriendlyContact: 3096 s := Tribe[integer(Data)].TPhrase('FRCANCELBYREJECT_FRIENDLY');3096 S := Tribe[Integer(Data)].TPhrase('FRCANCELBYREJECT_FRIENDLY'); 3097 3097 trAlliance: 3098 s := Tribe[integer(Data)].TPhrase('FRCANCELBYREJECT_ALLIANCE');3098 S := Tribe[Integer(Data)].TPhrase('FRCANCELBYREJECT_ALLIANCE'); 3099 3099 end; 3100 TribeMessage( integer(Data), s, 'CANCELTREATY');3100 TribeMessage(Integer(Data), S, 'CANCELTREATY'); 3101 3101 end; 3102 3102 3103 3103 cShowCancelTreatyByAlliance: 3104 if idle and (NewPlayer = me) then3105 TribeMessage( integer(Data), Tribe[integer(Data)3104 if Idle and (NewPlayer = Me) then 3105 TribeMessage(Integer(Data), Tribe[Integer(Data) 3106 3106 ].TPhrase('FRENEMYALLIANCE'), 'CANCELTREATY'); 3107 3107 3108 3108 cShowSupportAllianceAgainst: 3109 3109 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] 3112 3112 .TPhrase('FRMYALLIANCE2'), 'CANCELTREATY'); 3113 3113 3114 3114 cShowPeaceViolation: 3115 3115 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'), 3118 3118 [TurnToString(MyRO.Turn + PeaceEvaTurns - 1)]), 'MSG_WITHDRAW'); 3119 3119 … … 3122 3122 3123 3123 cShowUnitChanged, cShowCityChanged, cShowAfterMove, cShowAfterAttack: 3124 if ( idle and (NewPlayer = me) or not idle and not skipped) and3124 if (Idle and (NewPlayer = Me) or not Idle and not skipped) and 3125 3125 not((GameMode = cMovie) and (MovieSpeed = 4)) then 3126 3126 begin 3127 assert(NewPlayer = me);3128 if not idle or (GameMode = cMovie) then3127 Assert(NewPlayer = Me); 3128 if not Idle or (GameMode = cMovie) then 3129 3129 Application.ProcessMessages; 3130 3130 if Command = cShowCityChanged then 3131 3131 begin 3132 CurrentMoveInfo.DoShow := false;3133 if idle then3134 CurrentMoveInfo.DoShow := true3132 CurrentMoveInfo.DoShow := False; 3133 if Idle then 3134 CurrentMoveInfo.DoShow := True 3135 3135 else if CurrentMoveInfo.IsAlly then 3136 3136 CurrentMoveInfo.DoShow := not mAlNoMoves.Checked … … 3140 3140 else if Command = cShowUnitChanged then 3141 3141 begin 3142 CurrentMoveInfo.DoShow := false;3143 if idle then3142 CurrentMoveInfo.DoShow := False; 3143 if Idle then 3144 3144 CurrentMoveInfo.DoShow := not mEffectiveMovesOnly.Checked 3145 3145 else if CurrentMoveInfo.IsAlly then … … 3155 3155 begin 3156 3156 if Command = cShowCityChanged then 3157 MapValid := false;3158 FocusOnLoc( integer(Data), flImmUpdate);3157 MapValid := False; 3158 FocusOnLoc(Integer(Data), flImmUpdate); 3159 3159 // OldUnFocus:=UnFocus; 3160 3160 // UnFocus:=-1; 3161 3161 if Command = cShowAfterMove then 3162 PaintLoc( integer(Data), CurrentMoveInfo.AfterMovePaintRadius)3162 PaintLoc(Integer(Data), CurrentMoveInfo.AfterMovePaintRadius) 3163 3163 // show discovered areas 3164 3164 else 3165 PaintLoc( integer(Data), 1);3165 PaintLoc(Integer(Data), 1); 3166 3166 // UnFocus:=OldUnFocus; 3167 3167 if (Command = cShowAfterAttack) and … … 3173 3173 Update; // remove message box from screen 3174 3174 end 3175 else if not idle then3175 else if not Idle then 3176 3176 if Command = cShowCityChanged then 3177 3177 Sleep(MoveTime * WaitAfterShowMove div 16) 3178 3178 else if (Command = cShowUnitChanged) and 3179 (MyMap[ integer(Data)] and fUnit <> 0) then3179 (MyMap[Integer(Data)] and fUnit <> 0) then 3180 3180 Sleep(MoveTime * WaitAfterShowMove div 32) 3181 3181 end // if CurrentMoveInfo.DoShow 3182 3182 else 3183 MapValid := false;3183 MapValid := False; 3184 3184 end; 3185 3185 3186 3186 cShowMoving, cShowCapturing: 3187 if ( idle and (NewPlayer = me) or not idle and not skipped and3187 if (Idle and (NewPlayer = Me) or not Idle and not skipped and 3188 3188 (TShowMove(Data).emix <> $FFFF)) and 3189 3189 not((GameMode = cMovie) and (MovieSpeed = 4)) then 3190 3190 begin 3191 assert(NewPlayer = me);3192 if not idle or (GameMode = cMovie) then3191 Assert(NewPlayer = Me); 3192 if not Idle or (GameMode = cMovie) then 3193 3193 Application.ProcessMessages; 3194 3194 with TShowMove(Data) do 3195 3195 begin 3196 CurrentMoveInfo.DoShow := false;3197 if not idle and (not Assigned(Tribe[Owner].ModelPicture[mix].HGr)) then3196 CurrentMoveInfo.DoShow := False; 3197 if not Idle and (not Assigned(Tribe[Owner].ModelPicture[mix].HGr)) then 3198 3198 InitEnemyModel(emix); 3199 3199 3200 3200 ToLoc := dLoc(FromLoc, dx, dy); 3201 if idle then3201 if Idle then 3202 3202 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! 3204 3204 CurrentMoveInfo.DoShow := not mEffectiveMovesOnly.Checked or 3205 3205 (Command = cShowCapturing); … … 3234 3234 else 3235 3235 CurrentMoveInfo.AfterMovePaintRadius := 1; 3236 if (MyRO.Wonder[woShinkansen].EffectiveOwner = me) and3236 if (MyRO.Wonder[woShinkansen].EffectiveOwner = Me) and 3237 3237 (Domain = dGround) and 3238 3238 (MyMap[FromLoc] and (fRR or fCity) <> 0) and … … 3249 3249 CurrentMoveInfo.IsAlly := MyRO.Treaty[Owner] = trAlliance; 3250 3250 if GameMode = cMovie then 3251 CurrentMoveInfo.DoShow := true3251 CurrentMoveInfo.DoShow := True 3252 3252 else if CurrentMoveInfo.IsAlly then 3253 3253 CurrentMoveInfo.DoShow := not mAlNoMoves.Checked and … … 3265 3265 cix := MyRO.nCity - 1; 3266 3266 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); 3269 3269 end 3270 3270 else … … 3272 3272 ecix := MyRO.nEnemyCity - 1; 3273 3273 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); 3276 3276 end; 3277 3277 TribeMessage(Owner, Format(Tribe[Owner].TPhrase('CAPTURE'), 3278 [ s]), '');3278 [S]), ''); 3279 3279 Update; // remove message box from screen 3280 3280 end; … … 3361 3361 end // if CurrentMoveInfo.DoShow 3362 3362 else 3363 MapValid := false;3363 MapValid := False; 3364 3364 end; 3365 3365 end; 3366 3366 3367 3367 cShowAttacking: 3368 if ( idle and (NewPlayer = me) or not idle and not skipped and3368 if (Idle and (NewPlayer = Me) or not Idle and not skipped and 3369 3369 (TShowMove(Data).emix <> $FFFF)) and 3370 3370 not((GameMode = cMovie) and (MovieSpeed = 4)) then 3371 3371 begin 3372 assert(NewPlayer = me);3373 if not idle or (GameMode = cMovie) then3372 Assert(NewPlayer = Me); 3373 if not Idle or (GameMode = cMovie) then 3374 3374 Application.ProcessMessages; 3375 3375 with TShowMove(Data) do 3376 3376 begin 3377 3377 CurrentMoveInfo.AfterAttackExpeller := -1; 3378 CurrentMoveInfo.DoShow := false;3379 if idle then3380 CurrentMoveInfo.DoShow := true // own unit -- always show attacks3378 CurrentMoveInfo.DoShow := False; 3379 if Idle then 3380 CurrentMoveInfo.DoShow := True // own unit -- always show attacks 3381 3381 else 3382 3382 begin … … 3398 3398 cix := MyRO.nCity - 1; 3399 3399 while (cix >= 0) and (MyCity[cix].Loc <> ToLoc) do 3400 dec(cix);3400 Dec(cix); 3401 3401 if MyCity[cix].Status and csToldBombard = 0 then 3402 3402 begin 3403 if not supervising then3403 if not Supervising then 3404 3404 MyCity[cix].Status := MyCity[cix].Status or csToldBombard; 3405 s:= CityName(MyCity[cix].ID);3405 S := CityName(MyCity[cix].ID); 3406 3406 SoundMessageEx(Format(Tribe[Owner].TPhrase('BOMBARD'), 3407 [ s]), '');3407 [S]), ''); 3408 3408 Update; // remove message box from screen 3409 3409 end; … … 3414 3414 if Flags and umExpelling <> 0 then 3415 3415 Play('MOVE_EXPEL') 3416 else if Owner = me then3416 else if Owner = Me then 3417 3417 begin 3418 MakeModelInfo( me, mix, MyModel[mix], mi);3418 MakeModelInfo(Me, mix, MyModel[mix], mi); 3419 3419 Play(AttackSound(ModelCode(mi))); 3420 3420 end … … 3441 3441 MoveOnScreen(TShowMove(Data), 10, 0, 16); 3442 3442 end 3443 else if not idle then3443 else if not Idle then 3444 3444 Sleep(MoveTime div 2); 3445 3445 MainMap.AttackEnd; 3446 3446 end // if CurrentMoveInfo.DoShow 3447 3447 else 3448 MapValid := false;3448 MapValid := False; 3449 3449 end; 3450 3450 end; … … 3455 3455 else 3456 3456 begin 3457 s:= Phrases.Lookup('FOREIGNINFO');3457 S := Phrases.Lookup('FOREIGNINFO'); 3458 3458 for p1 := 0 to nPl - 1 do 3459 3459 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, ''); 3462 3462 end; 3463 3463 … … 3471 3471 begin 3472 3472 MessgText := Format(Phrases.Lookup('GRLIB_GENERAL'), 3473 [Phrases.Lookup('ADVANCES', integer(Data))]);3473 [Phrases.Lookup('ADVANCES', Integer(Data))]); 3474 3474 OpenSound := 'NEWADVANCE_GRLIB'; 3475 3475 Kind := mkOk; … … 3481 3481 cRefreshDebugMap: 3482 3482 begin 3483 if integer(Data) = MainMap.pDebugMap then3483 if Integer(Data) = MainMap.pDebugMap then 3484 3484 begin 3485 MapValid := false;3485 MapValid := False; 3486 3486 MainOffscreenPaint; 3487 3487 Update; … … 3494 3494 cSetTribe: 3495 3495 with TTribeInfo(Data) do begin 3496 i:= UnusedTribeFiles.Count - 1;3497 while ( i>= 0) and3498 (AnsiCompareFileName(UnusedTribeFiles[ i], FileName) <> 0) do3499 dec(i);3500 if i>= 0 then3501 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); 3503 3503 end; 3504 3504 cSetNewModelPicture: … … 3511 3511 (TModelPictureInfo(Data), False); 3512 3512 cSetSlaveIndex: 3513 Tribe[ integer(Data) shr 16].mixSlaves := integer(Data) and $FFFF;3513 Tribe[Integer(Data) shr 16].mixSlaves := Integer(Data) and $FFFF; 3514 3514 cSetCityName: 3515 3515 with TCityNameInfo(Data) do … … 3528 3528 procedure TMainScreen.FormCreate(Sender: TObject); 3529 3529 var 3530 i, j: integer;3530 I, J: Integer; 3531 3531 begin 3532 3532 NoMap := TIsoMap.Create; … … 3570 3570 3571 3571 // tag-controlled language 3572 for i:= 0 to ComponentCount - 1 do3573 if Components[ i].Tag and $FF <> 0 then3574 if Components[ i] is TMenuItem then begin3575 TMenuItem(Components[ i]).Caption := Phrases.Lookup('CONTROLS',3576 -1 + Components[ i].Tag and $FF);3577 for j:= 0 to Length(SaveOption) - 1 do3578 if Components[ i].Tag and $FF = SaveOption[j] then3579 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; 3580 3580 end else 3581 if Components[ i] is TButtonBase then begin3582 TButtonBase(Components[ i]).Hint := Phrases.Lookup('CONTROLS',3583 -1 + Components[ i].Tag and $FF);3584 if (Components[ i] is TButtonC) and3585 (TButtonC(Components[ i]).ButtonIndex <> 1) then3586 TButtonC(Components[ i]).ButtonIndex :=3587 Integer(MapOptionChecked) shr (Components[ i].Tag shr 8) and 1 + 23581 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 3588 3588 end; 3589 3589 … … 3598 3598 ManagementArea.Hint := Phrases2.Lookup('BTN_MANAGE'); 3599 3599 end; 3600 for i:= 0 to mRep.Count - 1 do3601 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; 3605 3605 end; 3606 3606 … … 3621 3621 else Buffer.height := 3 * ySizeBig; 3622 3622 Buffer.Canvas.Font.Assign(UniFont[ftSmall]); 3623 for i:= 0 to nPl - 1 do3624 AILogo[ i] := nil;3623 for I := 0 to nPl - 1 do 3624 AILogo[I] := nil; 3625 3625 Canvas.Font.Assign(UniFont[ftSmall]); 3626 3626 InitButtons; … … 3639 3639 FreeAndNil(Panel); 3640 3640 for I := 0 to nPl - 1 do 3641 if AILogo[ i] <> nil then3641 if AILogo[I] <> nil then 3642 3642 FreeAndNil(AILogo[I]); 3643 3643 FreeAndNil(Offscreen); … … 3699 3699 Status := Status and ($FFFF - usRecover - usGoto - usEnhance); 3700 3700 if Job > jNone then 3701 Server(sStartJob + jNone shl 4, me, UnFocus, nil^);3701 Server(sStartJob + jNone shl 4, Me, UnFocus, nil^); 3702 3702 end; 3703 3703 end; … … 3725 3725 if DoJob(jCity) = eCity then 3726 3726 begin 3727 MapValid := false;3727 MapValid := False; 3728 3728 PaintAll; 3729 ZoomToCity(Loc0, true, chFounded);3729 ZoomToCity(Loc0, True, chFounded); 3730 3730 end; 3731 3731 end else begin 3732 3732 CityOptimizer_BeforeRemoveUnit(UnFocus); 3733 ServerResult := Server(sAddToCity, me, UnFocus, nil^);3733 ServerResult := Server(sAddToCity, Me, UnFocus, nil^); 3734 3734 if ServerResult >= rExecuted then 3735 3735 begin 3736 3736 cix := MyRO.nCity - 1; 3737 3737 while (cix >= 0) and (MyCity[cix].Loc <> Loc0) do 3738 dec(cix);3739 assert(cix >= 0);3738 Dec(cix); 3739 Assert(cix >= 0); 3740 3740 CityOptimizer_CityChange(cix); 3741 3741 CityOptimizer_AfterRemoveUnit; // does nothing here 3742 3742 SetTroopLoc(Loc0); 3743 UpdateViews( true);3744 DestinationMarkON := false;3743 UpdateViews(True); 3744 DestinationMarkON := False; 3745 3745 PaintDestination; 3746 3746 UnFocus := -1; 3747 3747 PaintLoc(Loc0); 3748 NextUnit(UnStartLoc, true);3748 NextUnit(UnStartLoc, True); 3749 3749 end 3750 3750 else if ServerResult = eMaxSize then … … 3829 3829 Destination := Status shr 16; 3830 3830 Status := Status and not(usStay or usRecover) or usWaiting; 3831 MoveToLoc(Destination, true);3831 MoveToLoc(Destination, True); 3832 3832 end; 3833 3833 end; … … 3850 3850 begin 3851 3851 cixOldHome := Home; 3852 if Server(sSetUnitHome, me, UnFocus, nil^) >= rExecuted then3852 if Server(sSetUnitHome, Me, UnFocus, nil^) >= rExecuted then 3853 3853 begin 3854 3854 CityOptimizer_CityChange(cixOldHome); 3855 3855 CityOptimizer_CityChange(Home); 3856 UpdateViews( true);3856 UpdateViews(True); 3857 3857 end 3858 3858 else … … 3862 3862 begin 3863 3863 Status := Status and not(usStay or usRecover or usEnhance); 3864 MoveToLoc(maNextCity, true);3864 MoveToLoc(maNextCity, True); 3865 3865 end; 3866 3866 end; … … 3882 3882 procedure TMainScreen.mJumpClick(Sender: TObject); 3883 3883 begin 3884 if supervising then3884 if Supervising then 3885 3885 Jump[0] := 20 3886 3886 else 3887 Jump[ me] := 20;3888 EndTurn( true);3887 Jump[Me] := 20; 3888 EndTurn(True); 3889 3889 end; 3890 3890 … … 3895 3895 if UnFocus >= 0 then 3896 3896 with MyUn[UnFocus] do begin 3897 i := Server(sLoadUnit, me, UnFocus, nil^);3898 if i>= rExecuted then3897 I := Server(sLoadUnit, Me, UnFocus, nil^); 3898 if I >= rExecuted then 3899 3899 begin 3900 3900 if MyModel[mix].Domain = dAir then … … 3902 3902 else 3903 3903 Play('MOVE_LOAD'); 3904 DestinationMarkON := false;3904 DestinationMarkON := False; 3905 3905 PaintDestination; 3906 3906 Status := Status and ($FFFF - usWaiting - usStay - usRecover - usGoto - usEnhance); 3907 NextUnit(UnStartLoc, true);3907 NextUnit(UnStartLoc, True); 3908 3908 end 3909 else if i= eNoTime_Load then3909 else if I = eNoTime_Load then 3910 3910 if MyModel[mix].Domain = dAir then 3911 3911 SoundMessage(Phrases.Lookup('NOTIMELOADAIR'), 'NOMOVE_TIME') … … 3942 3942 with MyUn[UnFocus] do begin 3943 3943 Status := Status and not usWaiting; 3944 NextUnit(UnStartLoc, true);3944 NextUnit(UnStartLoc, True); 3945 3945 end; 3946 3946 end; … … 3971 3971 if not Edited or (SimpleQuery(mkYesNo, Phrases.Lookup('MAP_RANDOM'), '') 3972 3972 = 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; 3976 3976 PaintAllMaps; 3977 3977 end; … … 3982 3982 if UnFocus >= 0 then 3983 3983 with MyUn[UnFocus] do begin 3984 DestinationMarkON := false;3984 DestinationMarkON := False; 3985 3985 PaintDestination; 3986 3986 Status := Status and ($FFFF - usStay - usGoto - usEnhance) or usRecover; 3987 3987 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); 3990 3990 end; 3991 3991 end; … … 3999 3999 QueryText := Phrases.Lookup('MAP_CLOSE'); 4000 4000 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^); 4003 4003 end; 4004 4004 end else 4005 Server(sAbandonMap, me, 0, nil^);4005 Server(sAbandonMap, Me, 0, nil^); 4006 4006 end else begin 4007 4007 if Server(sGetGameChanged, 0, 0, nil^) = eOK then begin … … 4022 4022 I: Integer; 4023 4023 begin 4024 AltGovs := false;4025 for i:= 2 to nGov - 1 do4026 if (GovPreq[ i] <> preNA) and4027 ((GovPreq[ i] = preNone) or (MyRO.Tech[GovPreq[i]] >= tsApplicable)) then4028 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; 4029 4029 4030 4030 if not AltGovs then … … 4032 4032 else 4033 4033 begin 4034 RevolutionChanged := false;4034 RevolutionChanged := False; 4035 4035 if MyRO.Happened and phChangeGov <> 0 then 4036 4036 begin 4037 4037 ModalSelectDlg.ShowNewContent(wmModal, kGov); 4038 if ModalSelectDlg. result >= 0 then4038 if ModalSelectDlg.Result >= 0 then 4039 4039 begin 4040 4040 Play('NEWGOV'); 4041 Server(sSetGovernment, me, ModalSelectDlg.result, nil^);4041 Server(sSetGovernment, Me, ModalSelectDlg.Result, nil^); 4042 4042 CityOptimizer_BeginOfTurn; 4043 RevolutionChanged := true;4043 RevolutionChanged := True; 4044 4044 end; 4045 4045 end … … 4047 4047 with MessgExDlg do 4048 4048 begin // revolution! 4049 MessgExDlg.MessgText := Tribe[ me].TPhrase('REVOLUTION');4049 MessgExDlg.MessgText := Tribe[Me].TPhrase('REVOLUTION'); 4050 4050 MessgExDlg.Kind := mkYesNo; 4051 4051 MessgExDlg.IconKind := mikPureIcon; … … 4055 4055 begin 4056 4056 Play('REVOLUTION'); 4057 Server(sRevolution, me, 0, nil^);4058 RevolutionChanged := true;4057 Server(sRevolution, Me, 0, nil^); 4058 RevolutionChanged := True; 4059 4059 if NatStatDlg.Visible then 4060 4060 NatStatDlg.Close; … … 4064 4064 end; 4065 4065 if RevolutionChanged then 4066 UpdateViews( true);4066 UpdateViews(True); 4067 4067 end; 4068 4068 end; … … 4084 4084 procedure TMainScreen.mRunClick(Sender: TObject); 4085 4085 begin 4086 if supervising then4086 if Supervising then 4087 4087 Jump[0] := 999999 4088 4088 else 4089 Jump[ me] := 999999;4090 EndTurn( true);4089 Jump[Me] := 999999; 4090 EndTurn(True); 4091 4091 end; 4092 4092 … … 4100 4100 if UnFocus >= 0 then 4101 4101 with TUn(MyUn[UnFocus]) do 4102 Server(sSelectTransport, me, UnFocus, nil^);4102 Server(sSelectTransport, Me, UnFocus, nil^); 4103 4103 end; 4104 4104 … … 4112 4112 if UnFocus >= 0 then 4113 4113 with TUn(MyUn[UnFocus]) do begin 4114 DestinationMarkON := false;4114 DestinationMarkON := False; 4115 4115 PaintDestination; 4116 4116 Status := Status and ($FFFF - usRecover - usGoto - usEnhance) or usStay; 4117 4117 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); 4120 4120 end; 4121 4121 end; … … 4137 4137 I: Integer; 4138 4138 begin 4139 if G.Difficulty[ me] > 0 then4140 ListDlg.ShowNewContent_MilReport(wmPersistent, me)4139 if G.Difficulty[Me] > 0 then 4140 ListDlg.ShowNewContent_MilReport(wmPersistent, Me) 4141 4141 else 4142 4142 begin 4143 i:= 1;4144 while ( i < nPl) and (1 shl iand MyRO.Alive = 0) do4145 inc(i);4146 if i< nPl then4147 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); 4148 4148 end; 4149 4149 end; … … 4160 4160 if Master >= 0 then begin 4161 4161 OldMaster := Master; 4162 i := Server(sUnloadUnit, me, UnFocus, nil^);4163 if i>= rExecuted then4162 I := Server(sUnloadUnit, Me, UnFocus, nil^); 4163 if I >= rExecuted then 4164 4164 begin 4165 4165 if MyModel[mix].Domain = dAir then … … 4173 4173 Status := Status and not usWaiting; 4174 4174 if MyModel[mix].Domain <> dAir then 4175 NextUnit(Loc, true)4175 NextUnit(Loc, True) 4176 4176 else 4177 4177 PanelPaint; 4178 4178 end 4179 else if i= eNoTime_Load then4179 else if I = eNoTime_Load then 4180 4180 if MyModel[mix].Domain = dAir then 4181 4181 SoundMessage(Phrases.Lookup('NOTIMELOADAIR'), 'NOMOVE_TIME') … … 4186 4186 NewFocus := -1; 4187 4187 uix := UnFocus; 4188 for i:= 1 to MyRO.nUn - 1 do4188 for I := 1 to MyRO.nUn - 1 do 4189 4189 begin 4190 4190 uix := (uix + MyRO.nUn - 1) mod MyRO.nUn; 4191 4191 if (MyUn[uix].Master = UnFocus) and 4192 (MyUn[uix].Movement = integer(MyModel[MyUn[uix].mix].speed)) then4192 (MyUn[uix].Movement = Integer(MyModel[MyUn[uix].mix].speed)) then 4193 4193 begin 4194 4194 MyUn[uix].Status := MyUn[uix].Status or usWaiting; … … 4210 4210 if UnFocus >= 0 then 4211 4211 with MyUn[UnFocus] do begin 4212 DestinationMarkON := false;4212 DestinationMarkON := False; 4213 4213 PaintDestination; 4214 4214 Status := Status and ($FFFF - usStay - usRecover - usGoto - usEnhance) or usWaiting; 4215 4215 end; 4216 NextUnit(-1, false);4216 NextUnit(-1, False); 4217 4217 end; 4218 4218 … … 4229 4229 procedure TMainScreen.FormResize(Sender: TObject); 4230 4230 var 4231 MiniFrame, MaxMapWidth: integer;4231 MiniFrame, MaxMapWidth: Integer; 4232 4232 begin 4233 4233 SmallScreen := ClientWidth < 1024; … … 4307 4307 begin 4308 4308 RectInvalidate(0, TopBarHeight, ClientWidth, TopBarHeight + MapHeight); 4309 MapValid := false;4309 MapValid := False; 4310 4310 PaintAll; 4311 4311 end; 4312 4312 end; 4313 4313 4314 procedure TMainScreen.FormCloseQuery(Sender: TObject; var CanClose: boolean);4314 procedure TMainScreen.FormCloseQuery(Sender: TObject; var CanClose: Boolean); 4315 4315 begin 4316 4316 CanClose := Closable; 4317 if not Closable and idle and (me = 0) and (ClientMode < scContact) then4317 if not Closable and Idle and (Me = 0) and (ClientMode < scContact) then 4318 4318 mResign.Click; 4319 4319 end; … … 4337 4337 begin 4338 4338 MessgExDlg.CancelMovie; 4339 Server(sBreak, me, 0, nil^);4339 Server(sBreak, Me, 0, nil^); 4340 4340 end 4341 4341 else if ClientMode < 0 then 4342 skipped := true4342 skipped := True 4343 4343 else if ClientMode >= scContact then 4344 4344 NegoDlg.ShowNewContent(wmPersistent) … … 4346 4346 begin 4347 4347 Jump[pTurn] := 0; 4348 StartRunning := false;4348 StartRunning := False; 4349 4349 end 4350 4350 else … … 4359 4359 else 4360 4360 with MainMap do begin 4361 if supervising then4361 if Supervising then 4362 4362 xTerrain := xMidPanel + 2 * xxt + 14 4363 4363 else if ClientWidth < 1280 then … … 4366 4366 xTerrain := ClientWidth div 2; 4367 4367 xTroop := xTerrain + 2 * xxt + 12; 4368 if SmallScreen and not supervising then4368 if SmallScreen and not Supervising then 4369 4369 xTroop := xRightPanel + 10 - 3 * 66 - 4370 4370 GetSystemMetrics(SM_CXVSCROLL) - 19 - 4; … … 4375 4375 end; 4376 4376 4377 function TMainScreen.EndTurn(WasSkipped: boolean): boolean;4378 4379 function IsResourceUnused(cix, NeedFood, NeedProd: integer): boolean;4377 function TMainScreen.EndTurn(WasSkipped: Boolean): Boolean; 4378 4379 function IsResourceUnused(cix, NeedFood, NeedProd: Integer): Boolean; 4380 4380 var 4381 dx, dy, fix: integer;4381 dx, dy, fix: Integer; 4382 4382 CityAreaInfo: TCityAreaInfo; 4383 4383 TileInfo: TTileInfo; 4384 4384 begin 4385 Server(sGetCityAreaInfo, me, cix, CityAreaInfo);4385 Server(sGetCityAreaInfo, Me, cix, CityAreaInfo); 4386 4386 for dy := -3 to 3 do 4387 4387 for dx := -3 to 3 do … … 4393 4393 begin 4394 4394 TileInfo.ExplCity := cix; 4395 Server(sGetHypoCityTileInfo, me, dLoc(MyCity[cix].Loc, dx, dy),4395 Server(sGetHypoCityTileInfo, Me, dLoc(MyCity[cix].Loc, dx, dy), 4396 4396 TileInfo); 4397 4397 if (TileInfo.Food >= NeedFood) and (TileInfo.Prod >= NeedProd) then 4398 4398 begin 4399 result := true;4400 exit4399 Result := True; 4400 Exit 4401 4401 end; 4402 4402 end 4403 4403 end; 4404 result := false;4404 Result := False; 4405 4405 end; 4406 4406 4407 4407 var 4408 p1, uix, cix, CenterLoc: integer;4408 p1, uix, cix, CenterLoc: Integer; 4409 4409 MsgItem: string; 4410 4410 CityReport: TCityReport; 4411 4411 PlaneReturnData: TPlaneReturnData; 4412 Zoom: boolean;4413 begin 4414 result := false;4412 Zoom: Boolean; 4413 begin 4414 Result := False; 4415 4415 if ClientMode >= scDipOffer then 4416 4416 Exit; 4417 4417 4418 if supervising and (me <> 0) then begin4418 if Supervising and (Me <> 0) then begin 4419 4419 ApplyToVisibleForms(faClose); 4420 4420 ItsMeAgain(0); … … 4435 4435 PlaneReturnData.Loc := Loc; 4436 4436 PlaneReturnData.Movement := 0; // end turn without further movement? 4437 if Server(sGetPlaneReturn, me, uix, PlaneReturnData) = eNoWay then4437 if Server(sGetPlaneReturn, Me, uix, PlaneReturnData) = eNoWay then 4438 4438 begin 4439 4439 CenterLoc := Loc + G.lx * 6; 4440 4440 // centering the unit itself would make it covered by the query dialog 4441 4441 while CenterLoc >= G.lx * G.ly do 4442 dec(CenterLoc, G.lx * 2);4442 Dec(CenterLoc, G.lx * 2); 4443 4443 Centre(CenterLoc); 4444 4444 SetTroopLoc(-1); … … 4455 4455 SetTroopLoc(Loc); 4456 4456 PanelPaint; 4457 exit;4457 Exit; 4458 4458 end; 4459 4459 MyUn[uix].Status := MyUn[uix].Status or usToldNoReturn; … … 4461 4461 end; 4462 4462 4463 if not supervising and (MyRO.TestFlags and tfImmImprove = 0) and4463 if not Supervising and (MyRO.TestFlags and tfImmImprove = 0) and 4464 4464 (MyRO.Government <> gAnarchy) and (MyRO.Money + TaxSum < 0) and 4465 4465 (MyRO.TaxRate < 100) then // low funds! … … 4473 4473 ShowModal; 4474 4474 if ModalResult <> mrOK then 4475 exit;4475 Exit; 4476 4476 end; 4477 4477 … … 4481 4481 if (Loc >= 0) and (Flags and chCaptured = 0) then 4482 4482 begin 4483 Zoom := false;4483 Zoom := False; 4484 4484 CityReport.HypoTiles := -1; 4485 4485 CityReport.HypoTax := -1; 4486 4486 CityReport.HypoLux := -1; 4487 Server(sGetCityReport, me, cix, CityReport);4487 Server(sGetCityReport, Me, cix, CityReport); 4488 4488 4489 4489 if (CityReport.Working - CityReport.Happy > Size shr 1) and … … 4576 4576 else 4577 4577 EOT.Hint := Phrases.Lookup('BTN_SKIP'); 4578 result := true;4578 Result := True; 4579 4579 SetTroopLoc(-1); 4580 4580 pTurn := -1; 4581 4581 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; 4585 4585 EOT.ButtonIndex := eotCancel; 4586 EOT.Visible := true;4587 MapValid := false;4586 EOT.Visible := True; 4587 MapValid := False; 4588 4588 PanelPaint; 4589 4589 Update; 4590 4590 ClientMode := -1; 4591 idle := false;4591 Idle := False; 4592 4592 skipped := WasSkipped; 4593 4593 for p1 := 1 to nPl - 1 do 4594 4594 if G.RO[p1] <> nil then 4595 skipped := true; // don't show enemy moves in hotseat mode4595 skipped := True; // don't show enemy moves in hotseat mode 4596 4596 end 4597 4597 else … … 4603 4603 if NegoDlg.Visible then 4604 4604 NegoDlg.Close; 4605 HaveStrategyAdvice := false;4605 HaveStrategyAdvice := False; 4606 4606 // AdvisorDlg.HaveStrategyAdvice; 4607 4607 // negotiation might have changed advices 4608 4608 EOT.ButtonIndex := eotCancel; 4609 EOT.Visible := true;4609 EOT.Visible := True; 4610 4610 PanelPaint; 4611 4611 Update; 4612 4612 ClientMode := -1; 4613 idle := false;4614 end; 4615 4616 procedure TMainScreen.ProcessRect(x0, y0, nx, ny, Options: integer);4613 Idle := False; 4614 end; 4615 4616 procedure TMainScreen.ProcessRect(x0, y0, nx, ny, Options: Integer); 4617 4617 var 4618 xs, ys, xl, yl: integer;4618 xs, ys, xl, yl: Integer; 4619 4619 begin 4620 4620 with MainMap do begin … … 4625 4625 while abs(2 * (xs + G.lx * (xxt * 2)) + xl - MapWidth) < 4626 4626 abs(2 * xs + xl - MapWidth) do 4627 inc(xs, G.lx * (xxt * 2));4627 Inc(xs, G.lx * (xxt * 2)); 4628 4628 ys := (y0 - yw) * yyt - yyt; 4629 4629 if xs + xl > MapWidth then … … 4632 4632 yl := MapHeight - ys; 4633 4633 if (xl <= 0) or (yl <= 0) then 4634 exit;4634 Exit; 4635 4635 if Options and prPaint <> 0 then begin 4636 4636 if Options and prAutoBounds <> 0 then … … 4644 4644 end; 4645 4645 4646 procedure TMainScreen.PaintLoc(Loc: integer; Radius: integer = 0);4646 procedure TMainScreen.PaintLoc(Loc: Integer; Radius: Integer = 0); 4647 4647 var 4648 yLoc, x0: integer;4648 yLoc, x0: Integer; 4649 4649 begin 4650 4650 if MapValid then begin 4651 4651 yLoc := (Loc + G.lx * 1024) div G.lx - 1024; 4652 4652 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]); 4654 4654 ProcessRect(x0, yLoc - 2 * Radius, 4 * Radius + 1, 4 * Radius + 1, 4655 4655 prPaint or prAutoBounds or prInvalidate); … … 4658 4658 end; 4659 4659 4660 procedure TMainScreen.PaintLocTemp(Loc: integer; Style: TPaintLocTempStyle);4660 procedure TMainScreen.PaintLocTemp(Loc: Integer; Style: TPaintLocTempStyle); 4661 4661 var 4662 y0, x0, xMap, yMap: integer;4662 y0, x0, xMap, yMap: Integer; 4663 4663 begin 4664 4664 with NoMap do begin 4665 4665 if not MapValid then 4666 exit;4666 Exit; 4667 4667 Buffer.Canvas.Font.Assign(UniFont[ftSmall]); 4668 4668 y0 := Loc div G.lx; … … 4672 4672 while abs(2 * (xMap + G.lx * (xxt * 2)) + 2 * xxt - MapWidth) < 4673 4673 abs(2 * xMap + 2 * xxt - MapWidth) do 4674 inc(xMap, G.lx * (xxt * 2));4674 Inc(xMap, G.lx * (xxt * 2)); 4675 4675 yMap := (y0 - yw) * yyt - yyt; 4676 4676 NoMap.SetOutput(Buffer); … … 4684 4684 // panel protusions are added 4685 4685 // NoMap must be set to buffer and bounds before 4686 procedure TMainScreen.PaintBufferToScreen(xMap, yMap, width, height: integer);4686 procedure TMainScreen.PaintBufferToScreen(xMap, yMap, width, height: Integer); 4687 4687 begin 4688 4688 if xMap + width > MapWidth then … … 4692 4692 if (width <= 0) or (height <= 0) or (width + xMap <= 0) or (height + yMap <= 0) 4693 4693 then 4694 exit;4694 Exit; 4695 4695 4696 4696 NoMap.BitBltBitmap(Panel, -xMap - MapOffset, -yMap + MapHeight - overlap, xMidPanel, … … 4719 4719 end; 4720 4720 4721 procedure TMainScreen.PaintLoc_BeforeMove(FromLoc: integer);4721 procedure TMainScreen.PaintLoc_BeforeMove(FromLoc: Integer); 4722 4722 var 4723 yLoc, x0: integer;4723 yLoc, x0: Integer; 4724 4724 begin 4725 4725 if MapValid then … … 4727 4727 yLoc := (FromLoc + G.lx * 1024) div G.lx - 1024; 4728 4728 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]); 4730 4730 ProcessRect(x0, yLoc, 1, 1, prPaint or prAutoBounds); 4731 4731 end … … 4734 4734 procedure TMainScreen.PaintDestination; 4735 4735 var 4736 Destination: integer;4736 Destination: Integer; 4737 4737 begin 4738 4738 if (UnFocus >= 0) and (MyUn[UnFocus].Status and usGoto <> 0) then … … 4755 4755 procedure TMainScreen.MainOffscreenPaint; 4756 4756 var 4757 ProcessOptions: integer;4757 ProcessOptions: Integer; 4758 4758 rec: TRect; 4759 DoInvalidate: boolean;4760 begin 4761 if me < 0 then4762 with offscreen.Canvas do4759 DoInvalidate: Boolean; 4760 begin 4761 if Me < 0 then 4762 with Offscreen.Canvas do 4763 4763 begin 4764 4764 Brush.Color := $000000; … … 4766 4766 Brush.Style := bsClear; 4767 4767 OffscreenUser := self; 4768 exit;4768 Exit; 4769 4769 end; 4770 4770 … … 4777 4777 if MapValid and (xwd = xw) and (ywd = yw) then 4778 4778 MainMap.SetPaintBounds(0, 0, UsedOffscreenWidth, UsedOffscreenHeight); 4779 MapValid := false;4779 MapValid := False; 4780 4780 OffscreenUser := self; 4781 4781 end; … … 4790 4790 (ywd - yw > MapHeight div yyt) then 4791 4791 begin 4792 offscreen.Canvas.Font.Assign(UniFont[ftSmall]);4792 Offscreen.Canvas.Font.Assign(UniFont[ftSmall]); 4793 4793 ProcessRect(xw, yw, MapWidth div xxt, MapHeight div yyt, 4794 4794 prPaint or prInvalidate); 4795 4795 end else begin 4796 4796 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]); 4799 4799 rec := Rect(0, 0, MapWidth, MapHeight); 4800 4800 {$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, 4802 4802 rec, rec, 0, nil); 4803 4803 {$ENDIF} 4804 4804 {$IFDEF UNIX} 4805 ScrollDC( offscreen.Canvas, (xwd - xw) * (xxt * 2), (ywd - yw) * yyt,4805 ScrollDC(Offscreen.Canvas, (xwd - xw) * (xxt * 2), (ywd - yw) * yyt, 4806 4806 rec, rec, 0, nil); 4807 4807 {$ENDIF} 4808 for DoInvalidate := false to FastScrolling do begin4808 for DoInvalidate := False to FastScrolling do begin 4809 4809 if DoInvalidate then begin 4810 4810 rec.Bottom := MapHeight - overlap; … … 4863 4863 xwd := xw; 4864 4864 ywd := yw; 4865 MapValid := true;4865 MapValid := True; 4866 4866 end; 4867 4867 … … 4920 4920 function MovementToString(var Un: TUn): string; 4921 4921 begin 4922 result := ScreenTools.MovementToString(Un.Movement);4922 Result := ScreenTools.MovementToString(Un.Movement); 4923 4923 if Un.Master >= 0 then 4924 result := '(' + result + ')'4924 Result := '(' + Result + ')' 4925 4925 else if (MyModel[Un.mix].Domain = dAir) and 4926 4926 (MyModel[Un.mix].Kind <> mkSpecial_Glider) then 4927 result := Format('%s(%d)', [result, Un.Fuel]);4927 Result := Format('%s(%d)', [Result, Un.Fuel]); 4928 4928 end; 4929 4929 4930 4930 var 4931 i, uix, uixDefender, x, xSrc, ySrc, xSrcBase, ySrcBase, CostFactor, Count,4931 I, uix, uixDefender, X, xSrc, ySrc, xSrcBase, ySrcBase, CostFactor, Count, 4932 4932 mixShow, xTreasurySection, xResearchSection, JobFocus, TrueMoney, 4933 TrueResearch: integer;4933 TrueResearch: Integer; 4934 4934 Tile: Cardinal; 4935 s: string;4935 S: string; 4936 4936 unx: TUn; 4937 4937 UnitInfo: TUnitInfo; 4938 4938 JobProgressData: TJobProgressData; 4939 Prio: boolean;4939 Prio: Boolean; 4940 4940 begin 4941 4941 if not Assigned(MyRO) then Exit; … … 5014 5014 CopyMiniToPanel; 5015 5015 if ClientMode <> cEditMap then // MapBtn icons 5016 for i:= 0 to 5 do5017 if i<> 3 then5018 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); 5020 5020 5021 5021 if ClientMode = cEditMap then 5022 5022 begin 5023 for i:= 0 to TrRow - 1 do5024 trix[ i] := -1;5023 for I := 0 to TrRow - 1 do 5024 trix[I] := -1; 5025 5025 Count := 0; 5026 for i:= 0 to nBrushTypes - 1 do5026 for I := 0 to nBrushTypes - 1 do 5027 5027 begin // display terrain types 5028 5028 if (Count >= TrRow * sb.Position) and (Count < TrRow * (sb.Position + 1)) 5029 5029 then 5030 5030 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; 5033 5033 xSrcBase := -1; 5034 case BrushTypes[ i] of5034 case BrushTypes[I] of 5035 5035 0 .. 8: 5036 5036 begin 5037 xSrc := BrushTypes[ i];5037 xSrc := BrushTypes[I]; 5038 5038 ySrc := 0 5039 5039 end; … … 5043 5043 ySrcBase := 2; 5044 5044 xSrc := 0; 5045 ySrc := 2 * integer(BrushTypes[i]) - 155045 ySrc := 2 * Integer(BrushTypes[I]) - 15 5046 5046 end; 5047 5047 fRiver: … … 5076 5076 ySrcBase := 2; 5077 5077 xSrc := 8; 5078 ySrc := 12 + BrushTypes[ i] shr 25;5078 ySrc := 12 + BrushTypes[I] shr 25; 5079 5079 end; 5080 5080 tiIrrigation, tiFarm, tiMine, tiBase: 5081 5081 begin 5082 xSrc := BrushTypes[ i] shr 12 - 1;5082 xSrc := BrushTypes[I] shr 12 - 1; 5083 5083 ySrc := 12 5084 5084 end; … … 5103 5103 with MainMap do begin 5104 5104 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, 5106 5106 yyt * 3, 1 + xSrcBase * (xxt * 2 + 1), 5107 5107 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, 5109 5109 yyt * 3, 1 + xSrc * (xxt * 2 + 1), 1 + ySrc * (yyt * 3 + 1)); 5110 if BrushTypes[ i] = BrushType then begin5111 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, 5113 5113 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, 5116 5116 yTroop + 2 * yyt + 10, MainTexture.ColorMark, MainTexture.ColorMark); 5117 5117 end; 5118 5118 end; 5119 5119 end; 5120 inc(Count)5120 Inc(Count) 5121 5121 end; 5122 5122 case BrushType of 5123 5123 fDesert, fPrairie, fTundra, fArctic, fSwamp, fHills, fMountains: 5124 s:= Phrases.Lookup('TERRAIN', BrushType);5124 S := Phrases.Lookup('TERRAIN', BrushType); 5125 5125 fShore: 5126 s:= Format(Phrases.Lookup('TWOTERRAINS'),5126 S := Format(Phrases.Lookup('TWOTERRAINS'), 5127 5127 [Phrases.Lookup('TERRAIN', fOcean), Phrases.Lookup('TERRAIN', 5128 5128 fShore)]); 5129 5129 fGrass: 5130 s:= Format(Phrases.Lookup('TWOTERRAINS'),5130 S := Format(Phrases.Lookup('TWOTERRAINS'), 5131 5131 [Phrases.Lookup('TERRAIN', fGrass), Phrases.Lookup('TERRAIN', 5132 5132 fGrass + 12)]); 5133 5133 fForest: 5134 s:= Format(Phrases.Lookup('TWOTERRAINS'),5134 S := Format(Phrases.Lookup('TWOTERRAINS'), 5135 5135 [Phrases.Lookup('TERRAIN', fForest), Phrases.Lookup('TERRAIN', 5136 5136 fJungle)]); 5137 5137 fRiver: 5138 s:= Phrases.Lookup('RIVER');5138 S := Phrases.Lookup('RIVER'); 5139 5139 fDeadLands, fDeadLands or fCobalt, fDeadLands or fUranium, 5140 5140 fDeadLands or fMercury: 5141 s:= Phrases.Lookup('TERRAIN', 3 * 12 + BrushType shr 25);5141 S := Phrases.Lookup('TERRAIN', 3 * 12 + BrushType shr 25); 5142 5142 fPrefStartPos: 5143 s:= Phrases.Lookup('MAP_PREFSTART');5143 S := Phrases.Lookup('MAP_PREFSTART'); 5144 5144 fStartPos: 5145 s:= Phrases.Lookup('MAP_START');5145 S := Phrases.Lookup('MAP_START'); 5146 5146 fPoll: 5147 s:= Phrases.Lookup('POLL');5147 S := Phrases.Lookup('POLL'); 5148 5148 else // terrain improvements 5149 5149 begin 5150 5150 case BrushType of 5151 5151 fRoad: 5152 i:= 1;5152 I := 1; 5153 5153 fRR: 5154 i:= 2;5154 I := 2; 5155 5155 tiIrrigation: 5156 i:= 4;5156 I := 4; 5157 5157 tiFarm: 5158 i:= 5;5158 I := 5; 5159 5159 tiMine: 5160 i:= 7;5160 I := 7; 5161 5161 fCanal: 5162 i:= 8;5162 I := 8; 5163 5163 tiFort: 5164 i:= 10;5164 I := 10; 5165 5165 tiBase: 5166 i:= 12;5166 I := 12; 5167 5167 end; 5168 s := Phrases.Lookup('JOBRESULT', i);5168 S := Phrases.Lookup('JOBRESULT', I); 5169 5169 end 5170 5170 end; 5171 5171 LoweredTextOut(Panel.Canvas, -1, MainTexture, xTroop + 1, 5172 PanelHeight - 19, s);5172 PanelHeight - 19, S); 5173 5173 end 5174 5174 else if TroopLoc >= 0 then … … 5183 5183 else 5184 5184 mixShow := mix; 5185 with Tribe[ me].ModelPicture[mixShow] do5185 with Tribe[Me].ModelPicture[mixShow] do 5186 5186 begin 5187 5187 Sprite(Panel, HGr, xMidPanel + 7 + 12, yTroop + 1, 64, 48, … … 5193 5193 5194 5194 MakeBlue(Panel, xMidPanel + 7 + 12 + 10, yTroop - 13, 44, 12); 5195 s:= MovementToString(MyUn[UnFocus]);5195 S := MovementToString(MyUn[UnFocus]); 5196 5196 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) + '%'; 5200 5200 LightGradient(Panel.Canvas, xMidPanel + 7 + 12 + 7, PanelHeight - 22, 5201 5201 (Health + 1) div 2, (ColorOfHealth(Health) and $FEFEFE shr 2) * 3); … … 5204 5204 div 2, PanelHeight - 22, 50 - (Health + 1) div 2, $000000); 5205 5205 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); 5207 5207 5208 5208 FrameImage(Panel.Canvas, HGrSystem.Data, … … 5210 5210 121 + Exp div ExpCost * 13, 28); 5211 5211 if Job = jCity then 5212 s := Tribe[me].ModelName[-1]5212 S := Tribe[Me].ModelName[-1] 5213 5213 else 5214 s := Tribe[me].ModelName[mix];5214 S := Tribe[Me].ModelName[mix]; 5215 5215 if Home >= 0 then 5216 5216 begin 5217 5217 LoweredTextOut(Panel.Canvas, -1, MainTexture, 5218 xMidPanel + 7 + xUnitText + 18, yTroop + 5, s);5218 xMidPanel + 7 + xUnitText + 18, yTroop + 5, S); 5219 5219 LoweredTextOut(Panel.Canvas, -1, MainTexture, 5220 5220 xMidPanel + 7 + xUnitText + 18, yTroop + 21, … … 5223 5223 else 5224 5224 LoweredTextOut(Panel.Canvas, -1, MainTexture, 5225 xMidPanel + 7 + xUnitText + 18, yTroop + 13, s);5225 xMidPanel + 7 + xUnitText + 18, yTroop + 13, S); 5226 5226 end; 5227 5227 5228 5228 if (UnFocus >= 0) and (MyUn[UnFocus].Loc <> TroopLoc) then 5229 5229 begin // divide panel 5230 if SmallScreen and not supervising then5231 x:= xTroop - 85230 if SmallScreen and not Supervising then 5231 X := xTroop - 8 5232 5232 else 5233 x:= xTroop - 152;5233 X := xTroop - 152; 5234 5234 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); 5237 5237 Pen.Color := MainTexture.ColorBevelLight; 5238 MoveTo( x, PanelHeight - MidPanelHeight + 2);5239 LineTo( x, PanelHeight);5240 end; 5241 5242 for i:= 0 to 23 do5243 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; 5244 5244 if MyMap[TroopLoc] and fUnit <> 0 then 5245 5245 begin … … 5251 5251 LoweredTextOut(Panel.Canvas, -1, MainTexture, xTroop + 10, 5252 5252 PanelHeight - 24, Phrases.Lookup('PRESENT')); 5253 Server(sGetDefender, me, TroopLoc, uixDefender);5253 Server(sGetDefender, Me, TroopLoc, uixDefender); 5254 5254 Count := 0; 5255 for Prio := true downto false do5255 for Prio := True downto False do 5256 5256 for uix := 0 to MyRO.nUn - 1 do 5257 5257 if (uix = uixDefender) = Prio then … … 5264 5264 begin 5265 5265 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; 5268 5268 if uix = UnFocus then 5269 5269 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, 5272 5272 $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, 5275 5275 MainTexture.ColorMark, MainTexture.ColorMark); 5276 5276 end 5277 5277 else if (unx.Master >= 0) and (unx.Master = UnFocus) then 5278 5278 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); 5283 5283 end; 5284 5284 NoMapPanel.SetOutput(Panel); 5285 NoMapPanel.PaintUnit(xTroop + 2 + x, yTroop + 1, UnitInfo,5285 NoMapPanel.PaintUnit(xTroop + 2 + X, yTroop + 1, UnitInfo, 5286 5286 unx.Status); 5287 5287 if (ClientMode < scContact) and … … 5289 5289 (unx.Status and (usStay or usRecover or usGoto) <> 0)) 5290 5290 then 5291 Sprite(Panel, HGrSystem, xTroop + 2 + 60 - 20 + x,5291 Sprite(Panel, HGrSystem, xTroop + 2 + 60 - 20 + X, 5292 5292 yTroop + 35, 20, 20, 81, 25); 5293 5293 5294 if not supervising then5294 if not Supervising then 5295 5295 begin 5296 MakeBlue(Panel, xTroop + 2 + 10 + x,5296 MakeBlue(Panel, xTroop + 2 + 10 + X, 5297 5297 yTroop - 13, 44, 12); 5298 s:= MovementToString(unx);5298 S := MovementToString(unx); 5299 5299 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); 5302 5302 end; 5303 5303 end; 5304 inc(Count)5304 Inc(Count) 5305 5305 end; 5306 5306 end; // for uix:=0 to MyRO.nUn-1 5307 assert(Count = TrCnt);5307 Assert(Count = TrCnt); 5308 5308 end; 5309 5309 end … … 5312 5312 LoweredTextOut(Panel.Canvas, -1, MainTexture, xTroop + 8, 5313 5313 PanelHeight - 24, Phrases.Lookup('PRESENT')); 5314 Server(sGetUnits, me, TroopLoc, Count);5315 for i:= 0 to Count - 1 do5316 if ( i >= TrRow * sb.Position) and (i< TrRow * (sb.Position + 1)) then5314 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 5317 5317 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; 5320 5320 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); 5323 5323 end; 5324 5324 end; 5325 5325 end; 5326 if not SmallScreen or supervising then5326 if not SmallScreen or Supervising then 5327 5327 begin // show terrain and improvements 5328 5328 with NoMapPanel do … … 5330 5330 if (UnFocus >= 0) and (MyUn[UnFocus].Job <> jNone) then begin 5331 5331 JobFocus := MyUn[UnFocus].Job; 5332 Server(sGetJobProgress, me, MyUn[UnFocus].Loc, JobProgressData);5332 Server(sGetJobProgress, Me, MyUn[UnFocus].Loc, JobProgressData); 5333 5333 MakeBlue(Panel, xTerrain - 72, 148 - 17, 144, 31); 5334 5334 PaintRelativeProgressBar(Panel.Canvas, 3, xTerrain - 68, 148 + 3, 63, 5335 5335 JobProgressData[JobFocus].Done, 5336 5336 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', 5339 5339 [ScreenTools.MovementToString(JobProgressData[JobFocus].Done), 5340 5340 ScreenTools.MovementToString(JobProgressData[JobFocus].Required)]); 5341 RisedTextOut(Panel.Canvas, xTerrain + 6, 148 - 3, s);5341 RisedTextOut(Panel.Canvas, xTerrain + 6, 148 - 3, S); 5342 5342 Tile := MyMap[MyUn[UnFocus].Loc]; 5343 5343 if (JobFocus = jRoad) and (Tile and fRiver <> 0) then … … 5354 5354 JobFocus := nJob + 4 5355 5355 end; 5356 s:= Phrases.Lookup('JOBRESULT', JobFocus);5356 S := Phrases.Lookup('JOBRESULT', JobFocus); 5357 5357 RisedTextOut(Panel.Canvas, xTerrain - BiColorTextWidth(Panel.Canvas, 5358 s) div 2, 148 - 19, s);5358 S) div 2, 148 - 19, S); 5359 5359 end; 5360 5360 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) 5362 5362 else if MyMap[TroopLoc] and fDeadLands <> 0 then 5363 s:= Phrases.Lookup('TERRAIN', 3 * 12)5363 S := Phrases.Lookup('TERRAIN', 3 * 12) 5364 5364 else if (MyMap[TroopLoc] and fTerrain = fForest) and 5365 5365 IsJungle(TroopLoc div G.lx) then 5366 s:= Phrases.Lookup('TERRAIN', fJungle)5366 S := Phrases.Lookup('TERRAIN', fJungle) 5367 5367 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); 5371 5371 end; 5372 5372 … … 5379 5379 end; 5380 5380 5381 for i:= 0 to ControlCount - 1 do5382 if Controls[ i] is TButtonB then5383 with TButtonB(Controls[ i]) do5381 for I := 0 to ControlCount - 1 do 5382 if Controls[I] is TButtonB then 5383 with TButtonB(Controls[I]) do 5384 5384 begin 5385 5385 if Visible then … … 5397 5397 if ClientMode <> cEditMap then 5398 5398 begin 5399 for i:= 0 to ControlCount - 1 do5400 if Controls[ i] is TButtonC then5401 with TButtonC(Controls[ i]) do5399 for I := 0 to ControlCount - 1 do 5400 if Controls[I] is TButtonC then 5401 with TButtonC(Controls[I]) do 5402 5402 begin 5403 5403 Dump(Panel, HGrSystem, Left, Top - self.ClientHeight + PanelHeight, … … 5439 5439 TrueMoney := MyRO.Money; 5440 5440 TrueResearch := MyRO.Research; 5441 if supervising then5441 if Supervising then 5442 5442 begin // normalize values from after-turn state 5443 dec(TrueMoney, TaxSum);5443 Dec(TrueMoney, TaxSum); 5444 5444 if TrueMoney < 0 then 5445 5445 TrueMoney := 0; // shouldn't happen 5446 dec(TrueResearch, ScienceSum);5446 Dec(TrueResearch, ScienceSum); 5447 5447 if TrueResearch < 0 then 5448 5448 TrueResearch := 0; // shouldn't happen … … 5452 5452 ImageOp_BCC(TopBar, Templates.Data, Point(xTreasurySection + 8, 1), TreasuryIcon.BoundsRect, 5453 5453 $40A040, $4030C0); 5454 s:= IntToStr(TrueMoney);5454 S := IntToStr(TrueMoney); 5455 5455 LoweredTextOut(TopBar.Canvas, -1, MainTexture, xTreasurySection + 48, 0, 5456 s+ '%c');5456 S + '%c'); 5457 5457 if MyRO.Government <> gAnarchy then 5458 5458 begin … … 5460 5460 $0000C0, $0080C0); 5461 5461 if TaxSum >= 0 then 5462 s:= Format(Phrases.Lookup('MONEYGAINPOS'), [TaxSum])5462 S := Format(Phrases.Lookup('MONEYGAINPOS'), [TaxSum]) 5463 5463 else 5464 s:= Format(Phrases.Lookup('MONEYGAINNEG'), [TaxSum]);5464 S := Format(Phrases.Lookup('MONEYGAINNEG'), [TaxSum]); 5465 5465 LoweredTextOut(TopBar.Canvas, -1, MainTexture, xTreasurySection + 48 + 5466 15, 18, s);5466 15, 18, S); 5467 5467 end; 5468 5468 … … 5484 5484 else 5485 5485 CostFactor := 2; 5486 Server(sGetTechCost, me, 0, i);5486 Server(sGetTechCost, Me, 0, I); 5487 5487 CostFactor := CostFactor * 22; // length of progress bar 5488 5488 PaintRelativeProgressBar(TopBar.Canvas, 2, xResearchSection + 48 + 1, 26, 5489 CostFactor, TrueResearch, ScienceSum, i, true, MainTexture);5489 CostFactor, TrueResearch, ScienceSum, I, True, MainTexture); 5490 5490 5491 5491 if MyRO.ResearchTech < 0 then 5492 s:= Phrases.Lookup('SCIENCE')5492 S := Phrases.Lookup('SCIENCE') 5493 5493 else if MyRO.ResearchTech = adMilitary then 5494 s:= Phrases.Lookup('INITUNIT')5494 S := Phrases.Lookup('INITUNIT') 5495 5495 else 5496 5496 begin 5497 s:= Phrases.Lookup('ADVANCES', MyRO.ResearchTech);5497 S := Phrases.Lookup('ADVANCES', MyRO.ResearchTech); 5498 5498 if MyRO.ResearchTech in FutureTech then 5499 5499 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) 5501 5501 else 5502 s := s+ ' 1';5502 S := S + ' 1'; 5503 5503 end; 5504 5504 if ScienceSum > 0 then 5505 5505 begin 5506 5506 { j:=(i-MyRO.Research-1) div ScienceSum +1; 5507 if j<1 then j:=1;5508 if j>1 then5509 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]); } 5510 5510 LoweredTextOut(TopBar.Canvas, -1, MainTexture, 5511 xResearchSection + 48, 0, s);5511 xResearchSection + 48, 0, S); 5512 5512 end 5513 5513 else 5514 5514 LoweredTextOut(TopBar.Canvas, -1, MainTexture, 5515 xResearchSection + 48, 0, s);5515 xResearchSection + 48, 0, S); 5516 5516 end 5517 5517 else … … 5521 5521 ImageOp_BCC(TopBar, Templates.Data, Point(xResearchSection + 48 + CostFactor + 11, 5522 5522 22), ChangeIcon.BoundsRect, $0000C0, $0080C0); 5523 s:= Format(Phrases.Lookup('TECHGAIN'), [ScienceSum]);5523 S := Format(Phrases.Lookup('TECHGAIN'), [ScienceSum]); 5524 5524 LoweredTextOut(TopBar.Canvas, -1, MainTexture, xResearchSection + 48 + 5525 CostFactor + 26, 18, s);5525 CostFactor + 26, 18, S); 5526 5526 end; 5527 5527 end; … … 5529 5529 begin 5530 5530 TopBar.Canvas.Font.Assign(UniFont[ftCaption]); 5531 s:= TurnToString(MyRO.Turn);5531 S := TurnToString(MyRO.Turn); 5532 5532 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); 5535 5535 TopBar.Canvas.Font.Assign(UniFont[ftNormal]); 5536 5536 end; … … 5540 5540 procedure TMainScreen.FocusNextUnit(Dir: Integer); 5541 5541 var 5542 i, uix, NewFocus: Integer;5542 I, uix, NewFocus: Integer; 5543 5543 begin 5544 5544 if ClientMode >= scContact then … … 5547 5547 PaintDestination; 5548 5548 NewFocus := -1; 5549 for i:= 1 to MyRO.nUn do begin5550 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; 5551 5551 if (MyUn[uix].Loc >= 0) and (MyUn[uix].Status and usStay = 0) then begin 5552 5552 NewFocus := uix; … … 5561 5561 end; 5562 5562 5563 procedure TMainScreen.FocusOnLoc(Loc: integer; Options: integer = 0);5563 procedure TMainScreen.FocusOnLoc(Loc: Integer; Options: Integer = 0); 5564 5564 var 5565 dx: integer;5566 Outside, Changed: boolean;5565 dx: Integer; 5566 Outside, Changed: Boolean; 5567 5567 begin 5568 5568 with MainMap do begin … … 5572 5572 (Loc div G.lx >= yw + (MapHeight - 1) div yyt - 2)); 5573 5573 end; 5574 Changed := true;5574 Changed := True; 5575 5575 if Outside then begin 5576 5576 Centre(Loc); … … 5580 5580 PaintAllMaps 5581 5581 else 5582 Changed := false;5582 Changed := False; 5583 5583 if Options and flRepaintPanel <> 0 then 5584 5584 PanelPaint; … … 5590 5590 var 5591 5591 Dist, TestDist: Single; 5592 i, uix, NewFocus: Integer;5592 I, uix, NewFocus: Integer; 5593 5593 GotoOnly: Boolean; 5594 5594 begin … … 5600 5600 for GotoOnly := GoOnPhase downto False do begin 5601 5601 NewFocus := -1; 5602 for i:= 1 to MyRO.nUn do begin5603 uix := (UnFocus + i) mod MyRO.nUn;5602 for I := 1 to MyRO.nUn do begin 5603 uix := (UnFocus + I) mod MyRO.nUn; 5604 5604 if (MyUn[uix].Loc >= 0) and (MyUn[uix].Job = jNone) and 5605 5605 (MyUn[uix].Status and (usStay or usRecover or usWaiting) = usWaiting) … … 5640 5640 end; 5641 5641 5642 procedure TMainScreen.Scroll(dx, dy: integer);5642 procedure TMainScreen.Scroll(dx, dy: Integer); 5643 5643 begin 5644 5644 xw := (xw + G.lx + dx) mod G.lx; … … 5664 5664 procedure TMainScreen.Timer1Timer(Sender: TObject); 5665 5665 var 5666 dx, dy, ScrollSpeed: integer;5667 begin 5668 if idle and (me >= 0) and (GameMode <> cMovie) then5666 dx, dy, ScrollSpeed: Integer; 5667 begin 5668 if Idle and (Me >= 0) and (GameMode <> cMovie) then 5669 5669 if (fsModal in Screen.ActiveForm.FormState) or 5670 5670 (Screen.ActiveForm is TBufferedDrawDlg) and … … 5674 5674 if not BlinkON then 5675 5675 begin 5676 BlinkON := true;5676 BlinkON := True; 5677 5677 if UnFocus >= 0 then 5678 5678 PaintLocTemp(MyUn[UnFocus].Loc) 5679 else if TurnComplete and not supervising then5679 else if TurnComplete and not Supervising then 5680 5680 EOT.SetButtonIndexFast(eotBlinkOn); 5681 5681 end; … … 5689 5689 dx := 0; 5690 5690 dy := 0; 5691 if Mouse.CursorPos. y< Screen.height - PanelHeight then5692 if Mouse.CursorPos. x= 0 then5691 if Mouse.CursorPos.Y < Screen.height - PanelHeight then 5692 if Mouse.CursorPos.X = 0 then 5693 5693 dx := -ScrollSpeed // scroll left 5694 else if Mouse.CursorPos. x= Screen.width - 1 then5694 else if Mouse.CursorPos.X = Screen.width - 1 then 5695 5695 dx := ScrollSpeed; // scroll right 5696 if Mouse.CursorPos. y= 0 then5696 if Mouse.CursorPos.Y = 0 then 5697 5697 dy := -ScrollSpeed // scroll up 5698 else if (Mouse.CursorPos. y= Screen.height - 1) and5699 (Mouse.CursorPos. x>= TerrainBtn.Left + TerrainBtn.width) and5700 (Mouse.CursorPos. x< xRightPanel + 10 - 8) then5698 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 5701 5701 dy := ScrollSpeed; // scroll down 5702 5702 if (dx <> 0) or (dy <> 0) then … … 5711 5711 BlinkTime := (BlinkTime + 1) mod (BlinkOnTime + BlinkOffTime); 5712 5712 BlinkON := BlinkTime >= BlinkOffTime; 5713 DestinationMarkON := true;5713 DestinationMarkON := True; 5714 5714 if UnFocus >= 0 then 5715 5715 begin … … 5722 5722 end; 5723 5723 end 5724 else if TurnComplete and not supervising then5724 else if TurnComplete and not Supervising then 5725 5725 begin 5726 5726 if BlinkTime = 0 then … … 5732 5732 end; 5733 5733 5734 procedure TMainScreen.SetMapPos(Loc: integer; MapPos: TPoint);5734 procedure TMainScreen.SetMapPos(Loc: Integer; MapPos: TPoint); 5735 5735 begin 5736 5736 with MainMap do begin … … 5750 5750 end; 5751 5751 5752 procedure TMainScreen.Centre(Loc: integer);5752 procedure TMainScreen.Centre(Loc: Integer); 5753 5753 begin 5754 5754 SetMapPos(Loc, Point(MapWidth div 2, MapHeight div 2)); 5755 5755 end; 5756 5756 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 then5757 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 5762 5762 with CityDlg do 5763 5763 begin … … 5785 5785 end; 5786 5786 5787 function TMainScreen.LocationOfScreenPixel( x, y: integer): Integer;5787 function TMainScreen.LocationOfScreenPixel(X, Y: Integer): Integer; 5788 5788 var 5789 qx, qy: integer;5789 qx, qy: Integer; 5790 5790 begin 5791 5791 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) 5794 5794 div (xxt * yyt * 4) - 999; 5795 5795 Result := (xw + (qx - qy + 2048) div 2 - 1024 + G.lx) mod G.lx + G.lx * … … 5805 5805 5806 5806 procedure TMainScreen.MapBoxMouseDown(Sender: TObject; Button: TMouseButton; 5807 Shift: TShiftState; x, y: integer);5807 Shift: TShiftState; X, Y: Integer); 5808 5808 var 5809 i, uix, emix, p1, dx, dy, MouseLoc: integer;5809 I, uix, emix, p1, dx, dy, MouseLoc: Integer; 5810 5810 EditTileData: TEditTileData; 5811 m, m2: TMenuItem;5811 M, m2: TMenuItem; 5812 5812 MoveAdviceData: TMoveAdviceData; 5813 DoCenter: boolean;5813 DoCenter: Boolean; 5814 5814 begin 5815 5815 if GameMode = cMovie then 5816 exit;5816 Exit; 5817 5817 5818 5818 if CityDlg.Visible then … … 5820 5820 if UnitStatDlg.Visible then 5821 5821 UnitStatDlg.Close; 5822 MouseLoc := LocationOfScreenPixel( x, y);5822 MouseLoc := LocationOfScreenPixel(X, Y); 5823 5823 if (MouseLoc < 0) or (MouseLoc >= G.lx * G.ly) then 5824 exit;5824 Exit; 5825 5825 if (Button = mbLeft) and not(ssShift in Shift) then 5826 5826 begin 5827 DoCenter := true;5827 DoCenter := True; 5828 5828 if ClientMode = cEditMap then 5829 5829 begin 5830 DoCenter := false;5830 DoCenter := False; 5831 5831 EditTileData.Loc := MouseLoc; 5832 5832 if ssCtrl in Shift then // toggle special resource … … 5866 5866 else 5867 5867 EditTileData.NewTile := MyMap[MouseLoc] xor BrushType; 5868 Server(sEditTile, me, 0, EditTileData);5869 Edited := true;5868 Server(sEditTile, Me, 0, EditTileData); 5869 Edited := True; 5870 5870 BrushLoc := MouseLoc; 5871 5871 PaintLoc(MouseLoc, 2); … … 5893 5893 begin 5894 5894 ZoomToCity(MouseLoc); 5895 DoCenter := false;5895 DoCenter := False; 5896 5896 end 5897 5897 else 5898 5898 begin 5899 5899 UnitStatDlg.ShowNewContent_EnemyCity(wmPersistent, MouseLoc); 5900 DoCenter := false;5900 DoCenter := False; 5901 5901 end; 5902 5902 end … … 5904 5904 if MyMap[MouseLoc] and fOwned <> 0 then 5905 5905 begin 5906 DoCenter := false;5907 if not supervising and (ClientMode < scContact) then5906 DoCenter := False; 5907 if not Supervising and (ClientMode < scContact) then 5908 5908 begin // not in negotiation mode 5909 5909 if (UnFocus >= 0) and (MyUn[UnFocus].Loc = MouseLoc) then 5910 5910 begin // rotate 5911 5911 uix := (UnFocus + 1) mod MyRO.nUn; 5912 i:= MyRO.nUn - 1;5913 while i> 0 do5912 I := MyRO.nUn - 1; 5913 while I > 0 do 5914 5914 begin 5915 5915 if (MyUn[uix].Loc = MouseLoc) and (MyUn[uix].Job = jNone) and … … 5917 5917 usWaiting) = usWaiting) then 5918 5918 Break; 5919 dec(i);5919 Dec(I); 5920 5920 uix := (uix + 1) mod MyRO.nUn; 5921 5921 end; 5922 if i= 0 then5922 if I = 0 then 5923 5923 uix := UnFocus; 5924 5924 end 5925 5925 else 5926 Server(sGetDefender, me, MouseLoc, uix);5926 Server(sGetDefender, Me, MouseLoc, uix); 5927 5927 if uix <> UnFocus then 5928 5928 SetUnFocus(uix); 5929 TurnComplete := false;5929 TurnComplete := False; 5930 5930 EOT.ButtonIndex := eotGray; 5931 5931 end; … … 5935 5935 else if (MyMap[MouseLoc] and fSpiedOut <> 0) and not(ssCtrl in Shift) then 5936 5936 begin 5937 DoCenter := false;5937 DoCenter := False; 5938 5938 SetTroopLoc(MouseLoc); 5939 5939 PanelPaint; … … 5941 5941 else 5942 5942 begin 5943 DoCenter := false;5943 DoCenter := False; 5944 5944 UnitStatDlg.ShowNewContent_EnemyLoc(wmPersistent, MouseLoc); 5945 5945 end; … … 5953 5953 not(ssShift in Shift) then 5954 5954 begin 5955 if supervising then5955 if Supervising then 5956 5956 begin 5957 5957 EditLoc := MouseLoc; 5958 Server(sGetModels, me, 0, nil^);5958 Server(sGetModels, Me, 0, nil^); 5959 5959 EmptyMenu(mCreateUnit); 5960 5960 for p1 := 0 to nPl - 1 do 5961 5961 if 1 shl p1 and MyRO.Alive <> 0 then 5962 5962 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'); 5965 5965 for emix := MyRO.nEnemyModel - 1 downto 0 do 5966 5966 if (MyRO.EnemyModel[emix].Owner = p1) and 5967 (Server(sCreateUnit - sExecute + p1 shl 4, me,5967 (Server(sCreateUnit - sExecute + p1 shl 4, Me, 5968 5968 MyRO.EnemyModel[emix].mix, MouseLoc) >= rExecuted) then 5969 5969 begin 5970 5970 if not Assigned(Tribe[p1].ModelPicture[MyRO.EnemyModel[emix].mix].HGr) then 5971 5971 InitEnemyModel(emix); 5972 m2 := TMenuItem.Create( m);5972 m2 := TMenuItem.Create(M); 5973 5973 m2.Caption := Tribe[p1].ModelName[MyRO.EnemyModel[emix].mix]; 5974 5974 m2.Tag := p1 shl 16 + MyRO.EnemyModel[emix].mix; 5975 5975 m2.OnClick := CreateUnitClick; 5976 m.Add(m2);5976 M.Add(m2); 5977 5977 end; 5978 m.Visible := m.Count > 0;5979 mCreateUnit.Add( m);5978 M.Visible := M.Count > 0; 5979 mCreateUnit.Add(M); 5980 5980 end; 5981 5981 if FullScreen then 5982 EditPopup.Popup(Left + x, Top + y)5982 EditPopup.Popup(Left + X, Top + Y) 5983 5983 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); 5986 5986 end 5987 5987 else if (UnFocus >= 0) and (MyUn[UnFocus].Loc <> MouseLoc) then … … 5994 5994 if abs(dx) + abs(dy) < 3 then 5995 5995 begin 5996 DestinationMarkON := false;5996 DestinationMarkON := False; 5997 5997 PaintDestination; 5998 5998 Status := Status and ($FFFF - usStay - usRecover - usGoto - usEnhance) … … 6007 6007 with MyUn[UnFocus], BattleDlg.Forecast do 6008 6008 begin 6009 pAtt := me;6009 pAtt := Me; 6010 6010 mixAtt := mix; 6011 6011 HealthAtt := Health; … … 6014 6014 end; 6015 6015 BattleDlg.Forecast.Movement := MyUn[UnFocus].Movement; 6016 if (Server(sGetBattleForecastEx, me, MouseLoc, BattleDlg.Forecast)6016 if (Server(sGetBattleForecastEx, Me, MouseLoc, BattleDlg.Forecast) 6017 6017 >= rExecuted) and (BattleDlg.Forecast.EndHealthAtt <= 0) then 6018 6018 begin 6019 6019 BattleDlg.uix := UnFocus; 6020 6020 BattleDlg.ToLoc := MouseLoc; 6021 BattleDlg.IsSuicideQuery := true;6021 BattleDlg.IsSuicideQuery := True; 6022 6022 BattleDlg.ShowModal; 6023 6023 if BattleDlg.ModalResult <> mrOK then 6024 exit;6024 Exit; 6025 6025 end; 6026 6026 end; 6027 DestinationMarkON := false;6027 DestinationMarkON := False; 6028 6028 PaintDestination; 6029 6029 Status := Status and not(usStay or usRecover or usEnhance) or 6030 6030 usWaiting; 6031 MoveToLoc(MouseLoc, false); { goto }6031 MoveToLoc(MouseLoc, False); { goto } 6032 6032 end; 6033 6033 end; … … 6036 6036 (MyModel[MyUn[UnFocus].mix].Kind in [mkSettler, mkSlaves]) then 6037 6037 begin 6038 DestinationMarkON := false;6038 DestinationMarkON := False; 6039 6039 PaintDestination; 6040 6040 MyUn[UnFocus].Status := MyUn[UnFocus].Status and … … 6042 6042 uix := UnFocus; 6043 6043 if MouseLoc <> MyUn[uix].Loc then 6044 MoveToLoc(MouseLoc, true); { goto }6044 MoveToLoc(MouseLoc, True); { goto } 6045 6045 if (UnFocus = uix) and (MyUn[uix].Loc = MouseLoc) then 6046 6046 mEnhance.Click; … … 6055 6055 with MyUn[UnFocus], BattleDlg.Forecast do 6056 6056 begin 6057 pAtt := me;6057 pAtt := Me; 6058 6058 mixAtt := mix; 6059 6059 HealthAtt := Health; … … 6062 6062 end; 6063 6063 BattleDlg.Forecast.Movement := MyUn[UnFocus].Movement; 6064 if Server(sGetBattleForecastEx, me, MouseLoc, BattleDlg.Forecast) >= rExecuted6064 if Server(sGetBattleForecastEx, Me, MouseLoc, BattleDlg.Forecast) >= rExecuted 6065 6065 then 6066 6066 begin 6067 6067 BattleDlg.uix := UnFocus; 6068 6068 BattleDlg.ToLoc := MouseLoc; 6069 BattleDlg.Left := x- BattleDlg.width div 2;6069 BattleDlg.Left := X - BattleDlg.width div 2; 6070 6070 if BattleDlg.Left < 0 then 6071 6071 BattleDlg.Left := 0 6072 6072 else if BattleDlg.Left + BattleDlg.width > Screen.width then 6073 6073 BattleDlg.Left := Screen.width - BattleDlg.width; 6074 BattleDlg.Top := y- BattleDlg.height div 2;6074 BattleDlg.Top := Y - BattleDlg.height div 2; 6075 6075 if BattleDlg.Top < 0 then 6076 6076 BattleDlg.Top := 0 6077 6077 else if BattleDlg.Top + BattleDlg.height > Screen.height then 6078 6078 BattleDlg.Top := Screen.height - BattleDlg.height; 6079 BattleDlg.IsSuicideQuery := false;6079 BattleDlg.IsSuicideQuery := False; 6080 6080 BattleDlg.Show; 6081 6081 end; … … 6083 6083 end; 6084 6084 6085 function TMainScreen.MoveUnit(dx, dy: integer; Options: integer): integer;6085 function TMainScreen.MoveUnit(dx, dy: Integer; Options: Integer): Integer; 6086 6086 // move focused unit to adjacent tile 6087 6087 var 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; 6090 6090 OldToTile: Cardinal; 6091 6091 CityCaptured, IsAttack, OldUnrest, NewUnrest, NeedEcoUpdate, NeedRepaintPanel, 6092 ToTransport, ToShip: boolean;6092 ToTransport, ToShip: Boolean; 6093 6093 PlaneReturnData: TPlaneReturnData; 6094 6094 QueryItem: string; 6095 6095 begin 6096 result := eInvalid;6096 Result := eInvalid; 6097 6097 UnFocus0 := UnFocus; 6098 6098 FromLoc := MyUn[UnFocus].Loc; … … 6100 6100 if (ToLoc < 0) or (ToLoc >= G.lx * G.ly) then 6101 6101 begin 6102 result := eInvalid;6103 exit;6102 Result := eInvalid; 6103 Exit; 6104 6104 end; 6105 6105 if MyMap[ToLoc] and fStealthUnit <> 0 then 6106 6106 begin 6107 6107 SoundMessage(Phrases.Lookup('ATTACKSTEALTH'), ''); 6108 exit;6108 Exit; 6109 6109 end; 6110 6110 if MyMap[ToLoc] and fHiddenUnit <> 0 then 6111 6111 begin 6112 6112 SoundMessage(Phrases.Lookup('ATTACKSUB'), ''); 6113 exit;6113 Exit; 6114 6114 end; 6115 6115 … … 6121 6121 begin 6122 6122 SoundMessage(Phrases.Lookup('NOATTACKER'), ''); 6123 exit;6123 Exit; 6124 6124 end; 6125 6125 euix := MyRO.nEnemyUn - 1; 6126 6126 while (euix >= 0) and (MyRO.EnemyUn[euix].Loc <> ToLoc) do 6127 dec(euix);6127 Dec(euix); 6128 6128 end; 6129 6129 6130 6130 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) then6133 Server(sStartJob + jNone shl 4, me, UnFocus, nil^);6134 if ( result < rExecuted) and (result <> eNoTime_Move) then6135 begin 6136 case result of6131 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 6137 6137 eNoTime_Load: 6138 6138 if MyModel[MyUn[UnFocus].mix].Domain = dAir then … … 6170 6170 (MyMap[ToLoc] and (fUnit or fOwned) = fUnit or fOwned) then 6171 6171 begin // false load attempt 6172 ToShip := false;6173 ToTransport := false;6172 ToShip := False; 6173 ToTransport := False; 6174 6174 for uix := 0 to MyRO.nUn - 1 do 6175 6175 if (MyUn[uix].Loc = ToLoc) and 6176 6176 (MyModel[MyUn[uix].mix].Domain = dSea) then 6177 6177 begin 6178 ToShip := true;6178 ToShip := True; 6179 6179 if MyModel[MyUn[uix].mix].Cap[mcSeaTrans] > 0 then 6180 ToTransport := true;6180 ToTransport := True; 6181 6181 end; 6182 6182 if ToTransport then … … 6193 6193 Play('NOMOVE_DEFAULT'); 6194 6194 end; 6195 exit;6196 end; 6197 6198 if (( result = eWon) or (result = eLost) or (result = eBloody)) and6195 Exit; 6196 end; 6197 6198 if ((Result = eWon) or (Result = eLost) or (Result = eBloody)) and 6199 6199 (MyUn[UnFocus].Movement < 100) and 6200 6200 (MyModel[MyUn[UnFocus].mix].Cap[mcWill] = 0) then … … 6203 6203 [MyUn[UnFocus].Movement]), 'NOMOVE_TIME') <> mrOK then 6204 6204 begin 6205 result := eInvalid;6206 exit;6205 Result := eInvalid; 6206 Exit; 6207 6207 end; 6208 6208 Update; // remove message box from screen 6209 6209 end; 6210 6210 6211 OldUnrest := false;6212 NewUnrest := false;6213 if ( result >= rExecuted) and (result and rUnitRemoved = 0) and6211 OldUnrest := False; 6212 NewUnrest := False; 6213 if (Result >= rExecuted) and (Result and rUnitRemoved = 0) and 6214 6214 (MyMap[ToLoc] and (fUnit or fOwned) <> fUnit) then 6215 6215 begin … … 6221 6221 begin 6222 6222 QueryItem := 'UNREST_NOTOWN'; 6223 p1 := me;6223 p1 := Me; 6224 6224 end 6225 6225 else … … 6238 6238 if ModalResult <> mrOK then 6239 6239 begin 6240 result := eInvalid;6241 exit;6240 Result := eInvalid; 6241 Exit; 6242 6242 end; 6243 6243 end; … … 6246 6246 end; 6247 6247 6248 if ( result >= rExecuted) and (MyModel[MyUn[UnFocus].mix].Domain = dAir) and6248 if (Result >= rExecuted) and (MyModel[MyUn[UnFocus].mix].Domain = dAir) and 6249 6249 (MyUn[UnFocus].Status and usToldNoReturn = 0) then 6250 6250 begin // can plane return? … … 6266 6266 PlaneReturnData.Movement := MyUn[UnFocus].Movement - 150; 6267 6267 end; 6268 if Server(sGetPlaneReturn, me, UnFocus, PlaneReturnData) = eNoWay then6268 if Server(sGetPlaneReturn, Me, UnFocus, PlaneReturnData) = eNoWay then 6269 6269 begin 6270 6270 if MyModel[MyUn[UnFocus].mix].Kind = mkSpecial_Glider then … … 6275 6275 <> mrOK then 6276 6276 begin 6277 result := eInvalid;6278 exit;6277 Result := eInvalid; 6278 Exit; 6279 6279 end; 6280 6280 Update; // remove message box from screen … … 6283 6283 end; 6284 6284 6285 if result = eMissionDone then6285 if Result = eMissionDone then 6286 6286 begin 6287 6287 ModalSelectDlg.ShowNewContent(wmModal, kMission); 6288 6288 Update; // dialog still on screen 6289 Mission := ModalSelectDlg. result;6289 Mission := ModalSelectDlg.Result; 6290 6290 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 then6291 Exit; 6292 Server(sSetSpyMission + Mission shl 4, Me, 0, nil^); 6293 end; 6294 6295 CityCaptured := False; 6296 if Result = eNoTime_Move then 6297 6297 Play('NOMOVE_TIME') 6298 6298 else 6299 6299 begin 6300 NeedEcoUpdate := false;6301 DestinationMarkON := false;6300 NeedEcoUpdate := False; 6301 DestinationMarkON := False; 6302 6302 PaintDestination; 6303 if result and rUnitRemoved <> 0 then6303 if Result and rUnitRemoved <> 0 then 6304 6304 CityOptimizer_BeforeRemoveUnit(UnFocus); 6305 IsAttack := ( result = eBombarded) or (result <> eMissionDone) and6305 IsAttack := (Result = eBombarded) or (Result <> eMissionDone) and 6306 6306 (MyMap[ToLoc] and (fUnit or fOwned) = fUnit); 6307 6307 if not IsAttack then … … 6309 6309 cix := MyRO.nCity - 1; { look for own city at dest location } 6310 6310 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) 6313 6313 then 6314 CityCaptured := true;6315 result := Server(sMoveUnit + DirCode, me, UnFocus, nil^);6316 case result of6314 CityCaptured := True; 6315 Result := Server(sMoveUnit + DirCode, Me, UnFocus, nil^); 6316 case Result of 6317 6317 eHiddenUnit: 6318 6318 begin … … 6332 6332 rExecuted .. maxint: 6333 6333 begin 6334 if result and rUnitRemoved <> 0 then6334 if Result and rUnitRemoved <> 0 then 6335 6335 UnFocus := -1 // unit died 6336 6336 else 6337 6337 begin 6338 assert(UnFocus >= 0);6338 Assert(UnFocus >= 0); 6339 6339 MyUn[UnFocus].Status := MyUn[UnFocus].Status and 6340 6340 not(usStay or usRecover); … … 6346 6346 begin // borders have moved, unrest might have changed in any city 6347 6347 CityOptimizer_BeginOfTurn; 6348 NeedEcoUpdate := true;6348 NeedEcoUpdate := True; 6349 6349 end 6350 6350 else … … 6356 6356 if MyUn[uix].Master = UnFocus then 6357 6357 CityOptimizer_CityChange(MyUn[uix].Home); 6358 NeedEcoUpdate := true;6358 NeedEcoUpdate := True; 6359 6359 end; 6360 6360 if (MyRO.Government = gDespotism) and … … 6366 6366 while (cixChanged >= 0) and 6367 6367 (MyCity[cixChanged].Loc <> FromLoc) do 6368 dec(cixChanged);6369 assert(cixChanged >= 0);6368 Dec(cixChanged); 6369 Assert(cixChanged >= 0); 6370 6370 if cixChanged >= 0 then 6371 6371 begin 6372 6372 CityOptimizer_CityChange(cixChanged); 6373 NeedEcoUpdate := true;6373 NeedEcoUpdate := True; 6374 6374 end; 6375 6375 end; … … 6379 6379 while (cixChanged >= 0) and 6380 6380 (MyCity[cixChanged].Loc <> ToLoc) do 6381 dec(cixChanged);6382 assert(cixChanged >= 0);6381 Dec(cixChanged); 6382 Assert(cixChanged >= 0); 6383 6383 if cixChanged >= 0 then 6384 6384 begin 6385 6385 CityOptimizer_CityChange(cixChanged); 6386 NeedEcoUpdate := true;6386 NeedEcoUpdate := True; 6387 6387 end; 6388 6388 end; … … 6392 6392 end; 6393 6393 else 6394 assert(false);6394 Assert(False); 6395 6395 end; 6396 6396 SetTroopLoc(ToLoc); … … 6398 6398 else 6399 6399 begin { enemy unit -- attack } 6400 if result = eBombarded then6400 if Result = eBombarded then 6401 6401 Defender := MyRO.Territory[ToLoc] 6402 6402 else … … 6405 6405 if SimpleQuery(mkYesNo,Phrases.Lookup('FRCANCELQUERY_CEASEFIRE'), 6406 6406 'MSG_DEFAULT')<>mrOK then 6407 exit; }6408 if (Options and muNoSuicideCheck = 0) and ( result and rUnitRemoved <> 0)6409 and ( result <> eMissionDone) then6407 Exit; } 6408 if (Options and muNoSuicideCheck = 0) and (Result and rUnitRemoved <> 0) 6409 and (Result <> eMissionDone) then 6410 6410 begin // suicide query 6411 6411 with MyUn[UnFocus], BattleDlg.Forecast do 6412 6412 begin 6413 pAtt := me;6413 pAtt := Me; 6414 6414 mixAtt := mix; 6415 6415 HealthAtt := Health; … … 6418 6418 end; 6419 6419 BattleDlg.Forecast.Movement := MyUn[UnFocus].Movement; 6420 Server(sGetBattleForecastEx, me, ToLoc, BattleDlg.Forecast);6420 Server(sGetBattleForecastEx, Me, ToLoc, BattleDlg.Forecast); 6421 6421 BattleDlg.uix := UnFocus; 6422 6422 BattleDlg.ToLoc := ToLoc; 6423 BattleDlg.IsSuicideQuery := true;6423 BattleDlg.IsSuicideQuery := True; 6424 6424 BattleDlg.ShowModal; 6425 6425 if BattleDlg.ModalResult <> mrOK then 6426 exit;6426 Exit; 6427 6427 end; 6428 6428 6429 6429 cixChanged := -1; 6430 if ( result and rUnitRemoved <> 0) and (MyRO.Government = gDespotism) and6430 if (Result and rUnitRemoved <> 0) and (MyRO.Government = gDespotism) and 6431 6431 (MyModel[MyUn[UnFocus].mix].Kind = mkSpecial_TownGuard) and 6432 6432 (MyMap[FromLoc] and fCity <> 0) then … … 6434 6434 cixChanged := MyRO.nCity - 1; 6435 6435 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 do6441 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; 6442 6442 OldToTile := MyMap[ToLoc]; 6443 result := Server(sMoveUnit + DirCode, me, UnFocus, nil^);6443 Result := Server(sMoveUnit + DirCode, Me, UnFocus, nil^); 6444 6444 nLostArmy := 0; 6445 for i:= 0 to MyRO.nEnemyModel - 1 do6446 begin 6447 LostArmy[ i] := MyRO.EnemyModel[i].Lost - LostArmy[i];6448 inc(nLostArmy, LostArmy[i]);6449 end; 6450 if result and rUnitRemoved <> 0 then6445 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 6451 6451 begin 6452 6452 UnFocus := -1; … … 6457 6457 begin // city was destroyed, borders have moved, unrest might have changed in any city 6458 6458 CityOptimizer_BeginOfTurn; 6459 NeedEcoUpdate := true;6459 NeedEcoUpdate := True; 6460 6460 end 6461 6461 else … … 6464 6464 begin 6465 6465 CityOptimizer_CityChange(cixChanged); 6466 NeedEcoUpdate := true;6466 NeedEcoUpdate := True; 6467 6467 end; 6468 if ( result = eWon) or (result = eBloody) or (result = eExpelled) then6468 if (Result = eWon) or (Result = eBloody) or (Result = eExpelled) then 6469 6469 begin 6470 6470 CityOptimizer_TileBecomesAvailable(ToLoc); 6471 NeedEcoUpdate := true;6471 NeedEcoUpdate := True; 6472 6472 end; 6473 6473 end; … … 6484 6484 end; 6485 6485 end; 6486 if result and rUnitRemoved <> 0 then6486 if Result and rUnitRemoved <> 0 then 6487 6487 begin 6488 6488 CityOptimizer_AfterRemoveUnit; 6489 6489 ListDlg.RemoveUnit; 6490 NeedEcoUpdate := true;6490 NeedEcoUpdate := True; 6491 6491 end; 6492 6492 if NeedEcoUpdate then 6493 6493 begin 6494 UpdateViews( true);6494 UpdateViews(True); 6495 6495 Update; 6496 6496 end; 6497 6497 end; 6498 6498 6499 if result = eMissionDone then6499 if Result = eMissionDone then 6500 6500 begin 6501 6501 p1 := MyRO.Territory[ToLoc]; … … 6503 6503 smStealMap: 6504 6504 begin 6505 MapValid := false;6505 MapValid := False; 6506 6506 PaintAllMaps 6507 6507 end; … … 6516 6516 CheckToldNoReturn(UnFocus); 6517 6517 6518 NeedRepaintPanel := false;6519 if result >= rExecuted then6518 NeedRepaintPanel := False; 6519 if Result >= rExecuted then 6520 6520 begin 6521 6521 if CityCaptured and (MyMap[ToLoc] and fCity = 0) then 6522 6522 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) 6525 6525 then 6526 6526 with MessgExDlg do 6527 6527 begin 6528 6528 if WondersDlg.Visible then 6529 WondersDlg.SmartUpdateContent( false);6529 WondersDlg.SmartUpdateContent(False); 6530 6530 OpenSound := 'WONDER_DESTROYED'; 6531 6531 MessgText := Format(Phrases.Lookup('WONDERDEST'), 6532 [Phrases.Lookup('IMPROVEMENTS', i)]);6532 [Phrases.Lookup('IMPROVEMENTS', I)]); 6533 6533 Kind := mkOkHelp; 6534 6534 HelpKind := hkImp; 6535 HelpNo := i;6535 HelpNo := I; 6536 6536 IconKind := mikImp; 6537 IconIndex := i;6537 IconIndex := I; 6538 6538 ShowModal; 6539 MyData.ToldWonders[ i] := MyRO.Wonder[i];6539 MyData.ToldWonders[I] := MyRO.Wonder[I]; 6540 6540 end; 6541 6541 end; … … 6543 6543 begin // city captured 6544 6544 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 then6545 for I := 0 to nWonder - 1 do { tell about capture of wonders } 6546 if MyRO.City[MyRO.nCity - 1].Built[I] > 0 then 6547 6547 with MessgExDlg do 6548 6548 begin 6549 6549 if WondersDlg.Visible then 6550 WondersDlg.SmartUpdateContent( false);6550 WondersDlg.SmartUpdateContent(False); 6551 6551 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)]); 6554 6554 Kind := mkOkHelp; 6555 6555 HelpKind := hkImp; 6556 HelpNo := i;6556 HelpNo := I; 6557 6557 IconKind := mikImp; 6558 IconIndex := i;6558 IconIndex := I; 6559 6559 ShowModal; 6560 MyData.ToldWonders[ i] := MyRO.Wonder[i];6560 MyData.ToldWonders[I] := MyRO.Wonder[I]; 6561 6561 end; 6562 6562 … … 6564 6564 begin { Temple of Zeus -- choose advance to steal } 6565 6565 ModalSelectDlg.ShowNewContent(wmModal, kStealTech); 6566 Server(sStealTech, me, ModalSelectDlg.result, nil^);6566 Server(sStealTech, Me, ModalSelectDlg.Result, nil^); 6567 6567 end; 6568 6568 TellNewModels; … … 6570 6570 cix := MyRO.nCity - 1; 6571 6571 while (cix >= 0) and (MyCity[cix].Loc <> ToLoc) do 6572 dec(cix);6573 assert(cix >= 0);6572 Dec(cix); 6573 Assert(cix >= 0); 6574 6574 MyCity[cix].Status := MyCity[cix].Status and not csResourceWeightsMask or 6575 6575 (3 shl 4); 6576 6576 // captured city, set to maximum growth 6577 6577 NewTiles := 1 shl 13; { exploit central tile only } 6578 Server(sSetCityTiles, me, cix, NewTiles);6578 Server(sSetCityTiles, Me, cix, NewTiles); 6579 6579 end 6580 6580 else 6581 NeedRepaintPanel := true;6581 NeedRepaintPanel := True; 6582 6582 end; 6583 6583 TellNewContacts; … … 6593 6593 if Options and (muAutoNoWait or muAutoNext) <> 0 then 6594 6594 begin 6595 if (UnFocus >= 0) and (( result = eNoTime_Move) or UnitExhausted(UnFocus) or6595 if (UnFocus >= 0) and ((Result = eNoTime_Move) or UnitExhausted(UnFocus) or 6596 6596 (MyUn[UnFocus].Master >= 0) or (MyModel[MyUn[UnFocus].mix].Domain = dAir) 6597 6597 and ((MyMap[MyUn[UnFocus].Loc] and fCity <> 0) … … 6607 6607 end 6608 6608 else 6609 NextUnit(UnStartLoc, true);6609 NextUnit(UnStartLoc, True); 6610 6610 end 6611 6611 else if (UnFocus < 0) and (Options and muAutoNext <> 0) then 6612 NextUnit(UnStartLoc, result <> eMissionDone);6612 NextUnit(UnStartLoc, Result <> eMissionDone); 6613 6613 end; 6614 6614 … … 6618 6618 else 6619 6619 begin 6620 assert(result <> eMissionDone);6620 Assert(Result <> eMissionDone); 6621 6621 CheckTerrainBtnVisible; 6622 6622 FocusOnLoc(ToLoc, flRepaintPanel or flImmUpdate); 6623 6623 end; 6624 6624 6625 if ( result >= rExecuted) and CityCaptured and (MyMap[ToLoc] and fCity <> 0)6625 if (Result >= rExecuted) and CityCaptured and (MyMap[ToLoc] and fCity <> 0) 6626 6626 then 6627 6627 ZoomToCity(ToLoc, UnFocus < 0, chCaptured); // show captured city … … 6629 6629 6630 6630 procedure TMainScreen.MoveOnScreen(ShowMove: TShowMove; 6631 Step0, Step1, nStep: integer; Restore: boolean = true);6631 Step0, Step1, nStep: Integer; Restore: Boolean = True); 6632 6632 var 6633 6633 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; 6635 6635 UnitInfo: TUnitInfo; 6636 6636 Ticks0, Ticks: TDateTime; 6637 6637 begin 6638 Timer1.Enabled := false;6638 Timer1.Enabled := False; 6639 6639 Ticks0 := NowPrecise; 6640 6640 with ShowMove do … … 6645 6645 UnitInfo.Job := jNone; 6646 6646 UnitInfo.Flags := Flags; 6647 if Owner <> me then6647 if Owner <> Me then 6648 6648 UnitInfo.emix := emix; 6649 6649 … … 6664 6664 * xxt - MapWidth) < abs(((xFromLoc - xw1) * 2 + yFromLoc and 1 + 1) * xxt 6665 6665 * 2 + dx * xxt - MapWidth) do 6666 dec(xw1, G.lx);6666 Dec(xw1, G.lx); 6667 6667 6668 6668 xTo := (xToLoc - xw1) * (xxt * 2) + yToLoc and 1 * xxt + (xxt - xxu); … … 6684 6684 yRange := yFrom - yTo; 6685 6685 end; 6686 inc(xRange, xxt * 2);6687 inc(yRange, yyt * 3);6686 Inc(xRange, xxt * 2); 6687 Inc(yRange, yyt * 3); 6688 6688 end; 6689 6689 … … 6694 6694 begin 6695 6695 BitBltCanvas(Buffer.Canvas, 0, 0, xRange, yRange, 6696 offscreen.Canvas, xMin, yMin);6696 Offscreen.Canvas, xMin, yMin); 6697 6697 if Step1 <> Step0 then 6698 6698 begin … … 6723 6723 < MoveTime) then 6724 6724 begin 6725 if not idle or (GameMode = cMovie) then6725 if not Idle or (GameMode = cMovie) then 6726 6726 Application.ProcessMessages; 6727 6727 Sleep(1); 6728 inc(SliceCount)6728 Inc(SliceCount) 6729 6729 end; 6730 6730 Ticks := NowPrecise; … … 6735 6735 if Restore then 6736 6736 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); 6738 6738 PaintBufferToScreen(xMin, yMin, xRange, yRange); 6739 6739 end; 6740 6740 BlinkTime := -1; 6741 Timer1.Enabled := true;6742 end; 6743 6744 procedure TMainScreen.MoveToLoc(Loc: integer; CheckSuicide: boolean);6741 Timer1.Enabled := True; 6742 end; 6743 6744 procedure TMainScreen.MoveToLoc(Loc: Integer; CheckSuicide: Boolean); 6745 6745 // path finder: move focused unit to loc, start multi-turn goto if too far 6746 6746 var 6747 uix, i, MoveOptions, NextLoc, MoveResult: integer;6747 uix, I, MoveOptions, NextLoc, MoveResult: Integer; 6748 6748 MoveAdviceData: TMoveAdviceData; 6749 6749 StopReason: (None, Arrived, Dead, NoTime, EnemySpotted, MoveError); 6750 6750 begin 6751 6751 if MyUn[UnFocus].Job > jNone then 6752 Server(sStartJob + jNone shl 4, me, UnFocus, nil^);6752 Server(sStartJob + jNone shl 4, Me, UnFocus, nil^); 6753 6753 if GetMoveAdvice(UnFocus, Loc, MoveAdviceData) >= rExecuted then 6754 6754 begin … … 6756 6756 StopReason := None; 6757 6757 repeat 6758 for i:= 0 to MoveAdviceData.nStep - 1 do6759 begin 6760 if i= MoveAdviceData.nStep - 1 then6758 for I := 0 to MoveAdviceData.nStep - 1 do 6759 begin 6760 if I = MoveAdviceData.nStep - 1 then 6761 6761 MoveOptions := muAutoNext 6762 6762 else 6763 6763 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]); 6766 6766 if (NextLoc = Loc) or (Loc = maNextCity) and 6767 6767 (MyMap[NextLoc] and fCity <> 0) then … … 6769 6769 if not CheckSuicide and (NextLoc = Loc) then 6770 6770 MoveOptions := MoveOptions or muNoSuicideCheck; 6771 MoveResult := MoveUnit(MoveAdviceData.dx[ i], MoveAdviceData.dy[i],6771 MoveResult := MoveUnit(MoveAdviceData.dx[I], MoveAdviceData.dy[I], 6772 6772 MoveOptions); 6773 6773 if MoveResult < rExecuted then … … 6781 6781 end; 6782 6782 if (StopReason = None) and ((MoveAdviceData.nStep < 25) or 6783 (MyRO.Wonder[woShinkansen].EffectiveOwner <> me)) then6783 (MyRO.Wonder[woShinkansen].EffectiveOwner <> Me)) then 6784 6784 StopReason := NoTime; 6785 6785 if StopReason <> None then … … 6787 6787 if GetMoveAdvice(UnFocus, Loc, MoveAdviceData) < rExecuted then 6788 6788 begin 6789 assert(false);6789 Assert(False); 6790 6790 Break; 6791 6791 end; 6792 until false;6792 until False; 6793 6793 6794 6794 case StopReason of 6795 6795 None: 6796 assert(false);6796 Assert(False); 6797 6797 Arrived: 6798 6798 MyUn[uix].Status := MyUn[uix].Status and ($FFFF - usGoto); 6799 6799 Dead: 6800 6800 if UnFocus < 0 then 6801 NextUnit(UnStartLoc, false);6801 NextUnit(UnStartLoc, False); 6802 6802 else 6803 6803 begin // multi-turn goto … … 6812 6812 begin 6813 6813 MyUn[uix].Status := MyUn[uix].Status and not usWaiting; 6814 NextUnit(UnStartLoc, true);6814 NextUnit(UnStartLoc, True); 6815 6815 end; 6816 6816 end; … … 6820 6820 6821 6821 procedure TMainScreen.PanelBoxMouseDown(Sender: TObject; Button: TMouseButton; 6822 Shift: TShiftState; x, y: integer);6822 Shift: TShiftState; X, Y: Integer); 6823 6823 var 6824 i, xMouse, MouseLoc, p1: integer;6824 I, xMouse, MouseLoc, p1: Integer; 6825 6825 begin 6826 6826 if GameMode = cMovie then 6827 exit;6827 Exit; 6828 6828 6829 6829 if Button = mbLeft then 6830 6830 begin 6831 if ( x >= xMini + 2) and (y >= yMini + 2) and (x< xMini + 2 + 2 * G.lx) and6832 ( y< yMini + 2 + G.ly) then6831 if (X >= xMini + 2) and (Y >= yMini + 2) and (X < xMini + 2 + 2 * G.lx) and 6832 (Y < yMini + 2 + G.ly) then 6833 6833 if ssShift in Shift then 6834 6834 begin 6835 6835 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) 6837 6837 div 2) mod G.lx; 6838 MouseLoc := xMouse + G.lx * ( y- (yMini + 2));6838 MouseLoc := xMouse + G.lx * (Y - (yMini + 2)); 6839 6839 if MyMap[MouseLoc] and fTerrain <> fUNKNOWN then 6840 6840 begin 6841 6841 p1 := MyRO.Territory[MouseLoc]; 6842 if (p1 = me) or (p1 >= 0) and (MyRO.Treaty[p1] >= trNone) then6842 if (p1 = Me) or (p1 >= 0) and (MyRO.Treaty[p1] >= trNone) then 6843 6843 NatStatDlg.ShowNewContent(wmPersistent, p1); 6844 6844 end; … … 6850 6850 if UnitStatDlg.Visible then 6851 6851 UnitStatDlg.Close; 6852 Tracking := true;6853 PanelBoxMouseMove(Sender, Shift + [ssLeft], x, y);6852 Tracking := True; 6853 PanelBoxMouseMove(Sender, Shift + [ssLeft], X, Y); 6854 6854 end 6855 else if (ClientMode <> cEditMap) and ( x>= ClientWidth - xPalace) and6856 ( y >= yPalace) and (x< ClientWidth - xPalace + xSizeBig) and6857 ( y< yPalace + ySizeBig) then6855 else if (ClientMode <> cEditMap) and (X >= ClientWidth - xPalace) and 6856 (Y >= yPalace) and (X < ClientWidth - xPalace + xSizeBig) and 6857 (Y < yPalace + ySizeBig) then 6858 6858 begin 6859 6859 InitPopup(StatPopup); … … 6866 6866 GetSystemMetrics(SM_CYCAPTION) + 3) 6867 6867 end 6868 (* else if ( x>=xAdvisor-3) and (y>=yAdvisor-3)6869 and ( x<xAdvisor+16+3) and (y<yAdvisor+16+3) and HaveStrategyAdvice then6868 (* else if (X>=xAdvisor-3) and (Y>=yAdvisor-3) 6869 and (X<xAdvisor+16+3) and (Y<yAdvisor+16+3) and HaveStrategyAdvice then 6870 6870 AdviceBtnClick *) 6871 else if ( x >= xTroop + 1) and (y>= yTroop + 1) and6872 ( x < xTroop + TrRow * TrPitch) and (y<= yTroop + 55) then6873 begin 6874 i := (x- xTroop - 1) div TrPitch;6875 if trix[ i] >= 0 then6871 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 6876 6876 if ClientMode = cEditMap then 6877 6877 begin 6878 BrushType := trix[ i];6878 BrushType := trix[I]; 6879 6879 PanelPaint 6880 6880 end … … 6884 6884 if ssShift in Shift then 6885 6885 UnitStatDlg.ShowNewContent_OwnModel(wmPersistent, 6886 MyUn[trix[ i]].mix)6887 else if not supervising and (ClientMode < scContact) and6888 ( x - xTroop - 1 - i * TrPitch >= 60 - 20) and (y>= yTroop + 35)6889 and ((MyUn[trix[ i]].Job > jNone) or (MyUn[trix[i]].Status and6886 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 6890 6890 (usStay or usRecover or usGoto) <> 0)) then 6891 6891 begin // wake up 6892 MyUn[trix[ i]].Status := MyUn[trix[i]].Status and6892 MyUn[trix[I]].Status := MyUn[trix[I]].Status and 6893 6893 ($FFFF - usStay - usRecover - usGoto - usEnhance) or usWaiting; 6894 if MyUn[trix[ i]].Job > jNone then6895 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^); 6896 6896 if (UnFocus < 0) and not CityDlg.Visible then 6897 6897 begin 6898 SetUnFocus(trix[ i]);6899 SetTroopLoc(MyUn[trix[ i]].Loc);6898 SetUnFocus(trix[I]); 6899 SetTroopLoc(MyUn[trix[I]].Loc); 6900 6900 FocusOnLoc(TroopLoc, flRepaintPanel) 6901 6901 end … … 6903 6903 begin 6904 6904 if CityDlg.Visible and (CityDlg.RestoreUnFocus < 0) then 6905 CityDlg.RestoreUnFocus := trix[ i];6905 CityDlg.RestoreUnFocus := trix[I]; 6906 6906 PanelPaint; 6907 6907 end … … 6909 6909 else if (ClientMode < scContact) then 6910 6910 begin 6911 if supervising then6912 UnitStatDlg.ShowNewContent_OwnUnit(wmPersistent, trix[ i])6911 if Supervising then 6912 UnitStatDlg.ShowNewContent_OwnUnit(wmPersistent, trix[I]) 6913 6913 else if CityDlg.Visible then 6914 6914 begin … … 6916 6916 CityDlg.Close; 6917 6917 SumCities(TaxSum, ScienceSum); 6918 SetUnFocus(trix[ i]);6918 SetUnFocus(trix[I]); 6919 6919 end 6920 6920 else 6921 6921 begin 6922 DestinationMarkON := false;6922 DestinationMarkON := False; 6923 6923 PaintDestination; 6924 UnFocus := trix[ i];6924 UnFocus := trix[I]; 6925 6925 UnStartLoc := TroopLoc; 6926 6926 BlinkTime := 0; 6927 BlinkON := false;6927 BlinkON := False; 6928 6928 PaintLoc(TroopLoc); 6929 6929 end; 6930 6930 if UnFocus >= 0 then 6931 6931 begin 6932 UnitInfoBtn.Visible := true;6933 UnitBtn.Visible := true;6934 TurnComplete := false;6932 UnitInfoBtn.Visible := True; 6933 UnitBtn.Visible := True; 6934 TurnComplete := False; 6935 6935 EOT.ButtonIndex := eotGray; 6936 6936 end; … … 6939 6939 end; 6940 6940 end 6941 else if Server(sGetUnits, me, TroopLoc, TrCnt) >= rExecuted then6941 else if Server(sGetUnits, Me, TroopLoc, TrCnt) >= rExecuted then 6942 6942 if ssShift in Shift then 6943 6943 UnitStatDlg.ShowNewContent_EnemyModel(wmPersistent, 6944 MyRO.EnemyUn[MyRO.nEnemyUn + trix[ i]].emix) // model info6944 MyRO.EnemyUn[MyRO.nEnemyUn + trix[I]].emix) // model info 6945 6945 else 6946 6946 UnitStatDlg.ShowNewContent_EnemyUnit(wmPersistent, 6947 MyRO.nEnemyUn + trix[ i]); // unit info6948 end; 6949 end; 6950 end; 6951 6952 procedure TMainScreen.SetTroopLoc(Loc: integer);6947 MyRO.nEnemyUn + trix[I]); // unit info 6948 end; 6949 end; 6950 end; 6951 6952 procedure TMainScreen.SetTroopLoc(Loc: Integer); 6953 6953 var 6954 trixFocus, uix, uixDefender: integer;6955 Prio: boolean;6954 trixFocus, uix, uixDefender: Integer; 6955 Prio: Boolean; 6956 6956 begin 6957 6957 TroopLoc := Loc; … … 6965 6965 if MyMap[Loc] and fOwned <> 0 then 6966 6966 begin // count own units here 6967 Server(sGetDefender, me, TroopLoc, uixDefender);6968 for Prio := true downto false do6967 Server(sGetDefender, Me, TroopLoc, uixDefender); 6968 for Prio := True downto False do 6969 6969 for uix := 0 to MyRO.nUn - 1 do 6970 6970 if ((uix = uixDefender) = Prio) and (MyUn[uix].Loc = Loc) then … … 6972 6972 if uix = UnFocus then 6973 6973 trixFocus := TrCnt; 6974 inc(TrCnt);6974 Inc(TrCnt); 6975 6975 end; 6976 6976 end 6977 6977 else // count enemy units here 6978 Server(sGetUnits, me, Loc, TrCnt);6978 Server(sGetUnits, Me, Loc, TrCnt); 6979 6979 if TrCnt = 0 then 6980 6980 sb.Init(0, 1) … … 6987 6987 end; 6988 6988 6989 (* procedure TMainScreen.ShowMoveHint(ToLoc: integer; Force: boolean = false);6989 (* procedure TMainScreen.ShowMoveHint(ToLoc: Integer; Force: Boolean = False); 6990 6990 var 6991 Step,Loc,x0,y0,xs,ys: integer;6991 Step,Loc,x0,y0,xs,ys: Integer; 6992 6992 Info: string; 6993 6993 InfoSize: TSize; … … 7002 7002 MoveAdvice.MoreTurns:=0; 7003 7003 MoveAdvice.MaxHostile_MovementLeft:=MyUn[UnFocus].Health-50; 7004 if Server(sGetMoveAdvice, me,UnFocus,MoveAdvice)<rExecuted then7004 if Server(sGetMoveAdvice,Me,UnFocus,MoveAdvice)<rExecuted then 7005 7005 ToLoc:=-1 7006 7006 end; 7007 if (ToLoc=MoveHintToLoc) and not Force then exit;7007 if (ToLoc=MoveHintToLoc) and not Force then Exit; 7008 7008 if (ToLoc<>MoveHintToLoc) and (MoveHintToLoc>=0) then 7009 7009 begin invalidate; update end; // clear old hint from screen 7010 7010 MoveHintToLoc:=ToLoc; 7011 if ToLoc<0 then exit;7012 7013 with canvas do7011 if ToLoc<0 then Exit; 7012 7013 with Canvas do 7014 7014 begin 7015 7015 Pen.Color:=$80C0FF; … … 7022 7022 xs:=(x0-xw)*66+y0 and 1*33-G.lx*66; 7023 7023 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); 7025 7025 ys:=(y0-yw)*16; 7026 7026 if Step=0 then moveto(xs+33,ys+16) … … 7030 7030 end; 7031 7031 Brush.Color:=$80C0FF; 7032 Info:=' '+ inttostr(88)+' ';7032 Info:=' '+IntToStr(88)+' '; 7033 7033 InfoSize:=TextExtent(Info); 7034 7034 TextOut(xs+33-InfoSize.cx div 2, ys+16-InfoSize.cy div 2, Info); … … 7037 7037 end; *) 7038 7038 7039 procedure TMainScreen.SetDebugMap( p: integer);7040 begin 7041 MainMap.pDebugMap := p;7039 procedure TMainScreen.SetDebugMap(P: Integer); 7040 begin 7041 MainMap.pDebugMap := P; 7042 7042 MapOptions := MapOptions - [moLocCodes]; 7043 mLocCodes.Checked := false;7044 MapValid := false;7043 mLocCodes.Checked := False; 7044 MapValid := False; 7045 7045 MainOffscreenPaint; 7046 7046 end; 7047 7047 7048 procedure TMainScreen.SetViewpoint( p: integer);7048 procedure TMainScreen.SetViewpoint(P: Integer); 7049 7049 var 7050 i: Integer;7051 begin 7052 if supervising and (G.RO[0].Turn > 0) and7053 (( p = 0) or (1 shl pand G.RO[0].Alive <> 0)) then7050 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 7054 7054 begin 7055 7055 ApplyToVisibleForms(faClose); 7056 ItsMeAgain( p);7056 ItsMeAgain(P); 7057 7057 SumCities(TaxSum, ScienceSum); 7058 for i:= 0 to MyRO.nModel - 1 do7059 if not Assigned(Tribe[ me].ModelPicture[i].HGr) then7060 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); 7061 7061 7062 7062 SetTroopLoc(-1); … … 7146 7146 end; 7147 7147 7148 procedure TMainScreen.FormKeyDown(Sender: TObject; var Key: word;7148 procedure TMainScreen.FormKeyDown(Sender: TObject; var Key: Word; 7149 7149 Shift: TShiftState); 7150 7150 … … 7156 7156 end; 7157 7157 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); 7162 7162 end; 7163 7163 … … 7195 7195 'A': 7196 7196 begin // auto symmetry 7197 Server($7F0, me,0,nil^);7198 MapValid:= false;7197 Server($7F0,Me,0,nil^); 7198 MapValid:=False; 7199 7199 PaintAll; 7200 7200 end; … … 7203 7203 dy:=0; 7204 7204 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); 7206 7206 dy:=dy 7207 7207 end; … … 7330 7330 function TMainScreen.DoJob(j0: Integer): Integer; 7331 7331 var 7332 Loc0, Movement0: integer;7332 Loc0, Movement0: Integer; 7333 7333 begin 7334 7334 with MyUn[UnFocus] do 7335 7335 begin 7336 DestinationMarkON := false;7336 DestinationMarkON := False; 7337 7337 PaintDestination; 7338 7338 Loc0 := Loc; 7339 7339 Movement0 := Movement; 7340 7340 if j0 < 0 then 7341 result := ProcessEnhancement(UnFocus, MyData.EnhancementJobs)7341 Result := ProcessEnhancement(UnFocus, MyData.EnhancementJobs) 7342 7342 // terrain enhancement 7343 7343 else 7344 result := Server(sStartJob + j0 shl 4, me, UnFocus, nil^);7345 if result >= rExecuted then7346 begin 7347 if result = eDied then7344 Result := Server(sStartJob + j0 shl 4, Me, UnFocus, nil^); 7345 if Result >= rExecuted then 7346 begin 7347 if Result = eDied then 7348 7348 UnFocus := -1; 7349 7349 PaintLoc(Loc0); 7350 7350 if UnFocus >= 0 then 7351 7351 begin 7352 if (j0 < 0) and ( result <> eJobDone) then7352 if (j0 < 0) and (Result <> eJobDone) then 7353 7353 // multi-turn terrain enhancement 7354 7354 Status := Status and ($FFFF - usStay - usRecover - usGoto) or … … 7360 7360 begin 7361 7361 Status := Status and not usWaiting; 7362 NextUnit(UnStartLoc, true);7362 NextUnit(UnStartLoc, True); 7363 7363 end 7364 7364 else … … 7366 7366 end 7367 7367 else 7368 NextUnit(UnStartLoc, true);7369 end; 7370 end; 7371 case result of7368 NextUnit(UnStartLoc, True); 7369 end; 7370 end; 7371 case Result of 7372 7372 eNoBridgeBuilding: 7373 7373 SoundMessage(Phrases.Lookup('NOBB'), 'INVALID'); … … 7378 7378 'NOMOVE_TREATY'); 7379 7379 else 7380 if result < rExecuted then7380 if Result < rExecuted then 7381 7381 Play('INVALID'); 7382 7382 end; … … 7390 7390 with TUn(MyUn[UnFocus]) do begin 7391 7391 if (Sender = mUtilize) and 7392 not(Server(sRemoveUnit - sExecute, me, UnFocus, nil^) = eUtilized) then7392 not(Server(sRemoveUnit - sExecute, Me, UnFocus, nil^) = eUtilized) then 7393 7393 begin 7394 7394 SimpleMessage(Phrases2.Lookup('SHIP_UTILIZE')); 7395 7395 // freight for colony ship is the only case in which the command is 7396 7396 // available to player though not valid 7397 exit;7397 Exit; 7398 7398 end; 7399 7399 if (Sender = mUtilize) and (Health < 100) then 7400 7400 if SimpleQuery(mkYesNo, Phrases.Lookup('DAMAGED_UTILIZE'), '') <> mrOK 7401 7401 then 7402 exit;7402 Exit; 7403 7403 Loc0 := Loc; 7404 7404 CityOptimizer_BeforeRemoveUnit(UnFocus); 7405 if Server(sRemoveUnit, me, UnFocus, nil^) = eUtilized then7405 if Server(sRemoveUnit, Me, UnFocus, nil^) = eUtilized then 7406 7406 Play('CITY_UTILIZE') 7407 7407 else … … 7409 7409 CityOptimizer_AfterRemoveUnit; 7410 7410 SetTroopLoc(Loc0); 7411 UpdateViews( true);7412 DestinationMarkON := false;7411 UpdateViews(True); 7412 DestinationMarkON := False; 7413 7413 PaintDestination; 7414 7414 UnFocus := -1; 7415 7415 PaintLoc(Loc0); 7416 NextUnit(UnStartLoc, true);7416 NextUnit(UnStartLoc, True); 7417 7417 end; 7418 7418 end; … … 7420 7420 procedure TMainScreen.InitPopup(Popup: TPopupMenu); 7421 7421 var 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; 7425 7425 mox: ^TModel; 7426 7426 begin 7427 NoSuper := not supervising and (1 shl me and MyRO.Alive <> 0);7428 HaveCities := false;7429 for i:= 0 to MyRO.nCity - 1 do7430 if MyCity[ i].Loc >= 0 then7431 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; 7433 7433 Break; 7434 7434 end; … … 7436 7436 begin 7437 7437 mTechTree.Visible := ClientMode <> cEditMap; 7438 mResign.Enabled := supervising or (me = 0) and (ClientMode < scContact);7438 mResign.Enabled := Supervising or (Me = 0) and (ClientMode < scContact); 7439 7439 mRandomMap.Visible := (ClientMode = cEditMap) and 7440 (Server(sMapGeneratorRequest, me, 0, nil^) = eOK);7440 (Server(sMapGeneratorRequest, Me, 0, nil^) = eOK); 7441 7441 mOptions.Visible := ClientMode <> cEditMap; 7442 7442 mManip.Visible := ClientMode <> cEditMap; … … 7452 7452 case SoundMode of 7453 7453 smOff: 7454 mSoundOff.Checked := true;7454 mSoundOff.Checked := True; 7455 7455 smOn: 7456 mSoundOn.Checked := true;7456 mSoundOn.Checked := True; 7457 7457 smOnAlt: 7458 mSoundOnAlt.Checked := true;7459 end; 7460 7461 for i:= 0 to nTestFlags - 1 do7462 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; 7466 7466 for p1 := 1 to nPl - 1 do 7467 7467 if G.RO[p1] <> nil then 7468 Multi := true;7468 Multi := True; 7469 7469 mEnemyMovement.Visible := not Multi; 7470 7470 end; … … 7472 7472 if NoSuper and (ClientMode < scContact) then 7473 7473 begin 7474 mCityTypes.Enabled := false;7474 mCityTypes.Enabled := False; 7475 7475 // check if city types already usefull: 7476 7476 if MyRO.nCity > 0 then 7477 for i:= nWonder to nImp - 1 do7478 if ( i <> imTrGoods) and (Imp[i].Kind = ikCommon) and7479 (Imp[ i].Preq <> preNA) and7480 ((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)) 7481 7481 then 7482 7482 begin 7483 mCityTypes.Enabled := true;7483 mCityTypes.Enabled := True; 7484 7484 Break 7485 7485 end; 7486 7486 end; 7487 mViewpoint.Visible := (ClientMode <> cEditMap) and supervising;7487 mViewpoint.Visible := (ClientMode <> cEditMap) and Supervising; 7488 7488 mViewpoint.Enabled := G.RO[0].Turn > 0; 7489 if supervising then7489 if Supervising then 7490 7490 begin 7491 7491 EmptyMenu(mViewpoint); … … 7493 7493 if (p1 = 0) or (1 shl p1 and G.RO[0].Alive <> 0) then 7494 7494 begin 7495 m:= TMenuItem.Create(mViewpoint);7495 M := TMenuItem.Create(mViewpoint); 7496 7496 if p1 = 0 then 7497 m.Caption := Phrases.Lookup('SUPER')7497 M.Caption := Phrases.Lookup('SUPER') 7498 7498 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; 7502 7502 if p1 < 10 then 7503 m.ShortCut := ShortCut(48 + p1, [ssCtrl]);7504 m.RadioItem := true;7505 if p1 = me then7506 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); 7508 7508 end 7509 7509 end; 7510 mDebugMap.Visible := (ClientMode <> cEditMap) and supervising;7511 if supervising then7510 mDebugMap.Visible := (ClientMode <> cEditMap) and Supervising; 7511 if Supervising then 7512 7512 begin 7513 7513 EmptyMenu(mDebugMap); … … 7515 7515 if (p1 = 0) or (1 shl p1 and G.RO[0].Alive <> 0) then 7516 7516 begin 7517 m:= TMenuItem.Create(mDebugMap);7517 M := TMenuItem.Create(mDebugMap); 7518 7518 if p1 = 0 then 7519 m.Caption := Phrases2.Lookup('MENU_DEBUGMAPOFF')7519 M.Caption := Phrases2.Lookup('MENU_DEBUGMAPOFF') 7520 7520 else 7521 m.Caption := Tribe[p1].TString(Phrases2.Lookup('BELONG'));7521 M.Caption := Tribe[p1].TString(Phrases2.Lookup('BELONG')); 7522 7522 if p1 = 0 then 7523 m.Tag := -17523 M.Tag := -1 7524 7524 else 7525 m.Tag := p1;7526 m.OnClick := DebugMapClick;7525 M.Tag := p1; 7526 M.OnClick := DebugMapClick; 7527 7527 if p1 < 10 then 7528 m.ShortCut := ShortCut(48 + p1, [ssAlt]);7529 m.RadioItem := true;7530 if m.Tag = MainMap.pDebugMap then7531 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); 7533 7533 end; 7534 7534 end; … … 7545 7545 (ClientMode < scContact); 7546 7546 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; 7548 7548 mCityStat.Enabled := HaveCities; 7549 mScienceStat.Visible := true;7549 mScienceStat.Visible := True; 7550 7550 mScienceStat.Enabled := not NoSuper or (MyRO.ResearchTech >= 0) or 7551 7551 (MyRO.Happened and phTech <> 0) or (MyRO.Happened and phGameEnd <> 0) … … 7554 7554 mEUnitStat.Enabled := MyRO.nEnemyModel > 0; 7555 7555 { mWonders.Enabled:= false; 7556 for i:=0 to nWonder - 1 do if MyRO.Wonder[i].CityID <> WonderNotBuiltYet then7557 mWonders.Enabled:= true; }7556 for I:=0 to nWonder - 1 do if MyRO.Wonder[I].CityID <> WonderNotBuiltYet then 7557 mWonders.Enabled:=True; } 7558 7558 mDiagram.Enabled := MyRO.Turn >= 2; 7559 mShips.Enabled := false;7559 mShips.Enabled := False; 7560 7560 for p1 := 0 to nPl - 1 do 7561 7561 if MyRO.Ship[p1].Parts[spComp] + MyRO.Ship[p1].Parts[spPow] + 7562 7562 MyRO.Ship[p1].Parts[spHab] > 0 then 7563 mShips.Enabled := true;7563 mShips.Enabled := True; 7564 7564 end 7565 7565 else if Popup = UnitPopup then … … 7567 7567 mox := @MyModel[MyUn[UnFocus].mix]; 7568 7568 Tile := MyMap[MyUn[UnFocus].Loc]; 7569 extended := Tile and fCity = 0;7570 if extended then7569 Extended := Tile and fCity = 0; 7570 if Extended then 7571 7571 begin 7572 7572 mCity.Caption := Phrases.Lookup('BTN_FOUND'); … … 7579 7579 end; 7580 7580 7581 extended := extended and ((mox.Kind = mkSettler) or (mox.Kind = mkSlaves)7581 Extended := Extended and ((mox.Kind = mkSettler) or (mox.Kind = mkSlaves) 7582 7582 and (MyRO.Wonder[woPyramids].EffectiveOwner >= 0)) and 7583 7583 (MyUn[UnFocus].Master < 0) and (Tile and fDeadLands = 0); 7584 7584 if (mox.Kind = mkFreight) and (Tile and fCity <> 0) and 7585 7585 not Phrases2FallenBackToEnglish or 7586 (Server(sRemoveUnit - sExecute, me, UnFocus, nil^) = eUtilized) then7587 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; 7590 7590 if mox.Kind = mkFreight then 7591 7591 mUtilize.Caption := Phrases.Lookup('UTILIZE') … … 7595 7595 else 7596 7596 begin 7597 mDisband.Visible := true;7598 mUtilize.Visible := false7597 mDisband.Visible := True; 7598 mUtilize.Visible := False 7599 7599 end; 7600 7600 mGoOn.Visible := MyUn[UnFocus].Status and (usGoto or usWaiting) = usGoto or … … 7603 7603 mRecover.Visible := (MyUn[UnFocus].Health < 100) and 7604 7604 (Tile and fTerrain >= fGrass) and 7605 ((MyRO.Wonder[woGardens].EffectiveOwner = me) or7605 ((MyRO.Wonder[woGardens].EffectiveOwner = Me) or 7606 7606 (Tile and fTerrain <> fArctic) and (Tile and fTerrain <> fDesert)) and 7607 7607 not((mox.Domain = dAir) and (Tile and fCity = 0) and … … 7609 7609 mStay.Visible := not((mox.Domain = dAir) and (Tile and fCity = 0) and 7610 7610 (Tile and fTerImp <> tiBase)); 7611 mCity.Visible := extended and (mox.Kind = mkSettler) or7611 mCity.Visible := Extended and (mox.Kind = mkSettler) or 7612 7612 (Tile and fCity <> 0) and ((mox.Kind in [mkSettler, mkSlaves]) or 7613 7613 (MyUn[UnFocus].Flags and unConscripts <> 0)); … … 7617 7617 (MyUn[UnFocus].Status and (usRecover or usGoto) <> 0); 7618 7618 7619 Test := Server(sLoadUnit - sExecute, me, UnFocus, nil^);7619 Test := Server(sLoadUnit - sExecute, Me, UnFocus, nil^); 7620 7620 mLoad.Visible := (Test >= rExecuted) or (Test = eNoTime_Load); 7621 7621 mUnload.Visible := (MyUn[UnFocus].Master >= 0) or 7622 7622 (MyUn[UnFocus].TroopLoad + MyUn[UnFocus].AirLoad > 0); 7623 mSelectTransport.Visible := Server(sSelectTransport - sExecute, me, UnFocus,7623 mSelectTransport.Visible := Server(sSelectTransport - sExecute, Me, UnFocus, 7624 7624 nil^) >= rExecuted; 7625 7625 end … … 7628 7628 mox := @MyModel[MyUn[UnFocus].mix]; 7629 7629 Tile := MyMap[MyUn[UnFocus].Loc]; 7630 extended := Tile and fCity = 0;7630 Extended := Tile and fCity = 0; 7631 7631 7632 7632 if (Tile and fRiver <> 0) and (MyRO.Tech[adBridgeBuilding] >= tsApplicable) … … 7648 7648 mClear.Caption := Phrases.Lookup('BTN_DRAIN'); 7649 7649 7650 extended := extended and ((mox.Kind = mkSettler) or (mox.Kind = mkSlaves)7650 Extended := Extended and ((mox.Kind = mkSettler) or (mox.Kind = mkSlaves) 7651 7651 and (MyRO.Wonder[woPyramids].EffectiveOwner >= 0)) and 7652 7652 (MyUn[UnFocus].Master < 0); 7653 if extended then7653 if Extended then 7654 7654 begin 7655 7655 mRoad.Visible := JobTest(UnFocus, jRoad, [eNoBridgeBuilding, eTreaty]); … … 7671 7671 else 7672 7672 begin 7673 for i:= 0 to Popup.Items.Count - 1 do7674 Popup.Items[ i].Visible := false;7673 for I := 0 to Popup.Items.Count - 1 do 7674 Popup.Items[I].Visible := False; 7675 7675 end; 7676 7676 end; … … 7678 7678 // set menu seperators 7679 7679 LastSep := nil; 7680 NeedSep := false;7681 for i:= 0 to Popup.Items.Count - 1 do7682 if Popup.Items[ i].Caption = '-' then7683 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; 7685 7685 if NeedSep then 7686 LastSep := Popup.Items[ i];7687 NeedSep := false7686 LastSep := Popup.Items[I]; 7687 NeedSep := False 7688 7688 end 7689 else if Popup.Items[ i].Visible then7690 NeedSep := true;7689 else if Popup.Items[I].Visible then 7690 NeedSep := True; 7691 7691 if (LastSep <> nil) and not NeedSep then 7692 LastSep.Visible := false7692 LastSep.Visible := False 7693 7693 end; 7694 7694 … … 7709 7709 end; 7710 7710 7711 procedure TMainScreen.CityClosed(Activateuix: integer; StepFocus: boolean;7712 SelectFocus: boolean);7713 begin 7714 if supervising then7711 procedure TMainScreen.CityClosed(Activateuix: Integer; StepFocus: Boolean; 7712 SelectFocus: Boolean); 7713 begin 7714 if Supervising then 7715 7715 begin 7716 7716 SetTroopLoc(-1); … … 7729 7729 end 7730 7730 else if StepFocus then 7731 NextUnit(TroopLoc, true)7731 NextUnit(TroopLoc, True) 7732 7732 else 7733 7733 begin … … 7744 7744 7745 7745 procedure TMainScreen.PanelBoxMouseMove(Sender: TObject; Shift: TShiftState; 7746 x, y: integer);7746 X, Y: Integer); 7747 7747 var 7748 xCentre, yCentre: integer;7748 xCentre, yCentre: Integer; 7749 7749 begin 7750 7750 if Tracking and (ssLeft in Shift) then 7751 7751 with MainMap do begin 7752 if ( x >= xMini + 2) and (y >= yMini + 2) and (x< xMini + 2 + 2 * G.lx) and7753 ( y< yMini + 2 + G.ly) then7754 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 + 7756 7756 MapWidth div (xxt * 4)) mod G.lx; 7757 yCentre := ( y- yMini - 2);7757 yCentre := (Y - yMini - 2); 7758 7758 xw := (xCentre - MapWidth div (xxt * 4) + G.lx) mod G.lx; 7759 7759 if ywmax <= 0 then … … 7769 7769 BitBltCanvas(Buffer.Canvas, 0, 0, G.lx * 2, G.ly, MiniMap.Bitmap.Canvas, 0, 0); 7770 7770 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, 7773 7773 MainTexture.ColorMark, MainTexture.ColorMark) 7774 7774 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 - 7777 7777 2, MainTexture.ColorMark, MainTexture.ColorMark); 7778 7778 BitBltCanvas(Panel.Canvas, xMini + 2, yMini + 2, G.lx * 2, G.ly, … … 7786 7786 end 7787 7787 else 7788 Tracking := false;7788 Tracking := False; 7789 7789 end; 7790 7790 7791 7791 procedure TMainScreen.PanelBoxMouseUp(Sender: TObject; Button: TMouseButton; 7792 Shift: TShiftState; x, y: integer);7792 Shift: TShiftState; X, Y: Integer); 7793 7793 begin 7794 7794 if Tracking then 7795 7795 begin 7796 Tracking := false;7796 Tracking := False; 7797 7797 xwMini := xw; 7798 7798 ywMini := yw; … … 7803 7803 7804 7804 procedure TMainScreen.MapBoxMouseMove(Sender: TObject; Shift: TShiftState; 7805 x, y: integer);7805 X, Y: Integer); 7806 7806 var 7807 MouseLoc: integer;7808 begin 7809 xMouse := x;7810 yMouse := y;7807 MouseLoc: Integer; 7808 begin 7809 xMouse := X; 7810 yMouse := Y; 7811 7811 if (ClientMode = cEditMap) and (ssLeft in Shift) and not Tracking then 7812 7812 begin 7813 MouseLoc := LocationOfScreenPixel( x, y);7813 MouseLoc := LocationOfScreenPixel(X, Y); 7814 7814 if MouseLoc <> BrushLoc then 7815 MapBoxMouseDown(nil, mbLeft, Shift, x, y);7815 MapBoxMouseDown(nil, mbLeft, Shift, X, Y); 7816 7816 end 7817 (* else if idle and (UnFocus>=0) then7817 (* else if Idle and (UnFocus>=0) then 7818 7818 begin 7819 7819 qx:=(xMouse*32+yMouse*66+16*66) div(32*66)-1; … … 7828 7828 TMenuItem(Sender).Checked := not TMenuItem(Sender).Checked; 7829 7829 SetMapOptions; 7830 MapValid := false;7830 MapValid := False; 7831 7831 PaintAllMaps; 7832 7832 end; … … 7834 7834 procedure TMainScreen.mNamesClick(Sender: TObject); 7835 7835 var 7836 p1: integer;7836 p1: Integer; 7837 7837 begin 7838 7838 mNames.Checked := not mNames.Checked; … … 7844 7844 else 7845 7845 Tribe[p1].NumberName := p1; 7846 MapValid := false;7846 MapValid := False; 7847 7847 PaintAll; 7848 7848 end; 7849 7849 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));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)); 7854 7854 end; 7855 7855 7856 7856 procedure TMainScreen.FormMouseDown(Sender: TObject; Button: TMouseButton; 7857 Shift: TShiftState; x, y: integer);7858 begin 7859 if idle then7860 if ( x < 40) and (y< 40) then7857 Shift: TShiftState; X, Y: Integer); 7858 begin 7859 if Idle then 7860 if (X < 40) and (Y < 40) then 7861 7861 begin 7862 7862 if GameMode <> cMovie then … … 7870 7870 end; 7871 7871 end 7872 else if IsPanelPixel( x, y) then7873 PanelBoxMouseDown(Sender, Button, Shift, x,7874 y- (ClientHeight - PanelHeight))7875 else if ( y >= TopBarHeight) and (x>= MapOffset) and7876 ( x< MapOffset + MapWidth) then7877 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) 7878 7878 end; 7879 7879 7880 7880 procedure TMainScreen.FormMouseMove(Sender: TObject; Shift: TShiftState; 7881 x, y: integer);7882 begin 7883 if idle then7884 if IsPanelPixel( x, y) then7885 PanelBoxMouseMove(Sender, Shift, x, y- (ClientHeight - PanelHeight))7886 else if ( y >= TopBarHeight) and (x>= MapOffset) and7887 ( x< MapOffset + MapWidth) then7888 MapBoxMouseMove(Sender, Shift, x - MapOffset, y- TopBarHeight);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); 7889 7889 end; 7890 7890 7891 7891 procedure TMainScreen.FormMouseUp(Sender: TObject; Button: TMouseButton; 7892 Shift: TShiftState; x, y: integer);7893 begin 7894 if idle then7895 PanelBoxMouseUp(Sender, Button, Shift, x, y- (ClientHeight - PanelHeight));7892 Shift: TShiftState; X, Y: Integer); 7893 begin 7894 if Idle then 7895 PanelBoxMouseUp(Sender, Button, Shift, X, Y - (ClientHeight - PanelHeight)); 7896 7896 end; 7897 7897 … … 7902 7902 with Canvas do 7903 7903 begin // pillarbox, make left and right border black 7904 if me < 0 then7904 if Me < 0 then 7905 7905 Brush.Color := $000000 7906 7906 else … … 7929 7929 end; 7930 7930 BitBltCanvas(Canvas, MapOffset, TopBarHeight, MapWidth, MapHeight - overlap, 7931 offscreen.Canvas, 0, 0);7931 Offscreen.Canvas, 0, 0); 7932 7932 BitBltCanvas(Canvas, 0, 0, ClientWidth, TopBarHeight, TopBar.Canvas, 7933 7933 0, 0); 7934 7934 if xMidPanel > MapOffset then 7935 7935 BitBltCanvas(Canvas, xMidPanel, TopBarHeight + MapHeight - overlap, 7936 ClientWidth div 2 - xMidPanel, overlap, offscreen.Canvas,7936 ClientWidth div 2 - xMidPanel, overlap, Offscreen.Canvas, 7937 7937 xMidPanel - MapOffset, MapHeight - overlap) 7938 7938 else 7939 7939 BitBltCanvas(Canvas, MapOffset, TopBarHeight + MapHeight - overlap, 7940 ClientWidth div 2 - MapOffset, overlap, offscreen.Canvas, 0,7940 ClientWidth div 2 - MapOffset, overlap, Offscreen.Canvas, 0, 7941 7941 MapHeight - overlap); 7942 7942 if xRightPanel < MapOffset + MapWidth then 7943 7943 BitBltCanvas(Canvas, ClientWidth div 2, TopBarHeight + MapHeight - overlap, 7944 xRightPanel - ClientWidth div 2, overlap, offscreen.Canvas,7944 xRightPanel - ClientWidth div 2, overlap, Offscreen.Canvas, 7945 7945 ClientWidth div 2 - MapOffset, MapHeight - overlap) 7946 7946 else 7947 7947 BitBltCanvas(Canvas, ClientWidth div 2, TopBarHeight + MapHeight - overlap, 7948 7948 MapOffset + MapWidth - ClientWidth div 2, overlap, 7949 offscreen.Canvas, ClientWidth div 2 - MapOffset,7949 Offscreen.Canvas, ClientWidth div 2 - MapOffset, 7950 7950 MapHeight - overlap); 7951 7951 BitBltCanvas(Canvas, 0, TopBarHeight + MapHeight - overlap, xMidPanel, … … 7960 7960 end; 7961 7961 7962 procedure TMainScreen.RectInvalidate(Left, Top, Rigth, Bottom: integer);7962 procedure TMainScreen.RectInvalidate(Left, Top, Rigth, Bottom: Integer); 7963 7963 var 7964 7964 r0: HRgn; 7965 7965 begin 7966 7966 r0 := CreateRectRgn(Left, Top, Rigth, Bottom); 7967 InvalidateRgn(Handle, r0, false);7967 InvalidateRgn(Handle, r0, False); 7968 7968 DeleteObject(r0); 7969 7969 end; 7970 7970 7971 procedure TMainScreen.SmartRectInvalidate(Left, Top, Rigth, Bottom: integer);7971 procedure TMainScreen.SmartRectInvalidate(Left, Top, Rigth, Bottom: Integer); 7972 7972 var 7973 i: integer;7973 I: Integer; 7974 7974 r0, r1: HRgn; 7975 7975 begin 7976 7976 r0 := CreateRectRgn(Left, Top, Rigth, Bottom); 7977 for i:= 0 to ControlCount - 1 do7978 if not(Controls[ i] is TArea) and Controls[i].Visible then7979 begin 7980 with Controls[ i].BoundsRect do7977 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 7981 7981 r1 := CreateRectRgn(Left, Top, Right, Bottom); 7982 7982 CombineRgn(r0, r0, r1, RGN_DIFF); 7983 7983 DeleteObject(r1); 7984 7984 end; 7985 InvalidateRgn(Handle, r0, false);7985 InvalidateRgn(Handle, r0, False); 7986 7986 DeleteObject(r0); 7987 7987 end; … … 8048 8048 procedure TMainScreen.FormClose(Sender: TObject; var Action: TCloseAction); 8049 8049 begin 8050 Timer1.Enabled := false;8050 Timer1.Enabled := False; 8051 8051 end; 8052 8052 8053 8053 procedure TMainScreen.Radio(Sender: TObject); 8054 8054 begin 8055 TMenuItem(Sender).Checked := true;8055 TMenuItem(Sender).Checked := True; 8056 8056 end; 8057 8057 8058 8058 procedure TMainScreen.mManipClick(Sender: TObject); 8059 8059 var 8060 Flag: integer;8060 Flag: Integer; 8061 8061 begin 8062 8062 with TMenuItem(Sender) do … … 8070 8070 Play('CHEAT'); 8071 8071 end; 8072 if not supervising then8072 if not Supervising then 8073 8073 begin 8074 8074 if Flag = tfUncover then 8075 8075 begin 8076 MapValid := false;8076 MapValid := False; 8077 8077 PaintAllMaps; 8078 8078 end … … 8098 8098 else 8099 8099 begin 8100 MapValid := false;8100 MapValid := False; 8101 8101 PaintAllMaps; 8102 8102 end; // update main map … … 8117 8117 end; 8118 8118 SetMapOptions; 8119 MapValid := false;8119 MapValid := False; 8120 8120 PaintAllMaps; 8121 8121 end; … … 8135 8135 end; 8136 8136 SetMapOptions; 8137 MapValid := false;8137 MapValid := False; 8138 8138 PaintAllMaps; 8139 8139 end; 8140 8140 8141 procedure TMainScreen.FormKeyUp(Sender: TObject; var Key: word;8141 procedure TMainScreen.FormKeyUp(Sender: TObject; var Key: Word; 8142 8142 Shift: TShiftState); 8143 8143 begin 8144 if idle and (Key = VK_APPS) then8144 if Idle and (Key = VK_APPS) then 8145 8145 begin 8146 8146 InitPopup(GamePopup); … … 8150 8150 GamePopup.Popup(Left + 4, Top + GetSystemMetrics(SM_CYCAPTION) + 4 + 8151 8151 TopBarHeight - 1); 8152 exit;8152 Exit; 8153 8153 end; // windows menu button calls game menu 8154 8154 end; … … 8156 8156 procedure TMainScreen.CreateUnitClick(Sender: TObject); 8157 8157 var 8158 p1, mix: integer;8158 p1, mix: Integer; 8159 8159 begin 8160 8160 p1 := TComponent(Sender).Tag shr 16; 8161 8161 mix := TComponent(Sender).Tag and $FFFF; 8162 if Server(sCreateUnit + p1 shl 4, me, mix, EditLoc) >= rExecuted then8162 if Server(sCreateUnit + p1 shl 4, Me, mix, EditLoc) >= rExecuted then 8163 8163 PaintLoc(EditLoc); 8164 8164 end; … … 8181 8181 { procedure TMainScreen.AdviceBtnClick; 8182 8182 var 8183 OldAdviceLoc: integer;8184 begin 8185 DestinationMarkON:= false;8183 OldAdviceLoc: Integer; 8184 begin 8185 DestinationMarkON:=False; 8186 8186 PaintDestination; 8187 8187 AdvisorDlg.GiveStrategyAdvice; … … 8193 8193 { procedure TMainScreen.SetAdviceLoc(Loc: integer; AvoidRect: TRect); 8194 8194 var 8195 OldAdviceLoc, x,y: integer;8195 OldAdviceLoc,X,Y: Integer; 8196 8196 begin 8197 8197 if Loc<>MainMap.AdviceLoc then … … 8199 8199 if Loc>=0 then 8200 8200 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); 8204 8204 PaintAllMaps; 8205 8205 end; … … 8259 8259 procedure TMainScreen.SaveMenuItemsState; 8260 8260 var 8261 i, j: integer;8261 I, J: Integer; 8262 8262 begin 8263 8263 if soTellAI in OptionChecked then OptionChecked := [soTellAI] 8264 8264 else OptionChecked := []; 8265 for i:= 0 to ComponentCount - 1 do8266 if Components[ i] is TMenuItem then8267 for j:= 0 to Length(SaveOption) - 1 do8268 if TMenuItem(Components[ i]).Checked and8269 (TMenuItem(Components[ i]).Tag = SaveOption[j]) then8270 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)]; 8271 8271 end; 8272 8272 … … 8280 8280 with Reg do 8281 8281 try 8282 OpenKey(AppRegistryKey, true);8282 OpenKey(AppRegistryKey, True); 8283 8283 WriteInteger('TileSize', Integer(MainMap.TileSize)); 8284 8284 WriteInteger('OptionChecked', Integer(OptionChecked)); 8285 8285 WriteInteger('MapOptionChecked', Integer(MapOptionChecked)); 8286 WriteInteger('CityReport', integer(CityRepMask));8286 WriteInteger('CityReport', Integer(CityRepMask)); 8287 8287 finally 8288 8288 Free;
Note:
See TracChangeset
for help on using the changeset viewer.