Ignore:
Timestamp:
Mar 17, 2021, 11:11:55 AM (4 years ago)
Author:
chronos
Message:
  • Modified: LoadGraphicSet now returns TGrExtDescr reference. Replaced integer index references to GrExt with with direct class reference to TGrExtDescr.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/IsoEngine.pas

    r301 r313  
    5151    procedure FillRect(x, y, Width, Height, Color: integer);
    5252    procedure Textout(x, y, Color: integer; const s: string);
    53     procedure Sprite(HGr, xDst, yDst, Width, Height, xGr, yGr: integer);
     53    procedure Sprite(HGr: TGrExtDescr; xDst, yDst, Width, Height, xGr, yGr: integer);
    5454    procedure TSprite(xDst, yDst, grix: integer; PureBlack: boolean = false);
    5555
     
    139139function ApplyTileSize(xxtNew, yytNew: integer): boolean;
    140140var
    141   i, x, y, xSrc, ySrc, HGrTerrainNew, HGrCitiesNew, age, size: integer;
     141  i: Integer;
     142  x: Integer;
     143  y: Integer;
     144  xSrc: Integer;
     145  ySrc: Integer;
     146  HGrTerrainNew: TGrExtDescr;
     147  HGrCitiesNew: TGrExtDescr;
     148  Age: Integer;
     149  Size: Integer;
    142150  LandMore, OceanMore, DitherMask, Mask24: TBitmap;
    143151  MaskLine: array [0 .. 50 * 3 - 1] of TPixelPointer; // 32 = assumed maximum for yyt
     
    147155  HGrTerrainNew := LoadGraphicSet(Format('Terrain%dx%d.png',
    148156    [xxtNew * 2, yytNew * 2]));
    149   if HGrTerrainNew < 0 then
     157  if not Assigned(HGrTerrainNew) then
    150158    exit;
    151159  HGrCitiesNew := LoadGraphicSet(Format('Cities%dx%d.png',
    152160    [xxtNew * 2, yytNew * 2]));
    153   if HGrCitiesNew < 0 then
     161  if not Assigned(HGrCitiesNew) then
    154162    exit;
    155163  xxt := xxtNew;
     
    196204  DitherMask.Canvas.FillRect(0, 0, DitherMask.Width, DitherMask.Height);
    197205  BitBltCanvas(DitherMask.Canvas, 0, 0, xxt * 2, yyt * 2,
    198     GrExt[HGrTerrain].Mask.Canvas, 1 + 7 * (xxt * 2 + 1),
     206    HGrTerrain.Mask.Canvas, 1 + 7 * (xxt * 2 + 1),
    199207    1 + yyt + 15 * (yyt * 3 + 1), SRCAND);
    200208
     
    218226    for y := -1 to 6 do
    219227      BitBltCanvas(LandPatch.Canvas, (x + 2) * (xxt * 2), (y + 2) * yyt,
    220         xxt * 2, yyt, GrExt[HGrTerrain].Data.Canvas, xSrc, ySrc);
     228        xxt * 2, yyt, HGrTerrain.Data.Canvas, xSrc, ySrc);
    221229    for y := -2 to 6 do
    222230      BitBltCanvas(LandPatch.Canvas, (x + 2) * (xxt * 2), (y + 2) * yyt, xxt,
    223         yyt, GrExt[HGrTerrain].Data.Canvas, xSrc + xxt, ySrc + yyt,
     231        yyt, HGrTerrain.Data.Canvas, xSrc + xxt, ySrc + yyt,
    224232        SRCPAINT);
    225233    for y := -2 to 6 do
    226234      BitBltCanvas(LandPatch.Canvas, (x + 2) * (xxt * 2) + xxt, (y + 2) * yyt,
    227         xxt, yyt, GrExt[HGrTerrain].Data.Canvas, xSrc, ySrc + yyt,
     235        xxt, yyt, HGrTerrain.Data.Canvas, xSrc, ySrc + yyt,
    228236        SRCPAINT);
    229237    for y := -2 to 6 do
     
    254262    for x := -2 to 6 do
    255263      BitBltCanvas(LandMore.Canvas, (x + 2) * (xxt * 2), (y + 2) * yyt,
    256         xxt * 2, yyt, GrExt[HGrTerrain].Data.Canvas, xSrc, ySrc);
     264        xxt * 2, yyt, HGrTerrain.Data.Canvas, xSrc, ySrc);
    257265    BitBltCanvas(LandMore.Canvas, xxt * 2, (y + 2) * yyt, xxt, yyt,
    258       GrExt[HGrTerrain].Data.Canvas, xSrc + xxt, ySrc + yyt, SRCPAINT);
     266      HGrTerrain.Data.Canvas, xSrc + xxt, ySrc + yyt, SRCPAINT);
    259267    for x := 0 to 7 do
    260268      BitBltCanvas(LandMore.Canvas, (x + 2) * (xxt * 2) - xxt, (y + 2) * yyt,
    261         xxt * 2, yyt, GrExt[HGrTerrain].Data.Canvas, xSrc, ySrc + yyt,
     269        xxt * 2, yyt, HGrTerrain.Data.Canvas, xSrc, ySrc + yyt,
    262270        SRCPAINT);
    263271    for x := -2 to 6 do
     
    276284      if (x >= 1) = (y >= 2) then
    277285        BitBltCanvas(OceanPatch.Canvas, x * (xxt * 2), y * yyt, xxt * 2, yyt,
    278           GrExt[HGrTerrain].Data.Canvas, xSrc, ySrc);
     286          HGrTerrain.Data.Canvas, xSrc, ySrc);
    279287      if (x >= 1) and ((y < 2) or (x >= 2)) then
    280288      begin
    281289        BitBltCanvas(OceanPatch.Canvas, x * (xxt * 2), y * yyt, xxt, yyt,
    282           GrExt[HGrTerrain].Data.Canvas, xSrc + xxt, ySrc + yyt,
     290          HGrTerrain.Data.Canvas, xSrc + xxt, ySrc + yyt,
    283291          SRCPAINT);
    284292        BitBltCanvas(OceanPatch.Canvas, x * (xxt * 2) + xxt, y * yyt, xxt, yyt,
    285           GrExt[HGrTerrain].Data.Canvas, xSrc, ySrc + yyt, SRCPAINT);
     293          HGrTerrain.Data.Canvas, xSrc, ySrc + yyt, SRCPAINT);
    286294      end;
    287295      BitBltCanvas(OceanPatch.Canvas, x * (xxt * 2), y * yyt, xxt, yyt,
     
    301309      if (x < 1) or (y >= 2) then
    302310        BitBltCanvas(OceanMore.Canvas, x * (xxt * 2), y * yyt, xxt * 2, yyt,
    303           GrExt[HGrTerrain].Data.Canvas, xSrc, ySrc);
     311          HGrTerrain.Data.Canvas, xSrc, ySrc);
    304312      if (x = 1) and (y < 2) or (x >= 2) and (y >= 1) then
    305313      begin
    306314        BitBltCanvas(OceanMore.Canvas, x * (xxt * 2), y * yyt, xxt, yyt,
    307           GrExt[HGrTerrain].Data.Canvas, xSrc + xxt, ySrc + yyt,
     315          HGrTerrain.Data.Canvas, xSrc + xxt, ySrc + yyt,
    308316          SRCPAINT);
    309317        BitBltCanvas(OceanMore.Canvas, x * (xxt * 2) + xxt, y * yyt, xxt, yyt,
    310           GrExt[HGrTerrain].Data.Canvas, xSrc, ySrc + yyt, SRCPAINT);
     318          HGrTerrain.Data.Canvas, xSrc, ySrc + yyt, SRCPAINT);
    311319      end;
    312320      BitBltCanvas(OceanMore.Canvas, x * (xxt * 2), y * yyt, xxt * 2, yyt,
     
    317325    DitherMask.Canvas, 0, 0, DSTINVERT); { invert dither mask }
    318326  BitBltCanvas(DitherMask.Canvas, 0, 0, xxt * 2, yyt * 2,
    319     GrExt[HGrTerrain].Mask.Canvas, 1, 1 + yyt, SRCPAINT);
     327    HGrTerrain.Mask.Canvas, 1, 1 + yyt, SRCPAINT);
    320328
    321329  for x := -1 to 6 do
     
    351359  end;
    352360  BitBltCanvas(DitherMask.Canvas, 0, 0, xxt * 2, yyt,
    353     GrExt[HGrTerrain].Mask.Canvas, 1, 1 + yyt);
     361    HGrTerrain.Mask.Canvas, 1, 1 + yyt);
    354362
    355363  for x := 0 to 6 do
     
    369377  // reduce size of terrain icons
    370378  Mask24 := TBitmap.Create;
    371   Mask24.Assign(GrExt[HGrTerrain].Mask);
     379  Mask24.Assign(HGrTerrain.Mask);
    372380  Mask24.PixelFormat := pf24bit;
    373381  Mask24.BeginUpdate;
     
    526534end;
    527535
    528 procedure TIsoMap.Sprite(HGr, xDst, yDst, Width, Height, xGr, yGr: integer);
    529 begin
    530   BitBltBitmap(GrExt[HGr].Mask, xDst, yDst, Width, Height, xGr, yGr, SRCAND);
    531   BitBltBitmap(GrExt[HGr].Data, xDst, yDst, Width, Height, xGr, yGr, SRCPAINT);
     536procedure TIsoMap.Sprite(HGr: TGrExtDescr; xDst, yDst, Width, Height, xGr, yGr: integer);
     537begin
     538  BitBltBitmap(HGr.Mask, xDst, yDst, Width, Height, xGr, yGr, SRCAND);
     539  BitBltBitmap(HGr.Data, xDst, yDst, Width, Height, xGr, yGr, SRCPAINT);
    532540end;
    533541
     
    579587      else
    580588        mixShow := mix;
    581       if (Tribe[Owner].ModelPicture[mixShow].HGr = 0) and
     589      if (Tribe[Owner].ModelPicture[mixShow].HGr = HGrSystem) and
    582590        (@OnInitEnemyModel <> nil) then
    583591        if not OnInitEnemyModel(emix) then
     
    612620        xGr := 121 + j mod 7 * 9;
    613621        yGr := 1 + j div 7 * 9;
    614         BitBltBitmap(GrExt[HGrSystem].Mask, x + xsh + 3, y + ysh + 9, 8, 8, xGr,
     622        BitBltBitmap(HGrSystem.Mask, x + xsh + 3, y + ysh + 9, 8, 8, xGr,
    615623          yGr, SRCAND);
    616624        Sprite(HGrSystem, x + xsh + 2, y + ysh + 8, 8, 8, xGr, yGr);
     
    631639  accessory: boolean);
    632640var
    633   age, cHGr, cpix, xGr, xShield, yShield, LabelTextColor, LabelLength: integer;
     641  age: Integer;
     642  cHGr: TGrExtDescr;
     643  cpix: Integer;
     644  xGr: Integer;
     645  xShield: Integer;
     646  yShield: Integer;
     647  LabelTextColor: Integer;
     648  LabelLength: Integer;
    634649  cpic: TCityPicture;
    635650  s: string;
     
    650665    cpix := Tribe[CityInfo.Owner].cpix;
    651666    if (ciWalled and CityInfo.Flags = 0) or
    652       (GrExt[cHGr].Data.Canvas.Pixels[(xGr + 4) * 65, cpix * 49 + 48] = $00FFFF)
     667      (cHGr.Data.Canvas.Pixels[(xGr + 4) * 65, cpix * 49 + 48] = $00FFFF)
    653668    then
    654669      Sprite(cHGr, x - xxc, y - 2 * yyc, xxc * 2, yyc * 3,
     
    819834    exit;
    820835
    821   BitBltBitmap(GrExt[HGrTerrain].Data, x + xxt div 2, y, xxt, yyt,
     836  BitBltBitmap(HGrTerrain.Data, x + xxt div 2, y, xxt, yyt,
    822837    1 + (Conn shr 6 + Conn and 1 shl 2) * (xxt * 2 + 1),
    823838    1 + yyt + (16 + Tile and fTerrain) * (yyt * 3 + 1), SRCPAINT);
    824   BitBltBitmap(GrExt[HGrTerrain].Data, x + xxt, y + yyt div 2, xxt, yyt,
     839  BitBltBitmap(HGrTerrain.Data, x + xxt, y + yyt div 2, xxt, yyt,
    825840    1 + (Conn and 7) * (xxt * 2 + 1) + xxt,
    826841    1 + yyt * 2 + (16 + Tile and fTerrain) * (yyt * 3 + 1), SRCPAINT);
    827   BitBltBitmap(GrExt[HGrTerrain].Data, x + xxt div 2, y + yyt, xxt, yyt,
     842  BitBltBitmap(HGrTerrain.Data, x + xxt div 2, y + yyt, xxt, yyt,
    828843    1 + (Conn shr 2 and 7) * (xxt * 2 + 1) + xxt,
    829844    1 + yyt + (16 + Tile and fTerrain) * (yyt * 3 + 1), SRCPAINT);
    830   BitBltBitmap(GrExt[HGrTerrain].Data, x, y + yyt div 2, xxt, yyt,
     845  BitBltBitmap(HGrTerrain.Data, x, y + yyt div 2, xxt, yyt,
    831846    1 + (Conn shr 4 and 7) * (xxt * 2 + 1),
    832847    1 + yyt * 2 + (16 + Tile and fTerrain) * (yyt * 3 + 1), SRCPAINT);
    833848  Conn := Connection4(Loc, fTerrain, fUNKNOWN); { dither to black }
    834849  if Conn and 1 <> 0 then
    835     BitBltBitmap(GrExt[HGrTerrain].Mask, x + xxt, y, xxt, yyt, 1 + 7 * (xxt * 2 + 1) +
     850    BitBltBitmap(HGrTerrain.Mask, x + xxt, y, xxt, yyt, 1 + 7 * (xxt * 2 + 1) +
    836851      xxt, 1 + yyt + 15 * (yyt * 3 + 1), SRCAND);
    837852  if Conn and 2 <> 0 then
    838     BitBltBitmap(GrExt[HGrTerrain].Mask, x + xxt, y + yyt, xxt, yyt,
     853    BitBltBitmap(HGrTerrain.Mask, x + xxt, y + yyt, xxt, yyt,
    839854      1 + 7 * (xxt * 2 + 1) + xxt, 1 + yyt * 2 + 15 * (yyt * 3 + 1), SRCAND);
    840855  if Conn and 4 <> 0 then
    841     BitBltBitmap(GrExt[HGrTerrain].Mask, x, y + yyt, xxt, yyt, 1 + 7 * (xxt * 2 + 1),
     856    BitBltBitmap(HGrTerrain.Mask, x, y + yyt, xxt, yyt, 1 + 7 * (xxt * 2 + 1),
    842857      1 + yyt * 2 + 15 * (yyt * 3 + 1), SRCAND);
    843858  if Conn and 8 <> 0 then
    844     BitBltBitmap(GrExt[HGrTerrain].Mask, x, y, xxt, yyt, 1 + 7 * (xxt * 2 + 1),
     859    BitBltBitmap(HGrTerrain.Mask, x, y, xxt, yyt, 1 + 7 * (xxt * 2 + 1),
    845860      1 + yyt + 15 * (yyt * 3 + 1), SRCAND);
    846861end;
     
    10121027
    10131028          BitBltCanvas(Borders.Canvas, 0, p1 * (yyt * 2), xxt * 2,
    1014             yyt * 2, GrExt[HGrTerrain].Data.Canvas,
     1029            yyt * 2, HGrTerrain.Data.Canvas,
    10151030            1 + 8 * (xxt * 2 + 1), 1 + yyt + 16 * (yyt * 3 + 1));
    10161031          Borders.BeginUpdate;
     
    10431058              if p2 <> p1 then
    10441059              begin
    1045                 BitBltBitmap(GrExt[HGrTerrain].Mask, x + dx * xxt, y + dy * yyt, xxt,
     1060                BitBltBitmap(HGrTerrain.Mask, x + dx * xxt, y + dy * yyt, xxt,
    10461061                  yyt, 1 + 8 * (xxt * 2 + 1) + dx * xxt,
    10471062                  1 + yyt + 16 * (yyt * 3 + 1) + dy * yyt, SRCAND);
     
    15361551                bix := Aix;
    15371552            if Aix = -1 then
    1538               BitBltBitmap(GrExt[HGrTerrain].Data, x + dx * xxt, y + dy * yyt, xxt,
     1553              BitBltBitmap(HGrTerrain.Data, x + dx * xxt, y + dy * yyt, xxt,
    15391554                yyt, 1 + 6 * (xxt * 2 + 1) + (dx + dy + 1) and 1 * xxt, 1 + yyt,
    15401555                SRCCOPY) // arctic <-> ocean
    15411556            else if bix = -1 then
    1542               BitBltBitmap(GrExt[HGrTerrain].Data, x + dx * xxt, y + dy * yyt, xxt,
     1557              BitBltBitmap(HGrTerrain.Data, x + dx * xxt, y + dy * yyt, xxt,
    15431558                yyt, 1 + 6 * (xxt * 2 + 1) + xxt - (dx + dy + 1) and 1 * xxt,
    15441559                1 + yyt * 2, SRCCOPY) // arctic <-> ocean
     
    15491564      end;
    15501565
    1551   DataCanvas := GrExt[HGrTerrain].Data.Canvas;
    1552   MaskCanvas := GrExt[HGrTerrain].Mask.Canvas;
     1566  DataCanvas := HGrTerrain.Data.Canvas;
     1567  MaskCanvas := HGrTerrain.Mask.Canvas;
    15531568  for dy := -2 to ny + 1 do
    15541569    for dx := -1 to nx do
Note: See TracChangeset for help on using the changeset viewer.