mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r21263) -Fix [FS#3935]: under some circumstances two vehicles could leave a non-drive through road stop at once
This commit is contained in:
parent
f80af8f8c8
commit
097880c5e2
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -1055,34 +1055,43 @@ static const RoadDriveEntry * const _road_road_drive_data[] = {
|
|||
_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,
|
||||
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_ne_far,
|
||||
_rv_station_right_se_far,
|
||||
_rv_station_right_ne_near,
|
||||
_rv_station_right_se_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,
|
||||
};
|
||||
|
||||
/** 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[] = {
|
||||
|
|
Loading…
Reference in New Issue