summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrichk <richk@openttd.org>2007-03-18 21:44:00 +0000
committerrichk <richk@openttd.org>2007-03-18 21:44:00 +0000
commitf44cbfe1fe885699d91d86348d6430c976d914cf (patch)
treedb4adfa47ae23b5feb82a89bb42afebf72559d62 /src
parent408442d57572c8b99dacb71f1da9ff1ea3a27326 (diff)
downloadopenttd-f44cbfe1fe885699d91d86348d6430c976d914cf.tar.xz
(svn r9299) -Fix (FS#675,FS#660): Small micro-movements on airports (of <4 pixels) caused odd aircraft movements. On oilrigs, this caused a full crash as movement would take helicopter out of airport/station tile.
Corrected by maneuvering aircraft directly over these tiny movements, rather than relying on movement by changing facing.
Diffstat (limited to 'src')
-rw-r--r--src/aircraft_cmd.cpp39
1 files changed, 29 insertions, 10 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index a022ba47b..b7c3de562 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -1063,19 +1063,38 @@ static bool AircraftController(Vehicle *v)
if (v->load_unload_time_rem != 0) v->load_unload_time_rem--;
do {
- /* Turn. Do it slowly if in the air. */
- Direction newdir = GetDirectionTowards(v, x + amd->x, y + amd->y);
- if (newdir != v->direction) {
- v->direction = newdir;
- if (amd->flag & AMED_SLOWTURN) {
- if (v->load_unload_time_rem == 0) v->load_unload_time_rem = 8;
- } else {
- v->cur_speed >>= 1;
+
+ GetNewVehiclePosResult gp;
+
+ if (dist < 4) {
+ /* move vehicle one pixel towards target */
+ gp.x = (v->x_pos != (x + amd->x)) ?
+ v->x_pos + ((x + amd->x > v->x_pos) ? 1 : -1) :
+ v->x_pos;
+ gp.y = (v->y_pos != (y + amd->y)) ?
+ v->y_pos + ((y + amd->y > v->y_pos) ? 1 : -1) :
+ v->y_pos;
+
+ /* Oilrigs must keep v->tile as st->airport_tile, since the landing pad is in a non-airport tile */
+ gp.new_tile = (st->airport_type == AT_OILRIG) ? st->airport_tile : TileVirtXY(gp.x, gp.y);
+
+ } else {
+
+ /* Turn. Do it slowly if in the air. */
+ Direction newdir = GetDirectionTowards(v, x + amd->x, y + amd->y);
+ if (newdir != v->direction) {
+ v->direction = newdir;
+ if (amd->flag & AMED_SLOWTURN) {
+ if (v->load_unload_time_rem == 0) v->load_unload_time_rem = 8;
+ } else {
+ v->cur_speed >>= 1;
+ }
}
+
+ /* Move vehicle. */
+ gp = GetNewVehiclePos(v);
}
- /* Move vehicle. */
- GetNewVehiclePosResult gp = GetNewVehiclePos(v);
v->tile = gp.new_tile;
/* If vehicle is in the air, use tile coordinate 0. */
// if (amd->flag & (AMED_TAKEOFF | AMED_SLOWTURN | AMED_LAND)) v->tile = 0;