summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-01-20 22:33:29 +0000
committersmatz <smatz@openttd.org>2009-01-20 22:33:29 +0000
commit15e783afa01b2dd89319f5686e0622100588e181 (patch)
tree0c9f0a4258bc127c05fd9259a6f9f503df26cea0 /src
parentfd7063530c5d089c85e5db35afac089921079768 (diff)
downloadopenttd-15e783afa01b2dd89319f5686e0622100588e181.tar.xz
(svn r15179) -Fix [FS#2560](r12096): removing of leftover level crossings (from very old savegames) failed
Diffstat (limited to 'src')
-rw-r--r--src/saveload/afterload.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index 21d11f97a..39c02f008 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -39,7 +39,6 @@
#include "../unmovable_map.h"
#include "../tree_map.h"
#include "../company_func.h"
-#include "../command_func.h"
#include "../road_cmd.h"
#include "../ai/ai.hpp"
@@ -1452,8 +1451,21 @@ bool AfterLoadGame()
Owner o = GetTileOwner(t);
if (!IsValidCompanyID(o)) {
/* remove leftover rail piece from crossing (from very old savegames) */
- _current_company = o;
- DoCommand(t, 0, GetCrossingRailTrack(t), DC_EXEC | DC_BANKRUPT, CMD_REMOVE_SINGLE_RAIL);
+ Vehicle *v = NULL, *w;
+ FOR_ALL_VEHICLES(w) {
+ if (w->type == VEH_TRAIN && w->tile == t) {
+ v = w;
+ break;
+ }
+ }
+ if (v != NULL) {
+ /* when there is a train on crossing (it could happen in TTD), set owner of crossing to train owner */
+ SetTileOwner(t, v->owner);
+ } else {
+ /* else change the crossing to normal road (road vehicles won't care) */
+ MakeRoadNormal(t, GetCrossingRoadBits(t), GetRoadTypes(t), GetTownIndex(t),
+ GetRoadOwner(t, ROADTYPE_ROAD), GetRoadOwner(t, ROADTYPE_TRAM), GetRoadOwner(t, ROADTYPE_HWAY));
+ }
}
}
}