diff options
author | Peter Nelson <peter1138@openttd.org> | 2019-01-31 20:54:15 +0000 |
---|---|---|
committer | PeterN <peter@fuzzle.org> | 2019-02-04 00:19:48 +0000 |
commit | 33e3f4916173b4129cbbe60f94dae659a70edb83 (patch) | |
tree | 2384acf24eafd4fa75910401c58e859926c1bb4c /src/ship_cmd.cpp | |
parent | 0749a291c4941511744e82a315ee34d96e053fb1 (diff) | |
download | openttd-33e3f4916173b4129cbbe60f94dae659a70edb83.tar.xz |
Fix #7119: When rotating a ship, apply an additional offset to avoid movement glitch.
Diffstat (limited to 'src/ship_cmd.cpp')
-rw-r--r-- | src/ship_cmd.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index b357fa64c..5d3a28b1b 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -319,6 +319,15 @@ void Ship::UpdateDeltaXY() this->x_extent = bb[1]; this->y_extent = bb[0]; this->z_extent = 6; + + if (this->direction != this->rotation) { + /* If we are rotating, then it is possible the ship was moved to its next position. In that + * case, because we are still showing the old direction, the ship will appear to glitch sideways + * slightly. We can work around this by applying an additional offset to make the ship appear + * where it was before it moved. */ + this->x_offs -= this->x_pos - this->rotation_x_pos; + this->y_offs -= this->y_pos - this->rotation_y_pos; + } } /** @@ -678,6 +687,9 @@ static void ShipController(Ship *v) /* Stop for rotation */ v->cur_speed = 0; v->direction = new_direction; + /* Remember our current location to avoid movement glitch */ + v->rotation_x_pos = v->x_pos; + v->rotation_y_pos = v->y_pos; break; } } @@ -704,6 +716,9 @@ getout: reverse_direction: v->direction = ReverseDir(v->direction); + /* Remember our current location to avoid movement glitch */ + v->rotation_x_pos = v->x_pos; + v->rotation_y_pos = v->y_pos; v->cur_speed = 0; v->path.clear(); goto getout; |