summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2004-11-22 10:09:37 +0000
committertron <tron@openttd.org>2004-11-22 10:09:37 +0000
commit40a04816a42a0ec9389c4bd2ede5fcd908979f96 (patch)
treecf78bff2b6e0aee96ff59230b140e43027cc55c8
parent6d817709854d94fa5655c976e54336404c01ff7c (diff)
downloadopenttd-40a04816a42a0ec9389c4bd2ede5fcd908979f96.tar.xz
(svn r756) Demystify and explain some piece of code regarding which house sprite to draw
-rw-r--r--town_cmd.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/town_cmd.c b/town_cmd.c
index 7bd9b6301..7174d454c 100644
--- a/town_cmd.c
+++ b/town_cmd.c
@@ -52,12 +52,16 @@ static void DrawTile_Town(TileInfo *ti)
/* Retrieve pointer to the draw town tile struct */
{
- uint hash, t;
- hash = ti->x >> 4;
- hash ^= hash>>2;
- hash ^= (t=(ti->y >> 4));
- hash -= t>>2;
- dcts = &_town_draw_tile_data[((_map2[ti->tile]<<4)|(_map3_lo[ti->tile]>>6)|((hash&3)<<2))];
+ /* this "randomizes" on the (up to) 4 variants of a building */
+ byte gfx = _map2[ti->tile];
+ byte stage = _map3_lo[ti->tile] >> 6;
+ uint variant;
+ variant = ti->x >> 4;
+ variant ^= ti->x >> 6;
+ variant ^= ti->y >> 4;
+ variant -= ti->y >> 6;
+ variant &= 3;
+ dcts = &_town_draw_tile_data[gfx << 4 | variant << 2 | stage];
}
z = ti->z;