Changeset - r14768:ffbec4f9cf48
[Not reviewed]
master
0 1 0
alberth - 14 years ago 2010-03-07 16:10:40
alberth@openttd.org
(svn r19366) -Codechange: Move setting of _error_message from the callback check routine to the caller.
1 file changed with 7 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/vehicle.cpp
Show inline comments
 
@@ -458,13 +458,12 @@ static Vehicle *EnsureNoTrainOnTrackProc
 

	
 
	if (v->type != VEH_TRAIN) return NULL;
 

	
 
	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;
 
}
 

	
 
/**
 
 * Tests if a vehicle interacts with the specified track bits.
 
 * All track bits interact except parallel #TRACK_BIT_HORZ or #TRACK_BIT_VERT.
 
@@ -472,13 +471,19 @@ static Vehicle *EnsureNoTrainOnTrackProc
 
 * @param tile The tile.
 
 * @param track_bits The track bits.
 
 * @return \c true if no train that interacts, is found. \c false if a train is found.
 
 */
 
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)
 
{
 
	Vehicle **old_hash = v->old_new_hash;
 
	Vehicle **new_hash;
0 comments (0 inline, 0 general)