summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2010-03-07 16:10:40 +0000
committeralberth <alberth@openttd.org>2010-03-07 16:10:40 +0000
commit6eac50bc16dd37f4c5f564485a4df3bd04639043 (patch)
treea3968977c2d779ae9d996f10451b5abda7cba673
parent29b79e03e80f0e57f9af5ec4eeedc6de205f201b (diff)
downloadopenttd-6eac50bc16dd37f4c5f564485a4df3bd04639043.tar.xz
(svn r19366) -Codechange: Move setting of _error_message from the callback check routine to the caller.
-rw-r--r--src/vehicle.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 440f59bf8..312813c36 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -461,7 +461,6 @@ static Vehicle *EnsureNoTrainOnTrackProc(Vehicle *v, void *data)
Train *t = Train::From(v);
if ((t->track != rail_bits) && !TracksOverlap(t->track | rail_bits)) return NULL;
- _error_message = STR_ERROR_TRAIN_IN_THE_WAY + v->type;
return v;
}
@@ -475,7 +474,13 @@ static Vehicle *EnsureNoTrainOnTrackProc(Vehicle *v, void *data)
*/
bool EnsureNoTrainOnTrackBits(TileIndex tile, TrackBits track_bits)
{
- return !HasVehicleOnPos(tile, &track_bits, &EnsureNoTrainOnTrackProc);
+ /* Value v is not safe in MP games, however, it is used to generate a local
+ * error message only (which may be different for different machines).
+ * Such a message does not affect MP synchronisation.
+ */
+ Vehicle *v = VehicleFromPos(tile, &track_bits, &EnsureNoTrainOnTrackProc, true);
+ if (v != NULL) _error_message = STR_ERROR_TRAIN_IN_THE_WAY + v->type;
+ return v == NULL;
}
static void UpdateNewVehiclePosHash(Vehicle *v, bool remove)