Changeset 465 for branches/highdpi/LocalPlayer/Term.pas
- Timestamp:
- Nov 30, 2023, 10:16:14 PM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/highdpi/LocalPlayer/Term.pas
r405 r465 5 5 6 6 uses 7 UDpiControls, {$IFDEF W indows}7 UDpiControls, {$IFDEF WINDOWS} 8 8 Windows, 9 9 {$ENDIF} 10 {$IFDEF Linux}10 {$IFDEF UNIX} 11 11 LMessages, Messages, 12 12 {$ENDIF} … … 14 14 LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, DrawDlg, Types, 15 15 Forms, Menus, ExtCtrls, dateutils, Platform, ButtonB, ButtonC, EOTButton, Area, 16 UGraphicSet, UMiniMap, IsoEngine; 16 GraphicSet, MiniMap, IsoEngine, Wonders, TechTree, Enhance, Nego, CityType, 17 Diagram, CityScreen, Rates, Battle, NatStat, UnitStat, Draft, Select, MessgEx, 18 Help; 17 19 18 20 const … … 68 70 mWonders: TDpiMenuItem; 69 71 mScienceStat: TDpiMenuItem; 70 mR R: TDpiMenuItem;72 mRailRoad: TDpiMenuItem; 71 73 mClear: TDpiMenuItem; 72 74 mFarm: TDpiMenuItem; … … 181 183 procedure FormMouseWheel(Sender: TObject; Shift: TShiftState; 182 184 WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); 185 procedure mAfforestClick(Sender: TObject); 186 procedure mAirBaseClick(Sender: TObject); 187 procedure mCanalClick(Sender: TObject); 188 procedure mCancelClick(Sender: TObject); 189 procedure mCentreClick(Sender: TObject); 190 procedure mcityClick(Sender: TObject); 191 procedure mCityStatClick(Sender: TObject); 192 procedure mCityTypesClick(Sender: TObject); 193 procedure mClearClick(Sender: TObject); 194 procedure mDiagramClick(Sender: TObject); 195 procedure mEmpireClick(Sender: TObject); 196 procedure mEnhanceClick(Sender: TObject); 197 procedure mEnhanceDefClick(Sender: TObject); 198 procedure mEUnitStatClick(Sender: TObject); 199 procedure mFarmClick(Sender: TObject); 200 procedure mfortClick(Sender: TObject); 201 procedure mGoOnClick(Sender: TObject); 202 procedure mHelpClick(Sender: TObject); 203 procedure mhomeClick(Sender: TObject); 204 procedure mirrigationClick(Sender: TObject); 205 procedure mirrigationDrawItem(Sender: TObject; ACanvas: TDpiCanvas; 206 ARect: TRect; AState: TOwnerDrawState); 207 procedure mJumpClick(Sender: TObject); 208 procedure mLoadClick(Sender: TObject); 209 procedure mmineClick(Sender: TObject); 210 procedure mNationsClick(Sender: TObject); 211 procedure mNextUnitClick(Sender: TObject); 212 procedure mnoordersClick(Sender: TObject); 213 procedure mPillageClick(Sender: TObject); 214 procedure mpollutionClick(Sender: TObject); 215 procedure mPrevUnitClick(Sender: TObject); 216 procedure mRandomMapClick(Sender: TObject); 217 procedure mRecoverClick(Sender: TObject); 218 procedure mResignClick(Sender: TObject); 219 procedure mRevolutionClick(Sender: TObject); 220 procedure mroadClick(Sender: TObject); 221 procedure mRailRoadClick(Sender: TObject); 222 procedure mRunClick(Sender: TObject); 223 procedure mScienceStatClick(Sender: TObject); 224 procedure mSelectTransportClick(Sender: TObject); 225 procedure mShipsClick(Sender: TObject); 226 procedure mstayClick(Sender: TObject); 227 procedure mTechTreeClick(Sender: TObject); 228 procedure mtransClick(Sender: TObject); 229 procedure mUnitStatClick(Sender: TObject); 230 procedure mUnloadClick(Sender: TObject); 231 procedure mwaitClick(Sender: TObject); 232 procedure mWebsiteClick(Sender: TObject); 233 procedure mWondersClick(Sender: TObject); 183 234 procedure Timer1Timer(Sender: TObject); 184 235 procedure MapBoxMouseDown(Sender: TObject; Button: TMouseButton; 185 Shift: TShiftState; x, y: integer);236 Shift: TShiftState; X, Y: Integer); 186 237 procedure EOTClick(Sender: TObject); 187 238 procedure PanelBoxMouseDown(Sender: TObject; Button: TMouseButton; 188 Shift: TShiftState; x, y: integer);189 procedure FormKeyDown(Sender: TObject; var Key: word; Shift: TShiftState);190 procedure MenuClick(Sender: TObject);239 Shift: TShiftState; X, Y: Integer); 240 procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); 241 procedure mDisbandOrUtilizeClick(Sender: TObject); 191 242 procedure FormResize(Sender: TObject); 192 243 procedure PanelBtnClick(Sender: TObject); 193 procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);244 procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); 194 245 procedure Toggle(Sender: TObject); 195 246 procedure PanelBoxMouseMove(Sender: TObject; Shift: TShiftState; 196 x, y: integer);247 X, Y: Integer); 197 248 procedure PanelBoxMouseUp(Sender: TObject; Button: TMouseButton; 198 Shift: TShiftState; x, y: integer);249 Shift: TShiftState; X, Y: Integer); 199 250 procedure MapBoxMouseMove(Sender: TObject; Shift: TShiftState; 200 x, y: integer);251 X, Y: Integer); 201 252 procedure mShowClick(Sender: TObject); 202 253 procedure FormMouseDown(Sender: TObject; Button: TMouseButton; 203 Shift: TShiftState; x, y: integer);204 procedure FormMouseMove(Sender: TObject; Shift: TShiftState; x, y: integer);254 Shift: TShiftState; X, Y: Integer); 255 procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); 205 256 procedure FormMouseUp(Sender: TObject; Button: TMouseButton; 206 Shift: TShiftState; x, y: integer);257 Shift: TShiftState; X, Y: Integer); 207 258 procedure FormPaint(Sender: TObject); 208 259 procedure mRepClicked(Sender: TObject); … … 214 265 procedure mNamesClick(Sender: TObject); 215 266 procedure MapBtnClick(Sender: TObject); 216 procedure FormKeyUp(Sender: TObject; var Key: word; Shift: TShiftState);267 procedure FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); 217 268 procedure CreateUnitClick(Sender: TObject); 218 269 procedure mSoundOffClick(Sender: TObject); … … 275 326 NoMap: TIsoMap; 276 327 NoMapPanel: TIsoMap; 277 function ChooseUnusedTribe: integer; 328 // Forms 329 FWondersDlg: TWondersDlg; 330 FTechTreeDlg: TTechTreeDlg; 331 FEnhanceDlg: TEnhanceDlg; 332 FNegoDlg: TNegoDlg; 333 FCityTypeDlg: TCityTypeDlg; 334 FDiaDlg: TDiaDlg; 335 FCityDlg: TCityDlg; 336 FRatesDlg: TRatesDlg; 337 FBattleDlg: TBattleDlg; 338 FNatStatDlg: TNatStatDlg; 339 FUnitStatDlg: TUnitStatDlg; 340 FDraftDlg: TDraftDlg; 341 FModalSelectDlg: TModalSelectDlg; 342 FListDlg: TListDlg; 343 FMessgExDlg: TMessgExDlg; 344 FHelpDlg: THelpDlg; 345 procedure ArrangeDialogs; 346 procedure ArrangeDialog(Form: TBufferedDrawDlg); 347 function ChooseUnusedTribe: Integer; 348 function DoJob(j0: Integer): Integer; 349 function GetBattleDlg: TBattleDlg; 350 function GetCityDlg: TCityDlg; 351 function GetCityTypeDlg: TCityTypeDlg; 352 function GetDiaDlg: TDiaDlg; 353 function GetDraftDlg: TDraftDlg; 354 function GetEnhanceDlg: TEnhanceDlg; 355 function GetHelpDlg: THelpDlg; 356 function GetListDlg: TListDlg; 357 function GetMessgExDlg: TMessgExDlg; 358 function GetModalSelectDlg: TModalSelectDlg; 359 function GetNatStatDlg: TNatStatDlg; 360 function GetNegoDlg: TNegoDlg; 361 function GetRatesDlg: TRatesDlg; 362 function GetTechTreeDlg: TTechTreeDlg; 278 363 procedure GetTribeList; 364 function GetUnitStatDlg: TUnitStatDlg; 365 function GetWondersDlg: TWondersDlg; 279 366 procedure InitModule; 280 367 procedure DoneModule; 281 procedure InitTurn(NewPlayer: integer);368 procedure InitTurn(NewPlayer: Integer); 282 369 procedure SaveMenuItemsState; 283 370 procedure ScrollBarUpdate(Sender: TObject); … … 291 378 procedure FocusNextUnit(Dir: Integer = 1); 292 379 procedure NextUnit(NearLoc: Integer; AutoTurn: Boolean); 293 procedure Scroll(dx, dy: integer);294 procedure SetMapPos(Loc: integer; MapPos: TPoint);295 procedure Centre(Loc: integer);296 procedure SetTroopLoc(Loc: integer);297 procedure ProcessRect(x0, y0, nx, ny, Options: integer);298 procedure PaintLoc(Loc: integer; Radius: integer = 0);299 procedure PaintLoc_BeforeMove(FromLoc: integer);300 procedure PaintLocTemp(Loc: integer; Style: TPaintLocTempStyle = pltsNormal);301 procedure PaintBufferToScreen(xMap, yMap, width, height: integer);380 procedure Scroll(dx, dy: Integer); 381 procedure SetMapPos(Loc: Integer; MapPos: TPoint); 382 procedure Centre(Loc: Integer); 383 procedure SetTroopLoc(Loc: Integer); 384 procedure ProcessRect(x0, y0, nx, ny, Options: Integer); 385 procedure PaintLoc(Loc: Integer; Radius: Integer = 0); 386 procedure PaintLoc_BeforeMove(FromLoc: Integer); 387 procedure PaintLocTemp(Loc: Integer; Style: TPaintLocTempStyle = pltsNormal); 388 procedure PaintBufferToScreen(xMap, yMap, width, height: Integer); 302 389 procedure PaintDestination; 303 procedure SetUnFocus(uix: integer);304 function MoveUnit(dx, dy: integer; Options: integer = 0): integer;305 procedure MoveToLoc(Loc: integer; CheckSuicide: boolean);306 procedure MoveOnScreen(ShowMove: TShowMove; Step0, Step1, nStep: integer;307 Restore: boolean = true);308 procedure FocusOnLoc(Loc: integer; Options: integer = 0);309 function EndTurn(WasSkipped: boolean = false): boolean;390 procedure SetUnFocus(uix: Integer); 391 function MoveUnit(dx, dy: Integer; Options: Integer = 0): Integer; 392 procedure MoveToLoc(Loc: Integer; CheckSuicide: Boolean); 393 procedure MoveOnScreen(ShowMove: TShowMove; Step0, Step1, nStep: Integer; 394 Restore: Boolean = True); 395 procedure FocusOnLoc(Loc: Integer; Options: Integer = 0); 396 function EndTurn(WasSkipped: Boolean = False): Boolean; 310 397 procedure EndNego; 311 function IsPanelPixel( x, y: integer): boolean;398 function IsPanelPixel(X, Y: Integer): Boolean; 312 399 procedure InitPopup(Popup: TDpiPopupMenu); 313 400 procedure SetMapOptions; … … 315 402 procedure CheckTerrainBtnVisible; 316 403 procedure RememberPeaceViolation; 317 procedure SetDebugMap( p: integer);318 procedure SetViewpoint( p: integer);319 function LocationOfScreenPixel( x, y: integer): Integer;404 procedure SetDebugMap(P: Integer); 405 procedure SetViewpoint(P: Integer); 406 function LocationOfScreenPixel(X, Y: Integer): Integer; 320 407 function GetCenterLoc: Integer; 321 408 procedure SetTileSizeCenter(TileSize: TTileSize); 322 409 procedure SetTileSize(TileSize: TTileSize; Loc: Integer; MapPos: TPoint); 323 procedure RectInvalidate(Left, Top, Rigth, Bottom: integer);410 procedure RectInvalidate(Left, Top, Rigth, Bottom: Integer); 324 411 procedure ShowEnemyShipChange(ShowShipChange: TShowShipChange); 325 procedure SmartRectInvalidate(Left, Top, Rigth, Bottom: integer);412 procedure SmartRectInvalidate(Left, Top, Rigth, Bottom: Integer); 326 413 procedure LoadSettings; 327 414 procedure SaveSettings; … … 331 418 procedure UpdateKeyShortcuts; 332 419 procedure SetFullScreen(Active: Boolean); 333 procedure PaintZoomedTile(dst: TDpiBitmap; x, y, Loc: integer);420 procedure PaintZoomedTile(dst: TDpiBitmap; X, Y, Loc: Integer); 334 421 public 335 UsedOffscreenWidth, UsedOffscreenHeight: integer; 422 UsedOffscreenWidth: Integer; 423 UsedOffscreenHeight: Integer; 336 424 Offscreen: TDpiBitmap; 337 425 OffscreenUser: TDpiForm; 338 procedure Client(Command, NewPlayer: integer; var Data); 339 procedure SetAIName(p: integer; Name: string); 340 function ZoomToCity(Loc: integer; NextUnitOnClose: boolean = false; 341 ShowEvent: integer = 0): boolean; 342 procedure CityClosed(Activateuix: integer; StepFocus: boolean = false; 343 SelectFocus: boolean = false); 344 function DipCall(Command: integer): integer; 345 function OfferCall(var Offer: TOffer): integer; 346 procedure UpdateViews(UpdateCityScreen: boolean = false); 347 function ContactRefused(p: integer; Item: String): boolean; 426 procedure Client(Command, NewPlayer: Integer; var Data); 427 procedure SetAIName(P: Integer; Name: string); 428 function ZoomToCity(Loc: Integer; NextUnitOnClose: Boolean = False; 429 ShowEvent: Integer = 0): Boolean; 430 procedure CityClosed(Activateuix: Integer; StepFocus: Boolean = False; 431 SelectFocus: Boolean = False); 432 function DipCall(Command: Integer): Integer; 433 function OfferCall(var Offer: TOffer): Integer; 434 procedure UpdateViews(UpdateCityScreen: Boolean = False); 435 function ContactRefused(P: Integer; Item: String): Boolean; 436 // Forms 437 property WondersDlg: TWondersDlg read GetWondersDlg; 438 property TechTreeDlg: TTechTreeDlg read GetTechTreeDlg; 439 property EnhanceDlg: TEnhanceDlg read GetEnhanceDlg; 440 property NegoDlg: TNegoDlg read GetNegoDlg; 441 property CityTypeDlg: TCityTypeDlg read GetCityTypeDlg; 442 property DiaDlg: TDiaDlg read GetDiaDlg; 443 property CityDlg: TCityDlg read GetCityDlg; 444 property RatesDlg: TRatesDlg read GetRatesDlg; 445 property BattleDlg: TBattleDlg read GetBattleDlg; 446 property NatStatDlg: TNatStatDlg read GetNatStatDlg; 447 property UnitStatDlg: TUnitStatDlg read GetUnitStatDlg; 448 property DraftDlg: TDraftDlg read GetDraftDlg; 449 property ModalSelectDlg: TModalSelectDlg read GetModalSelectDlg; 450 property ListDlg: TListDlg read GetListDlg; 451 property MessgExDlg: TMessgExDlg read GetMessgExDlg; 452 property HelpDlg: THelpDlg read GetHelpDlg; 348 453 end; 349 454 … … 352 457 353 458 type 459 460 { TTribeInfo } 461 354 462 TTribeInfo = record 355 trix: integer;463 trix: Integer; 356 464 FileName: ShortString; 357 end; 465 function GetCommandDataSize: Byte; 466 end; 467 468 { TCityNameInfo } 358 469 359 470 TCityNameInfo = record 360 ID: integer;471 ID: Integer; 361 472 NewName: ShortString; 362 end; 473 function GetCommandDataSize: Byte; 474 end; 475 476 { TModelNameInfo } 363 477 364 478 TModelNameInfo = record 365 mix: integer;479 mix: Integer; 366 480 NewName: ShortString; 367 end; 368 369 TPriceSet = set of $00 .. $FF; 481 function GetCommandDataSize: Byte; 482 end; 483 484 TFormAction = (faClose, faEnable, faDisable, faUpdate, faSmartUpdateContent); 370 485 371 486 const … … 410 525 usToldNoReturn = $100; 411 526 usPersistent = usStay or usGoto or usEnhance or usRecover or 412 integer($FFFF0000);527 Integer($FFFF0000); 413 528 414 529 { model status flags } … … 424 539 adNexus = $803; 425 540 426 SpecialModelPictureCode: array [0 .. nSpecialModel - 1] of integer = (10,541 SpecialModelPictureCode: array [0 .. nSpecialModel - 1] of Integer = (10, 427 542 11, 40, 41, 21, 30, { 50,51, } 64, 74, { 71, } 73); 428 543 … … 437 552 438 553 nCityEventPriority = 16; 439 CityEventPriority: array [0 .. nCityEventPriority - 1] of integer =554 CityEventPriority: array [0 .. nCityEventPriority - 1] of Integer = 440 555 (chDisorder, chImprovementLost, chUnitLost, chAllImpsMade, chProduction, 441 556 chOldWonder, chNoSettlerProd, chPopDecrease, chProductionSabotaged, … … 504 619 DestinationMarkON: Boolean; 505 620 StartRunning: Boolean; 506 StayOnTop_Ensured: Boolean;507 621 Supervising: Boolean; 508 622 UnusedTribeFiles: TStringList; … … 512 626 DipMem: array [0 .. nPl - 1] of TDipMem; 513 627 514 function CityEventName( i: integer): string;515 function RoughCredibility(Credibility: integer): integer;516 517 function InitEnemyModel(emix: integer): boolean;628 function CityEventName(I: Integer): string; 629 function RoughCredibility(Credibility: Integer): Integer; 630 631 function InitEnemyModel(emix: Integer): Boolean; 518 632 procedure InitAllEnemyModels; 519 procedure InitMyModel(mix: integer; final: boolean); 520 521 procedure ImpImage(ca: TDpiCanvas; x, y, iix: integer; Government: integer = -1; 522 IsControl: boolean = false); 523 procedure HelpOnTerrain(Loc, NewMode: integer); 633 procedure InitMyModel(Mix: Integer; Final: Boolean); 634 635 procedure ImpImage(ca: TDpiCanvas; X, Y, iix: Integer; Government: Integer = -1; 636 IsControl: Boolean = False); 637 procedure HelpOnTerrain(Loc: Integer; NewMode: TWindowMode); 638 function AlignUp(Value, Alignment: Integer): Integer; 524 639 525 640 … … 527 642 528 643 uses 529 Directories, CityScreen, Draft, MessgEx, Select, CityType, Help, 530 UnitStat, Log, Diagram, NatStat, Wonders, Enhance, Nego, UPixelPointer, Sound, 531 Battle, Rates, TechTree, Registry, Global, UKeyBindings; 644 Directories, Log, PixelPointer, Sound, Registry, Global, KeyBindings, CmdList; 532 645 533 646 {$R *.lfm} … … 536 649 lxmax_xxx = 130; 537 650 LeftPanelWidth = 70; 538 LeftPanelWidth_Editor = 46;539 651 overlap = PanelHeight - MidPanelHeight; 540 652 yTroop = PanelHeight - 83; 541 653 xPalace = 66; 542 654 yPalace = 24; // 120; 543 xAdvisor = 108;544 yAdvisor = 48; 655 { xAdvisor = 108; 656 yAdvisor = 48;} 545 657 xUnitText = 80; 546 PaperShade = 3;547 658 BlinkOnTime = 12; 548 659 BlinkOffTime = 6; 549 660 MoveTime = 300; // {time for moving a unit in ms} 550 661 WaitAfterShowMove = 32; 551 FastScrolling = false; // causes problems with overlapping windows662 FastScrolling = False; // causes problems with overlapping windows 552 663 553 664 nBrushTypes = 26; … … 587 698 CurrentMoveInfo: TCurrentMoveInfo; 588 699 589 function CityEventName( i: integer): string;590 begin 591 if i= 14 then // chAllImpsMade700 function CityEventName(I: Integer): string; 701 begin 702 if I = 14 then // chAllImpsMade 592 703 if not Phrases2FallenBackToEnglish then 593 result := Phrases2.Lookup('CITYEVENT_ALLIMPSMADE')704 Result := Phrases2.Lookup('CITYEVENT_ALLIMPSMADE') 594 705 else 595 result := Phrases.Lookup('CITYEVENTS', 1)706 Result := Phrases.Lookup('CITYEVENTS', 1) 596 707 else 597 result := Phrases.Lookup('CITYEVENTS', i);708 Result := Phrases.Lookup('CITYEVENTS', I); 598 709 end; 599 710 … … 605 716 TBuffer = array [0 .. 99999, 0 .. 2] of Integer; 606 717 var 607 Sum, Cnt, dx, dy, nx, ny, ix, iy, ir, x, y, c, ch: Integer; 718 Sum: Int64; 719 Cnt, dx, dy, nx, ny, ix, iy, ir, X, Y, C, ch: Integer; 608 720 xdivider, ydivider: Integer; 609 721 Resampled: ^TBuffer; … … 611 723 begin 612 724 nx := BigImp.Width div xSizeBig * xSizeSmall; 613 ny := BigImp.Height div ySizeBig * ySizeSmall;614 SmallImp.SetSize(nx, ny);615 SmallImp.Canvas.StretchDraw(Rect(0, 0, SmallImp.Width, SmallImp.Height), BigImp);616 617 { nx := BigImp.Width div xSizeBig * xSizeSmall;618 725 ny := BigImp.Height div ySizeBig * ySizeSmall; 619 726 … … 624 731 for ix := 0 to BigImp.Width div xSizeBig - 1 do 625 732 for iy := 0 to BigImp.Height div ySizeBig - 1 do begin 626 PixelPtr := PixelPointer(BigImp, ScaleToNative(ix * xSizeBig),627 ScaleToNative( cut + iy * ySizeBig));628 for y := 0 to ScaleToNative(ySizeBig - 2 * cut) - 1 do begin629 ydivider := (ScaleFromNative( y) * ySizeSmall div (ySizeBig - 2 * cut) + 1) *630 (ySizeBig - 2 * cut) - ScaleFromNative(y) * ySizeSmall;733 PixelPtr := TPixelPointer.Create(BigImp, ScaleToNative(ix * xSizeBig), 734 ScaleToNative(Cut + iy * ySizeBig)); 735 for Y := 0 to ScaleToNative(ySizeBig - 2 * Cut) - 1 do begin 736 ydivider := (ScaleFromNative(Y) * ySizeSmall div (ySizeBig - 2 * Cut) + 1) * 737 (ySizeBig - 2 * Cut) - ScaleFromNative(Y) * ySizeSmall; 631 738 if ydivider > ySizeSmall then 632 739 ydivider := ySizeSmall; 633 for x:= 0 to ScaleToNative(xSizeBig) - 1 do begin634 ir := ix * xSizeSmall + iy * nx * ySizeSmall + ScaleFromNative( x) *635 xSizeSmall div xSizeBig + ScaleFromNative( y) *636 ySizeSmall div (ySizeBig - 2 * cut) * nx;637 xdivider := (ScaleFromNative( x) * xSizeSmall div xSizeBig + 1) *638 xSizeBig - ScaleFromNative( x) * xSizeSmall;740 for X := 0 to ScaleToNative(xSizeBig) - 1 do begin 741 ir := ix * xSizeSmall + iy * nx * ySizeSmall + ScaleFromNative(X) * 742 xSizeSmall div xSizeBig + ScaleFromNative(Y) * 743 ySizeSmall div (ySizeBig - 2 * Cut) * nx; 744 xdivider := (ScaleFromNative(X) * xSizeSmall div xSizeBig + 1) * 745 xSizeBig - ScaleFromNative(X) * xSizeSmall; 639 746 if xdivider > xSizeSmall then 640 747 xdivider := xSizeSmall; 641 748 for ch := 0 to 2 do begin 642 c:= PixelPtr.Pixel^.Planes[ch];643 Inc(Resampled[ir, ch], c* xdivider * ydivider);749 C := PixelPtr.Pixel^.Planes[ch]; 750 Inc(Resampled[ir, ch], C * xdivider * ydivider); 644 751 if xdivider < xSizeSmall then 645 Inc(Resampled[ir + 1, ch], c* (xSizeSmall - xdivider) *752 Inc(Resampled[ir + 1, ch], C * (xSizeSmall - xdivider) * 646 753 ydivider); 647 754 if ydivider < ySizeSmall then 648 755 Inc(Resampled[ir + nx, ch], 649 c* xdivider * (ySizeSmall - ydivider));756 C * xdivider * (ySizeSmall - ydivider)); 650 757 if (xdivider < xSizeSmall) and (ydivider < ySizeSmall) then 651 Inc(Resampled[ir + nx + 1, ch], c* (xSizeSmall - xdivider) *758 Inc(Resampled[ir + nx + 1, ch], C * (xSizeSmall - xdivider) * 652 759 (ySizeSmall - ydivider)); 653 760 end; … … 662 769 SmallImp.SetSize(nx, ny); 663 770 SmallImp.BeginUpdate; 664 PixelPtr := PixelPointer(SmallImp);665 for y:= 0 to ScaleToNative(ny) - 1 do begin666 for x:= 0 to ScaleToNative(nx) - 1 do begin771 PixelPtr := TPixelPointer.Create(SmallImp); 772 for Y := 0 to ScaleToNative(ny) - 1 do begin 773 for X := 0 to ScaleToNative(nx) - 1 do begin 667 774 for ch := 0 to 2 do begin 668 775 Sum := 0; 669 776 Cnt := 0; 670 777 for dy := -1 to 1 do 671 if ((dy >= 0) or (ScaleFromNative( y) mod ySizeSmall > 0)) and672 ((dy <= 0) or (ScaleFromNative( y) mod ySizeSmall < ySizeSmall - 1)) then778 if ((dy >= 0) or (ScaleFromNative(Y) mod ySizeSmall > 0)) and 779 ((dy <= 0) or (ScaleFromNative(Y) mod ySizeSmall < ySizeSmall - 1)) then 673 780 for dx := -1 to 1 do 674 if ((dx >= 0) or (ScaleFromNative( x) mod xSizeSmall > 0)) and675 ((dx <= 0) or (ScaleFromNative( x) mod xSizeSmall < xSizeSmall - 1)) then781 if ((dx >= 0) or (ScaleFromNative(X) mod xSizeSmall > 0)) and 782 ((dx <= 0) or (ScaleFromNative(X) mod xSizeSmall < xSizeSmall - 1)) then 676 783 begin 677 Inc(Sum, Resampled[ScaleFromNative( x) + dx + nx * (ScaleFromNative(y) + dy), ch]);784 Inc(Sum, Resampled[ScaleFromNative(X) + dx + nx * (ScaleFromNative(Y) + dy), ch]); 678 785 Inc(Cnt); 679 786 end; 680 Sum := ((Cnt * Sharpen + 800) * Resampled[ScaleFromNative( x) + nx * ScaleFromNative(y), ch] - Sum *681 Sharpen) div (800 * xSizeBig * (ySizeBig - 2 * cut));787 Sum := ((Cnt * Sharpen + 800) * Resampled[ScaleFromNative(X) + nx * ScaleFromNative(Y), ch] - Sum * 788 Sharpen) div (800 * xSizeBig * (ySizeBig - 2 * Cut)); 682 789 if Sum < 0 then Sum := 0; 683 790 if Sum > 255 then Sum := 255; … … 690 797 SmallImp.EndUpdate; 691 798 FreeMem(Resampled); 692 } 693 end; 694 695 procedure ImpImage(ca: TDpiCanvas; x, y, iix: integer; Government: integer; 696 IsControl: boolean); 799 end; 800 801 procedure ImpImage(ca: TDpiCanvas; X, Y, iix: Integer; Government: Integer; 802 IsControl: Boolean); 697 803 begin 698 804 if Government < 0 then … … 700 806 if (iix = imPalace) and (Government <> gAnarchy) then 701 807 iix := Government - 8; 702 FrameImage(ca, BigImp, x, y, xSizeBig, ySizeBig, (iix + SystemIconLines * 7)808 FrameImage(ca, BigImp, X, Y, xSizeBig, ySizeBig, (iix + SystemIconLines * 7) 703 809 mod 7 * xSizeBig, (iix + SystemIconLines * 7) div 7 * ySizeBig, IsControl); 704 810 end; 705 811 706 procedure HelpOnTerrain(Loc , NewMode: integer);812 procedure HelpOnTerrain(Loc: Integer; NewMode: TWindowMode); 707 813 begin 708 814 if MyMap[Loc] and fDeadLands <> 0 then 709 HelpDlg.ShowNewContent(NewMode, hkTer, 3 * 12)815 MainScreen.HelpDlg.ShowNewContent(NewMode, hkTer, 3 * 12) 710 816 else if (MyMap[Loc] and fTerrain = fForest) and IsJungle(Loc div G.lx) then 711 HelpDlg.ShowNewContent(NewMode, hkTer,817 MainScreen.HelpDlg.ShowNewContent(NewMode, hkTer, 712 818 fJungle + (MyMap[Loc] shr 5 and 3) * 12) 713 819 else 714 HelpDlg.ShowNewContent(NewMode, hkTer, MyMap[Loc] and fTerrain +820 MainScreen.HelpDlg.ShowNewContent(NewMode, hkTer, MyMap[Loc] and fTerrain + 715 821 (MyMap[Loc] shr 5 and 3) * 12); 716 822 end; 717 823 824 function AlignUp(Value, Alignment: Integer): Integer; 825 begin 826 Result := Value or (Alignment - 1); 827 end; 828 718 829 { *** tribe management procedures *** } 719 830 720 function RoughCredibility(Credibility: integer): integer;831 function RoughCredibility(Credibility: Integer): Integer; 721 832 begin 722 833 case Credibility of 723 834 0 .. 69: 724 result := 0;835 Result := 0; 725 836 70 .. 89: 726 result := 1;837 Result := 1; 727 838 90 .. 99: 728 result := 2;839 Result := 2; 729 840 100: 730 result := 3731 end; 732 end; 733 734 procedure ChooseModelPicture( p, mix, code, Hash, Turn: integer;735 ForceNew, final: boolean);841 Result := 3; 842 end; 843 end; 844 845 procedure ChooseModelPicture(P, mix, Code, Hash, Turn: Integer; 846 ForceNew, final: Boolean); 736 847 var 737 i: integer;848 I: Integer; 738 849 Picture: TModelPictureInfo; 739 IsNew: boolean;740 begin 741 Picture.trix := p;850 IsNew: Boolean; 851 begin 852 Picture.trix := P; 742 853 Picture.mix := mix; 743 if code = 74 then854 if Code = 74 then 744 855 begin // use correct pictures for slaves 745 if Tribe[ p].mixSlaves < 0 then746 if not TribeOriginal[ p] then747 Tribe[ p].mixSlaves := mix856 if Tribe[P].mixSlaves < 0 then 857 if not TribeOriginal[P] then 858 Tribe[P].mixSlaves := mix 748 859 else 749 860 begin 750 i := mix + pshl 16;751 Server(cSetSlaveIndex, 0, 0, i);861 I := mix + P shl 16; 862 Server(cSetSlaveIndex, 0, 0, I); 752 863 end; 753 864 if ToldSlavery = 1 then … … 757 868 Picture.Hash := 0; 758 869 Picture.GrName := 'StdUnits.png'; 759 IsNew := true;870 IsNew := True; 760 871 end 761 872 else 762 873 begin 763 874 Picture.Hash := Hash; 764 IsNew := Tribe[ p].ChooseModelPicture(Picture, code, Turn, ForceNew);875 IsNew := Tribe[P].ChooseModelPicture(Picture, Code, Turn, ForceNew); 765 876 end; 766 877 if final then 767 if not TribeOriginal[ p] then768 Tribe[ p].SetModelPicture(Picture, IsNew)878 if not TribeOriginal[P] then 879 Tribe[P].SetModelPicture(Picture, IsNew) 769 880 else if IsNew then 770 Server( cSetNewModelPicture + (Length(Picture.GrName) + 1 + 16 + 3) div 4,881 Server(CommandWithData(cSetNewModelPicture, Picture.GetCommandDataSize), 771 882 0, 0, Picture) 772 883 else 773 Server( cSetModelPicture + (Length(Picture.GrName) + 1 + 16 + 3) div 4, 0,774 0, Picture)884 Server(CommandWithData(cSetModelPicture, Picture.GetCommandDataSize), 885 0, 0, Picture) 775 886 else 776 with Tribe[ p].ModelPicture[mix] do887 with Tribe[P].ModelPicture[mix] do 777 888 begin 778 889 HGr := LoadGraphicSet(Picture.GrName); … … 781 892 end; 782 893 783 function InitEnemyModel(emix: integer): boolean;894 function InitEnemyModel(emix: Integer): Boolean; 784 895 begin 785 896 if GameMode = cMovie then 786 897 begin 787 result := false;788 exit898 Result := False; 899 Exit; 789 900 end; 790 901 with MyRO.EnemyModel[emix] do 791 902 ChooseModelPicture(Owner, mix, ModelCode(MyRO.EnemyModel[emix]), 792 ModelHash(MyRO.EnemyModel[emix]), MyRO.Turn, false, true);793 result := true;903 ModelHash(MyRO.EnemyModel[emix]), MyRO.Turn, False, True); 904 Result := True; 794 905 end; 795 906 796 907 procedure InitAllEnemyModels; 797 908 var 798 emix: integer;909 emix: Integer; 799 910 begin 800 911 for emix := 0 to MyRO.nEnemyModel - 1 do … … 804 915 end; 805 916 806 procedure InitMyModel( mix: integer; final: boolean);917 procedure InitMyModel(Mix: Integer; Final: Boolean); 807 918 var 808 919 mi: TModelInfo; 809 920 begin 810 921 if (GameMode = cMovie) and (MyModel[mix].Kind < $08) then 811 exit;922 Exit; 812 923 // don't exit for special units because cSetModelPicture comes after TellNewModels 813 MakeModelInfo( me, mix, MyModel[mix], mi);814 ChooseModelPicture( me, mix, ModelCode(mi), ModelHash(mi), MyRO.Turn,815 false, final);816 end; 817 818 function AttackSound( code: integer): string;819 begin 820 result := 'ATTACK_' + char(48 + code div 100 mod 10) +821 char(48 + code div 10 mod 10) + char(48 + code mod 10);822 end; 823 824 procedure CheckToldNoReturn(uix: integer);924 MakeModelInfo(Me, Mix, MyModel[mix], mi); 925 ChooseModelPicture(Me, Mix, ModelCode(mi), ModelHash(mi), MyRO.Turn, 926 False, Final); 927 end; 928 929 function AttackSound(Code: Integer): string; 930 begin 931 Result := 'ATTACK_' + char(48 + Code div 100 mod 10) + 932 char(48 + Code div 10 mod 10) + char(48 + Code mod 10); 933 end; 934 935 procedure CheckToldNoReturn(uix: Integer); 825 936 // check whether aircraft survived low-fuel warning 826 937 begin 827 assert(not supervising);938 Assert(not Supervising); 828 939 with MyUn[uix] do 829 940 if (Status and usToldNoReturn <> 0) and … … 833 944 end; 834 945 835 function CreateTribe( p: integer; FileName: string; Original: boolean): boolean;946 function CreateTribe(P: Integer; FileName: string; Original: Boolean): Boolean; 836 947 begin 837 948 FileName := LocalizedFilePath('Tribes' + DirectorySeparator + FileName + … … 843 954 end; 844 955 845 TribeOriginal[ p] := Original;846 Tribe[ p] := TTribe.Create(FileName);847 with Tribe[ p] do956 TribeOriginal[P] := Original; 957 Tribe[P] := TTribe.Create(FileName); 958 with Tribe[P] do 848 959 begin 849 960 if (GameMode = cNewGame) or not Original then 850 961 begin 851 Term.ChooseModelPicture( p, 0, 010, 1, 0, true, true);852 Term.ChooseModelPicture( p, 1, 040, 1, 0, true, true);853 Term.ChooseModelPicture( p, 2, 041, 1, 0, true, true);854 Term.ChooseModelPicture( p, -1, 017, 1, 0, true, true);855 end; 856 DipMem[ p].pContact := -1;857 end; 858 result := true;962 Term.ChooseModelPicture(P, 0, 010, 1, 0, True, True); 963 Term.ChooseModelPicture(P, 1, 040, 1, 0, True, True); 964 Term.ChooseModelPicture(P, 2, 041, 1, 0, True, True); 965 Term.ChooseModelPicture(P, -1, 017, 1, 0, True, True); 966 end; 967 DipMem[P].pContact := -1; 968 end; 969 Result := True; 859 970 end; 860 971 861 972 procedure TellNewContacts; 862 973 var 863 p1: integer;864 begin 865 if not supervising then974 p1: Integer; 975 begin 976 if not Supervising then 866 977 for p1 := 0 to nPl - 1 do 867 if (p1 <> me) and (1 shl p1 and MyData.ToldContact = 0) and978 if (p1 <> Me) and (1 shl p1 and MyData.ToldContact = 0) and 868 979 (1 shl p1 and MyRO.Alive <> 0) and (MyRO.Treaty[p1] > trNoContact) then 869 980 begin 870 981 TribeMessage(p1, Tribe[p1].TPhrase('FRNEWNATION'), ''); 871 982 MyData.ToldContact := MyData.ToldContact or (1 shl p1); 872 end 983 end; 873 984 end; 874 985 875 986 procedure TellNewModels; 876 987 var 877 mix: integer;988 mix: Integer; 878 989 ModelNameInfo: TModelNameInfo; 879 990 begin 880 if supervising then881 exit;882 with Tribe[ me] do991 if Supervising then 992 Exit; 993 with Tribe[Me] do 883 994 while MyData.ToldModels < MyRO.nModel do 884 995 begin { new Unit class available } … … 891 1002 end; 892 1003 if not Assigned(ModelPicture[MyData.ToldModels].HGr) then 893 InitMyModel(MyData.ToldModels, true);1004 InitMyModel(MyData.ToldModels, True); 894 1005 { only run if no researched model } 895 with M essgExDlg do1006 with MainScreen.MessgExDlg do 896 1007 begin 897 1008 { MakeModelInfo(me,MyData.ToldModels,MyModel[MyData.ToldModels],mi); … … 919 1030 ModelNameInfo.mix := MyData.ToldModels; 920 1031 ModelNameInfo.NewName := EInput.Text; 921 Server(cSetModelName + (Length(ModelNameInfo.NewName) + 1 + 4 + 3) 922 div 4, me, 0, ModelNameInfo); 1032 if ModelNameInfo.GetCommandDataSize > CommandDataMaxSize then 1033 Delete(ModelNameInfo.NewName, Length(ModelNameInfo.NewName) - 1034 (ModelNameInfo.GetCommandDataSize - 1 - CommandDataMaxSize), MaxInt); 1035 Server(CommandWithData(cSetModelName, ModelNameInfo.GetCommandDataSize), 1036 Me, 0, ModelNameInfo); 923 1037 end; 924 1038 end; … … 929 1043 MyModel[mix].Status := MyModel[mix].Status or msObsolete; 930 1044 end; 931 inc(MyData.ToldModels); 932 end; 933 end; 934 935 procedure TMainScreen.PaintZoomedTile(dst: TDpiBitmap; x, y, Loc: integer); 936 937 procedure TSprite(xDst, yDst, xSrc, ySrc: integer); 1045 Inc(MyData.ToldModels); 1046 end; 1047 end; 1048 1049 { TTribeInfo } 1050 1051 function TTribeInfo.GetCommandDataSize: Byte; 1052 begin 1053 Result := SizeOf(trix) + 1 + Length(FileName) 1054 end; 1055 1056 { TModelNameInfo } 1057 1058 function TModelNameInfo.GetCommandDataSize: Byte; 1059 begin 1060 Result := SizeOf(mix) + 1 + Length(NewName); 1061 end; 1062 1063 { TCityNameInfo } 1064 1065 function TCityNameInfo.GetCommandDataSize: Byte; 1066 begin 1067 Result := SizeOf(ID) + 1 + Length(NewName); 1068 end; 1069 1070 procedure TMainScreen.PaintZoomedTile(dst: TDpiBitmap; X, Y, Loc: Integer); 1071 1072 procedure TSprite(xDst, yDst, xSrc, ySrc: Integer); 938 1073 begin 939 1074 with NoMapPanel do 940 Sprite(dst, HGrTerrain, x + xDst, y+ yDst, xxt * 2, yyt * 3,1075 Sprite(dst, HGrTerrain, X + xDst, Y + yDst, xxt * 2, yyt * 3, 941 1076 1 + xSrc * (xxt * 2 + 1), 1 + ySrc * (yyt * 3 + 1)); 942 1077 end; 943 1078 944 procedure TSprite4(xSrc, ySrc: integer);1079 procedure TSprite4(xSrc, ySrc: Integer); 945 1080 begin 946 1081 with NoMapPanel do begin 947 Sprite(dst, HGrTerrain, x + xxt, y+ yyt + 2, xxt * 2, yyt * 2 - 2,1082 Sprite(dst, HGrTerrain, X + xxt, Y + yyt + 2, xxt * 2, yyt * 2 - 2, 948 1083 1 + xSrc * (xxt * 2 + 1), 3 + yyt + ySrc * (yyt * 3 + 1)); 949 Sprite(dst, HGrTerrain, x + 4, y+ 2 * yyt, xxt * 2 - 4, yyt * 2,1084 Sprite(dst, HGrTerrain, X + 4, Y + 2 * yyt, xxt * 2 - 4, yyt * 2, 950 1085 5 + xSrc * (xxt * 2 + 1), 1 + yyt + ySrc * (yyt * 3 + 1)); 951 Sprite(dst, HGrTerrain, x + xxt * 2, y+ 2 * yyt, xxt * 2 - 4, yyt * 2,1086 Sprite(dst, HGrTerrain, X + xxt * 2, Y + 2 * yyt, xxt * 2 - 4, yyt * 2, 952 1087 1 + xSrc * (xxt * 2 + 1), 1 + yyt + ySrc * (yyt * 3 + 1)); 953 Sprite(dst, HGrTerrain, x + xxt, y+ yyt * 3, xxt * 2, yyt * 2 - 2,1088 Sprite(dst, HGrTerrain, X + xxt, Y + yyt * 3, xxt * 2, yyt * 2 - 2, 954 1089 1 + xSrc * (xxt * 2 + 1), 1 + yyt + ySrc * (yyt * 3 + 1)); 955 1090 end; … … 957 1092 958 1093 var 959 cix, ySrc, Tile: integer;1094 cix, ySrc, Tile: Integer; 960 1095 begin 961 1096 with NoMapPanel do begin … … 971 1106 cix := MyRO.nCity - 1; 972 1107 while (cix >= 0) and (MyCity[cix].Loc <> Loc) do 973 dec(cix);974 assert(cix >= 0);1108 Dec(cix); 1109 Assert(cix >= 0); 975 1110 if MyCity[cix].Built[imSupermarket] > 0 then 976 1111 Tile := Tile or tiFarm … … 1063 1198 end; 1064 1199 1065 function ChooseResearch: boolean;1200 function ChooseResearch: Boolean; 1066 1201 var 1067 ChosenResearch: integer;1202 ChosenResearch: Integer; 1068 1203 begin 1069 1204 if (MyData.FarTech <> adNone) and (MyRO.Tech[MyData.FarTech] >= tsApplicable) … … 1073 1208 { research complete -- select new } 1074 1209 repeat 1075 M odalSelectDlg.ShowNewContent(wmModal, kAdvance);1076 if M odalSelectDlg.result < 0 then1210 MainScreen.ModalSelectDlg.ShowNewContent(wmModal, kAdvance); 1211 if MainScreen.ModalSelectDlg.Result < 0 then 1077 1212 begin 1078 result := false;1079 exit;1080 end; 1081 ChosenResearch := M odalSelectDlg.result;1213 Result := False; 1214 Exit; 1215 end; 1216 ChosenResearch := MainScreen.ModalSelectDlg.Result; 1082 1217 if ChosenResearch = adMilitary then 1083 1218 begin 1084 DraftDlg.ShowNewContent(wmModal);1085 if DraftDlg.ModalResult <> mrOK then1086 Tribe[ me].ModelPicture[MyRO.nModel].HGr := nil1087 end; 1088 until (ChosenResearch <> adMilitary) or ( DraftDlg.ModalResult = mrOK);1219 MainScreen.DraftDlg.ShowNewContent(wmModal); 1220 if MainScreen.DraftDlg.ModalResult <> mrOK then 1221 Tribe[Me].ModelPicture[MyRO.nModel].HGr := nil; 1222 end; 1223 until (ChosenResearch <> adMilitary) or (MainScreen.DraftDlg.ModalResult = mrOK); 1089 1224 1090 1225 if ChosenResearch = adMilitary then 1091 InitMyModel(MyRO.nModel, true)1226 InitMyModel(MyRO.nModel, True) 1092 1227 else if ChosenResearch = adFar then 1093 1228 begin 1094 M odalSelectDlg.ShowNewContent(wmModal, kFarAdvance);1095 if M odalSelectDlg.result >= 0 then1096 if (M odalSelectDlg.result = adNone) or1097 (Server(sSetResearch - sExecute, me, ModalSelectDlg.result, nil^) <1229 MainScreen.ModalSelectDlg.ShowNewContent(wmModal, kFarAdvance); 1230 if MainScreen.ModalSelectDlg.Result >= 0 then 1231 if (MainScreen.ModalSelectDlg.Result = adNone) or 1232 (Server(sSetResearch - sExecute, Me, MainScreen.ModalSelectDlg.Result, nil^) < 1098 1233 rExecuted) then 1099 MyData.FarTech := M odalSelectDlg.result1234 MyData.FarTech := MainScreen.ModalSelectDlg.Result 1100 1235 else 1101 1236 begin 1102 ChosenResearch := M odalSelectDlg.result;1237 ChosenResearch := MainScreen.ModalSelectDlg.Result; 1103 1238 // can be researched immediately 1104 MyData.FarTech := adNone 1239 MyData.FarTech := adNone; 1105 1240 end; 1106 1241 end; … … 1109 1244 MyData.FarTech := adNexus 1110 1245 else 1111 Server(sSetResearch, me, ChosenResearch, nil^); 1112 ListDlg.TechChange; 1113 result := true; 1246 Server(sSetResearch, Me, ChosenResearch, nil^); 1247 MainScreen.ListDlg.TechChange; 1248 Result := True; 1249 end; 1250 1251 procedure ApplyToVisibleForms(FormAction: TFormAction); 1252 var 1253 I: Integer; 1254 Form: TDpiForm; 1255 begin 1256 for I := 0 to DpiScreen.FormCount - 1 do begin 1257 Form := DpiScreen.Forms[I]; 1258 if Form.Visible and (Form is TBufferedDrawDlg) then begin 1259 case FormAction of 1260 faClose: Form.Close; 1261 faEnable: Form.Enabled := True; 1262 faDisable: Form.Enabled := False; 1263 faUpdate: begin 1264 if @Form.OnShow <> nil then Form.OnShow(nil); 1265 Form.Invalidate; 1266 Form.Update; 1267 end; 1268 faSmartUpdateContent: TBufferedDrawDlg(Form).SmartUpdateContent(False); 1269 end; 1270 end; 1271 end; 1114 1272 end; 1115 1273 1116 1274 (* ** client function handling ** *) 1117 1275 1118 function TMainScreen.DipCall(Command: integer): integer;1276 function TMainScreen.DipCall(Command: Integer): Integer; 1119 1277 var 1120 i: integer;1121 IsTreatyDeal: boolean;1122 begin 1123 result := Server(Command, me, 0, nil^);1124 if result >= rExecuted then1278 I: Integer; 1279 IsTreatyDeal: Boolean; 1280 begin 1281 Result := Server(Command, Me, 0, nil^); 1282 if Result >= rExecuted then 1125 1283 begin 1126 1284 if Command and $FF0F = scContact then 1127 1285 begin 1128 DipMem[ me].pContact := Command shr 4 and $F;1286 DipMem[Me].pContact := Command shr 4 and $F; 1129 1287 NegoDlg.Initiate; 1130 DipMem[ me].DeliveredPrices := [];1131 DipMem[ me].ReceivedPrices := [];1132 end; 1133 1134 DipMem[ me].SentCommand := Command;1135 DipMem[ me].FormerTreaty := MyRO.Treaty[DipMem[me].pContact];1288 DipMem[Me].DeliveredPrices := []; 1289 DipMem[Me].ReceivedPrices := []; 1290 end; 1291 1292 DipMem[Me].SentCommand := Command; 1293 DipMem[Me].FormerTreaty := MyRO.Treaty[DipMem[Me].pContact]; 1136 1294 if Command = scDipCancelTreaty then 1137 1295 Play('CANCELTREATY') 1138 1296 else if Command = scDipAccept then 1139 1297 begin // remember delivered and received prices 1140 for i:= 0 to ReceivedOffer.nDeliver - 1 do1141 include(DipMem[me].ReceivedPrices, ReceivedOffer.Price[i] shr 24);1142 for i:= 0 to ReceivedOffer.nCost - 1 do1143 include(DipMem[me].DeliveredPrices,1144 ReceivedOffer.Price[ReceivedOffer.nDeliver + i] shr 24);1145 IsTreatyDeal := false;1146 for i:= 0 to ReceivedOffer.nDeliver + ReceivedOffer.nCost - 1 do1147 if ReceivedOffer.Price[ i] and opMask = opTreaty then1148 IsTreatyDeal := true;1298 for I := 0 to ReceivedOffer.nDeliver - 1 do 1299 Include(DipMem[Me].ReceivedPrices, ReceivedOffer.Price[I] shr 24); 1300 for I := 0 to ReceivedOffer.nCost - 1 do 1301 Include(DipMem[Me].DeliveredPrices, 1302 ReceivedOffer.Price[ReceivedOffer.nDeliver + I] shr 24); 1303 IsTreatyDeal := False; 1304 for I := 0 to ReceivedOffer.nDeliver + ReceivedOffer.nCost - 1 do 1305 if ReceivedOffer.Price[I] and opMask = opTreaty then 1306 IsTreatyDeal := True; 1149 1307 if IsTreatyDeal then 1150 1308 Play('NEWTREATY') … … 1153 1311 end; 1154 1312 CityDlg.CloseAction := None; 1155 if G.RO[DipMem[ me].pContact] <> nil then1313 if G.RO[DipMem[Me].pContact] <> nil then 1156 1314 begin // close windows for next player 1157 for i := 0 to DpiScreen.FormCount - 1 do 1158 if DpiScreen.Forms[i].Visible and (DpiScreen.Forms[i] is TBufferedDrawDlg) 1159 then 1160 DpiScreen.Forms[i].Close; 1315 ApplyToVisibleForms(faClose); 1161 1316 end 1162 1317 else … … 1170 1325 end; 1171 1326 1172 function TMainScreen.OfferCall(var Offer: TOffer): integer; 1173 var 1174 i: integer; 1175 begin 1176 result := Server(scDipOffer, me, 0, Offer); 1177 if result >= rExecuted then 1178 begin 1179 DipMem[me].SentCommand := scDipOffer; 1180 DipMem[me].FormerTreaty := MyRO.Treaty[DipMem[me].pContact]; 1181 DipMem[me].SentOffer := Offer; 1327 function TMainScreen.OfferCall(var Offer: TOffer): Integer; 1328 begin 1329 Result := Server(scDipOffer, Me, 0, Offer); 1330 if Result >= rExecuted then 1331 begin 1332 DipMem[Me].SentCommand := scDipOffer; 1333 DipMem[Me].FormerTreaty := MyRO.Treaty[DipMem[Me].pContact]; 1334 DipMem[Me].SentOffer := Offer; 1182 1335 CityDlg.CloseAction := None; 1183 if G.RO[DipMem[ me].pContact] <> nil then1336 if G.RO[DipMem[Me].pContact] <> nil then 1184 1337 begin // close windows for next player 1185 for i := 0 to DpiScreen.FormCount - 1 do 1186 if DpiScreen.Forms[i].Visible and (DpiScreen.Forms[i] is TBufferedDrawDlg) 1187 then 1188 DpiScreen.Forms[i].Close; 1338 ApplyToVisibleForms(faClose); 1189 1339 end 1190 1340 else … … 1198 1348 end; 1199 1349 1200 procedure TMainScreen.SetUnFocus(uix: integer);1350 procedure TMainScreen.SetUnFocus(uix: Integer); 1201 1351 var 1202 Loc0: integer;1203 begin 1204 assert(not((uix >= 0) and supervising));1352 Loc0: Integer; 1353 begin 1354 Assert(not((uix >= 0) and Supervising)); 1205 1355 if uix <> UnFocus then 1206 1356 begin 1207 DestinationMarkON := false;1357 DestinationMarkON := False; 1208 1358 PaintDestination; 1209 1359 if uix >= 0 then 1210 1360 UnStartLoc := MyUn[uix].Loc; 1211 BlinkON := false;1361 BlinkON := False; 1212 1362 BlinkTime := -1; 1213 1363 if UnFocus >= 0 then … … 1229 1379 procedure TMainScreen.CheckTerrainBtnVisible; 1230 1380 var 1231 Tile: integer;1381 Tile: Integer; 1232 1382 mox: ^TModel; 1233 1383 begin … … 1241 1391 end 1242 1392 else 1243 TerrainBtn.Visible := false;1393 TerrainBtn.Visible := False; 1244 1394 end; 1245 1395 … … 1249 1399 begin 1250 1400 MovieSpeed1Btn.Down := MovieSpeed = 1; 1251 MovieSpeed1Btn.Visible := true;1401 MovieSpeed1Btn.Visible := True; 1252 1402 MovieSpeed2Btn.Down := MovieSpeed = 2; 1253 MovieSpeed2Btn.Visible := true;1403 MovieSpeed2Btn.Visible := True; 1254 1404 MovieSpeed3Btn.Down := MovieSpeed = 3; 1255 MovieSpeed3Btn.Visible := true;1405 MovieSpeed3Btn.Visible := True; 1256 1406 MovieSpeed4Btn.Down := MovieSpeed = 4; 1257 MovieSpeed4Btn.Visible := true;1407 MovieSpeed4Btn.Visible := True; 1258 1408 end 1259 1409 else 1260 1410 begin 1261 MovieSpeed1Btn.Visible := false;1262 MovieSpeed2Btn.Visible := false;1263 MovieSpeed3Btn.Visible := false;1264 MovieSpeed4Btn.Visible := false;1411 MovieSpeed1Btn.Visible := False; 1412 MovieSpeed2Btn.Visible := False; 1413 MovieSpeed3Btn.Visible := False; 1414 MovieSpeed4Btn.Visible := False; 1265 1415 end; 1266 1416 end; … … 1276 1426 end; 1277 1427 1278 procedure TMainScreen.UpdateViews(UpdateCityScreen: boolean);1428 procedure TMainScreen.UpdateViews(UpdateCityScreen: Boolean); 1279 1429 begin 1280 1430 SumCities(TaxSum, ScienceSum); … … 1286 1436 end; 1287 1437 1288 procedure TMainScreen.SetAIName( p: integer; Name: string);1438 procedure TMainScreen.SetAIName(P: Integer; Name: string); 1289 1439 begin 1290 1440 if Name = '' then 1291 1441 begin 1292 if AILogo[ p] <> nil then1442 if AILogo[P] <> nil then 1293 1443 begin 1294 FreeAndNil(AILogo[ p]);1444 FreeAndNil(AILogo[P]); 1295 1445 end; 1296 1446 end 1297 1447 else 1298 1448 begin 1299 if AILogo[ p] = nil then1300 AILogo[ p] := TDpiBitmap.Create;1301 if not LoadGraphicFile(AILogo[ p], HomeDir + Name + '.png', [gfNoError]) then1449 if AILogo[P] = nil then 1450 AILogo[P] := TDpiBitmap.Create; 1451 if not LoadGraphicFile(AILogo[P], HomeDir + Name + '.png', [gfNoError]) then 1302 1452 begin 1303 FreeAndNil(AILogo[ p]);1304 end; 1305 end; 1306 end; 1307 1308 function TMainScreen.ContactRefused( p: integer; Item: String): boolean;1453 FreeAndNil(AILogo[P]); 1454 end; 1455 end; 1456 end; 1457 1458 function TMainScreen.ContactRefused(P: Integer; Item: String): Boolean; 1309 1459 // return whether treaty was cancelled 1310 1460 var 1311 s: string;1312 begin 1313 assert(MyRO.Treaty[p] >= trPeace);1314 s := Tribe[p].TPhrase(Item);1315 if MyRO.Turn < MyRO.LastCancelTreaty[ p] + CancelTreatyTurns then1316 begin 1317 SimpleMessage( s);1318 result := false;1461 S: string; 1462 begin 1463 Assert(MyRO.Treaty[P] >= trPeace); 1464 S := Tribe[P].TPhrase(Item); 1465 if MyRO.Turn < MyRO.LastCancelTreaty[P] + CancelTreatyTurns then 1466 begin 1467 SimpleMessage(S); 1468 Result := False; 1319 1469 end 1320 1470 else 1321 1471 begin 1322 case MyRO.Treaty[ p] of1472 case MyRO.Treaty[P] of 1323 1473 trPeace: 1324 s := s+ ' ' + Phrases.Lookup('FRCANCELQUERY_PEACE');1474 S := S + ' ' + Phrases.Lookup('FRCANCELQUERY_PEACE'); 1325 1475 trFriendlyContact: 1326 s := s+ ' ' + Phrases.Lookup('FRCANCELQUERY_FRIENDLY');1476 S := S + ' ' + Phrases.Lookup('FRCANCELQUERY_FRIENDLY'); 1327 1477 trAlliance: 1328 s := s+ ' ' + Phrases.Lookup('FRCANCELQUERY_ALLIANCE');1329 end; 1330 result := SimpleQuery(mkYesNo, s, 'NEGO_REJECTED') = mrOK;1331 if result then1478 S := S + ' ' + Phrases.Lookup('FRCANCELQUERY_ALLIANCE'); 1479 end; 1480 Result := SimpleQuery(mkYesNo, S, 'NEGO_REJECTED') = mrOK; 1481 if Result then 1332 1482 begin 1333 1483 Play('CANCELTREATY'); 1334 Server(sCancelTreaty, me, 0, nil^);1335 if MyRO.Treaty[ p] = trNone then1484 Server(sCancelTreaty, Me, 0, nil^); 1485 if MyRO.Treaty[P] = trNone then 1336 1486 CityOptimizer_BeginOfTurn; 1337 1487 // peace treaty was cancelled -- use formerly forbidden tiles 1338 MapValid := false;1488 MapValid := False; 1339 1489 PaintAllMaps; 1340 1490 end; … … 1344 1494 procedure TMainScreen.RememberPeaceViolation; 1345 1495 var 1346 uix, p1: integer;1496 uix, p1: Integer; 1347 1497 begin 1348 1498 MyData.PeaceEvaHappened := 0; … … 1352 1502 begin 1353 1503 p1 := MyRO.Territory[Loc]; 1354 if (p1 <> me) and (p1 >= 0) and1504 if (p1 <> Me) and (p1 >= 0) and 1355 1505 (MyRO.Turn = MyRO.EvaStart[p1] + (PeaceEvaTurns - 1)) then 1356 1506 MyData.PeaceEvaHappened := MyData.PeaceEvaHappened or (1 shl p1); … … 1390 1540 1391 1541 var 1392 i, cix, mix: integer;1393 need: boolean;1542 I, cix, mix: Integer; 1543 need: Boolean; 1394 1544 mi: TModelInfo; 1395 1545 begin 1396 1546 if (sbStart in Check) and not (sbStart in SoundPreloadDone) then begin 1397 for i:= 0 to nStartBlock - 1 do1398 PreparePlay(StartBlock[ i]);1547 for I := 0 to nStartBlock - 1 do 1548 PreparePlay(StartBlock[I]); 1399 1549 SoundPreloadDone := SoundPreloadDone + [sbStart]; 1400 1550 end; 1401 1551 if (sbWonder in Check) and not (sbWonder in SoundPreloadDone) then begin 1402 need := false;1403 for i:= 0 to nWonder - 1 do1404 if MyRO.Wonder[ i].CityID <> WonderNotBuiltYet then1405 need := true;1552 need := False; 1553 for I := 0 to nWonder - 1 do 1554 if MyRO.Wonder[I].CityID <> WonderNotBuiltYet then 1555 need := True; 1406 1556 if need then begin 1407 for i:= 0 to nWonderBlock - 1 do1408 PreparePlay(WonderBlock[ i]);1557 for I := 0 to nWonderBlock - 1 do 1558 PreparePlay(WonderBlock[I]); 1409 1559 SoundPreloadDone := SoundPreloadDone + [sbWonder]; 1410 1560 end; … … 1412 1562 if ((sbScience in Check) and not (sbScience in SoundPreloadDone)) and 1413 1563 (MyRO.Tech[adScience] >= tsApplicable) then begin 1414 for i:= 0 to nScienceBlock - 1 do1415 PreparePlay(ScienceBlock[ i]);1564 for I := 0 to nScienceBlock - 1 do 1565 PreparePlay(ScienceBlock[I]); 1416 1566 SoundPreloadDone := SoundPreloadDone + [sbScience]; 1417 1567 end; 1418 1568 if ((sbContact in Check) and not (sbContact in SoundPreloadDone)) and 1419 1569 (MyRO.nEnemyModel + MyRO.nEnemyCity > 0) then begin 1420 for i:= 0 to nContactBlock - 1 do1421 PreparePlay(ContactBlock[ i]);1570 for I := 0 to nContactBlock - 1 do 1571 PreparePlay(ContactBlock[I]); 1422 1572 SoundPreloadDone := SoundPreloadDone + [sbContact]; 1423 1573 end; … … 1430 1580 with MyCity[cix] do 1431 1581 if (Loc >= 0) and (Flags and CityRepMask <> 0) then 1432 for i:= 0 to 12 do1433 if 1 shl iand Flags and CityRepMask <> 0 then1434 PreparePlay(CityEventSoundItem[ i]);1582 for I := 0 to 12 do 1583 if 1 shl I and Flags and CityRepMask <> 0 then 1584 PreparePlay(CityEventSoundItem[I]); 1435 1585 for mix := 0 to MyRO.nModel - 1 do 1436 1586 with MyModel[mix] do 1437 1587 if Attack > 0 then 1438 1588 begin 1439 MakeModelInfo( me, mix, MyModel[mix], mi);1589 MakeModelInfo(Me, mix, MyModel[mix], mi); 1440 1590 PreparePlay(AttackSound(ModelCode(mi))); 1441 1591 end; … … 1448 1598 Color: TColor; 1449 1599 Name: string; 1450 ok: boolean;1600 ok: Boolean; 1451 1601 begin 1452 1602 UnusedTribeFiles.Clear; … … 1468 1618 end; 1469 1619 1470 function TMainScreen.ChooseUnusedTribe: integer; 1620 function TMainScreen.GetUnitStatDlg: TUnitStatDlg; 1621 begin 1622 if not Assigned(FUnitStatDlg) then begin 1623 FUnitStatDlg := TUnitStatDlg.Create(nil); 1624 ArrangeDialog(FUnitStatDlg); 1625 FUnitStatDlg.CheckAge; 1626 end; 1627 Result := FUnitStatDlg; 1628 end; 1629 1630 function TMainScreen.GetWondersDlg: TWondersDlg; 1631 begin 1632 if not Assigned(FWondersDlg) then FWondersDlg := TWondersDlg.Create(nil); 1633 Result := FWondersDlg; 1634 end; 1635 1636 function TMainScreen.ChooseUnusedTribe: Integer; 1471 1637 var 1472 i: Integer;1473 j: Integer;1638 I: Integer; 1639 J: Integer; 1474 1640 ColorDistance: Integer; 1475 1641 BestColorDistance: Integer; … … 1477 1643 CountBest: Integer; 1478 1644 begin 1479 assert(UnusedTribeFiles.Count > 0);1480 result := -1;1645 Assert(UnusedTribeFiles.Count > 0); 1646 Result := -1; 1481 1647 BestColorDistance := -1; 1482 for j:= 0 to UnusedTribeFiles.Count - 1 do1648 for J := 0 to UnusedTribeFiles.Count - 1 do 1483 1649 begin 1484 1650 ColorDistance := 250; // consider differences more than this infinite 1485 for i:= 0 to nPl - 1 do1486 if Tribe[ i] <> nil then1651 for I := 0 to nPl - 1 do 1652 if Tribe[I] <> nil then 1487 1653 begin 1488 TestColorDistance := abs( integer(UnusedTribeFiles.Objects[j])1489 shr 16 and $FF - Tribe[ i].Color shr 16 and $FF) +1490 abs( integer(UnusedTribeFiles.Objects[j]) shr 8 and1491 $FF - Tribe[ i].Color shr 8 and $FF) * 3 +1492 abs( integer(UnusedTribeFiles.Objects[j]) and1493 $FF - Tribe[ i].Color and $FF) * 2;1654 TestColorDistance := abs(Integer(UnusedTribeFiles.Objects[J]) 1655 shr 16 and $FF - Tribe[I].Color shr 16 and $FF) + 1656 abs(Integer(UnusedTribeFiles.Objects[J]) shr 8 and 1657 $FF - Tribe[I].Color shr 8 and $FF) * 3 + 1658 abs(Integer(UnusedTribeFiles.Objects[J]) and 1659 $FF - Tribe[I].Color and $FF) * 2; 1494 1660 if TestColorDistance < ColorDistance then 1495 1661 ColorDistance := TestColorDistance; … … 1502 1668 if ColorDistance = BestColorDistance then 1503 1669 begin 1504 inc(CountBest);1670 Inc(CountBest); 1505 1671 if DelphiRandom(CountBest) = 0 then 1506 result := j;1672 Result := J; 1507 1673 end; 1508 1674 end; … … 1511 1677 procedure TMainScreen.ShowEnemyShipChange(ShowShipChange: TShowShipChange); 1512 1678 var 1513 i, TestCost, MostCost: integer;1514 Ship1Plus, Ship2Plus: boolean;1679 I, TestCost, MostCost: Integer; 1680 Ship1Plus, Ship2Plus: Boolean; 1515 1681 begin 1516 1682 with ShowShipChange, MessgExDlg do … … 1535 1701 begin 1536 1702 OpenSound := 'SHIP_TRADED'; 1537 Ship1Plus := false;1538 Ship2Plus := false;1539 for i:= 0 to nShipPart - 1 do1703 Ship1Plus := False; 1704 Ship2Plus := False; 1705 for I := 0 to nShipPart - 1 do 1540 1706 begin 1541 if Ship1Change[ i] > 0 then1542 Ship1Plus := true;1543 if Ship2Change[ i] > 0 then1544 Ship2Plus := true;1707 if Ship1Change[I] > 0 then 1708 Ship1Plus := True; 1709 if Ship2Change[I] > 0 then 1710 Ship2Plus := True; 1545 1711 end; 1546 1712 if Ship1Plus and Ship2Plus then … … 1569 1735 begin 1570 1736 MostCost := 0; 1571 for i:= 0 to nShipPart - 1 do1737 for I := 0 to nShipPart - 1 do 1572 1738 begin 1573 TestCost := abs(Ship1Change[ i]) * Imp[imShipComp + i].Cost;1739 TestCost := abs(Ship1Change[I]) * Imp[imShipComp + I].Cost; 1574 1740 if TestCost > MostCost then 1575 1741 begin 1576 1742 MostCost := TestCost; 1577 IconIndex := imShipComp + i;1743 IconIndex := imShipComp + I; 1578 1744 end; 1579 1745 end; … … 1587 1753 procedure TMainScreen.InitModule; 1588 1754 var 1589 i, j, Domain: integer;1755 I, J, Domain: Integer; 1590 1756 begin 1591 1757 { search icons for advances: } 1592 for i:= 0 to nAdv - 1 do1593 if iin FutureTech then1594 AdvIcon[ i] := 96 + i- futResearchTechnology1758 for I := 0 to nAdv - 1 do 1759 if I in FutureTech then 1760 AdvIcon[I] := 96 + I - futResearchTechnology 1595 1761 else 1596 1762 begin 1597 AdvIcon[ i] := -1;1763 AdvIcon[I] := -1; 1598 1764 for Domain := 0 to nDomains - 1 do 1599 for j:= 0 to nUpgrade - 1 do1600 if upgrade[Domain, j].Preq = ithen1601 if AdvIcon[ i] >= 0 then1602 AdvIcon[ i] := 851765 for J := 0 to nUpgrade - 1 do 1766 if upgrade[Domain, J].Preq = I then 1767 if AdvIcon[I] >= 0 then 1768 AdvIcon[I] := 85 1603 1769 else 1604 AdvIcon[ i] := 86 + Domain;1605 for j:= 0 to nFeature - 1 do1606 if Feature[ j].Preq = ithen1770 AdvIcon[I] := 86 + Domain; 1771 for J := 0 to nFeature - 1 do 1772 if Feature[J].Preq = I then 1607 1773 for Domain := 0 to nDomains - 1 do 1608 if 1 shl Domain and Feature[ j].Domains <> 0 then1609 if (AdvIcon[ i] >= 0) and (AdvIcon[i] <> 86 + Domain) then1610 AdvIcon[ i] := 851774 if 1 shl Domain and Feature[J].Domains <> 0 then 1775 if (AdvIcon[I] >= 0) and (AdvIcon[I] <> 86 + Domain) then 1776 AdvIcon[I] := 85 1611 1777 else 1612 AdvIcon[ i] := 86 + Domain;1613 for j:= nWonder to nImp - 1 do1614 if Imp[ j].Preq = ithen1615 AdvIcon[ i] := j;1616 for j:= nWonder to nImp - 1 do1617 if (Imp[ j].Preq = i) and (Imp[j].Kind <> ikCommon) then1618 AdvIcon[ i] := j;1619 for j:= 0 to nJob - 1 do1620 if i = JobPreq[j] then1621 AdvIcon[ i] := 84;1622 for j:= 0 to nWonder - 1 do1623 if Imp[ j].Preq = ithen1624 AdvIcon[ i] := j;1625 if AdvIcon[ i] < 0 then1626 if AdvValue[ i] < 1000 then1627 AdvIcon[ i] := -71778 AdvIcon[I] := 86 + Domain; 1779 for J := nWonder to nImp - 1 do 1780 if Imp[J].Preq = I then 1781 AdvIcon[I] := J; 1782 for J := nWonder to nImp - 1 do 1783 if (Imp[J].Preq = I) and (Imp[J].Kind <> ikCommon) then 1784 AdvIcon[I] := J; 1785 for J := 0 to nJob - 1 do 1786 if I = JobPreq[J] then 1787 AdvIcon[I] := 84; 1788 for J := 0 to nWonder - 1 do 1789 if Imp[J].Preq = I then 1790 AdvIcon[I] := J; 1791 if AdvIcon[I] < 0 then 1792 if AdvValue[I] < 1000 then 1793 AdvIcon[I] := -7 1628 1794 else 1629 AdvIcon[ i] := 24 + AdvValue[i] div 1000;1630 for j:= 2 to nGov - 1 do1631 if GovPreq[ j] = ithen1632 AdvIcon[ i] := j- 8;1795 AdvIcon[I] := 24 + AdvValue[I] div 1000; 1796 for J := 2 to nGov - 1 do 1797 if GovPreq[J] = I then 1798 AdvIcon[I] := J - 8; 1633 1799 end; 1634 1800 AdvIcon[adConscription] := 86 + dGround; 1635 1801 1636 1802 UnusedTribeFiles := tstringlist.Create; 1637 UnusedTribeFiles.Sorted := true;1803 UnusedTribeFiles.Sorted := True; 1638 1804 TribeNames := tstringlist.Create; 1639 1805 1640 1806 IsoEngine.Init(InitEnemyModel); 1641 1807 // non-default tile size is missing a file, switch to default 1642 MainMap.SetOutput( offscreen);1808 MainMap.SetOutput(Offscreen); 1643 1809 1644 1810 HGrStdUnits := LoadGraphicSet('StdUnits.png'); … … 1647 1813 InitSmallImp; 1648 1814 SoundPreloadDone := []; 1649 StartRunning := false; 1650 StayOnTop_Ensured := false; 1815 StartRunning := False; 1651 1816 1652 1817 sb := TPVScrollbar.Create(Self); … … 1659 1824 FreeAndNil(UnusedTribeFiles); 1660 1825 FreeAndNil(TribeNames); 1661 // AdvisorDlg.DeInit; 1662 end; 1663 1664 procedure TMainScreen.InitTurn(NewPlayer: integer); 1826 end; 1827 1828 procedure TMainScreen.InitTurn(NewPlayer: Integer); 1665 1829 const 1666 1830 nAdvBookIcon = 16; 1667 1831 AdvBookIcon: array [0 .. nAdvBookIcon - 1] of record Adv, 1668 Icon: integer end = ((Adv: adPolyTheism; Icon: woZeus),1832 Icon: Integer end = ((Adv: adPolyTheism; Icon: woZeus), 1669 1833 (Adv: adBronzeWorking; Icon: woColossus), (Adv: adMapMaking; 1670 1834 Icon: woLighthouse), (Adv: adPoetry; Icon: imTheater), (Adv: adMonotheism; … … 1678 1842 sbAll = [sbStart, sbWonder, sbScience, sbContact, sbTurn]; 1679 1843 var 1680 p1, i, ad, uix, cix, MoveOptions, MoveResult, Loc1,1844 p1, I, ad, uix, cix, MoveOptions, MoveResult, Loc1, 1681 1845 NewAgeCenterTo, Winners, NewGovAvailable, dx, 1682 dy: integer;1846 dy: Integer; 1683 1847 MoveAdviceData: TMoveAdviceData; 1684 1848 Picture: TModelPictureInfo; 1685 s, Item, Item2: string;1849 S, Item, Item2: string; 1686 1850 UpdatePanel, OwnWonder, ok, Stop, ShowCityList, WondersOnly, 1687 AllowCityScreen: boolean;1688 begin 1689 if IsMultiPlayerGame and (NewPlayer <> me) then1690 begin 1691 UnitInfoBtn.Visible := false;1692 UnitBtn.Visible := false;1693 TerrainBtn.Visible := false;1694 EOT.Visible := false;1695 end; 1696 if IsMultiPlayerGame and (NewPlayer <> me) and1851 AllowCityScreen: Boolean; 1852 begin 1853 if IsMultiPlayerGame and (NewPlayer <> Me) then 1854 begin 1855 UnitInfoBtn.Visible := False; 1856 UnitBtn.Visible := False; 1857 TerrainBtn.Visible := False; 1858 EOT.Visible := False; 1859 end; 1860 if IsMultiPlayerGame and (NewPlayer <> Me) and 1697 1861 (G.RO[0].Happened and phShipComplete = 0) then 1698 1862 begin // inter player screen 1699 for i:= 0 to ControlCount - 1 do1700 if Controls[ i] is TButtonC then1701 Controls[ i].Visible := false;1702 me := -1;1863 for I := 0 to ControlCount - 1 do 1864 if Controls[I] is TButtonC then 1865 Controls[I].Visible := False; 1866 Me := -1; 1703 1867 MainTexture.Age := -1; 1704 1868 with Panel.Canvas do … … 1716 1880 Invalidate; 1717 1881 1718 s:= TurnToString(G.RO[0].Turn);1719 if supervising then1720 SimpleMessage(Format(Phrases.Lookup('SUPERTURN'), [ s]))1882 S := TurnToString(G.RO[0].Turn); 1883 if Supervising then 1884 SimpleMessage(Format(Phrases.Lookup('SUPERTURN'), [S])) 1721 1885 else 1722 SimpleMessage(Format(Tribe[NewPlayer].TPhrase('TURN'), [ s]));1723 end; 1724 for i:= 0 to ControlCount - 1 do1725 if Controls[ i] is TButtonC then1726 Controls[ i].Visible := true;1886 SimpleMessage(Format(Tribe[NewPlayer].TPhrase('TURN'), [S])); 1887 end; 1888 for I := 0 to ControlCount - 1 do 1889 if Controls[I] is TButtonC then 1890 Controls[I].Visible := True; 1727 1891 1728 1892 ItsMeAgain(NewPlayer); 1729 1893 MyData := G.RO[NewPlayer].Data; 1730 if not supervising then1894 if not Supervising then 1731 1895 SoundPreload(sbAll); 1732 if ( me = 0) and ((MyRO.Turn = 0) or (ClientMode = cResume)) then1896 if (Me = 0) and ((MyRO.Turn = 0) or (ClientMode = cResume)) then 1733 1897 Invalidate; // colorize empty space 1734 1898 1735 if not supervising then1899 if not Supervising then 1736 1900 begin 1737 1901 … … 1743 1907 else } 1744 1908 begin 1745 Age := GetAge( me);1909 Age := GetAge(Me); 1746 1910 if MainTexture.Age <> Age then begin 1747 1911 MainTexture.Age := Age; … … 1767 1931 end; 1768 1932 InitCityMark(MainTexture); 1769 CityDlg.CheckAge;1770 NatStatDlg.CheckAge;1771 UnitStatDlg.CheckAge;1772 HelpDlg.Difficulty := G.Difficulty[me];1933 if Assigned(FCityDlg) then FCityDlg.CheckAge; 1934 if Assigned(FNatStatDlg) then FNatStatDlg.CheckAge; 1935 if Assigned(FUnitStatDlg) then FUnitStatDlg.CheckAge; 1936 if Assigned(FHelpDlg) then FHelpDlg.Difficulty := G.Difficulty[Me]; 1773 1937 1774 1938 UnFocus := -1; 1775 1939 MarkCityLoc := -1; 1776 BlinkON := false;1940 BlinkON := False; 1777 1941 BlinkTime := -1; 1778 Tracking := false;1779 TurnComplete := false;1942 Tracking := False; 1943 TurnComplete := False; 1780 1944 1781 1945 if (ToldSlavery < 0) or … … 1797 1961 Hash := 0; 1798 1962 GrName := 'StdUnits.png'; 1799 Tribe[p1].SetModelPicture(Picture, true);1800 end 1801 end; 1802 1803 if not supervising and (ClientMode = cTurn) then1963 Tribe[p1].SetModelPicture(Picture, True); 1964 end; 1965 end; 1966 1967 if not Supervising and (ClientMode = cTurn) then 1804 1968 begin 1805 1969 for cix := 0 to MyRO.nCity - 1 do … … 1816 1980 if ClientMode = cMovieTurn then 1817 1981 begin 1818 UnitInfoBtn.Visible := false;1819 UnitBtn.Visible := false;1820 TerrainBtn.Visible := false;1982 UnitInfoBtn.Visible := False; 1983 UnitBtn.Visible := False; 1984 TerrainBtn.Visible := False; 1821 1985 EOT.Hint := Phrases.Lookup('BTN_STOP'); 1822 EOT.Visible := true;1986 EOT.Visible := True; 1823 1987 end 1824 1988 else if ClientMode < scContact then … … 1827 1991 UnitBtn.Visible := UnFocus >= 0; 1828 1992 CheckTerrainBtnVisible; 1829 TurnComplete := supervising;1993 TurnComplete := Supervising; 1830 1994 EOT.Hint := Phrases.Lookup('BTN_ENDTURN'); 1831 EOT.Visible := Server(sTurn - sExecute, me, 0, nil^) >= rExecuted;1995 EOT.Visible := Server(sTurn - sExecute, Me, 0, nil^) >= rExecuted; 1832 1996 end 1833 1997 else 1834 1998 begin 1835 UnitInfoBtn.Visible := false;1836 UnitBtn.Visible := false;1837 TerrainBtn.Visible := false;1999 UnitInfoBtn.Visible := False; 2000 UnitBtn.Visible := False; 2001 TerrainBtn.Visible := False; 1838 2002 EOT.Hint := Phrases.Lookup('BTN_NEGO'); 1839 EOT.Visible := true;2003 EOT.Visible := True; 1840 2004 end; 1841 2005 SetTroopLoc(-1); 1842 MapValid := false;2006 MapValid := False; 1843 2007 NewAgeCenterTo := 0; 1844 if ((MyRO.Turn = 0) and not supervising or IsMultiPlayerGame or2008 if ((MyRO.Turn = 0) and not Supervising or IsMultiPlayerGame or 1845 2009 (ClientMode = cResume)) and (MyRO.nCity > 0) then 1846 2010 begin … … 1857 2021 begin 1858 2022 NewAgeCenterTo := -1; 1859 Loc1 := dLoc(Loc1, -dx, -dy) 2023 Loc1 := dLoc(Loc1, -dx, -dy); 1860 2024 end 1861 2025 else … … 1865 2029 end 1866 2030 end; 1867 Centre(Loc1) 1868 end; 1869 1870 for i := 0 to DpiScreen.FormCount - 1 do 1871 if DpiScreen.Forms[i] is TBufferedDrawDlg then 1872 DpiScreen.Forms[i].Enabled := true; 2031 Centre(Loc1); 2032 end; 2033 2034 ApplyToVisibleForms(faEnable); 1873 2035 1874 2036 if ClientMode <> cResume then … … 1881 2043 // first turn after anarchy -- don't show despotism palace! 1882 2044 Update; 1883 for i := 0 to DpiScreen.FormCount - 1 do 1884 if (DpiScreen.Forms[i].Visible) and (DpiScreen.Forms[i] is TBufferedDrawDlg) 1885 then 1886 begin 1887 if @DpiScreen.Forms[i].OnShow <> nil then 1888 DpiScreen.Forms[i].OnShow(nil); 1889 DpiScreen.Forms[i].Invalidate; 1890 DpiScreen.Forms[i].Update; 1891 end; 2045 ApplyToVisibleForms(faUpdate); 1892 2046 1893 2047 if MyRO.Happened and phGameEnd <> 0 then … … 1897 2051 begin 1898 2052 OpenSound := 'MSG_GAMEOVER'; 1899 MessgText := Tribe[ me].TPhrase('GAMEOVER');2053 MessgText := Tribe[Me].TPhrase('GAMEOVER'); 1900 2054 IconKind := mikBigIcon; 1901 2055 IconIndex := 8; … … 1908 2062 begin 1909 2063 Winners := Winners or 1 shl p1; 1910 for i:= 0 to nShipPart - 1 do1911 if MyRO.Ship[p1].Parts[ i] < ShipNeed[i] then2064 for I := 0 to nShipPart - 1 do 2065 if MyRO.Ship[p1].Parts[I] < ShipNeed[I] then 1912 2066 Winners := Winners and not(1 shl p1); 1913 2067 end; 1914 assert(Winners <> 0);1915 if Winners and (1 shl me) <> 0 then2068 Assert(Winners <> 0); 2069 if Winners and (1 shl Me) <> 0 then 1916 2070 begin 1917 s:= '';2071 S := ''; 1918 2072 for p1 := 0 to nPl - 1 do 1919 if (p1 <> me) and (1 shl p1 and Winners <> 0) then1920 if s= '' then1921 s:= Tribe[p1].TPhrase('SHORTNAME')2073 if (p1 <> Me) and (1 shl p1 and Winners <> 0) then 2074 if S = '' then 2075 S := Tribe[p1].TPhrase('SHORTNAME') 1922 2076 else 1923 s:= Format(Phrases.Lookup('SHAREDWIN_CONCAT'),1924 [ s, Tribe[p1].TPhrase('SHORTNAME')]);2077 S := Format(Phrases.Lookup('SHAREDWIN_CONCAT'), 2078 [S, Tribe[p1].TPhrase('SHORTNAME')]); 1925 2079 1926 2080 OpenSound := 'MSG_YOUWIN'; 1927 MessgText := Tribe[ me].TPhrase('MYSPACESHIP');1928 if s<> '' then2081 MessgText := Tribe[Me].TPhrase('MYSPACESHIP'); 2082 if S <> '' then 1929 2083 MessgText := MessgText + '\' + 1930 Format(Phrases.Lookup('SHAREDWIN'), [ s]);2084 Format(Phrases.Lookup('SHAREDWIN'), [S]); 1931 2085 IconKind := mikBigIcon; 1932 2086 IconIndex := 9; … … 1934 2088 else 1935 2089 begin 1936 assert(me = 0);2090 Assert(Me = 0); 1937 2091 OpenSound := 'MSG_GAMEOVER'; 1938 2092 MessgText := ''; … … 1946 2100 else { if MyRO.Happened and fTimeUp<>0 then } 1947 2101 begin 1948 assert(me = 0);2102 Assert(Me = 0); 1949 2103 OpenSound := 'MSG_GAMEOVER'; 1950 if not supervising then1951 MessgText := Tribe[ me].TPhrase('TIMEUP')2104 if not Supervising then 2105 MessgText := Tribe[Me].TPhrase('TIMEUP') 1952 2106 else 1953 2107 MessgText := Phrases.Lookup('TIMEUPSUPER'); … … 1961 2115 p1 := 0; 1962 2116 while (p1 < nPl - 1) and (Winners and (1 shl p1) = 0) do 1963 inc(p1);2117 Inc(p1); 1964 2118 if MyRO.Happened and phShipComplete = 0 then 1965 2119 DiaDlg.ShowNewContent_Charts(wmModal); 1966 2120 end; 1967 TurnComplete := true;1968 exit;1969 end; 1970 if not supervising and (1 shl me and MyRO.Alive = 0) then2121 TurnComplete := True; 2122 Exit; 2123 end; 2124 if not Supervising and (1 shl Me and MyRO.Alive = 0) then 1971 2125 begin 1972 TurnComplete := true;1973 exit;2126 TurnComplete := True; 2127 Exit; 1974 2128 end; 1975 2129 1976 2130 if (ClientMode = cContinue) and 1977 (DipMem[ me].SentCommand and $FF0F = scContact) then2131 (DipMem[Me].SentCommand and $FF0F = scContact) then 1978 2132 // contact was refused 1979 if MyRO.Treaty[DipMem[ me].pContact] >= trPeace then1980 ContactRefused(DipMem[ me].pContact, 'FRREJECTED')2133 if MyRO.Treaty[DipMem[Me].pContact] >= trPeace then 2134 ContactRefused(DipMem[Me].pContact, 'FRREJECTED') 1981 2135 else 1982 SoundMessage(Tribe[DipMem[ me].pContact].TPhrase('FRREJECTED'),2136 SoundMessage(Tribe[DipMem[Me].pContact].TPhrase('FRREJECTED'), 1983 2137 'NEGO_REJECTED'); 1984 2138 1985 if not supervising and (Age > MyData.ToldAge) and2139 if not Supervising and (Age > MyData.ToldAge) and 1986 2140 ((Age > 0) or (ClientMode <> cMovieTurn)) then 1987 2141 with MessgExDlg do … … 1991 2145 if Phrases2FallenBackToEnglish then 1992 2146 begin 1993 s := Tribe[me].TPhrase('AGE0');2147 S := Tribe[Me].TPhrase('AGE0'); 1994 2148 MessgText := 1995 Format( s, [TurnToString(MyRO.Turn), CityName(MyCity[0].ID)])2149 Format(S, [TurnToString(MyRO.Turn), CityName(MyCity[0].ID)]); 1996 2150 end 1997 2151 else 1998 2152 begin 1999 s := Tribe[me].TString(Phrases2.Lookup('AGE0'));2000 MessgText := Format( s, [TurnToString(MyRO.Turn)]);2001 end 2153 S := Tribe[Me].TString(Phrases2.Lookup('AGE0')); 2154 MessgText := Format(S, [TurnToString(MyRO.Turn)]); 2155 end; 2002 2156 end 2003 2157 else 2004 2158 begin 2005 s := Tribe[me].TPhrase('AGE' + char(48 + Age));2006 MessgText := Format( s, [TurnToString(MyRO.Turn)]);2159 S := Tribe[Me].TPhrase('AGE' + char(48 + Age)); 2160 MessgText := Format(S, [TurnToString(MyRO.Turn)]); 2007 2161 end; 2008 2162 IconKind := mikAge; … … 2012 2166 CenterTo := NewAgeCenterTo; 2013 2167 OpenSound := 'AGE_' + char(48 + Age); 2168 DpiApplication.ProcessMessages; 2014 2169 ShowModal; 2015 2170 MyData.ToldAge := Age; … … 2025 2180 begin 2026 2181 OpenSound := 'MSG_EXTINCT'; 2027 s:= Tribe[p1].TPhrase('EXTINCT');2028 MessgText := Format( s, [TurnToString(MyRO.Turn)]);2029 if MyRO.Alive = 1 shl me then2182 S := Tribe[p1].TPhrase('EXTINCT'); 2183 MessgText := Format(S, [TurnToString(MyRO.Turn)]); 2184 if MyRO.Alive = 1 shl Me then 2030 2185 MessgText := MessgText + Phrases.Lookup('EXTINCTALL'); 2031 2186 Kind := mkOk; … … 2034 2189 ShowModal; 2035 2190 end; 2036 if (ClientMode <> cMovieTurn) and not supervising then2191 if (ClientMode <> cMovieTurn) and not Supervising then 2037 2192 DiaDlg.ShowNewContent_Charts(wmModal); 2038 2193 end; 2039 2194 2040 2195 // tell changes of own credibility 2041 if not supervising then2196 if not Supervising then 2042 2197 begin 2043 2198 if RoughCredibility(MyRO.Credibility) <> … … 2046 2201 if RoughCredibility(MyRO.Credibility) > 2047 2202 RoughCredibility(MyData.ToldOwnCredibility) then 2048 s:= Phrases.Lookup('CREDUP')2203 S := Phrases.Lookup('CREDUP') 2049 2204 else 2050 s:= Phrases.Lookup('CREDDOWN');2051 TribeMessage( me, Format(s, [Phrases.Lookup('CREDIBILITY',2205 S := Phrases.Lookup('CREDDOWN'); 2206 TribeMessage(Me, Format(S, [Phrases.Lookup('CREDIBILITY', 2052 2207 RoughCredibility(MyRO.Credibility))]), ''); 2053 2208 end; … … 2055 2210 end; 2056 2211 2057 for i:= 0 to nWonder - 1 do2212 for I := 0 to nWonder - 1 do 2058 2213 begin 2059 OwnWonder := false;2214 OwnWonder := False; 2060 2215 for cix := 0 to MyRO.nCity - 1 do 2061 if (MyCity[cix].Loc >= 0) and (MyCity[cix].ID = MyRO.Wonder[ i].CityID)2216 if (MyCity[cix].Loc >= 0) and (MyCity[cix].ID = MyRO.Wonder[I].CityID) 2062 2217 then 2063 OwnWonder := true;2064 if MyRO.Wonder[ i].CityID <> MyData.ToldWonders[i].CityID then2218 OwnWonder := True; 2219 if MyRO.Wonder[I].CityID <> MyData.ToldWonders[I].CityID then 2065 2220 begin 2066 if MyRO.Wonder[ i].CityID = WonderDestroyed then2221 if MyRO.Wonder[I].CityID = WonderDestroyed then 2067 2222 with MessgExDlg do 2068 2223 begin { tell about destroyed wonders } 2069 2224 OpenSound := 'WONDER_DESTROYED'; 2070 2225 MessgText := Format(Phrases.Lookup('WONDERDEST'), 2071 [Phrases.Lookup('IMPROVEMENTS', i)]);2226 [Phrases.Lookup('IMPROVEMENTS', I)]); 2072 2227 Kind := mkOkHelp; 2073 2228 HelpKind := hkImp; 2074 HelpNo := i;2229 HelpNo := I; 2075 2230 IconKind := mikImp; 2076 IconIndex := i;2231 IconIndex := I; 2077 2232 ShowModal; 2078 2233 end 2079 2234 else 2080 2235 begin 2081 if i= woManhattan then2082 if MyRO.Wonder[ i].EffectiveOwner > me then2236 if I = woManhattan then 2237 if MyRO.Wonder[I].EffectiveOwner > Me then 2083 2238 MyData.ColdWarStart := MyRO.Turn - 1 2084 2239 else … … 2087 2242 with MessgExDlg do 2088 2243 begin { tell about newly built wonders } 2089 if i= woManhattan then2244 if I = woManhattan then 2090 2245 begin 2091 2246 OpenSound := 'MSG_COLDWAR'; 2092 s := Tribe[MyRO.Wonder[i].EffectiveOwner].TPhrase('COLDWAR')2247 S := Tribe[MyRO.Wonder[I].EffectiveOwner].TPhrase('COLDWAR'); 2093 2248 end 2094 else if MyRO.Wonder[ i].EffectiveOwner >= 0 then2249 else if MyRO.Wonder[I].EffectiveOwner >= 0 then 2095 2250 begin 2096 2251 OpenSound := 'WONDER_BUILT'; 2097 s := Tribe[MyRO.Wonder[i].EffectiveOwner]2098 .TPhrase('WONDERBUILT') 2252 S := Tribe[MyRO.Wonder[I].EffectiveOwner] 2253 .TPhrase('WONDERBUILT'); 2099 2254 end 2100 2255 else 2101 2256 begin 2102 2257 OpenSound := 'MSG_DEFAULT'; 2103 s:= Phrases.Lookup('WONDERBUILTEXP');2258 S := Phrases.Lookup('WONDERBUILTEXP'); 2104 2259 // already expired when built 2105 2260 end; 2106 MessgText := Format( s, [Phrases.Lookup('IMPROVEMENTS', i),2107 CityName(MyRO.Wonder[ i].CityID)]);2261 MessgText := Format(S, [Phrases.Lookup('IMPROVEMENTS', I), 2262 CityName(MyRO.Wonder[I].CityID)]); 2108 2263 Kind := mkOkHelp; 2109 2264 HelpKind := hkImp; 2110 HelpNo := i;2265 HelpNo := I; 2111 2266 IconKind := mikImp; 2112 IconIndex := i;2267 IconIndex := I; 2113 2268 ShowModal; 2114 end 2115 end 2269 end; 2270 end; 2116 2271 end 2117 else if (MyRO.Wonder[ i].EffectiveOwner <> MyData.ToldWonders[i]2118 .EffectiveOwner) and (MyRO.Wonder[ i].CityID > WonderDestroyed) then2119 if MyRO.Wonder[ i].EffectiveOwner < 0 then2272 else if (MyRO.Wonder[I].EffectiveOwner <> MyData.ToldWonders[I] 2273 .EffectiveOwner) and (MyRO.Wonder[I].CityID > WonderDestroyed) then 2274 if MyRO.Wonder[I].EffectiveOwner < 0 then 2120 2275 begin 2121 if i<> woMIR then2276 if I <> woMIR then 2122 2277 with MessgExDlg do 2123 2278 begin { tell about expired wonders } 2124 2279 OpenSound := 'WONDER_EXPIRED'; 2125 2280 MessgText := Format(Phrases.Lookup('WONDEREXP'), 2126 [Phrases.Lookup('IMPROVEMENTS', i),2127 CityName(MyRO.Wonder[ i].CityID)]);2281 [Phrases.Lookup('IMPROVEMENTS', I), 2282 CityName(MyRO.Wonder[I].CityID)]); 2128 2283 Kind := mkOkHelp; 2129 2284 HelpKind := hkImp; 2130 HelpNo := i;2285 HelpNo := I; 2131 2286 IconKind := mikImp; 2132 IconIndex := i;2287 IconIndex := I; 2133 2288 ShowModal; 2134 end 2289 end; 2135 2290 end 2136 else if (MyData.ToldWonders[ i].EffectiveOwner >= 0) and not OwnWonder2291 else if (MyData.ToldWonders[I].EffectiveOwner >= 0) and not OwnWonder 2137 2292 then 2138 2293 with MessgExDlg do 2139 2294 begin { tell about capture of wonders } 2140 2295 OpenSound := 'WONDER_CAPTURED'; 2141 s := Tribe[MyRO.Wonder[i].EffectiveOwner].TPhrase('WONDERCAPT');2142 MessgText := Format( s, [Phrases.Lookup('IMPROVEMENTS', i),2143 CityName(MyRO.Wonder[ i].CityID)]);2296 S := Tribe[MyRO.Wonder[I].EffectiveOwner].TPhrase('WONDERCAPT'); 2297 MessgText := Format(S, [Phrases.Lookup('IMPROVEMENTS', I), 2298 CityName(MyRO.Wonder[I].CityID)]); 2144 2299 Kind := mkOkHelp; 2145 2300 HelpKind := hkImp; 2146 HelpNo := i;2301 HelpNo := I; 2147 2302 IconKind := mikImp; 2148 IconIndex := i;2303 IconIndex := I; 2149 2304 ShowModal; 2150 2305 end; … … 2154 2309 begin 2155 2310 SoundMessageEx(Phrases.Lookup('COLDWAREND'), 'MSG_DEFAULT'); 2156 MyData.ColdWarStart := -ColdWarTurns - 1 2311 MyData.ColdWarStart := -ColdWarTurns - 1; 2157 2312 end; 2158 2313 … … 2160 2315 end; // ClientMode<>cResume 2161 2316 MyData.ToldAlive := MyRO.Alive; 2162 move(MyRO.Wonder, MyData.ToldWonders, SizeOf(MyData.ToldWonders));2317 Move(MyRO.Wonder, MyData.ToldWonders, SizeOf(MyData.ToldWonders)); 2163 2318 2164 2319 NewGovAvailable := -1; … … 2184 2339 IconKind := mikBook; 2185 2340 IconIndex := -1; 2186 for i:= 0 to nAdvBookIcon - 1 do2187 if AdvBookIcon[ i].Adv = ad then2188 IconIndex := AdvBookIcon[ i].Icon;2341 for I := 0 to nAdvBookIcon - 1 do 2342 if AdvBookIcon[I].Adv = ad then 2343 IconIndex := AdvBookIcon[I].Icon; 2189 2344 ShowModal; 2190 2345 MyData.ToldTech[ad] := MyRO.Tech[ad]; 2191 for i:= gMonarchy to nGov - 1 do2192 if GovPreq[ i] = ad then2193 NewGovAvailable := i;2346 for I := gMonarchy to nGov - 1 do 2347 if GovPreq[I] = ad then 2348 NewGovAvailable := I; 2194 2349 end; 2195 2350 end; 2196 2351 2197 ShowCityList := false;2352 ShowCityList := False; 2198 2353 if ClientMode = cTurn then 2199 2354 begin … … 2201 2356 ChooseResearch; 2202 2357 2203 UpdatePanel := false;2358 UpdatePanel := False; 2204 2359 if MyRO.Happened and phChangeGov <> 0 then 2205 2360 begin 2206 2361 ModalSelectDlg.ShowNewContent(wmModal, kGov); 2207 2362 Play('NEWGOV'); 2208 Server(sSetGovernment, me, ModalSelectDlg.result, nil^);2363 Server(sSetGovernment, Me, ModalSelectDlg.Result, nil^); 2209 2364 CityOptimizer_BeginOfTurn; 2210 UpdatePanel := true;2365 UpdatePanel := True; 2211 2366 end; 2212 2367 end; // ClientMode=cTurn 2213 2368 2214 if not supervising and ((ClientMode = cTurn) or (ClientMode = cMovieTurn))2369 if not Supervising and ((ClientMode = cTurn) or (ClientMode = cMovieTurn)) 2215 2370 then 2216 2371 for cix := 0 to MyRO.nCity - 1 do … … 2222 2377 begin 2223 2378 // tell what happened in cities 2224 for WondersOnly := true downto false do2379 for WondersOnly := True downto False do 2225 2380 for cix := 0 to MyRO.nCity - 1 do 2226 2381 with MyCity[cix] do … … 2233 2388 begin { tell about newly built wonder } 2234 2389 OpenSound := 'WONDER_BUILT'; 2235 s := Tribe[me].TPhrase('WONDERBUILTOWN');2390 S := Tribe[Me].TPhrase('WONDERBUILTOWN'); 2236 2391 MessgText := 2237 Format( s, [Phrases.Lookup('IMPROVEMENTS',2392 Format(S, [Phrases.Lookup('IMPROVEMENTS', 2238 2393 Project0 and cpIndex), CityName(ID)]); 2239 2394 Kind := mkOkHelp; … … 2244 2399 ShowModal; 2245 2400 end; 2246 if not supervising and (ClientMode = cTurn) then2401 if not Supervising and (ClientMode = cTurn) then 2247 2402 begin 2248 AllowCityScreen := true;2403 AllowCityScreen := True; 2249 2404 if (Status and 7 <> 0) and 2250 2405 (Project and (cpImp + cpIndex) = cpImp + imTrGoods) then … … 2252 2407 begin 2253 2408 if AutoBuild(cix, MyData.ImpOrder[Status and 7 - 1]) then 2254 AllowCityScreen := false2409 AllowCityScreen := False 2255 2410 else if Flags and chProduction <> 0 then 2256 2411 Flags := (Flags and not chProduction) or chAllImpsMade … … 2280 2435 CityDlg.ShowNewContent(wmModal, MyCity[cix].Loc, 2281 2436 Flags and CityRepMask); 2282 UpdatePanel := true;2437 UpdatePanel := True; 2283 2438 end; 2284 2439 end … … 2286 2441 begin 2287 2442 if Flags and CityRepMask <> 0 then 2288 ShowCityList := true2443 ShowCityList := True; 2289 2444 end; 2290 2445 end; … … 2306 2461 begin 2307 2462 Play('REVOLUTION'); 2308 Server(sRevolution, me, 0, nil^);2463 Server(sRevolution, Me, 0, nil^); 2309 2464 end; 2310 2465 end; … … 2340 2495 DpiApplication.ProcessMessages; 2341 2496 2342 if not supervising then2497 if not Supervising then 2343 2498 for uix := 0 to MyRO.nUn - 1 do 2344 2499 with MyUn[uix] do … … 2368 2523 begin // !!! Shinkansen 2369 2524 MoveResult := eOK; 2370 ok := true;2371 for i:= 0 to MoveAdviceData.nStep - 1 do2525 ok := True; 2526 for I := 0 to MoveAdviceData.nStep - 1 do 2372 2527 begin 2373 Loc1 := dLoc(Loc, MoveAdviceData.dx[ i],2374 MoveAdviceData.dy[ i]);2528 Loc1 := dLoc(Loc, MoveAdviceData.dx[I], 2529 MoveAdviceData.dy[I]); 2375 2530 if (MyMap[Loc1] and (fCity or fOwned) = fCity) 2376 2531 // don't capture cities during auto move … … 2378 2533 // don't attack during auto move 2379 2534 begin 2380 ok := false;2535 ok := False; 2381 2536 Break 2382 2537 end … … 2385 2540 if (Loc1 = MoveAdviceData.ToLoc) or 2386 2541 (MoveAdviceData.ToLoc = maNextCity) and 2387 (MyMap[dLoc(Loc, MoveAdviceData.dx[ i],2388 MoveAdviceData.dy[ i])] and fCity <> 0) then2542 (MyMap[dLoc(Loc, MoveAdviceData.dx[I], 2543 MoveAdviceData.dy[I])] and fCity <> 0) then 2389 2544 MoveOptions := muAutoNoWait 2390 2545 else 2391 2546 MoveOptions := 0; 2392 MoveResult := MoveUnit(MoveAdviceData.dx[ i],2393 MoveAdviceData.dy[ i], MoveOptions);2547 MoveResult := MoveUnit(MoveAdviceData.dx[I], 2548 MoveAdviceData.dy[I], MoveOptions); 2394 2549 if (MoveResult < rExecuted) or (MoveResult = eEnemySpotted) 2395 2550 then 2396 2551 begin 2397 ok := false;2552 ok := False; 2398 2553 Break 2399 2554 end; … … 2407 2562 begin 2408 2563 MoveResult := eOK; 2409 Stop := true;2564 Stop := True; 2410 2565 end; 2411 2566 … … 2430 2585 end; // ClientMode=cTurn 2431 2586 2432 HaveStrategyAdvice := false; 2433 // (GameMode<>cMovie) and not supervising 2434 // and AdvisorDlg.HaveStrategyAdvice; 2435 GoOnPhase := true; 2436 if supervising or (GameMode = cMovie) then 2587 HaveStrategyAdvice := False; 2588 GoOnPhase := True; 2589 if Supervising or (GameMode = cMovie) then 2437 2590 begin 2438 2591 SetTroopLoc(-1); … … 2449 2602 SetUnFocus(-1) 2450 2603 else 2451 NextUnit(-1, false);2604 NextUnit(-1, False); 2452 2605 if UnFocus < 0 then 2453 2606 begin … … 2466 2619 end; 2467 2620 2468 procedure TMainScreen.Client(Command, NewPlayer: integer; var Data);2621 procedure TMainScreen.Client(Command, NewPlayer: Integer; var Data); 2469 2622 var 2470 i, j, p1, mix, ToLoc, AnimationSpeed, ShowMoveDomain, cix, ecix: integer;2623 I, J, p1, mix, ToLoc, AnimationSpeed, ShowMoveDomain, cix, ecix: Integer; 2471 2624 Color: TColor; 2472 Name, s: string;2625 Name, S: string; 2473 2626 TribeInfo: TTribeInfo; 2474 2627 mi: TModelInfo; 2475 SkipTurn, IsAlpine, IsTreatyDeal: boolean;2628 SkipTurn, IsAlpine, IsTreatyDeal: Boolean; 2476 2629 begin 2477 2630 case Command of 2478 2631 cTurn, cResume, cContinue, cMovieTurn, scContact, scDipStart .. scDipBreak: 2479 2632 begin 2480 supervising := G.Difficulty[NewPlayer] = 0;2633 Supervising := G.Difficulty[NewPlayer] = 0; 2481 2634 ArrangeMidPanel; 2482 2635 end … … 2484 2637 case Command of 2485 2638 cDebugMessage: 2486 LogDlg.Add(NewPlayer, G.RO[0].Turn, pchar(@Data));2639 LogDlg.Add(NewPlayer, G.RO[0].Turn, PChar(@Data)); 2487 2640 2488 2641 cShowNego: 2489 2642 with TShowNegoData(Data) do 2490 2643 begin 2491 s:= Format('P%d to P%d: ', [pSender, pTarget]);2644 S := Format('P%d to P%d: ', [pSender, pTarget]); 2492 2645 if (Action = scDipOffer) and (Offer.nDeliver + Offer.nCost > 0) then 2493 2646 begin 2494 s := s+ 'Offer ';2495 for i:= 0 to Offer.nDeliver + Offer.nCost - 1 do2647 S := S + 'Offer '; 2648 for I := 0 to Offer.nDeliver + Offer.nCost - 1 do 2496 2649 begin 2497 if i= Offer.nDeliver then2498 s := s+ ' for '2499 else if i> 0 then2500 s := s+ '+';2501 case Offer.Price[ i] and opMask of2650 if I = Offer.nDeliver then 2651 S := S + ' for ' 2652 else if I > 0 then 2653 S := S + '+'; 2654 case Offer.Price[I] and opMask of 2502 2655 opChoose: 2503 s := s+ 'Price of choice';2656 S := S + 'Price of choice'; 2504 2657 opCivilReport: 2505 s := s+ 'State report';2658 S := S + 'State report'; 2506 2659 opMilReport: 2507 s := s+ 'Military report';2660 S := S + 'Military report'; 2508 2661 opMap: 2509 s := s+ 'Map';2662 S := S + 'Map'; 2510 2663 opTreaty: 2511 s := s+ 'Treaty';2664 S := S + 'Treaty'; 2512 2665 opShipParts: 2513 s := s+ 'Ship part';2666 S := S + 'Ship part'; 2514 2667 opMoney: 2515 s := s + IntToStr(Offer.Price[i] and $FFFFFF) + 'o';2668 S := S + IntToStr(Offer.Price[I] and $FFFFFF) + 'o'; 2516 2669 opTribute: 2517 s := s + IntToStr(Offer.Price[i] and $FFFFFF) + 'o tribute';2670 S := S + IntToStr(Offer.Price[I] and $FFFFFF) + 'o tribute'; 2518 2671 opTech: 2519 s := s + Phrases.Lookup('ADVANCES', Offer.Price[i] and $FFFFFF);2672 S := S + Phrases.Lookup('ADVANCES', Offer.Price[I] and $FFFFFF); 2520 2673 opAllTech: 2521 s := s+ 'All advances';2674 S := S + 'All advances'; 2522 2675 opModel: 2523 s := s + Tribe[pSender].ModelName[Offer.Price[i] and $FFFFFF];2676 S := S + Tribe[pSender].ModelName[Offer.Price[I] and $FFFFFF]; 2524 2677 opAllModel: 2525 s := s+ 'All models';2678 S := S + 'All models'; 2526 2679 end; 2527 2680 end; 2528 LogDlg.Add(NewPlayer, G.RO[0].Turn, pchar(s));2681 LogDlg.Add(NewPlayer, G.RO[0].Turn, PChar(S)); 2529 2682 end 2530 2683 else if Action = scDipAccept then 2531 2684 begin 2532 s := s+ '--- ACCEPTED! ---';2533 LogDlg.Add(NewPlayer, G.RO[0].Turn, pchar(s));2685 S := S + '--- ACCEPTED! ---'; 2686 LogDlg.Add(NewPlayer, G.RO[0].Turn, PChar(S)); 2534 2687 end; 2535 2688 end; … … 2538 2691 begin 2539 2692 Server := TInitModuleData(Data).Server; 2540 // AdvisorDlg.Init;2541 2693 InitModule; 2542 2694 TInitModuleData(Data).DataSize := SizeOf(TPersistentData); … … 2552 2704 MainTexture.Age := -1; 2553 2705 Tribes.Init; 2554 HelpDlg.UserLeft := (DpiScreen. width - HelpDlg.width) div 2;2555 HelpDlg.UserTop := (DpiScreen. height - HelpDlg.height) div 2;2706 HelpDlg.UserLeft := (DpiScreen.Width - HelpDlg.Width) div 2; 2707 HelpDlg.UserTop := (DpiScreen.Height - HelpDlg.Height) div 2; 2556 2708 HelpDlg.Difficulty := 0; 2557 2709 if Command = cStartCredits then 2558 HelpDlg.ShowNewContent(wmModal, hkMisc, miscCredits)2710 HelpDlg.ShowNewContent(wmModal, hkMisc, Integer(miscCredits)) 2559 2711 else 2560 HelpDlg.ShowNewContent(wmModal, hkMisc, miscMain);2712 HelpDlg.ShowNewContent(wmModal, hkMisc, Integer(miscMain)); 2561 2713 Tribes.Done; 2562 2714 end; … … 2564 2716 cNewGame, cLoadGame, cMovie, cNewMap: 2565 2717 begin 2566 { if (Command=cNewGame) or (Command=cLoadGame) then2567 AdvisorDlg.NewGame(Data); }2568 2718 GenerateNames := mNames.Checked; 2569 GameOK := true;2719 GameOK := True; 2570 2720 G := TNewGameData(Data); 2571 me := -1;2721 Me := -1; 2572 2722 pLogo := -1; 2573 2723 ClientMode := -1; 2574 2724 SetMapOptions; 2575 2725 MainMap.pDebugMap := -1; 2576 idle := false;2726 Idle := False; 2577 2727 FillChar(Jump, SizeOf(Jump), 0); 2578 2728 if StartRunning then … … 2597 2747 ToldContact := 0; 2598 2748 ToldOwnCredibility := InitialCredibility; 2599 for i:= 0 to nPl - 1 do2600 if G.Difficulty[ i] > 0 then2601 inc(ToldAlive, 1 shl i);2749 for I := 0 to nPl - 1 do 2750 if G.Difficulty[I] > 0 then 2751 Inc(ToldAlive, 1 shl I); 2602 2752 PeaceEvaHappened := 0; 2603 for i:= 0 to nWonder - 1 do2604 with ToldWonders[ i] do2753 for I := 0 to nWonder - 1 do 2754 with ToldWonders[I] do 2605 2755 begin 2606 2756 CityID := -1; 2607 EffectiveOwner := -1 2757 EffectiveOwner := -1; 2608 2758 end; 2609 2759 FillChar(ToldTech, SizeOf(ToldTech), Byte(tsNA)); … … 2612 2762 end; 2613 2763 2614 // arrange dialogs 2615 ListDlg.UserLeft := 8; 2616 ListDlg.UserTop := TopBarHeight + 8; 2617 HelpDlg.UserLeft := DpiScreen.width - HelpDlg.width - 8; 2618 HelpDlg.UserTop := TopBarHeight + 8; 2619 UnitStatDlg.UserLeft := 397; 2620 UnitStatDlg.UserTop := TopBarHeight + 64; 2621 DiaDlg.UserLeft := (DpiScreen.width - DiaDlg.width) div 2; 2622 DiaDlg.UserTop := (DpiScreen.height - DiaDlg.height) div 2; 2623 NatStatDlg.UserLeft := DpiScreen.width - NatStatDlg.width - 8; 2624 NatStatDlg.UserTop := DpiScreen.height - PanelHeight - 2625 NatStatDlg.height - 8; 2626 if NatStatDlg.UserTop < 8 then 2627 NatStatDlg.UserTop := 8; 2764 ArrangeDialogs; 2628 2765 2629 2766 Age := 0; 2630 2767 MovieSpeed := 1; 2631 LogDlg.mSlot.Visible := true;2632 LogDlg.Host := self;2633 HelpDlg.ClearHistory;2634 CityDlg.Reset;2768 LogDlg.mSlot.Visible := True; 2769 LogDlg.Host := Self; 2770 if Assigned(FHelpDlg) then FHelpDlg.ClearHistory; 2771 if Assigned(FCityDlg) then FCityDlg.Reset; 2635 2772 2636 2773 MiniMap.Size := Point(G.lx, G.ly); 2637 for i:= 0 to nPl - 1 do2774 for I := 0 to nPl - 1 do 2638 2775 begin 2639 Tribe[ i] := nil;2640 TribeOriginal[ i] := false;2776 Tribe[I] := nil; 2777 TribeOriginal[I] := False; 2641 2778 end; 2642 2779 ToldSlavery := -1; 2643 RepaintOnResize := false;2644 Closable := false;2645 FirstMovieTurn := true;2780 RepaintOnResize := False; 2781 Closable := False; 2782 FirstMovieTurn := True; 2646 2783 2647 2784 MenuArea.Visible := GameMode <> cMovie; … … 2654 2791 if NewPlayer = 0 then 2655 2792 begin 2656 i:= 0;2793 I := 0; 2657 2794 for p1 := 0 to nPl - 1 do 2658 2795 if (G.Difficulty[p1] > 0) and (Tribe[p1] = nil) then 2659 inc(i);2660 if i> UnusedTribeFiles.Count then2796 Inc(I); 2797 if I > UnusedTribeFiles.Count then 2661 2798 begin 2662 GameOK := false;2799 GameOK := False; 2663 2800 SimpleMessage(Phrases.Lookup('TOOFEWTRIBES')); 2664 2801 end … … 2671 2808 TribeInfo.trix := p1; 2672 2809 TribeNames.Clear; 2673 for j:= 0 to UnusedTribeFiles.Count - 1 do2810 for J := 0 to UnusedTribeFiles.Count - 1 do 2674 2811 begin 2675 GetTribeInfo(UnusedTribeFiles[ j], Name, Color);2812 GetTribeInfo(UnusedTribeFiles[J], Name, Color); 2676 2813 TribeNames.AddObject(Name, TObject(Color)); 2677 2814 end; 2678 assert(TribeNames.Count > 0);2815 Assert(TribeNames.Count > 0); 2679 2816 ModalSelectDlg.ShowNewContent(wmModal, kTribe); 2680 2817 DpiApplication.ProcessMessages; 2681 TribeInfo.FileName := UnusedTribeFiles[ModalSelectDlg. result];2682 UnusedTribeFiles.Delete(ModalSelectDlg. result);2818 TribeInfo.FileName := UnusedTribeFiles[ModalSelectDlg.Result]; 2819 UnusedTribeFiles.Delete(ModalSelectDlg.Result); 2683 2820 2684 2821 if GameMode = cLoadGame then 2685 CreateTribe(TribeInfo.trix, TribeInfo.FileName, false)2822 CreateTribe(TribeInfo.trix, TribeInfo.FileName, False) 2686 2823 else 2687 Server( cSetTribe + (Length(TribeInfo.FileName) + 1 + 7) div 4,2824 Server(CommandWithData(cSetTribe, TribeInfo.GetCommandDataSize), 2688 2825 0, 0, TribeInfo); 2689 2826 end; … … 2693 2830 then 2694 2831 begin // autoselect enemy tribes 2695 j:= ChooseUnusedTribe;2696 TribeInfo.FileName := UnusedTribeFiles[ j];2697 UnusedTribeFiles.Delete( j);2832 J := ChooseUnusedTribe; 2833 TribeInfo.FileName := UnusedTribeFiles[J]; 2834 UnusedTribeFiles.Delete(J); 2698 2835 TribeInfo.trix := p1; 2699 2836 if GameMode = cLoadGame then 2700 CreateTribe(TribeInfo.trix, TribeInfo.FileName, false)2837 CreateTribe(TribeInfo.trix, TribeInfo.FileName, False) 2701 2838 else 2702 Server( cSetTribe + (Length(TribeInfo.FileName) + 1 + 7) div 4,2839 Server(CommandWithData(cSetTribe, TribeInfo.GetCommandDataSize), 2703 2840 0, 0, TribeInfo); 2704 2841 end; … … 2714 2851 SaveSettings; 2715 2852 CityDlg.CloseAction := None; 2716 for i := 0 to DpiScreen.FormCount - 1 do 2717 if DpiScreen.Forms[i].Visible and (DpiScreen.Forms[i] is TBufferedDrawDlg) 2718 then 2719 DpiScreen.Forms[i].Close; 2853 ApplyToVisibleForms(faClose); 2720 2854 if LogDlg.Visible then 2721 2855 LogDlg.Close; 2722 2856 LogDlg.List.Clear; 2723 StartRunning := not idle and (Jump[0] > 0); // AI called Reload2724 me := -1;2725 idle := false;2857 StartRunning := not Idle and (Jump[0] > 0); // AI called Reload 2858 Me := -1; 2859 Idle := False; 2726 2860 ClientMode := -1; 2727 UnitInfoBtn.Visible := false;2728 UnitBtn.Visible := false;2729 TerrainBtn.Visible := false;2730 MovieSpeed1Btn.Visible := false;2731 MovieSpeed2Btn.Visible := false;2732 MovieSpeed3Btn.Visible := false;2733 MovieSpeed4Btn.Visible := false;2734 EOT.Visible := false;2735 for i:= 0 to ControlCount - 1 do2736 if Controls[ i] is TButtonC then2737 Controls[ i].Visible := false;2861 UnitInfoBtn.Visible := False; 2862 UnitBtn.Visible := False; 2863 TerrainBtn.Visible := False; 2864 MovieSpeed1Btn.Visible := False; 2865 MovieSpeed2Btn.Visible := False; 2866 MovieSpeed3Btn.Visible := False; 2867 MovieSpeed4Btn.Visible := False; 2868 EOT.Visible := False; 2869 for I := 0 to ControlCount - 1 do 2870 if Controls[I] is TButtonC then 2871 Controls[I].Visible := False; 2738 2872 sb.Init(0, 1); 2739 2873 for p1 := 0 to nPl - 1 do … … 2741 2875 FreeAndNil(Tribe[p1]); 2742 2876 Tribes.Done; 2743 RepaintOnResize := false;2744 Closable := true;2877 RepaintOnResize := False; 2878 Closable := True; 2745 2879 Close; 2746 { if (GameMode=cNewGame) or (GameMode=cLoadGame) then2747 AdvisorDlg.BreakGame; }2748 2880 end; 2749 2881 … … 2765 2897 Show; 2766 2898 Update; 2767 RepaintOnResize := true;2899 RepaintOnResize := True; 2768 2900 xw := 0; 2769 2901 yw := ywcenter; 2770 if not StayOnTop_Ensured then2771 begin2772 StayOnTop_Ensured := true;2773 CityDlg.StayOnTop_Workaround;2774 CityTypeDlg.StayOnTop_Workaround;2775 DiaDlg.StayOnTop_Workaround;2776 DraftDlg.StayOnTop_Workaround;2777 EnhanceDlg.StayOnTop_Workaround;2778 HelpDlg.StayOnTop_Workaround;2779 NatStatDlg.StayOnTop_Workaround;2780 NegoDlg.StayOnTop_Workaround;2781 ModalSelectDlg.StayOnTop_Workaround;2782 ListDlg.StayOnTop_Workaround;2783 UnitStatDlg.StayOnTop_Workaround;2784 WondersDlg.StayOnTop_Workaround;2785 RatesDlg.StayOnTop_Workaround;2786 end;2787 2902 end; 2788 2903 2789 2904 cShowTurnChange: 2790 2905 begin 2791 if integer(Data) >= 0 then2906 if Integer(Data) >= 0 then 2792 2907 begin 2793 pLogo := integer(Data);2908 pLogo := Integer(Data); 2794 2909 if G.RO[pLogo] = nil then 2795 2910 begin 2796 2911 if AILogo[pLogo] <> nil then 2797 DpiBit Canvas(Canvas, (xRightPanel + 10) - (16 + 64),2912 DpiBitBltCanvas(Canvas, (xRightPanel + 10) - (16 + 64), 2798 2913 ClientHeight - PanelHeight, 64, 64, AILogo[pLogo].Canvas, 2799 2914 0, 0); 2800 end 2801 end 2915 end; 2916 end; 2802 2917 end; 2803 2918 … … 2818 2933 ItsMeAgain(p1); 2819 2934 for mix := 0 to MyRO.nModel - 1 do 2820 if not Assigned(Tribe[ me].ModelPicture[mix].HGr) then2821 InitMyModel(mix, true);2935 if not Assigned(Tribe[Me].ModelPicture[mix].HGr) then 2936 InitMyModel(mix, True); 2822 2937 end; 2823 me := -1;2938 Me := -1; 2824 2939 end; 2825 2940 … … 2830 2945 Jump[pTurn] := 0 2831 2946 else 2832 dec(Jump[pTurn]);2947 Dec(Jump[pTurn]); 2833 2948 SkipTurn := Jump[pTurn] > 0; 2834 2949 if SkipTurn then … … 2839 2954 MiniMapPaint; 2840 2955 InitAllEnemyModels; // necessary for correct replay 2841 if not EndTurn( true) then2842 SkipTurn := false;2956 if not EndTurn(True) then 2957 SkipTurn := False; 2843 2958 end; 2844 2959 if not SkipTurn then … … 2847 2962 NegoDlg.Visible then 2848 2963 NegoDlg.Close; 2849 skipped := false; // always show my moves during my turn2850 idle := true;2964 Skipped := False; // always show my moves during my turn 2965 Idle := True; 2851 2966 InitTurn(NewPlayer); 2852 DipMem[ me].pContact := -1;2853 (* if ( me=0) and (MyRO.Alive and (1 shl me)=0)} then2967 DipMem[Me].pContact := -1; 2968 (* if (Me=0) and (MyRO.Alive and (1 shl Me)=0)} then 2854 2969 begin 2855 2970 if SimpleQuery(Phrases.Lookup('RESIGN'))=mrIgnore then 2856 Server(sResign, me,0,nil^)2857 else Server(sBreak, me,0,nil^)2971 Server(sResign,Me,0,nil^) 2972 else Server(sBreak,Me,0,nil^) 2858 2973 end 2859 2974 else Play('TURNSTART'); *) … … 2866 2981 pTurn := NewPlayer; 2867 2982 pLogo := -1; 2868 skipped := false; // always show my moves during my turn2869 idle := true;2983 Skipped := False; // always show my moves during my turn 2984 Idle := True; 2870 2985 if FirstMovieTurn then 2871 2986 begin 2872 2987 CheckMovieSpeedBtnState; 2873 FirstMovieTurn := false;2988 FirstMovieTurn := False; 2874 2989 end; 2875 2990 InitTurn(NewPlayer); … … 2888 3003 pTurn := -1; 2889 3004 pLogo := -1; 2890 MapValid := false;3005 MapValid := False; 2891 3006 ClientMode := -1; 2892 idle := false;2893 skipped := false;3007 Idle := False; 3008 Skipped := False; 2894 3009 end; 2895 3010 … … 2901 3016 ItsMeAgain(0); 2902 3017 MyData := nil; 2903 UnitInfoBtn.Visible := false;2904 UnitBtn.Visible := false;2905 TerrainBtn.Visible := false;2906 MovieSpeed1Btn.Visible := false;2907 MovieSpeed2Btn.Visible := false;2908 MovieSpeed3Btn.Visible := false;2909 MovieSpeed4Btn.Visible := false;2910 EOT.Visible := false;3018 UnitInfoBtn.Visible := False; 3019 UnitBtn.Visible := False; 3020 TerrainBtn.Visible := False; 3021 MovieSpeed1Btn.Visible := False; 3022 MovieSpeed2Btn.Visible := False; 3023 MovieSpeed3Btn.Visible := False; 3024 MovieSpeed4Btn.Visible := False; 3025 EOT.Visible := False; 2911 3026 HelpDlg.Difficulty := 0; 2912 3027 BrushType := fGrass; 2913 3028 BrushLoc := -1; 2914 Edited := false;3029 Edited := False; 2915 3030 UnFocus := -1; 2916 3031 MarkCityLoc := -1; 2917 Tracking := false;2918 TurnComplete := false;2919 MapValid := false;3032 Tracking := False; 3033 TurnComplete := False; 3034 MapValid := False; 2920 3035 FormResize(nil); // calculate geometrics and paint all 2921 3036 SetTroopLoc(-1); 2922 idle := true;3037 Idle := True; 2923 3038 end; 2924 3039 … … 2930 3045 scContact: 2931 3046 begin 2932 DipMem[NewPlayer].pContact := integer(Data);3047 DipMem[NewPlayer].pContact := Integer(Data); 2933 3048 if Jump[NewPlayer] > 0 then 2934 3049 DipCall(scReject) … … 2937 3052 ClientMode := Command; 2938 3053 InitTurn(NewPlayer); 2939 MyData.ToldContact := MyData.ToldContact or (1 shl integer(Data));3054 MyData.ToldContact := MyData.ToldContact or (1 shl Integer(Data)); 2940 3055 // don't tell about new nation when already contacted by them 2941 3056 with MessgExDlg do 2942 3057 begin 2943 OpenSound := 'CONTACT_' + char(48 + MyRO.EnemyReport[ integer(Data)3058 OpenSound := 'CONTACT_' + char(48 + MyRO.EnemyReport[Integer(Data) 2944 3059 ].Attitude); 2945 MessgText := Tribe[ integer(Data)].TPhrase('FRCONTACT');3060 MessgText := Tribe[Integer(Data)].TPhrase('FRCONTACT'); 2946 3061 Kind := mkYesNo; 2947 3062 IconKind := mikTribe; 2948 IconIndex := integer(Data);3063 IconIndex := Integer(Data); 2949 3064 ShowModal; 2950 3065 if ModalResult = mrOK then 2951 3066 begin 2952 3067 NegoDlg.Respond; 2953 DipMem[ me].DeliveredPrices := [];2954 DipMem[ me].ReceivedPrices := [];3068 DipMem[Me].DeliveredPrices := []; 3069 DipMem[Me].ReceivedPrices := []; 2955 3070 DipCall(scDipStart); 2956 3071 end … … 2980 3095 else if Command = scDipAccept then 2981 3096 begin // remember delivered and received prices 2982 for i := 0 to DipMem[me].SentOffer.nDeliver - 1 do2983 include(DipMem[me].DeliveredPrices,2984 DipMem[ me].SentOffer.Price[i] shr 24);2985 for i := 0 to DipMem[me].SentOffer.nCost - 1 do2986 include(DipMem[me].ReceivedPrices,2987 DipMem[ me].SentOffer.Price[DipMem[me].SentOffer.nDeliver +2988 i] shr 24);2989 IsTreatyDeal := false;2990 for i:= 0 to ReceivedOffer.nDeliver + ReceivedOffer.nCost - 1 do2991 if DipMem[ me].SentOffer.Price[i] and opMask = opTreaty then2992 IsTreatyDeal := true;3097 for I := 0 to DipMem[Me].SentOffer.nDeliver - 1 do 3098 Include(DipMem[Me].DeliveredPrices, 3099 DipMem[Me].SentOffer.Price[I] shr 24); 3100 for I := 0 to DipMem[Me].SentOffer.nCost - 1 do 3101 Include(DipMem[Me].ReceivedPrices, 3102 DipMem[Me].SentOffer.Price[DipMem[Me].SentOffer.nDeliver + 3103 I] shr 24); 3104 IsTreatyDeal := False; 3105 for I := 0 to ReceivedOffer.nDeliver + ReceivedOffer.nCost - 1 do 3106 if DipMem[Me].SentOffer.Price[I] and opMask = opTreaty then 3107 IsTreatyDeal := True; 2993 3108 if IsTreatyDeal then 2994 3109 Play('NEWTREATY') … … 2997 3112 end; 2998 3113 NegoDlg.Start; 2999 idle := true;3114 Idle := True; 3000 3115 end; 3001 3116 … … 3003 3118 if not IsMultiPlayerGame then 3004 3119 begin 3005 case G.RO[NewPlayer].Treaty[ integer(Data)] of3120 case G.RO[NewPlayer].Treaty[Integer(Data)] of 3006 3121 trPeace: 3007 s := Tribe[integer(Data)].TPhrase('FRCANCELBYREJECT_PEACE');3122 S := Tribe[Integer(Data)].TPhrase('FRCANCELBYREJECT_PEACE'); 3008 3123 trFriendlyContact: 3009 s := Tribe[integer(Data)].TPhrase('FRCANCELBYREJECT_FRIENDLY');3124 S := Tribe[Integer(Data)].TPhrase('FRCANCELBYREJECT_FRIENDLY'); 3010 3125 trAlliance: 3011 s := Tribe[integer(Data)].TPhrase('FRCANCELBYREJECT_ALLIANCE');3126 S := Tribe[Integer(Data)].TPhrase('FRCANCELBYREJECT_ALLIANCE'); 3012 3127 end; 3013 TribeMessage( integer(Data), s, 'CANCELTREATY');3128 TribeMessage(Integer(Data), S, 'CANCELTREATY'); 3014 3129 end; 3015 3130 3016 3131 cShowCancelTreatyByAlliance: 3017 if idle and (NewPlayer = me) then3018 TribeMessage( integer(Data), Tribe[integer(Data)3132 if Idle and (NewPlayer = Me) then 3133 TribeMessage(Integer(Data), Tribe[Integer(Data) 3019 3134 ].TPhrase('FRENEMYALLIANCE'), 'CANCELTREATY'); 3020 3135 3021 3136 cShowSupportAllianceAgainst: 3022 3137 if not IsMultiPlayerGame and (Jump[0] = 0) then 3023 TribeMessage( integer(Data) and $F, Tribe[integer(Data) and $F]3024 .TPhrase('FRMYALLIANCE1') + ' ' + Tribe[ integer(Data) shr 4]3138 TribeMessage(Integer(Data) and $F, Tribe[Integer(Data) and $F] 3139 .TPhrase('FRMYALLIANCE1') + ' ' + Tribe[Integer(Data) shr 4] 3025 3140 .TPhrase('FRMYALLIANCE2'), 'CANCELTREATY'); 3026 3141 3027 3142 cShowPeaceViolation: 3028 3143 if not IsMultiPlayerGame and (Jump[0] = 0) then 3029 TribeMessage( integer(Data),3030 Format(Tribe[ integer(Data)].TPhrase('EVIOLATION'),3144 TribeMessage(Integer(Data), 3145 Format(Tribe[Integer(Data)].TPhrase('EVIOLATION'), 3031 3146 [TurnToString(MyRO.Turn + PeaceEvaTurns - 1)]), 'MSG_WITHDRAW'); 3032 3147 … … 3035 3150 3036 3151 cShowUnitChanged, cShowCityChanged, cShowAfterMove, cShowAfterAttack: 3037 if ( idle and (NewPlayer = me) or not idle and not skipped) and3152 if (Idle and (NewPlayer = Me) or not Idle and not skipped) and 3038 3153 not((GameMode = cMovie) and (MovieSpeed = 4)) then 3039 3154 begin 3040 assert(NewPlayer = me);3041 if not idle or (GameMode = cMovie) then3155 Assert(NewPlayer = Me); 3156 if not Idle or (GameMode = cMovie) then 3042 3157 DpiApplication.ProcessMessages; 3043 3158 if Command = cShowCityChanged then 3044 3159 begin 3045 CurrentMoveInfo.DoShow := false;3046 if idle then3047 CurrentMoveInfo.DoShow := true3160 CurrentMoveInfo.DoShow := False; 3161 if Idle then 3162 CurrentMoveInfo.DoShow := True 3048 3163 else if CurrentMoveInfo.IsAlly then 3049 3164 CurrentMoveInfo.DoShow := not mAlNoMoves.Checked … … 3053 3168 else if Command = cShowUnitChanged then 3054 3169 begin 3055 CurrentMoveInfo.DoShow := false;3056 if idle then3170 CurrentMoveInfo.DoShow := False; 3171 if Idle then 3057 3172 CurrentMoveInfo.DoShow := not mEffectiveMovesOnly.Checked 3058 3173 else if CurrentMoveInfo.IsAlly then … … 3068 3183 begin 3069 3184 if Command = cShowCityChanged then 3070 MapValid := false;3071 FocusOnLoc( integer(Data), flImmUpdate);3185 MapValid := False; 3186 FocusOnLoc(Integer(Data), flImmUpdate); 3072 3187 // OldUnFocus:=UnFocus; 3073 3188 // UnFocus:=-1; 3074 3189 if Command = cShowAfterMove then 3075 PaintLoc( integer(Data), CurrentMoveInfo.AfterMovePaintRadius)3190 PaintLoc(Integer(Data), CurrentMoveInfo.AfterMovePaintRadius) 3076 3191 // show discovered areas 3077 3192 else 3078 PaintLoc( integer(Data), 1);3193 PaintLoc(Integer(Data), 1); 3079 3194 // UnFocus:=OldUnFocus; 3080 3195 if (Command = cShowAfterAttack) and … … 3086 3201 Update; // remove message box from screen 3087 3202 end 3088 else if not idle then3203 else if not Idle then 3089 3204 if Command = cShowCityChanged then 3090 3205 Sleep(MoveTime * WaitAfterShowMove div 16) 3091 3206 else if (Command = cShowUnitChanged) and 3092 (MyMap[ integer(Data)] and fUnit <> 0) then3207 (MyMap[Integer(Data)] and fUnit <> 0) then 3093 3208 Sleep(MoveTime * WaitAfterShowMove div 32) 3094 3209 end // if CurrentMoveInfo.DoShow 3095 3210 else 3096 MapValid := false;3211 MapValid := False; 3097 3212 end; 3098 3213 3099 3214 cShowMoving, cShowCapturing: 3100 if ( idle and (NewPlayer = me) or not idle and not skipped and3215 if (Idle and (NewPlayer = Me) or not Idle and not skipped and 3101 3216 (TShowMove(Data).emix <> $FFFF)) and 3102 3217 not((GameMode = cMovie) and (MovieSpeed = 4)) then 3103 3218 begin 3104 assert(NewPlayer = me);3105 if not idle or (GameMode = cMovie) then3219 Assert(NewPlayer = Me); 3220 if not Idle or (GameMode = cMovie) then 3106 3221 DpiApplication.ProcessMessages; 3107 3222 with TShowMove(Data) do 3108 3223 begin 3109 CurrentMoveInfo.DoShow := false;3110 if not idle and (not Assigned(Tribe[Owner].ModelPicture[mix].HGr)) then3224 CurrentMoveInfo.DoShow := False; 3225 if not Idle and (not Assigned(Tribe[Owner].ModelPicture[mix].HGr)) then 3111 3226 InitEnemyModel(emix); 3112 3227 3113 3228 ToLoc := dLoc(FromLoc, dx, dy); 3114 if idle then3229 if Idle then 3115 3230 begin // own unit -- make discovered land visible 3116 assert(Owner = me); // no foreign moves during my turn!3231 Assert(Owner = Me); // no foreign moves during my turn! 3117 3232 CurrentMoveInfo.DoShow := not mEffectiveMovesOnly.Checked or 3118 3233 (Command = cShowCapturing); … … 3147 3262 else 3148 3263 CurrentMoveInfo.AfterMovePaintRadius := 1; 3149 if (MyRO.Wonder[woShinkansen].EffectiveOwner = me) and3264 if (MyRO.Wonder[woShinkansen].EffectiveOwner = Me) and 3150 3265 (Domain = dGround) and 3151 3266 (MyMap[FromLoc] and (fRR or fCity) <> 0) and … … 3162 3277 CurrentMoveInfo.IsAlly := MyRO.Treaty[Owner] = trAlliance; 3163 3278 if GameMode = cMovie then 3164 CurrentMoveInfo.DoShow := true3279 CurrentMoveInfo.DoShow := True 3165 3280 else if CurrentMoveInfo.IsAlly then 3166 3281 CurrentMoveInfo.DoShow := not mAlNoMoves.Checked and … … 3178 3293 cix := MyRO.nCity - 1; 3179 3294 while (cix >= 0) and (MyCity[cix].Loc <> ToLoc) do 3180 dec(cix);3181 s:= CityName(MyCity[cix].ID);3295 Dec(cix); 3296 S := CityName(MyCity[cix].ID); 3182 3297 end 3183 3298 else … … 3185 3300 ecix := MyRO.nEnemyCity - 1; 3186 3301 while (ecix >= 0) and (MyRO.EnemyCity[ecix].Loc <> ToLoc) do 3187 dec(ecix);3188 s:= CityName(MyRO.EnemyCity[ecix].ID);3302 Dec(ecix); 3303 S := CityName(MyRO.EnemyCity[ecix].ID); 3189 3304 end; 3190 3305 TribeMessage(Owner, Format(Tribe[Owner].TPhrase('CAPTURE'), 3191 [ s]), '');3306 [S]), ''); 3192 3307 Update; // remove message box from screen 3193 3308 end; … … 3274 3389 end // if CurrentMoveInfo.DoShow 3275 3390 else 3276 MapValid := false;3391 MapValid := False; 3277 3392 end; 3278 3393 end; 3279 3394 3280 3395 cShowAttacking: 3281 if ( idle and (NewPlayer = me) or not idle and not skipped and3396 if (Idle and (NewPlayer = Me) or not Idle and not skipped and 3282 3397 (TShowMove(Data).emix <> $FFFF)) and 3283 3398 not((GameMode = cMovie) and (MovieSpeed = 4)) then 3284 3399 begin 3285 assert(NewPlayer = me);3286 if not idle or (GameMode = cMovie) then3400 Assert(NewPlayer = Me); 3401 if not Idle or (GameMode = cMovie) then 3287 3402 DpiApplication.ProcessMessages; 3288 3403 with TShowMove(Data) do 3289 3404 begin 3290 3405 CurrentMoveInfo.AfterAttackExpeller := -1; 3291 CurrentMoveInfo.DoShow := false;3292 if idle then3293 CurrentMoveInfo.DoShow := true // own unit -- always show attacks3406 CurrentMoveInfo.DoShow := False; 3407 if Idle then 3408 CurrentMoveInfo.DoShow := True // own unit -- always show attacks 3294 3409 else 3295 3410 begin … … 3311 3426 cix := MyRO.nCity - 1; 3312 3427 while (cix >= 0) and (MyCity[cix].Loc <> ToLoc) do 3313 dec(cix);3428 Dec(cix); 3314 3429 if MyCity[cix].Status and csToldBombard = 0 then 3315 3430 begin 3316 if not supervising then3431 if not Supervising then 3317 3432 MyCity[cix].Status := MyCity[cix].Status or csToldBombard; 3318 s:= CityName(MyCity[cix].ID);3433 S := CityName(MyCity[cix].ID); 3319 3434 SoundMessageEx(Format(Tribe[Owner].TPhrase('BOMBARD'), 3320 [ s]), '');3435 [S]), ''); 3321 3436 Update; // remove message box from screen 3322 3437 end; … … 3327 3442 if Flags and umExpelling <> 0 then 3328 3443 Play('MOVE_EXPEL') 3329 else if Owner = me then3444 else if Owner = Me then 3330 3445 begin 3331 MakeModelInfo( me, mix, MyModel[mix], mi);3446 MakeModelInfo(Me, mix, MyModel[mix], mi); 3332 3447 Play(AttackSound(ModelCode(mi))); 3333 3448 end … … 3354 3469 MoveOnScreen(TShowMove(Data), 10, 0, 16); 3355 3470 end 3356 else if not idle then3471 else if not Idle then 3357 3472 Sleep(MoveTime div 2); 3358 3473 MainMap.AttackEnd; 3359 3474 end // if CurrentMoveInfo.DoShow 3360 3475 else 3361 MapValid := false;3476 MapValid := False; 3362 3477 end; 3363 3478 end; … … 3368 3483 else 3369 3484 begin 3370 s:= Phrases.Lookup('FOREIGNINFO');3485 S := Phrases.Lookup('FOREIGNINFO'); 3371 3486 for p1 := 0 to nPl - 1 do 3372 3487 if 3 shl (p1 * 2) and Cardinal(Data) <> 0 then 3373 s := s+ '\' + Tribe[p1].TPhrase('SHORTNAME');3374 SoundMessageEx( s, '');3488 S := S + '\' + Tribe[p1].TPhrase('SHORTNAME'); 3489 SoundMessageEx(S, ''); 3375 3490 end; 3376 3491 … … 3384 3499 begin 3385 3500 MessgText := Format(Phrases.Lookup('GRLIB_GENERAL'), 3386 [Phrases.Lookup('ADVANCES', integer(Data))]);3501 [Phrases.Lookup('ADVANCES', Integer(Data))]); 3387 3502 OpenSound := 'NEWADVANCE_GRLIB'; 3388 3503 Kind := mkOk; … … 3394 3509 cRefreshDebugMap: 3395 3510 begin 3396 if integer(Data) = MainMap.pDebugMap then3511 if Integer(Data) = MainMap.pDebugMap then 3397 3512 begin 3398 MapValid := false;3513 MapValid := False; 3399 3514 MainOffscreenPaint; 3400 3515 Update; 3401 end 3516 end; 3402 3517 end; 3403 3518 3404 3519 else 3405 3520 if Command >= cClientEx then 3406 case Command and $FFF0 of 3407 3521 case Command and (not Integer(CommandDataElementCountMask)) of 3408 3522 cSetTribe: 3409 with TTribeInfo(Data) do 3410 begin 3411 i := UnusedTribeFiles.Count - 1; 3412 while (i >= 0) and 3413 (AnsiCompareFileName(UnusedTribeFiles[i], FileName) <> 0) do 3414 dec(i); 3415 if i >= 0 then 3416 UnusedTribeFiles.Delete(i); 3417 CreateTribe(trix, FileName, true); 3523 with TTribeInfo(Data) do begin 3524 I := UnusedTribeFiles.Count - 1; 3525 while (I >= 0) and 3526 (AnsiCompareFileName(UnusedTribeFiles[I], FileName) <> 0) do 3527 Dec(I); 3528 if I >= 0 then 3529 UnusedTribeFiles.Delete(I); 3530 CreateTribe(trix, FileName, True); 3418 3531 end; 3419 3420 cSetNewModelPicture, cSetModelPicture: 3532 cSetNewModelPicture: 3421 3533 if TribeOriginal[TModelPictureInfo(Data).trix] then 3422 3534 Tribe[TModelPictureInfo(Data).trix].SetModelPicture 3423 (TModelPictureInfo(Data), Command and 3424 $FFF0 = cSetNewModelPicture); 3425 3426 cSetSlaveIndex and $FFF0: 3427 Tribe[integer(Data) shr 16].mixSlaves := integer(Data) and $FFFF; 3428 3535 (TModelPictureInfo(Data), True); 3536 cSetModelPicture: 3537 if TribeOriginal[TModelPictureInfo(Data).trix] then 3538 Tribe[TModelPictureInfo(Data).trix].SetModelPicture 3539 (TModelPictureInfo(Data), False); 3540 cSetSlaveIndex: 3541 Tribe[Integer(Data) shr 16].mixSlaves := Integer(Data) and $FFFF; 3429 3542 cSetCityName: 3430 3543 with TCityNameInfo(Data) do 3431 3544 if TribeOriginal[ID shr 12] then 3432 3545 Tribe[ID shr 12].SetCityName(ID and $FFF, NewName); 3433 3434 3546 cSetModelName: 3435 3547 with TModelNameInfo(Data) do … … 3444 3556 procedure TMainScreen.FormCreate(Sender: TObject); 3445 3557 var 3446 i, j: integer;3558 I, J: Integer; 3447 3559 begin 3448 3560 NoMap := TIsoMap.Create; … … 3486 3598 3487 3599 // tag-controlled language 3488 for i:= 0 to ComponentCount - 1 do3489 if Components[ i].Tag and $FF <> 0 then3490 if Components[ i] is TDpiMenuItem then begin3491 TDpiMenuItem(Components[ i]).Caption := Phrases.Lookup('CONTROLS',3492 -1 + Components[ i].Tag and $FF);3493 for j:= 0 to Length(SaveOption) - 1 do3494 if Components[ i].Tag and $FF = SaveOption[j] then3495 TDpiMenuItem(Components[ i]).Checked := TSaveOption(j) in OptionChecked;3600 for I := 0 to ComponentCount - 1 do 3601 if Components[I].Tag and $FF <> 0 then 3602 if Components[I] is TDpiMenuItem then begin 3603 TDpiMenuItem(Components[I]).Caption := Phrases.Lookup('CONTROLS', 3604 -1 + Components[I].Tag and $FF); 3605 for J := 0 to Length(SaveOption) - 1 do 3606 if Components[I].Tag and $FF = SaveOption[J] then 3607 TDpiMenuItem(Components[I]).Checked := TSaveOption(J) in OptionChecked; 3496 3608 end else 3497 if Components[ i] is TButtonBase then begin3498 TButtonBase(Components[ i]).Hint := Phrases.Lookup('CONTROLS',3499 -1 + Components[ i].Tag and $FF);3500 if (Components[ i] is TButtonC) and3501 (TButtonC(Components[ i]).ButtonIndex <> 1) then3502 TButtonC(Components[ i]).ButtonIndex :=3503 Integer(MapOptionChecked) shr (Components[ i].Tag shr 8) and 1 + 23609 if Components[I] is TButtonBase then begin 3610 TButtonBase(Components[I]).Hint := Phrases.Lookup('CONTROLS', 3611 -1 + Components[I].Tag and $FF); 3612 if (Components[I] is TButtonC) and 3613 (TButtonC(Components[I]).ButtonIndex <> 1) then 3614 TButtonC(Components[I]).ButtonIndex := 3615 Integer(MapOptionChecked) shr (Components[I].Tag shr 8) and 1 + 2 3504 3616 end; 3505 3617 … … 3514 3626 ManagementArea.Hint := Phrases2.Lookup('BTN_MANAGE'); 3515 3627 end; 3516 for i:= 0 to mRep.Count - 1 do3517 begin 3518 j := mRep[i].Tag shr 8;3519 mRep[ i].Caption := CityEventName(j);3520 mRep[ i].Checked := CityRepMask and (1 shl j) <> 0;3628 for I := 0 to mRep.Count - 1 do 3629 begin 3630 J := mRep[I].Tag shr 8; 3631 mRep[I].Caption := CityEventName(J); 3632 mRep[I].Checked := CityRepMask and (1 shl J) <> 0; 3521 3633 end; 3522 3634 … … 3537 3649 else Buffer.height := 3 * ySizeBig; 3538 3650 Buffer.Canvas.Font.Assign(UniFont[ftSmall]); 3539 for i:= 0 to nPl - 1 do3540 AILogo[ i] := nil;3651 for I := 0 to nPl - 1 do 3652 AILogo[I] := nil; 3541 3653 Canvas.Font.Assign(UniFont[ftSmall]); 3542 3654 InitButtons; … … 3548 3660 I: Integer; 3549 3661 begin 3662 if Assigned(FWondersDlg) then FreeAndNil(FWondersDlg); 3663 if Assigned(FTechTreeDlg) then FreeAndNil(FTechTreeDlg); 3664 if Assigned(FEnhanceDlg) then FreeAndNil(FEnhanceDlg); 3665 if Assigned(FNegoDlg) then FreeAndNil(FNegoDlg); 3666 if Assigned(FCityTypeDlg) then FreeAndNil(FCityTypeDlg); 3667 if Assigned(FDiaDlg) then FreeAndNil(FDiaDlg); 3668 if Assigned(FCityDlg) then FreeAndNil(FCityDlg); 3669 if Assigned(FRatesDlg) then FreeAndNil(FRatesDlg); 3670 if Assigned(FBattleDlg) then FreeAndNil(FBattleDlg); 3671 if Assigned(FNatStatDlg) then FreeAndNil(FNatStatDlg); 3672 if Assigned(FUnitStatDlg) then FreeAndNil(FUnitStatDlg); 3673 if Assigned(FDraftDlg) then FreeAndNil(FDraftDlg); 3674 if Assigned(FModalSelectDlg) then FreeAndNil(FModalSelectDlg); 3675 if Assigned(FListDlg) then FreeAndNil(FListDlg); 3676 if Assigned(FMessgExDlg) then FreeAndNil(FMessgExDlg); 3677 if Assigned(FHelpDlg) then FreeAndNil(FHelpDlg); 3678 3550 3679 MainFormKeyDown := nil; 3551 3680 FreeAndNil(sb); … … 3555 3684 FreeAndNil(Panel); 3556 3685 for I := 0 to nPl - 1 do 3557 if AILogo[ i] <> nil then3686 if AILogo[I] <> nil then 3558 3687 FreeAndNil(AILogo[I]); 3559 3688 FreeAndNil(Offscreen); … … 3586 3715 end; 3587 3716 3717 procedure TMainScreen.mAfforestClick(Sender: TObject); 3718 begin 3719 if UnFocus >= 0 then 3720 with TUn(MyUn[UnFocus]) do 3721 DoJob(jAfforest); 3722 end; 3723 3724 procedure TMainScreen.mAirBaseClick(Sender: TObject); 3725 begin 3726 if UnFocus >= 0 then 3727 with TUn(MyUn[UnFocus]) do 3728 DoJob(jBase); 3729 end; 3730 3731 procedure TMainScreen.mCanalClick(Sender: TObject); 3732 begin 3733 if UnFocus >= 0 then 3734 with TUn(MyUn[UnFocus]) do 3735 DoJob(jCanal); 3736 end; 3737 3738 procedure TMainScreen.mCancelClick(Sender: TObject); 3739 begin 3740 if UnFocus >= 0 then 3741 with MyUn[UnFocus] do begin 3742 DestinationMarkON := False; 3743 PaintDestination; 3744 Status := Status and ($FFFF - usRecover - usGoto - usEnhance); 3745 if Job > jNone then 3746 Server(sStartJob + jNone shl 4, Me, UnFocus, nil^); 3747 end; 3748 end; 3749 3750 procedure TMainScreen.mCentreClick(Sender: TObject); 3751 begin 3752 if UnFocus >= 0 then 3753 with TUn(MyUn[UnFocus]) do begin 3754 Centre(Loc); 3755 PaintAllMaps; 3756 end; 3757 end; 3758 3759 procedure TMainScreen.mcityClick(Sender: TObject); 3760 var 3761 Loc0: Integer; 3762 cix: Integer; 3763 ServerResult: Integer; 3764 begin 3765 if UnFocus >= 0 then 3766 with TUn(MyUn[UnFocus]) do begin 3767 Loc0 := Loc; 3768 if MyMap[Loc] and fCity = 0 then 3769 begin // build city 3770 if DoJob(jCity) = eCity then 3771 begin 3772 MapValid := False; 3773 PaintAll; 3774 ZoomToCity(Loc0, True, chFounded); 3775 end; 3776 end else begin 3777 CityOptimizer_BeforeRemoveUnit(UnFocus); 3778 ServerResult := Server(sAddToCity, Me, UnFocus, nil^); 3779 if ServerResult >= rExecuted then 3780 begin 3781 cix := MyRO.nCity - 1; 3782 while (cix >= 0) and (MyCity[cix].Loc <> Loc0) do 3783 Dec(cix); 3784 Assert(cix >= 0); 3785 CityOptimizer_CityChange(cix); 3786 CityOptimizer_AfterRemoveUnit; // does nothing here 3787 SetTroopLoc(Loc0); 3788 UpdateViews(True); 3789 DestinationMarkON := False; 3790 PaintDestination; 3791 UnFocus := -1; 3792 PaintLoc(Loc0); 3793 NextUnit(UnStartLoc, True); 3794 end 3795 else if ServerResult = eMaxSize then 3796 SimpleMessage(Phrases.Lookup('ADDTOMAXSIZE')); 3797 end; 3798 end; 3799 end; 3800 3801 procedure TMainScreen.mCityStatClick(Sender: TObject); 3802 begin 3803 ListDlg.ShowNewContent(wmPersistent, kCities); 3804 end; 3805 3806 procedure TMainScreen.mCityTypesClick(Sender: TObject); 3807 begin 3808 CityTypeDlg.ShowNewContent(wmModal); 3809 // must be modal because types are not saved before closing 3810 end; 3811 3812 procedure TMainScreen.mClearClick(Sender: TObject); 3813 begin 3814 if UnFocus >= 0 then 3815 with TUn(MyUn[UnFocus]) do 3816 DoJob(jClear); 3817 end; 3818 3819 procedure TMainScreen.mDiagramClick(Sender: TObject); 3820 begin 3821 DiaDlg.ShowNewContent_Charts(wmPersistent); 3822 end; 3823 3824 procedure TMainScreen.mEmpireClick(Sender: TObject); 3825 begin 3826 RatesDlg.ShowNewContent(wmPersistent); 3827 end; 3828 3829 procedure TMainScreen.mEnhanceClick(Sender: TObject); 3830 begin 3831 if UnFocus >= 0 then 3832 with TUn(MyUn[UnFocus]) do 3833 DoJob(-1); 3834 end; 3835 3836 procedure TMainScreen.mEnhanceDefClick(Sender: TObject); 3837 begin 3838 if UnFocus >= 0 then 3839 EnhanceDlg.ShowNewContent(wmPersistent, 3840 MyMap[MyUn[UnFocus].Loc] and fTerrain) 3841 else 3842 EnhanceDlg.ShowNewContent(wmPersistent); 3843 end; 3844 3845 procedure TMainScreen.mEUnitStatClick(Sender: TObject); 3846 begin 3847 if MyRO.nEnemyModel > 0 then 3848 ListDlg.ShowNewContent(wmPersistent, kAllEModels); 3849 end; 3850 3851 procedure TMainScreen.mFarmClick(Sender: TObject); 3852 begin 3853 if UnFocus >= 0 then 3854 with TUn(MyUn[UnFocus]) do 3855 DoJob(jFarm); 3856 end; 3857 3858 procedure TMainScreen.mfortClick(Sender: TObject); 3859 begin 3860 if UnFocus >= 0 then 3861 with TUn(MyUn[UnFocus]) do 3862 DoJob(jFort); 3863 end; 3864 3865 procedure TMainScreen.mGoOnClick(Sender: TObject); 3866 var 3867 Destination: Integer; 3868 begin 3869 if UnFocus >= 0 then 3870 with TUn(MyUn[UnFocus]) do begin 3871 if Status shr 16 = $7FFF then 3872 Destination := maNextCity 3873 else 3874 Destination := Status shr 16; 3875 Status := Status and not(usStay or usRecover) or usWaiting; 3876 MoveToLoc(Destination, True); 3877 end; 3878 end; 3879 3880 procedure TMainScreen.mHelpClick(Sender: TObject); 3881 begin 3882 if ClientMode = cEditMap then 3883 HelpDlg.ShowNewContent(wmPersistent, hkText, HelpDlg.TextIndex('MAPEDIT')) 3884 else 3885 HelpDlg.ShowNewContent(wmPersistent, hkMisc, Integer(miscMain)); 3886 end; 3887 3888 procedure TMainScreen.mhomeClick(Sender: TObject); 3889 var 3890 cixOldHome: Integer; 3891 begin 3892 if UnFocus >= 0 then 3893 with TUn(MyUn[UnFocus]) do begin 3894 if MyMap[Loc] and fCity <> 0 then 3895 begin 3896 cixOldHome := Home; 3897 if Server(sSetUnitHome, Me, UnFocus, nil^) >= rExecuted then 3898 begin 3899 CityOptimizer_CityChange(cixOldHome); 3900 CityOptimizer_CityChange(Home); 3901 UpdateViews(True); 3902 end 3903 else 3904 Play('INVALID'); 3905 end 3906 else 3907 begin 3908 Status := Status and not(usStay or usRecover or usEnhance); 3909 MoveToLoc(maNextCity, True); 3910 end; 3911 end; 3912 end; 3913 3914 procedure TMainScreen.mirrigationClick(Sender: TObject); 3915 begin 3916 if UnFocus >= 0 then 3917 with TUn(MyUn[UnFocus]) do 3918 DoJob(jIrr); 3919 end; 3920 3921 procedure TMainScreen.mirrigationDrawItem(Sender: TObject; ACanvas: TDpiCanvas; 3922 ARect: TRect; AState: TOwnerDrawState); 3923 begin 3924 3925 end; 3926 3927 procedure TMainScreen.mJumpClick(Sender: TObject); 3928 begin 3929 if Supervising then 3930 Jump[0] := 20 3931 else 3932 Jump[Me] := 20; 3933 EndTurn(True); 3934 end; 3935 3936 procedure TMainScreen.mLoadClick(Sender: TObject); 3937 var 3938 I: Integer; 3939 begin 3940 if UnFocus >= 0 then 3941 with MyUn[UnFocus] do begin 3942 I := Server(sLoadUnit, Me, UnFocus, nil^); 3943 if I >= rExecuted then 3944 begin 3945 if MyModel[mix].Domain = dAir then 3946 Play('MOVE_PLANELANDING') 3947 else 3948 Play('MOVE_LOAD'); 3949 DestinationMarkON := False; 3950 PaintDestination; 3951 Status := Status and ($FFFF - usWaiting - usStay - usRecover - usGoto - usEnhance); 3952 NextUnit(UnStartLoc, True); 3953 end 3954 else if I = eNoTime_Load then 3955 if MyModel[mix].Domain = dAir then 3956 SoundMessage(Phrases.Lookup('NOTIMELOADAIR'), 'NOMOVE_TIME') 3957 else 3958 SoundMessage(Format(Phrases.Lookup('NOTIMELOADGROUND'), 3959 [MovementToString(MyModel[mix].speed)]), 'NOMOVE_TIME'); 3960 end; 3961 end; 3962 3963 procedure TMainScreen.mmineClick(Sender: TObject); 3964 begin 3965 if UnFocus >= 0 then 3966 with TUn(MyUn[UnFocus]) do 3967 DoJob(jMine); 3968 end; 3969 3970 procedure TMainScreen.mNationsClick(Sender: TObject); 3971 begin 3972 NatStatDlg.ShowNewContent(wmPersistent); 3973 end; 3974 3975 procedure TMainScreen.mNextUnitClick(Sender: TObject); 3976 begin 3977 if UnFocus >= 0 then 3978 with MyUn[UnFocus] do begin 3979 Status := Status and not usWaiting; 3980 FocusNextUnit(1); 3981 end; 3982 end; 3983 3984 procedure TMainScreen.mnoordersClick(Sender: TObject); 3985 begin 3986 if UnFocus >= 0 then 3987 with MyUn[UnFocus] do begin 3988 Status := Status and not usWaiting; 3989 NextUnit(UnStartLoc, True); 3990 end; 3991 end; 3992 3993 procedure TMainScreen.mPillageClick(Sender: TObject); 3994 begin 3995 DoJob(jPillage); 3996 end; 3997 3998 procedure TMainScreen.mpollutionClick(Sender: TObject); 3999 begin 4000 if UnFocus >= 0 then 4001 with TUn(MyUn[UnFocus]) do 4002 DoJob(jPoll); 4003 end; 4004 4005 procedure TMainScreen.mPrevUnitClick(Sender: TObject); 4006 begin 4007 if UnFocus >= 0 then 4008 with MyUn[UnFocus] do begin 4009 Status := Status and not usWaiting; 4010 FocusNextUnit(-1); 4011 end; 4012 end; 4013 4014 procedure TMainScreen.mRandomMapClick(Sender: TObject); 4015 begin 4016 if not Edited or (SimpleQuery(mkYesNo, Phrases.Lookup('MAP_RANDOM'), '') 4017 = mrOK) then begin 4018 Server(sRandomMap, Me, 0, nil^); 4019 Edited := True; 4020 MapValid := False; 4021 PaintAllMaps; 4022 end; 4023 end; 4024 4025 procedure TMainScreen.mRecoverClick(Sender: TObject); 4026 begin 4027 if UnFocus >= 0 then 4028 with MyUn[UnFocus] do begin 4029 DestinationMarkON := False; 4030 PaintDestination; 4031 Status := Status and ($FFFF - usStay - usGoto - usEnhance) or usRecover; 4032 if Job > jNone then 4033 Server(sStartJob + jNone shl 4, Me, UnFocus, nil^); 4034 NextUnit(UnStartLoc, True); 4035 end; 4036 end; 4037 4038 procedure TMainScreen.mResignClick(Sender: TObject); 4039 var 4040 QueryText: string; 4041 begin 4042 if ClientMode = cEditMap then begin 4043 if Edited then begin 4044 QueryText := Phrases.Lookup('MAP_CLOSE'); 4045 case SimpleQuery(mkYesNoCancel, QueryText, '') of 4046 mrIgnore: Server(sAbandonMap, Me, 0, nil^); 4047 mrOK: Server(sSaveMap, Me, 0, nil^); 4048 end; 4049 end else 4050 Server(sAbandonMap, Me, 0, nil^); 4051 end else begin 4052 if Server(sGetGameChanged, 0, 0, nil^) = eOK then begin 4053 QueryText := Phrases.Lookup('RESIGN'); 4054 case SimpleQuery(mkYesNoCancel, QueryText, '') of 4055 mrIgnore: Server(sResign, 0, 0, nil^); 4056 mrOK: Server(sBreak, 0, 0, nil^); 4057 end; 4058 end else 4059 Server(sResign, 0, 0, nil^); 4060 end; 4061 end; 4062 4063 procedure TMainScreen.mRevolutionClick(Sender: TObject); 4064 var 4065 AltGovs: Boolean; 4066 RevolutionChanged: Boolean; 4067 I: Integer; 4068 begin 4069 AltGovs := False; 4070 for I := 2 to nGov - 1 do 4071 if (GovPreq[I] <> preNA) and 4072 ((GovPreq[I] = preNone) or (MyRO.Tech[GovPreq[I]] >= tsApplicable)) then 4073 AltGovs := True; 4074 4075 if not AltGovs then 4076 SoundMessage(Phrases.Lookup('NOALTGOVS'), 'MSG_DEFAULT') 4077 else 4078 begin 4079 RevolutionChanged := False; 4080 if MyRO.Happened and phChangeGov <> 0 then 4081 begin 4082 ModalSelectDlg.ShowNewContent(wmModal, kGov); 4083 if ModalSelectDlg.Result >= 0 then 4084 begin 4085 Play('NEWGOV'); 4086 Server(sSetGovernment, Me, ModalSelectDlg.Result, nil^); 4087 CityOptimizer_BeginOfTurn; 4088 RevolutionChanged := True; 4089 end; 4090 end 4091 else 4092 with MessgExDlg do 4093 begin // revolution! 4094 MessgExDlg.MessgText := Tribe[Me].TPhrase('REVOLUTION'); 4095 MessgExDlg.Kind := mkYesNo; 4096 MessgExDlg.IconKind := mikPureIcon; 4097 MessgExDlg.IconIndex := 72; // anarchy palace 4098 MessgExDlg.ShowModal; 4099 if ModalResult = mrOK then 4100 begin 4101 Play('REVOLUTION'); 4102 Server(sRevolution, Me, 0, nil^); 4103 RevolutionChanged := True; 4104 if NatStatDlg.Visible then 4105 NatStatDlg.Close; 4106 if CityDlg.Visible then 4107 CityDlg.Close; 4108 end 4109 end; 4110 if RevolutionChanged then 4111 UpdateViews(True); 4112 end; 4113 end; 4114 4115 procedure TMainScreen.mroadClick(Sender: TObject); 4116 begin 4117 if UnFocus >= 0 then 4118 with TUn(MyUn[UnFocus]) do 4119 DoJob(jRoad); 4120 end; 4121 4122 procedure TMainScreen.mRailRoadClick(Sender: TObject); 4123 begin 4124 if UnFocus >= 0 then 4125 with TUn(MyUn[UnFocus]) do 4126 DoJob(jRR); 4127 end; 4128 4129 procedure TMainScreen.mRunClick(Sender: TObject); 4130 begin 4131 if Supervising then 4132 Jump[0] := 999999 4133 else 4134 Jump[Me] := 999999; 4135 EndTurn(True); 4136 end; 4137 4138 procedure TMainScreen.mScienceStatClick(Sender: TObject); 4139 begin 4140 ListDlg.ShowNewContent(wmPersistent, kScience); 4141 end; 4142 4143 procedure TMainScreen.mSelectTransportClick(Sender: TObject); 4144 begin 4145 if UnFocus >= 0 then 4146 with TUn(MyUn[UnFocus]) do 4147 Server(sSelectTransport, Me, UnFocus, nil^); 4148 end; 4149 4150 procedure TMainScreen.mShipsClick(Sender: TObject); 4151 begin 4152 DiaDlg.ShowNewContent_Ship(wmPersistent); 4153 end; 4154 4155 procedure TMainScreen.mstayClick(Sender: TObject); 4156 begin 4157 if UnFocus >= 0 then 4158 with TUn(MyUn[UnFocus]) do begin 4159 DestinationMarkON := False; 4160 PaintDestination; 4161 Status := Status and ($FFFF - usRecover - usGoto - usEnhance) or usStay; 4162 if Job > jNone then 4163 Server(sStartJob + jNone shl 4, Me, UnFocus, nil^); 4164 NextUnit(UnStartLoc, True); 4165 end; 4166 end; 4167 4168 procedure TMainScreen.mTechTreeClick(Sender: TObject); 4169 begin 4170 TechTreeDlg.ShowModal; 4171 end; 4172 4173 procedure TMainScreen.mtransClick(Sender: TObject); 4174 begin 4175 if UnFocus >= 0 then 4176 with TUn(MyUn[UnFocus]) do 4177 DoJob(jTrans); 4178 end; 4179 4180 procedure TMainScreen.mUnitStatClick(Sender: TObject); 4181 var 4182 I: Integer; 4183 begin 4184 if G.Difficulty[Me] > 0 then 4185 ListDlg.ShowNewContent_MilReport(wmPersistent, Me) 4186 else 4187 begin 4188 I := 1; 4189 while (I < nPl) and (1 shl I and MyRO.Alive = 0) do 4190 Inc(I); 4191 if I < nPl then 4192 ListDlg.ShowNewContent_MilReport(wmPersistent, I); 4193 end; 4194 end; 4195 4196 procedure TMainScreen.mUnloadClick(Sender: TObject); 4197 var 4198 I: Integer; 4199 OldMaster: Integer; 4200 NewFocus: Integer; 4201 uix: Integer; 4202 begin 4203 if UnFocus >= 0 then 4204 with MyUn[UnFocus] do begin 4205 if Master >= 0 then begin 4206 OldMaster := Master; 4207 I := Server(sUnloadUnit, Me, UnFocus, nil^); 4208 if I >= rExecuted then 4209 begin 4210 if MyModel[mix].Domain = dAir then 4211 Play('MOVE_PLANESTART') 4212 else if (MyModel[MyUn[OldMaster].mix].Domain = dAir) and 4213 (MyMap[Loc] and fCity = 0) and (MyMap[Loc] and fTerImp <> tiBase) 4214 then 4215 Play('MOVE_PARACHUTE') 4216 else 4217 Play('MOVE_UNLOAD'); 4218 Status := Status and not usWaiting; 4219 if MyModel[mix].Domain <> dAir then 4220 NextUnit(Loc, True) 4221 else 4222 PanelPaint; 4223 end 4224 else if I = eNoTime_Load then 4225 if MyModel[mix].Domain = dAir then 4226 SoundMessage(Phrases.Lookup('NOTIMELOADAIR'), 'NOMOVE_TIME') 4227 else 4228 SoundMessage(Format(Phrases.Lookup('NOTIMELOADGROUND'), 4229 [MovementToString(MyModel[mix].speed)]), 'NOMOVE_TIME'); 4230 end else begin 4231 NewFocus := -1; 4232 uix := UnFocus; 4233 for I := 1 to MyRO.nUn - 1 do 4234 begin 4235 uix := (uix + MyRO.nUn - 1) mod MyRO.nUn; 4236 if (MyUn[uix].Master = UnFocus) and 4237 (MyUn[uix].Movement = Integer(MyModel[MyUn[uix].mix].speed)) then 4238 begin 4239 MyUn[uix].Status := MyUn[uix].Status or usWaiting; 4240 NewFocus := uix; 4241 end; 4242 end; 4243 if NewFocus >= 0 then 4244 begin 4245 SetUnFocus(NewFocus); 4246 SetTroopLoc(Loc); 4247 PanelPaint; 4248 end; 4249 end; 4250 end; 4251 end; 4252 4253 procedure TMainScreen.mwaitClick(Sender: TObject); 4254 begin 4255 if UnFocus >= 0 then 4256 with MyUn[UnFocus] do begin 4257 DestinationMarkON := False; 4258 PaintDestination; 4259 Status := Status and ($FFFF - usStay - usRecover - usGoto - usEnhance) or usWaiting; 4260 end; 4261 NextUnit(-1, False); 4262 end; 4263 4264 procedure TMainScreen.mWebsiteClick(Sender: TObject); 4265 begin 4266 OpenURL(CevoHomepage); 4267 end; 4268 4269 procedure TMainScreen.mWondersClick(Sender: TObject); 4270 begin 4271 WondersDlg.ShowNewContent(wmPersistent); 4272 end; 4273 3588 4274 procedure TMainScreen.FormResize(Sender: TObject); 3589 4275 var 3590 MiniFrame, MaxMapWidth: integer;4276 MiniFrame, MaxMapWidth: Integer; 3591 4277 begin 3592 4278 SmallScreen := ClientWidth < 1024; … … 3666 4352 begin 3667 4353 RectInvalidate(0, TopBarHeight, ClientWidth, TopBarHeight + MapHeight); 3668 MapValid := false;4354 MapValid := False; 3669 4355 PaintAll; 3670 4356 end; 3671 4357 end; 3672 4358 3673 procedure TMainScreen.FormCloseQuery(Sender: TObject; var CanClose: boolean);4359 procedure TMainScreen.FormCloseQuery(Sender: TObject; var CanClose: Boolean); 3674 4360 begin 3675 4361 CanClose := Closable; 3676 if not Closable and idle and (me = 0) and (ClientMode < scContact) then3677 MenuClick(mResign);4362 if not Closable and Idle and (Me = 0) and (ClientMode < scContact) then 4363 mResign.Click; 3678 4364 end; 3679 4365 … … 3696 4382 begin 3697 4383 MessgExDlg.CancelMovie; 3698 Server(sBreak, me, 0, nil^);4384 Server(sBreak, Me, 0, nil^); 3699 4385 end 3700 4386 else if ClientMode < 0 then 3701 skipped := true4387 Skipped := True 3702 4388 else if ClientMode >= scContact then 3703 4389 NegoDlg.ShowNewContent(wmPersistent) … … 3705 4391 begin 3706 4392 Jump[pTurn] := 0; 3707 StartRunning := false;4393 StartRunning := False; 3708 4394 end 3709 4395 else … … 3718 4404 else 3719 4405 with MainMap do begin 3720 if supervising then4406 if Supervising then 3721 4407 xTerrain := xMidPanel + 2 * xxt + 14 3722 4408 else if ClientWidth < 1280 then … … 3725 4411 xTerrain := ClientWidth div 2; 3726 4412 xTroop := xTerrain + 2 * xxt + 12; 3727 if SmallScreen and not supervising then4413 if SmallScreen and not Supervising then 3728 4414 xTroop := xRightPanel + 10 - 3 * 66 - 3729 4415 DpiGetSystemMetrics(SM_CXVSCROLL) - 19 - 4; … … 3734 4420 end; 3735 4421 3736 function TMainScreen.EndTurn(WasSkipped: boolean): boolean;3737 3738 function IsResourceUnused(cix, NeedFood, NeedProd: integer): boolean;4422 function TMainScreen.EndTurn(WasSkipped: Boolean): Boolean; 4423 4424 function IsResourceUnused(cix, NeedFood, NeedProd: Integer): Boolean; 3739 4425 var 3740 dx, dy, fix: integer;4426 dx, dy, fix: Integer; 3741 4427 CityAreaInfo: TCityAreaInfo; 3742 4428 TileInfo: TTileInfo; 3743 4429 begin 3744 Server(sGetCityAreaInfo, me, cix, CityAreaInfo);4430 Server(sGetCityAreaInfo, Me, cix, CityAreaInfo); 3745 4431 for dy := -3 to 3 do 3746 4432 for dx := -3 to 3 do … … 3752 4438 begin 3753 4439 TileInfo.ExplCity := cix; 3754 Server(sGetHypoCityTileInfo, me, dLoc(MyCity[cix].Loc, dx, dy),4440 Server(sGetHypoCityTileInfo, Me, dLoc(MyCity[cix].Loc, dx, dy), 3755 4441 TileInfo); 3756 4442 if (TileInfo.Food >= NeedFood) and (TileInfo.Prod >= NeedProd) then 3757 4443 begin 3758 result := true;3759 exit4444 Result := True; 4445 Exit 3760 4446 end; 3761 4447 end 3762 4448 end; 3763 result := false;4449 Result := False; 3764 4450 end; 3765 4451 3766 4452 var 3767 i, p1, uix, cix, CenterLoc: integer;4453 p1, uix, cix, CenterLoc: Integer; 3768 4454 MsgItem: string; 3769 4455 CityReport: TCityReport; 3770 4456 PlaneReturnData: TPlaneReturnData; 3771 Zoom: boolean;3772 begin 3773 result := false;4457 Zoom: Boolean; 4458 begin 4459 Result := False; 3774 4460 if ClientMode >= scDipOffer then 3775 exit; 3776 3777 if supervising and (me <> 0) then 3778 begin 3779 for i := 0 to DpiScreen.FormCount - 1 do 3780 if DpiScreen.Forms[i].Visible and (DpiScreen.Forms[i] is TBufferedDrawDlg) then 3781 DpiScreen.Forms[i].Close; // close windows 4461 Exit; 4462 4463 if Supervising and (Me <> 0) then begin 4464 ApplyToVisibleForms(faClose); 3782 4465 ItsMeAgain(0); 3783 4466 end; … … 3797 4480 PlaneReturnData.Loc := Loc; 3798 4481 PlaneReturnData.Movement := 0; // end turn without further movement? 3799 if Server(sGetPlaneReturn, me, uix, PlaneReturnData) = eNoWay then4482 if Server(sGetPlaneReturn, Me, uix, PlaneReturnData) = eNoWay then 3800 4483 begin 3801 4484 CenterLoc := Loc + G.lx * 6; 3802 4485 // centering the unit itself would make it covered by the query dialog 3803 4486 while CenterLoc >= G.lx * G.ly do 3804 dec(CenterLoc, G.lx * 2);4487 Dec(CenterLoc, G.lx * 2); 3805 4488 Centre(CenterLoc); 3806 4489 SetTroopLoc(-1); … … 3817 4500 SetTroopLoc(Loc); 3818 4501 PanelPaint; 3819 exit;4502 Exit; 3820 4503 end; 3821 4504 MyUn[uix].Status := MyUn[uix].Status or usToldNoReturn; 3822 end 4505 end; 3823 4506 end; 3824 4507 3825 if not supervising and (MyRO.TestFlags and tfImmImprove = 0) and4508 if not Supervising and (MyRO.TestFlags and tfImmImprove = 0) and 3826 4509 (MyRO.Government <> gAnarchy) and (MyRO.Money + TaxSum < 0) and 3827 4510 (MyRO.TaxRate < 100) then // low funds! … … 3835 4518 ShowModal; 3836 4519 if ModalResult <> mrOK then 3837 exit4520 Exit; 3838 4521 end; 3839 4522 … … 3843 4526 if (Loc >= 0) and (Flags and chCaptured = 0) then 3844 4527 begin 3845 Zoom := false;4528 Zoom := False; 3846 4529 CityReport.HypoTiles := -1; 3847 4530 CityReport.HypoTax := -1; 3848 4531 CityReport.HypoLux := -1; 3849 Server(sGetCityReport, me, cix, CityReport);4532 Server(sGetCityReport, Me, cix, CityReport); 3850 4533 3851 4534 if (CityReport.Working - CityReport.Happy > Size shr 1) and … … 3904 4587 begin // zoom to city 3905 4588 ZoomToCity(Loc); 3906 exit3907 end 4589 Exit; 4590 end; 3908 4591 end; 3909 4592 … … 3911 4594 (MyData.FarTech <> adNexus) then 3912 4595 if not ChooseResearch then 3913 exit;4596 Exit; 3914 4597 end; 3915 4598 … … 3921 4604 3922 4605 CityDlg.CloseAction := None; 3923 if IsMultiPlayerGame then 3924 begin // close windows for next player 3925 for i := 0 to DpiScreen.FormCount - 1 do 3926 if DpiScreen.Forms[i].Visible and (DpiScreen.Forms[i] is TBufferedDrawDlg) then 3927 DpiScreen.Forms[i].Close; 3928 end 3929 else 3930 begin 4606 if IsMultiPlayerGame then begin 4607 // Close windows for next player 4608 ApplyToVisibleForms(faClose); 4609 end else begin 3931 4610 if CityDlg.Visible then 3932 4611 CityDlg.Close; … … 3934 4613 UnitStatDlg.Close; 3935 4614 end; 3936 for i := 0 to DpiScreen.FormCount - 1 do 3937 if DpiScreen.Forms[i].Visible and (DpiScreen.Forms[i] is TBufferedDrawDlg) then 3938 DpiScreen.Forms[i].Enabled := false; 4615 ApplyToVisibleForms(faDisable); 3939 4616 3940 4617 if Server(sTurn, pTurn, 0, nil^) >= rExecuted then … … 3944 4621 else 3945 4622 EOT.Hint := Phrases.Lookup('BTN_SKIP'); 3946 result := true;4623 Result := True; 3947 4624 SetTroopLoc(-1); 3948 4625 pTurn := -1; 3949 4626 pLogo := -1; 3950 UnitInfoBtn.Visible := false;3951 UnitBtn.Visible := false;3952 TerrainBtn.Visible := false;4627 UnitInfoBtn.Visible := False; 4628 UnitBtn.Visible := False; 4629 TerrainBtn.Visible := False; 3953 4630 EOT.ButtonIndex := eotCancel; 3954 EOT.Visible := true;3955 MapValid := false;4631 EOT.Visible := True; 4632 MapValid := False; 3956 4633 PanelPaint; 3957 4634 Update; 3958 4635 ClientMode := -1; 3959 idle := false;3960 skipped := WasSkipped;4636 Idle := False; 4637 Skipped := WasSkipped; 3961 4638 for p1 := 1 to nPl - 1 do 3962 4639 if G.RO[p1] <> nil then 3963 skipped := true; // don't show enemy moves in hotseat mode4640 Skipped := True; // don't show enemy moves in hotseat mode 3964 4641 end 3965 4642 else 3966 PanelPaint 3967 end; // EndTurn4643 PanelPaint; 4644 end; 3968 4645 3969 4646 procedure TMainScreen.EndNego; … … 3971 4648 if NegoDlg.Visible then 3972 4649 NegoDlg.Close; 3973 HaveStrategyAdvice := false; 3974 // AdvisorDlg.HaveStrategyAdvice; 3975 // negotiation might have changed advices 4650 HaveStrategyAdvice := False; 3976 4651 EOT.ButtonIndex := eotCancel; 3977 EOT.Visible := true;4652 EOT.Visible := True; 3978 4653 PanelPaint; 3979 4654 Update; 3980 4655 ClientMode := -1; 3981 idle := false;3982 end; 3983 3984 procedure TMainScreen.ProcessRect(x0, y0, nx, ny, Options: integer);4656 Idle := False; 4657 end; 4658 4659 procedure TMainScreen.ProcessRect(x0, y0, nx, ny, Options: Integer); 3985 4660 var 3986 xs, ys, xl, yl: integer;4661 xs, ys, xl, yl: Integer; 3987 4662 begin 3988 4663 with MainMap do begin … … 3993 4668 while abs(2 * (xs + G.lx * (xxt * 2)) + xl - MapWidth) < 3994 4669 abs(2 * xs + xl - MapWidth) do 3995 inc(xs, G.lx * (xxt * 2));4670 Inc(xs, G.lx * (xxt * 2)); 3996 4671 ys := (y0 - yw) * yyt - yyt; 3997 4672 if xs + xl > MapWidth then … … 4000 4675 yl := MapHeight - ys; 4001 4676 if (xl <= 0) or (yl <= 0) then 4002 exit;4677 Exit; 4003 4678 if Options and prPaint <> 0 then begin 4004 4679 if Options and prAutoBounds <> 0 then … … 4012 4687 end; 4013 4688 4014 procedure TMainScreen.PaintLoc(Loc: integer; Radius: integer = 0);4689 procedure TMainScreen.PaintLoc(Loc: Integer; Radius: Integer = 0); 4015 4690 var 4016 yLoc, x0: integer;4691 yLoc, x0: Integer; 4017 4692 begin 4018 4693 if MapValid then begin 4019 4694 yLoc := (Loc + G.lx * 1024) div G.lx - 1024; 4020 4695 x0 := (Loc + (yLoc and 1 - 2 * Radius + G.lx * 1024) div 2) mod G.lx; 4021 offscreen.Canvas.Font.Assign(UniFont[ftSmall]);4696 Offscreen.Canvas.Font.Assign(UniFont[ftSmall]); 4022 4697 ProcessRect(x0, yLoc - 2 * Radius, 4 * Radius + 1, 4 * Radius + 1, 4023 4698 prPaint or prAutoBounds or prInvalidate); … … 4026 4701 end; 4027 4702 4028 procedure TMainScreen.PaintLocTemp(Loc: integer; Style: TPaintLocTempStyle);4703 procedure TMainScreen.PaintLocTemp(Loc: Integer; Style: TPaintLocTempStyle); 4029 4704 var 4030 y0, x0, xMap, yMap: integer;4705 y0, x0, xMap, yMap: Integer; 4031 4706 begin 4032 4707 with NoMap do begin 4033 4708 if not MapValid then 4034 exit;4709 Exit; 4035 4710 Buffer.Canvas.Font.Assign(UniFont[ftSmall]); 4036 4711 y0 := Loc div G.lx; … … 4040 4715 while abs(2 * (xMap + G.lx * (xxt * 2)) + 2 * xxt - MapWidth) < 4041 4716 abs(2 * xMap + 2 * xxt - MapWidth) do 4042 inc(xMap, G.lx * (xxt * 2));4717 Inc(xMap, G.lx * (xxt * 2)); 4043 4718 yMap := (y0 - yw) * yyt - yyt; 4044 4719 NoMap.SetOutput(Buffer); … … 4052 4727 // panel protusions are added 4053 4728 // NoMap must be set to buffer and bounds before 4054 procedure TMainScreen.PaintBufferToScreen(xMap, yMap, width, height: integer);4729 procedure TMainScreen.PaintBufferToScreen(xMap, yMap, width, height: Integer); 4055 4730 begin 4056 4731 if xMap + width > MapWidth then … … 4060 4735 if (width <= 0) or (height <= 0) or (width + xMap <= 0) or (height + yMap <= 0) 4061 4736 then 4062 exit;4737 Exit; 4063 4738 4064 4739 NoMap.BitBltBitmap(Panel, -xMap - MapOffset, -yMap + MapHeight - overlap, xMidPanel, … … 4070 4745 begin 4071 4746 if xMap < 0 then 4072 DpiBit Canvas(Canvas, MapOffset, TopBarHeight, width + xMap,4747 DpiBitBltCanvas(Canvas, MapOffset, TopBarHeight, width + xMap, 4073 4748 height + yMap, Buffer.Canvas, -xMap, -yMap) 4074 4749 else 4075 DpiBit Canvas(Canvas, xMap + MapOffset, TopBarHeight, width,4750 DpiBitBltCanvas(Canvas, xMap + MapOffset, TopBarHeight, width, 4076 4751 height + yMap, Buffer.Canvas, 0, -yMap); 4077 4752 end … … 4079 4754 begin 4080 4755 if xMap < 0 then 4081 DpiBit Canvas(Canvas, MapOffset, TopBarHeight + yMap, width + xMap,4756 DpiBitBltCanvas(Canvas, MapOffset, TopBarHeight + yMap, width + xMap, 4082 4757 height, Buffer.Canvas, -xMap, 0) 4083 4758 else 4084 DpiBit Canvas(Canvas, xMap + MapOffset, TopBarHeight + yMap, width,4759 DpiBitBltCanvas(Canvas, xMap + MapOffset, TopBarHeight + yMap, width, 4085 4760 height, Buffer.Canvas, 0, 0); 4086 4761 end; 4087 4762 end; 4088 4763 4089 procedure TMainScreen.PaintLoc_BeforeMove(FromLoc: integer);4764 procedure TMainScreen.PaintLoc_BeforeMove(FromLoc: Integer); 4090 4765 var 4091 yLoc, x0: integer;4766 yLoc, x0: Integer; 4092 4767 begin 4093 4768 if MapValid then … … 4095 4770 yLoc := (FromLoc + G.lx * 1024) div G.lx - 1024; 4096 4771 x0 := (FromLoc + (yLoc and 1 + G.lx * 1024) div 2) mod G.lx; 4097 offscreen.Canvas.Font.Assign(UniFont[ftSmall]);4772 Offscreen.Canvas.Font.Assign(UniFont[ftSmall]); 4098 4773 ProcessRect(x0, yLoc, 1, 1, prPaint or prAutoBounds); 4099 4774 end … … 4102 4777 procedure TMainScreen.PaintDestination; 4103 4778 var 4104 Destination: integer;4779 Destination: Integer; 4105 4780 begin 4106 4781 if (UnFocus >= 0) and (MyUn[UnFocus].Status and usGoto <> 0) then … … 4112 4787 end; 4113 4788 4114 {$IFDEF LINUX}4789 {$IFDEF UNIX} 4115 4790 // Can't do scrolling of DC under Linux, then fallback into BitBlt. 4116 4791 function DpiScrollDC(Canvas: TDpiCanvas; dx: longint; dy: longint; const lprcScroll:TRect; const lprcClip:TRect; hrgnUpdate:HRGN; lprcUpdate: PRect):Boolean; 4117 4792 begin 4118 Result := DpiBit Canvas(Canvas, lprcScroll.Left + dx, lprcScroll.Top + dy, lprcScroll.Right - lprcScroll.Left, lprcScroll.Bottom - lprcScroll.Top,4793 Result := DpiBitBltCanvas(Canvas, lprcScroll.Left + dx, lprcScroll.Top + dy, lprcScroll.Right - lprcScroll.Left, lprcScroll.Bottom - lprcScroll.Top, 4119 4794 Canvas, lprcScroll.Left, lprcScroll.Top); 4120 4795 end; … … 4123 4798 procedure TMainScreen.MainOffscreenPaint; 4124 4799 var 4125 ProcessOptions: integer;4800 ProcessOptions: Integer; 4126 4801 rec: TRect; 4127 DoInvalidate: boolean;4128 begin 4129 if me < 0 then4130 with offscreen.Canvas do4802 DoInvalidate: Boolean; 4803 begin 4804 if Me < 0 then 4805 with Offscreen.Canvas do 4131 4806 begin 4132 4807 Brush.Color := $000000; … … 4134 4809 Brush.Style := bsClear; 4135 4810 OffscreenUser := self; 4136 exit;4811 Exit; 4137 4812 end; 4138 4813 … … 4145 4820 if MapValid and (xwd = xw) and (ywd = yw) then 4146 4821 MainMap.SetPaintBounds(0, 0, UsedOffscreenWidth, UsedOffscreenHeight); 4147 MapValid := false;4822 MapValid := False; 4148 4823 OffscreenUser := self; 4149 4824 end; … … 4158 4833 (ywd - yw > MapHeight div yyt) then 4159 4834 begin 4160 offscreen.Canvas.Font.Assign(UniFont[ftSmall]);4835 Offscreen.Canvas.Font.Assign(UniFont[ftSmall]); 4161 4836 ProcessRect(xw, yw, MapWidth div xxt, MapHeight div yyt, 4162 4837 prPaint or prInvalidate); 4163 4838 end else begin 4164 4839 if (xwd = xw) and (ywd = yw) then 4165 exit; { map window not moved }4166 offscreen.Canvas.Font.Assign(UniFont[ftSmall]);4840 Exit; { map window not moved } 4841 Offscreen.Canvas.Font.Assign(UniFont[ftSmall]); 4167 4842 rec := Rect(0, 0, MapWidth, MapHeight); 4168 4843 {$IFDEF WINDOWS} 4169 DpiScrollDC( offscreen.Canvas, (xwd - xw) * (xxt * 2), (ywd - yw) * yyt,4844 DpiScrollDC(Offscreen.Canvas.Handle, (xwd - xw) * (xxt * 2), (ywd - yw) * yyt, 4170 4845 rec, rec, 0, nil); 4171 4846 {$ENDIF} 4172 {$IFDEF LINUX}4173 DpiScrollDC( offscreen.Canvas, (xwd - xw) * (xxt * 2), (ywd - yw) * yyt,4847 {$IFDEF UNIX} 4848 DpiScrollDC(Offscreen.Canvas, (xwd - xw) * (xxt * 2), (ywd - yw) * yyt, 4174 4849 rec, rec, 0, nil); 4175 4850 {$ENDIF} 4176 for DoInvalidate := false to FastScrolling do begin4851 for DoInvalidate := False to FastScrolling do begin 4177 4852 if DoInvalidate then begin 4178 4853 rec.Bottom := MapHeight - overlap; 4179 4854 {$IFDEF WINDOWS} 4180 DpiScrollDC(Canvas , (xwd - xw) * (xxt * 2), (ywd - yw) * yyt, rec,4855 DpiScrollDC(Canvas.Handle, (xwd - xw) * (xxt * 2), (ywd - yw) * yyt, rec, 4181 4856 rec, 0, nil); 4182 4857 {$ENDIF} 4183 {$IFDEF LINUX}4858 {$IFDEF UNIX} 4184 4859 DpiScrollDC(Canvas, (xwd - xw) * (xxt * 2), (ywd - yw) * yyt, 4185 4860 rec, rec, 0, nil); … … 4231 4906 xwd := xw; 4232 4907 ywd := yw; 4233 MapValid := true;4908 MapValid := True; 4234 4909 end; 4235 4910 … … 4264 4939 begin 4265 4940 with MainMap do begin 4266 DpiBit Canvas(Panel.Canvas, xMini + 2, yMini + 2, G.lx * 2, G.ly,4941 DpiBitBltCanvas(Panel.Canvas, xMini + 2, yMini + 2, G.lx * 2, G.ly, 4267 4942 MiniMap.Bitmap.Canvas, 0, 0); 4268 4943 if MarkCityLoc >= 0 then … … 4288 4963 function MovementToString(var Un: TUn): string; 4289 4964 begin 4290 result := ScreenTools.MovementToString(Un.Movement);4965 Result := ScreenTools.MovementToString(Un.Movement); 4291 4966 if Un.Master >= 0 then 4292 result := '(' + result + ')'4967 Result := '(' + Result + ')' 4293 4968 else if (MyModel[Un.mix].Domain = dAir) and 4294 4969 (MyModel[Un.mix].Kind <> mkSpecial_Glider) then 4295 result := Format('%s(%d)', [result, Un.Fuel]);4970 Result := Format('%s(%d)', [Result, Un.Fuel]); 4296 4971 end; 4297 4972 4298 4973 var 4299 i, uix, uixDefender, x, xSrc, ySrc, xSrcBase, ySrcBase, CostFactor, Count,4974 I, uix, uixDefender, X, xSrc, ySrc, xSrcBase, ySrcBase, CostFactor, Count, 4300 4975 mixShow, xTreasurySection, xResearchSection, JobFocus, TrueMoney, 4301 TrueResearch: integer;4976 TrueResearch: Integer; 4302 4977 Tile: Cardinal; 4303 s: string;4978 S: string; 4304 4979 unx: TUn; 4305 4980 UnitInfo: TUnitInfo; 4306 4981 JobProgressData: TJobProgressData; 4307 Prio: boolean;4982 Prio: Boolean; 4308 4983 begin 4309 4984 if not Assigned(MyRO) then Exit; … … 4349 5024 if ClientMode <> cEditMap then 4350 5025 begin 4351 if supervising then5026 if Supervising then 4352 5027 begin 4353 5028 ScreenTools.Frame(Panel.Canvas, ClientWidth - xPalace - 1, yPalace - 1, … … 4357 5032 ClientWidth - xPalace + xSizeBig + 1, yPalace + ySizeBig + 1, 4358 5033 $FFFFFF, $B0B0B0); 4359 DpiBit Canvas(Panel.Canvas, ClientWidth - xPalace, yPalace, xSizeBig,5034 DpiBitBltCanvas(Panel.Canvas, ClientWidth - xPalace, yPalace, xSizeBig, 4360 5035 ySizeBig, HGrSystem2.Data.Canvas, 70, 123); 4361 5036 end … … 4382 5057 CopyMiniToPanel; 4383 5058 if ClientMode <> cEditMap then // MapBtn icons 4384 for i:= 0 to 5 do4385 if i<> 3 then4386 Dump(Panel, HGrSystem, xMini + G.lx - 42 + 16 * i, PanelHeight - 26,4387 8, 8, 121 + i* 9, 61);5059 for I := 0 to 5 do 5060 if I <> 3 then 5061 Dump(Panel, HGrSystem, xMini + G.lx - 42 + 16 * I, PanelHeight - 26, 5062 8, 8, 121 + I * 9, 61); 4388 5063 4389 5064 if ClientMode = cEditMap then 4390 5065 begin 4391 for i:= 0 to TrRow - 1 do4392 trix[ i] := -1;5066 for I := 0 to TrRow - 1 do 5067 trix[I] := -1; 4393 5068 Count := 0; 4394 for i:= 0 to nBrushTypes - 1 do5069 for I := 0 to nBrushTypes - 1 do 4395 5070 begin // display terrain types 4396 5071 if (Count >= TrRow * sb.Position) and (Count < TrRow * (sb.Position + 1)) 4397 5072 then 4398 5073 begin 4399 trix[Count - TrRow * sb.Position] := BrushTypes[ i];4400 x:= (Count - TrRow * sb.Position) * TrPitch;5074 trix[Count - TrRow * sb.Position] := BrushTypes[I]; 5075 X := (Count - TrRow * sb.Position) * TrPitch; 4401 5076 xSrcBase := -1; 4402 case BrushTypes[ i] of5077 case BrushTypes[I] of 4403 5078 0 .. 8: 4404 5079 begin 4405 xSrc := BrushTypes[ i];5080 xSrc := BrushTypes[I]; 4406 5081 ySrc := 0 4407 5082 end; … … 4411 5086 ySrcBase := 2; 4412 5087 xSrc := 0; 4413 ySrc := 2 * integer(BrushTypes[i]) - 155088 ySrc := 2 * Integer(BrushTypes[I]) - 15 4414 5089 end; 4415 5090 fRiver: … … 4444 5119 ySrcBase := 2; 4445 5120 xSrc := 8; 4446 ySrc := 12 + BrushTypes[ i] shr 25;5121 ySrc := 12 + BrushTypes[I] shr 25; 4447 5122 end; 4448 5123 tiIrrigation, tiFarm, tiMine, tiBase: 4449 5124 begin 4450 xSrc := BrushTypes[ i] shr 12 - 1;5125 xSrc := BrushTypes[I] shr 12 - 1; 4451 5126 ySrc := 12 4452 5127 end; … … 4471 5146 with MainMap do begin 4472 5147 if xSrcBase >= 0 then 4473 Sprite(Panel, HGrTerrain, xTroop + 2 + x, yTroop + 9 - yyt, xxt * 2,5148 Sprite(Panel, HGrTerrain, xTroop + 2 + X, yTroop + 9 - yyt, xxt * 2, 4474 5149 yyt * 3, 1 + xSrcBase * (xxt * 2 + 1), 4475 5150 1 + ySrcBase * (yyt * 3 + 1)); 4476 Sprite(Panel, HGrTerrain, xTroop + 2 + x, yTroop + 9 - yyt, xxt * 2,5151 Sprite(Panel, HGrTerrain, xTroop + 2 + X, yTroop + 9 - yyt, xxt * 2, 4477 5152 yyt * 3, 1 + xSrc * (xxt * 2 + 1), 1 + ySrc * (yyt * 3 + 1)); 4478 if BrushTypes[ i] = BrushType then begin4479 ScreenTools.Frame(Panel.Canvas, xTroop + 2 + x,4480 yTroop + 7 - yyt div 2, xTroop + 2 * xxt + x,5153 if BrushTypes[I] = BrushType then begin 5154 ScreenTools.Frame(Panel.Canvas, xTroop + 2 + X, 5155 yTroop + 7 - yyt div 2, xTroop + 2 * xxt + X, 4481 5156 yTroop + 2 * yyt + 11, $000000, $000000); 4482 ScreenTools.Frame(Panel.Canvas, xTroop + 1 + x,4483 yTroop + 6 - yyt div 2, xTroop + 2 * xxt - 1 + x,5157 ScreenTools.Frame(Panel.Canvas, xTroop + 1 + X, 5158 yTroop + 6 - yyt div 2, xTroop + 2 * xxt - 1 + X, 4484 5159 yTroop + 2 * yyt + 10, MainTexture.ColorMark, MainTexture.ColorMark); 4485 5160 end; 4486 5161 end; 4487 5162 end; 4488 inc(Count)5163 Inc(Count) 4489 5164 end; 4490 5165 case BrushType of 4491 5166 fDesert, fPrairie, fTundra, fArctic, fSwamp, fHills, fMountains: 4492 s:= Phrases.Lookup('TERRAIN', BrushType);5167 S := Phrases.Lookup('TERRAIN', BrushType); 4493 5168 fShore: 4494 s:= Format(Phrases.Lookup('TWOTERRAINS'),5169 S := Format(Phrases.Lookup('TWOTERRAINS'), 4495 5170 [Phrases.Lookup('TERRAIN', fOcean), Phrases.Lookup('TERRAIN', 4496 5171 fShore)]); 4497 5172 fGrass: 4498 s:= Format(Phrases.Lookup('TWOTERRAINS'),5173 S := Format(Phrases.Lookup('TWOTERRAINS'), 4499 5174 [Phrases.Lookup('TERRAIN', fGrass), Phrases.Lookup('TERRAIN', 4500 5175 fGrass + 12)]); 4501 5176 fForest: 4502 s:= Format(Phrases.Lookup('TWOTERRAINS'),5177 S := Format(Phrases.Lookup('TWOTERRAINS'), 4503 5178 [Phrases.Lookup('TERRAIN', fForest), Phrases.Lookup('TERRAIN', 4504 5179 fJungle)]); 4505 5180 fRiver: 4506 s:= Phrases.Lookup('RIVER');5181 S := Phrases.Lookup('RIVER'); 4507 5182 fDeadLands, fDeadLands or fCobalt, fDeadLands or fUranium, 4508 5183 fDeadLands or fMercury: 4509 s:= Phrases.Lookup('TERRAIN', 3 * 12 + BrushType shr 25);5184 S := Phrases.Lookup('TERRAIN', 3 * 12 + BrushType shr 25); 4510 5185 fPrefStartPos: 4511 s:= Phrases.Lookup('MAP_PREFSTART');5186 S := Phrases.Lookup('MAP_PREFSTART'); 4512 5187 fStartPos: 4513 s:= Phrases.Lookup('MAP_START');5188 S := Phrases.Lookup('MAP_START'); 4514 5189 fPoll: 4515 s:= Phrases.Lookup('POLL');5190 S := Phrases.Lookup('POLL'); 4516 5191 else // terrain improvements 4517 5192 begin 4518 5193 case BrushType of 4519 5194 fRoad: 4520 i:= 1;5195 I := 1; 4521 5196 fRR: 4522 i:= 2;5197 I := 2; 4523 5198 tiIrrigation: 4524 i:= 4;5199 I := 4; 4525 5200 tiFarm: 4526 i:= 5;5201 I := 5; 4527 5202 tiMine: 4528 i:= 7;5203 I := 7; 4529 5204 fCanal: 4530 i:= 8;5205 I := 8; 4531 5206 tiFort: 4532 i:= 10;5207 I := 10; 4533 5208 tiBase: 4534 i:= 12;5209 I := 12; 4535 5210 end; 4536 s := Phrases.Lookup('JOBRESULT', i);5211 S := Phrases.Lookup('JOBRESULT', I); 4537 5212 end 4538 5213 end; 4539 5214 LoweredTextOut(Panel.Canvas, -1, MainTexture, xTroop + 1, 4540 PanelHeight - 19, s);5215 PanelHeight - 19, S); 4541 5216 end 4542 5217 else if TroopLoc >= 0 then … … 4544 5219 Brush.Style := bsClear; 4545 5220 if UnFocus >= 0 then 4546 with MyUn [UnFocus] do4547 with MyModel [mix] do5221 with MyUn^[UnFocus] do 5222 with MyModel^[mix] do 4548 5223 begin { display info about selected unit } 4549 5224 if Job = jCity then … … 4551 5226 else 4552 5227 mixShow := mix; 4553 with Tribe[ me].ModelPicture[mixShow] do5228 with Tribe[Me].ModelPicture[mixShow] do 4554 5229 begin 4555 5230 Sprite(Panel, HGr, xMidPanel + 7 + 12, yTroop + 1, 64, 48, … … 4561 5236 4562 5237 MakeBlue(Panel, xMidPanel + 7 + 12 + 10, yTroop - 13, 44, 12); 4563 s:= MovementToString(MyUn[UnFocus]);5238 S := MovementToString(MyUn[UnFocus]); 4564 5239 RisedTextOut(Panel.Canvas, xMidPanel + 7 + 12 + 32 - 4565 BiColorTextWidth(Panel.Canvas, s) div 2, yTroop - 16, s);4566 4567 s:= IntToStr(Health) + '%';5240 BiColorTextWidth(Panel.Canvas, S) div 2, yTroop - 16, S); 5241 5242 S := IntToStr(Health) + '%'; 4568 5243 LightGradient(Panel.Canvas, xMidPanel + 7 + 12 + 7, PanelHeight - 22, 4569 5244 (Health + 1) div 2, (ColorOfHealth(Health) and $FEFEFE shr 2) * 3); … … 4572 5247 div 2, PanelHeight - 22, 50 - (Health + 1) div 2, $000000); 4573 5248 RisedTextOut(Panel.Canvas, xMidPanel + 7 + 12 + 32 - 4574 BiColorTextWidth(Panel.Canvas, s) div 2, PanelHeight - 23, s);5249 BiColorTextWidth(Panel.Canvas, S) div 2, PanelHeight - 23, S); 4575 5250 4576 5251 FrameImage(Panel.Canvas, HGrSystem.Data, … … 4578 5253 121 + Exp div ExpCost * 13, 28); 4579 5254 if Job = jCity then 4580 s := Tribe[me].ModelName[-1]5255 S := Tribe[Me].ModelName[-1] 4581 5256 else 4582 s := Tribe[me].ModelName[mix];5257 S := Tribe[Me].ModelName[mix]; 4583 5258 if Home >= 0 then 4584 5259 begin 4585 5260 LoweredTextOut(Panel.Canvas, -1, MainTexture, 4586 xMidPanel + 7 + xUnitText + 18, yTroop + 5, s);5261 xMidPanel + 7 + xUnitText + 18, yTroop + 5, S); 4587 5262 LoweredTextOut(Panel.Canvas, -1, MainTexture, 4588 5263 xMidPanel + 7 + xUnitText + 18, yTroop + 21, … … 4591 5266 else 4592 5267 LoweredTextOut(Panel.Canvas, -1, MainTexture, 4593 xMidPanel + 7 + xUnitText + 18, yTroop + 13, s);5268 xMidPanel + 7 + xUnitText + 18, yTroop + 13, S); 4594 5269 end; 4595 5270 4596 5271 if (UnFocus >= 0) and (MyUn[UnFocus].Loc <> TroopLoc) then 4597 5272 begin // divide panel 4598 if SmallScreen and not supervising then4599 x:= xTroop - 85273 if SmallScreen and not Supervising then 5274 X := xTroop - 8 4600 5275 else 4601 x:= xTroop - 152;5276 X := xTroop - 152; 4602 5277 Pen.Color := MainTexture.ColorBevelShade; 4603 MoveTo( x- 1, PanelHeight - MidPanelHeight + 2);4604 LineTo( x- 1, PanelHeight);5278 MoveTo(X - 1, PanelHeight - MidPanelHeight + 2); 5279 LineTo(X - 1, PanelHeight); 4605 5280 Pen.Color := MainTexture.ColorBevelLight; 4606 MoveTo( x, PanelHeight - MidPanelHeight + 2);4607 LineTo( x, PanelHeight);4608 end; 4609 4610 for i:= 0 to 23 do4611 trix[ i] := -1;5281 MoveTo(X, PanelHeight - MidPanelHeight + 2); 5282 LineTo(X, PanelHeight); 5283 end; 5284 5285 for I := 0 to 23 do 5286 trix[I] := -1; 4612 5287 if MyMap[TroopLoc] and fUnit <> 0 then 4613 5288 begin … … 4619 5294 LoweredTextOut(Panel.Canvas, -1, MainTexture, xTroop + 10, 4620 5295 PanelHeight - 24, Phrases.Lookup('PRESENT')); 4621 Server(sGetDefender, me, TroopLoc, uixDefender);5296 Server(sGetDefender, Me, TroopLoc, uixDefender); 4622 5297 Count := 0; 4623 for Prio := true downto false do5298 for Prio := True downto False do 4624 5299 for uix := 0 to MyRO.nUn - 1 do 4625 5300 if (uix = uixDefender) = Prio then … … 4632 5307 begin 4633 5308 trix[Count - TrRow * sb.Position] := uix; 4634 MakeUnitInfo( me, unx, UnitInfo);4635 x:= (Count - TrRow * sb.Position) * TrPitch;5309 MakeUnitInfo(Me, unx, UnitInfo); 5310 X := (Count - TrRow * sb.Position) * TrPitch; 4636 5311 if uix = UnFocus then 4637 5312 begin 4638 ScreenTools.Frame(Panel.Canvas, xTroop + 4 + x,4639 yTroop + 3, xTroop + 64 + x, yTroop + 47,5313 ScreenTools.Frame(Panel.Canvas, xTroop + 4 + X, 5314 yTroop + 3, xTroop + 64 + X, yTroop + 47, 4640 5315 $000000, $000000); 4641 ScreenTools.Frame(Panel.Canvas, xTroop + 3 + x,4642 yTroop + 2, xTroop + 63 + x, yTroop + 46,5316 ScreenTools.Frame(Panel.Canvas, xTroop + 3 + X, 5317 yTroop + 2, xTroop + 63 + X, yTroop + 46, 4643 5318 MainTexture.ColorMark, MainTexture.ColorMark); 4644 5319 end 4645 5320 else if (unx.Master >= 0) and (unx.Master = UnFocus) then 4646 5321 begin 4647 CFrame(Panel.Canvas, xTroop + 4 + x, yTroop + 3,4648 xTroop + 64 + x, yTroop + 47, 8, $000000);4649 CFrame(Panel.Canvas, xTroop + 3 + x, yTroop + 2,4650 xTroop + 63 + x, yTroop + 46, 8, MainTexture.ColorMark);5322 CFrame(Panel.Canvas, xTroop + 4 + X, yTroop + 3, 5323 xTroop + 64 + X, yTroop + 47, 8, $000000); 5324 CFrame(Panel.Canvas, xTroop + 3 + X, yTroop + 2, 5325 xTroop + 63 + X, yTroop + 46, 8, MainTexture.ColorMark); 4651 5326 end; 4652 5327 NoMapPanel.SetOutput(Panel); 4653 NoMapPanel.PaintUnit(xTroop + 2 + x, yTroop + 1, UnitInfo,5328 NoMapPanel.PaintUnit(xTroop + 2 + X, yTroop + 1, UnitInfo, 4654 5329 unx.Status); 4655 5330 if (ClientMode < scContact) and … … 4657 5332 (unx.Status and (usStay or usRecover or usGoto) <> 0)) 4658 5333 then 4659 Sprite(Panel, HGrSystem, xTroop + 2 + 60 - 20 + x,5334 Sprite(Panel, HGrSystem, xTroop + 2 + 60 - 20 + X, 4660 5335 yTroop + 35, 20, 20, 81, 25); 4661 5336 4662 if not supervising then5337 if not Supervising then 4663 5338 begin 4664 MakeBlue(Panel, xTroop + 2 + 10 + x,5339 MakeBlue(Panel, xTroop + 2 + 10 + X, 4665 5340 yTroop - 13, 44, 12); 4666 s:= MovementToString(unx);5341 S := MovementToString(unx); 4667 5342 RisedTextOut(Panel.Canvas, 4668 xTroop + x + 34 - BiColorTextWidth(Panel.Canvas, s)4669 div 2, yTroop - 16, s);5343 xTroop + X + 34 - BiColorTextWidth(Panel.Canvas, S) 5344 div 2, yTroop - 16, S); 4670 5345 end; 4671 5346 end; 4672 inc(Count)5347 Inc(Count) 4673 5348 end; 4674 5349 end; // for uix:=0 to MyRO.nUn-1 4675 assert(Count = TrCnt);5350 Assert(Count = TrCnt); 4676 5351 end; 4677 5352 end … … 4680 5355 LoweredTextOut(Panel.Canvas, -1, MainTexture, xTroop + 8, 4681 5356 PanelHeight - 24, Phrases.Lookup('PRESENT')); 4682 Server(sGetUnits, me, TroopLoc, Count);4683 for i:= 0 to Count - 1 do4684 if ( i >= TrRow * sb.Position) and (i< TrRow * (sb.Position + 1)) then5357 Server(sGetUnits, Me, TroopLoc, Count); 5358 for I := 0 to Count - 1 do 5359 if (I >= TrRow * sb.Position) and (I < TrRow * (sb.Position + 1)) then 4685 5360 begin // display enemy units 4686 trix[ i - TrRow * sb.Position] := i;4687 x := (i- TrRow * sb.Position) * TrPitch;5361 trix[I - TrRow * sb.Position] := I; 5362 X := (I - TrRow * sb.Position) * TrPitch; 4688 5363 NoMapPanel.SetOutput(Panel); 4689 NoMapPanel.PaintUnit(xTroop + 2 + x, yTroop + 1,4690 MyRO.EnemyUn[MyRO.nEnemyUn + i], 0);5364 NoMapPanel.PaintUnit(xTroop + 2 + X, yTroop + 1, 5365 MyRO.EnemyUn[MyRO.nEnemyUn + I], 0); 4691 5366 end; 4692 5367 end; 4693 5368 end; 4694 if not SmallScreen or supervising then5369 if not SmallScreen or Supervising then 4695 5370 begin // show terrain and improvements 4696 5371 with NoMapPanel do … … 4698 5373 if (UnFocus >= 0) and (MyUn[UnFocus].Job <> jNone) then begin 4699 5374 JobFocus := MyUn[UnFocus].Job; 4700 Server(sGetJobProgress, me, MyUn[UnFocus].Loc, JobProgressData);5375 Server(sGetJobProgress, Me, MyUn[UnFocus].Loc, JobProgressData); 4701 5376 MakeBlue(Panel, xTerrain - 72, 148 - 17, 144, 31); 4702 5377 PaintRelativeProgressBar(Panel.Canvas, 3, xTerrain - 68, 148 + 3, 63, 4703 5378 JobProgressData[JobFocus].Done, 4704 5379 JobProgressData[JobFocus].NextTurnPlus, 4705 JobProgressData[JobFocus].Required, true, MainTexture);4706 s:= Format('%s/%s',5380 JobProgressData[JobFocus].Required, True, MainTexture); 5381 S := Format('%s/%s', 4707 5382 [ScreenTools.MovementToString(JobProgressData[JobFocus].Done), 4708 5383 ScreenTools.MovementToString(JobProgressData[JobFocus].Required)]); 4709 RisedTextOut(Panel.Canvas, xTerrain + 6, 148 - 3, s);5384 RisedTextOut(Panel.Canvas, xTerrain + 6, 148 - 3, S); 4710 5385 Tile := MyMap[MyUn[UnFocus].Loc]; 4711 5386 if (JobFocus = jRoad) and (Tile and fRiver <> 0) then … … 4722 5397 JobFocus := nJob + 4 4723 5398 end; 4724 s:= Phrases.Lookup('JOBRESULT', JobFocus);5399 S := Phrases.Lookup('JOBRESULT', JobFocus); 4725 5400 RisedTextOut(Panel.Canvas, xTerrain - BiColorTextWidth(Panel.Canvas, 4726 s) div 2, 148 - 19, s);5401 S) div 2, 148 - 19, S); 4727 5402 end; 4728 5403 if MyMap[TroopLoc] and (fTerrain or fSpecial) = fGrass or fSpecial1 then 4729 s:= Phrases.Lookup('TERRAIN', fGrass + 12)5404 S := Phrases.Lookup('TERRAIN', fGrass + 12) 4730 5405 else if MyMap[TroopLoc] and fDeadLands <> 0 then 4731 s:= Phrases.Lookup('TERRAIN', 3 * 12)5406 S := Phrases.Lookup('TERRAIN', 3 * 12) 4732 5407 else if (MyMap[TroopLoc] and fTerrain = fForest) and 4733 5408 IsJungle(TroopLoc div G.lx) then 4734 s:= Phrases.Lookup('TERRAIN', fJungle)5409 S := Phrases.Lookup('TERRAIN', fJungle) 4735 5410 else 4736 s:= Phrases.Lookup('TERRAIN', MyMap[TroopLoc] and fTerrain);4737 RisedTextOut(Panel.Canvas, xTerrain - BiColorTextWidth(Panel.Canvas, s)4738 div 2, 99, s);5411 S := Phrases.Lookup('TERRAIN', MyMap[TroopLoc] and fTerrain); 5412 RisedTextOut(Panel.Canvas, xTerrain - BiColorTextWidth(Panel.Canvas, S) 5413 div 2, 99, S); 4739 5414 end; 4740 5415 … … 4747 5422 end; 4748 5423 4749 for i:= 0 to ControlCount - 1 do4750 if Controls[ i] is TButtonB then4751 with TButtonB(Controls[ i]) do5424 for I := 0 to ControlCount - 1 do 5425 if Controls[I] is TButtonB then 5426 with TButtonB(Controls[I]) do 4752 5427 begin 4753 5428 if Visible then … … 4765 5440 if ClientMode <> cEditMap then 4766 5441 begin 4767 for i:= 0 to ControlCount - 1 do4768 if Controls[ i] is TButtonC then4769 with TButtonC(Controls[ i]) do5442 for I := 0 to ControlCount - 1 do 5443 if Controls[I] is TButtonC then 5444 with TButtonC(Controls[I]) do 4770 5445 begin 4771 5446 Dump(Panel, HGrSystem, Left, Top - self.ClientHeight + PanelHeight, … … 4807 5482 TrueMoney := MyRO.Money; 4808 5483 TrueResearch := MyRO.Research; 4809 if supervising then5484 if Supervising then 4810 5485 begin // normalize values from after-turn state 4811 dec(TrueMoney, TaxSum);5486 Dec(TrueMoney, TaxSum); 4812 5487 if TrueMoney < 0 then 4813 5488 TrueMoney := 0; // shouldn't happen 4814 dec(TrueResearch, ScienceSum);5489 Dec(TrueResearch, ScienceSum); 4815 5490 if TrueResearch < 0 then 4816 5491 TrueResearch := 0; // shouldn't happen … … 4820 5495 ImageOp_BCC(TopBar, Templates.Data, Point(xTreasurySection + 8, 1), TreasuryIcon.BoundsRect, 4821 5496 $40A040, $4030C0); 4822 s:= IntToStr(TrueMoney);5497 S := IntToStr(TrueMoney); 4823 5498 LoweredTextOut(TopBar.Canvas, -1, MainTexture, xTreasurySection + 48, 0, 4824 s+ '%c');5499 S + '%c'); 4825 5500 if MyRO.Government <> gAnarchy then 4826 5501 begin … … 4828 5503 $0000C0, $0080C0); 4829 5504 if TaxSum >= 0 then 4830 s:= Format(Phrases.Lookup('MONEYGAINPOS'), [TaxSum])5505 S := Format(Phrases.Lookup('MONEYGAINPOS'), [TaxSum]) 4831 5506 else 4832 s:= Format(Phrases.Lookup('MONEYGAINNEG'), [TaxSum]);5507 S := Format(Phrases.Lookup('MONEYGAINNEG'), [TaxSum]); 4833 5508 LoweredTextOut(TopBar.Canvas, -1, MainTexture, xTreasurySection + 48 + 4834 15, 18, s);5509 15, 18, S); 4835 5510 end; 4836 5511 … … 4852 5527 else 4853 5528 CostFactor := 2; 4854 Server(sGetTechCost, me, 0, i);5529 Server(sGetTechCost, Me, 0, I); 4855 5530 CostFactor := CostFactor * 22; // length of progress bar 4856 5531 PaintRelativeProgressBar(TopBar.Canvas, 2, xResearchSection + 48 + 1, 26, 4857 CostFactor, TrueResearch, ScienceSum, i, true, MainTexture);5532 CostFactor, TrueResearch, ScienceSum, I, True, MainTexture); 4858 5533 4859 5534 if MyRO.ResearchTech < 0 then 4860 s:= Phrases.Lookup('SCIENCE')5535 S := Phrases.Lookup('SCIENCE') 4861 5536 else if MyRO.ResearchTech = adMilitary then 4862 s:= Phrases.Lookup('INITUNIT')5537 S := Phrases.Lookup('INITUNIT') 4863 5538 else 4864 5539 begin 4865 s:= Phrases.Lookup('ADVANCES', MyRO.ResearchTech);5540 S := Phrases.Lookup('ADVANCES', MyRO.ResearchTech); 4866 5541 if MyRO.ResearchTech in FutureTech then 4867 5542 if MyRO.Tech[MyRO.ResearchTech] >= 1 then 4868 s := s+ ' ' + IntToStr(MyRO.Tech[MyRO.ResearchTech] + 1)5543 S := S + ' ' + IntToStr(MyRO.Tech[MyRO.ResearchTech] + 1) 4869 5544 else 4870 s := s+ ' 1';5545 S := S + ' 1'; 4871 5546 end; 4872 5547 if ScienceSum > 0 then 4873 5548 begin 4874 5549 { j:=(i-MyRO.Research-1) div ScienceSum +1; 4875 if j<1 then j:=1;4876 if j>1 then4877 s:=Format(Phrases.Lookup('TECHWAIT'),[s,j]); }5550 if J<1 then J:=1; 5551 if J>1 then 5552 S:=Format(Phrases.Lookup('TECHWAIT'),[S,J]); } 4878 5553 LoweredTextOut(TopBar.Canvas, -1, MainTexture, 4879 xResearchSection + 48, 0, s);5554 xResearchSection + 48, 0, S); 4880 5555 end 4881 5556 else 4882 5557 LoweredTextOut(TopBar.Canvas, -1, MainTexture, 4883 xResearchSection + 48, 0, s);5558 xResearchSection + 48, 0, S); 4884 5559 end 4885 5560 else … … 4889 5564 ImageOp_BCC(TopBar, Templates.Data, Point(xResearchSection + 48 + CostFactor + 11, 4890 5565 22), ChangeIcon.BoundsRect, $0000C0, $0080C0); 4891 s:= Format(Phrases.Lookup('TECHGAIN'), [ScienceSum]);5566 S := Format(Phrases.Lookup('TECHGAIN'), [ScienceSum]); 4892 5567 LoweredTextOut(TopBar.Canvas, -1, MainTexture, xResearchSection + 48 + 4893 CostFactor + 26, 18, s);5568 CostFactor + 26, 18, S); 4894 5569 end; 4895 5570 end; … … 4897 5572 begin 4898 5573 TopBar.Canvas.Font.Assign(UniFont[ftCaption]); 4899 s:= TurnToString(MyRO.Turn);5574 S := TurnToString(MyRO.Turn); 4900 5575 RisedTextOut(TopBar.Canvas, 4901 40 + (xTreasurySection - 40 - BiColorTextWidth(TopBar.Canvas, s))4902 div 2, 6, s);5576 40 + (xTreasurySection - 40 - BiColorTextWidth(TopBar.Canvas, S)) 5577 div 2, 6, S); 4903 5578 TopBar.Canvas.Font.Assign(UniFont[ftNormal]); 4904 5579 end; … … 4908 5583 procedure TMainScreen.FocusNextUnit(Dir: Integer); 4909 5584 var 4910 i, uix, NewFocus: Integer;5585 I, uix, NewFocus: Integer; 4911 5586 begin 4912 5587 if ClientMode >= scContact then … … 4915 5590 PaintDestination; 4916 5591 NewFocus := -1; 4917 for i:= 1 to MyRO.nUn do begin4918 uix := (UnFocus + i* Dir + MyRO.nUn) mod MyRO.nUn;5592 for I := 1 to MyRO.nUn do begin 5593 uix := (UnFocus + I * Dir + MyRO.nUn) mod MyRO.nUn; 4919 5594 if (MyUn[uix].Loc >= 0) and (MyUn[uix].Status and usStay = 0) then begin 4920 5595 NewFocus := uix; … … 4929 5604 end; 4930 5605 4931 procedure TMainScreen.FocusOnLoc(Loc: integer; Options: integer = 0);5606 procedure TMainScreen.FocusOnLoc(Loc: Integer; Options: Integer = 0); 4932 5607 var 4933 dx: integer;4934 Outside, Changed: boolean;5608 dx: Integer; 5609 Outside, Changed: Boolean; 4935 5610 begin 4936 5611 with MainMap do begin … … 4940 5615 (Loc div G.lx >= yw + (MapHeight - 1) div yyt - 2)); 4941 5616 end; 4942 Changed := true;5617 Changed := True; 4943 5618 if Outside then begin 4944 5619 Centre(Loc); … … 4948 5623 PaintAllMaps 4949 5624 else 4950 Changed := false;5625 Changed := False; 4951 5626 if Options and flRepaintPanel <> 0 then 4952 5627 PanelPaint; … … 4958 5633 var 4959 5634 Dist, TestDist: Single; 4960 i, uix, NewFocus: Integer;5635 I, uix, NewFocus: Integer; 4961 5636 GotoOnly: Boolean; 4962 5637 begin … … 4968 5643 for GotoOnly := GoOnPhase downto False do begin 4969 5644 NewFocus := -1; 4970 for i:= 1 to MyRO.nUn do begin4971 uix := (UnFocus + i) mod MyRO.nUn;5645 for I := 1 to MyRO.nUn do begin 5646 uix := (UnFocus + I) mod MyRO.nUn; 4972 5647 if (MyUn[uix].Loc >= 0) and (MyUn[uix].Job = jNone) and 4973 5648 (MyUn[uix].Status and (usStay or usRecover or usWaiting) = usWaiting) … … 5008 5683 end; 5009 5684 5010 procedure TMainScreen.Scroll(dx, dy: integer);5685 procedure TMainScreen.Scroll(dx, dy: Integer); 5011 5686 begin 5012 5687 xw := (xw + G.lx + dx) mod G.lx; … … 5032 5707 procedure TMainScreen.Timer1Timer(Sender: TObject); 5033 5708 var 5034 dx, dy, ScrollSpeed: integer;5035 begin 5036 if idle and (me >= 0) and (GameMode <> cMovie) then5709 dx, dy, ScrollSpeed: Integer; 5710 begin 5711 if Idle and (Me >= 0) and (GameMode <> cMovie) then 5037 5712 if (fsModal in DpiScreen.ActiveForm.FormState) or 5038 5713 (DpiScreen.ActiveForm is TBufferedDrawDlg) and … … 5042 5717 if not BlinkON then 5043 5718 begin 5044 BlinkON := true;5719 BlinkON := True; 5045 5720 if UnFocus >= 0 then 5046 5721 PaintLocTemp(MyUn[UnFocus].Loc) 5047 else if TurnComplete and not supervising then5722 else if TurnComplete and not Supervising then 5048 5723 EOT.SetButtonIndexFast(eotBlinkOn); 5049 5724 end; … … 5057 5732 dx := 0; 5058 5733 dy := 0; 5059 if DpiMouse.CursorPos. y< DpiScreen.height - PanelHeight then5060 if DpiMouse.CursorPos. x= 0 then5734 if DpiMouse.CursorPos.Y < DpiScreen.height - PanelHeight then 5735 if DpiMouse.CursorPos.X = 0 then 5061 5736 dx := -ScrollSpeed // scroll left 5062 else if DpiMouse.CursorPos. x= DpiScreen.width - 1 then5737 else if DpiMouse.CursorPos.X = DpiScreen.width - 1 then 5063 5738 dx := ScrollSpeed; // scroll right 5064 if DpiMouse.CursorPos. y= 0 then5739 if DpiMouse.CursorPos.Y = 0 then 5065 5740 dy := -ScrollSpeed // scroll up 5066 else if (DpiMouse.CursorPos. y= DpiScreen.height - 1) and5067 (DpiMouse.CursorPos. x>= TerrainBtn.Left + TerrainBtn.width) and5068 (DpiMouse.CursorPos. x< xRightPanel + 10 - 8) then5741 else if (DpiMouse.CursorPos.Y = DpiScreen.height - 1) and 5742 (DpiMouse.CursorPos.X >= TerrainBtn.Left + TerrainBtn.width) and 5743 (DpiMouse.CursorPos.X < xRightPanel + 10 - 8) then 5069 5744 dy := ScrollSpeed; // scroll down 5070 5745 if (dx <> 0) or (dy <> 0) then … … 5079 5754 BlinkTime := (BlinkTime + 1) mod (BlinkOnTime + BlinkOffTime); 5080 5755 BlinkON := BlinkTime >= BlinkOffTime; 5081 DestinationMarkON := true;5756 DestinationMarkON := True; 5082 5757 if UnFocus >= 0 then 5083 5758 begin … … 5090 5765 end; 5091 5766 end 5092 else if TurnComplete and not supervising then5767 else if TurnComplete and not Supervising then 5093 5768 begin 5094 5769 if BlinkTime = 0 then … … 5100 5775 end; 5101 5776 5102 procedure TMainScreen.SetMapPos(Loc: integer; MapPos: TPoint);5777 procedure TMainScreen.SetMapPos(Loc: Integer; MapPos: TPoint); 5103 5778 begin 5104 5779 with MainMap do begin … … 5118 5793 end; 5119 5794 5120 procedure TMainScreen.Centre(Loc: integer);5795 procedure TMainScreen.Centre(Loc: Integer); 5121 5796 begin 5122 5797 SetMapPos(Loc, Point(MapWidth div 2, MapHeight div 2)); 5123 5798 end; 5124 5799 5125 function TMainScreen.ZoomToCity(Loc: integer; NextUnitOnClose: boolean = false;5126 ShowEvent: integer = 0): boolean;5127 begin 5128 result := MyMap[Loc] and (fOwned or fSpiedOut) <> 0;5129 if result then5800 function TMainScreen.ZoomToCity(Loc: Integer; NextUnitOnClose: Boolean = False; 5801 ShowEvent: Integer = 0): Boolean; 5802 begin 5803 Result := MyMap[Loc] and (fOwned or fSpiedOut) <> 0; 5804 if Result then 5130 5805 with CityDlg do 5131 5806 begin … … 5153 5828 end; 5154 5829 5155 function TMainScreen.LocationOfScreenPixel( x, y: integer): Integer;5830 function TMainScreen.LocationOfScreenPixel(X, Y: Integer): Integer; 5156 5831 var 5157 qx, qy: integer;5832 qx, qy: Integer; 5158 5833 begin 5159 5834 with MainMap do begin 5160 qx := ( x * (yyt * 2) + y* (xxt * 2) + xxt * yyt * 2) div (xxt * yyt * 4) - 1;5161 qy := ( y * (xxt * 2) - x* (yyt * 2) - xxt * yyt * 2 + 4000 * xxt * yyt)5835 qx := (X * (yyt * 2) + Y * (xxt * 2) + xxt * yyt * 2) div (xxt * yyt * 4) - 1; 5836 qy := (Y * (xxt * 2) - X * (yyt * 2) - xxt * yyt * 2 + 4000 * xxt * yyt) 5162 5837 div (xxt * yyt * 4) - 999; 5163 5838 Result := (xw + (qx - qy + 2048) div 2 - 1024 + G.lx) mod G.lx + G.lx * … … 5173 5848 5174 5849 procedure TMainScreen.MapBoxMouseDown(Sender: TObject; Button: TMouseButton; 5175 Shift: TShiftState; x, y: integer);5850 Shift: TShiftState; X, Y: Integer); 5176 5851 var 5177 i, uix, emix, p1, dx, dy, MouseLoc: integer;5852 I, uix, emix, p1, dx, dy, MouseLoc: Integer; 5178 5853 EditTileData: TEditTileData; 5179 m, m2: TDpiMenuItem;5854 M, m2: TDpiMenuItem; 5180 5855 MoveAdviceData: TMoveAdviceData; 5181 DoCenter: boolean;5856 DoCenter: Boolean; 5182 5857 begin 5183 5858 if GameMode = cMovie then 5184 exit;5185 5186 if CityDlg.Visible then5859 Exit; 5860 5861 if Assigned(FCityDlg) and CityDlg.Visible then 5187 5862 CityDlg.Close; 5188 if UnitStatDlg.Visible then5863 if Assigned(FUnitStatDlg) and UnitStatDlg.Visible then 5189 5864 UnitStatDlg.Close; 5190 MouseLoc := LocationOfScreenPixel( x, y);5865 MouseLoc := LocationOfScreenPixel(X, Y); 5191 5866 if (MouseLoc < 0) or (MouseLoc >= G.lx * G.ly) then 5192 exit;5867 Exit; 5193 5868 if (Button = mbLeft) and not(ssShift in Shift) then 5194 5869 begin 5195 DoCenter := true;5870 DoCenter := True; 5196 5871 if ClientMode = cEditMap then 5197 5872 begin 5198 DoCenter := false;5873 DoCenter := False; 5199 5874 EditTileData.Loc := MouseLoc; 5200 5875 if ssCtrl in Shift then // toggle special resource … … 5234 5909 else 5235 5910 EditTileData.NewTile := MyMap[MouseLoc] xor BrushType; 5236 Server(sEditTile, me, 0, EditTileData);5237 Edited := true;5911 Server(sEditTile, Me, 0, EditTileData); 5912 Edited := True; 5238 5913 BrushLoc := MouseLoc; 5239 5914 PaintLoc(MouseLoc, 2); 5240 5915 MiniMapPaint; 5241 DpiBit Canvas(Panel.Canvas, xMini + 2, yMini + 2, G.lx * 2, G.ly,5916 DpiBitBltCanvas(Panel.Canvas, xMini + 2, yMini + 2, G.lx * 2, G.ly, 5242 5917 MiniMap.Bitmap.Canvas, 0, 0); 5243 5918 with MainMap do begin … … 5261 5936 begin 5262 5937 ZoomToCity(MouseLoc); 5263 DoCenter := false;5938 DoCenter := False; 5264 5939 end 5265 5940 else 5266 5941 begin 5267 5942 UnitStatDlg.ShowNewContent_EnemyCity(wmPersistent, MouseLoc); 5268 DoCenter := false;5943 DoCenter := False; 5269 5944 end; 5270 5945 end … … 5272 5947 if MyMap[MouseLoc] and fOwned <> 0 then 5273 5948 begin 5274 DoCenter := false;5275 if not supervising and (ClientMode < scContact) then5949 DoCenter := False; 5950 if not Supervising and (ClientMode < scContact) then 5276 5951 begin // not in negotiation mode 5277 5952 if (UnFocus >= 0) and (MyUn[UnFocus].Loc = MouseLoc) then 5278 5953 begin // rotate 5279 5954 uix := (UnFocus + 1) mod MyRO.nUn; 5280 i:= MyRO.nUn - 1;5281 while i> 0 do5955 I := MyRO.nUn - 1; 5956 while I > 0 do 5282 5957 begin 5283 5958 if (MyUn[uix].Loc = MouseLoc) and (MyUn[uix].Job = jNone) and … … 5285 5960 usWaiting) = usWaiting) then 5286 5961 Break; 5287 dec(i);5962 Dec(I); 5288 5963 uix := (uix + 1) mod MyRO.nUn; 5289 5964 end; 5290 if i= 0 then5965 if I = 0 then 5291 5966 uix := UnFocus; 5292 5967 end 5293 5968 else 5294 Server(sGetDefender, me, MouseLoc, uix);5969 Server(sGetDefender, Me, MouseLoc, uix); 5295 5970 if uix <> UnFocus then 5296 5971 SetUnFocus(uix); 5297 TurnComplete := false;5972 TurnComplete := False; 5298 5973 EOT.ButtonIndex := eotGray; 5299 5974 end; … … 5303 5978 else if (MyMap[MouseLoc] and fSpiedOut <> 0) and not(ssCtrl in Shift) then 5304 5979 begin 5305 DoCenter := false;5980 DoCenter := False; 5306 5981 SetTroopLoc(MouseLoc); 5307 5982 PanelPaint; … … 5309 5984 else 5310 5985 begin 5311 DoCenter := false;5986 DoCenter := False; 5312 5987 UnitStatDlg.ShowNewContent_EnemyLoc(wmPersistent, MouseLoc); 5313 5988 end; … … 5321 5996 not(ssShift in Shift) then 5322 5997 begin 5323 if supervising then5998 if Supervising then 5324 5999 begin 5325 6000 EditLoc := MouseLoc; 5326 Server(sGetModels, me, 0, nil^);6001 Server(sGetModels, Me, 0, nil^); 5327 6002 EmptyMenu(mCreateUnit); 5328 6003 for p1 := 0 to nPl - 1 do 5329 6004 if 1 shl p1 and MyRO.Alive <> 0 then 5330 6005 begin 5331 m:= TDpiMenuItem.Create(mCreateUnit);5332 m.Caption := Tribe[p1].TPhrase('SHORTNAME');6006 M := TDpiMenuItem.Create(mCreateUnit); 6007 M.Caption := Tribe[p1].TPhrase('SHORTNAME'); 5333 6008 for emix := MyRO.nEnemyModel - 1 downto 0 do 5334 6009 if (MyRO.EnemyModel[emix].Owner = p1) and 5335 (Server(sCreateUnit - sExecute + p1 shl 4, me,6010 (Server(sCreateUnit - sExecute + p1 shl 4, Me, 5336 6011 MyRO.EnemyModel[emix].mix, MouseLoc) >= rExecuted) then 5337 6012 begin 5338 6013 if not Assigned(Tribe[p1].ModelPicture[MyRO.EnemyModel[emix].mix].HGr) then 5339 6014 InitEnemyModel(emix); 5340 m2 := TDpiMenuItem.Create( m);6015 m2 := TDpiMenuItem.Create(M); 5341 6016 m2.Caption := Tribe[p1].ModelName[MyRO.EnemyModel[emix].mix]; 5342 6017 m2.Tag := p1 shl 16 + MyRO.EnemyModel[emix].mix; 5343 6018 m2.OnClick := CreateUnitClick; 5344 m.Add(m2);6019 M.Add(m2); 5345 6020 end; 5346 m.Visible := m.Count > 0;5347 mCreateUnit.Add( m);6021 M.Visible := M.Count > 0; 6022 mCreateUnit.Add(M); 5348 6023 end; 5349 6024 if FullScreen then 5350 EditPopup.Popup(Left + x, Top + y)6025 EditPopup.Popup(Left + X, Top + Y) 5351 6026 else 5352 EditPopup.Popup(Left + x+ 4,5353 Top + y+ DpiGetSystemMetrics(SM_CYCAPTION) + 4);6027 EditPopup.Popup(Left + X + 4, 6028 Top + Y + DpiGetSystemMetrics(SM_CYCAPTION) + 4); 5354 6029 end 5355 6030 else if (UnFocus >= 0) and (MyUn[UnFocus].Loc <> MouseLoc) then … … 5362 6037 if abs(dx) + abs(dy) < 3 then 5363 6038 begin 5364 DestinationMarkON := false;6039 DestinationMarkON := False; 5365 6040 PaintDestination; 5366 6041 Status := Status and ($FFFF - usStay - usRecover - usGoto - usEnhance) … … 5375 6050 with MyUn[UnFocus], BattleDlg.Forecast do 5376 6051 begin 5377 pAtt := me;6052 pAtt := Me; 5378 6053 mixAtt := mix; 5379 6054 HealthAtt := Health; … … 5382 6057 end; 5383 6058 BattleDlg.Forecast.Movement := MyUn[UnFocus].Movement; 5384 if (Server(sGetBattleForecastEx, me, MouseLoc, BattleDlg.Forecast)6059 if (Server(sGetBattleForecastEx, Me, MouseLoc, BattleDlg.Forecast) 5385 6060 >= rExecuted) and (BattleDlg.Forecast.EndHealthAtt <= 0) then 5386 6061 begin 5387 6062 BattleDlg.uix := UnFocus; 5388 6063 BattleDlg.ToLoc := MouseLoc; 5389 BattleDlg.IsSuicideQuery := true;6064 BattleDlg.IsSuicideQuery := True; 5390 6065 BattleDlg.ShowModal; 5391 6066 if BattleDlg.ModalResult <> mrOK then 5392 exit;6067 Exit; 5393 6068 end; 5394 6069 end; 5395 DestinationMarkON := false;6070 DestinationMarkON := False; 5396 6071 PaintDestination; 5397 6072 Status := Status and not(usStay or usRecover or usEnhance) or 5398 6073 usWaiting; 5399 MoveToLoc(MouseLoc, false); { goto }6074 MoveToLoc(MouseLoc, False); { goto } 5400 6075 end; 5401 6076 end; … … 5404 6079 (MyModel[MyUn[UnFocus].mix].Kind in [mkSettler, mkSlaves]) then 5405 6080 begin 5406 DestinationMarkON := false;6081 DestinationMarkON := False; 5407 6082 PaintDestination; 5408 6083 MyUn[UnFocus].Status := MyUn[UnFocus].Status and … … 5410 6085 uix := UnFocus; 5411 6086 if MouseLoc <> MyUn[uix].Loc then 5412 MoveToLoc(MouseLoc, true); { goto }6087 MoveToLoc(MouseLoc, True); { goto } 5413 6088 if (UnFocus = uix) and (MyUn[uix].Loc = MouseLoc) then 5414 MenuClick(mEnhance);6089 mEnhance.Click; 5415 6090 end 5416 6091 else if (Button = mbLeft) and (ssShift in Shift) and … … 5423 6098 with MyUn[UnFocus], BattleDlg.Forecast do 5424 6099 begin 5425 pAtt := me;6100 pAtt := Me; 5426 6101 mixAtt := mix; 5427 6102 HealthAtt := Health; … … 5430 6105 end; 5431 6106 BattleDlg.Forecast.Movement := MyUn[UnFocus].Movement; 5432 if Server(sGetBattleForecastEx, me, MouseLoc, BattleDlg.Forecast) >= rExecuted6107 if Server(sGetBattleForecastEx, Me, MouseLoc, BattleDlg.Forecast) >= rExecuted 5433 6108 then 5434 6109 begin 5435 6110 BattleDlg.uix := UnFocus; 5436 6111 BattleDlg.ToLoc := MouseLoc; 5437 BattleDlg.Left := x- BattleDlg.width div 2;6112 BattleDlg.Left := X - BattleDlg.width div 2; 5438 6113 if BattleDlg.Left < 0 then 5439 6114 BattleDlg.Left := 0 5440 6115 else if BattleDlg.Left + BattleDlg.width > DpiScreen.width then 5441 6116 BattleDlg.Left := DpiScreen.width - BattleDlg.width; 5442 BattleDlg.Top := y- BattleDlg.height div 2;6117 BattleDlg.Top := Y - BattleDlg.height div 2; 5443 6118 if BattleDlg.Top < 0 then 5444 6119 BattleDlg.Top := 0 5445 6120 else if BattleDlg.Top + BattleDlg.height > DpiScreen.height then 5446 6121 BattleDlg.Top := DpiScreen.height - BattleDlg.height; 5447 BattleDlg.IsSuicideQuery := false;6122 BattleDlg.IsSuicideQuery := False; 5448 6123 BattleDlg.Show; 5449 6124 end; … … 5451 6126 end; 5452 6127 5453 function TMainScreen.MoveUnit(dx, dy: integer; Options: integer): integer;6128 function TMainScreen.MoveUnit(dx, dy: Integer; Options: Integer): Integer; 5454 6129 // move focused unit to adjacent tile 5455 6130 var 5456 i, cix, uix, euix, FromLoc, ToLoc, DirCode, UnFocus0, Defender, Mission, p1,5457 NewTiles, cixChanged: integer;6131 I, cix, uix, euix, FromLoc, ToLoc, DirCode, UnFocus0, Defender, Mission, p1, 6132 NewTiles, cixChanged: Integer; 5458 6133 OldToTile: Cardinal; 5459 6134 CityCaptured, IsAttack, OldUnrest, NewUnrest, NeedEcoUpdate, NeedRepaintPanel, 5460 ToTransport, ToShip: boolean;6135 ToTransport, ToShip: Boolean; 5461 6136 PlaneReturnData: TPlaneReturnData; 5462 6137 QueryItem: string; 5463 6138 begin 5464 result := eInvalid;6139 Result := eInvalid; 5465 6140 UnFocus0 := UnFocus; 5466 6141 FromLoc := MyUn[UnFocus].Loc; … … 5468 6143 if (ToLoc < 0) or (ToLoc >= G.lx * G.ly) then 5469 6144 begin 5470 result := eInvalid;5471 exit;6145 Result := eInvalid; 6146 Exit; 5472 6147 end; 5473 6148 if MyMap[ToLoc] and fStealthUnit <> 0 then 5474 6149 begin 5475 6150 SoundMessage(Phrases.Lookup('ATTACKSTEALTH'), ''); 5476 exit;6151 Exit; 5477 6152 end; 5478 6153 if MyMap[ToLoc] and fHiddenUnit <> 0 then 5479 6154 begin 5480 6155 SoundMessage(Phrases.Lookup('ATTACKSUB'), ''); 5481 exit;6156 Exit; 5482 6157 end; 5483 6158 … … 5489 6164 begin 5490 6165 SoundMessage(Phrases.Lookup('NOATTACKER'), ''); 5491 exit;6166 Exit; 5492 6167 end; 5493 6168 euix := MyRO.nEnemyUn - 1; 5494 6169 while (euix >= 0) and (MyRO.EnemyUn[euix].Loc <> ToLoc) do 5495 dec(euix);6170 Dec(euix); 5496 6171 end; 5497 6172 5498 6173 DirCode := dx and 7 shl 4 + dy and 7 shl 7; 5499 result := Server(sMoveUnit - sExecute + DirCode, me, UnFocus, nil^);5500 if ( result < rExecuted) and (MyUn[UnFocus].Job > jNone) then5501 Server(sStartJob + jNone shl 4, me, UnFocus, nil^);5502 if ( result < rExecuted) and (result <> eNoTime_Move) then5503 begin 5504 case result of6174 Result := Server(sMoveUnit - sExecute + DirCode, Me, UnFocus, nil^); 6175 if (Result < rExecuted) and (MyUn[UnFocus].Job > jNone) then 6176 Server(sStartJob + jNone shl 4, Me, UnFocus, nil^); 6177 if (Result < rExecuted) and (Result <> eNoTime_Move) then 6178 begin 6179 case Result of 5505 6180 eNoTime_Load: 5506 6181 if MyModel[MyUn[UnFocus].mix].Domain = dAir then … … 5538 6213 (MyMap[ToLoc] and (fUnit or fOwned) = fUnit or fOwned) then 5539 6214 begin // false load attempt 5540 ToShip := false;5541 ToTransport := false;6215 ToShip := False; 6216 ToTransport := False; 5542 6217 for uix := 0 to MyRO.nUn - 1 do 5543 6218 if (MyUn[uix].Loc = ToLoc) and 5544 6219 (MyModel[MyUn[uix].mix].Domain = dSea) then 5545 6220 begin 5546 ToShip := true;6221 ToShip := True; 5547 6222 if MyModel[MyUn[uix].mix].Cap[mcSeaTrans] > 0 then 5548 ToTransport := true;6223 ToTransport := True; 5549 6224 end; 5550 6225 if ToTransport then … … 5561 6236 Play('NOMOVE_DEFAULT'); 5562 6237 end; 5563 exit;5564 end; 5565 5566 if (( result = eWon) or (result = eLost) or (result = eBloody)) and6238 Exit; 6239 end; 6240 6241 if ((Result = eWon) or (Result = eLost) or (Result = eBloody)) and 5567 6242 (MyUn[UnFocus].Movement < 100) and 5568 6243 (MyModel[MyUn[UnFocus].mix].Cap[mcWill] = 0) then … … 5571 6246 [MyUn[UnFocus].Movement]), 'NOMOVE_TIME') <> mrOK then 5572 6247 begin 5573 result := eInvalid;5574 exit;6248 Result := eInvalid; 6249 Exit; 5575 6250 end; 5576 6251 Update; // remove message box from screen 5577 6252 end; 5578 6253 5579 OldUnrest := false;5580 NewUnrest := false;5581 if ( result >= rExecuted) and (result and rUnitRemoved = 0) and6254 OldUnrest := False; 6255 NewUnrest := False; 6256 if (Result >= rExecuted) and (Result and rUnitRemoved = 0) and 5582 6257 (MyMap[ToLoc] and (fUnit or fOwned) <> fUnit) then 5583 6258 begin … … 5589 6264 begin 5590 6265 QueryItem := 'UNREST_NOTOWN'; 5591 p1 := me;6266 p1 := Me; 5592 6267 end 5593 6268 else … … 5606 6281 if ModalResult <> mrOK then 5607 6282 begin 5608 result := eInvalid;5609 exit;6283 Result := eInvalid; 6284 Exit; 5610 6285 end; 5611 6286 end; 5612 6287 Update; // remove message box from screen 5613 end 5614 end; 5615 5616 if ( result >= rExecuted) and (MyModel[MyUn[UnFocus].mix].Domain = dAir) and6288 end; 6289 end; 6290 6291 if (Result >= rExecuted) and (MyModel[MyUn[UnFocus].mix].Domain = dAir) and 5617 6292 (MyUn[UnFocus].Status and usToldNoReturn = 0) then 5618 6293 begin // can plane return? … … 5634 6309 PlaneReturnData.Movement := MyUn[UnFocus].Movement - 150; 5635 6310 end; 5636 if Server(sGetPlaneReturn, me, UnFocus, PlaneReturnData) = eNoWay then6311 if Server(sGetPlaneReturn, Me, UnFocus, PlaneReturnData) = eNoWay then 5637 6312 begin 5638 6313 if MyModel[MyUn[UnFocus].mix].Kind = mkSpecial_Glider then … … 5643 6318 <> mrOK then 5644 6319 begin 5645 result := eInvalid;5646 exit;6320 Result := eInvalid; 6321 Exit; 5647 6322 end; 5648 6323 Update; // remove message box from screen 5649 6324 MyUn[UnFocus].Status := MyUn[UnFocus].Status or usToldNoReturn; 5650 end 5651 end; 5652 5653 if result = eMissionDone then6325 end; 6326 end; 6327 6328 if Result = eMissionDone then 5654 6329 begin 5655 6330 ModalSelectDlg.ShowNewContent(wmModal, kMission); 5656 6331 Update; // dialog still on screen 5657 Mission := ModalSelectDlg. result;6332 Mission := ModalSelectDlg.Result; 5658 6333 if Mission < 0 then 5659 exit;5660 Server(sSetSpyMission + Mission shl 4, me, 0, nil^);5661 end; 5662 5663 CityCaptured := false;5664 if result = eNoTime_Move then6334 Exit; 6335 Server(sSetSpyMission + Mission shl 4, Me, 0, nil^); 6336 end; 6337 6338 CityCaptured := False; 6339 if Result = eNoTime_Move then 5665 6340 Play('NOMOVE_TIME') 5666 6341 else 5667 6342 begin 5668 NeedEcoUpdate := false;5669 DestinationMarkON := false;6343 NeedEcoUpdate := False; 6344 DestinationMarkON := False; 5670 6345 PaintDestination; 5671 if result and rUnitRemoved <> 0 then6346 if Result and rUnitRemoved <> 0 then 5672 6347 CityOptimizer_BeforeRemoveUnit(UnFocus); 5673 IsAttack := ( result = eBombarded) or (result <> eMissionDone) and6348 IsAttack := (Result = eBombarded) or (Result <> eMissionDone) and 5674 6349 (MyMap[ToLoc] and (fUnit or fOwned) = fUnit); 5675 6350 if not IsAttack then … … 5677 6352 cix := MyRO.nCity - 1; { look for own city at dest location } 5678 6353 while (cix >= 0) and (MyCity[cix].Loc <> ToLoc) do 5679 dec(cix);5680 if ( result <> eMissionDone) and (MyMap[ToLoc] and fCity <> 0) and (cix < 0)6354 Dec(cix); 6355 if (Result <> eMissionDone) and (MyMap[ToLoc] and fCity <> 0) and (cix < 0) 5681 6356 then 5682 CityCaptured := true;5683 result := Server(sMoveUnit + DirCode, me, UnFocus, nil^);5684 case result of6357 CityCaptured := True; 6358 Result := Server(sMoveUnit + DirCode, Me, UnFocus, nil^); 6359 case Result of 5685 6360 eHiddenUnit: 5686 6361 begin 5687 6362 Play('NOMOVE_SUBMARINE'); 5688 PaintLoc(ToLoc) 6363 PaintLoc(ToLoc); 5689 6364 end; 5690 6365 eStealthUnit: 5691 6366 begin 5692 6367 Play('NOMOVE_STEALTH'); 5693 PaintLoc(ToLoc) 6368 PaintLoc(ToLoc); 5694 6369 end; 5695 6370 eZOC_EnemySpotted: 5696 6371 begin 5697 6372 Play('NOMOVE_ZOC'); 5698 PaintLoc(ToLoc, 1) 6373 PaintLoc(ToLoc, 1); 5699 6374 end; 5700 rExecuted .. maxint:6375 rExecuted..MaxInt: 5701 6376 begin 5702 if result and rUnitRemoved <> 0 then6377 if Result and rUnitRemoved <> 0 then 5703 6378 UnFocus := -1 // unit died 5704 6379 else 5705 6380 begin 5706 assert(UnFocus >= 0);6381 Assert(UnFocus >= 0); 5707 6382 MyUn[UnFocus].Status := MyUn[UnFocus].Status and 5708 6383 not(usStay or usRecover); … … 5714 6389 begin // borders have moved, unrest might have changed in any city 5715 6390 CityOptimizer_BeginOfTurn; 5716 NeedEcoUpdate := true;6391 NeedEcoUpdate := True; 5717 6392 end 5718 6393 else … … 5724 6399 if MyUn[uix].Master = UnFocus then 5725 6400 CityOptimizer_CityChange(MyUn[uix].Home); 5726 NeedEcoUpdate := true;6401 NeedEcoUpdate := True; 5727 6402 end; 5728 6403 if (MyRO.Government = gDespotism) and … … 5734 6409 while (cixChanged >= 0) and 5735 6410 (MyCity[cixChanged].Loc <> FromLoc) do 5736 dec(cixChanged);5737 assert(cixChanged >= 0);6411 Dec(cixChanged); 6412 Assert(cixChanged >= 0); 5738 6413 if cixChanged >= 0 then 5739 6414 begin 5740 6415 CityOptimizer_CityChange(cixChanged); 5741 NeedEcoUpdate := true;6416 NeedEcoUpdate := True; 5742 6417 end; 5743 6418 end; … … 5747 6422 while (cixChanged >= 0) and 5748 6423 (MyCity[cixChanged].Loc <> ToLoc) do 5749 dec(cixChanged);5750 assert(cixChanged >= 0);6424 Dec(cixChanged); 6425 Assert(cixChanged >= 0); 5751 6426 if cixChanged >= 0 then 5752 6427 begin 5753 6428 CityOptimizer_CityChange(cixChanged); 5754 NeedEcoUpdate := true;6429 NeedEcoUpdate := True; 5755 6430 end; 5756 6431 end; … … 5760 6435 end; 5761 6436 else 5762 assert(false);6437 Assert(False); 5763 6438 end; 5764 6439 SetTroopLoc(ToLoc); … … 5766 6441 else 5767 6442 begin { enemy unit -- attack } 5768 if result = eBombarded then6443 if Result = eBombarded then 5769 6444 Defender := MyRO.Territory[ToLoc] 5770 6445 else … … 5773 6448 if SimpleQuery(mkYesNo,Phrases.Lookup('FRCANCELQUERY_CEASEFIRE'), 5774 6449 'MSG_DEFAULT')<>mrOK then 5775 exit; }5776 if (Options and muNoSuicideCheck = 0) and ( result and rUnitRemoved <> 0)5777 and ( result <> eMissionDone) then6450 Exit; } 6451 if (Options and muNoSuicideCheck = 0) and (Result and rUnitRemoved <> 0) 6452 and (Result <> eMissionDone) then 5778 6453 begin // suicide query 5779 6454 with MyUn[UnFocus], BattleDlg.Forecast do 5780 6455 begin 5781 pAtt := me;6456 pAtt := Me; 5782 6457 mixAtt := mix; 5783 6458 HealthAtt := Health; … … 5786 6461 end; 5787 6462 BattleDlg.Forecast.Movement := MyUn[UnFocus].Movement; 5788 Server(sGetBattleForecastEx, me, ToLoc, BattleDlg.Forecast);6463 Server(sGetBattleForecastEx, Me, ToLoc, BattleDlg.Forecast); 5789 6464 BattleDlg.uix := UnFocus; 5790 6465 BattleDlg.ToLoc := ToLoc; 5791 BattleDlg.IsSuicideQuery := true;6466 BattleDlg.IsSuicideQuery := True; 5792 6467 BattleDlg.ShowModal; 5793 6468 if BattleDlg.ModalResult <> mrOK then 5794 exit;6469 Exit; 5795 6470 end; 5796 6471 5797 6472 cixChanged := -1; 5798 if ( result and rUnitRemoved <> 0) and (MyRO.Government = gDespotism) and6473 if (Result and rUnitRemoved <> 0) and (MyRO.Government = gDespotism) and 5799 6474 (MyModel[MyUn[UnFocus].mix].Kind = mkSpecial_TownGuard) and 5800 6475 (MyMap[FromLoc] and fCity <> 0) then … … 5802 6477 cixChanged := MyRO.nCity - 1; 5803 6478 while (cixChanged >= 0) and (MyCity[cixChanged].Loc <> FromLoc) do 5804 dec(cixChanged);5805 assert(cixChanged >= 0);5806 end; 5807 5808 for i:= 0 to MyRO.nEnemyModel - 1 do5809 LostArmy[ i] := MyRO.EnemyModel[i].Lost;6479 Dec(cixChanged); 6480 Assert(cixChanged >= 0); 6481 end; 6482 6483 for I := 0 to MyRO.nEnemyModel - 1 do 6484 LostArmy[I] := MyRO.EnemyModel[I].Lost; 5810 6485 OldToTile := MyMap[ToLoc]; 5811 result := Server(sMoveUnit + DirCode, me, UnFocus, nil^);6486 Result := Server(sMoveUnit + DirCode, Me, UnFocus, nil^); 5812 6487 nLostArmy := 0; 5813 for i:= 0 to MyRO.nEnemyModel - 1 do6488 for I := 0 to MyRO.nEnemyModel - 1 do 5814 6489 begin 5815 LostArmy[ i] := MyRO.EnemyModel[i].Lost - LostArmy[i];5816 inc(nLostArmy, LostArmy[i])5817 end; 5818 if result and rUnitRemoved <> 0 then6490 LostArmy[I] := MyRO.EnemyModel[I].Lost - LostArmy[I]; 6491 Inc(nLostArmy, LostArmy[I]); 6492 end; 6493 if Result and rUnitRemoved <> 0 then 5819 6494 begin 5820 6495 UnFocus := -1; … … 5825 6500 begin // city was destroyed, borders have moved, unrest might have changed in any city 5826 6501 CityOptimizer_BeginOfTurn; 5827 NeedEcoUpdate := true; 5828 end 5829 else 5830 begin 6502 NeedEcoUpdate := True; 6503 end else begin 5831 6504 if cixChanged >= 0 then 5832 6505 begin 5833 6506 CityOptimizer_CityChange(cixChanged); 5834 NeedEcoUpdate := true;6507 NeedEcoUpdate := True; 5835 6508 end; 5836 if ( result = eWon) or (result = eBloody) or (result = eExpelled) then6509 if (Result = eWon) or (Result = eBloody) or (Result = eExpelled) then 5837 6510 begin 5838 6511 CityOptimizer_TileBecomesAvailable(ToLoc); 5839 NeedEcoUpdate := true;6512 NeedEcoUpdate := True; 5840 6513 end; 5841 6514 end; … … 5849 6522 MyRO.EnemyModel[MyRO.EnemyUn[euix].emix].Domain)); 5850 6523 ShowModal; 5851 end 5852 end 5853 end; 5854 if result and rUnitRemoved <> 0 then6524 end; 6525 end; 6526 end; 6527 if Result and rUnitRemoved <> 0 then 5855 6528 begin 5856 6529 CityOptimizer_AfterRemoveUnit; 5857 6530 ListDlg.RemoveUnit; 5858 NeedEcoUpdate := true;6531 NeedEcoUpdate := True; 5859 6532 end; 5860 6533 if NeedEcoUpdate then 5861 6534 begin 5862 UpdateViews( true);5863 Update 5864 end 5865 end; 5866 5867 if result = eMissionDone then6535 UpdateViews(True); 6536 Update; 6537 end; 6538 end; 6539 6540 if Result = eMissionDone then 5868 6541 begin 5869 6542 p1 := MyRO.Territory[ToLoc]; … … 5871 6544 smStealMap: 5872 6545 begin 5873 MapValid := false;6546 MapValid := False; 5874 6547 PaintAllMaps 5875 6548 end; … … 5884 6557 CheckToldNoReturn(UnFocus); 5885 6558 5886 NeedRepaintPanel := false;5887 if result >= rExecuted then6559 NeedRepaintPanel := False; 6560 if Result >= rExecuted then 5888 6561 begin 5889 6562 if CityCaptured and (MyMap[ToLoc] and fCity = 0) then 5890 6563 begin // city destroyed 5891 for i:= 0 to nWonder - 1 do { tell about destroyed wonders }5892 if (MyRO.Wonder[ i].CityID = WonderDestroyed) and (MyData.ToldWonders[i].CityID <> WonderDestroyed)6564 for I := 0 to nWonder - 1 do { tell about destroyed wonders } 6565 if (MyRO.Wonder[I].CityID = WonderDestroyed) and (MyData.ToldWonders[I].CityID <> WonderDestroyed) 5893 6566 then 5894 6567 with MessgExDlg do 5895 6568 begin 5896 6569 if WondersDlg.Visible then 5897 WondersDlg.SmartUpdateContent( false);6570 WondersDlg.SmartUpdateContent(False); 5898 6571 OpenSound := 'WONDER_DESTROYED'; 5899 6572 MessgText := Format(Phrases.Lookup('WONDERDEST'), 5900 [Phrases.Lookup('IMPROVEMENTS', i)]);6573 [Phrases.Lookup('IMPROVEMENTS', I)]); 5901 6574 Kind := mkOkHelp; 5902 6575 HelpKind := hkImp; 5903 HelpNo := i;6576 HelpNo := I; 5904 6577 IconKind := mikImp; 5905 IconIndex := i;6578 IconIndex := I; 5906 6579 ShowModal; 5907 MyData.ToldWonders[ i] := MyRO.Wonder[i];5908 end 6580 MyData.ToldWonders[I] := MyRO.Wonder[I]; 6581 end; 5909 6582 end; 5910 6583 if CityCaptured and (MyMap[ToLoc] and fCity <> 0) then 5911 6584 begin // city captured 5912 6585 ListDlg.AddCity; 5913 for i:= 0 to nWonder - 1 do { tell about capture of wonders }5914 if MyRO.City[MyRO.nCity - 1].Built[ i] > 0 then6586 for I := 0 to nWonder - 1 do { tell about capture of wonders } 6587 if MyRO.City[MyRO.nCity - 1].Built[I] > 0 then 5915 6588 with MessgExDlg do 5916 6589 begin 5917 6590 if WondersDlg.Visible then 5918 WondersDlg.SmartUpdateContent( false);6591 WondersDlg.SmartUpdateContent(False); 5919 6592 OpenSound := 'WONDER_CAPTURED'; 5920 MessgText := Format(Tribe[ me].TPhrase('WONDERCAPTOWN'),5921 [Phrases.Lookup('IMPROVEMENTS', i)]);6593 MessgText := Format(Tribe[Me].TPhrase('WONDERCAPTOWN'), 6594 [Phrases.Lookup('IMPROVEMENTS', I)]); 5922 6595 Kind := mkOkHelp; 5923 6596 HelpKind := hkImp; 5924 HelpNo := i;6597 HelpNo := I; 5925 6598 IconKind := mikImp; 5926 IconIndex := i;6599 IconIndex := I; 5927 6600 ShowModal; 5928 MyData.ToldWonders[ i] := MyRO.Wonder[i];6601 MyData.ToldWonders[I] := MyRO.Wonder[I]; 5929 6602 end; 5930 6603 … … 5932 6605 begin { Temple of Zeus -- choose advance to steal } 5933 6606 ModalSelectDlg.ShowNewContent(wmModal, kStealTech); 5934 Server(sStealTech, me, ModalSelectDlg.result, nil^);6607 Server(sStealTech, Me, ModalSelectDlg.Result, nil^); 5935 6608 end; 5936 6609 TellNewModels; … … 5938 6611 cix := MyRO.nCity - 1; 5939 6612 while (cix >= 0) and (MyCity[cix].Loc <> ToLoc) do 5940 dec(cix);5941 assert(cix >= 0);6613 Dec(cix); 6614 Assert(cix >= 0); 5942 6615 MyCity[cix].Status := MyCity[cix].Status and not csResourceWeightsMask or 5943 6616 (3 shl 4); 5944 6617 // captured city, set to maximum growth 5945 6618 NewTiles := 1 shl 13; { exploit central tile only } 5946 Server(sSetCityTiles, me, cix, NewTiles);6619 Server(sSetCityTiles, Me, cix, NewTiles); 5947 6620 end 5948 6621 else 5949 NeedRepaintPanel := true;6622 NeedRepaintPanel := True; 5950 6623 end; 5951 6624 TellNewContacts; … … 5961 6634 if Options and (muAutoNoWait or muAutoNext) <> 0 then 5962 6635 begin 5963 if (UnFocus >= 0) and (( result = eNoTime_Move) or UnitExhausted(UnFocus) or6636 if (UnFocus >= 0) and ((Result = eNoTime_Move) or UnitExhausted(UnFocus) or 5964 6637 (MyUn[UnFocus].Master >= 0) or (MyModel[MyUn[UnFocus].mix].Domain = dAir) 5965 6638 and ((MyMap[MyUn[UnFocus].Loc] and fCity <> 0) … … 5975 6648 end 5976 6649 else 5977 NextUnit(UnStartLoc, true);6650 NextUnit(UnStartLoc, True); 5978 6651 end 5979 6652 else if (UnFocus < 0) and (Options and muAutoNext <> 0) then 5980 NextUnit(UnStartLoc, result <> eMissionDone);6653 NextUnit(UnStartLoc, Result <> eMissionDone); 5981 6654 end; 5982 6655 … … 5986 6659 else 5987 6660 begin 5988 assert(result <> eMissionDone);6661 Assert(Result <> eMissionDone); 5989 6662 CheckTerrainBtnVisible; 5990 FocusOnLoc(ToLoc, flRepaintPanel or flImmUpdate) 5991 end; 5992 5993 if ( result >= rExecuted) and CityCaptured and (MyMap[ToLoc] and fCity <> 0)6663 FocusOnLoc(ToLoc, flRepaintPanel or flImmUpdate); 6664 end; 6665 6666 if (Result >= rExecuted) and CityCaptured and (MyMap[ToLoc] and fCity <> 0) 5994 6667 then 5995 6668 ZoomToCity(ToLoc, UnFocus < 0, chCaptured); // show captured city 5996 end; // moveunit6669 end; 5997 6670 5998 6671 procedure TMainScreen.MoveOnScreen(ShowMove: TShowMove; 5999 Step0, Step1, nStep: integer; Restore: boolean = true);6672 Step0, Step1, nStep: Integer; Restore: Boolean = True); 6000 6673 var 6001 6674 ToLoc, xFromLoc, yFromLoc, xToLoc, yToLoc, xFrom, yFrom, xTo, yTo, xMin, yMin, 6002 xRange, yRange, xw1, Step, xMoving, yMoving, SliceCount: integer;6675 xRange, yRange, xw1, Step, xMoving, yMoving, SliceCount: Integer; 6003 6676 UnitInfo: TUnitInfo; 6004 6677 Ticks0, Ticks: TDateTime; 6005 6678 begin 6006 Timer1.Enabled := false;6679 Timer1.Enabled := False; 6007 6680 Ticks0 := NowPrecise; 6008 6681 with ShowMove do … … 6013 6686 UnitInfo.Job := jNone; 6014 6687 UnitInfo.Flags := Flags; 6015 if Owner <> me then6688 if Owner <> Me then 6016 6689 UnitInfo.emix := emix; 6017 6690 … … 6032 6705 * xxt - MapWidth) < abs(((xFromLoc - xw1) * 2 + yFromLoc and 1 + 1) * xxt 6033 6706 * 2 + dx * xxt - MapWidth) do 6034 dec(xw1, G.lx);6707 Dec(xw1, G.lx); 6035 6708 6036 6709 xTo := (xToLoc - xw1) * (xxt * 2) + yToLoc and 1 * xxt + (xxt - xxu); … … 6040 6713 if xFrom < xTo then begin 6041 6714 xMin := xFrom; 6042 xRange := xTo - xFrom 6715 xRange := xTo - xFrom; 6043 6716 end else begin 6044 6717 xMin := xTo; 6045 xRange := xFrom - xTo 6718 xRange := xFrom - xTo; 6046 6719 end; 6047 6720 if yFrom < yTo then begin 6048 6721 yMin := yFrom; 6049 yRange := yTo - yFrom 6722 yRange := yTo - yFrom; 6050 6723 end else begin 6051 6724 yMin := yTo; 6052 yRange := yFrom - yTo 6053 end; 6054 inc(xRange, xxt * 2);6055 inc(yRange, yyt * 3);6725 yRange := yFrom - yTo; 6726 end; 6727 Inc(xRange, xxt * 2); 6728 Inc(yRange, yyt * 3); 6056 6729 end; 6057 6730 … … 6061 6734 for Step := 0 to abs(Step1 - Step0) do 6062 6735 begin 6063 DpiBit Canvas(Buffer.Canvas, 0, 0, xRange, yRange,6064 offscreen.Canvas, xMin, yMin);6736 DpiBitBltCanvas(Buffer.Canvas, 0, 0, xRange, yRange, 6737 Offscreen.Canvas, xMin, yMin); 6065 6738 if Step1 <> Step0 then 6066 6739 begin … … 6079 6752 NoMap.PaintUnit(xMoving - xMin, yMoving - yMin, UnitInfo, 0); 6080 6753 PaintBufferToScreen(xMin, yMin, xRange, yRange); 6081 {$IFDEF LINUX}6082 // TODO: Force animation under linux6754 {$IFDEF UNIX} 6755 // TODO: Force animation under UNIX 6083 6756 DpiApplication.ProcessMessages; 6084 6757 {$ENDIF} … … 6091 6764 < MoveTime) then 6092 6765 begin 6093 if not idle or (GameMode = cMovie) then6766 if not Idle or (GameMode = cMovie) then 6094 6767 DpiApplication.ProcessMessages; 6095 6768 Sleep(1); 6096 inc(SliceCount)6769 Inc(SliceCount) 6097 6770 end; 6098 6771 Ticks := NowPrecise; 6099 6772 until (((Ticks - Ticks0) * 12) / OneMillisecond) >= MoveTime; 6100 Ticks0 := Ticks 6773 Ticks0 := Ticks; 6101 6774 end; 6102 6775 end; 6103 6776 if Restore then 6104 6777 begin 6105 DpiBit Canvas(Buffer.Canvas, 0, 0, xRange, yRange, offscreen.Canvas, xMin, yMin);6778 DpiBitBltCanvas(Buffer.Canvas, 0, 0, xRange, yRange, Offscreen.Canvas, xMin, yMin); 6106 6779 PaintBufferToScreen(xMin, yMin, xRange, yRange); 6107 6780 end; 6108 6781 BlinkTime := -1; 6109 Timer1.Enabled := true;6110 end; 6111 6112 procedure TMainScreen.MoveToLoc(Loc: integer; CheckSuicide: boolean);6782 Timer1.Enabled := True; 6783 end; 6784 6785 procedure TMainScreen.MoveToLoc(Loc: Integer; CheckSuicide: Boolean); 6113 6786 // path finder: move focused unit to loc, start multi-turn goto if too far 6114 6787 var 6115 uix, i, MoveOptions, NextLoc, MoveResult: integer;6788 uix, I, MoveOptions, NextLoc, MoveResult: Integer; 6116 6789 MoveAdviceData: TMoveAdviceData; 6117 6790 StopReason: (None, Arrived, Dead, NoTime, EnemySpotted, MoveError); 6118 6791 begin 6119 6792 if MyUn[UnFocus].Job > jNone then 6120 Server(sStartJob + jNone shl 4, me, UnFocus, nil^);6793 Server(sStartJob + jNone shl 4, Me, UnFocus, nil^); 6121 6794 if GetMoveAdvice(UnFocus, Loc, MoveAdviceData) >= rExecuted then 6122 6795 begin … … 6124 6797 StopReason := None; 6125 6798 repeat 6126 for i:= 0 to MoveAdviceData.nStep - 1 do6799 for I := 0 to MoveAdviceData.nStep - 1 do 6127 6800 begin 6128 if i= MoveAdviceData.nStep - 1 then6801 if I = MoveAdviceData.nStep - 1 then 6129 6802 MoveOptions := muAutoNext 6130 6803 else 6131 6804 MoveOptions := 0; 6132 NextLoc := dLoc(MyUn[uix].Loc, MoveAdviceData.dx[ i],6133 MoveAdviceData.dy[ i]);6805 NextLoc := dLoc(MyUn[uix].Loc, MoveAdviceData.dx[I], 6806 MoveAdviceData.dy[I]); 6134 6807 if (NextLoc = Loc) or (Loc = maNextCity) and 6135 6808 (MyMap[NextLoc] and fCity <> 0) then … … 6137 6810 if not CheckSuicide and (NextLoc = Loc) then 6138 6811 MoveOptions := MoveOptions or muNoSuicideCheck; 6139 MoveResult := MoveUnit(MoveAdviceData.dx[ i], MoveAdviceData.dy[i],6812 MoveResult := MoveUnit(MoveAdviceData.dx[I], MoveAdviceData.dy[I], 6140 6813 MoveOptions); 6141 6814 if MoveResult < rExecuted then … … 6149 6822 end; 6150 6823 if (StopReason = None) and ((MoveAdviceData.nStep < 25) or 6151 (MyRO.Wonder[woShinkansen].EffectiveOwner <> me)) then6824 (MyRO.Wonder[woShinkansen].EffectiveOwner <> Me)) then 6152 6825 StopReason := NoTime; 6153 6826 if StopReason <> None then … … 6155 6828 if GetMoveAdvice(UnFocus, Loc, MoveAdviceData) < rExecuted then 6156 6829 begin 6157 assert(false);6830 Assert(False); 6158 6831 Break; 6159 6832 end; 6160 until false;6833 until False; 6161 6834 6162 6835 case StopReason of 6163 6836 None: 6164 assert(false);6837 Assert(False); 6165 6838 Arrived: 6166 6839 MyUn[uix].Status := MyUn[uix].Status and ($FFFF - usGoto); 6167 6840 Dead: 6168 6841 if UnFocus < 0 then 6169 NextUnit(UnStartLoc, false);6842 NextUnit(UnStartLoc, False); 6170 6843 else 6171 6844 begin // multi-turn goto … … 6180 6853 begin 6181 6854 MyUn[uix].Status := MyUn[uix].Status and not usWaiting; 6182 NextUnit(UnStartLoc, true);6855 NextUnit(UnStartLoc, True); 6183 6856 end; 6184 6857 end; … … 6188 6861 6189 6862 procedure TMainScreen.PanelBoxMouseDown(Sender: TObject; Button: TMouseButton; 6190 Shift: TShiftState; x, y: integer);6863 Shift: TShiftState; X, Y: Integer); 6191 6864 var 6192 i, xMouse, MouseLoc, p1: integer;6865 I, xMouse, MouseLoc, p1: Integer; 6193 6866 begin 6194 6867 if GameMode = cMovie then 6195 exit;6868 Exit; 6196 6869 6197 6870 if Button = mbLeft then 6198 6871 begin 6199 if ( x >= xMini + 2) and (y >= yMini + 2) and (x< xMini + 2 + 2 * G.lx) and6200 ( y< yMini + 2 + G.ly) then6872 if (X >= xMini + 2) and (Y >= yMini + 2) and (X < xMini + 2 + 2 * G.lx) and 6873 (Y < yMini + 2 + G.ly) then 6201 6874 if ssShift in Shift then 6202 6875 begin 6203 6876 with MainMap do 6204 xMouse := (xwMini + ( x- (xMini + 2) + MapWidth div (xxt * 2) + G.lx)6877 xMouse := (xwMini + (X - (xMini + 2) + MapWidth div (xxt * 2) + G.lx) 6205 6878 div 2) mod G.lx; 6206 MouseLoc := xMouse + G.lx * ( y- (yMini + 2));6879 MouseLoc := xMouse + G.lx * (Y - (yMini + 2)); 6207 6880 if MyMap[MouseLoc] and fTerrain <> fUNKNOWN then 6208 6881 begin 6209 6882 p1 := MyRO.Territory[MouseLoc]; 6210 if (p1 = me) or (p1 >= 0) and (MyRO.Treaty[p1] >= trNone) then6883 if (p1 = Me) or (p1 >= 0) and (MyRO.Treaty[p1] >= trNone) then 6211 6884 NatStatDlg.ShowNewContent(wmPersistent, p1); 6212 6885 end; … … 6218 6891 if UnitStatDlg.Visible then 6219 6892 UnitStatDlg.Close; 6220 Tracking := true;6221 PanelBoxMouseMove(Sender, Shift + [ssLeft], x, y);6893 Tracking := True; 6894 PanelBoxMouseMove(Sender, Shift + [ssLeft], X, Y); 6222 6895 end 6223 else if (ClientMode <> cEditMap) and ( x>= ClientWidth - xPalace) and6224 ( y >= yPalace) and (x< ClientWidth - xPalace + xSizeBig) and6225 ( y< yPalace + ySizeBig) then6896 else if (ClientMode <> cEditMap) and (X >= ClientWidth - xPalace) and 6897 (Y >= yPalace) and (X < ClientWidth - xPalace + xSizeBig) and 6898 (Y < yPalace + ySizeBig) then 6226 6899 begin 6227 6900 InitPopup(StatPopup); … … 6234 6907 DpiGetSystemMetrics(SM_CYCAPTION) + 3) 6235 6908 end 6236 (* else if ( x>=xAdvisor-3) and (y>=yAdvisor-3)6237 and ( x<xAdvisor+16+3) and (y<yAdvisor+16+3) and HaveStrategyAdvice then6909 (* else if (X>=xAdvisor-3) and (Y>=yAdvisor-3) 6910 and (X<xAdvisor+16+3) and (Y<yAdvisor+16+3) and HaveStrategyAdvice then 6238 6911 AdviceBtnClick *) 6239 else if ( x >= xTroop + 1) and (y>= yTroop + 1) and6240 ( x < xTroop + TrRow * TrPitch) and (y<= yTroop + 55) then6912 else if (X >= xTroop + 1) and (Y >= yTroop + 1) and 6913 (X < xTroop + TrRow * TrPitch) and (Y <= yTroop + 55) then 6241 6914 begin 6242 i := (x- xTroop - 1) div TrPitch;6243 if trix[ i] >= 0 then6915 I := (X - xTroop - 1) div TrPitch; 6916 if trix[I] >= 0 then 6244 6917 if ClientMode = cEditMap then 6245 6918 begin 6246 BrushType := trix[ i];6247 PanelPaint 6919 BrushType := trix[I]; 6920 PanelPaint; 6248 6921 end 6249 6922 else if (TroopLoc >= 0) then … … 6252 6925 if ssShift in Shift then 6253 6926 UnitStatDlg.ShowNewContent_OwnModel(wmPersistent, 6254 MyUn[trix[ i]].mix)6255 else if not supervising and (ClientMode < scContact) and6256 ( x - xTroop - 1 - i * TrPitch >= 60 - 20) and (y>= yTroop + 35)6257 and ((MyUn[trix[ i]].Job > jNone) or (MyUn[trix[i]].Status and6927 MyUn[trix[I]].mix) 6928 else if not Supervising and (ClientMode < scContact) and 6929 (X - xTroop - 1 - I * TrPitch >= 60 - 20) and (Y >= yTroop + 35) 6930 and ((MyUn[trix[I]].Job > jNone) or (MyUn[trix[I]].Status and 6258 6931 (usStay or usRecover or usGoto) <> 0)) then 6259 6932 begin // wake up 6260 MyUn[trix[ i]].Status := MyUn[trix[i]].Status and6933 MyUn[trix[I]].Status := MyUn[trix[I]].Status and 6261 6934 ($FFFF - usStay - usRecover - usGoto - usEnhance) or usWaiting; 6262 if MyUn[trix[ i]].Job > jNone then6263 Server(sStartJob + jNone shl 4, me, trix[i], nil^);6935 if MyUn[trix[I]].Job > jNone then 6936 Server(sStartJob + jNone shl 4, Me, trix[I], nil^); 6264 6937 if (UnFocus < 0) and not CityDlg.Visible then 6265 6938 begin 6266 SetUnFocus(trix[ i]);6267 SetTroopLoc(MyUn[trix[ i]].Loc);6939 SetUnFocus(trix[I]); 6940 SetTroopLoc(MyUn[trix[I]].Loc); 6268 6941 FocusOnLoc(TroopLoc, flRepaintPanel) 6269 6942 end … … 6271 6944 begin 6272 6945 if CityDlg.Visible and (CityDlg.RestoreUnFocus < 0) then 6273 CityDlg.RestoreUnFocus := trix[ i];6946 CityDlg.RestoreUnFocus := trix[I]; 6274 6947 PanelPaint; 6275 6948 end … … 6277 6950 else if (ClientMode < scContact) then 6278 6951 begin 6279 if supervising then6280 UnitStatDlg.ShowNewContent_OwnUnit(wmPersistent, trix[ i])6952 if Supervising then 6953 UnitStatDlg.ShowNewContent_OwnUnit(wmPersistent, trix[I]) 6281 6954 else if CityDlg.Visible then 6282 6955 begin … … 6284 6957 CityDlg.Close; 6285 6958 SumCities(TaxSum, ScienceSum); 6286 SetUnFocus(trix[ i]);6959 SetUnFocus(trix[I]); 6287 6960 end 6288 6961 else 6289 6962 begin 6290 DestinationMarkON := false;6963 DestinationMarkON := False; 6291 6964 PaintDestination; 6292 UnFocus := trix[ i];6965 UnFocus := trix[I]; 6293 6966 UnStartLoc := TroopLoc; 6294 6967 BlinkTime := 0; 6295 BlinkON := false;6968 BlinkON := False; 6296 6969 PaintLoc(TroopLoc); 6297 6970 end; 6298 6971 if UnFocus >= 0 then 6299 6972 begin 6300 UnitInfoBtn.Visible := true;6301 UnitBtn.Visible := true;6302 TurnComplete := false;6973 UnitInfoBtn.Visible := True; 6974 UnitBtn.Visible := True; 6975 TurnComplete := False; 6303 6976 EOT.ButtonIndex := eotGray; 6304 6977 end; … … 6307 6980 end; 6308 6981 end 6309 else if Server(sGetUnits, me, TroopLoc, TrCnt) >= rExecuted then6982 else if Server(sGetUnits, Me, TroopLoc, TrCnt) >= rExecuted then 6310 6983 if ssShift in Shift then 6311 6984 UnitStatDlg.ShowNewContent_EnemyModel(wmPersistent, 6312 MyRO.EnemyUn[MyRO.nEnemyUn + trix[ i]].emix) // model info6985 MyRO.EnemyUn[MyRO.nEnemyUn + trix[I]].emix) // model info 6313 6986 else 6314 6987 UnitStatDlg.ShowNewContent_EnemyUnit(wmPersistent, 6315 MyRO.nEnemyUn + trix[ i]); // unit info6316 end; 6317 end; 6318 end; 6319 6320 procedure TMainScreen.SetTroopLoc(Loc: integer);6988 MyRO.nEnemyUn + trix[I]); // unit info 6989 end; 6990 end; 6991 end; 6992 6993 procedure TMainScreen.SetTroopLoc(Loc: Integer); 6321 6994 var 6322 trixFocus, uix, uixDefender: integer;6323 Prio: boolean;6995 trixFocus, uix, uixDefender: Integer; 6996 Prio: Boolean; 6324 6997 begin 6325 6998 TroopLoc := Loc; … … 6333 7006 if MyMap[Loc] and fOwned <> 0 then 6334 7007 begin // count own units here 6335 Server(sGetDefender, me, TroopLoc, uixDefender);6336 for Prio := true downto false do7008 Server(sGetDefender, Me, TroopLoc, uixDefender); 7009 for Prio := True downto False do 6337 7010 for uix := 0 to MyRO.nUn - 1 do 6338 7011 if ((uix = uixDefender) = Prio) and (MyUn[uix].Loc = Loc) then … … 6340 7013 if uix = UnFocus then 6341 7014 trixFocus := TrCnt; 6342 inc(TrCnt);7015 Inc(TrCnt); 6343 7016 end; 6344 7017 end 6345 7018 else // count enemy units here 6346 Server(sGetUnits, me, Loc, TrCnt);7019 Server(sGetUnits, Me, Loc, TrCnt); 6347 7020 if TrCnt = 0 then 6348 7021 sb.Init(0, 1) … … 6355 7028 end; 6356 7029 6357 (* procedure TMainScreen.ShowMoveHint(ToLoc: integer; Force: boolean = false);7030 (* procedure TMainScreen.ShowMoveHint(ToLoc: Integer; Force: Boolean = False); 6358 7031 var 6359 Step,Loc,x0,y0,xs,ys: integer;7032 Step,Loc,x0,y0,xs,ys: Integer; 6360 7033 Info: string; 6361 7034 InfoSize: TSize; … … 6370 7043 MoveAdvice.MoreTurns:=0; 6371 7044 MoveAdvice.MaxHostile_MovementLeft:=MyUn[UnFocus].Health-50; 6372 if Server(sGetMoveAdvice, me,UnFocus,MoveAdvice)<rExecuted then7045 if Server(sGetMoveAdvice,Me,UnFocus,MoveAdvice)<rExecuted then 6373 7046 ToLoc:=-1 6374 7047 end; 6375 if (ToLoc=MoveHintToLoc) and not Force then exit;7048 if (ToLoc=MoveHintToLoc) and not Force then Exit; 6376 7049 if (ToLoc<>MoveHintToLoc) and (MoveHintToLoc>=0) then 6377 7050 begin invalidate; update end; // clear old hint from screen 6378 7051 MoveHintToLoc:=ToLoc; 6379 if ToLoc<0 then exit;6380 6381 with canvas do7052 if ToLoc<0 then Exit; 7053 7054 with Canvas do 6382 7055 begin 6383 7056 Pen.Color:=$80C0FF; … … 6390 7063 xs:=(x0-xw)*66+y0 and 1*33-G.lx*66; 6391 7064 while abs(2*(xs+G.lx*66)-MapWidth)<abs(2*xs-MapWidth) do 6392 inc(xs,G.lx*66);7065 Inc(xs,G.lx*66); 6393 7066 ys:=(y0-yw)*16; 6394 7067 if Step=0 then moveto(xs+33,ys+16) … … 6398 7071 end; 6399 7072 Brush.Color:=$80C0FF; 6400 Info:=' '+ inttostr(88)+' ';7073 Info:=' '+IntToStr(88)+' '; 6401 7074 InfoSize:=TextExtent(Info); 6402 7075 TextOut(xs+33-InfoSize.cx div 2, ys+16-InfoSize.cy div 2, Info); … … 6405 7078 end; *) 6406 7079 6407 procedure TMainScreen.SetDebugMap( p: integer);6408 begin 6409 MainMap.pDebugMap := p;7080 procedure TMainScreen.SetDebugMap(P: Integer); 7081 begin 7082 MainMap.pDebugMap := P; 6410 7083 MapOptions := MapOptions - [moLocCodes]; 6411 mLocCodes.Checked := false;6412 MapValid := false;7084 mLocCodes.Checked := False; 7085 MapValid := False; 6413 7086 MainOffscreenPaint; 6414 7087 end; 6415 7088 6416 procedure TMainScreen.SetViewpoint( p: integer);7089 procedure TMainScreen.SetViewpoint(P: Integer); 6417 7090 var 6418 i: Integer; 6419 begin 6420 if supervising and (G.RO[0].Turn > 0) and 6421 ((p = 0) or (1 shl p and G.RO[0].Alive <> 0)) then 6422 begin 6423 for i := 0 to DpiScreen.FormCount - 1 do 6424 if DpiScreen.Forms[i].Visible and (DpiScreen.Forms[i] is TBufferedDrawDlg) then 6425 DpiScreen.Forms[i].Close; // close windows 6426 ItsMeAgain(p); 7091 I: Integer; 7092 begin 7093 if Supervising and (G.RO[0].Turn > 0) and 7094 ((P = 0) or (1 shl P and G.RO[0].Alive <> 0)) then 7095 begin 7096 ApplyToVisibleForms(faClose); 7097 ItsMeAgain(P); 6427 7098 SumCities(TaxSum, ScienceSum); 6428 for i:= 0 to MyRO.nModel - 1 do6429 if not Assigned(Tribe[ me].ModelPicture[i].HGr) then6430 InitMyModel( i, True);7099 for I := 0 to MyRO.nModel - 1 do 7100 if not Assigned(Tribe[Me].ModelPicture[I].HGr) then 7101 InitMyModel(I, True); 6431 7102 6432 7103 SetTroopLoc(-1); … … 6481 7152 MTrans.ShortCut := BTrans.ShortCut; 6482 7153 mPollution.ShortCut := BPollution.ShortCut; 6483 mR R.ShortCut := BRailRoad.ShortCut;7154 mRailRoad.ShortCut := BRailRoad.ShortCut; 6484 7155 mRoad.ShortCut := BRailRoad.ShortCut; 6485 7156 mUnload.ShortCut := BUnload.ShortCut; … … 6516 7187 end; 6517 7188 6518 procedure TMainScreen.FormKeyDown(Sender: TObject; var Key: word;7189 procedure TMainScreen.FormKeyDown(Sender: TObject; var Key: Word; 6519 7190 Shift: TShiftState); 6520 7191 … … 6523 7194 InitPopup(Popup); 6524 7195 if Item.Visible and Item.Enabled then 6525 MenuClick(Item);6526 end; 6527 6528 procedure SetViewpointMe( p: Integer);6529 begin 6530 if p = me then SetViewpoint(p)6531 else SetViewpoint( p);7196 Item.Click; 7197 end; 7198 7199 procedure SetViewpointMe(P: Integer); 7200 begin 7201 if P = Me then SetViewpoint(P) 7202 else SetViewpoint(P); 6532 7203 end; 6533 7204 … … 6558 7229 6559 7230 if ClientMode = cEditMap then begin 6560 if BResign.Test(ShortCut) then MenuClick(mResign)6561 else if BRandomMap.Test(ShortCut) then MenuClick(mRandomMap)6562 else if BHelp.Test(ShortCut) then MenuClick(mHelp);7231 if BResign.Test(ShortCut) then mResign.Click 7232 else if BRandomMap.Test(ShortCut) then mRandomMap.Click 7233 else if BHelp.Test(ShortCut) then mHelp.Click; 6563 7234 (*if Shift = [ssCtrl] then 6564 7235 case char(Key) of 6565 7236 'A': 6566 7237 begin // auto symmetry 6567 Server($7F0, me,0,nil^);6568 MapValid:= false;7238 Server($7F0,Me,0,nil^); 7239 MapValid:=False; 6569 7240 PaintAll; 6570 7241 end; … … 6573 7244 dy:=0; 6574 7245 for dx:=G.lx to G.lx*(G.ly-1)-1 do 6575 if MyMap[dx] and fTerrain>=fGrass then inc(dy);7246 if MyMap[dx] and fTerrain>=fGrass then Inc(dy); 6576 7247 dy:=dy 6577 7248 end; … … 6586 7257 SetFullScreen(FullScreen); 6587 7258 end 6588 else if BHelp.Test(ShortCut) then MenuClick(mHelp)7259 else if BHelp.Test(ShortCut) then mHelp.Click 6589 7260 else if BUnitStat.Test(ShortCut) then MenuClick_Check(StatPopup, mUnitStat) 6590 7261 else if BCityStat.Test(ShortCut) then MenuClick_Check(StatPopup, mCityStat) … … 6608 7279 else if BSetDebugMap9.Test(ShortCut) then SetDebugMap(9) 6609 7280 6610 else if BJump.Test(ShortCut) then MenuClick(mJump)7281 else if BJump.Test(ShortCut) then mJump.Click 6611 7282 else if BDebugMap.Test(ShortCut) then mShowClick(mDebugMap) 6612 7283 else if BLocCodes.Test(ShortCut) then mShowClick(mLocCodes) … … 6617 7288 else if BNames.Test(ShortCut) then mNamesClick(mNames) 6618 7289 else if BResign.Test(ShortCut) then MenuClick_Check(GamePopup, mResign) 6619 else if BRun.Test(ShortCut) then MenuClick(mRun)7290 else if BRun.Test(ShortCut) then mRun.Click 6620 7291 else if BTestMapRepaint.Test(ShortCut) then begin // test map repaint time 6621 7292 Time0 := NowPrecise; … … 6642 7313 else if BMapBtn5.Test(ShortCut) then MapBtnClick(MapBtn5) 6643 7314 else if BMapBtn6.Test(ShortCut) then MapBtnClick(MapBtn6) 6644 else if BTechTree.Test(ShortCut) then MenuClick(mTechTree)6645 else if BWait.Test(ShortCut) then MenuClick(mWait);7315 else if BTechTree.Test(ShortCut) then mTechTree.Click 7316 else if BWait.Test(ShortCut) then mWait.Click; 6646 7317 6647 7318 if UnFocus >= 0 then begin 6648 if BDisbandUnit.Test(ShortCut) then MenuClick(mDisband)7319 if BDisbandUnit.Test(ShortCut) then mDisband.Click 6649 7320 else if BFortify.Test(ShortCut) then MenuClick_Check(TerrainPopup, mFort) 6650 else if BCenterUnit.Test(ShortCut) then MenuClick(mCentre)6651 else if BStay.Test(ShortCut) then MenuClick(mStay)6652 else if BNoOrders.Test(ShortCut) then MenuClick(mNoOrders)6653 else if BPrevUnit.Test(ShortCut) then MenuClick(mPrevUnit)6654 else if BNextUnit.Test(ShortCut) then MenuClick(mNextUnit)7321 else if BCenterUnit.Test(ShortCut) then mCentre.Click 7322 else if BStay.Test(ShortCut) then mStay.Click 7323 else if BNoOrders.Test(ShortCut) then mNoOrders.Click 7324 else if BPrevUnit.Test(ShortCut) then mPrevUnit.Click 7325 else if BNextUnit.Test(ShortCut) then mNextUnit.Click 6655 7326 else if BCancel.Test(ShortCut) then MenuClick_Check(UnitPopup, mCancel) 6656 7327 else if BPillage.Test(ShortCut) then MenuClick_Check(UnitPopup, mPillage) … … 6660 7331 else if BEnhance.Test(ShortCut) then begin 6661 7332 InitPopup(TerrainPopup); 6662 if mEnhance.Visible and mEnhance.Enabled then MenuClick(mEnhance)6663 else MenuClick(mEnhanceDef)7333 if mEnhance.Visible and mEnhance.Enabled then mEnhance.Click 7334 else mEnhanceDef.Click 6664 7335 end 6665 7336 else if BGoOn.Test(ShortCut) then MenuClick_Check(UnitPopup, mGoOn) … … 6667 7338 else if BFarmClearIrrigation.Test(ShortCut) then begin 6668 7339 if JobTest(UnFocus, jFarm, [eTreaty]) then 6669 MenuClick(mFarm)7340 mFarm.Click 6670 7341 else if JobTest(UnFocus, jClear, [eTreaty]) then 6671 MenuClick(mClear)7342 mClear.Click 6672 7343 else MenuClick_Check(TerrainPopup, mIrrigation); 6673 7344 end 6674 7345 else if BLoad.Test(ShortCut) then MenuClick_Check(UnitPopup, mLoad) 6675 7346 else if BAfforestMine.Test(ShortCut) then begin 6676 if JobTest(UnFocus, jAfforest, [eTreaty]) then MenuClick(mAfforest)7347 if JobTest(UnFocus, jAfforest, [eTreaty]) then mAfforest.Click 6677 7348 else MenuClick_Check(TerrainPopup, mMine); 6678 7349 end … … 6681 7352 else if BPollution.Test(ShortCut) then MenuClick_Check(TerrainPopup, mPollution) 6682 7353 else if BRailRoad.Test(ShortCut) then begin 6683 if JobTest(UnFocus, jRR, [eTreaty]) then MenuClick(mRR)7354 if JobTest(UnFocus, jRR, [eTreaty]) then mRailRoad.Click 6684 7355 else MenuClick_Check(TerrainPopup, mRoad); 6685 7356 end … … 6698 7369 end; 6699 7370 6700 procedure TMainScreen.MenuClick(Sender: TObject); 6701 6702 function DoJob(j0: integer): integer; 6703 var 6704 Loc0, Movement0: integer; 6705 begin 6706 with MyUn[UnFocus] do 7371 function TMainScreen.DoJob(j0: Integer): Integer; 7372 var 7373 Loc0, Movement0: Integer; 7374 begin 7375 with MyUn[UnFocus] do 7376 begin 7377 DestinationMarkON := False; 7378 PaintDestination; 7379 Loc0 := Loc; 7380 Movement0 := Movement; 7381 if j0 < 0 then 7382 Result := ProcessEnhancement(UnFocus, MyData.EnhancementJobs) 7383 // terrain enhancement 7384 else 7385 Result := Server(sStartJob + j0 shl 4, Me, UnFocus, nil^); 7386 if Result >= rExecuted then 6707 7387 begin 6708 DestinationMarkON := false; 6709 PaintDestination; 6710 Loc0 := Loc; 6711 Movement0 := Movement; 6712 if j0 < 0 then 6713 result := ProcessEnhancement(UnFocus, MyData.EnhancementJobs) 6714 // terrain enhancement 6715 else 6716 result := Server(sStartJob + j0 shl 4, me, UnFocus, nil^); 6717 if result >= rExecuted then 7388 if Result = eDied then 7389 UnFocus := -1; 7390 PaintLoc(Loc0); 7391 if UnFocus >= 0 then 6718 7392 begin 6719 if result = eDied then 6720 UnFocus := -1; 6721 PaintLoc(Loc0); 6722 if UnFocus >= 0 then 7393 if (j0 < 0) and (Result <> eJobDone) then 7394 // multi-turn terrain enhancement 7395 Status := Status and ($FFFF - usStay - usRecover - usGoto) or 7396 usEnhance 7397 else 7398 Status := Status and 7399 ($FFFF - usStay - usRecover - usGoto - usEnhance); 7400 if (Job <> jNone) or (Movement0 < 100) then 6723 7401 begin 6724 if (j0 < 0) and (result <> eJobDone) then 6725 // multi-turn terrain enhancement 6726 Status := Status and ($FFFF - usStay - usRecover - usGoto) or 6727 usEnhance 6728 else 6729 Status := Status and 6730 ($FFFF - usStay - usRecover - usGoto - usEnhance); 6731 if (Job <> jNone) or (Movement0 < 100) then 6732 begin 6733 Status := Status and not usWaiting; 6734 NextUnit(UnStartLoc, true); 6735 end 6736 else 6737 PanelPaint; 7402 Status := Status and not usWaiting; 7403 NextUnit(UnStartLoc, True); 6738 7404 end 6739 7405 else 6740 NextUnit(UnStartLoc, true); 6741 end; 6742 end; 6743 case result of 6744 eNoBridgeBuilding: 6745 SoundMessage(Phrases.Lookup('NOBB'), 'INVALID'); 6746 eNoCityTerrain: 6747 SoundMessage(Phrases.Lookup('NOCITY'), 'INVALID'); 6748 eTreaty: 6749 SoundMessage(Tribe[MyRO.Territory[Loc0]].TPhrase('PEACE_NOWORK'), 6750 'NOMOVE_TREATY'); 6751 else 6752 if result < rExecuted then 6753 Play('INVALID') 6754 end; 6755 end; 6756 6757 var 6758 i, uix, NewFocus, Loc0, OldMaster, Destination, cix, cixOldHome, 6759 ServerResult: integer; 6760 AltGovs, RevolutionChanged: boolean; 6761 QueryText: string; 6762 6763 begin 6764 if Sender = mResign then 6765 if ClientMode = cEditMap then 6766 begin 6767 if Edited then 6768 begin 6769 QueryText := Phrases.Lookup('MAP_CLOSE'); 6770 case SimpleQuery(mkYesNoCancel, QueryText, '') of 6771 mrIgnore: 6772 Server(sAbandonMap, me, 0, nil^); 6773 mrOK: 6774 Server(sSaveMap, me, 0, nil^); 6775 end 7406 PanelPaint; 6776 7407 end 6777 7408 else 6778 Server(sAbandonMap, me, 0, nil^) 6779 end 7409 NextUnit(UnStartLoc, True); 7410 end; 7411 end; 7412 case Result of 7413 eNoBridgeBuilding: 7414 SoundMessage(Phrases.Lookup('NOBB'), 'INVALID'); 7415 eNoCityTerrain: 7416 SoundMessage(Phrases.Lookup('NOCITY'), 'INVALID'); 7417 eTreaty: 7418 SoundMessage(Tribe[MyRO.Territory[Loc0]].TPhrase('PEACE_NOWORK'), 7419 'NOMOVE_TREATY'); 7420 else 7421 if Result < rExecuted then 7422 Play('INVALID'); 7423 end; 7424 end; 7425 7426 function TMainScreen.GetBattleDlg: TBattleDlg; 7427 begin 7428 if not Assigned(FBattleDlg) then FBattleDlg := TBattleDlg.Create(nil); 7429 Result := FBattleDlg; 7430 end; 7431 7432 function TMainScreen.GetCityDlg: TCityDlg; 7433 begin 7434 if not Assigned(FCityDlg) then begin 7435 FCityDlg := TCityDlg.Create(nil); 7436 FCityDlg.CheckAge; 7437 end; 7438 Result := FCityDlg; 7439 end; 7440 7441 function TMainScreen.GetCityTypeDlg: TCityTypeDlg; 7442 begin 7443 if not Assigned(FCityTypeDlg) then FCityTypeDlg := TCityTypeDlg.Create(nil); 7444 Result := FCityTypeDlg; 7445 end; 7446 7447 function TMainScreen.GetDiaDlg: TDiaDlg; 7448 begin 7449 if not Assigned(FDiaDlg) then begin 7450 FDiaDlg := TDiaDlg.Create(nil); 7451 ArrangeDialog(FDiaDlg); 7452 end; 7453 Result := FDiaDlg; 7454 end; 7455 7456 function TMainScreen.GetDraftDlg: TDraftDlg; 7457 begin 7458 if not Assigned(FDraftDlg) then FDraftDlg := TDraftDlg.Create(nil); 7459 Result := FDraftDlg; 7460 end; 7461 7462 function TMainScreen.GetEnhanceDlg: TEnhanceDlg; 7463 begin 7464 if not Assigned(FEnhanceDlg) then FEnhanceDlg := TEnhanceDlg.Create(nil); 7465 Result := FEnhanceDlg; 7466 end; 7467 7468 function TMainScreen.GetHelpDlg: THelpDlg; 7469 begin 7470 if not Assigned(FHelpDlg) then begin 7471 FHelpDlg := THelpDlg.Create(nil); 7472 ArrangeDialog(FHelpDlg); 7473 FHelpDlg.Difficulty := G.Difficulty[Me]; 7474 end; 7475 Result := FHelpDlg; 7476 end; 7477 7478 function TMainScreen.GetListDlg: TListDlg; 7479 begin 7480 if not Assigned(FListDlg) then begin 7481 FListDlg := TListDlg.Create(nil); 7482 ArrangeDialog(FListDlg); 7483 end; 7484 Result := FListDlg; 7485 end; 7486 7487 function TMainScreen.GetMessgExDlg: TMessgExDlg; 7488 begin 7489 if not Assigned(FMessgExDlg) then FMessgExDlg := TMessgExDlg.Create(nil); 7490 Result := FMessgExDlg; 7491 end; 7492 7493 function TMainScreen.GetModalSelectDlg: TModalSelectDlg; 7494 begin 7495 if not Assigned(FModalSelectDlg) then FModalSelectDlg := TModalSelectDlg.Create(nil); 7496 Result := FModalSelectDlg; 7497 end; 7498 7499 function TMainScreen.GetNatStatDlg: TNatStatDlg; 7500 begin 7501 if not Assigned(FNatStatDlg) then begin 7502 FNatStatDlg := TNatStatDlg.Create(nil); 7503 ArrangeDialog(FNatStatDlg); 7504 FNatStatDlg.CheckAge; 7505 end; 7506 Result := FNatStatDlg; 7507 end; 7508 7509 function TMainScreen.GetNegoDlg: TNegoDlg; 7510 begin 7511 if not Assigned(FNegoDlg) then FNegoDlg := TNegoDlg.Create(nil); 7512 Result := FNegoDlg; 7513 end; 7514 7515 function TMainScreen.GetRatesDlg: TRatesDlg; 7516 begin 7517 if not Assigned(FRatesDlg) then begin 7518 //FRatesDlg := TRatesDlg.Create(nil); 7519 DpiApplication.CreateForm(TRatesDlg, FRatesDlg); 7520 FRatesDlg.Show; 7521 end; 7522 Result := FRatesDlg; 7523 end; 7524 7525 function TMainScreen.GetTechTreeDlg: TTechTreeDlg; 7526 begin 7527 if not Assigned(FTechTreeDlg) then FTechTreeDlg := TTechTreeDlg.Create(nil); 7528 Result := FTechTreeDlg; 7529 end; 7530 7531 procedure TMainScreen.mDisbandOrUtilizeClick(Sender: TObject); 7532 var 7533 Loc0: Integer; 7534 begin 7535 if UnFocus >= 0 then 7536 with TUn(MyUn[UnFocus]) do begin 7537 if (Sender = mUtilize) and 7538 not(Server(sRemoveUnit - sExecute, Me, UnFocus, nil^) = eUtilized) then 7539 begin 7540 SimpleMessage(Phrases2.Lookup('SHIP_UTILIZE')); 7541 // freight for colony ship is the only case in which the command is 7542 // available to player though not valid 7543 Exit; 7544 end; 7545 if (Sender = mUtilize) and (Health < 100) then 7546 if SimpleQuery(mkYesNo, Phrases.Lookup('DAMAGED_UTILIZE'), '') <> mrOK 7547 then 7548 Exit; 7549 Loc0 := Loc; 7550 CityOptimizer_BeforeRemoveUnit(UnFocus); 7551 if Server(sRemoveUnit, Me, UnFocus, nil^) = eUtilized then 7552 Play('CITY_UTILIZE') 6780 7553 else 6781 begin 6782 if Server(sGetGameChanged, 0, 0, nil^) = eOK then 6783 begin 6784 QueryText := Phrases.Lookup('RESIGN'); 6785 case SimpleQuery(mkYesNoCancel, QueryText, '') of 6786 mrIgnore: 6787 Server(sResign, 0, 0, nil^); 6788 mrOK: 6789 Server(sBreak, 0, 0, nil^) 6790 end 6791 end 6792 else 6793 Server(sResign, 0, 0, nil^) 6794 end 6795 else if Sender = mEmpire then 6796 RatesDlg.ShowNewContent(wmPersistent) 6797 else if Sender = mRevolution then 6798 begin 6799 AltGovs := false; 6800 for i := 2 to nGov - 1 do 6801 if (GovPreq[i] <> preNA) and 6802 ((GovPreq[i] = preNone) or (MyRO.Tech[GovPreq[i]] >= tsApplicable)) then 6803 AltGovs := true; 6804 6805 if not AltGovs then 6806 SoundMessage(Phrases.Lookup('NOALTGOVS'), 'MSG_DEFAULT') 6807 else 6808 begin 6809 RevolutionChanged := false; 6810 if MyRO.Happened and phChangeGov <> 0 then 6811 begin 6812 ModalSelectDlg.ShowNewContent(wmModal, kGov); 6813 if ModalSelectDlg.result >= 0 then 6814 begin 6815 Play('NEWGOV'); 6816 Server(sSetGovernment, me, ModalSelectDlg.result, nil^); 6817 CityOptimizer_BeginOfTurn; 6818 RevolutionChanged := true; 6819 end 6820 end 6821 else 6822 with MessgExDlg do 6823 begin // revolution! 6824 MessgExDlg.MessgText := Tribe[me].TPhrase('REVOLUTION'); 6825 MessgExDlg.Kind := mkYesNo; 6826 MessgExDlg.IconKind := mikPureIcon; 6827 MessgExDlg.IconIndex := 72; // anarchy palace 6828 MessgExDlg.ShowModal; 6829 if ModalResult = mrOK then 6830 begin 6831 Play('REVOLUTION'); 6832 Server(sRevolution, me, 0, nil^); 6833 RevolutionChanged := true; 6834 if NatStatDlg.Visible then 6835 NatStatDlg.Close; 6836 if CityDlg.Visible then 6837 CityDlg.Close; 6838 end 6839 end; 6840 if RevolutionChanged then 6841 UpdateViews(true); 6842 end 6843 end 6844 else if Sender = mWebsite then 6845 OpenURL(CevoHomepage) 6846 else if Sender = mRandomMap then 6847 begin 6848 if not Edited or (SimpleQuery(mkYesNo, Phrases.Lookup('MAP_RANDOM'), '') 6849 = mrOK) then 6850 begin 6851 Server(sRandomMap, me, 0, nil^); 6852 Edited := true; 6853 MapValid := false; 6854 PaintAllMaps; 6855 end 6856 end 6857 else if Sender = mJump then 6858 begin 6859 if supervising then 6860 Jump[0] := 20 6861 else 6862 Jump[me] := 20; 6863 EndTurn(true); 6864 end 6865 else if Sender = mRun then 6866 begin 6867 if supervising then 6868 Jump[0] := 999999 6869 else 6870 Jump[me] := 999999; 6871 EndTurn(true); 6872 end 6873 else if Sender = mEnhanceDef then 6874 begin 6875 if UnFocus >= 0 then 6876 EnhanceDlg.ShowNewContent(wmPersistent, 6877 MyMap[MyUn[UnFocus].Loc] and fTerrain) 6878 else 6879 EnhanceDlg.ShowNewContent(wmPersistent) 6880 end 6881 else if Sender = mCityTypes then 6882 CityTypeDlg.ShowNewContent(wmModal) 6883 // must be modal because types are not saved before closing 6884 else if Sender = mUnitStat then 6885 begin 6886 if G.Difficulty[me] > 0 then 6887 ListDlg.ShowNewContent_MilReport(wmPersistent, me) 6888 else 6889 begin 6890 i := 1; 6891 while (i < nPl) and (1 shl i and MyRO.Alive = 0) do 6892 inc(i); 6893 if i < nPl then 6894 ListDlg.ShowNewContent_MilReport(wmPersistent, i); 6895 end; 6896 end 6897 else if Sender = mEUnitStat then 6898 begin 6899 if MyRO.nEnemyModel > 0 then 6900 ListDlg.ShowNewContent(wmPersistent, kAllEModels); 6901 end 6902 else if Sender = mCityStat then 6903 ListDlg.ShowNewContent(wmPersistent, kCities) 6904 else if Sender = mScienceStat then 6905 ListDlg.ShowNewContent(wmPersistent, kScience) 6906 else if Sender = mNations then 6907 NatStatDlg.ShowNewContent(wmPersistent) 6908 else if Sender = mHelp then 6909 if ClientMode = cEditMap then 6910 HelpDlg.ShowNewContent(wmPersistent, hkText, HelpDlg.TextIndex('MAPEDIT')) 6911 else 6912 HelpDlg.ShowNewContent(wmPersistent, hkMisc, miscMain) 6913 else if Sender = mTechTree then 6914 TechTreeDlg.ShowModal 6915 else if Sender = mWonders then 6916 WondersDlg.ShowNewContent(wmPersistent) 6917 else if Sender = mDiagram then 6918 DiaDlg.ShowNewContent_Charts(wmPersistent) 6919 else if Sender = mShips then 6920 DiaDlg.ShowNewContent_Ship(wmPersistent) 6921 else if Sender = mWait then 6922 begin 6923 if UnFocus >= 0 then 6924 begin 6925 DestinationMarkON := false; 6926 PaintDestination; 6927 MyUn[UnFocus].Status := MyUn[UnFocus].Status and 6928 ($FFFF - usStay - usRecover - usGoto - usEnhance) or usWaiting; 6929 end; 6930 NextUnit(-1, false); 6931 end 6932 else if UnFocus >= 0 then 6933 with TUn(MyUn[UnFocus]) do 6934 if Sender = mGoOn then 6935 begin 6936 if Status shr 16 = $7FFF then 6937 Destination := maNextCity 6938 else 6939 Destination := Status shr 16; 6940 Status := Status and not(usStay or usRecover) or usWaiting; 6941 MoveToLoc(Destination, true); 6942 end 6943 else if Sender = mHome then 6944 if MyMap[Loc] and fCity <> 0 then 6945 begin 6946 cixOldHome := Home; 6947 if Server(sSetUnitHome, me, UnFocus, nil^) >= rExecuted then 6948 begin 6949 CityOptimizer_CityChange(cixOldHome); 6950 CityOptimizer_CityChange(Home); 6951 UpdateViews(true); 6952 end 6953 else 6954 Play('INVALID'); 6955 end 6956 else 6957 begin 6958 Status := Status and not(usStay or usRecover or usEnhance); 6959 MoveToLoc(maNextCity, true) 6960 end 6961 else if Sender = mCentre then 6962 begin 6963 Centre(Loc); 6964 PaintAllMaps; 6965 end 6966 else if Sender = mCity then 6967 begin 6968 Loc0 := Loc; 6969 if MyMap[Loc] and fCity = 0 then 6970 begin // build city 6971 if DoJob(jCity) = eCity then 6972 begin 6973 MapValid := false; 6974 PaintAll; 6975 ZoomToCity(Loc0, true, chFounded); 6976 end; 6977 end 6978 else 6979 begin 6980 CityOptimizer_BeforeRemoveUnit(UnFocus); 6981 ServerResult := Server(sAddToCity, me, UnFocus, nil^); 6982 if ServerResult >= rExecuted then 6983 begin 6984 cix := MyRO.nCity - 1; 6985 while (cix >= 0) and (MyCity[cix].Loc <> Loc0) do 6986 dec(cix); 6987 assert(cix >= 0); 6988 CityOptimizer_CityChange(cix); 6989 CityOptimizer_AfterRemoveUnit; // does nothing here 6990 SetTroopLoc(Loc0); 6991 UpdateViews(true); 6992 DestinationMarkON := false; 6993 PaintDestination; 6994 UnFocus := -1; 6995 PaintLoc(Loc0); 6996 NextUnit(UnStartLoc, true); 6997 end 6998 else if ServerResult = eMaxSize then 6999 SimpleMessage(Phrases.Lookup('ADDTOMAXSIZE')); 7000 end 7001 end 7002 else if Sender = mRoad then 7003 DoJob(jRoad) 7004 else if Sender = mRR then 7005 DoJob(jRR) 7006 else if Sender = mClear then 7007 DoJob(jClear) 7008 else if Sender = mIrrigation then 7009 DoJob(jIrr) 7010 else if Sender = mFarm then 7011 DoJob(jFarm) 7012 else if Sender = mAfforest then 7013 DoJob(jAfforest) 7014 else if Sender = mMine then 7015 DoJob(jMine) 7016 else if Sender = mCanal then 7017 DoJob(jCanal) 7018 else if Sender = MTrans then 7019 DoJob(jTrans) 7020 else if Sender = mFort then 7021 DoJob(jFort) 7022 else if Sender = mAirBase then 7023 DoJob(jBase) 7024 else if Sender = mPollution then 7025 DoJob(jPoll) 7026 else if Sender = mPillage then 7027 DoJob(jPillage) 7028 else if Sender = mEnhance then 7029 DoJob(-1) 7030 else if Sender = mStay then 7031 begin 7032 DestinationMarkON := false; 7033 PaintDestination; 7034 Status := Status and ($FFFF - usRecover - usGoto - usEnhance) or usStay; 7035 if Job > jNone then 7036 Server(sStartJob + jNone shl 4, me, UnFocus, nil^); 7037 NextUnit(UnStartLoc, true); 7038 end 7039 else if Sender = mRecover then 7040 begin 7041 DestinationMarkON := false; 7042 PaintDestination; 7043 Status := Status and ($FFFF - usStay - usGoto - usEnhance) or usRecover; 7044 if Job > jNone then 7045 Server(sStartJob + jNone shl 4, me, UnFocus, nil^); 7046 NextUnit(UnStartLoc, true); 7047 end 7048 else if Sender = mNoOrders then 7049 begin 7050 Status := Status and not usWaiting; 7051 NextUnit(UnStartLoc, true); 7052 end 7053 else if Sender = mPrevUnit then 7054 begin 7055 Status := Status and not usWaiting; 7056 FocusNextUnit(-1); 7057 end 7058 else if Sender = mNextUnit then 7059 begin 7060 Status := Status and not usWaiting; 7061 FocusNextUnit(1); 7062 end 7063 else if Sender = mCancel then 7064 begin 7065 DestinationMarkON := false; 7066 PaintDestination; 7067 Status := Status and ($FFFF - usRecover - usGoto - usEnhance); 7068 if Job > jNone then 7069 Server(sStartJob + jNone shl 4, me, UnFocus, nil^); 7070 end 7071 else if (Sender = mDisband) or (Sender = mUtilize) then 7072 begin 7073 if (Sender = mUtilize) and 7074 not(Server(sRemoveUnit - sExecute, me, UnFocus, nil^) = eUtilized) 7075 then 7076 begin 7077 SimpleMessage(Phrases2.Lookup('SHIP_UTILIZE')); 7078 // freight for colony ship is the only case in which the command is 7079 // available to player though not valid 7080 exit 7081 end; 7082 if (Sender = mUtilize) and (Health < 100) then 7083 if SimpleQuery(mkYesNo, Phrases.Lookup('DAMAGED_UTILIZE'), '') <> mrOK 7084 then 7085 exit; 7086 Loc0 := Loc; 7087 CityOptimizer_BeforeRemoveUnit(UnFocus); 7088 if Server(sRemoveUnit, me, UnFocus, nil^) = eUtilized then 7089 Play('CITY_UTILIZE') 7090 else 7091 Play('DISBAND'); 7092 CityOptimizer_AfterRemoveUnit; 7093 SetTroopLoc(Loc0); 7094 UpdateViews(true); 7095 DestinationMarkON := false; 7096 PaintDestination; 7097 UnFocus := -1; 7098 PaintLoc(Loc0); 7099 NextUnit(UnStartLoc, true); 7100 end 7101 else if Sender = mLoad then 7102 begin 7103 i := Server(sLoadUnit, me, UnFocus, nil^); 7104 if i >= rExecuted then 7105 begin 7106 if MyModel[mix].Domain = dAir then 7107 Play('MOVE_PLANELANDING') 7108 else 7109 Play('MOVE_LOAD'); 7110 DestinationMarkON := false; 7111 PaintDestination; 7112 Status := Status and ($FFFF - usWaiting - usStay - usRecover - usGoto 7113 - usEnhance); 7114 NextUnit(UnStartLoc, true); 7115 end 7116 else if i = eNoTime_Load then 7117 if MyModel[mix].Domain = dAir then 7118 SoundMessage(Phrases.Lookup('NOTIMELOADAIR'), 'NOMOVE_TIME') 7119 else 7120 SoundMessage(Format(Phrases.Lookup('NOTIMELOADGROUND'), 7121 [MovementToString(MyModel[mix].speed)]), 'NOMOVE_TIME'); 7122 end 7123 else if Sender = mUnload then 7124 if Master >= 0 then 7125 begin 7126 OldMaster := Master; 7127 i := Server(sUnloadUnit, me, UnFocus, nil^); 7128 if i >= rExecuted then 7129 begin 7130 if MyModel[mix].Domain = dAir then 7131 Play('MOVE_PLANESTART') 7132 else if (MyModel[MyUn[OldMaster].mix].Domain = dAir) and 7133 (MyMap[Loc] and fCity = 0) and (MyMap[Loc] and fTerImp <> tiBase) 7134 then 7135 Play('MOVE_PARACHUTE') 7136 else 7137 Play('MOVE_UNLOAD'); 7138 Status := Status and not usWaiting; 7139 if MyModel[mix].Domain <> dAir then 7140 NextUnit(Loc, true) 7141 else 7142 PanelPaint; 7143 end 7144 else if i = eNoTime_Load then 7145 if MyModel[mix].Domain = dAir then 7146 SoundMessage(Phrases.Lookup('NOTIMELOADAIR'), 'NOMOVE_TIME') 7147 else 7148 SoundMessage(Format(Phrases.Lookup('NOTIMELOADGROUND'), 7149 [MovementToString(MyModel[mix].speed)]), 'NOMOVE_TIME'); 7150 end 7151 else 7152 begin 7153 NewFocus := -1; 7154 uix := UnFocus; 7155 for i := 1 to MyRO.nUn - 1 do 7156 begin 7157 uix := (uix + MyRO.nUn - 1) mod MyRO.nUn; 7158 if (MyUn[uix].Master = UnFocus) and 7159 (MyUn[uix].Movement = integer(MyModel[MyUn[uix].mix].speed)) then 7160 begin 7161 MyUn[uix].Status := MyUn[uix].Status or usWaiting; 7162 NewFocus := uix 7163 end; 7164 end; 7165 if NewFocus >= 0 then 7166 begin 7167 SetUnFocus(NewFocus); 7168 SetTroopLoc(Loc); 7169 PanelPaint 7170 end; 7171 end 7172 else if Sender = mSelectTransport then 7173 Server(sSelectTransport, me, UnFocus, nil^) 7554 Play('DISBAND'); 7555 CityOptimizer_AfterRemoveUnit; 7556 SetTroopLoc(Loc0); 7557 UpdateViews(True); 7558 DestinationMarkON := False; 7559 PaintDestination; 7560 UnFocus := -1; 7561 PaintLoc(Loc0); 7562 NextUnit(UnStartLoc, True); 7563 end; 7174 7564 end; 7175 7565 7176 7566 procedure TMainScreen.InitPopup(Popup: TDpiPopupMenu); 7177 7567 var 7178 i, p1, Tile, Test: integer;7179 NoSuper, extended, Multi, NeedSep, HaveCities: boolean;7180 LastSep, m: TDpiMenuItem;7568 I, p1, Tile, Test: Integer; 7569 NoSuper, Extended, Multi, NeedSep, HaveCities: Boolean; 7570 LastSep, M: TDpiMenuItem; 7181 7571 mox: ^TModel; 7182 7572 begin 7183 NoSuper := not supervising and (1 shl me and MyRO.Alive <> 0);7184 HaveCities := false;7185 for i:= 0 to MyRO.nCity - 1 do7186 if MyCity[ i].Loc >= 0 then7573 NoSuper := not Supervising and (1 shl Me and MyRO.Alive <> 0); 7574 HaveCities := False; 7575 for I := 0 to MyRO.nCity - 1 do 7576 if MyCity[I].Loc >= 0 then 7187 7577 begin 7188 HaveCities := true;7578 HaveCities := True; 7189 7579 Break; 7190 7580 end; … … 7192 7582 begin 7193 7583 mTechTree.Visible := ClientMode <> cEditMap; 7194 mResign.Enabled := supervising or (me = 0) and (ClientMode < scContact);7584 mResign.Enabled := Supervising or (Me = 0) and (ClientMode < scContact); 7195 7585 mRandomMap.Visible := (ClientMode = cEditMap) and 7196 (Server(sMapGeneratorRequest, me, 0, nil^) = eOK);7586 (Server(sMapGeneratorRequest, Me, 0, nil^) = eOK); 7197 7587 mOptions.Visible := ClientMode <> cEditMap; 7198 7588 mManip.Visible := ClientMode <> cEditMap; … … 7208 7598 case SoundMode of 7209 7599 smOff: 7210 mSoundOff.Checked := true;7600 mSoundOff.Checked := True; 7211 7601 smOn: 7212 mSoundOn.Checked := true;7602 mSoundOn.Checked := True; 7213 7603 smOnAlt: 7214 mSoundOnAlt.Checked := true;7215 end; 7216 7217 for i:= 0 to nTestFlags - 1 do7218 mManip[ i].Checked := MyRO.TestFlags and (1 shl i) <> 0;7219 mManip.Enabled := supervising or (me = 0);7220 7221 Multi := false;7604 mSoundOnAlt.Checked := True; 7605 end; 7606 7607 for I := 0 to nTestFlags - 1 do 7608 mManip[I].Checked := MyRO.TestFlags and (1 shl I) <> 0; 7609 mManip.Enabled := Supervising or (Me = 0); 7610 7611 Multi := False; 7222 7612 for p1 := 1 to nPl - 1 do 7223 7613 if G.RO[p1] <> nil then 7224 Multi := true;7614 Multi := True; 7225 7615 mEnemyMovement.Visible := not Multi; 7226 7616 end; … … 7228 7618 if NoSuper and (ClientMode < scContact) then 7229 7619 begin 7230 mCityTypes.Enabled := false;7620 mCityTypes.Enabled := False; 7231 7621 // check if city types already usefull: 7232 7622 if MyRO.nCity > 0 then 7233 for i:= nWonder to nImp - 1 do7234 if ( i <> imTrGoods) and (Imp[i].Kind = ikCommon) and7235 (Imp[ i].Preq <> preNA) and7236 ((Imp[ i].Preq = preNone) or (MyRO.Tech[Imp[i].Preq] >= tsApplicable))7623 for I := nWonder to nImp - 1 do 7624 if (I <> imTrGoods) and (Imp[I].Kind = ikCommon) and 7625 (Imp[I].Preq <> preNA) and 7626 ((Imp[I].Preq = preNone) or (MyRO.Tech[Imp[I].Preq] >= tsApplicable)) 7237 7627 then 7238 7628 begin 7239 mCityTypes.Enabled := true;7629 mCityTypes.Enabled := True; 7240 7630 Break 7241 7631 end; 7242 7632 end; 7243 mViewpoint.Visible := (ClientMode <> cEditMap) and supervising;7633 mViewpoint.Visible := (ClientMode <> cEditMap) and Supervising; 7244 7634 mViewpoint.Enabled := G.RO[0].Turn > 0; 7245 if supervising then7635 if Supervising then 7246 7636 begin 7247 7637 EmptyMenu(mViewpoint); … … 7249 7639 if (p1 = 0) or (1 shl p1 and G.RO[0].Alive <> 0) then 7250 7640 begin 7251 m:= TDpiMenuItem.Create(mViewpoint);7641 M := TDpiMenuItem.Create(mViewpoint); 7252 7642 if p1 = 0 then 7253 m.Caption := Phrases.Lookup('SUPER')7643 M.Caption := Phrases.Lookup('SUPER') 7254 7644 else 7255 m.Caption := Tribe[p1].TString(Phrases2.Lookup('BELONG'));7256 m.Tag := p1;7257 m.OnClick := ViewpointClick;7645 M.Caption := Tribe[p1].TString(Phrases2.Lookup('BELONG')); 7646 M.Tag := p1; 7647 M.OnClick := ViewpointClick; 7258 7648 if p1 < 10 then 7259 m.ShortCut := ShortCut(48 + p1, [ssCtrl]);7260 m.RadioItem := true;7261 if p1 = me then7262 m.Checked := true;7263 mViewpoint.Add( m);7649 M.ShortCut := ShortCut(48 + p1, [ssCtrl]); 7650 M.RadioItem := True; 7651 if p1 = Me then 7652 M.Checked := True; 7653 mViewpoint.Add(M); 7264 7654 end 7265 7655 end; 7266 mDebugMap.Visible := (ClientMode <> cEditMap) and supervising;7267 if supervising then7656 mDebugMap.Visible := (ClientMode <> cEditMap) and Supervising; 7657 if Supervising then 7268 7658 begin 7269 7659 EmptyMenu(mDebugMap); … … 7271 7661 if (p1 = 0) or (1 shl p1 and G.RO[0].Alive <> 0) then 7272 7662 begin 7273 m:= TDpiMenuItem.Create(mDebugMap);7663 M := TDpiMenuItem.Create(mDebugMap); 7274 7664 if p1 = 0 then 7275 m.Caption := Phrases2.Lookup('MENU_DEBUGMAPOFF')7665 M.Caption := Phrases2.Lookup('MENU_DEBUGMAPOFF') 7276 7666 else 7277 m.Caption := Tribe[p1].TString(Phrases2.Lookup('BELONG'));7667 M.Caption := Tribe[p1].TString(Phrases2.Lookup('BELONG')); 7278 7668 if p1 = 0 then 7279 m.Tag := -17669 M.Tag := -1 7280 7670 else 7281 m.Tag := p1;7282 m.OnClick := DebugMapClick;7671 M.Tag := p1; 7672 M.OnClick := DebugMapClick; 7283 7673 if p1 < 10 then 7284 m.ShortCut := ShortCut(48 + p1, [ssAlt]);7285 m.RadioItem := true;7286 if m.Tag = MainMap.pDebugMap then7287 m.Checked := true;7288 mDebugMap.Add( m);7674 M.ShortCut := ShortCut(48 + p1, [ssAlt]); 7675 M.RadioItem := True; 7676 if M.Tag = MainMap.pDebugMap then 7677 M.Checked := True; 7678 mDebugMap.Add(M); 7289 7679 end; 7290 7680 end; … … 7301 7691 (ClientMode < scContact); 7302 7692 mUnitStat.Enabled := NoSuper or (MyRO.Turn > 0); 7303 mCityStat.Visible := 1 shl me and MyRO.Alive <> 0;7693 mCityStat.Visible := 1 shl Me and MyRO.Alive <> 0; 7304 7694 mCityStat.Enabled := HaveCities; 7305 mScienceStat.Visible := true;7695 mScienceStat.Visible := True; 7306 7696 mScienceStat.Enabled := not NoSuper or (MyRO.ResearchTech >= 0) or 7307 7697 (MyRO.Happened and phTech <> 0) or (MyRO.Happened and phGameEnd <> 0) … … 7310 7700 mEUnitStat.Enabled := MyRO.nEnemyModel > 0; 7311 7701 { mWonders.Enabled:= false; 7312 for i:=0 to nWonder - 1 do if MyRO.Wonder[i].CityID <> WonderNotBuiltYet then7313 mWonders.Enabled:= true; }7702 for I:=0 to nWonder - 1 do if MyRO.Wonder[I].CityID <> WonderNotBuiltYet then 7703 mWonders.Enabled:=True; } 7314 7704 mDiagram.Enabled := MyRO.Turn >= 2; 7315 mShips.Enabled := false;7705 mShips.Enabled := False; 7316 7706 for p1 := 0 to nPl - 1 do 7317 7707 if MyRO.Ship[p1].Parts[spComp] + MyRO.Ship[p1].Parts[spPow] + 7318 7708 MyRO.Ship[p1].Parts[spHab] > 0 then 7319 mShips.Enabled := true;7709 mShips.Enabled := True; 7320 7710 end 7321 7711 else if Popup = UnitPopup then … … 7323 7713 mox := @MyModel[MyUn[UnFocus].mix]; 7324 7714 Tile := MyMap[MyUn[UnFocus].Loc]; 7325 extended := Tile and fCity = 0;7326 if extended then7715 Extended := Tile and fCity = 0; 7716 if Extended then 7327 7717 begin 7328 7718 mCity.Caption := Phrases.Lookup('BTN_FOUND'); … … 7335 7725 end; 7336 7726 7337 extended := extended and ((mox.Kind = mkSettler) or (mox.Kind = mkSlaves)7727 Extended := Extended and ((mox.Kind = mkSettler) or (mox.Kind = mkSlaves) 7338 7728 and (MyRO.Wonder[woPyramids].EffectiveOwner >= 0)) and 7339 7729 (MyUn[UnFocus].Master < 0) and (Tile and fDeadLands = 0); 7340 7730 if (mox.Kind = mkFreight) and (Tile and fCity <> 0) and 7341 7731 not Phrases2FallenBackToEnglish or 7342 (Server(sRemoveUnit - sExecute, me, UnFocus, nil^) = eUtilized) then7732 (Server(sRemoveUnit - sExecute, Me, UnFocus, nil^) = eUtilized) then 7343 7733 begin 7344 mDisband.Visible := false;7345 mUtilize.Visible := true;7734 mDisband.Visible := False; 7735 mUtilize.Visible := True; 7346 7736 if mox.Kind = mkFreight then 7347 7737 mUtilize.Caption := Phrases.Lookup('UTILIZE') … … 7351 7741 else 7352 7742 begin 7353 mDisband.Visible := true;7354 mUtilize.Visible := false7743 mDisband.Visible := True; 7744 mUtilize.Visible := False 7355 7745 end; 7356 7746 mGoOn.Visible := MyUn[UnFocus].Status and (usGoto or usWaiting) = usGoto or … … 7359 7749 mRecover.Visible := (MyUn[UnFocus].Health < 100) and 7360 7750 (Tile and fTerrain >= fGrass) and 7361 ((MyRO.Wonder[woGardens].EffectiveOwner = me) or7751 ((MyRO.Wonder[woGardens].EffectiveOwner = Me) or 7362 7752 (Tile and fTerrain <> fArctic) and (Tile and fTerrain <> fDesert)) and 7363 7753 not((mox.Domain = dAir) and (Tile and fCity = 0) and … … 7365 7755 mStay.Visible := not((mox.Domain = dAir) and (Tile and fCity = 0) and 7366 7756 (Tile and fTerImp <> tiBase)); 7367 mCity.Visible := extended and (mox.Kind = mkSettler) or7757 mCity.Visible := Extended and (mox.Kind = mkSettler) or 7368 7758 (Tile and fCity <> 0) and ((mox.Kind in [mkSettler, mkSlaves]) or 7369 7759 (MyUn[UnFocus].Flags and unConscripts <> 0)); … … 7373 7763 (MyUn[UnFocus].Status and (usRecover or usGoto) <> 0); 7374 7764 7375 Test := Server(sLoadUnit - sExecute, me, UnFocus, nil^);7765 Test := Server(sLoadUnit - sExecute, Me, UnFocus, nil^); 7376 7766 mLoad.Visible := (Test >= rExecuted) or (Test = eNoTime_Load); 7377 7767 mUnload.Visible := (MyUn[UnFocus].Master >= 0) or 7378 7768 (MyUn[UnFocus].TroopLoad + MyUn[UnFocus].AirLoad > 0); 7379 mSelectTransport.Visible := Server(sSelectTransport - sExecute, me, UnFocus,7769 mSelectTransport.Visible := Server(sSelectTransport - sExecute, Me, UnFocus, 7380 7770 nil^) >= rExecuted; 7381 7771 end … … 7384 7774 mox := @MyModel[MyUn[UnFocus].mix]; 7385 7775 Tile := MyMap[MyUn[UnFocus].Loc]; 7386 extended := Tile and fCity = 0;7776 Extended := Tile and fCity = 0; 7387 7777 7388 7778 if (Tile and fRiver <> 0) and (MyRO.Tech[adBridgeBuilding] >= tsApplicable) … … 7390 7780 begin 7391 7781 mRoad.Caption := Phrases.Lookup('BTN_BUILDBRIDGE'); 7392 mR R.Caption := Phrases.Lookup('BTN_BUILDRRBRIDGE');7782 mRailRoad.Caption := Phrases.Lookup('BTN_BUILDRRBRIDGE'); 7393 7783 end 7394 7784 else 7395 7785 begin 7396 7786 mRoad.Caption := Phrases.Lookup('BTN_BUILDROAD'); 7397 mR R.Caption := Phrases.Lookup('BTN_BUILDRR');7787 mRailRoad.Caption := Phrases.Lookup('BTN_BUILDRR'); 7398 7788 end; 7399 7789 if Tile and fTerrain = fForest then … … 7404 7794 mClear.Caption := Phrases.Lookup('BTN_DRAIN'); 7405 7795 7406 extended := extended and ((mox.Kind = mkSettler) or (mox.Kind = mkSlaves)7796 Extended := Extended and ((mox.Kind = mkSettler) or (mox.Kind = mkSlaves) 7407 7797 and (MyRO.Wonder[woPyramids].EffectiveOwner >= 0)) and 7408 7798 (MyUn[UnFocus].Master < 0); 7409 if extended then7799 if Extended then 7410 7800 begin 7411 7801 mRoad.Visible := JobTest(UnFocus, jRoad, [eNoBridgeBuilding, eTreaty]); 7412 mR R.Visible := JobTest(UnFocus, jRR, [eNoBridgeBuilding, eTreaty]);7802 mRailRoad.Visible := JobTest(UnFocus, jRR, [eNoBridgeBuilding, eTreaty]); 7413 7803 mClear.Visible := JobTest(UnFocus, jClear, [eTreaty]); 7414 7804 mIrrigation.Visible := JobTest(UnFocus, jIrr, [eTreaty]); … … 7427 7817 else 7428 7818 begin 7429 for i:= 0 to Popup.Items.Count - 1 do7430 Popup.Items[ i].Visible := false;7819 for I := 0 to Popup.Items.Count - 1 do 7820 Popup.Items[I].Visible := False; 7431 7821 end; 7432 7822 end; … … 7434 7824 // set menu seperators 7435 7825 LastSep := nil; 7436 NeedSep := false;7437 for i:= 0 to Popup.Items.Count - 1 do7438 if Popup.Items[ i].Caption = '-' then7826 NeedSep := False; 7827 for I := 0 to Popup.Items.Count - 1 do 7828 if Popup.Items[I].Caption = '-' then 7439 7829 begin 7440 Popup.Items[ i].Visible := NeedSep;7830 Popup.Items[I].Visible := NeedSep; 7441 7831 if NeedSep then 7442 LastSep := Popup.Items[ i];7443 NeedSep := false7832 LastSep := Popup.Items[I]; 7833 NeedSep := False 7444 7834 end 7445 else if Popup.Items[ i].Visible then7446 NeedSep := true;7835 else if Popup.Items[I].Visible then 7836 NeedSep := True; 7447 7837 if (LastSep <> nil) and not NeedSep then 7448 LastSep.Visible := false7838 LastSep.Visible := False 7449 7839 end; 7450 7840 … … 7465 7855 end; 7466 7856 7467 procedure TMainScreen.CityClosed(Activateuix: integer; StepFocus: boolean;7468 SelectFocus: boolean);7469 begin 7470 if supervising then7857 procedure TMainScreen.CityClosed(Activateuix: Integer; StepFocus: Boolean; 7858 SelectFocus: Boolean); 7859 begin 7860 if Supervising then 7471 7861 begin 7472 7862 SetTroopLoc(-1); … … 7485 7875 end 7486 7876 else if StepFocus then 7487 NextUnit(TroopLoc, true)7877 NextUnit(TroopLoc, True) 7488 7878 else 7489 7879 begin … … 7496 7886 procedure TMainScreen.Toggle(Sender: TObject); 7497 7887 begin 7498 TDpiMenuItem(Sender).Checked := not TDpiMenuItem(Sender).Checked 7888 TDpiMenuItem(Sender).Checked := not TDpiMenuItem(Sender).Checked; 7499 7889 end; 7500 7890 7501 7891 procedure TMainScreen.PanelBoxMouseMove(Sender: TObject; Shift: TShiftState; 7502 x, y: integer);7892 X, Y: Integer); 7503 7893 var 7504 xCentre, yCentre: integer;7894 xCentre, yCentre: Integer; 7505 7895 begin 7506 7896 if Tracking and (ssLeft in Shift) then 7507 7897 with MainMap do begin 7508 if ( x >= xMini + 2) and (y >= yMini + 2) and (x< xMini + 2 + 2 * G.lx) and7509 ( y< yMini + 2 + G.ly) then7898 if (X >= xMini + 2) and (Y >= yMini + 2) and (X < xMini + 2 + 2 * G.lx) and 7899 (Y < yMini + 2 + G.ly) then 7510 7900 begin 7511 xCentre := (xwMini + ( x- xMini - 2) div 2 + G.lx div 2 +7901 xCentre := (xwMini + (X - xMini - 2) div 2 + G.lx div 2 + 7512 7902 MapWidth div (xxt * 4)) mod G.lx; 7513 yCentre := ( y- yMini - 2);7903 yCentre := (Y - yMini - 2); 7514 7904 xw := (xCentre - MapWidth div (xxt * 4) + G.lx) mod G.lx; 7515 7905 if ywmax <= 0 then … … 7523 7913 yw := ywmax; 7524 7914 end; 7525 DpiBit Canvas(Buffer.Canvas, 0, 0, G.lx * 2, G.ly, MiniMap.Bitmap.Canvas, 0, 0);7915 DpiBitBltCanvas(Buffer.Canvas, 0, 0, G.lx * 2, G.ly, MiniMap.Bitmap.Canvas, 0, 0); 7526 7916 if ywmax <= 0 then 7527 Frame(Buffer.Canvas, x- xMini - 2 - MapWidth div (xxt * 2), 0,7528 x- xMini - 2 + MapWidth div (xxt * 2) - 1, G.ly - 1,7917 Frame(Buffer.Canvas, X - xMini - 2 - MapWidth div (xxt * 2), 0, 7918 X - xMini - 2 + MapWidth div (xxt * 2) - 1, G.ly - 1, 7529 7919 MainTexture.ColorMark, MainTexture.ColorMark) 7530 7920 else 7531 Frame(Buffer.Canvas, x- xMini - 2 - MapWidth div (xxt * 2), yw,7532 x- xMini - 2 + MapWidth div (xxt * 2) - 1, yw + MapHeight div yyt -7921 Frame(Buffer.Canvas, X - xMini - 2 - MapWidth div (xxt * 2), yw, 7922 X - xMini - 2 + MapWidth div (xxt * 2) - 1, yw + MapHeight div yyt - 7533 7923 2, MainTexture.ColorMark, MainTexture.ColorMark); 7534 DpiBit Canvas(Panel.Canvas, xMini + 2, yMini + 2, G.lx * 2, G.ly,7924 DpiBitBltCanvas(Panel.Canvas, xMini + 2, yMini + 2, G.lx * 2, G.ly, 7535 7925 Buffer.Canvas, 0, 0); 7536 7926 MainOffscreenPaint; … … 7542 7932 end 7543 7933 else 7544 Tracking := false;7934 Tracking := False; 7545 7935 end; 7546 7936 7547 7937 procedure TMainScreen.PanelBoxMouseUp(Sender: TObject; Button: TMouseButton; 7548 Shift: TShiftState; x, y: integer);7938 Shift: TShiftState; X, Y: Integer); 7549 7939 begin 7550 7940 if Tracking then 7551 7941 begin 7552 Tracking := false;7942 Tracking := False; 7553 7943 xwMini := xw; 7554 7944 ywMini := yw; … … 7559 7949 7560 7950 procedure TMainScreen.MapBoxMouseMove(Sender: TObject; Shift: TShiftState; 7561 x, y: integer);7951 X, Y: Integer); 7562 7952 var 7563 MouseLoc: integer;7564 begin 7565 xMouse := x;7566 yMouse := y;7953 MouseLoc: Integer; 7954 begin 7955 xMouse := X; 7956 yMouse := Y; 7567 7957 if (ClientMode = cEditMap) and (ssLeft in Shift) and not Tracking then 7568 7958 begin 7569 MouseLoc := LocationOfScreenPixel( x, y);7959 MouseLoc := LocationOfScreenPixel(X, Y); 7570 7960 if MouseLoc <> BrushLoc then 7571 MapBoxMouseDown(nil, mbLeft, Shift, x, y);7961 MapBoxMouseDown(nil, mbLeft, Shift, X, Y); 7572 7962 end 7573 (* else if idle and (UnFocus>=0) then7963 (* else if Idle and (UnFocus>=0) then 7574 7964 begin 7575 7965 qx:=(xMouse*32+yMouse*66+16*66) div(32*66)-1; … … 7584 7974 TDpiMenuItem(Sender).Checked := not TDpiMenuItem(Sender).Checked; 7585 7975 SetMapOptions; 7586 MapValid := false;7976 MapValid := False; 7587 7977 PaintAllMaps; 7588 7978 end; … … 7590 7980 procedure TMainScreen.mNamesClick(Sender: TObject); 7591 7981 var 7592 p1: integer;7982 p1: Integer; 7593 7983 begin 7594 7984 mNames.Checked := not mNames.Checked; … … 7600 7990 else 7601 7991 Tribe[p1].NumberName := p1; 7602 MapValid := false;7992 MapValid := False; 7603 7993 PaintAll; 7604 7994 end; 7605 7995 7606 function TMainScreen.IsPanelPixel( x, y: integer): boolean;7607 begin 7608 result := (y >= TopBarHeight + MapHeight) or (y>= ClientHeight - PanelHeight)7609 and (( x < xMidPanel) or (x>= xRightPanel));7996 function TMainScreen.IsPanelPixel(X, Y: Integer): Boolean; 7997 begin 7998 Result := (Y >= TopBarHeight + MapHeight) or (Y >= ClientHeight - PanelHeight) 7999 and ((X < xMidPanel) or (X >= xRightPanel)); 7610 8000 end; 7611 8001 7612 8002 procedure TMainScreen.FormMouseDown(Sender: TObject; Button: TMouseButton; 7613 Shift: TShiftState; x, y: integer);7614 begin 7615 if idle then7616 if ( x < 40) and (y< 40) then8003 Shift: TShiftState; X, Y: Integer); 8004 begin 8005 if Idle then 8006 if (X < 40) and (Y < 40) then 7617 8007 begin 7618 8008 if GameMode <> cMovie then … … 7626 8016 end; 7627 8017 end 7628 else if IsPanelPixel( x, y) then7629 PanelBoxMouseDown(Sender, Button, Shift, x,7630 y- (ClientHeight - PanelHeight))7631 else if ( y >= TopBarHeight) and (x>= MapOffset) and7632 ( x< MapOffset + MapWidth) then7633 MapBoxMouseDown(Sender, Button, Shift, x - MapOffset, y- TopBarHeight)8018 else if IsPanelPixel(X, Y) then 8019 PanelBoxMouseDown(Sender, Button, Shift, X, 8020 Y - (ClientHeight - PanelHeight)) 8021 else if (Y >= TopBarHeight) and (X >= MapOffset) and 8022 (X < MapOffset + MapWidth) then 8023 MapBoxMouseDown(Sender, Button, Shift, X - MapOffset, Y - TopBarHeight) 7634 8024 end; 7635 8025 7636 8026 procedure TMainScreen.FormMouseMove(Sender: TObject; Shift: TShiftState; 7637 x, y: integer);7638 begin 7639 if idle then7640 if IsPanelPixel( x, y) then7641 PanelBoxMouseMove(Sender, Shift, x, y- (ClientHeight - PanelHeight))7642 else if ( y >= TopBarHeight) and (x>= MapOffset) and7643 ( x< MapOffset + MapWidth) then7644 MapBoxMouseMove(Sender, Shift, x - MapOffset, y- TopBarHeight);8027 X, Y: Integer); 8028 begin 8029 if Idle then 8030 if IsPanelPixel(X, Y) then 8031 PanelBoxMouseMove(Sender, Shift, X, Y - (ClientHeight - PanelHeight)) 8032 else if (Y >= TopBarHeight) and (X >= MapOffset) and 8033 (X < MapOffset + MapWidth) then 8034 MapBoxMouseMove(Sender, Shift, X - MapOffset, Y - TopBarHeight); 7645 8035 end; 7646 8036 7647 8037 procedure TMainScreen.FormMouseUp(Sender: TObject; Button: TMouseButton; 7648 Shift: TShiftState; x, y: integer);7649 begin 7650 if idle then7651 PanelBoxMouseUp(Sender, Button, Shift, x, y- (ClientHeight - PanelHeight));8038 Shift: TShiftState; X, Y: Integer); 8039 begin 8040 if Idle then 8041 PanelBoxMouseUp(Sender, Button, Shift, X, Y - (ClientHeight - PanelHeight)); 7652 8042 end; 7653 8043 … … 7658 8048 with Canvas do 7659 8049 begin // pillarbox, make left and right border black 7660 if me < 0 then8050 if Me < 0 then 7661 8051 Brush.Color := $000000 7662 8052 else … … 7684 8074 Brush.Style := bsClear; 7685 8075 end; 7686 DpiBit Canvas(Canvas, MapOffset, TopBarHeight, MapWidth, MapHeight - overlap,7687 offscreen.Canvas, 0, 0);7688 DpiBit Canvas(Canvas, 0, 0, ClientWidth, TopBarHeight, TopBar.Canvas,8076 DpiBitBltCanvas(Canvas, MapOffset, TopBarHeight, MapWidth, MapHeight - overlap, 8077 Offscreen.Canvas, 0, 0); 8078 DpiBitBltCanvas(Canvas, 0, 0, ClientWidth, TopBarHeight, TopBar.Canvas, 7689 8079 0, 0); 7690 8080 if xMidPanel > MapOffset then 7691 DpiBit Canvas(Canvas, xMidPanel, TopBarHeight + MapHeight - overlap,7692 ClientWidth div 2 - xMidPanel, overlap, offscreen.Canvas,8081 DpiBitBltCanvas(Canvas, xMidPanel, TopBarHeight + MapHeight - overlap, 8082 ClientWidth div 2 - xMidPanel, overlap, Offscreen.Canvas, 7693 8083 xMidPanel - MapOffset, MapHeight - overlap) 7694 8084 else 7695 DpiBit Canvas(Canvas, MapOffset, TopBarHeight + MapHeight - overlap,7696 ClientWidth div 2 - MapOffset, overlap, offscreen.Canvas, 0,8085 DpiBitBltCanvas(Canvas, MapOffset, TopBarHeight + MapHeight - overlap, 8086 ClientWidth div 2 - MapOffset, overlap, Offscreen.Canvas, 0, 7697 8087 MapHeight - overlap); 7698 8088 if xRightPanel < MapOffset + MapWidth then 7699 DpiBit Canvas(Canvas, ClientWidth div 2, TopBarHeight + MapHeight - overlap,7700 xRightPanel - ClientWidth div 2, overlap, offscreen.Canvas,8089 DpiBitBltCanvas(Canvas, ClientWidth div 2, TopBarHeight + MapHeight - overlap, 8090 xRightPanel - ClientWidth div 2, overlap, Offscreen.Canvas, 7701 8091 ClientWidth div 2 - MapOffset, MapHeight - overlap) 7702 8092 else 7703 DpiBit Canvas(Canvas, ClientWidth div 2, TopBarHeight + MapHeight - overlap,8093 DpiBitBltCanvas(Canvas, ClientWidth div 2, TopBarHeight + MapHeight - overlap, 7704 8094 MapOffset + MapWidth - ClientWidth div 2, overlap, 7705 offscreen.Canvas, ClientWidth div 2 - MapOffset,8095 Offscreen.Canvas, ClientWidth div 2 - MapOffset, 7706 8096 MapHeight - overlap); 7707 DpiBit Canvas(Canvas, 0, TopBarHeight + MapHeight - overlap, xMidPanel,8097 DpiBitBltCanvas(Canvas, 0, TopBarHeight + MapHeight - overlap, xMidPanel, 7708 8098 overlap, Panel.Canvas, 0, 0); 7709 DpiBit Canvas(Canvas, xRightPanel, TopBarHeight + MapHeight - overlap,8099 DpiBitBltCanvas(Canvas, xRightPanel, TopBarHeight + MapHeight - overlap, 7710 8100 Panel.width - xRightPanel, overlap, Panel.Canvas, xRightPanel, 0); 7711 DpiBit Canvas(Canvas, 0, TopBarHeight + MapHeight, Panel.width,8101 DpiBitBltCanvas(Canvas, 0, TopBarHeight + MapHeight, Panel.width, 7712 8102 PanelHeight - overlap, Panel.Canvas, 0, overlap); 7713 8103 if (pLogo >= 0) and (G.RO[pLogo] = nil) and (AILogo[pLogo] <> nil) then 7714 DpiBit Canvas(Canvas, xRightPanel + 10 - (16 + 64),8104 DpiBitBltCanvas(Canvas, xRightPanel + 10 - (16 + 64), 7715 8105 ClientHeight - PanelHeight, 64, 64, AILogo[pLogo].Canvas, 0, 0); 7716 8106 end; 7717 8107 7718 procedure TMainScreen.RectInvalidate(Left, Top, Rigth, Bottom: integer);8108 procedure TMainScreen.RectInvalidate(Left, Top, Rigth, Bottom: Integer); 7719 8109 var 7720 8110 r0: HRgn; 7721 8111 begin 7722 8112 r0 := DpiCreateRectRgn(Left, Top, Rigth, Bottom); 7723 InvalidateRgn(Handle, r0, false);8113 InvalidateRgn(Handle, r0, False); 7724 8114 DeleteObject(r0); 7725 8115 end; 7726 8116 7727 procedure TMainScreen.SmartRectInvalidate(Left, Top, Rigth, Bottom: integer);8117 procedure TMainScreen.SmartRectInvalidate(Left, Top, Rigth, Bottom: Integer); 7728 8118 var 7729 i: integer;8119 I: Integer; 7730 8120 r0, r1: HRgn; 7731 8121 begin 7732 8122 r0 := DpiCreateRectRgn(Left, Top, Rigth, Bottom); 7733 for i:= 0 to ControlCount - 1 do7734 if not(Controls[ i] is TArea) and Controls[i].Visible then8123 for I := 0 to ControlCount - 1 do 8124 if not(Controls[I] is TArea) and Controls[I].Visible then 7735 8125 begin 7736 with Controls[ i].BoundsRect do8126 with Controls[I].BoundsRect do 7737 8127 r1 := DpiCreateRectRgn(Left, Top, Right, Bottom); 7738 8128 CombineRgn(r0, r0, r1, RGN_DIFF); 7739 8129 DeleteObject(r1); 7740 8130 end; 7741 InvalidateRgn(Handle, r0, false);8131 InvalidateRgn(Handle, r0, False); 7742 8132 DeleteObject(r0); 7743 8133 end; … … 7804 8194 procedure TMainScreen.FormClose(Sender: TObject; var Action: TCloseAction); 7805 8195 begin 7806 Timer1.Enabled := false;8196 Timer1.Enabled := False; 7807 8197 end; 7808 8198 7809 8199 procedure TMainScreen.Radio(Sender: TObject); 7810 8200 begin 7811 TDpiMenuItem(Sender).Checked := true;8201 TDpiMenuItem(Sender).Checked := True; 7812 8202 end; 7813 8203 7814 8204 procedure TMainScreen.mManipClick(Sender: TObject); 7815 8205 var 7816 Flag: integer;8206 Flag: Integer; 7817 8207 begin 7818 8208 with TDpiMenuItem(Sender) do … … 7826 8216 Play('CHEAT'); 7827 8217 end; 7828 if not supervising then8218 if not Supervising then 7829 8219 begin 7830 8220 if Flag = tfUncover then 7831 8221 begin 7832 MapValid := false;8222 MapValid := False; 7833 8223 PaintAllMaps; 7834 8224 end … … 7854 8244 else 7855 8245 begin 7856 MapValid := false;8246 MapValid := False; 7857 8247 PaintAllMaps; 7858 8248 end; // update main map … … 7873 8263 end; 7874 8264 SetMapOptions; 7875 MapValid := false;8265 MapValid := False; 7876 8266 PaintAllMaps; 7877 8267 end; … … 7891 8281 end; 7892 8282 SetMapOptions; 7893 MapValid := false;8283 MapValid := False; 7894 8284 PaintAllMaps; 7895 8285 end; 7896 8286 7897 procedure TMainScreen.FormKeyUp(Sender: TObject; var Key: word;8287 procedure TMainScreen.FormKeyUp(Sender: TObject; var Key: Word; 7898 8288 Shift: TShiftState); 7899 8289 begin 7900 if idle and (Key = VK_APPS) then8290 if Idle and (Key = VK_APPS) then 7901 8291 begin 7902 8292 InitPopup(GamePopup); … … 7906 8296 GamePopup.Popup(Left + 4, Top + DpiGetSystemMetrics(SM_CYCAPTION) + 4 + 7907 8297 TopBarHeight - 1); 7908 exit;8298 Exit; 7909 8299 end; // windows menu button calls game menu 7910 8300 end; … … 7912 8302 procedure TMainScreen.CreateUnitClick(Sender: TObject); 7913 8303 var 7914 p1, mix: integer;8304 p1, mix: Integer; 7915 8305 begin 7916 8306 p1 := TComponent(Sender).Tag shr 16; 7917 8307 mix := TComponent(Sender).Tag and $FFFF; 7918 if Server(sCreateUnit + p1 shl 4, me, mix, EditLoc) >= rExecuted then8308 if Server(sCreateUnit + p1 shl 4, Me, mix, EditLoc) >= rExecuted then 7919 8309 PaintLoc(EditLoc); 7920 8310 end; … … 7934 8324 SoundMode := smOnAlt; 7935 8325 end; 7936 7937 { procedure TMainScreen.AdviceBtnClick;7938 var7939 OldAdviceLoc: integer;7940 begin7941 DestinationMarkON:=false;7942 PaintDestination;7943 AdvisorDlg.GiveStrategyAdvice;7944 OldAdviceLoc:=MainMap.AdviceLoc;7945 MainMap.AdviceLoc:=-1;7946 PaintLoc(OldAdviceLoc);7947 end; }7948 7949 { procedure TMainScreen.SetAdviceLoc(Loc: integer; AvoidRect: TRect);7950 var7951 OldAdviceLoc,x,y: integer;7952 begin7953 if Loc<>MainMap.AdviceLoc then7954 begin7955 if Loc>=0 then7956 begin // center7957 y:=Loc div G.lx;7958 x:=(Loc+G.lx - AvoidRect.Right div (2*66)) mod G.lx;7959 Centre(y*G.lx+x);7960 PaintAllMaps;7961 end;7962 OldAdviceLoc:=MainMap.AdviceLoc;7963 MainMap.AdviceLoc:=Loc;7964 PaintLoc(OldAdviceLoc);7965 PaintLoc(MainMap.AdviceLoc);7966 end;7967 end; }7968 8326 7969 8327 procedure TMainScreen.UnitInfoBtnClick(Sender: TObject); … … 8004 8362 8005 8363 procedure TMainScreen.SetTileSize(TileSize: TTileSize; Loc: Integer; MapPos: TPoint); 8006 var8007 i: integer;8008 8364 begin 8009 8365 MainMap.TileSize := TileSize; … … 8012 8368 SetMapPos(Loc, MapPos); 8013 8369 PaintAllMaps; 8014 for i := 0 to DpiScreen.FormCount - 1 do 8015 if DpiScreen.Forms[i].Visible and (DpiScreen.Forms[i] is TBufferedDrawDlg) then 8016 TBufferedDrawDlg(DpiScreen.Forms[i]).SmartUpdateContent(false); 8370 ApplyToVisibleForms(faSmartUpdateContent); 8017 8371 end; 8018 8372 8019 8373 procedure TMainScreen.SaveMenuItemsState; 8020 8374 var 8021 i, j: integer;8375 I, J: Integer; 8022 8376 begin 8023 8377 if soTellAI in OptionChecked then OptionChecked := [soTellAI] 8024 8378 else OptionChecked := []; 8025 for i:= 0 to ComponentCount - 1 do8026 if Components[ i] is TDpiMenuItem then8027 for j:= 0 to Length(SaveOption) - 1 do8028 if TDpiMenuItem(Components[ i]).Checked and8029 (TDpiMenuItem(Components[ i]).Tag = SaveOption[j]) then8030 OptionChecked := OptionChecked + [TSaveOption( j)];8379 for I := 0 to ComponentCount - 1 do 8380 if Components[I] is TDpiMenuItem then 8381 for J := 0 to Length(SaveOption) - 1 do 8382 if TDpiMenuItem(Components[I]).Checked and 8383 (TDpiMenuItem(Components[I]).Tag = SaveOption[J]) then 8384 OptionChecked := OptionChecked + [TSaveOption(J)]; 8031 8385 end; 8032 8386 … … 8040 8394 with Reg do 8041 8395 try 8042 OpenKey(AppRegistryKey, true);8396 OpenKey(AppRegistryKey, True); 8043 8397 WriteInteger('TileSize', Integer(MainMap.TileSize)); 8044 8398 WriteInteger('OptionChecked', Integer(OptionChecked)); 8045 8399 WriteInteger('MapOptionChecked', Integer(MapOptionChecked)); 8046 WriteInteger('CityReport', integer(CityRepMask));8400 WriteInteger('CityReport', Integer(CityRepMask)); 8047 8401 finally 8048 8402 Free; … … 8056 8410 end; 8057 8411 8412 procedure TMainScreen.ArrangeDialogs; 8413 begin 8414 ArrangeDialog(FListDlg); 8415 ArrangeDialog(FHelpDlg); 8416 ArrangeDialog(FUnitStatDlg); 8417 ArrangeDialog(FDiaDlg); 8418 ArrangeDialog(FNatStatDlg); 8419 end; 8420 8421 procedure TMainScreen.ArrangeDialog(Form: TBufferedDrawDlg); 8422 begin 8423 if not Assigned(Form) then Exit; 8424 8425 if Form is TListDlg then begin; 8426 ListDlg.UserLeft := 8; 8427 ListDlg.UserTop := TopBarHeight + 8; 8428 end; 8429 if Form is THelpDlg then begin 8430 HelpDlg.UserLeft := DpiScreen.Width - HelpDlg.Width - 8; 8431 HelpDlg.UserTop := TopBarHeight + 8; 8432 end; 8433 if Form is TUnitStatDlg then begin 8434 UnitStatDlg.UserLeft := 397; 8435 UnitStatDlg.UserTop := TopBarHeight + 64; 8436 end; 8437 if Form is TDiaDlg then begin 8438 DiaDlg.UserLeft := (DpiScreen.Width - DiaDlg.Width) div 2; 8439 DiaDlg.UserTop := (DpiScreen.Height - DiaDlg.Height) div 2; 8440 end; 8441 if Form is TNatStatDlg then begin 8442 NatStatDlg.UserLeft := DpiScreen.Width - NatStatDlg.Width - 8; 8443 NatStatDlg.UserTop := DpiScreen.Height - PanelHeight - NatStatDlg.Height - 8; 8444 if NatStatDlg.UserTop < 8 then 8445 NatStatDlg.UserTop := 8; 8446 end; 8447 end; 8448 8058 8449 procedure TMainScreen.ScrollBarUpdate(Sender: TObject); 8059 8450 begin
Note:
See TracChangeset
for help on using the changeset viewer.