Changeset 325 for trunk/LocalPlayer


Ignore:
Timestamp:
Mar 23, 2021, 10:49:30 PM (4 years ago)
Author:
chronos
Message:
  • Modified: Code cleanup.
Location:
trunk/LocalPlayer
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/CityScreen.pas

    r324 r325  
    55
    66uses
    7   {$IFDEF LINUX}
    8   LMessages,
    9   {$ENDIF}
     7  {$IFDEF LINUX}LMessages,{$ENDIF}
    108  Protocol, ClientTools, Term, ScreenTools, IsoEngine, BaseWin,
    119  LCLIntf, LCLType, Messages, SysUtils, Classes, Graphics, Controls, Forms, ExtCtrls,
     
    5351    procedure PageUpBtnClick(Sender: TObject);
    5452    procedure PageDownBtnClick(Sender: TObject);
    55 
     53  private
     54    c: TCity;
     55    Report: TCityReportNew;
     56    cOwner: Integer;
     57    cGov: Integer;
     58    emix: Integer; { enemy model index of produced unit }
     59    cix: Integer;
     60    cLoc: Integer;
     61    Mode: Integer;
     62    ZoomArea: Integer;
     63    Page: Integer;
     64    PageCount: Integer;
     65    BlinkTime: Integer;
     66    OpenSoundEvent: Integer;
     67    SizeClass: Integer;
     68    AgePrepared: Integer;
     69    Optimize_cixTileChange: Integer;
     70    Optimize_TilesBeforeChange: Integer;
     71    Happened: cardinal;
     72    imix: array [0 .. 15] of integer;
     73    CityAreaInfo: TCityAreaInfo;
     74    AreaMap: TIsoMap;
     75    CityMapTemplate: TBitmap;
     76    SmallCityMapTemplate: TBitmap;
     77    Back: TBitmap;
     78    SmallCityMap: TBitmap;
     79    ZoomCityMap: TBitmap;
     80    Template: TBitmap;
     81    IsPort: Boolean;
     82    ProdHint: Boolean;
     83    AllowChange: Boolean;
     84    procedure InitSmallCityMap;
     85    procedure InitZoomCityMap;
     86    procedure ChooseProject;
     87    procedure ChangeCity(d: integer);
     88    procedure ChangeResourceWeights(iResourceWeights: integer);
     89    procedure OnPlaySound(var Msg: TMessage); message WM_PLAYSOUND;
    5690  public
    5791    RestoreUnFocus: integer;
     
    6195    procedure Reset;
    6296    procedure CheckAge;
    63 
    64   private
    65     c: TCity;
    66     Report: TCityReportNew;
    67     cOwner, cGov, emix { enemy model index of produced unit } , cix, cLoc, Mode,
    68       ZoomArea, Page, PageCount, BlinkTime, OpenSoundEvent, SizeClass,
    69       AgePrepared: integer;
    70     Optimize_cixTileChange, Optimize_TilesBeforeChange: integer;
    71     Happened: cardinal;
    72     imix: array [0 .. 15] of integer;
    73     CityAreaInfo: TCityAreaInfo;
    74     AreaMap: TIsoMap;
    75     CityMapTemplate, SmallCityMapTemplate, Back, SmallCityMap, ZoomCityMap,
    76       Template: TBitmap;
    77     IsPort, ProdHint, AllowChange: boolean;
    78     procedure InitSmallCityMap;
    79     procedure InitZoomCityMap;
    80     procedure ChooseProject;
    81     procedure ChangeCity(d: integer);
    82     procedure ChangeResourceWeights(iResourceWeights: integer);
    83     procedure OnPlaySound(var Msg: TMessage); message WM_PLAYSOUND;
    8497  end;
    8598
     
    87100  CityDlg: TCityDlg;
    88101
     102
    89103implementation
    90104
    91105uses
    92   Select, Messg, MessgEx, Help, Tribes, Directories, Math, UPixelPointer, Sound;
     106  Select, Messg, MessgEx, Help, Tribes, Directories, Math, Sound;
    93107
    94108{$R *.lfm}
     
    278292    c := MyCity[cix];
    279293  case MyMap[cLoc] and fTerrain of
    280     fPrairie:
    281       cli1 := cliPrairie;
    282     fHills:
    283       cli1 := cliHills;
    284     fTundra:
    285       cli1 := cliTundra;
     294    fPrairie: cli1 := cliPrairie;
     295    fHills: cli1 := cliHills;
     296    fTundra: cli1 := cliTundra;
    286297  else
    287298    cli1 := cliPlains;
     
    13401351                not csResourceWeightsMask; // off
    13411352              c.Status := MyCity[cix].Status;
    1342               SmartUpdateContent
     1353              SmartUpdateContent;
    13431354            end;
    13441355            exit;
     
    17371748  begin
    17381749    dec(Page);
    1739     SmartUpdateContent
     1750    SmartUpdateContent;
    17401751  end;
    17411752end;
     
    17461757  begin
    17471758    inc(Page);
    1748     SmartUpdateContent
     1759    SmartUpdateContent;
    17491760  end;
    17501761end;
  • trunk/LocalPlayer/IsoEngine.pas

    r324 r325  
    1515  TIsoMap = class
    1616  private
     17    const
     18      Dirx: array [0..7] of Integer = (1, 2, 1, 0, -1, -2, -1, 0);
     19      Diry: array [0..7] of Integer = (-1, 0, 1, 2, 1, 0, -1, -2);
    1720    procedure CityGrid(xm, ym: integer; CityAllowClick: Boolean);
    1821    function IsShoreTile(Loc: integer): boolean;
     
    753756      (MyMap[dLoc(Loc, -2, 2)] and fObserved <> 0) and
    754757      (MyMap[dLoc(Loc, 2, 2)] and fObserved <> 0) then
    755       result := result or fObserved
     758      result := result or fObserved;
    756759  end
    757760  else if Loc < 0 then
     
    762765    if (MyMap[dLoc(Loc, -1, 1)] and fObserved <> 0) and
    763766      (MyMap[dLoc(Loc, 1, 1)] and fObserved <> 0) then
    764       result := result or fObserved
     767      result := result or fObserved;
    765768  end
    766769  else if Loc < G.lx * (G.ly + 1) then
     
    771774    if (MyMap[dLoc(Loc, -1, -1)] and fObserved <> 0) and
    772775      (MyMap[dLoc(Loc, 1, -1)] and fObserved <> 0) then
    773       result := result or fObserved
     776      result := result or fObserved;
    774777  end
    775778  else if Loc < G.lx * (G.ly + 2) then
     
    782785      (MyMap[dLoc(Loc, -2, -2)] and fObserved <> 0) and
    783786      (MyMap[dLoc(Loc, 2, -2)] and fObserved <> 0) then
    784       result := result or fObserved
    785   end
    786 end;
    787 
    788 const
    789   Dirx: array [0 .. 7] of integer = (1, 2, 1, 0, -1, -2, -1, 0);
    790   Diry: array [0 .. 7] of integer = (-1, 0, 1, 2, 1, 0, -1, -2);
     787      result := result or fObserved;
     788  end;
     789end;
    791790
    792791function TIsoMap.Connection4(Loc, Mask, Value: integer): integer;
     
    811810function TIsoMap.Connection8(Loc, Mask: integer): integer;
    812811var
    813   Dir, ConnLoc: integer;
     812  Dir: Integer;
     813  ConnLoc: Integer;
    814814begin
    815815  result := 0;
     
    825825function TIsoMap.OceanConnection(Loc: integer): integer;
    826826var
    827   Dir, ConnLoc: integer;
     827  Dir: Integer;
     828  ConnLoc: Integer;
    828829begin
    829830  result := 0;
     
    839840procedure TIsoMap.PaintShore(x, y, Loc: integer);
    840841var
    841   Conn, Tile: integer;
     842  Conn: Integer;
     843  Tile: Integer;
    842844begin
    843845  if (y <= FTop - yyt * 2) or (y > FBottom) or (x <= FLeft - xxt * 2) or
     
    13331335
    13341336function TIsoMap.IsShoreTile(Loc: integer): boolean;
    1335 const
    1336   Dirx: array [0 .. 7] of integer = (1, 2, 1, 0, -1, -2, -1, 0);
    1337   Diry: array [0 .. 7] of integer = (-1, 0, 1, 2, 1, 0, -1, -2);
    1338 var
    1339   Dir, ConnLoc: integer;
     1337var
     1338  Dir: Integer;
     1339  ConnLoc: integer;
    13401340begin
    13411341  result := false;
     
    13451345    if (ConnLoc < 0) or (ConnLoc >= G.lx * G.ly) or
    13461346      ((MyMap[ConnLoc] - 2) and fTerrain < 13) then
    1347       result := true
    1348   end
     1347      result := true;
     1348  end;
    13491349end;
    13501350
  • trunk/LocalPlayer/Term.pas

    r321 r325  
    224224    procedure MovieSpeedBtnClick(Sender: TObject);
    225225  private
    226     xw, yw, xwd, ywd, xwMini, ywMini, xMidPanel, xRightPanel, xTroop, xTerrain,
    227       xMini, yMini, ywmax, ywcenter, TroopLoc, TrCnt, TrRow, TrPitch, MapWidth,
    228       MapOffset, MapHeight, BlinkTime, BrushLoc, EditLoc, xMouse,
    229       yMouse: integer;
     226    xw: Integer;
     227    yw: Integer;
     228    xwd: Integer;
     229    ywd: Integer;
     230    xwMini: Integer;
     231    ywMini: Integer;
     232    xMidPanel: Integer;
     233    xRightPanel: Integer;
     234    xTroop: Integer;
     235    xTerrain: Integer;
     236    xMini: Integer;
     237    yMini: Integer;
     238    ywmax: Integer;
     239    ywcenter: Integer;
     240    TroopLoc: Integer;
     241    TrCnt: Integer;
     242    TrRow: Integer;
     243    TrPitch: Integer;
     244    MapWidth: Integer;
     245    MapOffset: Integer;
     246    MapHeight: Integer;
     247    BlinkTime: Integer;
     248    BrushLoc: Integer;
     249    EditLoc: Integer;
     250    xMouse: Integer;
     251    yMouse: Integer;
    230252    BrushType: Cardinal;
    231     trix: array [0 .. 63] of integer;
     253    trix: array [0 .. 63] of Integer;
    232254    AILogo: array [0 .. nPl - 1] of TBitmap;
    233     Mini, Panel, TopBar: TBitmap;
     255    Mini: TBitmap;
     256    Panel: TBitmap;
     257    TopBar: TBitmap;
    234258    sb: TPVScrollbar;
    235     Closable, RepaintOnResize, Tracking, TurnComplete, Edited, GoOnPhase,
    236       HaveStrategyAdvice, FirstMovieTurn: boolean;
     259    Closable: Boolean;
     260    RepaintOnResize: Boolean;
     261    Tracking: Boolean;
     262    TurnComplete: Boolean;
     263    Edited: Boolean;
     264    GoOnPhase: Boolean;
     265    HaveStrategyAdvice: Boolean;
     266    FirstMovieTurn: Boolean;
    237267    PrevWindowState: TWindowState;
    238268    CurrentWindowState: TWindowState;
     
    322352  end;
    323353
    324   TPriceSet = Set of $00 .. $FF;
     354  TPriceSet = set of $00 .. $FF;
    325355
    326356const
     
    416446  sbAll = $FF;
    417447
    418   TileSizes: array [TTileSize] of TPoint = ((X: 33; Y: 16), (X: 48; Y: 24), (X: 72; Y: 36));
     448  TileSizes: array [TTileSize] of TPoint = ((X: 33; Y: 16), (X: 48; Y: 24),
     449    (X: 72; Y: 36));
    419450
    420451type
     
    432463    ToldWonders: array [0 .. 27] of TWonderInfo;
    433464    ToldTech: array [0 .. nAdv - 1] of ShortInt;
     465  end;
     466
     467  TDipMem = record
     468    pContact: Integer;
     469    SentCommand: Integer;
     470    FormerTreaty: Integer;
     471    SentOffer: TOffer;
     472    DeliveredPrices: TPriceSet;
     473    ReceivedPrices: TPriceSet;
    434474  end;
    435475
     
    468508  TribeOriginal: array [0 .. nPl - 1] of Boolean;
    469509  LostArmy: array [0 .. nPl * nMmax - 1] of Integer;
    470   DipMem: array [0 .. nPl - 1] of record
    471     pContact: Integer;
    472     SentCommand: Integer;
    473     FormerTreaty: Integer;
    474     SentOffer: TOffer;
    475     DeliveredPrices: TPriceSet;
    476     ReceivedPrices: TPriceSet;
    477   end;
     510  DipMem: array [0 .. nPl - 1] of TDipMem;
    478511
    479512function CityEventName(i: integer): string;
     
    41894222      Brush.Style := bsClear;
    41904223      OffscreenUser := self;
    4191       exit
     4224      exit;
    41924225    end;
    41934226
     
    42144247    offscreen.Canvas.Font.Assign(UniFont[ftSmall]);
    42154248    ProcessRect(xw, yw, MapWidth div xxt, MapHeight div yyt,
    4216       prPaint or prInvalidate)
     4249      prPaint or prInvalidate);
    42174250  end
    42184251  else
     
    42854318        TopBarHeight + MapHeight - overlap);
    42864319    RectInvalidate(xMidPanel, TopBarHeight + MapHeight - overlap, xRightPanel,
    4287       TopBarHeight + MapHeight)
     4320      TopBarHeight + MapHeight);
    42884321  end;
    42894322  // if (xwd<>xw) or (ywd<>yw) then
     
    49534986  end;
    49544987  RectInvalidate(0, 0, ClientWidth, TopBarHeight);
    4955 end; { PanelPaint }
     4988end;
    49564989
    49574990procedure TMainScreen.FocusOnLoc(Loc: integer; Options: integer = 0);
     
    49685001  begin
    49695002    Centre(Loc);
    4970     PaintAllMaps
     5003    PaintAllMaps;
    49715004  end
    49725005  else if not MapValid then
     
    50035036        begin
    50045037          NewFocus := uix;
    5005           Break
     5038          Break;
    50065039        end
    50075040        else
     
    50115044          begin
    50125045            NewFocus := uix;
    5013             Dist := TestDist
    5014           end
    5015         end
     5046            Dist := TestDist;
     5047          end;
     5048        end;
    50165049    end;
    50175050    if GotoOnly then
     
    50435076    PanelPaint;
    50445077  end;
    5045 end; { NextUnit }
     5078end;
    50465079
    50475080procedure TMainScreen.Scroll(dx, dy: integer);
     
    50835116          PaintLocTemp(MyUn[UnFocus].Loc)
    50845117        else if TurnComplete and not supervising then
    5085           EOT.SetButtonIndexFast(eotBlinkOn)
    5086       end
     5118          EOT.SetButtonIndexFast(eotBlinkOn);
     5119      end;
    50875120    end
    50885121    else
     
    51135146            Screen.ActiveForm.OnDeactivate(nil);
    51145147          Scroll(dx, dy);
    5115         end
     5148        end;
    51165149      end;
    51175150
     
    51345167          EOT.SetButtonIndexFast(eotBlinkOff)
    51355168        else if BlinkTime = BlinkOffTime then
    5136           EOT.SetButtonIndexFast(eotBlinkOn)
    5137       end
    5138     end
     5169          EOT.SetButtonIndexFast(eotBlinkOn);
     5170      end;
     5171    end;
    51395172end;
    51405173
     
    51555188    else if yw > ywmax then
    51565189      yw := ywmax;
    5157   end
     5190  end;
    51585191end;
    51595192
Note: See TracChangeset for help on using the changeset viewer.