Ignore:
Timestamp:
Apr 21, 2024, 8:55:53 PM (2 weeks ago)
Author:
chronos
Message:
  • Modified: Optimize code with earlier break from for cycle evaluating boolean result.
  • Modified: Code cleanup.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/Term.pas

    r545 r549  
    12281228      IsTreatyDeal := False;
    12291229      for I := 0 to ReceivedOffer.nDeliver + ReceivedOffer.nCost - 1 do
    1230         if ReceivedOffer.Price[I] and opMask = opTreaty then
     1230        if ReceivedOffer.Price[I] and opMask = opTreaty then begin
    12311231          IsTreatyDeal := True;
     1232          Break;
     1233        end;
    12321234      if IsTreatyDeal then
    12331235        Play('NEWTREATY')
     
    14661468var
    14671469  I, cix, mix: Integer;
    1468   need: Boolean;
     1470  Need: Boolean;
    14691471  mi: TModelInfo;
    14701472begin
     
    14751477  end;
    14761478  if (sbWonder in Check) and not (sbWonder in SoundPreloadDone) then begin
    1477     need := False;
     1479    Need := False;
    14781480    for I := 0 to nWonder - 1 do
    1479       if MyRO.Wonder[I].CityID <> WonderNotBuiltYet then
    1480         need := True;
    1481     if need then begin
     1481      if MyRO.Wonder[I].CityID <> WonderNotBuiltYet then begin
     1482        Need := True;
     1483        Break;
     1484      end;
     1485    if Need then begin
    14821486      for I := 0 to nWonderBlock - 1 do
    14831487        PreparePlay(WonderBlock[I]);
     
    16301634          for I := 0 to nShipPart - 1 do
    16311635          begin
    1632             if Ship1Change[I] > 0 then
    1633               Ship1Plus := True;
    1634             if Ship2Change[I] > 0 then
    1635               Ship2Plus := True;
     1636            if Ship1Change[I] > 0 then Ship1Plus := True;
     1637            if Ship2Change[I] > 0 then Ship2Plus := True;
    16361638          end;
    16371639          if Ship1Plus and Ship2Plus then
     
    21402142      for cix := 0 to MyRO.nCity - 1 do
    21412143        if (MyCity[cix].Loc >= 0) and (MyCity[cix].ID = MyRO.Wonder[I].CityID)
    2142         then
     2144        then begin
    21432145          OwnWonder := True;
     2146          Break;
     2147        end;
    21442148      if MyRO.Wonder[I].CityID <> MyData.ToldWonders[I].CityID then
    21452149      begin
     
    30293033          IsTreatyDeal := False;
    30303034          for I := 0 to ReceivedOffer.nDeliver + ReceivedOffer.nCost - 1 do
    3031             if DipMem[Me].SentOffer.Price[I] and opMask = opTreaty then
     3035            if DipMem[Me].SentOffer.Price[I] and opMask = opTreaty then begin
    30323036              IsTreatyDeal := True;
     3037              Break;
     3038            end;
    30333039          if IsTreatyDeal then
    30343040            Play('NEWTREATY')
     
    39954001    for I := 2 to nGov - 1 do
    39964002      if (GovPreq[I] <> preNA) and
    3997         ((GovPreq[I] = preNone) or (MyRO.Tech[GovPreq[I]] >= tsApplicable)) then
    3998         AltGovs := True;
     4003        ((GovPreq[I] = preNone) or (MyRO.Tech[GovPreq[I]] >= tsApplicable)) then begin
     4004          AltGovs := True;
     4005          Break;
     4006        end;
    39994007
    40004008    if not AltGovs then
     
    42964304            begin
    42974305              Result := True;
    4298               Exit
     4306              Exit;
    42994307            end;
    43004308          end
     
    44904498    Skipped := WasSkipped;
    44914499    for p1 := 1 to nPl - 1 do
    4492       if G.RO[p1] <> nil then
     4500      if G.RO[p1] <> nil then begin
    44934501        Skipped := True; // don't show enemy moves in hotseat mode
     4502        Break;
     4503      end;
    44944504  end
    44954505  else
     
    74657475      Multi := False;
    74667476      for p1 := 1 to nPl - 1 do
    7467         if G.RO[p1] <> nil then
     7477        if G.RO[p1] <> nil then begin
    74687478          Multi := True;
     7479          Break;
     7480        end;
    74697481      mEnemyMovement.Visible := not Multi;
    74707482    end;
     
    75607572    for p1 := 0 to nPl - 1 do
    75617573      if MyRO.Ship[p1].Parts[spComp] + MyRO.Ship[p1].Parts[spPow] +
    7562         MyRO.Ship[p1].Parts[spHab] > 0 then
    7563         mShips.Enabled := True;
     7574        MyRO.Ship[p1].Parts[spHab] > 0 then begin
     7575          mShips.Enabled := True;
     7576          Break;
     7577        end;
    75647578  end
    75657579  else if Popup = UnitPopup then
     
    76857699      if NeedSep then
    76867700        LastSep := Popup.Items[I];
    7687       NeedSep := False
     7701      NeedSep := False;
    76887702    end
    76897703    else if Popup.Items[I].Visible then
    76907704      NeedSep := True;
    76917705  if (LastSep <> nil) and not NeedSep then
    7692     LastSep.Visible := False
     7706    LastSep.Visible := False;
    76937707end;
    76947708
Note: See TracChangeset for help on using the changeset viewer.