Changeset 549


Ignore:
Timestamp:
Apr 21, 2024, 8:55:53 PM (12 days ago)
Author:
chronos
Message:
  • Modified: Optimize code with earlier break from for cycle evaluating boolean result.
  • Modified: Code cleanup.
Location:
trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/AI/StdAI/AI.pas

    r548 r549  
    17881788  DistrictNeed, DistrictNeed0: array[0..maxCOD - 1] of Integer;
    17891789  ModelOrder: array[0..nMmax - 1] of Integer;
    1790   complete, Fortified: Boolean;
     1790  Complete, Fortified: Boolean;
    17911791
    17921792  function IsBombarded(cix: Integer): Boolean;
     
    19531953            end;
    19541954
    1955       complete := Loop >= FirstSurplusLoop[Cat];
     1955      Complete := Loop >= FirstSurplusLoop[Cat];
    19561956      for I := nModelOrder - 1 downto 0 do
    19571957      begin
     
    19671967                  Dec(DistrictNeed[District[Loc]]);
    19681968                Destination[uix] := Loc;
    1969                 complete := False;
     1969                Complete := False;
    19701970              end;
    19711971
     
    19801980                FindDestination(uix);
    19811981                if Destination[uix] >= 0 then
    1982                   complete := False;
     1982                  Complete := False;
    19831983              end;
    19841984      end;
    19851985      Inc(Loop)
    1986     until complete;
     1986    until Complete;
    19871987  end;
    19881988
     
    20052005    DistrictNeed0 := DistrictNeed;
    20062006
    2007     complete := True;
     2007    Complete := True;
    20082008    for uix := 0 to RO.nUn - 1 do
    20092009      with MyUnit[uix] do
     
    20152015            begin
    20162016              if DistrictNeed0[District[Loc]] > 0 then
    2017                 complete := False;
     2017                Complete := False;
    20182018            end
    20192019            else
     
    20212021              FindDestination(uix);
    20222022              //          if (Destination[uix]<0) and (RO.Territory[Loc]=me) then
    2023               //            complete:=false; // causes hangup when unit can't move due to zoc
     2023              //            Complete:=false; // causes hangup when unit can't move due to zoc
    20242024            end;
    2025   until complete;
     2025  until Complete;
    20262026
    20272027  for uix := 0 to RO.nUn - 1 do
     
    20442044        case ModelCat[mix] of
    20452045          mctGroundDefender, mctGroundAttacker:
    2046             Dec(UnitLack[District[Loc], ModelCat[mix]])
     2046            Dec(UnitLack[District[Loc], ModelCat[mix]]);
    20472047        end;
    20482048end;
     
    23512351            F := Formation[AdjacentLoc];
    23522352            if (F >= 0) and (F < maxCOD) and (OceanPresence[F] and
    2353               not (1 shl Me) <> 0) then
    2354               Result := True;
     2353              not (1 shl Me) <> 0) then begin
     2354                Result := True;
     2355                Exit;
     2356              end;
    23552357          end;
    23562358        end;
  • 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
  • trunk/CityProcessing.pas

    r548 r549  
    16051605                RareOK := False;
    16061606                for iH := 0 to nHierarchy - 1 do
    1607                   if Hierarchy[iH, nSelection[iH]].V21 and RareTiles <> 0 then
     1607                  if Hierarchy[iH, nSelection[iH]].V21 and RareTiles <> 0 then begin
    16081608                    RareOK := True;
     1609                    Break;
     1610                  end;
    16091611                if not RareOK then
    16101612                  TestReport.ProdRep := TestReport.Support;
  • trunk/Database.pas

    r548 r549  
    10361036        begin
    10371037          Loc1 := dLoc(Loc, Dir and 1 * 2 - 1, Dir shr 1 * 2 - 1);
    1038           if (Loc1 >= 0) and (RealMap[Loc1] and fTerrain < fGrass) then
     1038          if (Loc1 >= 0) and (RealMap[Loc1] and fTerrain < fGrass) then begin
    10391039            OneTileLake := False;
     1040            Break;
     1041          end;
    10401042        end;
    10411043        if not OneTileLake then
     
    14161418    Ok := True;
    14171419    for C := 1 to nsc do
    1418       if nCityLoc[C] < sccount[C] * (8 - MinGood) div (7 - MinGood) then
     1420      if nCityLoc[C] < sccount[C] * (8 - MinGood) div (7 - MinGood) then begin
    14191421        Ok := False;
     1422        Break;
     1423      end;
    14201424  until Ok;
    14211425
  • trunk/GameServer.pas

    r531 r549  
    474474  for ix := 0 to RW[P].nUn - 1 do
    475475    with RW[P].Un[ix] do
    476       if (Loc >= 0) and (SavedStatus <> Status) then
     476      if (Loc >= 0) and (SavedStatus <> Status) then begin
    477477        Result := True;
     478        Exit;
     479      end;
    478480  for ix := 0 to RW[P].nCity - 1 do
    479481    with RW[P].City[ix] do
    480       if (Loc >= 0) and (SavedStatus <> Status) then
     482      if (Loc >= 0) and (SavedStatus <> Status) then begin
    481483        Result := True;
     484        Exit;
     485      end;
    482486  for ix := 0 to RW[P].nModel - 1 do
    483487    with RW[P].Model[ix] do
    484       if SavedStatus <> Status then
     488      if SavedStatus <> Status then begin
    485489        Result := True;
     490        Exit;
     491      end;
    486492  for ix := 0 to RW[P].nEnemyCity - 1 do
    487493    with RW[P].EnemyCity[ix] do
    488       if (Loc >= 0) and (SavedStatus <> Status) then
     494      if (Loc >= 0) and (SavedStatus <> Status) then begin
    489495        Result := True;
     496        Exit;
     497      end;
    490498  if RW[P].Data <> nil then
    491499    for ix := 0 to bix[P].DataSize - 1 do
    492       if PDWortList(SavedData[P])[ix] <> PDWortList(RW[P].Data)[ix] then
     500      if PDWortList(SavedData[P])[ix] <> PDWortList(RW[P].Data)[ix] then begin
    493501        Result := True;
     502        Exit;
     503      end;
    494504end;
    495505
     
    10691079  for cix := 0 to RW[pTurn].nCity - 1 do
    10701080    with RW[pTurn].City[cix] do
    1071       if Loc >= 0 then
    1072       begin
    1073         // if SavedResourceWeights[cix]<>ResourceWeights then result:=true;
    1074         if SavedTiles[cix] <> Tiles then
     1081      if Loc >= 0 then begin
     1082        // if SavedResourceWeights[cix] <> ResourceWeights then Result := true;
     1083        if SavedTiles[cix] <> Tiles then begin
    10751084          Result := True;
     1085          Break;
     1086        end;
    10761087      end;
    10771088end;
     
    12041215    Notify(ntLoadBegin);
    12051216
    1206   started := False;
     1217  Started := False;
    12071218  StatRequest := False;
    12081219  MovieStopped := False;
     
    12241235    end;
    12251236    // complete all internal commands following an sTurn before generating statistics
    1226     if (Command = sTurn) and not started then
     1237    if (Command = sTurn) and not Started then
    12271238    begin
    12281239{$IFDEF TEXTLOG}WriteLn(TextLog, '---Turn 0 P0---'); {$ENDIF}
     
    12371248      end;
    12381249      StatRequest := True;
    1239       started := True;
     1250      Started := True;
    12401251    end
    12411252    else if (Command = sTurn) and (pTurn = 0) and (GTurn = LoadTurn) then
     
    12831294  if StatRequest then
    12841295    GenerateStat(pTurn);
    1285   Assert(started);
     1296  Assert(Started);
    12861297{$IFDEF TEXTLOG}CloseFile(TextLog); {$ENDIF}
    12871298{$IFDEF LOADPERF}QueryPerformanceCounter(time_total); { time in s is: (time_total-time_total0)/PerfFreq }{$ENDIF}
     
    14991510procedure DestroyCity_TellPlayers(P, cix: Integer; SaveUnits: Boolean);
    15001511begin
    1501   if RW[P].City[cix].built[imSpacePort] > 0 then
     1512  if RW[P].City[cix].Built[imSpacePort] > 0 then
    15021513    DestroySpacePort_TellPlayers(P, -1);
    15031514  DestroyCity(P, cix, SaveUnits);
     
    15061517procedure ChangeCityOwner_TellPlayers(pOld, cixOld, pNew: Integer);
    15071518begin
    1508   if RW[pOld].City[cixOld].built[imSpacePort] > 0 then
     1519  if RW[pOld].City[cixOld].Built[imSpacePort] > 0 then
    15091520    if RW[pNew].NatBuilt[imSpacePort] > 0 then
    15101521      DestroySpacePort_TellPlayers(pOld, pNew)
     
    15211532  ShipComplete := True;
    15221533  for I := 0 to nShipPart - 1 do
    1523     if GShip[P].Parts[I] < ShipNeed[I] then
     1534    if GShip[P].Parts[I] < ShipNeed[I] then begin
    15241535      ShipComplete := False;
     1536      Break;
     1537    end;
    15251538  if ShipComplete then
    15261539    GWinner := GWinner or 1 shl P; // game won!
     
    15871600            for cix := 1 to nCity - 1 do
    15881601              if (City[cix].Loc >= 0) and
    1589                 ((Loc1 < 0) or (City[cix].built[imPalace] > 0)) then
     1602                ((Loc1 < 0) or (City[cix].Built[imPalace] > 0)) then
    15901603                Loc1 := City[cix].Loc;
    15911604            for uix := 0 to nUn - 1 do
     
    19331946          for cix := 0 to RW[p1].nCity - 1 do
    19341947            if (RW[p1].City[cix].Loc >= 0) and
    1935               (RW[p1].City[cix].built[imTemple] > 0) then
     1948              (RW[p1].City[cix].Built[imTemple] > 0) then
    19361949              Inc(OracleIncome);
    19371950    end;
     
    23962409        dGround:
    23972410          LoseCityPop := (PModel.Cap[mcArtillery] > 0) or
    2398             (RW[MoveInfo.Defender].City[MoveInfo.Dcix].built[imWalls] = 0) and
     2411            (RW[MoveInfo.Defender].City[MoveInfo.Dcix].Built[imWalls] = 0) and
    23992412            (Continent[ToLoc] <> GrWallContinent[MoveInfo.Defender]);
    24002413        dSea:
    2401           LoseCityPop := RW[MoveInfo.Defender].City[MoveInfo.Dcix].built
     2414          LoseCityPop := RW[MoveInfo.Defender].City[MoveInfo.Dcix].Built
    24022415            [imCoastalFort] = 0;
    24032416        dAir:
    2404           LoseCityPop := RW[MoveInfo.Defender].City[MoveInfo.Dcix].built
     2417          LoseCityPop := RW[MoveInfo.Defender].City[MoveInfo.Dcix].Built
    24052418            [imMissileBat] = 0;
    24062419      end;
     
    24592472          for cix1 := 1 to nCity - 1 do
    24602473            if (City[cix1].Loc >= 0) and
    2461               ((ExpelToLoc < 0) or (City[cix1].built[imPalace] > 0)) then
     2474              ((ExpelToLoc < 0) or (City[cix1].Built[imPalace] > 0)) then
    24622475              ExpelToLoc := City[cix1].Loc;
    24632476        end;
     
    31053118        AllHumansDead := True;
    31063119        for p1 := 0 to nPl - 1 do
    3107           if (1 shl p1 and GAlive <> 0) and (bix[p1].Kind = btTerm) then
     3120          if (1 shl p1 and GAlive <> 0) and (bix[p1].Kind = btTerm) then begin
    31083121            AllHumansDead := False;
     3122            Break;
     3123          end;
    31093124        if (pDipActive >= 0) // still in negotiation mode
    31103125          or (pTurn = 0) and ((GWinner > 0) or (GTurn = MaxTurn) or
     
    32253240            (Integer(Data) >= 0) and (Integer(Data) < GTurn);
    32263241          for p1 := 1 to nPl - 1 do
    3227             if bix[p1].Kind = btTerm then
     3242            if bix[p1].Kind = btTerm then begin
    32283243              Ok := False;
     3244              Break;
     3245            end;
    32293246          // allow reload in AI-only games only
    32303247        end
     
    33633380              Result := eOfferNotAcceptable;
    33643381            for I := 0 to nDeliver + nCost - 1 do
    3365               if Price[I] = opChoose then
     3382              if Price[I] = opChoose then begin
    33663383                Result := eOfferNotAcceptable;
     3384                Break;
     3385              end;
    33673386            for I := 0 to nCost - 1 do
    33683387              if not PayPrice(pDipActive, p1, Price[nDeliver + I], False) then
     
    34873506          begin // no tribute allowed!
    34883507            for I := 0 to TOffer(Data).nDeliver + TOffer(Data).nCost - 1 do
    3489               if (TOffer(Data).Price[I] and opMask = opTribute) then
     3508              if (TOffer(Data).Price[I] and opMask = opTribute) then begin
    34903509                Result := eInvalidOffer;
     3510                Break;
     3511              end;
    34913512            for I := 0 to TOffer(Data).nDeliver + TOffer(Data).nCost - 1 do
    3492               if (TOffer(Data).Price[I] = opTreaty + trPeace) then
     3513              if (TOffer(Data).Price[I] = opTreaty + trPeace) then begin
    34933514                Result := eOK;
     3515                Break;
     3516              end;
    34943517          end;
    34953518          for I := 0 to TOffer(Data).nDeliver - 1 do
     
    35003523            Result := eInvalidOffer;
    35013524          for I := 0 to nShipPart - 1 do
    3502             if CountPrice(TOffer(Data), opShipParts + I shl 16) > 1 then
     3525            if CountPrice(TOffer(Data), opShipParts + I shl 16) > 1 then begin
    35033526              Result := eInvalidOffer;
     3527              Break;
     3528            end;
    35043529          if CountPrice(TOffer(Data), opMoney) > 1 then
    35053530            Result := eInvalidOffer;
     
    41914216                for I := 0 to nImpReplacement - 1 do
    41924217                  if (ImpReplacement[I].OldImp = NewProject and cpIndex) and
    4193                     (built[ImpReplacement[I].NewImp] > 0) then
    4194                     Result := eObsolete;
     4218                    (Built[ImpReplacement[I].NewImp] > 0) then begin
     4219                      Result := eObsolete;
     4220                      Break;
     4221                    end;
    41954222                if Result = eObsolete then
    41964223                else if Preq = preNA then
     
    41994226                then
    42004227                  Result := eNoPreq
    4201                 else if built[NewProject and cpIndex] > 0 then
     4228                else if Built[NewProject and cpIndex] > 0 then
    42024229                  Result := eInvalid
    42034230                else if (NewProject and cpIndex < nWonder) and
     
    42074234                  (RW[Player].NatBuilt[imSpacePort] > 0) then
    42084235                  Result := eViolation // space port already exists
    4209                 else if (NewProject = cpImp + imBank) and (built[imMarket] = 0)
     4236                else if (NewProject = cpImp + imBank) and (Built[imMarket] = 0)
    42104237                  or (NewProject = cpImp + imUniversity) and
    4211                   (built[imLibrary] = 0) or (NewProject = cpImp + imResLab) and
    4212                   (built[imUniversity] = 0) or (NewProject = cpImp + imMfgPlant)
    4213                   and (built[imFactory] = 0) then
     4238                  (Built[imLibrary] = 0) or (NewProject = cpImp + imResLab) and
     4239                  (Built[imUniversity] = 0) or (NewProject = cpImp + imMfgPlant)
     4240                  and (Built[imFactory] = 0) then
    42144241                  Result := eNoPreq;
    42154242                case NewProject - cpImp of
     
    43624389        else
    43634390          with RW[Player].City[Subject] do
    4364             if built[Integer(Data)] = 0 then
     4391            if Built[Integer(Data)] = 0 then
    43654392              Result := eInvalid
    43664393            else if (RW[Player].Government = gAnarchy) or
     
    43734400              Inc(RW[Player].Money, Imp[Integer(Data)].Cost * BuildCostMod
    43744401                [Difficulty[Player]] div 12);
    4375               built[Integer(Data)] := 0;
     4402              Built[Integer(Data)] := 0;
    43764403              if Imp[Integer(Data)].Kind in [ikNatLocal, ikNatGlobal] then
    43774404              begin
     
    44024429          else
    44034430            with RW[Player].City[Subject] do
    4404               if (built[OldImp] = 0) or (Project and cpImp = 0) or
     4431              if (Built[OldImp] = 0) or (Project and cpImp = 0) or
    44054432                not(Imp[Project and cpIndex].Kind in [ikCommon, ikNatLocal,
    44064433                ikNatGlobal]) then
     
    44194446                  Project0 := Project;
    44204447                Prod0 := Prod;
    4421                 built[OldImp] := 0;
     4448                Built[OldImp] := 0;
    44224449                if Imp[OldImp].Kind in [ikNatLocal, ikNatGlobal] then
    44234450                begin // nat. project lost
  • trunk/LocalPlayer/CityScreen.pas

    r548 r549  
    883883            Sprite(Offscreen, HGrSystem, X - 4, Y + 29 - 3 * J, 10, 10,
    884884              132, 115);
    885         end
     885        end;
    886886      end;
    887887    if imix[0] >= 0 then
     
    10821082        Loc1 := dLoc(cLoc, dx, dy);
    10831083        if (Loc1 >= 0) and (Loc1 < G.lx * G.ly) and
    1084           (MyMap[Loc1] and fTerrain < fGrass) then
    1085           IsPort := True;
     1084          (MyMap[Loc1] and fTerrain < fGrass) then begin
     1085            IsPort := True;
     1086            Break;
     1087          end;
    10861088      end;
    10871089
  • trunk/LocalPlayer/ClientTools.pas

    r531 r549  
    178178  Result := False;
    179179  for p1 := 1 to nPl - 1 do
    180     if G.RO[p1] <> nil then
     180    if G.RO[p1] <> nil then begin
    181181      Result := True;
     182      Break;
     183    end;
    182184end;
    183185
     
    373375          if Abs(dx) + Abs(dy) = 2 then
    374376            if Server(sMoveUnit - sExecute + dx and 7 shl 4 + dy and
    375               7 shl 7, Me, uix, nil^) >= rExecuted then
    376               Result := False;
     377              7 shl 7, Me, uix, nil^) >= rExecuted then begin
     378                Result := False;
     379                Exit;
     380              end;
    377381end;
    378382
     
    608612                  dx := fix and 3 shl 1 - 3 + (dy + 3) and 1;
    609613                  Loc1 := dLoc(MyCity[cix].Loc, dx, dy);
    610                   if MarkCitiesAround(Loc1, cix) then
     614                  if MarkCitiesAround(Loc1, cix) then begin
    611615                    Done := False;
     616                    Break;
     617                  end;
    612618                end;
    613619              Server(sSetCityTiles, Me, cix, Advice.Tiles);
     
    664670        dx := fix and 3 shl 1 - 3 + (dy + 3) and 1;
    665671        Loc1 := dLoc(MyCity[cix].Loc, dx, dy);
    666         if MarkCitiesAround(Loc1, cix) then
     672        if MarkCitiesAround(Loc1, cix) then begin
    667673          Done := False;
     674          Break;
     675        end;
    668676      end;
    669677    if not Done then
  • trunk/LocalPlayer/Draft.pas

    r536 r549  
    307307      for I := 0 to Lines - 1 do
    308308      begin
    309         if not(Code[I] in AutoFeature) then
     309        if not (Code[I] in AutoFeature) then
    310310        begin
    311311          // paint +/- butttons
     
    458458procedure TDraftDlg.FormShow(Sender: TObject);
    459459var
    460   count, D, I: Integer;
     460  Count, D, I: Integer;
    461461begin
    462462  Domain := dGround;
     
    465465    Inc(Domain);
    466466
    467   // count max number of features in any domain
     467  // Count max number of features in any domain
    468468  MaxLines := 0;
    469469  for D := 0 to nDomains - 1 do
     
    471471      (MyRO.Tech[upgrade[D, 0].Preq] >= tsApplicable) then
    472472    begin
    473       count := 0;
     473      Count := 0;
    474474      for I := 0 to nFeature - 1 do
    475475        if IsFeatureInList(D, I) then
    476           Inc(count);
    477       if count > MaxLines then
    478         MaxLines := count;
     476          Inc(Count);
     477      if Count > MaxLines then
     478        MaxLines := Count;
    479479    end;
    480480  Cut := (MaxLines0 - MaxLines) * LinePitch;
  • trunk/LocalPlayer/Help.pas

    r531 r549  
    965965      else if Item = 'AITSTAT' then
    966966        for I := 0 to 3 do
    967           AddLine(Phrases2.Lookup('AITSTAT', I), pkAITStat, I)
     967          AddLine(Phrases2.Lookup('AITSTAT', I), pkAITStat, I);
    968968    end;
    969969  end;
     
    15221522          for Domain := 0 to nDomains - 1 do
    15231523            for I := 1 to nUpgrade - 1 do
    1524               if upgrade[Domain, I].Preq = No then
     1524              if Upgrade[Domain, I].Preq = No then
    15251525              begin
    1526                 if upgrade[Domain, I].Strength > 0 then
     1526                if Upgrade[Domain, I].Strength > 0 then
    15271527                  AddLine(Format(HelpText.Lookup('STRENGTHUP'),
    15281528                    [Phrases.Lookup('DOMAIN', Domain), upgrade[Domain,
    15291529                    I].Strength]), pkDomain, Domain);
    1530                 if upgrade[Domain, I].Trans > 0 then
     1530                if Upgrade[Domain, I].Trans > 0 then
    15311531                  AddLine(Format(HelpText.Lookup('TRANSUP'),
    15321532                    [Phrases.Lookup('DOMAIN', Domain), upgrade[Domain, I].Trans]
     
    15341534                if No in FutureTech then
    15351535                  AddLine(Format(HelpText.Lookup('COSTUP'),
    1536                     [upgrade[Domain, I].Cost]), pkNormal_Dot)
     1536                    [Upgrade[Domain, I].Cost]), pkNormal_Dot)
    15371537                else
    15381538                  AddLine(Format(HelpText.Lookup('COSTMIN'),
    1539                     [upgrade[Domain, I].Cost]), pkNormal_Dot)
     1539                    [Upgrade[Domain, I].Cost]), pkNormal_Dot)
    15401540              end;
    15411541          NextSection('EXPIRATION');
  • trunk/LocalPlayer/IsoEngine.pas

    r548 r549  
    3939    function IsShoreTile(Loc: Integer): Boolean;
    4040    procedure MakeDark(Line: PPixelPointer; Length: Integer);
     41    procedure NameCity(X, Y, Loc: Integer);
     42    procedure PaintBorder(X, Y, Loc, Tile: Integer);
     43    function PoleTile(Loc: Integer): Integer;
    4144    procedure SetTileSize(AValue: TTileSize);
    4245    procedure ShadeOutside(x0, y0, Width, Height, xm, ym: Integer);
     46    procedure ShowSpacePort(X, Y, Tile: Integer; CityInfo: TCityInfo);
    4347  protected
    4448    FOutput: TBitmap;
     
    803807end;
    804808
    805 function PoleTile(Loc: Integer): Integer;
     809function TIsoMap.PoleTile(Loc: Integer): Integer;
    806810begin { virtual pole tile }
    807811  Result := fUNKNOWN;
     
    10471051end;
    10481052
     1053procedure TIsoMap.NameCity(X, Y, Loc: Integer);
     1054var
     1055  cix, xs, W: Integer;
     1056  BehindCityInfo: TCityInfo;
     1057  S: string;
     1058  IsCapital: Boolean;
     1059begin
     1060  BehindCityInfo.Loc := Loc - 2 * G.lx;
     1061  if ShowCityNames and not (moEditMode in MapOptions) and
     1062    (BehindCityInfo.Loc >= 0) and (BehindCityInfo.Loc < G.lx * G.ly) and
     1063    (MyMap[BehindCityInfo.Loc] and fCity <> 0) then
     1064  begin
     1065    GetCityInfo(BehindCityInfo.Loc, cix, BehindCityInfo);
     1066    IsCapital := BehindCityInfo.Flags and ciCapital <> 0;
     1067    { if Showuix and (cix>=0) then s:=IntToStr(cix)
     1068      else } S := CityName(BehindCityInfo.ID);
     1069    W := FOutput.Canvas.TextWidth(S);
     1070    xs := X + xxt - (W + 1) div 2;
     1071    if IsCapital then
     1072      FOutput.Canvas.Font.Style := FOutput.Canvas.Font.Style + [TFontStyle.fsUnderline];
     1073    TextOut(xs + 1, Y - 9, $000000, S);
     1074    TextOut(xs, Y - 10, $FFFFFF, S);
     1075    if IsCapital then
     1076      FOutput.Canvas.Font.Style := FOutput.Canvas.Font.Style - [TFontStyle.fsUnderline];
     1077  end;
     1078end;
     1079
     1080procedure TIsoMap.PaintBorder(X, Y, Loc, Tile: Integer);
     1081var
     1082  dx, dy: Integer;
     1083  p1, p2, Loc1: Integer;
     1084begin
     1085  if ShowBorder and (Loc >= 0) and (Loc < G.lx * G.ly) and
     1086    (Tile and fTerrain <> fUNKNOWN) then begin
     1087    p1 := MyRO.Territory[Loc];
     1088    if (p1 >= 0) and (ShowMyBorder or (p1 <> Me)) then begin
     1089      if BordersOK^ and (1 shl p1) = 0 then begin
     1090        UnshareBitmap(Borders);
     1091        BitBltBitmap(Borders, 0, p1 * (yyt * 2), xxt * 2,
     1092          yyt * 2, HGrTerrain.Data,
     1093          1 + 8 * (xxt * 2 + 1), 1 + yyt + 16 * (yyt * 3 + 1));
     1094        BitmapReplaceColor(Borders, 0, p1 * (yyt * 2), xxt * 2, yyt * 2, $636363, Tribe[p1].Color);
     1095        BordersOK^ := BordersOK^ or 1 shl p1;
     1096      end;
     1097      for dy := 0 to 1 do
     1098        for dx := 0 to 1 do begin
     1099          Loc1 := dLoc(Loc, dx * 2 - 1, dy * 2 - 1);
     1100          begin
     1101            if (Loc1 < 0) or (Loc1 >= G.lx * G.ly) then
     1102              p2 := -1
     1103            else if MyMap[Loc1] and fTerrain = fUNKNOWN then
     1104              p2 := p1
     1105            else
     1106              p2 := MyRO.Territory[Loc1];
     1107            if p2 <> p1 then
     1108            begin
     1109              BitBltBitmapOutput(HGrTerrain.Mask, X + dx * xxt, Y + dy * yyt, xxt,
     1110                yyt, 1 + 8 * (xxt * 2 + 1) + dx * xxt,
     1111                1 + yyt + 16 * (yyt * 3 + 1) + dy * yyt, SRCAND);
     1112              BitBltBitmapOutput(Borders, X + dx * xxt, Y + dy * yyt, xxt, yyt, dx * xxt,
     1113                p1 * (yyt * 2) + dy * yyt, SRCPAINT);
     1114            end;
     1115          end;
     1116        end;
     1117    end;
     1118  end;
     1119end;
     1120
     1121procedure TIsoMap.ShowSpacePort(X, Y, Tile: Integer; CityInfo: TCityInfo);
     1122begin
     1123  if ShowObjects and not (moEditMode in MapOptions) and
     1124    (Tile and fCity <> 0) and (CityInfo.Flags and ciSpacePort <> 0) then
     1125    TerrainSprite(X + xxt, Y - 6, spSpacePort);
     1126end;
     1127
    10491128// (x,y) is top left pixel of (2*xxt,3*yyt) rectangle
    10501129procedure TIsoMap.PaintTileObjects(X, Y, Loc, CityLoc, CityOwner: Integer;
    10511130  UseBlink: Boolean);
    10521131var
    1053   p1, p2, uix, cix, dy, Loc1, Tile, Multi, Destination: Integer;
     1132  uix, cix, dy, Tile, Multi, Destination: Integer;
    10541133  CityInfo: TCityInfo;
    10551134  UnitInfo: TUnitInfo;
     
    10571136  SpecialRow: Integer;
    10581137  SpecialCol: Integer;
    1059 
    1060   procedure NameCity;
    1061   var
    1062     cix, xs, W: Integer;
    1063     BehindCityInfo: TCityInfo;
    1064     S: string;
    1065     IsCapital: Boolean;
    1066   begin
    1067     BehindCityInfo.Loc := Loc - 2 * G.lx;
    1068     if ShowCityNames and not (moEditMode in MapOptions) and
    1069       (BehindCityInfo.Loc >= 0) and (BehindCityInfo.Loc < G.lx * G.ly) and
    1070       (MyMap[BehindCityInfo.Loc] and fCity <> 0) then
    1071     begin
    1072       GetCityInfo(BehindCityInfo.Loc, cix, BehindCityInfo);
    1073       IsCapital := BehindCityInfo.Flags and ciCapital <> 0;
    1074       { if Showuix and (cix>=0) then s:=IntToStr(cix)
    1075         else } S := CityName(BehindCityInfo.ID);
    1076       W := FOutput.Canvas.TextWidth(S);
    1077       xs := X + xxt - (W + 1) div 2;
    1078       if IsCapital then
    1079         FOutput.Canvas.Font.Style := FOutput.Canvas.Font.Style + [TFontStyle.fsUnderline];
    1080       TextOut(xs + 1, Y - 9, $000000, S);
    1081       TextOut(xs, Y - 10, $FFFFFF, S);
    1082       if IsCapital then
    1083         FOutput.Canvas.Font.Style := FOutput.Canvas.Font.Style - [TFontStyle.fsUnderline];
    1084     end;
    1085   end;
    1086 
    1087   procedure ShowSpacePort;
    1088   begin
    1089     if ShowObjects and not (moEditMode in MapOptions) and
    1090       (Tile and fCity <> 0) and (CityInfo.Flags and ciSpacePort <> 0) then
    1091       TerrainSprite(X + xxt, Y - 6, spSpacePort);
    1092   end;
    1093 
    1094   procedure PaintBorder;
    1095   var
    1096     dx, dy: Integer;
    1097   begin
    1098     if ShowBorder and (Loc >= 0) and (Loc < G.lx * G.ly) and
    1099       (Tile and fTerrain <> fUNKNOWN) then begin
    1100       p1 := MyRO.Territory[Loc];
    1101       if (p1 >= 0) and (ShowMyBorder or (p1 <> Me)) then begin
    1102         if BordersOK^ and (1 shl p1) = 0 then begin
    1103           UnshareBitmap(Borders);
    1104           BitBltBitmap(Borders, 0, p1 * (yyt * 2), xxt * 2,
    1105             yyt * 2, HGrTerrain.Data,
    1106             1 + 8 * (xxt * 2 + 1), 1 + yyt + 16 * (yyt * 3 + 1));
    1107           BitmapReplaceColor(Borders, 0, p1 * (yyt * 2), xxt * 2, yyt * 2, $636363, Tribe[p1].Color);
    1108           BordersOK^ := BordersOK^ or 1 shl p1;
    1109         end;
    1110         for dy := 0 to 1 do
    1111           for dx := 0 to 1 do begin
    1112             Loc1 := dLoc(Loc, dx * 2 - 1, dy * 2 - 1);
    1113             begin
    1114               if (Loc1 < 0) or (Loc1 >= G.lx * G.ly) then
    1115                 p2 := -1
    1116               else if MyMap[Loc1] and fTerrain = fUNKNOWN then
    1117                 p2 := p1
    1118               else
    1119                 p2 := MyRO.Territory[Loc1];
    1120               if p2 <> p1 then
    1121               begin
    1122                 BitBltBitmapOutput(HGrTerrain.Mask, X + dx * xxt, Y + dy * yyt, xxt,
    1123                   yyt, 1 + 8 * (xxt * 2 + 1) + dx * xxt,
    1124                   1 + yyt + 16 * (yyt * 3 + 1) + dy * yyt, SRCAND);
    1125                 BitBltBitmapOutput(Borders, X + dx * xxt, Y + dy * yyt, xxt, yyt, dx * xxt,
    1126                   p1 * (yyt * 2) + dy * yyt, SRCPAINT);
    1127               end;
    1128             end;
    1129           end;
    1130       end;
    1131     end;
    1132   end;
    1133 
    11341138begin
    11351139  if (Loc < 0) or (Loc >= G.lx * G.ly) then
     
    11431147    (X > FRight) then
    11441148  begin
    1145     NameCity;
    1146     ShowSpacePort;
     1149    NameCity(X, Y, Loc);
     1150    ShowSpacePort(X, Y, Tile, CityInfo);
    11471151    Exit;
    11481152  end;
    11491153  if Tile and fTerrain = fUNKNOWN then
    11501154  begin
    1151     NameCity;
    1152     ShowSpacePort;
     1155    NameCity(X, Y, Loc);
     1156    ShowSpacePort(X, Y, Tile, CityInfo);
    11531157    Exit;
    11541158  end; { square not discovered }
    11551159
    11561160  if not (FoW and (Tile and fObserved = 0)) then
    1157     PaintBorder;
     1161    PaintBorder(X, Y, Loc, Tile);
    11581162
    11591163  if (Loc >= 0) and (Loc < G.lx * G.ly) and (Loc = FAdviceLoc) then
     
    12111215
    12121216  if FoW and (Tile and fObserved = 0) then
    1213     PaintBorder;
     1217    PaintBorder(X, Y, Loc, Tile);
    12141218
    12151219{$IFNDEF SCR}
     
    12391243      else TerrainSprite(X, Y, 8 + 9 * 1); }
    12401244
    1241     NameCity;
    1242     ShowSpacePort;
     1245    NameCity(X, Y, Loc);
     1246    ShowSpacePort(X, Y, Tile, CityInfo);
    12431247    if Tile and fCity <> 0 then
    12441248      PaintCity(X + xxt, Y + yyt, CityInfo, CityOwner < 0);
     
    13831387begin
    13841388  Result := False;
    1385   for Dir := 0 to 7 do
    1386   begin
     1389  for Dir := 0 to 7 do begin
    13871390    ConnLoc := dLoc(Loc, Dirx[Dir], Diry[Dir]);
    13881391    if (ConnLoc < 0) or (ConnLoc >= G.lx * G.ly) or
    1389       ((MyMap[ConnLoc] - 2) and fTerrain < 13) then
    1390       Result := True;
     1392      ((MyMap[ConnLoc] - 2) and fTerrain < 13) then begin
     1393        Result := True;
     1394        Break;
     1395      end;
    13911396  end;
    13921397end;
  • trunk/LocalPlayer/NatStat.pas

    r536 r549  
    229229  HasContact := False;
    230230  for p1 := 0 to nPl - 1 do
    231     if (p1 <> Me) and (CurrentReport.Treaty[p1] > trNoContact) then
     231    if (p1 <> Me) and (CurrentReport.Treaty[p1] > trNoContact) then begin
    232232      HasContact := True;
     233      Break;
     234    end;
    233235  if HasContact then
    234236  begin
  • trunk/LocalPlayer/Nego.pas

    r531 r549  
    366366      begin
    367367        MyAllowed := MyAllowed + [opAllTech shr 24];
    368         Break
     368        Break;
    369369      end;
    370370    OppoAllowed := OppoAllowed + [opCivilReport shr 24, opAllTech shr 24];
  • trunk/LocalPlayer/Select.pas

    r536 r549  
    11191119                  if (Loc1 >= 0) and (Loc1 < G.lx * G.ly) and
    11201120                    ((MyMap[Loc1] and fTerrain = fShore) or
    1121                     (MyMap[Loc1] and fCanal > 0)) then
    1122                     Ok := True;
     1121                    (MyMap[Loc1] and fCanal > 0)) then begin
     1122                      Ok := True;
     1123                      Break;
     1124                    end;
    11231125                end;
    11241126          end
     
    11661168        for I := 0 to nDomains - 1 do
    11671169          if (upgrade[I, 0].Preq = preNone) or
    1168             (MyRO.Tech[upgrade[I, 0].Preq] >= tsApplicable) then
    1169             Ok := True;
     1170            (MyRO.Tech[upgrade[I, 0].Preq] >= tsApplicable) then begin
     1171              Ok := True;
     1172              Break;
     1173            end;
    11701174        if Ok then { new unit class }
    11711175        begin
     
    12731277          with MyRO.EnemyReport[Column[J]]^ do
    12741278            if (MyRO.Alive and (1 shl Column[J]) <> 0) and
    1275               (TurnOfCivilReport >= 0) and (ResearchTech = adMilitary) then
    1276               Ok := True;
     1279              (TurnOfCivilReport >= 0) and (ResearchTech = adMilitary) then begin
     1280                Ok := True;
     1281                Break;
     1282              end;
    12771283        if Ok then
    12781284        begin
     
    13331339          for emix := 0 to MyRO.nEnemyModel - 1 do
    13341340            if (MyRO.EnemyModel[emix].Owner = DipMem[Me].pContact) and
    1335               IsSameModel(MyRO.EnemyModel[emix], mi) then
    1336               Ok := False;
     1341              IsSameModel(MyRO.EnemyModel[emix], mi) then begin
     1342                Ok := False;
     1343                Break;
     1344              end;
    13371345          if Ok then
    13381346          begin
     
    14391447          end;
    14401448        SortModels;
    1441         FirstShrinkedLine[0] := 0
     1449        FirstShrinkedLine[0] := 0;
    14421450      end;
    14431451    kTribe:
     
    15541562  MultiPage := False;
    15551563  for I := 1 to MaxLayer - 1 do
    1556     if Lines[I] > 0 then
     1564    if Lines[I] > 0 then begin
    15571565      MultiPage := True;
     1566      Break;
     1567    end;
    15581568  WideBottom := MultiPage or (Kind = kScience) or
    15591569    not Phrases2FallenBackToEnglish and
     
    17371747          ((AdvValue[I] < 2000) or (MyRO.Tech[adMassProduction] > tsNA)) and
    17381748          ((AdvValue[I] < 1000) or (MyRO.Tech[adScience] > tsNA)) and
    1739           (Server(sSetResearch - sExecute, Me, I, nil^) < rExecuted) then
    1740           ShowFocus := True;
     1749          (Server(sSetResearch - sExecute, Me, I, nil^) < rExecuted) then begin
     1750            ShowFocus := True;
     1751            Break;
     1752          end;
    17411753    end;
    17421754  ToggleBtn.Visible := (Kind = kCities) and not Supervising or (Kind = kAdvance)
  • 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
  • trunk/NoTerm.pas

    r548 r549  
    256256                ShipComplete := True;
    257257                for I := 0 to nShipPart - 1 do
    258                   if G.RO[Me].Ship[P].Parts[I] < ShipNeed[I] then
     258                  if G.RO[Me].Ship[P].Parts[I] < ShipNeed[I] then begin
    259259                    ShipComplete := False;
     260                    Break;
     261                  end;
    260262                if ShipComplete then
    261263                  Inc(WinStat[P]);
Note: See TracChangeset for help on using the changeset viewer.