@@ -39,12 +39,13 @@ enum RoadVehicleStates {
/* Numeric values */
RVSB_IN_DEPOT = 0xFE, ///< The vehicle is in a depot
RVSB_WORMHOLE = 0xFF, ///< The vehicle is in a tunnel and/or bridge
/* 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
/* Bit sets of the above specified bits */
RVSB_IN_ROAD_STOP = 1 << RVS_IN_ROAD_STOP, ///< The vehicle is in a road stop
@@ -930,19 +930,12 @@ found_best_track:;
struct RoadDriveEntry {
byte x, y;
};
#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. */
for (const RoadVehicle *u = v; u != NULL; u = u->Next()) {
if (u->state != RVSB_IN_DEPOT || u->tile != v->tile) return false;
}
@@ -1379,26 +1372,26 @@ again:
/* If the vehicle is in a normal road stop and the frame equals the stop frame OR
* if the vehicle is in a drive-through road stop and this is the destination station
* and it's the correct type of stop (bus or truck) and the frame equals the stop frame...
* (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) &&
GetRoadStopType(v->tile) == (v->IsBus() ? ROADSTOP_BUS : ROADSTOP_TRUCK) &&
v->frame == RVC_DRIVE_THROUGH_STOP_FRAME))) {
RoadStop *rs = RoadStop::GetByTile(v->tile, GetRoadStopType(v->tile));
Station *st = Station::GetByTile(v->tile);
/* 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)) {
TileIndex next_tile = TILE_ADD(v->tile, TileOffsByDir(v->direction));
/* Check if next inline bay is free and has compatible road. */
@@ -1409,12 +1402,13 @@ again:
RoadZPosAffectSpeed(v, v->UpdateInclination(true, false));
return true;
rs->SetEntranceBusy(false);
SetBit(v->state, RVS_ENTERED_STOP);
v->last_station_visited = st->index;
if (IsDriveThroughStopTile(v->tile) || (v->current_order.IsType(OT_GOTO_STATION) && v->current_order.GetDestination() == st->index)) {
RoadVehArrivesAt(v, st);
v->BeginLoading();
@@ -1424,13 +1418,13 @@ again:
/* Vehicle is ready to leave a bay in a road stop */
if (rs->IsEntranceBusy()) {
/* Road stop entrance is busy, so wait as there is nowhere else to go */
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);
StartRoadVehSound(v);
SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
@@ -2374,12 +2374,25 @@ bool AfterLoadGame()
default: NOT_REACHED();
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();
GamelogPrintDebug(1);
@@ -212,14 +212,15 @@
* 147 20621
* 148 20659
* 149 20832
* 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
uint32 _ttdp_version; ///< version of TTDP savegame (if applicable)
uint16 _sl_version; ///< the major savegame version identifier
byte _sl_minor_version; ///< the minor savegame version, DO NOT USE!
@@ -1052,40 +1052,49 @@ static const RoadDriveEntry * const _roa
_roadveh_drive_data_30,
_roadveh_drive_data_31,
_rv_station_left_sw_far,
_rv_station_left_nw_far,
_rv_station_left_sw_near,
_rv_station_left_nw_near,
NULL,
_rv_station_left_ne_far,
_rv_station_left_se_far,
_rv_station_left_ne_near,
_rv_station_left_se_near,
_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,
/** 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[] = {
{15, 5},
{14, 5},
{13, 5},
Status change: