Better handle out of track and depot through load cases

Add advice messages for when loading is aborted due to out of track/depot
Handle non-aligned use of platform
Fix full-load behaviour
Fix speed limiting whilst advancing
This commit is contained in:
Jonathan G Rennison
2018-03-29 19:16:44 +01:00
parent 7aab49e282
commit 2821599f6b
7 changed files with 158 additions and 15 deletions

View File

@@ -38,6 +38,7 @@
#include "programmable_signals.h"
#include "spritecache.h"
#include "core/container_func.hpp"
#include "news_func.h"
#include "table/strings.h"
#include "table/railtypes.h"
@@ -3180,10 +3181,28 @@ static VehicleEnterTileStatus VehicleEnter_Track(Vehicle *u, TileIndex tile, int
/* this routine applies only to trains in depot tiles */
if (u->type != VEH_TRAIN || !IsRailDepotTile(tile)) return VETSB_CONTINUE;
if (u->current_order.IsType(OT_LOADING_ADVANCE)) u->LeaveStation();
Train *v = Train::From(u);
auto abort_load_through = [&](bool leave_station) {
if (_local_company == v->owner) {
SetDParam(0, v->index);
SetDParam(1, v->current_order.GetDestination());
AddNewsItem(STR_VEHICLE_LOAD_THROUGH_ABORTED_DEPOT, NT_ADVICE, NF_INCOLOUR | NF_SMALL | NF_VEHICLE_PARAM0,
NR_VEHICLE, v->index,
NR_STATION, v->current_order.GetDestination());
}
if (leave_station) {
v->LeaveStation();
/* Only advance to next order if we are loading at the current one */
const Order *order = v->GetOrder(v->cur_implicit_order_index);
if (order != NULL && order->IsType(OT_GOTO_STATION) && order->GetDestination() == v->last_station_visited) {
v->IncrementImplicitOrderIndex();
}
}
};
if (v->IsFrontEngine() && v->current_order.IsType(OT_LOADING_ADVANCE)) abort_load_through(true);
/* depot direction */
DiagDirection dir = GetRailDepotDirection(tile);
@@ -3204,6 +3223,13 @@ static VehicleEnterTileStatus VehicleEnter_Track(Vehicle *u, TileIndex tile, int
} else if (_fractcoords_enter[dir] == fract_coord) {
if (DiagDirToDir(ReverseDiagDir(dir)) == v->direction) {
/* enter the depot */
if (v->IsFrontEngine() && v->current_order.IsType(OT_LOADING_ADVANCE)) {
abort_load_through(true);
} else if (v->IsFrontEngine() && HasBit(v->flags, VRF_BEYOND_PLATFORM_END)) {
abort_load_through(false);
}
v->track = TRACK_BIT_DEPOT,
v->vehstatus |= VS_HIDDEN; // hide it
v->direction = ReverseDir(v->direction);