Ignore:
Timestamp:
Apr 21, 2024, 8:55:53 PM (7 months 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/AI/StdAI/Barbarina.pas

    r531 r549  
    218218    Result := True;
    219219    for cix := 0 to RO.nCity - 1 do
    220       with MyCity[cix] do
     220      with MyCity[cix] do begin
    221221        if Loc >= 0 then
    222222        begin // search for modern resource
     
    225225          begin
    226226            Loc1 := Radius[V21];
    227             if (Loc1 >= 0) and (RO.Map[Loc1] and fModern <> 0) then
     227            if (Loc1 >= 0) and (RO.Map[Loc1] and fModern <> 0) then begin
    228228              Result := False;
    229           end;
    230         end;
     229              Break;
     230            end;
     231          end;
     232        end;
     233        if not Result then Break;
     234      end;
    231235  end
    232236  else if IsResearched(adGunPowder) then
     
    892896    for F := 0 to maxCOD - 1 do
    893897      if (F < nContinent) and (ContinentPresence[F] and not
    894         (1 shl Me or PresenceUnknown) <> 0) then
    895         Go := True; // any enemy island known?
     898        (1 shl Me or PresenceUnknown) <> 0) then begin
     899          Go := True; // any enemy island known?
     900          Break;
     901        end;
    896902    if not Go then
    897903      Exit;
     
    922928              (TroopLoad = 0) and (Health = 100) then
    923929            begin
    924               go := True;
     930              Go := True;
    925931              SeaTransport_AddTransport(uix);
    926932            end;
     
    11701176          if MyUnit[uix].Loc >= 0 then
    11711177            RateAttack(uix);
    1172         end
    1173       until BackToStart
     1178        end;
     1179      until BackToStart;
    11741180    until not BackToStart;
    11751181
     
    12141220  function LowPriority(cix: Integer): Boolean;
    12151221  var
    1216     part, cixHighPriority, TestDistance: Integer;
     1222    Part, cixHighPriority, TestDistance: Integer;
    12171223  begin
    12181224    Result := False;
    1219     for part := 0 to nShipPart - 1 do
     1225    for Part := 0 to nShipPart - 1 do
    12201226    begin
    1221       cixHighPriority := ColonyShipPlan[part].cixProducing;
     1227      cixHighPriority := ColonyShipPlan[Part].cixProducing;
    12221228      if (cixHighPriority >= 0) and (cixHighPriority <> cix) then
    12231229      begin
     
    13751381  for cix := 0 to RO.nCity - 1 do
    13761382    with MyCity[cix] do
    1377       if (Loc >= 0) and (Project and (cpImp + cpIndex) = cpImp + imAlgae) then
     1383      if (Loc >= 0) and (Project and (cpImp + cpIndex) = cpImp + imAlgae) then begin
    13781384        AlgaeAvailable := False;
     1385        Break;
     1386      end;
    13791387
    13801388  for cix := 0 to RO.nCity - 1 do
     
    14941502                with MyUnit[uix] do
    14951503                  if (Loc >= 0) and (Home = cix) and
    1496                     (MyModel[mix].Kind = mkSettler) then
    1497                     HasSettler := True;
     1504                    (MyModel[mix].Kind = mkSettler) then begin
     1505                      HasSettler := True;
     1506                      Break;
     1507                    end;
    14981508              if ((RO.Government <> gDespotism) or (RO.nUn >= RO.nCity * 4)) and
    14991509                not IsResearched(adMassProduction) and (Built[imPalace] > 0) and
     
    15521562                ImportantCity := WillProduceColonyShip or (Built[imPalace] > 0);
    15531563                for iix := 0 to nWonder - 1 do
    1554                   if Built[iix] > 0 then
     1564                  if Built[iix] > 0 then begin
    15551565                    ImportantCity := True;
     1566                    Break;
     1567                  end;
    15561568                City_GetReportNew(cix, Report);
    15571569                if (Report.Corruption >= 6) and (RO.nUn >= RO.nCity * 4) and
     
    16971709          for I := 0 to nFeature - 1 do
    16981710            if (Cap[I] > 0) and (Feature[I].Preq <> preNone) and
    1699               ((Feature[I].Preq < 0) or not IsResearched(Feature[I].Preq)) then
    1700               Ready := False;
     1711              ((Feature[I].Preq < 0) or not IsResearched(Feature[I].Preq)) then begin
     1712                Ready := False;
     1713                Break;
     1714              end;
    17011715        if Ready then
    17021716        begin
    17031717          for I := 0 to nUpgrade - 1 do
    17041718            if (Upgrades and (1 shl I) <> 0) and not
    1705               IsResearched(Upgrade[Domain, I].Preq) then
    1706               Ready := False;
     1719              IsResearched(Upgrade[Domain, I].Preq) then begin
     1720                Ready := False;
     1721                Break;
     1722              end;
    17071723        end;
    17081724        if Ready then
     
    19111927    for Part := 0 to nShipPart - 1 do
    19121928      if (RO.Ship[Me].Parts[Part] < ShipNeed[Part]) // not enough of this kind already
    1913         and (ColonyShipPlan[Part].cixProducing < 0) then // no city to produce
    1914         Check := True;
     1929        and (ColonyShipPlan[Part].cixProducing < 0) then begin // no city to produce
     1930          Check := True;
     1931          Break;
     1932        end;
    19151933    if Check then
    19161934    begin
Note: See TracChangeset for help on using the changeset viewer.