summaryrefslogtreecommitdiff
path: root/src/saveload
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2013-12-22 11:55:07 +0000
committerfrosch <frosch@openttd.org>2013-12-22 11:55:07 +0000
commitb02179bd8e269f8373a32980438f0eb9d61f5a62 (patch)
treeb6adbb95c8a308ab6f968f87eac3dce5e7f84f40 /src/saveload
parentb3f08fb67af74ca6e667db8c05ae04f6f5acd28e (diff)
downloadopenttd-b02179bd8e269f8373a32980438f0eb9d61f5a62.tar.xz
(svn r26169) -Fix-ish [FS#5831-ish]: Unify the time a RV needs to travel through a curve.
Diffstat (limited to 'src/saveload')
-rw-r--r--src/saveload/afterload.cpp58
-rw-r--r--src/saveload/saveload.cpp3
2 files changed, 60 insertions, 1 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index a3830a76b..82c13e3f6 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -2832,6 +2832,64 @@ bool AfterLoadGame()
}
}
+ if (IsSavegameVersionBefore(188)) {
+ /* Fix articulated road vehicles.
+ * Some curves were shorter than other curves.
+ * Now they have the same length, but that means that trailing articulated parts will
+ * take longer to go through the curve than the parts in front which already left the courve.
+ * So, make articulated parts catch up. */
+ RoadVehicle *v;
+ bool roadside = _settings_game.vehicle.road_side == 1;
+ SmallVector<uint, 16> skip_frames;
+ FOR_ALL_ROADVEHICLES(v) {
+ if (!v->IsFrontEngine()) continue;
+ skip_frames.Clear();
+ TileIndex prev_tile = v->tile;
+ uint prev_tile_skip = 0;
+ uint cur_skip = 0;
+ for (RoadVehicle *u = v; u != NULL; u = u->Next()) {
+ if (u->tile != prev_tile) {
+ prev_tile_skip = cur_skip;
+ prev_tile = u->tile;
+ } else {
+ cur_skip = prev_tile_skip;
+ }
+
+ uint *this_skip = skip_frames.Append();
+ *this_skip = prev_tile_skip;
+
+ /* The following 3 curves now take longer than before */
+ switch (u->state) {
+ case 2:
+ cur_skip++;
+ if (u->frame <= (roadside ? 9 : 5)) *this_skip = cur_skip;
+ break;
+
+ case 4:
+ cur_skip++;
+ if (u->frame <= (roadside ? 5 : 9)) *this_skip = cur_skip;
+ break;
+
+ case 5:
+ cur_skip++;
+ if (u->frame <= (roadside ? 4 : 2)) *this_skip = cur_skip;
+ break;
+
+ default:
+ break;
+ }
+ }
+ while (cur_skip > skip_frames[0]) {
+ RoadVehicle *u = v;
+ RoadVehicle *prev = NULL;
+ for (uint *it = skip_frames.Begin(); it != skip_frames.End(); ++it, prev = u, u = u->Next()) {
+ extern bool IndividualRoadVehicleController(RoadVehicle *v, const RoadVehicle *prev);
+ if (*it >= cur_skip) IndividualRoadVehicleController(u, prev);
+ }
+ cur_skip--;
+ }
+ }
+ }
/* Station acceptance is some kind of cache */
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index 8bcf57119..d58fbc7ed 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -253,8 +253,9 @@
* 185 25620
* 186 25833
* 187 25899
+ * 188 26169
*/
-extern const uint16 SAVEGAME_VERSION = 187; ///< Current savegame version of OpenTTD.
+extern const uint16 SAVEGAME_VERSION = 188; ///< Current savegame version of OpenTTD.
SavegameType _savegame_type; ///< type of savegame we are loading