1
0
Fork 0

(svn r24328) -Codechange: Simplify some silly code.

release/1.3
frosch 2012-06-06 14:03:22 +00:00
parent c0e209162a
commit 2eb9795a98
2 changed files with 30 additions and 32 deletions

View File

@ -389,24 +389,23 @@ void RoadVehicle::MarkDirty()
void RoadVehicle::UpdateDeltaXY(Direction direction) void RoadVehicle::UpdateDeltaXY(Direction direction)
{ {
#define MKIT(a, b, c, d) ((a & 0xFF) << 24) | ((b & 0xFF) << 16) | ((c & 0xFF) << 8) | ((d & 0xFF) << 0) static const int8 _delta_xy_table[8][4] = {
static const uint32 _delta_xy_table[8] = { /* y_extent, x_extent, y_offs, x_offs */
MKIT(3, 3, -1, -1), {3, 3, -1, -1}, // N
MKIT(3, 7, -1, -3), {3, 7, -1, -3}, // NE
MKIT(3, 3, -1, -1), {3, 3, -1, -1}, // E
MKIT(7, 3, -3, -1), {7, 3, -3, -1}, // SE
MKIT(3, 3, -1, -1), {3, 3, -1, -1}, // S
MKIT(3, 7, -1, -3), {3, 7, -1, -3}, // SW
MKIT(3, 3, -1, -1), {3, 3, -1, -1}, // W
MKIT(7, 3, -3, -1), {7, 3, -3, -1}, // NW
}; };
#undef MKIT
uint32 x = _delta_xy_table[direction]; const int8 *bb = _delta_xy_table[direction];
this->x_offs = GB(x, 0, 8); this->x_offs = bb[3];
this->y_offs = GB(x, 8, 8); this->y_offs = bb[2];
this->x_extent = GB(x, 16, 8); this->x_extent = bb[1];
this->y_extent = GB(x, 24, 8); this->y_extent = bb[0];
this->z_extent = 6; this->z_extent = 6;
} }

View File

@ -271,24 +271,23 @@ TileIndex Ship::GetOrderStationLocation(StationID station)
void Ship::UpdateDeltaXY(Direction direction) void Ship::UpdateDeltaXY(Direction direction)
{ {
#define MKIT(a, b, c, d) ((a & 0xFF) << 24) | ((b & 0xFF) << 16) | ((c & 0xFF) << 8) | ((d & 0xFF) << 0) static const int8 _delta_xy_table[8][4] = {
static const uint32 _delta_xy_table[8] = { /* y_extent, x_extent, y_offs, x_offs */
MKIT( 6, 6, -3, -3), { 6, 6, -3, -3}, // N
MKIT( 6, 32, -3, -16), { 6, 32, -3, -16}, // NE
MKIT( 6, 6, -3, -3), { 6, 6, -3, -3}, // E
MKIT(32, 6, -16, -3), {32, 6, -16, -3}, // SE
MKIT( 6, 6, -3, -3), { 6, 6, -3, -3}, // S
MKIT( 6, 32, -3, -16), { 6, 32, -3, -16}, // SW
MKIT( 6, 6, -3, -3), { 6, 6, -3, -3}, // W
MKIT(32, 6, -16, -3), {32, 6, -16, -3}, // NW
}; };
#undef MKIT
uint32 x = _delta_xy_table[direction]; const int8 *bb = _delta_xy_table[direction];
this->x_offs = GB(x, 0, 8); this->x_offs = bb[3];
this->y_offs = GB(x, 8, 8); this->y_offs = bb[2];
this->x_extent = GB(x, 16, 8); this->x_extent = bb[1];
this->y_extent = GB(x, 24, 8); this->y_extent = bb[0];
this->z_extent = 6; this->z_extent = 6;
} }