summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2012-06-07 15:41:14 +0000
committerfrosch <frosch@openttd.org>2012-06-07 15:41:14 +0000
commit4c79a065673f4ae19d278ec3e0e4f68190ab330c (patch)
tree79e20081ac76fe4d5c57d131cd98f7271f9c0a61 /src
parent86b013f872b453052948a3a788c200fa827366d5 (diff)
downloadopenttd-4c79a065673f4ae19d278ec3e0e4f68190ab330c.tar.xz
(svn r24331) -Change [FS#5204]: [NewGRF] Make bounding boxes of road vehicles change according to the vehicle length to make alignment easier.
Diffstat (limited to 'src')
-rw-r--r--src/roadveh_cmd.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index bb917da7f..f29efb60a 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -389,23 +389,28 @@ void RoadVehicle::MarkDirty()
void RoadVehicle::UpdateDeltaXY(Direction direction)
{
- static const int8 _delta_xy_table[8][4] = {
- /* y_extent, x_extent, y_offs, x_offs */
- {3, 3, -1, -1}, // N
- {3, 7, -1, -3}, // NE
- {3, 3, -1, -1}, // E
- {7, 3, -3, -1}, // SE
- {3, 3, -1, -1}, // S
- {3, 7, -1, -3}, // SW
- {3, 3, -1, -1}, // W
- {7, 3, -3, -1}, // NW
+ static const int8 _delta_xy_table[8][10] = {
+ /* y_extent, x_extent, y_offs, x_offs, y_bb_offs, x_bb_offs, y_extent_shorten, x_extent_shorten, y_bb_offs_shorten, x_bb_offs_shorten */
+ {3, 3, -1, -1, 0, 0, -1, -1, -1, -1}, // N
+ {3, 7, -1, -3, 0, -1, 0, -1, 0, 0}, // NE
+ {3, 3, -1, -1, 0, 0, 1, -1, 1, -1}, // E
+ {7, 3, -3, -1, -1, 0, 0, 0, 1, 0}, // SE
+ {3, 3, -1, -1, 0, 0, 1, 1, 1, 1}, // S
+ {3, 7, -1, -3, 0, -1, 0, 0, 0, 1}, // SW
+ {3, 3, -1, -1, 0, 0, -1, 1, -1, 1}, // W
+ {7, 3, -3, -1, -1, 0, -1, 0, 0, 0}, // NW
};
+ int shorten = VEHICLE_LENGTH - this->gcache.cached_veh_length;
+ if (!IsDiagonalDirection(direction)) shorten >>= 1;
+
const int8 *bb = _delta_xy_table[direction];
+ this->x_bb_offs = bb[5] + bb[9] * shorten;
+ this->y_bb_offs = bb[4] + bb[8] * shorten;;
this->x_offs = bb[3];
this->y_offs = bb[2];
- this->x_extent = bb[1];
- this->y_extent = bb[0];
+ this->x_extent = bb[1] + bb[7] * shorten;
+ this->y_extent = bb[0] + bb[6] * shorten;
this->z_extent = 6;
}