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

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/Nego.pas

    r442 r447  
    1515type
    1616  THistory = record
    17     n: Integer;
     17    N: Integer;
    1818    Text: array[0 .. MaxHistory - 1] of ansistring;
    1919  end;
     
    5959    procedure FormDestroy(Sender: TObject);
    6060    procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
    61       Shift: TShiftState; X, Y: integer);
     61      Shift: TShiftState; X, Y: Integer);
    6262    procedure OkBtnClick(Sender: TObject);
    6363    procedure BwdBtnClick(Sender: TObject);
     
    7878
    7979  private
    80     Page, DipCommand: integer;
     80    Page, DipCommand: Integer;
    8181    CurrentOffer: TOffer;
    8282    MyAllowed, OppoAllowed: TPriceSet;
     
    8484    History: array [0 .. nPl - 1] of THistory;
    8585    RomanFont: TFont;
    86     Costs, Delivers: array [0 .. 11] of cardinal;
     86    Costs, Delivers: array [0 .. 11] of Cardinal;
    8787    procedure ResetCurrentOffer;
    8888    procedure BuildCurrentOffer;
    8989    procedure FindAllowed;
    9090    procedure SplitText(Text: string; Bounds: TRect);
    91     procedure PaintNationPicture(X, Y, p: integer);
     91    procedure PaintNationPicture(X, Y, P: Integer);
    9292    procedure SetButtonStates;
    9393  end;
     
    183183procedure TNegoDlg.ResetCurrentOffer;
    184184var
    185   i: integer;
     185  I: Integer;
    186186begin
    187187  CurrentOffer.nDeliver := 0;
    188188  CurrentOffer.nCost := 0;
    189   for i := 0 to 11 do
    190     Costs[i] := $FFFFFFFF;
    191   for i := 0 to 11 do
    192     Delivers[i] := $FFFFFFFF;
     189  for I := 0 to 11 do
     190    Costs[I] := $FFFFFFFF;
     191  for I := 0 to 11 do
     192    Delivers[I] := $FFFFFFFF;
    193193end;
    194194
     
    201201  else
    202202    PassBtn.SmartHint := Phrases.Lookup('BTN_PASS');
    203   case MyRO.Treaty[DipMem[me].pContact] of
     203  case MyRO.Treaty[DipMem[Me].pContact] of
    204204    trNone:
    205205      begin
     
    237237begin
    238238  if ClientMode <> scDipStart then
    239     with History[me] do
    240     begin
    241       if n = MaxHistory then
    242       begin
    243         move(Text[2], Text[0], (MaxHistory - 2) * sizeof(integer));
    244         dec(n, 2);
     239    with History[Me] do
     240    begin
     241      if N = MaxHistory then
     242      begin
     243        Move(Text[2], Text[0], (MaxHistory - 2) * SizeOf(Integer));
     244        Dec(N, 2);
    245245      end;
    246       Text[n] := copy(DipCommandToString(DipMem[me].pContact, me,
    247         DipMem[me].FormerTreaty, DipMem[me].SentCommand, ClientMode,
    248         DipMem[me].SentOffer, ReceivedOffer), 1, 255);
    249       inc(n);
     246      Text[N] := Copy(DipCommandToString(DipMem[Me].pContact, Me,
     247        DipMem[Me].FormerTreaty, DipMem[Me].SentCommand, ClientMode,
     248        DipMem[Me].SentOffer, ReceivedOffer), 1, 255);
     249      Inc(N);
    250250    end;
    251   assert(History[me].n mod 2 = 1);
    252 
    253   Page := History[me].n;
     251  Assert(History[Me].N mod 2 = 1);
     252
     253  Page := History[Me].N;
    254254  FindAllowed;
    255255  ResetCurrentOffer;
     
    283283procedure TNegoDlg.SplitText(Text: string; Bounds: TRect);
    284284var
    285   nLines, Line, Start, Stop, OrdinaryStop, Indent, Y: integer;
    286   s: string;
    287   preview, Dot: boolean;
     285  nLines, Line, Start, Stop, OrdinaryStop, Indent, Y: Integer;
     286  S: string;
     287  preview, Dot: Boolean;
    288288begin
    289289  nLines := 0;
    290   for preview := true downto false do
     290  for preview := True downto False do
    291291  begin
    292292    Start := 1;
     
    295295    while Start < Length(Text) do
    296296    begin
    297       Dot := false;
     297      Dot := False;
    298298      if (Start = 1) or (Text[Start - 1] = '\') then
    299299        if Text[Start] = '-' then
    300300        begin
    301301          Indent := ListIndent;
    302           inc(Start);
     302          Inc(Start);
    303303          if Start = Length(Text) then
    304             break;
    305           Dot := true;
     304            Break;
     305          Dot := True;
    306306        end
    307307        else
     
    310310      while (Stop < Length(Text)) and (Text[Stop] <> '\') do
    311311      begin
    312         inc(Stop);
     312        Inc(Stop);
    313313        if BiColorTextWidth(Offscreen.Canvas,
    314           copy(Text, Start, Stop - Start + 1)) > Bounds.Right - Bounds.Left -
     314          Copy(Text, Start, Stop - Start + 1)) > Bounds.Right - Bounds.Left -
    315315          PaperBorder_Left - PaperBorder_Right - Indent then
    316316        begin
    317           dec(Stop);
    318           break
     317          Dec(Stop);
     318          Break
    319319        end;
    320320      end;
     
    324324        while (Text[OrdinaryStop + 1] <> ' ') and
    325325          (Text[OrdinaryStop + 1] <> '\') do
    326           dec(OrdinaryStop);
     326          Dec(OrdinaryStop);
    327327        if (OrdinaryStop + 1 - Start) * 2 >= Stop - Start then
    328328          Stop := OrdinaryStop
     
    334334          Sprite(Offscreen, HGrSystem, Bounds.Left + PaperBorder_Left +
    335335            (ListIndent - 14), Y + 7, 8, 8, 90, 16);
    336         s := copy(Text, Start, Stop - Start + 1);
     336        S := Copy(Text, Start, Stop - Start + 1);
    337337        BiColorTextOut(Offscreen.Canvas, Colors.Canvas.Pixels[clkMisc,
    338338          cliPaperText], $7F007F, Bounds.Left + PaperBorder_Left +
    339           Indent, Y, s);
     339          Indent, Y, S);
    340340      end;
    341       inc(Line);
     341      Inc(Line);
    342342      Start := Stop + 2;
    343343    end;
     
    348348procedure TNegoDlg.FindAllowed;
    349349var
    350   i: integer;
     350  I: Integer;
    351351begin
    352352  CommandAllowed := [scDipOffer - scDipStart];
    353353  if ClientMode <> scDipBreak then
    354     include(CommandAllowed, scDipBreak - scDipStart);
    355   if MyRO.Treaty[DipMem[me].pContact] >= trPeace then
    356     include(CommandAllowed, scDipCancelTreaty - scDipStart);
    357   if (ClientMode = scDipOffer) and (Server(scDipAccept - sExecute, me, 0, nil^)
     354    Include(CommandAllowed, scDipBreak - scDipStart);
     355  if MyRO.Treaty[DipMem[Me].pContact] >= trPeace then
     356    Include(CommandAllowed, scDipCancelTreaty - scDipStart);
     357  if (ClientMode = scDipOffer) and (Server(scDipAccept - sExecute, Me, 0, nil^)
    358358    >= rExecuted) then
    359     include(CommandAllowed, scDipAccept - scDipStart);
     359    Include(CommandAllowed, scDipAccept - scDipStart);
    360360
    361361  MyAllowed := [opChoose shr 24, opMoney shr 24];
    362362  OppoAllowed := [opChoose shr 24, opMoney shr 24];
    363   if not IsCivilReportNew(DipMem[me].pContact) then
     363  if not IsCivilReportNew(DipMem[Me].pContact) then
    364364  begin // no up-to-date civil report
    365365    MyAllowed := MyAllowed + [opCivilReport shr 24];
    366     for i := 0 to nAdv - 1 do
    367       if MyRO.Tech[i] >= tsApplicable then
     366    for I := 0 to nAdv - 1 do
     367      if MyRO.Tech[I] >= tsApplicable then
    368368      begin
    369369        MyAllowed := MyAllowed + [opAllTech shr 24];
    370         break
     370        Break
    371371      end;
    372372    OppoAllowed := OppoAllowed + [opCivilReport shr 24, opAllTech shr 24];
     
    374374  else
    375375  begin // check techs
    376     for i := 0 to nAdv - 1 do
    377       if not(i in FutureTech) then
    378         if (MyRO.Tech[i] < tsSeen) and
    379           (MyRO.EnemyReport[DipMem[me].pContact].Tech[i] >= tsApplicable) then
     376    for I := 0 to nAdv - 1 do
     377      if not(I in FutureTech) then
     378        if (MyRO.Tech[I] < tsSeen) and
     379          (MyRO.EnemyReport[DipMem[Me].pContact].Tech[I] >= tsApplicable) then
    380380          OppoAllowed := OppoAllowed + [opAllTech shr 24]
    381         else if (MyRO.EnemyReport[DipMem[me].pContact].Tech[i] < tsSeen) and
    382           (MyRO.Tech[i] >= tsApplicable) then
     381        else if (MyRO.EnemyReport[DipMem[Me].pContact].Tech[I] < tsSeen) and
     382          (MyRO.Tech[I] >= tsApplicable) then
    383383          MyAllowed := MyAllowed + [opAllTech shr 24];
    384384  end;
    385   if not IsMilReportNew(DipMem[me].pContact) then
     385  if not IsMilReportNew(DipMem[Me].pContact) then
    386386  begin // no up-to-date military report
    387387    MyAllowed := MyAllowed + [opMilReport shr 24];
     
    397397      OppoAllowed := OppoAllowed + [opAllModel shr 24];
    398398  end;
    399   if MyRO.Treaty[DipMem[me].pContact] < trAlliance then
     399  if MyRO.Treaty[DipMem[Me].pContact] < trAlliance then
    400400  begin
    401401    MyAllowed := MyAllowed + [opTreaty shr 24, opMap shr 24];
     
    407407    OppoAllowed:=OppoAllowed+[opLowTreaty shr 24];
    408408    end; }
    409   for i := 0 to nShipPart - 1 do
    410   begin
    411     if MyRO.Ship[me].Parts[i] > 0 then
    412       include(MyAllowed, opShipParts shr 24);
    413     if MyRO.Ship[DipMem[me].pContact].Parts[i] > 0 then
    414       include(OppoAllowed, opShipParts shr 24);
    415   end;
    416   MyAllowed := MyAllowed - DipMem[me].DeliveredPrices *
     409  for I := 0 to nShipPart - 1 do
     410  begin
     411    if MyRO.Ship[Me].Parts[I] > 0 then
     412      Include(MyAllowed, opShipParts shr 24);
     413    if MyRO.Ship[DipMem[Me].pContact].Parts[I] > 0 then
     414      Include(OppoAllowed, opShipParts shr 24);
     415  end;
     416  MyAllowed := MyAllowed - DipMem[Me].DeliveredPrices *
    417417    [opAllTech shr 24, opAllModel shr 24, opCivilReport shr 24,
    418418    opMilReport shr 24, opMap shr 24];
    419   OppoAllowed := OppoAllowed - DipMem[me].ReceivedPrices *
     419  OppoAllowed := OppoAllowed - DipMem[Me].ReceivedPrices *
    420420    [opAllTech shr 24, opAllModel shr 24, opCivilReport shr 24,
    421421    opMilReport shr 24, opMap shr 24];
    422422end;
    423423
    424 procedure TNegoDlg.PaintNationPicture(X, Y, p: integer);
     424procedure TNegoDlg.PaintNationPicture(X, Y, P: Integer);
    425425begin
    426426  with Offscreen.Canvas do
    427427  begin
    428428    Pen.Color := $000000;
    429     Brush.Color := Tribe[p].Color;
     429    Brush.Color := Tribe[P].Color;
    430430    Rectangle(X - 6, Y - 1, X + 70, Y + 49);
    431431    Brush.Color := $000000;
    432     Tribe[p].InitAge(GetAge(p));
    433     if Assigned(Tribe[p].faceHGr) then
    434       Dump(Offscreen, Tribe[p].faceHGr, X, Y, 64, 48,
    435         1 + Tribe[p].facepix mod 10 * 65, 1 + Tribe[p].facepix div 10 * 49)
     432    Tribe[P].InitAge(GetAge(P));
     433    if Assigned(Tribe[P].faceHGr) then
     434      Dump(Offscreen, Tribe[P].faceHGr, X, Y, 64, 48,
     435        1 + Tribe[P].facepix mod 10 * 65, 1 + Tribe[P].facepix div 10 * 49)
    436436    else
    437437      FillRect(Rect(X, Y, X + 64, Y + 48));
     
    443443procedure TNegoDlg.SetButtonStates;
    444444var
    445   cix: integer;
    446   IsActionPage: boolean;
    447 begin
    448   IsActionPage := Page = History[me].n;
     445  cix: Integer;
     446  IsActionPage: Boolean;
     447begin
     448  IsActionPage := Page = History[Me].N;
    449449
    450450  AcceptBtn.Possible := IsActionPage and
     
    483483procedure TNegoDlg.OffscreenPaint;
    484484var
    485   i, cred: integer;
    486   s: string;
    487   OkEnabled: boolean;
     485  I, cred: Integer;
     486  S: string;
     487  OkEnabled: Boolean;
    488488begin
    489489  if (OffscreenUser <> nil) and (OffscreenUser <> self) then
     
    492492  OffscreenUser := self;
    493493
    494   if (DipCommand >= 0) and (Page = History[me].n) then
    495     History[me].Text[History[me].n] :=
    496       copy(DipCommandToString(me, DipMem[me].pContact,
    497       MyRO.Treaty[DipMem[me].pContact], ClientMode, DipCommand, ReceivedOffer,
     494  if (DipCommand >= 0) and (Page = History[Me].N) then
     495    History[Me].Text[History[Me].N] :=
     496      Copy(DipCommandToString(Me, DipMem[Me].pContact,
     497      MyRO.Treaty[DipMem[Me].pContact], ClientMode, DipCommand, ReceivedOffer,
    498498      CurrentOffer), 1, 255);
    499499
    500   FwdBtn.Visible := Page < History[me].n;
     500  FwdBtn.Visible := Page < History[Me].N;
    501501  BwdBtn.Visible := Page >= 2;
    502   if Page < History[me].n then
    503     OkEnabled := false
     502  if Page < History[Me].N then
     503    OkEnabled := False
    504504  else if DipCommand = scDipOffer then
    505     OkEnabled := Server(scDipOffer - sExecute, me, 0, CurrentOffer) >= rExecuted
     505    OkEnabled := Server(scDipOffer - sExecute, Me, 0, CurrentOffer) >= rExecuted
    506506  else
    507507    OkEnabled := DipCommand >= 0;
     
    532532    yPad1 + 41 + 42 * 2, $FFFFFF, $B0B0B0);
    533533
    534   PaintNationPicture(xNationPicture0, yNationPicture, DipMem[me].pContact);
    535   PaintNationPicture(xNationPicture1, yNationPicture, me);
    536 
    537   if History[me].Text[Page - 1] <> '' then
     534  PaintNationPicture(xNationPicture0, yNationPicture, DipMem[Me].pContact);
     535  PaintNationPicture(xNationPicture1, yNationPicture, Me);
     536
     537  if History[Me].Text[Page - 1] <> '' then
    538538  begin
    539539    FillSeamless(Offscreen.Canvas, xText0, yText0, wText, hText, 0, 0, Paper);
    540     i := Page - 1;
    541     if History[me].Text[0] = '' then
    542       dec(i);
    543     if i < 16 then
     540    I := Page - 1;
     541    if History[Me].Text[0] = '' then
     542      Dec(I);
     543    if I < 16 then
    544544    begin
    545545      Offscreen.Canvas.Font.Assign(RomanFont);
    546546      Offscreen.Canvas.TextOut
    547         (xText0 + (wText - Offscreen.Canvas.TextWidth(RomanNo[i])) div 2,
    548         yText0 + (hText - Offscreen.Canvas.TextHeight(RomanNo[i])) div 2,
    549         RomanNo[i]);
     547        (xText0 + (wText - Offscreen.Canvas.TextWidth(RomanNo[I])) div 2,
     548        yText0 + (hText - Offscreen.Canvas.TextHeight(RomanNo[I])) div 2,
     549        RomanNo[I]);
    550550    end
    551551  end;
    552552  FillSeamless(Offscreen.Canvas, xText1, yText1, wText, hText, 0, 0, Paper);
    553   i := Page;
    554   if History[me].Text[0] = '' then
    555     dec(i);
    556   if i < 16 then
     553  I := Page;
     554  if History[Me].Text[0] = '' then
     555    Dec(I);
     556  if I < 16 then
    557557  begin
    558558    Offscreen.Canvas.Font.Assign(RomanFont);
    559559    Offscreen.Canvas.TextOut
    560       (xText1 + (wText - Offscreen.Canvas.TextWidth(RomanNo[i])) div 2,
    561       yText1 + (hText - Offscreen.Canvas.TextHeight(RomanNo[i])) div 2,
    562       RomanNo[i]);
     560      (xText1 + (wText - Offscreen.Canvas.TextWidth(RomanNo[I])) div 2,
     561      yText1 + (hText - Offscreen.Canvas.TextHeight(RomanNo[I])) div 2,
     562      RomanNo[I]);
    563563  end;
    564564  with Offscreen.Canvas do
    565565  begin
    566566    Brush.Color := MainTexture.ColorBevelShade;
    567     if History[me].Text[Page - 1] <> '' then
     567    if History[Me].Text[Page - 1] <> '' then
    568568    begin
    569569      FillRect(Rect(xText0 + wText, yText0 + PaperShade,
     
    583583  { if Page=History[me].n then
    584584    begin // show attitude
    585     s:=Phrases.Lookup('ATTITUDE',MyRO.EnemyReport[DipMem[me].pContact].Attitude);
     585    S:=Phrases.Lookup('ATTITUDE',MyRO.EnemyReport[DipMem[Me].pContact].Attitude);
    586586    //LoweredTextOut(Offscreen.Canvas,-1,MainTexture,
    587587    RisedTextOut(Offscreen.Canvas,xText0+wText div 2-
    588     BiColorTextWidth(Offscreen.Canvas,s) div 2,yAttitude,s);
    589     s:=Phrases.Lookup('ATTITUDE',MyRO.Attitude[DipMem[me].pContact]);
     588    BiColorTextWidth(Offscreen.Canvas,S) div 2,yAttitude,S);
     589    S:=Phrases.Lookup('ATTITUDE',MyRO.Attitude[DipMem[Me].pContact]);
    590590    //LoweredTextOut(Offscreen.Canvas,-1,MainTexture,
    591591    RisedTextOut(Offscreen.Canvas,xText1+wText div 2-
    592     BiColorTextWidth(Offscreen.Canvas,s) div 2,yAttitude,s);
     592    BiColorTextWidth(Offscreen.Canvas,S) div 2,yAttitude,S);
    593593    end; }
    594594
    595   if History[me].Text[Page - 1] <> '' then
    596     SplitText(History[me].Text[Page - 1], Rect(xText0, yText0, xText0 + wText,
     595  if History[Me].Text[Page - 1] <> '' then
     596    SplitText(History[Me].Text[Page - 1], Rect(xText0, yText0, xText0 + wText,
    597597      yText0 + hText));
    598   if (Page < History[me].n) or OkEnabled then
    599     SplitText(History[me].Text[Page], Rect(xText1, yText1, xText1 + wText,
     598  if (Page < History[Me].N) or OkEnabled then
     599    SplitText(History[Me].Text[Page], Rect(xText1, yText1, xText1 + wText,
    600600      yText1 + hText));
    601601
    602602  // show credibility
    603603  Offscreen.Canvas.Font.Assign(UniFont[ftTiny]);
    604   cred := MyRO.EnemyReport[DipMem[me].pContact].Credibility;
     604  cred := MyRO.EnemyReport[DipMem[Me].pContact].Credibility;
    605605  case cred of
    606606    0 .. 49:
    607       i := 3;
     607      I := 3;
    608608    50 .. 90:
    609       i := 0;
     609      I := 0;
    610610    91 .. 100:
    611       i := 1;
    612   end;
    613   PaintProgressBar(Offscreen.Canvas, i, xCred0, yCred0 + 17, (cred + 2) div 5,
     611      I := 1;
     612  end;
     613  PaintProgressBar(Offscreen.Canvas, I, xCred0, yCred0 + 17, (cred + 2) div 5,
    614614    0, 20, MainTexture);
    615   s := IntToStr(cred);
     615  S := IntToStr(cred);
    616616  RisedTextOut(Offscreen.Canvas, xCred0 + 10 -
    617     (BiColorTextWidth(Offscreen.Canvas, s) + 1) div 2, yCred0, s);
     617    (BiColorTextWidth(Offscreen.Canvas, S) + 1) div 2, yCred0, S);
    618618  case MyRO.Credibility of
    619619    0 .. 49:
    620       i := 3;
     620      I := 3;
    621621    50 .. 90:
    622       i := 0;
     622      I := 0;
    623623    91 .. 100:
    624       i := 1;
    625   end;
    626   PaintProgressBar(Offscreen.Canvas, i, xCred1, yCred1 + 17,
     624      I := 1;
     625  end;
     626  PaintProgressBar(Offscreen.Canvas, I, xCred1, yCred1 + 17,
    627627    (MyRO.Credibility + 2) div 5, 0, 20, MainTexture);
    628   s := IntToStr(MyRO.Credibility);
     628  S := IntToStr(MyRO.Credibility);
    629629  RisedTextOut(Offscreen.Canvas, xCred1 + 10 -
    630     (BiColorTextWidth(Offscreen.Canvas, s) + 1) div 2, yCred1, s);
     630    (BiColorTextWidth(Offscreen.Canvas, S) + 1) div 2, yCred1, S);
    631631
    632632  MarkUsedOffscreen(ClientWidth, ClientHeight);
     
    635635procedure TNegoDlg.Initiate;
    636636begin
    637   History[me].n := 1;
    638   History[me].Text[0] := '';
     637  History[Me].N := 1;
     638  History[Me].Text[0] := '';
    639639end;
    640640
    641641procedure TNegoDlg.Respond;
    642642begin
    643   History[me].n := 0;
     643  History[Me].N := 0;
    644644end;
    645645
    646646procedure TNegoDlg.FormMouseDown(Sender: TObject; Button: TMouseButton;
    647   Shift: TShiftState; X, Y: integer);
     647  Shift: TShiftState; X, Y: Integer);
    648648begin
    649649  if (X >= xNationPicture0) and (X < xNationPicture0 + 64) and
    650650    (Y >= yNationPicture) and (Y < yNationPicture + 48) then
    651     NatStatDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), DipMem[me].pContact)
     651    NatStatDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), DipMem[Me].pContact)
    652652  else if (X >= xNationPicture1) and (X < xNationPicture1 + 64) and
    653653    (Y >= yNationPicture) and (Y < yNationPicture + 48) then
    654     NatStatDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), me)
     654    NatStatDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), Me)
    655655end;
    656656
    657657procedure TNegoDlg.BwdBtnClick(Sender: TObject);
    658658begin
    659   dec(Page, 2);
     659  Dec(Page, 2);
    660660  SetButtonStates;
    661661  SmartUpdateContent;
     
    664664procedure TNegoDlg.FwdBtnClick(Sender: TObject);
    665665begin
    666   inc(Page, 2);
     666  Inc(Page, 2);
    667667  SetButtonStates;
    668668  SmartUpdateContent;
     
    671671procedure TNegoDlg.OkBtnClick(Sender: TObject);
    672672begin
    673   inc(History[me].n);
     673  Inc(History[Me].N);
    674674  if DipCommand = scDipOffer then
    675675    MainScreen.OfferCall(CurrentOffer)
     
    697697procedure TNegoDlg.BuildCurrentOffer;
    698698var
    699   i: integer;
     699  I: Integer;
    700700begin
    701701  CurrentOffer.nDeliver := 0;
    702702  CurrentOffer.nCost := 0;
    703   for i := 0 to 11 do
    704     if Delivers[i] <> $FFFFFFFF then
    705     begin
    706       CurrentOffer.Price[CurrentOffer.nDeliver] := Delivers[i];
    707       inc(CurrentOffer.nDeliver);
     703  for I := 0 to 11 do
     704    if Delivers[I] <> $FFFFFFFF then
     705    begin
     706      CurrentOffer.Price[CurrentOffer.nDeliver] := Delivers[I];
     707      Inc(CurrentOffer.nDeliver);
    708708    end;
    709   for i := 0 to 11 do
    710     if Costs[i] <> $FFFFFFFF then
     709  for I := 0 to 11 do
     710    if Costs[I] <> $FFFFFFFF then
    711711    begin
    712712      CurrentOffer.Price[CurrentOffer.nDeliver + CurrentOffer.nCost] :=
    713         Costs[i];
    714       inc(CurrentOffer.nCost);
     713        Costs[I];
     714      Inc(CurrentOffer.nCost);
    715715    end;
    716716end;
     
    718718procedure TNegoDlg.WantClick(Sender: TObject);
    719719var
    720   a, i, max: integer;
    721   Price: cardinal;
    722 begin
    723   if (Page <> History[me].n) or (ClientMode = scDipCancelTreaty) or
     720  A, I, Max: Integer;
     721  Price: Cardinal;
     722begin
     723  if (Page <> History[Me].N) or (ClientMode = scDipCancelTreaty) or
    724724    (ClientMode = scDipBreak) then
    725     exit;
     725    Exit;
    726726  if Costs[TButtonN(Sender).Tag and $FF] <> $FFFFFFFF then
    727727    Price := $FFFFFFFF // toggle off
     
    731731    begin
    732732      SimpleMessage(Phrases.Lookup('MAX2WANTS'));
    733       exit
     733      Exit
    734734    end;
    735735    Price := ButtonPrice[TButtonN(Sender).Tag and $FF];
    736736    if not(Price shr 24 in OppoAllowed) then
    737       exit;
     737      Exit;
    738738    case Price of
    739739      opCivilReport, opMilReport:
    740         inc(Price, DipMem[me].pContact shl 16 + MyRO.Turn);
     740        Inc(Price, DipMem[Me].pContact shl 16 + MyRO.Turn);
    741741        // !!! choose player and year!
    742742      opMoney:
     
    747747          InputDlg.ShowModal;
    748748          if InputDlg.ModalResult <> mrOK then
    749             exit;
    750           val(InputDlg.EInput.Text, a, i);
    751           if (i <> 0) or (a <= 0) or (a >= MaxMoneyPrice) then
    752             exit;
    753           inc(Price, a);
     749            Exit;
     750          val(InputDlg.EInput.Text, A, I);
     751          if (I <> 0) or (A <= 0) or (A >= MaxMoneyPrice) then
     752            Exit;
     753          Inc(Price, A);
    754754        end;
    755755      opShipParts:
     
    765765              ShowModal;
    766766              if ModalResult <> mrOK then
    767                 exit
     767                Exit
    768768            end;
    769769          ModalSelectDlg.ShowNewContent(wmModal, kEShipPart);
    770           if ModalSelectDlg.result < 0 then
    771             exit;
    772           inc(Price, ModalSelectDlg.result shl 16);
    773           max := MyRO.Ship[DipMem[me].pContact].Parts[ModalSelectDlg.result];
     770          if ModalSelectDlg.Result < 0 then
     771            Exit;
     772          Inc(Price, ModalSelectDlg.Result shl 16);
     773          Max := MyRO.Ship[DipMem[Me].pContact].Parts[ModalSelectDlg.Result];
    774774          InputDlg.Caption := Phrases.Lookup('TITLE_NUMBER');
    775775          InputDlg.EInput.Text := '';
     
    777777          InputDlg.ShowModal;
    778778          if InputDlg.ModalResult <> mrOK then
    779             exit;
    780           val(InputDlg.EInput.Text, a, i);
    781           if (i <> 0) or (a <= 0) then
    782             exit;
    783           if a > max then
    784             a := max;
    785           if a > MaxShipPartPrice then
    786             a := MaxShipPartPrice;
    787           inc(Price, a);
     779            Exit;
     780          val(InputDlg.EInput.Text, A, I);
     781          if (I <> 0) or (A <= 0) then
     782            Exit;
     783          if A > Max then
     784            A := Max;
     785          if A > MaxShipPartPrice then
     786            A := MaxShipPartPrice;
     787          Inc(Price, A);
    788788        end;
    789789      opAllTech:
    790790        begin // choose technology
    791791          ModalSelectDlg.ShowNewContent(wmModal, kChooseETech);
    792           if ModalSelectDlg.result < 0 then
    793             exit;
    794           if ModalSelectDlg.result = adAll then
     792          if ModalSelectDlg.Result < 0 then
     793            Exit;
     794          if ModalSelectDlg.Result = adAll then
    795795            Price := opAllTech
    796796          else
    797             Price := OpTech + ModalSelectDlg.result;
     797            Price := OpTech + ModalSelectDlg.Result;
    798798        end;
    799799      opAllModel:
    800800        begin // choose model
    801801          ModalSelectDlg.ShowNewContent(wmModal, kChooseEModel);
    802           if ModalSelectDlg.result < 0 then
    803             exit;
    804           if ModalSelectDlg.result = mixAll then
     802          if ModalSelectDlg.Result < 0 then
     803            Exit;
     804          if ModalSelectDlg.Result = mixAll then
    805805            Price := opAllModel
    806806          else
    807             Price := OpModel + MyRO.EnemyModel[ModalSelectDlg.result].mix;
     807            Price := OpModel + MyRO.EnemyModel[ModalSelectDlg.Result].mix;
    808808        end;
    809809      opTreaty:
    810810        begin
    811           if MyRO.Treaty[DipMem[me].pContact] < trPeace then
     811          if MyRO.Treaty[DipMem[Me].pContact] < trPeace then
    812812            Price := opTreaty + trPeace
    813813          else
    814             Price := opTreaty + MyRO.Treaty[DipMem[me].pContact] + 1;
     814            Price := opTreaty + MyRO.Treaty[DipMem[Me].pContact] + 1;
    815815        end;
    816816      { opLowTreaty:
    817817        begin
    818         if MyRO.Treaty[DipMem[me].pContact]=trNone then Price:=opTreaty+trCeaseFire
    819         else Price:=opTreaty+MyRO.Treaty[DipMem[me].pContact]-1;
     818        if MyRO.Treaty[DipMem[Me].pContact]=trNone then Price:=opTreaty+trCeaseFire
     819        else Price:=opTreaty+MyRO.Treaty[DipMem[Me].pContact]-1;
    820820        end }
    821821    end;
     
    831831procedure TNegoDlg.OfferClick(Sender: TObject);
    832832var
    833   a, i, max: integer;
    834   Price: cardinal;
    835 begin
    836   if (Page <> History[me].n) or (ClientMode = scDipCancelTreaty) or
     833  A, I, Max: Integer;
     834  Price: Cardinal;
     835begin
     836  if (Page <> History[Me].N) or (ClientMode = scDipCancelTreaty) or
    837837    (ClientMode = scDipBreak) then
    838     exit;
     838    Exit;
    839839  if Delivers[TButtonN(Sender).Tag and $FF] <> $FFFFFFFF then
    840840    Price := $FFFFFFFF // toggle off
     
    844844    begin
    845845      SimpleMessage(Phrases.Lookup('MAX2OFFERS'));
    846       exit;
     846      Exit;
    847847    end;
    848848    Price := ButtonPrice[TButtonN(Sender).Tag and $FF];
    849849    if not(Price shr 24 in MyAllowed) then
    850       exit;
     850      Exit;
    851851    case Price of
    852852      opCivilReport, opMilReport:
    853         inc(Price, me shl 16 + MyRO.Turn); // !!! choose player and year!
     853        Inc(Price, Me shl 16 + MyRO.Turn); // !!! choose player and year!
    854854      opMoney:
    855855        begin // choose amount
     
    859859          InputDlg.ShowModal;
    860860          if InputDlg.ModalResult <> mrOK then
    861             exit;
    862           val(InputDlg.EInput.Text, a, i);
    863           if (i <> 0) or (a <= 0) or (a >= MaxMoneyPrice) then
    864             exit;
    865           if (Price = opMoney) and (a > MyRO.Money) then
    866             a := MyRO.Money;
    867           inc(Price, a);
     861            Exit;
     862          val(InputDlg.EInput.Text, A, I);
     863          if (I <> 0) or (A <= 0) or (A >= MaxMoneyPrice) then
     864            Exit;
     865          if (Price = opMoney) and (A > MyRO.Money) then
     866            A := MyRO.Money;
     867          Inc(Price, A);
    868868        end;
    869869      opShipParts:
    870870        begin // choose type and number
    871871          ModalSelectDlg.ShowNewContent(wmModal, kShipPart);
    872           if ModalSelectDlg.result < 0 then
    873             exit;
    874           inc(Price, ModalSelectDlg.result shl 16);
    875           max := MyRO.Ship[me].Parts[ModalSelectDlg.result];
     872          if ModalSelectDlg.Result < 0 then
     873            Exit;
     874          Inc(Price, ModalSelectDlg.Result shl 16);
     875          Max := MyRO.Ship[Me].Parts[ModalSelectDlg.Result];
    876876          InputDlg.Caption := Phrases.Lookup('TITLE_NUMBER');
    877877          InputDlg.EInput.Text := '';
     
    879879          InputDlg.ShowModal;
    880880          if InputDlg.ModalResult <> mrOK then
    881             exit;
    882           val(InputDlg.EInput.Text, a, i);
    883           if (i <> 0) or (a <= 0) then
    884             exit;
    885           if a > max then
    886             a := max;
    887           if a > MaxShipPartPrice then
    888             a := MaxShipPartPrice;
    889           inc(Price, a);
     881            Exit;
     882          val(InputDlg.EInput.Text, A, I);
     883          if (I <> 0) or (A <= 0) then
     884            Exit;
     885          if A > Max then
     886            A := Max;
     887          if A > MaxShipPartPrice then
     888            A := MaxShipPartPrice;
     889          Inc(Price, A);
    890890        end;
    891891      opAllTech:
    892892        begin // choose technology
    893893          ModalSelectDlg.ShowNewContent(wmModal, kChooseTech);
    894           if ModalSelectDlg.result < 0 then
    895             exit;
    896           if ModalSelectDlg.result = adAll then
     894          if ModalSelectDlg.Result < 0 then
     895            Exit;
     896          if ModalSelectDlg.Result = adAll then
    897897            Price := opAllTech
    898898          else
    899             Price := OpTech + ModalSelectDlg.result;
     899            Price := OpTech + ModalSelectDlg.Result;
    900900        end;
    901901      opAllModel:
    902902        begin // choose model
    903903          ModalSelectDlg.ShowNewContent(wmModal, kChooseModel);
    904           if ModalSelectDlg.result < 0 then
    905             exit;
    906           if ModalSelectDlg.result = mixAll then
     904          if ModalSelectDlg.Result < 0 then
     905            Exit;
     906          if ModalSelectDlg.Result = mixAll then
    907907            Price := opAllModel
    908908          else
    909             Price := OpModel + ModalSelectDlg.result;
     909            Price := OpModel + ModalSelectDlg.Result;
    910910        end;
    911911      opTreaty:
    912912        begin
    913           if MyRO.Treaty[DipMem[me].pContact] < trPeace then
     913          if MyRO.Treaty[DipMem[Me].pContact] < trPeace then
    914914            Price := opTreaty + trPeace
    915915          else
    916             Price := opTreaty + MyRO.Treaty[DipMem[me].pContact] + 1;
     916            Price := opTreaty + MyRO.Treaty[DipMem[Me].pContact] + 1;
    917917        end;
    918918      { opLowTreaty:
    919919        begin
    920         if MyRO.Treaty[DipMem[me].pContact]=trNone then Price:=opTreaty+trCeaseFire
    921         else Price:=opTreaty+MyRO.Treaty[DipMem[me].pContact]-1;
     920        if MyRO.Treaty[DipMem[Me].pContact]=trNone then Price:=opTreaty+trCeaseFire
     921        else Price:=opTreaty+MyRO.Treaty[DipMem[Me].pContact]-1;
    922922        end }
    923923    end;
     
    933933procedure TNegoDlg.FastBtnClick(Sender: TObject);
    934934var
    935   NewCommand: cardinal;
    936 begin
    937   if Page <> History[me].n then
    938     exit;
     935  NewCommand: Cardinal;
     936begin
     937  if Page <> History[Me].N then
     938    Exit;
    939939  NewCommand := TButtonN(Sender).Tag and $FF + scDipStart;
    940940  if not(NewCommand - scDipStart in CommandAllowed) then
    941     exit;
     941    Exit;
    942942  if (NewCommand = scDipCancelTreaty) and
    943     (MyRO.Turn < MyRO.LastCancelTreaty[DipMem[me].pContact] + CancelTreatyTurns)
     943    (MyRO.Turn < MyRO.LastCancelTreaty[DipMem[Me].pContact] + CancelTreatyTurns)
    944944  then
    945945  begin
    946946    SimpleMessage(Phrases.Lookup('CANCELTREATYRUSH'));
    947     exit;
     947    Exit;
    948948  end;
    949949  if (NewCommand = scDipOffer) and ((ClientMode = scDipCancelTreaty) or
Note: See TracChangeset for help on using the changeset viewer.