Changeset 551


Ignore:
Timestamp:
Apr 22, 2024, 10:38:13 PM (11 days ago)
Author:
chronos
Message:
  • Modified: Code cleanup.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/IsoEngine.pas

    r550 r551  
    6969    ShowGrWall: Boolean;
    7070    ShowDebug: Boolean;
    71     FoW: Boolean;
     71    FogOfWar: Boolean;
    7272    function Connection4(Loc, Mask, Value: Integer): Integer;
    7373    function Connection8(Loc, Mask: Integer): Integer;
    7474    function OceanConnection(Loc: Integer): Integer;
     75    procedure PaintLandOcean(X, Y, Loc, nx, ny: Integer);
    7576    procedure PaintShore(X, Y, Loc: Integer);
    7677    procedure PaintTileExtraTerrain(X, Y, Loc: Integer);
     
    902903end;
    903904
     905procedure TIsoMap.PaintLandOcean(X, Y, Loc, nx, ny: Integer);
     906var
     907  dy, dx: Integer;
     908  ALoc, BLoc, ATer, BTer, Aix, bix: Integer;
     909begin
     910  for dy := 0 to ny + 1 do
     911    if (Loc + dy * G.lx >= 0) and (Loc + (dy - 3) * G.lx < G.lx * G.ly) then
     912      for dx := 0 to nx do begin
     913        ALoc := dLoc(Loc, dx - (dy + dx) and 1, dy - 2);
     914        BLoc := dLoc(Loc, dx - (dy + dx + 1) and 1, dy - 1);
     915        if (ALoc < 0) or (ALoc >= G.lx * G.ly) then
     916          ATer := PoleTile(ALoc) and fTerrain
     917        else
     918          ATer := MyMap[ALoc] and fTerrain;
     919        if (BLoc < 0) or (BLoc >= G.lx * G.ly) then
     920          BTer := PoleTile(BLoc) and fTerrain
     921        else
     922          BTer := MyMap[BLoc] and fTerrain;
     923
     924        if (ATer <> fUNKNOWN) or (BTer <> fUNKNOWN) then
     925          if ((ATer < fGrass) or (ATer = fUNKNOWN)) and
     926            ((BTer < fGrass) or (BTer = fUNKNOWN)) then
     927          begin
     928            if ATer = fUNKNOWN then
     929              Aix := 0
     930            else if IsShoreTile(ALoc) then
     931              if ATer = fOcean then
     932                Aix := -1
     933              else
     934                Aix := 1
     935            else
     936              Aix := ATer + 2;
     937            if BTer = fUNKNOWN then
     938              bix := 0
     939            else if IsShoreTile(BLoc) then
     940              if BTer = fOcean then
     941                bix := -1
     942              else
     943                bix := 1
     944            else
     945              bix := BTer + 2;
     946            if (Aix > 1) or (bix > 1) then
     947            begin
     948              if Aix = -1 then
     949                if bix = fOcean + 2 then begin
     950                  Aix := 0;
     951                  bix := 0;
     952                end else begin
     953                  Aix := 0;
     954                  bix := 1;
     955                end
     956              else if bix = -1 then
     957                if Aix = fOcean + 2 then begin
     958                  Aix := 1;
     959                  bix := 1;
     960                end else begin
     961                  Aix := 1;
     962                  bix := 0;
     963                end;
     964              BitBltBitmapOutput(OceanPatch, X + dx * xxt, Y + dy * yyt, xxt, yyt,
     965                Aix * (xxt * 2) + (dx + dy + 1) and 1 * xxt, bix * yyt, SRCCOPY);
     966            end;
     967          end else begin
     968            if ATer = fUNKNOWN then
     969              Aix := 0
     970            else if (ALoc >= 0) and (ALoc < G.lx * G.ly) and
     971              (MyMap[ALoc] and fDeadLands <> 0) then
     972              Aix := -2
     973            else if ATer = fOcean then
     974              Aix := -1
     975            else if ATer = fShore then
     976              Aix := 1
     977            else if ATer >= fForest then
     978              Aix := 8
     979            else
     980              Aix := ATer;
     981            if BTer = fUNKNOWN then
     982              bix := 0
     983            else if (BLoc >= 0) and (BLoc < G.lx * G.ly) and
     984              (MyMap[BLoc] and fDeadLands <> 0) then
     985              bix := -2
     986            else if BTer = fOcean then
     987              bix := -1
     988            else if BTer = fShore then
     989              bix := 1
     990            else if BTer >= fForest then
     991              bix := 8
     992            else
     993              bix := BTer;
     994            if (Aix = -2) and (bix = -2) then begin
     995              Aix := fDesert;
     996              bix := fDesert;
     997            end
     998            else if Aix = -2 then
     999              if bix < 2 then
     1000                Aix := 8
     1001              else
     1002                Aix := bix
     1003            else if bix = -2 then
     1004              if Aix < 2 then
     1005                bix := 8
     1006              else
     1007                bix := Aix;
     1008            if Aix = -1 then
     1009              BitBltBitmapOutput(HGrTerrain.Data, X + dx * xxt, Y + dy * yyt, xxt,
     1010                yyt, 1 + 6 * (xxt * 2 + 1) + (dx + dy + 1) and 1 * xxt, 1 + yyt,
     1011                SRCCOPY) // arctic <-> ocean
     1012            else if bix = -1 then
     1013              BitBltBitmapOutput(HGrTerrain.Data, X + dx * xxt, Y + dy * yyt, xxt,
     1014                yyt, 1 + 6 * (xxt * 2 + 1) + xxt - (dx + dy + 1) and 1 * xxt,
     1015                1 + yyt * 2, SRCCOPY) // arctic <-> ocean
     1016            else
     1017              BitBltBitmapOutput(LandPatch, X + dx * xxt, Y + dy * yyt, xxt, yyt,
     1018                Aix * (xxt * 2) + (dx + dy + 1) and 1 * xxt, bix * yyt, SRCCOPY);
     1019          end;
     1020      end;
     1021end;
     1022
    9041023procedure TIsoMap.PaintShore(X, Y, Loc: Integer);
    9051024var
     
    11571276  end; { square not discovered }
    11581277
    1159   if not (FoW and (Tile and fObserved = 0)) then
     1278  if not (FogOfWar and (Tile and fObserved = 0)) then
    11601279    PaintBorder(X, Y, Loc, Tile);
    11611280
     
    12021321    Fog := Tile and fGrWall = 0
    12031322  else
    1204     Fog := FoW and (Tile and fObserved = 0);
     1323    Fog := FogOfWar and (Tile and fObserved = 0);
    12051324  if Fog and ShowObjects then
    12061325    if Loc < -G.lx then
     
    12131332      TerrainSprite(X, Y, spGrid, xxt <> 33);
    12141333
    1215   if FoW and (Tile and fObserved = 0) then
     1334  if FogOfWar and (Tile and fObserved = 0) then
    12161335    PaintBorder(X, Y, Loc, Tile);
    12171336
     
    14801599  dx, dy, xm, ym, ALoc, BLoc, ATer, BTer, Aix, bix: Integer;
    14811600begin
    1482   FoW := True;
     1601  FogOfWar := True;
    14831602  ShowLoc := moLocCodes in MapOptions;
    14841603  ShowDebug := pDebugMap >= 0;
     
    14891608  ShowMyBorder := CityOwner < 0;
    14901609  ShowGrWall := (CityOwner < 0) and (moGreatWall in MapOptions);
    1491   if ShowDebug then
    1492     Server(sGetDebugMap, Me, pDebugMap, DebugMap)
    1493   else
    1494     DebugMap := nil;
    1495   with FOutput.Canvas do
    1496   begin
     1610  if ShowDebug then Server(sGetDebugMap, Me, pDebugMap, DebugMap)
     1611    else DebugMap := nil;
     1612
     1613  with FOutput.Canvas do begin
    14971614    RealTop := Y - ((Loc + 12345 * G.lx) div G.lx - 12345) * yyt;
    14981615    RealBottom := Y + (G.ly - ((Loc + 12345 * G.lx) div G.lx - 12345) +
     
    15121629  end;
    15131630
    1514   for dy := 0 to ny + 1 do
    1515     if (Loc + dy * G.lx >= 0) and (Loc + (dy - 3) * G.lx < G.lx * G.ly) then
    1516       for dx := 0 to nx do
    1517       begin
    1518         ALoc := dLoc(Loc, dx - (dy + dx) and 1, dy - 2);
    1519         BLoc := dLoc(Loc, dx - (dy + dx + 1) and 1, dy - 1);
    1520         if (ALoc < 0) or (ALoc >= G.lx * G.ly) then
    1521           ATer := PoleTile(ALoc) and fTerrain
    1522         else
    1523           ATer := MyMap[ALoc] and fTerrain;
    1524         if (BLoc < 0) or (BLoc >= G.lx * G.ly) then
    1525           BTer := PoleTile(BLoc) and fTerrain
    1526         else
    1527           BTer := MyMap[BLoc] and fTerrain;
    1528 
    1529         if (ATer <> fUNKNOWN) or (BTer <> fUNKNOWN) then
    1530           if ((ATer < fGrass) or (ATer = fUNKNOWN)) and
    1531             ((BTer < fGrass) or (BTer = fUNKNOWN)) then
    1532           begin
    1533             if ATer = fUNKNOWN then
    1534               Aix := 0
    1535             else if IsShoreTile(ALoc) then
    1536               if ATer = fOcean then
    1537                 Aix := -1
    1538               else
    1539                 Aix := 1
    1540             else
    1541               Aix := ATer + 2;
    1542             if BTer = fUNKNOWN then
    1543               bix := 0
    1544             else if IsShoreTile(BLoc) then
    1545               if BTer = fOcean then
    1546                 bix := -1
    1547               else
    1548                 bix := 1
    1549             else
    1550               bix := BTer + 2;
    1551             if (Aix > 1) or (bix > 1) then
    1552             begin
    1553               if Aix = -1 then
    1554                 if bix = fOcean + 2 then
    1555                 begin
    1556                   Aix := 0;
    1557                   bix := 0;
    1558                 end
    1559                 else
    1560                 begin
    1561                   Aix := 0;
    1562                   bix := 1;
    1563                 end
    1564               else if bix = -1 then
    1565                 if Aix = fOcean + 2 then
    1566                 begin
    1567                   Aix := 1;
    1568                   bix := 1;
    1569                 end
    1570                 else
    1571                 begin
    1572                   Aix := 1;
    1573                   bix := 0;
    1574                 end;
    1575               BitBltBitmapOutput(OceanPatch, X + dx * xxt, Y + dy * yyt, xxt, yyt,
    1576                 Aix * (xxt * 2) + (dx + dy + 1) and 1 * xxt, bix * yyt, SRCCOPY);
    1577             end;
    1578           end
    1579           else
    1580           begin
    1581             if ATer = fUNKNOWN then
    1582               Aix := 0
    1583             else if (ALoc >= 0) and (ALoc < G.lx * G.ly) and
    1584               (MyMap[ALoc] and fDeadLands <> 0) then
    1585               Aix := -2
    1586             else if ATer = fOcean then
    1587               Aix := -1
    1588             else if ATer = fShore then
    1589               Aix := 1
    1590             else if ATer >= fForest then
    1591               Aix := 8
    1592             else
    1593               Aix := ATer;
    1594             if BTer = fUNKNOWN then
    1595               bix := 0
    1596             else if (BLoc >= 0) and (BLoc < G.lx * G.ly) and
    1597               (MyMap[BLoc] and fDeadLands <> 0) then
    1598               bix := -2
    1599             else if BTer = fOcean then
    1600               bix := -1
    1601             else if BTer = fShore then
    1602               bix := 1
    1603             else if BTer >= fForest then
    1604               bix := 8
    1605             else
    1606               bix := BTer;
    1607             if (Aix = -2) and (bix = -2) then
    1608             begin
    1609               Aix := fDesert;
    1610               bix := fDesert;
    1611             end
    1612             else if Aix = -2 then
    1613               if bix < 2 then
    1614                 Aix := 8
    1615               else
    1616                 Aix := bix
    1617             else if bix = -2 then
    1618               if Aix < 2 then
    1619                 bix := 8
    1620               else
    1621                 bix := Aix;
    1622             if Aix = -1 then
    1623               BitBltBitmapOutput(HGrTerrain.Data, X + dx * xxt, Y + dy * yyt, xxt,
    1624                 yyt, 1 + 6 * (xxt * 2 + 1) + (dx + dy + 1) and 1 * xxt, 1 + yyt,
    1625                 SRCCOPY) // arctic <-> ocean
    1626             else if bix = -1 then
    1627               BitBltBitmapOutput(HGrTerrain.Data, X + dx * xxt, Y + dy * yyt, xxt,
    1628                 yyt, 1 + 6 * (xxt * 2 + 1) + xxt - (dx + dy + 1) and 1 * xxt,
    1629                 1 + yyt * 2, SRCCOPY) // arctic <-> ocean
    1630             else
    1631               BitBltBitmapOutput(LandPatch, X + dx * xxt, Y + dy * yyt, xxt, yyt,
    1632                 Aix * (xxt * 2) + (dx + dy + 1) and 1 * xxt, bix * yyt, SRCCOPY);
    1633           end;
    1634       end;
     1631  PaintLandOcean(X, Y, Loc, nx, ny);
    16351632
    16361633  for dy := -2 to ny + 1 do
     
    16381635      if (dx + dy) and 1 = 0 then
    16391636        PaintShore(X + xxt * dx, Y + yyt + yyt * dy, dLoc(Loc, dx, dy));
     1637
    16401638  for dy := -2 to ny + 1 do
    16411639    for dx := -1 to nx do
    16421640      if (dx + dy) and 1 = 0 then
    1643         PaintTileExtraTerrain(X + xxt * dx, Y + yyt + yyt * dy,
    1644           dLoc(Loc, dx, dy));
    1645 
    1646   if CityOwner >= 0 then
    1647   begin
     1641        PaintTileExtraTerrain(X + xxt * dx, Y + yyt + yyt * dy, dLoc(Loc, dx, dy));
     1642
     1643  if CityOwner >= 0 then begin
     1644    // Paint objects outside radius
    16481645    for dy := -2 to ny + 1 do
    16491646      for dx := -2 to nx + 1 do
     
    16551652              CityOwner, UseBlink);
    16561653        end;
     1654
    16571655    dx := ((CityLoc mod G.lx * 2 + CityLoc div G.lx and 1) -
    16581656      ((Loc + 666 * G.lx) mod G.lx * 2 + (Loc + 666 * G.lx) div G.lx and 1) + 3
     
    16631661    ShadeOutside(FLeft, FTop, FRight - FLeft, FBottom - FTop, xm, ym);
    16641662    CityGrid(xm, ym, CityAllowClick);
     1663
     1664    // Paint objects inside radius
    16651665    for dy := -2 to ny + 1 do
    16661666      for dx := -2 to nx + 1 do
     
    16721672              CityOwner, UseBlink);
    16731673        end;
    1674   end
    1675   else
    1676   begin
    1677     if ShowLoc or (moEditMode in MapOptions) or
    1678       (moGrid in MapOptions) then
     1674  end else begin
     1675    if ShowLoc or (moEditMode in MapOptions) or (moGrid in MapOptions) then
    16791676      PaintGrid(X, Y, nx, ny);
     1677
    16801678    for dy := -2 to ny + 1 do
    16811679      for dx := -2 to nx + 1 do
     
    16841682            CityLoc, CityOwner, UseBlink);
    16851683  end;
    1686 
    1687   // frame(FOutput.Canvas,x+1,y+1,x+nx*33+33-2,y+ny*16+32-2,$FFFF,$FFFF);
    16881684end;
    16891685
Note: See TracChangeset for help on using the changeset viewer.