Changeset 447 for trunk/NoTerm.pas


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

Legend:

Unmodified
Added
Removed
  • trunk/NoTerm.pas

    r442 r447  
    1818    procedure FormPaint(Sender: TObject);
    1919    procedure FormCreate(Sender: TObject);
    20     procedure FormKeyDown(Sender: TObject; var Key: word; Shift: TShiftState);
     20    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    2121  public
    22     procedure Client(Command, Player: integer; var Data);
     22    procedure Client(Command, Player: Integer; var Data);
    2323  private
    2424    Me: Integer;
     
    4343    procedure NewStat;
    4444    procedure EndPlaying;
    45     procedure ShowActive(p: integer; Active: boolean);
     45    procedure ShowActive(P: Integer; Active: Boolean);
    4646    procedure ShowYear;
    4747  end;
     
    5050  NoTermDlg: TNoTermDlg;
    5151
    52 procedure Client(Command, Player: integer; var Data); stdcall;
     52procedure Client(Command, Player: Integer; var Data); stdcall;
    5353
    5454
     
    6969  dxBrain = 128;
    7070  dyBrain = 128;
    71   xBrain: array [0 .. nPlOffered - 1] of integer = (x0Brain, x0Brain,
     71  xBrain: array [0 .. nPlOffered - 1] of Integer = (x0Brain, x0Brain,
    7272    x0Brain + dxBrain, x0Brain + dxBrain, x0Brain + dxBrain, x0Brain,
    7373    x0Brain - dxBrain, x0Brain - dxBrain, x0Brain - dxBrain);
    74   yBrain: array [0 .. nPlOffered - 1] of integer = (y0Brain, y0Brain - dyBrain,
     74  yBrain: array [0 .. nPlOffered - 1] of Integer = (y0Brain, y0Brain - dyBrain,
    7575    y0Brain - dyBrain, y0Brain, y0Brain + dyBrain, y0Brain + dyBrain,
    7676    y0Brain + dyBrain, y0Brain, y0Brain - dyBrain);
    77   xActive: array [0 .. nPlOffered - 1] of integer = (0, 0, 36, 51, 36, 0,
     77  xActive: array [0 .. nPlOffered - 1] of Integer = (0, 0, 36, 51, 36, 0,
    7878    -36, -51, -36);
    79   yActive: array [0 .. nPlOffered - 1] of integer = (0, -51, -36, 0, 36, 51,
     79  yActive: array [0 .. nPlOffered - 1] of Integer = (0, -51, -36, 0, 36, 51,
    8080    36, 0, -36);
    8181
    8282var
    83   FormsCreated: boolean;
     83  FormsCreated: Boolean;
    8484
    8585procedure TNoTermDlg.FormCreate(Sender: TObject);
     
    108108procedure TNoTermDlg.EndPlaying;
    109109var
    110   EndCommand: integer;
     110  EndCommand: Integer;
    111111begin
    112112  NewStat;
    113   if G.RO[me].Turn > 0 then
     113  if G.RO[Me].Turn > 0 then
    114114    with MessgDlg do
    115115    begin
     
    127127end;
    128128
    129 procedure TNoTermDlg.ShowActive(p: integer; Active: boolean);
    130 begin
    131   if p < nPlOffered then
    132     Sprite(Canvas, HGrSystem, x0Brain + 28 + xActive[p],
    133       y0Brain + 28 + yActive[p], 8, 8, 81 + 9 * Byte(Active), 16);
     129procedure TNoTermDlg.ShowActive(P: Integer; Active: Boolean);
     130begin
     131  if P < nPlOffered then
     132    Sprite(Canvas, HGrSystem, x0Brain + 28 + xActive[P],
     133      y0Brain + 28 + yActive[P], 8, 8, 81 + 9 * Byte(Active), 16);
    134134end;
    135135
     
    138138  Fill(State.Canvas, 0, 0, 192, 20, 64, 287 + 138);
    139139  RisedTextOut(State.Canvas, 0, 0, Format(Phrases.Lookup('AIT_ROUND'), [Round])
    140     + ' ' + TurnToString(G.RO[me].Turn));
     140    + ' ' + TurnToString(G.RO[Me].Turn));
    141141  BitBltCanvas(Canvas, 64, 287 + 138, 192, 20, State.Canvas, 0, 0);
    142142end;
    143143
    144 procedure TNoTermDlg.Client(Command, Player: integer; var Data);
    145 var
    146   i, x, y, p: integer;
    147   ActiveDuration: extended;
    148   ShipComplete: boolean;
    149   r: TRect;
     144procedure TNoTermDlg.Client(Command, Player: Integer; var Data);
     145var
     146  I, X, Y, P: Integer;
     147  ActiveDuration: Extended;
     148  ShipComplete: Boolean;
     149  R: TRect;
    150150  nowt: TDateTime;
    151151begin
    152152  case Command of
    153153    cDebugMessage:
    154       LogDlg.Add(Player, G.RO[0].Turn, pchar(@Data));
     154      LogDlg.Add(Player, G.RO[0].Turn, PChar(@Data));
    155155
    156156    cInitModule:
     
    160160        Shade := TBitmap.Create;
    161161        Shade.SetSize(64, 64);
    162         for x := 0 to 63 do
    163           for y := 0 to 63 do
    164             if Odd(x + y) then
    165               Shade.Canvas.Pixels[x, y] := $FFFFFF
     162        for X := 0 to 63 do
     163          for Y := 0 to 63 do
     164            if Odd(X + Y) then
     165              Shade.Canvas.Pixels[X, Y] := $FFFFFF
    166166            else
    167               Shade.Canvas.Pixels[x, y] := $000000;
     167              Shade.Canvas.Pixels[X, Y] := $000000;
    168168        State := TBitmap.Create;
    169169        State.SetSize(192, 20);
     
    181181    cNewGame, cLoadGame:
    182182      begin
    183         inc(Round);
     183        Inc(Round);
    184184        if Mode = rmRunning then
    185185        begin
     
    190190          Show;
    191191        G := TNewGameData(Data);
    192         LogDlg.mSlot.Visible := false;
     192        LogDlg.mSlot.Visible := False;
    193193        LogDlg.Host := nil;
    194         ToldAlive := G.RO[me].Alive;
     194        ToldAlive := G.RO[Me].Alive;
    195195        Active := -1;
    196196        FillChar(DisallowShowActive, SizeOf(DisallowShowActive), 0); // false
     
    213213    cTurn, cResume, cContinue:
    214214      begin
    215         me := Player;
     215        Me := Player;
    216216        if Active >= 0 then
    217217        begin
    218           ShowActive(Active, false);
     218          ShowActive(Active, False);
    219219          Active := -1;
    220220        end; // should not happen
     
    228228        TurnTime := SecondOf(nowt - LastNewTurn);
    229229        LastNewTurn := nowt;
    230         if (G.RO[me].Alive <> ToldAlive) then
    231         begin
    232           for p := 1 to nPlOffered - 1 do
    233             if 1 shl p and (G.RO[me].Alive xor ToldAlive) <> 0 then
     230        if (G.RO[Me].Alive <> ToldAlive) then
     231        begin
     232          for P := 1 to nPlOffered - 1 do
     233            if 1 shl P and (G.RO[Me].Alive xor ToldAlive) <> 0 then
    234234            begin
    235               r := Rect(xBrain[p], yBrain[p] - 16, xBrain[p] + 64,
    236                 yBrain[p] - 16 + 64);
    237               InvalidateRect(Handle, @r, false);
     235              R := Rect(xBrain[P], yBrain[P] - 16, xBrain[P] + 64,
     236                yBrain[P] - 16 + 64);
     237              InvalidateRect(Handle, @R, False);
    238238            end;
    239           ToldAlive := G.RO[me].Alive;
     239          ToldAlive := G.RO[Me].Alive;
    240240        end;
    241241        Application.ProcessMessages;
    242242        if Mode = rmQuit then
    243243          EndPlaying
    244         else if G.RO[me].Happened and phGameEnd <> 0 then
     244        else if G.RO[Me].Happened and phGameEnd <> 0 then
    245245        begin // game ended, update statistics
    246           for p := 1 to nPlOffered - 1 do
    247             if Assigned(PlayersBrain[p]) then
    248               if 1 shl p and G.RO[me].Alive = 0 then
    249                 inc(ExtStat[p]) // extinct
    250               else if G.RO[me].Alive = 1 shl p then
    251                 inc(AloneStat[p]) // only player alive
     246          for P := 1 to nPlOffered - 1 do
     247            if Assigned(PlayersBrain[P]) then
     248              if 1 shl P and G.RO[Me].Alive = 0 then
     249                Inc(ExtStat[P]) // extinct
     250              else if G.RO[Me].Alive = 1 shl P then
     251                Inc(AloneStat[P]) // only player alive
    252252              else
    253253              begin // alive but not alone -- check colony ship
    254                 ShipComplete := true;
    255                 for i := 0 to nShipPart - 1 do
    256                   if G.RO[me].Ship[p].Parts[i] < ShipNeed[i] then
    257                     ShipComplete := false;
     254                ShipComplete := True;
     255                for I := 0 to nShipPart - 1 do
     256                  if G.RO[Me].Ship[P].Parts[I] < ShipNeed[I] then
     257                    ShipComplete := False;
    258258                if ShipComplete then
    259                   inc(WinStat[p]);
     259                  Inc(WinStat[P]);
    260260              end;
    261261          if Mode = rmRunning then
    262             Server(sNextRound, me, 0, nil^);
     262            Server(sNextRound, Me, 0, nil^);
    263263        end
    264264        else if Mode = rmRunning then
    265           Server(sTurn, me, 0, nil^);
     265          Server(sTurn, Me, 0, nil^);
    266266        if Mode = rmStop then
    267267        begin
     
    280280          TotalStatTime := TotalStatTime + ActiveDuration;
    281281          if not DisallowShowActive[Active] then
    282             ShowActive(Active, false);
     282            ShowActive(Active, False);
    283283          DisallowShowActive[Active] := (ActiveDuration < TurnTime * 0.25) and
    284284            (ActiveDuration < ShowActiveThreshold);
     
    286286        LastShowTurnChange := nowt;
    287287
    288         Active := integer(Data);
     288        Active := Integer(Data);
    289289        if (Active >= 0) and not DisallowShowActive[Active] then
    290           ShowActive(Active, true);
     290          ShowActive(Active, True);
    291291      end;
    292292  end;
     
    302302    GoBtn.ButtonIndex := 23;
    303303    GoBtn.Update;
    304     Server(sTurn, me, 0, nil^);
     304    Server(sTurn, Me, 0, nil^);
    305305  end;
    306306end;
     
    314314procedure TNoTermDlg.FormPaint(Sender: TObject);
    315315var
    316   i, TimeShare: integer;
     316  I, TimeShare: Integer;
    317317begin
    318318  Fill(Canvas, 3, 3, ClientWidth - 6, ClientHeight - 6, 0, 0);
     
    330330    7, Caption);
    331331  Canvas.Font.Assign(UniFont[ftSmall]);
    332   for i := 1 to nPlOffered - 1 do
    333     if Assigned(PlayersBrain[i]) then
     332  for I := 1 to nPlOffered - 1 do
     333    if Assigned(PlayersBrain[I]) then
    334334    begin
    335       Frame(Canvas, xBrain[i] - 24, yBrain[i] - 8 - 16, xBrain[i] - 24 + 111,
    336         yBrain[i] - 8 - 16 + 111, MainTexture.ColorBevelShade,
     335      Frame(Canvas, xBrain[I] - 24, yBrain[I] - 8 - 16, xBrain[I] - 24 + 111,
     336        yBrain[I] - 8 - 16 + 111, MainTexture.ColorBevelShade,
    337337        MainTexture.ColorBevelShade);
    338       FrameImage(Canvas, PlayersBrain[i].Picture, xBrain[i],
    339         yBrain[i] - 16, 64, 64, 0, 0);
    340       if 1 shl i and G.RO[me].Alive = 0 then
    341         BitBltCanvas(Canvas, xBrain[i], yBrain[i] - 16, 64, 64,
     338      FrameImage(Canvas, PlayersBrain[I].Picture, xBrain[I],
     339        yBrain[I] - 16, 64, 64, 0, 0);
     340      if 1 shl I and G.RO[Me].Alive = 0 then
     341        BitBltCanvas(Canvas, xBrain[I], yBrain[I] - 16, 64, 64,
    342342          Shade.Canvas, 0, 0, SRCAND);
    343       Sprite(Canvas, HGrSystem, xBrain[i] + 30 - 14, yBrain[i] + 53, 14,
     343      Sprite(Canvas, HGrSystem, xBrain[I] + 30 - 14, yBrain[I] + 53, 14,
    344344        14, 1, 316);
    345       RisedTextOut(Canvas, xBrain[i] + 30 - 16 - BiColorTextWidth(Canvas,
    346         IntToStr(WinStat[i])), yBrain[i] + 51, IntToStr(WinStat[i]));
    347       Sprite(Canvas, HGrSystem, xBrain[i] + 34, yBrain[i] + 53, 14, 14,
     345      RisedTextOut(Canvas, xBrain[I] + 30 - 16 - BiColorTextWidth(Canvas,
     346        IntToStr(WinStat[I])), yBrain[I] + 51, IntToStr(WinStat[I]));
     347      Sprite(Canvas, HGrSystem, xBrain[I] + 34, yBrain[I] + 53, 14, 14,
    348348        1 + 15, 316);
    349       RisedTextOut(Canvas, xBrain[i] + 34 + 16, yBrain[i] + 51,
    350         IntToStr(AloneStat[i]));
    351       Sprite(Canvas, HGrSystem, xBrain[i] + 30 - 14, yBrain[i] + 53 + 16, 14,
     349      RisedTextOut(Canvas, xBrain[I] + 34 + 16, yBrain[I] + 51,
     350        IntToStr(AloneStat[I]));
     351      Sprite(Canvas, HGrSystem, xBrain[I] + 30 - 14, yBrain[I] + 53 + 16, 14,
    352352        14, 1 + 30, 316);
    353       RisedTextOut(Canvas, xBrain[i] + 30 - 16 - BiColorTextWidth(Canvas,
    354         IntToStr(ExtStat[i])), yBrain[i] + 51 + 16, IntToStr(ExtStat[i]));
    355       Sprite(Canvas, HGrSystem, xBrain[i] + 34, yBrain[i] + 53 + 16, 14, 14,
     353      RisedTextOut(Canvas, xBrain[I] + 30 - 16 - BiColorTextWidth(Canvas,
     354        IntToStr(ExtStat[I])), yBrain[I] + 51 + 16, IntToStr(ExtStat[I]));
     355      Sprite(Canvas, HGrSystem, xBrain[I] + 34, yBrain[I] + 53 + 16, 14, 14,
    356356        1 + 45, 316);
    357357      if TotalStatTime > 0 then
    358358      begin
    359         TimeShare := trunc(TimeStat[i] / TotalStatTime * 100 + 0.5);
    360         RisedTextOut(Canvas, xBrain[i] + 34 + 16, yBrain[i] + 51 + 16,
     359        TimeShare := trunc(TimeStat[I] / TotalStatTime * 100 + 0.5);
     360        RisedTextOut(Canvas, xBrain[I] + 34 + 16, yBrain[I] + 51 + 16,
    361361          IntToStr(TimeShare) + '%');
    362362      end;
    363       ShowActive(i, i = Active);
     363      ShowActive(I, I = Active);
    364364    end;
    365365  Sprite(Canvas, HGrSystem2, x0Brain + 32 - 20, y0Brain + 32 - 20, 40,
     
    381381end;
    382382
    383 procedure TNoTermDlg.FormKeyDown(Sender: TObject; var Key: word;
     383procedure TNoTermDlg.FormKeyDown(Sender: TObject; var Key: Word;
    384384  Shift: TShiftState);
    385385begin
Note: See TracChangeset for help on using the changeset viewer.