Changeset - r16527:9475ed282143
[Not reviewed]
master
0 5 0
rubidium - 14 years ago 2010-11-20 09:09:57
rubidium@openttd.org
(svn r21263) -Fix [FS#3935]: under some circumstances two vehicles could leave a non-drive through road stop at once
5 files changed with 45 insertions and 27 deletions:
0 comments (0 inline, 0 general)
src/roadveh.h
Show inline comments
 
@@ -42,6 +42,7 @@ enum RoadVehicleStates {
 

	
 
	/* Bit numbers */
 
	RVS_USING_SECOND_BAY         =    1,                      ///< Only used while in a road stop
 
	RVS_ENTERED_STOP             =    2,                      ///< Only set when a vehicle has entered the stop
 
	RVS_DRIVE_SIDE               =    4,                      ///< Only used when retrieving move data
 
	RVS_IN_ROAD_STOP             =    5,                      ///< The vehicle is in a road stop
 
	RVS_IN_DT_ROAD_STOP          =    6,                      ///< The vehicle is in a drive-through road stop
src/roadveh_cmd.cpp
Show inline comments
 
@@ -933,13 +933,6 @@ struct RoadDriveEntry {
 

	
 
#include "table/roadveh_movement.h"
 

	
 
static const byte _road_veh_data_1[] = {
 
	20, 20, 16, 16, 0, 0, 0, 0,
 
	19, 19, 15, 15, 0, 0, 0, 0,
 
	16, 16, 12, 12, 0, 0, 0, 0,
 
	15, 15, 11, 11
 
};
 

	
 
static bool RoadVehLeaveDepot(RoadVehicle *v, bool first)
 
{
 
	/* Don't leave if not all the wagons are in the depot. */
 
@@ -1382,7 +1375,7 @@ again:
 
	 * (the station test and stop type test ensure that other vehicles, using the road stop as
 
	 * a through route, do not stop) */
 
	if (v->IsRoadVehFront() && ((IsInsideMM(v->state, RVSB_IN_ROAD_STOP, RVSB_IN_ROAD_STOP_END) &&
 
			_road_veh_data_1[v->state - RVSB_IN_ROAD_STOP + (_settings_game.vehicle.road_side << RVS_DRIVE_SIDE)] == v->frame) ||
 
			_road_stop_stop_frame[v->state - RVSB_IN_ROAD_STOP + (_settings_game.vehicle.road_side << RVS_DRIVE_SIDE)] == v->frame) ||
 
			(IsInsideMM(v->state, RVSB_IN_DT_ROAD_STOP, RVSB_IN_DT_ROAD_STOP_END) &&
 
			v->current_order.ShouldStopAtStation(v, GetStationIndex(v->tile)) &&
 
			v->owner == GetTileOwner(v->tile) &&
 
@@ -1395,7 +1388,7 @@ again:
 
		/* Vehicle is at the stop position (at a bay) in a road stop.
 
		 * Note, if vehicle is loading/unloading it has already been handled,
 
		 * so if we get here the vehicle has just arrived or is just ready to leave. */
 
		if (!v->current_order.IsType(OT_LEAVESTATION)) {
 
		if (!HasBit(v->state, RVS_ENTERED_STOP)) {
 
			/* Vehicle has arrived at a bay in a road stop */
 

	
 
			if (IsDriveThroughStopTile(v->tile)) {
 
@@ -1412,6 +1405,7 @@ again:
 
			}
 

	
 
			rs->SetEntranceBusy(false);
 
			SetBit(v->state, RVS_ENTERED_STOP);
 

	
 
			v->last_station_visited = st->index;
 

	
 
@@ -1427,7 +1421,7 @@ again:
 
				v->cur_speed = 0;
 
				return false;
 
			}
 
			v->current_order.Free();
 
			if (v->current_order.IsType(OT_LEAVESTATION)) v->current_order.Free();
 
		}
 

	
 
		if (IsStandardRoadStopTile(v->tile)) rs->SetEntranceBusy(true);
src/saveload/afterload.cpp
Show inline comments
 
@@ -2377,6 +2377,19 @@ bool AfterLoadGame()
 
		}
 
	}
 

	
 
	if (CheckSavegameVersion(153)) {
 
		RoadVehicle *rv;
 
		FOR_ALL_ROADVEHICLES(rv) {
 
			bool loading = rv->current_order.IsType(OT_LOADING) || rv->current_order.IsType(OT_LEAVESTATION);
 
			if (HasBit(rv->state, RVS_IN_ROAD_STOP)) {
 
				extern const byte _road_stop_stop_frame[];
 
				SB(rv->state, RVS_ENTERED_STOP, 1, loading || rv->frame > _road_stop_stop_frame[rv->state - RVSB_IN_ROAD_STOP + (_settings_game.vehicle.road_side << RVS_DRIVE_SIDE)]);
 
			} else if (HasBit(rv->state, RVS_IN_DT_ROAD_STOP)) {
 
				SB(rv->state, RVS_ENTERED_STOP, 1, loading || rv->frame > RVC_DRIVE_THROUGH_STOP_FRAME);
 
			}
 
		}
 
	}
 

	
 
	/* Road stops is 'only' updating some caches */
 
	AfterLoadRoadStops();
 
	AfterLoadLabelMaps();
src/saveload/saveload.cpp
Show inline comments
 
@@ -215,8 +215,9 @@
 
 *  150   20857
 
 *  151   20918
 
 *  152   21171
 
 *  153   21263
 
 */
 
extern const uint16 SAVEGAME_VERSION = 152; ///< Current savegame version of OpenTTD.
 
extern const uint16 SAVEGAME_VERSION = 153; ///< Current savegame version of OpenTTD.
 

	
 
SavegameType _savegame_type; ///< type of savegame we are loading
 

	
src/table/roadveh_movement.h
Show inline comments
 
@@ -1055,34 +1055,43 @@ static const RoadDriveEntry * const _roa
 
	_rv_station_left_nw_far,
 
	_rv_station_left_sw_near,
 
	_rv_station_left_nw_near,
 
	NULL,
 
	NULL,
 
	NULL,
 
	NULL,
 
	_rv_station_left_sw_far,
 
	_rv_station_left_nw_far,
 
	_rv_station_left_sw_near,
 
	_rv_station_left_nw_near,
 
	_rv_station_left_ne_far,
 
	_rv_station_left_se_far,
 
	_rv_station_left_ne_near,
 
	_rv_station_left_se_near,
 
	_rv_station_left_ne_far,
 
	_rv_station_left_se_far,
 
	_rv_station_left_ne_near,
 
	_rv_station_left_se_near,
 
	NULL,
 
	NULL,
 
	NULL,
 
	NULL,
 
	_rv_station_right_sw_far,
 
	_rv_station_right_nw_far,
 
	_rv_station_right_sw_near,
 
	_rv_station_right_nw_near,
 
	_rv_station_right_sw_far,
 
	_rv_station_right_nw_far,
 
	_rv_station_right_sw_near,
 
	_rv_station_right_nw_near,
 
	NULL,
 
	NULL,
 
	NULL,
 
	NULL,
 
	_rv_station_right_ne_far,
 
	_rv_station_right_se_far,
 
	_rv_station_right_ne_near,
 
	_rv_station_right_se_near,
 
	_rv_station_right_ne_far,
 
	_rv_station_right_se_far,
 
	_rv_station_right_ne_near,
 
	_rv_station_right_se_near,
 
	NULL,
 
	NULL,
 
	NULL,
 
	NULL,
 
};
 

	
 
/** Table of road stop stop frames, when to stop at a road stop. */
 
extern const byte _road_stop_stop_frame[] = {
 
	/* Duplicated left and right because of "entered stop" bit */
 
	20, 20, 16, 16,  20, 20, 16, 16,
 
	19, 19, 15, 15,  19, 19, 15, 15,
 
	16, 16, 12, 12,  16, 16, 12, 12,
 
	15, 15, 11, 11,  15, 15, 11, 11
 
};
 

	
 
static const RoadDriveEntry _roadveh_tram_turn_ne_0[] = {
0 comments (0 inline, 0 general)