mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 22:28:56 +00:00
(svn r12513) -Codechange: rename OriginalTileRandomiser something more descriptive
This commit is contained in:
parent
a0895d57fa
commit
4cc6140619
@ -216,7 +216,7 @@ static uint32 HouseGetVariable(const ResolverObject *object, byte variable, byte
|
|||||||
|
|
||||||
switch (variable) {
|
switch (variable) {
|
||||||
/* Construction stage. */
|
/* Construction stage. */
|
||||||
case 0x40: return (IsTileType(tile, MP_HOUSE) ? GetHouseBuildingStage(tile) : 0) | OriginalTileRandomiser(TileX(tile), TileY(tile)) << 2;
|
case 0x40: return (IsTileType(tile, MP_HOUSE) ? GetHouseBuildingStage(tile) : 0) | TileHash2Bit(TileX(tile), TileY(tile)) << 2;
|
||||||
|
|
||||||
/* Building age. */
|
/* Building age. */
|
||||||
case 0x41: return Clamp(_cur_year - GetHouseConstructionYear(tile), 0, 0xFF);
|
case 0x41: return Clamp(_cur_year - GetHouseConstructionYear(tile), 0, 0xFF);
|
||||||
@ -340,7 +340,7 @@ void DrawTileLayout(const TileInfo *ti, const SpriteGroup *group, byte stage, Ho
|
|||||||
pal = HasBit(callback, 14) ? GB(callback, 0, 8) + SPR_2CCMAP_BASE : callback;
|
pal = HasBit(callback, 14) ? GB(callback, 0, 8) + SPR_2CCMAP_BASE : callback;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pal = hs->random_colour[OriginalTileRandomiser(ti->x, ti->y)] + PALETTE_RECOLOR_START;
|
pal = hs->random_colour[TileHash2Bit(ti->x, ti->y)] + PALETTE_RECOLOR_START;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -314,7 +314,7 @@ extern const Town **_town_sort;
|
|||||||
extern Town *_cleared_town;
|
extern Town *_cleared_town;
|
||||||
extern int _cleared_town_rating;
|
extern int _cleared_town_rating;
|
||||||
|
|
||||||
uint OriginalTileRandomiser(uint x, uint y);
|
uint TileHash2Bit(uint x, uint y);
|
||||||
void ResetHouses();
|
void ResetHouses();
|
||||||
|
|
||||||
void ClearTownHouse(Town *t, TileIndex tile);
|
void ClearTownHouse(Town *t, TileIndex tile);
|
||||||
|
@ -129,15 +129,21 @@ static TownDrawTileProc * const _town_draw_tile_procs[1] = {
|
|||||||
TownDrawHouseLift
|
TownDrawHouseLift
|
||||||
};
|
};
|
||||||
|
|
||||||
uint OriginalTileRandomiser(uint x, uint y)
|
/**
|
||||||
|
* Calculate a hash value from a tile position
|
||||||
|
*
|
||||||
|
* @param x The X coordinate
|
||||||
|
* @param y The Y coordinate
|
||||||
|
* @return The hash of the tile
|
||||||
|
*/
|
||||||
|
uint TileHash2Bit(uint x, uint y)
|
||||||
{
|
{
|
||||||
uint variant;
|
uint hash = x >> 4;
|
||||||
variant = x >> 4;
|
hash ^= x >> 6;
|
||||||
variant ^= x >> 6;
|
hash ^= y >> 4;
|
||||||
variant ^= y >> 4;
|
hash -= y >> 6;
|
||||||
variant -= y >> 6;
|
hash &= 3;
|
||||||
variant &= 3;
|
return hash;
|
||||||
return variant;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -175,7 +181,7 @@ static void DrawTile_Town(TileInfo *ti)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Retrieve pointer to the draw town tile struct */
|
/* Retrieve pointer to the draw town tile struct */
|
||||||
dcts = &_town_draw_tile_data[house_id << 4 | OriginalTileRandomiser(ti->x, ti->y) << 2 | GetHouseBuildingStage(ti->tile)];
|
dcts = &_town_draw_tile_data[house_id << 4 | TileHash2Bit(ti->x, ti->y) << 2 | GetHouseBuildingStage(ti->tile)];
|
||||||
|
|
||||||
if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, FOUNDATION_LEVELED);
|
if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, FOUNDATION_LEVELED);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user