Skip to content

Commit

Permalink
Create makeTileRubbleTexture() to set tiles to a rubble texture
Browse files Browse the repository at this point in the history
  • Loading branch information
KJeff01 committed Apr 13, 2024
1 parent 5daee26 commit a2e1212
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/feature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,9 @@ bool destroyFeature(FEATURE *psDel, unsigned impactTime)
{
for (int width = 0; width < b.size.x; ++width)
{
MAPTILE *psTile = mapTile(b.map.x + width, b.map.y + breadth);
const unsigned int x = b.map.x + width;
const unsigned int y = b.map.y + breadth;
MAPTILE *psTile = mapTile(x, y);
// stops water texture changing for underwater features
if (terrainType(psTile) != TER_WATER)
{
Expand All @@ -555,22 +557,18 @@ bool destroyFeature(FEATURE *psDel, unsigned impactTime)
/* Clear feature bits */
if (isUrban)
{
psTile->texture = TileNumber_texture(psTile->texture) | RUBBLE_TILE;
SET_TILE_DECAL(psTile);
markTileDirty(b.map.x + width, b.map.y + breadth);
makeTileRubbleTexture(psTile, x, y, RUBBLE_TILE);
}
auxClearBlocking(b.map.x + width, b.map.y + breadth, AUXBITS_ALL);
auxClearBlocking(x, y, AUXBITS_ALL);
}
else
{
/* This remains a blocking tile */
psTile->psObject = nullptr;
auxClearBlocking(b.map.x + width, b.map.y + breadth, AIR_BLOCKED); // Shouldn't remain blocking for air units, however.
auxClearBlocking(x, y, AIR_BLOCKED); // Shouldn't remain blocking for air units, however.
if (isUrban)
{
psTile->texture = TileNumber_texture(psTile->texture) | BLOCKING_RUBBLE_TILE;
SET_TILE_DECAL(psTile);
markTileDirty(b.map.x + width, b.map.y + breadth);
makeTileRubbleTexture(psTile, x, y, BLOCKING_RUBBLE_TILE);
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,13 @@ WZ_DECL_ALWAYS_INLINE static inline bool worldOnMap(Vector2i pos)
return worldOnMap(pos.x, pos.y);
}

static inline void makeTileRubbleTexture(MAPTILE *psTile, const unsigned int x, const unsigned int y, const unsigned int newTexture)
{
psTile->texture = TileNumber_texture(psTile->texture) | newTexture;
SET_TILE_DECAL(psTile);
markTileDirty(x, y);
}


/* Intersect a line with the map and report tile intersection points */
bool map_Intersect(int *Cx, int *Cy, int *Vx, int *Vy, int *Sx, int *Sy);
Expand Down

0 comments on commit a2e1212

Please sign in to comment.