mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-08 23:19:40 +00:00
(svn r24424) [1.2] -Backport from trunk:
- Fix: Use the 'all vehicles' group for the autoreplace window from the vehicle list [FS#5239] (r24392) - Fix: Do not consider not finding a particular base set critical; just load a different one and display an in-game error later on [FS#5233] (r24388) - Fix: Make IsInDepot() functions behave consistent across vehicle types and add IsChainInDepot instead, if that is what shall be checked [FS#5188] (r24384) - Fix: Call Vehicle::IsStoppedInDepot only for the first vehicle in a chain (i.e. primary vehicle or free wagon) (r24382) - Fix: Do not resize the object GUI when selecting objects. Rather clip the object name (r24379)
This commit is contained in:
parent
b704037039
commit
d726d793ed
@ -77,7 +77,13 @@ struct Aircraft FINAL : public SpecializedVehicle<Aircraft, VEH_AIRCRAFT> {
|
|||||||
int GetDisplayMaxSpeed() const { return this->vcache.cached_max_speed; }
|
int GetDisplayMaxSpeed() const { return this->vcache.cached_max_speed; }
|
||||||
int GetSpeedOldUnits() const { return this->vcache.cached_max_speed * 10 / 128; }
|
int GetSpeedOldUnits() const { return this->vcache.cached_max_speed * 10 / 128; }
|
||||||
Money GetRunningCost() const;
|
Money GetRunningCost() const;
|
||||||
bool IsInDepot() const { return (this->vehstatus & VS_HIDDEN) != 0 && IsHangarTile(this->tile); }
|
|
||||||
|
bool IsInDepot() const
|
||||||
|
{
|
||||||
|
assert(this->IsPrimaryVehicle());
|
||||||
|
return (this->vehstatus & VS_HIDDEN) != 0 && IsHangarTile(this->tile);
|
||||||
|
}
|
||||||
|
|
||||||
bool Tick();
|
bool Tick();
|
||||||
void OnNewDay();
|
void OnNewDay();
|
||||||
uint Crash(bool flooded = false);
|
uint Crash(bool flooded = false);
|
||||||
|
@ -365,7 +365,7 @@ bool Aircraft::FindClosestDepot(TileIndex *location, DestinationID *destination,
|
|||||||
static void CheckIfAircraftNeedsService(Aircraft *v)
|
static void CheckIfAircraftNeedsService(Aircraft *v)
|
||||||
{
|
{
|
||||||
if (Company::Get(v->owner)->settings.vehicle.servint_aircraft == 0 || !v->NeedsAutomaticServicing()) return;
|
if (Company::Get(v->owner)->settings.vehicle.servint_aircraft == 0 || !v->NeedsAutomaticServicing()) return;
|
||||||
if (v->IsInDepot()) {
|
if (v->IsChainInDepot()) {
|
||||||
VehicleServiceInDepot(v);
|
VehicleServiceInDepot(v);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -662,7 +662,7 @@ CommandCost CmdAutoreplaceVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1
|
|||||||
CommandCost ret = CheckOwnership(v->owner);
|
CommandCost ret = CheckOwnership(v->owner);
|
||||||
if (ret.Failed()) return ret;
|
if (ret.Failed()) return ret;
|
||||||
|
|
||||||
if (!v->IsInDepot()) return CMD_ERROR;
|
if (!v->IsChainInDepot()) return CMD_ERROR;
|
||||||
if (v->vehstatus & VS_CRASHED) return CMD_ERROR;
|
if (v->vehstatus & VS_CRASHED) return CMD_ERROR;
|
||||||
|
|
||||||
bool free_wagon = false;
|
bool free_wagon = false;
|
||||||
@ -699,7 +699,7 @@ CommandCost CmdAutoreplaceVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1
|
|||||||
if (!was_stopped) cost.AddCost(CmdStartStopVehicle(v, true));
|
if (!was_stopped) cost.AddCost(CmdStartStopVehicle(v, true));
|
||||||
if (cost.Failed()) return cost;
|
if (cost.Failed()) return cost;
|
||||||
|
|
||||||
assert(v->IsStoppedInDepot());
|
assert(free_wagon || v->IsStoppedInDepot());
|
||||||
|
|
||||||
/* We have to construct the new vehicle chain to test whether it is valid.
|
/* We have to construct the new vehicle chain to test whether it is valid.
|
||||||
* Vehicle construction needs random bits, so we have to save the random seeds
|
* Vehicle construction needs random bits, so we have to save the random seeds
|
||||||
|
@ -48,6 +48,8 @@ public:
|
|||||||
void CopyOutDParams();
|
void CopyOutDParams();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void ScheduleErrorMessage(const ErrorMessageData &data);
|
||||||
|
|
||||||
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x = 0, int y = 0, uint textref_stack_size = 0, const uint32 *textref_stack = NULL);
|
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x = 0, int y = 0, uint textref_stack_size = 0, const uint32 *textref_stack = NULL);
|
||||||
void ClearErrorMessages();
|
void ClearErrorMessages();
|
||||||
void ShowFirstError();
|
void ShowFirstError();
|
||||||
|
@ -417,3 +417,13 @@ void ScheduleErrorMessage(ErrorList &datas)
|
|||||||
{
|
{
|
||||||
_error_list.splice(_error_list.end(), datas);
|
_error_list.splice(_error_list.end(), datas);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Schedule an error.
|
||||||
|
* Note: This does not try to display the error now. This is useful if the window system is not yet running.
|
||||||
|
* @param data Error message data; cleared afterwards
|
||||||
|
*/
|
||||||
|
void ScheduleErrorMessage(const ErrorMessageData &data)
|
||||||
|
{
|
||||||
|
_error_list.push_back(data);
|
||||||
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "train.h"
|
#include "train.h"
|
||||||
#include "roadveh.h"
|
#include "roadveh.h"
|
||||||
|
#include "depot_map.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recalculates the cached total power of a vehicle. Should be called when the consist is changed.
|
* Recalculates the cached total power of a vehicle. Should be called when the consist is changed.
|
||||||
@ -164,6 +165,27 @@ int GroundVehicle<T, Type>::GetAcceleration() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the whole vehicle chain is in the depot.
|
||||||
|
* @return true if and only if the whole chain is in the depot.
|
||||||
|
*/
|
||||||
|
template <class T, VehicleType Type>
|
||||||
|
bool GroundVehicle<T, Type>::IsChainInDepot() const
|
||||||
|
{
|
||||||
|
const T *v = this->First();
|
||||||
|
/* Is the front engine stationary in the depot? */
|
||||||
|
assert_compile((int)TRANSPORT_RAIL == (int)VEH_TRAIN);
|
||||||
|
assert_compile((int)TRANSPORT_ROAD == (int)VEH_ROAD);
|
||||||
|
if (!IsDepotTypeTile(v->tile, (TransportType)Type) || v->cur_speed != 0) return false;
|
||||||
|
|
||||||
|
/* Check whether the rest is also already trying to enter the depot. */
|
||||||
|
for (; v != NULL; v = v->Next()) {
|
||||||
|
if (!v->T::IsInDepot() || v->tile != this->tile) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/* Instantiation for Train */
|
/* Instantiation for Train */
|
||||||
template struct GroundVehicle<Train, VEH_TRAIN>;
|
template struct GroundVehicle<Train, VEH_TRAIN>;
|
||||||
/* Instantiation for RoadVehicle */
|
/* Instantiation for RoadVehicle */
|
||||||
|
@ -92,6 +92,7 @@ struct GroundVehicle : public SpecializedVehicle<T, Type> {
|
|||||||
void PowerChanged();
|
void PowerChanged();
|
||||||
void CargoChanged();
|
void CargoChanged();
|
||||||
int GetAcceleration() const;
|
int GetAcceleration() const;
|
||||||
|
bool IsChainInDepot() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common code executed for crashed ground vehicles
|
* Common code executed for crashed ground vehicles
|
||||||
|
@ -1393,6 +1393,9 @@ STR_CONFIG_ERROR_INVALID_GRF_INCOMPATIBLE :incompatible to
|
|||||||
STR_CONFIG_ERROR_INVALID_GRF_UNKNOWN :unknown
|
STR_CONFIG_ERROR_INVALID_GRF_UNKNOWN :unknown
|
||||||
STR_CONFIG_ERROR_INVALID_SAVEGAME_COMPRESSION_LEVEL :{WHITE}... compression level '{RAW_STRING}' is not valid
|
STR_CONFIG_ERROR_INVALID_SAVEGAME_COMPRESSION_LEVEL :{WHITE}... compression level '{RAW_STRING}' is not valid
|
||||||
STR_CONFIG_ERROR_INVALID_SAVEGAME_COMPRESSION_ALGORITHM :{WHITE}... savegame format '{RAW_STRING}' is not available. Reverting to '{RAW_STRING}'
|
STR_CONFIG_ERROR_INVALID_SAVEGAME_COMPRESSION_ALGORITHM :{WHITE}... savegame format '{RAW_STRING}' is not available. Reverting to '{RAW_STRING}'
|
||||||
|
STR_CONFIG_ERROR_INVALID_BASE_GRAPHICS_NOT_FOUND :{WHITE}... ignoring Base Graphics set '{RAW_STRING}': not found
|
||||||
|
STR_CONFIG_ERROR_INVALID_BASE_SOUNDS_NOT_FOUND :{WHITE}... ignoring Base Sounds set '{RAW_STRING}': not found
|
||||||
|
STR_CONFIG_ERROR_INVALID_BASE_MUSIC_NOT_FOUND :{WHITE}... ignoring Base Music set '{RAW_STRING}': not found
|
||||||
|
|
||||||
# Intro window
|
# Intro window
|
||||||
STR_INTRO_CAPTION :{WHITE}OpenTTD {REV}
|
STR_INTRO_CAPTION :{WHITE}OpenTTD {REV}
|
||||||
|
@ -93,6 +93,12 @@ public:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case WID_BO_OBJECT_NAME:
|
||||||
|
case WID_BO_OBJECT_SIZE:
|
||||||
|
/* We do not want the window to resize when selecting objects; better clip texts */
|
||||||
|
size->width = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
case WID_BO_OBJECT_MATRIX: {
|
case WID_BO_OBJECT_MATRIX: {
|
||||||
/* Get the right amount of buttons based on the current spec. */
|
/* Get the right amount of buttons based on the current spec. */
|
||||||
const ObjectSpec *spec = ObjectClass::Get(_selected_object_class, _selected_object_index);
|
const ObjectSpec *spec = ObjectClass::Get(_selected_object_class, _selected_object_index);
|
||||||
|
@ -722,8 +722,14 @@ int ttd_main(int argc, char *argv[])
|
|||||||
|
|
||||||
BaseGraphics::FindSets();
|
BaseGraphics::FindSets();
|
||||||
if (graphics_set == NULL && BaseGraphics::ini_set != NULL) graphics_set = strdup(BaseGraphics::ini_set);
|
if (graphics_set == NULL && BaseGraphics::ini_set != NULL) graphics_set = strdup(BaseGraphics::ini_set);
|
||||||
if (!BaseGraphics::SetSet(graphics_set) && !StrEmpty(graphics_set)) {
|
if (!BaseGraphics::SetSet(graphics_set)) {
|
||||||
usererror("Failed to select requested graphics set '%s'", graphics_set);
|
if (!StrEmpty(graphics_set)) {
|
||||||
|
BaseGraphics::SetSet(NULL);
|
||||||
|
|
||||||
|
ErrorMessageData msg(STR_CONFIG_ERROR, STR_CONFIG_ERROR_INVALID_BASE_GRAPHICS_NOT_FOUND);
|
||||||
|
msg.SetDParamStr(0, graphics_set);
|
||||||
|
ScheduleErrorMessage(msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
free(graphics_set);
|
free(graphics_set);
|
||||||
|
|
||||||
@ -782,18 +788,26 @@ int ttd_main(int argc, char *argv[])
|
|||||||
BaseSounds::FindSets();
|
BaseSounds::FindSets();
|
||||||
if (sounds_set == NULL && BaseSounds::ini_set != NULL) sounds_set = strdup(BaseSounds::ini_set);
|
if (sounds_set == NULL && BaseSounds::ini_set != NULL) sounds_set = strdup(BaseSounds::ini_set);
|
||||||
if (!BaseSounds::SetSet(sounds_set)) {
|
if (!BaseSounds::SetSet(sounds_set)) {
|
||||||
StrEmpty(sounds_set) ?
|
if (StrEmpty(sounds_set) || !BaseSounds::SetSet(NULL)) {
|
||||||
usererror("Failed to find a sounds set. Please acquire a sounds set for OpenTTD. See section 4.1 of readme.txt.") :
|
usererror("Failed to find a sounds set. Please acquire a sounds set for OpenTTD. See section 4.1 of readme.txt.");
|
||||||
usererror("Failed to select requested sounds set '%s'", sounds_set);
|
} else {
|
||||||
|
ErrorMessageData msg(STR_CONFIG_ERROR, STR_CONFIG_ERROR_INVALID_BASE_SOUNDS_NOT_FOUND);
|
||||||
|
msg.SetDParamStr(0, sounds_set);
|
||||||
|
ScheduleErrorMessage(msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
free(sounds_set);
|
free(sounds_set);
|
||||||
|
|
||||||
BaseMusic::FindSets();
|
BaseMusic::FindSets();
|
||||||
if (music_set == NULL && BaseMusic::ini_set != NULL) music_set = strdup(BaseMusic::ini_set);
|
if (music_set == NULL && BaseMusic::ini_set != NULL) music_set = strdup(BaseMusic::ini_set);
|
||||||
if (!BaseMusic::SetSet(music_set)) {
|
if (!BaseMusic::SetSet(music_set)) {
|
||||||
StrEmpty(music_set) ?
|
if (StrEmpty(music_set) || !BaseMusic::SetSet(NULL)) {
|
||||||
usererror("Failed to find a music set. Please acquire a music set for OpenTTD. See section 4.1 of readme.txt.") :
|
usererror("Failed to find a music set. Please acquire a music set for OpenTTD. See section 4.1 of readme.txt.");
|
||||||
usererror("Failed to select requested music set '%s'", music_set);
|
} else {
|
||||||
|
ErrorMessageData msg(STR_CONFIG_ERROR, STR_CONFIG_ERROR_INVALID_BASE_MUSIC_NOT_FOUND);
|
||||||
|
msg.SetDParamStr(0, music_set);
|
||||||
|
ScheduleErrorMessage(msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
free(music_set);
|
free(music_set);
|
||||||
|
|
||||||
|
@ -113,7 +113,6 @@ struct RoadVehicle FINAL : public GroundVehicle<RoadVehicle, VEH_ROAD> {
|
|||||||
Money GetRunningCost() const;
|
Money GetRunningCost() const;
|
||||||
int GetDisplayImageWidth(Point *offset = NULL) const;
|
int GetDisplayImageWidth(Point *offset = NULL) const;
|
||||||
bool IsInDepot() const { return this->state == RVSB_IN_DEPOT; }
|
bool IsInDepot() const { return this->state == RVSB_IN_DEPOT; }
|
||||||
bool IsStoppedInDepot() const;
|
|
||||||
bool Tick();
|
bool Tick();
|
||||||
void OnNewDay();
|
void OnNewDay();
|
||||||
uint Crash(bool flooded = false);
|
uint Crash(bool flooded = false);
|
||||||
|
@ -306,19 +306,6 @@ CommandCost CmdBuildRoadVehicle(TileIndex tile, DoCommandFlag flags, const Engin
|
|||||||
return CommandCost();
|
return CommandCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RoadVehicle::IsStoppedInDepot() const
|
|
||||||
{
|
|
||||||
TileIndex tile = this->tile;
|
|
||||||
|
|
||||||
if (!IsRoadDepotTile(tile)) return false;
|
|
||||||
if (this->IsFrontEngine() && !(this->vehstatus & VS_STOPPED)) return false;
|
|
||||||
|
|
||||||
for (const RoadVehicle *v = this; v != NULL; v = v->Next()) {
|
|
||||||
if (v->state != RVSB_IN_DEPOT || v->tile != tile) return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FindDepotData FindClosestRoadDepot(const RoadVehicle *v, int max_distance)
|
static FindDepotData FindClosestRoadDepot(const RoadVehicle *v, int max_distance)
|
||||||
{
|
{
|
||||||
if (IsRoadDepotTile(v->tile)) return FindDepotData(v->tile, 0);
|
if (IsRoadDepotTile(v->tile)) return FindDepotData(v->tile, 0);
|
||||||
@ -356,6 +343,8 @@ CommandCost CmdTurnRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
|||||||
RoadVehicle *v = RoadVehicle::GetIfValid(p1);
|
RoadVehicle *v = RoadVehicle::GetIfValid(p1);
|
||||||
if (v == NULL) return CMD_ERROR;
|
if (v == NULL) return CMD_ERROR;
|
||||||
|
|
||||||
|
if (!v->IsPrimaryVehicle()) return CMD_ERROR;
|
||||||
|
|
||||||
CommandCost ret = CheckOwnership(v->owner);
|
CommandCost ret = CheckOwnership(v->owner);
|
||||||
if (ret.Failed()) return ret;
|
if (ret.Failed()) return ret;
|
||||||
|
|
||||||
@ -1576,7 +1565,7 @@ static void CheckIfRoadVehNeedsService(RoadVehicle *v)
|
|||||||
{
|
{
|
||||||
/* If we already got a slot at a stop, use that FIRST, and go to a depot later */
|
/* If we already got a slot at a stop, use that FIRST, and go to a depot later */
|
||||||
if (Company::Get(v->owner)->settings.vehicle.servint_roadveh == 0 || !v->NeedsAutomaticServicing()) return;
|
if (Company::Get(v->owner)->settings.vehicle.servint_roadveh == 0 || !v->NeedsAutomaticServicing()) return;
|
||||||
if (v->IsInDepot()) {
|
if (v->IsChainInDepot()) {
|
||||||
VehicleServiceInDepot(v);
|
VehicleServiceInDepot(v);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@
|
|||||||
/* static */ bool ScriptVehicle::IsInDepot(VehicleID vehicle_id)
|
/* static */ bool ScriptVehicle::IsInDepot(VehicleID vehicle_id)
|
||||||
{
|
{
|
||||||
if (!IsValidVehicle(vehicle_id)) return false;
|
if (!IsValidVehicle(vehicle_id)) return false;
|
||||||
return ::Vehicle::Get(vehicle_id)->IsInDepot();
|
return ::Vehicle::Get(vehicle_id)->IsChainInDepot();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ bool ScriptVehicle::IsStoppedInDepot(VehicleID vehicle_id)
|
/* static */ bool ScriptVehicle::IsStoppedInDepot(VehicleID vehicle_id)
|
||||||
|
@ -142,7 +142,7 @@ static const Depot *FindClosestShipDepot(const Vehicle *v, uint max_distance)
|
|||||||
static void CheckIfShipNeedsService(Vehicle *v)
|
static void CheckIfShipNeedsService(Vehicle *v)
|
||||||
{
|
{
|
||||||
if (Company::Get(v->owner)->settings.vehicle.servint_ships == 0 || !v->NeedsAutomaticServicing()) return;
|
if (Company::Get(v->owner)->settings.vehicle.servint_ships == 0 || !v->NeedsAutomaticServicing()) return;
|
||||||
if (v->IsInDepot()) {
|
if (v->IsChainInDepot()) {
|
||||||
VehicleServiceInDepot(v);
|
VehicleServiceInDepot(v);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ static const TileIndexDiffC _ship_leave_depot_offs[] = {
|
|||||||
|
|
||||||
static bool CheckShipLeaveDepot(Ship *v)
|
static bool CheckShipLeaveDepot(Ship *v)
|
||||||
{
|
{
|
||||||
if (!v->IsInDepot()) return false;
|
if (!v->IsChainInDepot()) return false;
|
||||||
|
|
||||||
/* We are leaving a depot, but have to go to the exact same one; re-enter */
|
/* We are leaving a depot, but have to go to the exact same one; re-enter */
|
||||||
if (v->current_order.IsType(OT_GOTO_DEPOT) &&
|
if (v->current_order.IsType(OT_GOTO_DEPOT) &&
|
||||||
|
@ -101,8 +101,7 @@ struct Train FINAL : public GroundVehicle<Train, VEH_TRAIN> {
|
|||||||
int GetDisplayMaxSpeed() const { return this->vcache.cached_max_speed; }
|
int GetDisplayMaxSpeed() const { return this->vcache.cached_max_speed; }
|
||||||
Money GetRunningCost() const;
|
Money GetRunningCost() const;
|
||||||
int GetDisplayImageWidth(Point *offset = NULL) const;
|
int GetDisplayImageWidth(Point *offset = NULL) const;
|
||||||
bool IsInDepot() const;
|
bool IsInDepot() const { return this->track == TRACK_BIT_DEPOT; }
|
||||||
bool IsStoppedInDepot() const;
|
|
||||||
bool Tick();
|
bool Tick();
|
||||||
void OnNewDay();
|
void OnNewDay();
|
||||||
uint Crash(bool flooded = false);
|
uint Crash(bool flooded = false);
|
||||||
|
@ -730,34 +730,6 @@ CommandCost CmdBuildRailVehicle(TileIndex tile, DoCommandFlag flags, const Engin
|
|||||||
return CommandCost();
|
return CommandCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Is the whole consist the in a depot?
|
|
||||||
* @return \c true iff all vehicles of the train are in a depot.
|
|
||||||
*/
|
|
||||||
bool Train::IsInDepot() const
|
|
||||||
{
|
|
||||||
/* Is the front engine stationary in the depot? */
|
|
||||||
if (!IsRailDepotTile(this->tile) || this->cur_speed != 0) return false;
|
|
||||||
|
|
||||||
/* Check whether the rest is also already trying to enter the depot. */
|
|
||||||
for (const Train *v = this; v != NULL; v = v->Next()) {
|
|
||||||
if (v->track != TRACK_BIT_DEPOT || v->tile != this->tile) return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Is the train stopped in a depot?
|
|
||||||
* @return True if the train is stopped in a depot, else false.
|
|
||||||
*/
|
|
||||||
bool Train::IsStoppedInDepot() const
|
|
||||||
{
|
|
||||||
/* Are we stopped? Of course wagons don't really care... */
|
|
||||||
if (this->IsFrontEngine() && !(this->vehstatus & VS_STOPPED)) return false;
|
|
||||||
return this->IsInDepot();
|
|
||||||
}
|
|
||||||
|
|
||||||
static Train *FindGoodVehiclePos(const Train *src)
|
static Train *FindGoodVehiclePos(const Train *src)
|
||||||
{
|
{
|
||||||
EngineID eng = src->engine_type;
|
EngineID eng = src->engine_type;
|
||||||
@ -1932,6 +1904,8 @@ CommandCost CmdForceTrainProceed(TileIndex tile, DoCommandFlag flags, uint32 p1,
|
|||||||
Train *t = Train::GetIfValid(p1);
|
Train *t = Train::GetIfValid(p1);
|
||||||
if (t == NULL) return CMD_ERROR;
|
if (t == NULL) return CMD_ERROR;
|
||||||
|
|
||||||
|
if (!t->IsPrimaryVehicle()) return CMD_ERROR;
|
||||||
|
|
||||||
CommandCost ret = CheckOwnership(t->owner);
|
CommandCost ret = CheckOwnership(t->owner);
|
||||||
if (ret.Failed()) return ret;
|
if (ret.Failed()) return ret;
|
||||||
|
|
||||||
@ -1942,7 +1916,7 @@ CommandCost CmdForceTrainProceed(TileIndex tile, DoCommandFlag flags, uint32 p1,
|
|||||||
* to proceed to the next signal. In the other cases we
|
* to proceed to the next signal. In the other cases we
|
||||||
* would like to pass the signal at danger and run till the
|
* would like to pass the signal at danger and run till the
|
||||||
* next signal we encounter. */
|
* next signal we encounter. */
|
||||||
t->force_proceed = t->force_proceed == TFP_SIGNAL ? TFP_NONE : HasBit(t->flags, VRF_TRAIN_STUCK) || t->IsInDepot() ? TFP_STUCK : TFP_SIGNAL;
|
t->force_proceed = t->force_proceed == TFP_SIGNAL ? TFP_NONE : HasBit(t->flags, VRF_TRAIN_STUCK) || t->IsChainInDepot() ? TFP_STUCK : TFP_SIGNAL;
|
||||||
SetWindowDirty(WC_VEHICLE_VIEW, t->index);
|
SetWindowDirty(WC_VEHICLE_VIEW, t->index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3900,7 +3874,7 @@ bool Train::Tick()
|
|||||||
static void CheckIfTrainNeedsService(Train *v)
|
static void CheckIfTrainNeedsService(Train *v)
|
||||||
{
|
{
|
||||||
if (Company::Get(v->owner)->settings.vehicle.servint_trains == 0 || !v->NeedsAutomaticServicing()) return;
|
if (Company::Get(v->owner)->settings.vehicle.servint_trains == 0 || !v->NeedsAutomaticServicing()) return;
|
||||||
if (v->IsInDepot()) {
|
if (v->IsChainInDepot()) {
|
||||||
VehicleServiceInDepot(v);
|
VehicleServiceInDepot(v);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -410,11 +410,23 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual bool IsInDepot() const { return false; }
|
virtual bool IsInDepot() const { return false; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the whole vehicle chain is in the depot.
|
||||||
|
* @return true if and only if the whole chain is in the depot.
|
||||||
|
*/
|
||||||
|
virtual bool IsChainInDepot() const { return this->IsInDepot(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether the vehicle is in the depot *and* stopped.
|
* Check whether the vehicle is in the depot *and* stopped.
|
||||||
* @return true if and only if the vehicle is in the depot and stopped.
|
* @return true if and only if the vehicle is in the depot and stopped.
|
||||||
*/
|
*/
|
||||||
virtual bool IsStoppedInDepot() const { return this->IsInDepot() && (this->vehstatus & VS_STOPPED) != 0; }
|
bool IsStoppedInDepot() const
|
||||||
|
{
|
||||||
|
assert(this == this->First());
|
||||||
|
/* Free wagons have no VS_STOPPED state */
|
||||||
|
if (this->IsPrimaryVehicle() && !(this->vehstatus & VS_STOPPED)) return false;
|
||||||
|
return this->IsChainInDepot();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls the tick handler of the vehicle
|
* Calls the tick handler of the vehicle
|
||||||
|
@ -601,13 +601,7 @@ CommandCost CmdMassStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32
|
|||||||
|
|
||||||
if (!!(v->vehstatus & VS_STOPPED) != do_start) continue;
|
if (!!(v->vehstatus & VS_STOPPED) != do_start) continue;
|
||||||
|
|
||||||
if (!vehicle_list_window) {
|
if (!vehicle_list_window && !v->IsChainInDepot()) continue;
|
||||||
if (vli.vtype == VEH_TRAIN) {
|
|
||||||
if (!Train::From(v)->IsInDepot()) continue;
|
|
||||||
} else {
|
|
||||||
if (!(v->vehstatus & VS_HIDDEN)) continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Just try and don't care if some vehicle's can't be stopped. */
|
/* Just try and don't care if some vehicle's can't be stopped. */
|
||||||
DoCommand(tile, v->index, 0, flags, CMD_START_STOP_VEHICLE);
|
DoCommand(tile, v->index, 0, flags, CMD_START_STOP_VEHICLE);
|
||||||
@ -679,7 +673,7 @@ CommandCost CmdDepotMassAutoReplace(TileIndex tile, DoCommandFlag flags, uint32
|
|||||||
const Vehicle *v = list[i];
|
const Vehicle *v = list[i];
|
||||||
|
|
||||||
/* Ensure that the vehicle completely in the depot */
|
/* Ensure that the vehicle completely in the depot */
|
||||||
if (!v->IsInDepot()) continue;
|
if (!v->IsChainInDepot()) continue;
|
||||||
|
|
||||||
CommandCost ret = DoCommand(0, v->index, 0, flags, CMD_AUTOREPLACE_VEHICLE);
|
CommandCost ret = DoCommand(0, v->index, 0, flags, CMD_AUTOREPLACE_VEHICLE);
|
||||||
|
|
||||||
@ -991,6 +985,7 @@ CommandCost CmdSendVehicleToDepot(TileIndex tile, DoCommandFlag flags, uint32 p1
|
|||||||
|
|
||||||
Vehicle *v = Vehicle::GetIfValid(GB(p1, 0, 20));
|
Vehicle *v = Vehicle::GetIfValid(GB(p1, 0, 20));
|
||||||
if (v == NULL) return CMD_ERROR;
|
if (v == NULL) return CMD_ERROR;
|
||||||
|
if (!v->IsPrimaryVehicle()) return CMD_ERROR;
|
||||||
|
|
||||||
return v->SendToDepot(flags, (DepotCommand)(p1 & DEPOT_COMMAND_MASK));
|
return v->SendToDepot(flags, (DepotCommand)(p1 & DEPOT_COMMAND_MASK));
|
||||||
}
|
}
|
||||||
|
@ -1292,7 +1292,7 @@ void BaseVehicleListWindow::DrawVehicleListItems(VehicleID selected_vehicle, int
|
|||||||
|
|
||||||
if (show_orderlist) DrawSmallOrderList(v, orderlist_left, orderlist_right, y, v->cur_real_order_index);
|
if (show_orderlist) DrawSmallOrderList(v, orderlist_left, orderlist_right, y, v->cur_real_order_index);
|
||||||
|
|
||||||
if (v->IsInDepot()) {
|
if (v->IsChainInDepot()) {
|
||||||
str = STR_BLUE_COMMA;
|
str = STR_BLUE_COMMA;
|
||||||
} else {
|
} else {
|
||||||
str = (v->age > v->max_age - DAYS_IN_LEAP_YEAR) ? STR_RED_COMMA : STR_BLACK_COMMA;
|
str = (v->age > v->max_age - DAYS_IN_LEAP_YEAR) ? STR_RED_COMMA : STR_BLACK_COMMA;
|
||||||
@ -1544,7 +1544,7 @@ public:
|
|||||||
|
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case ADI_REPLACE: // Replace window
|
case ADI_REPLACE: // Replace window
|
||||||
ShowReplaceGroupVehicleWindow(DEFAULT_GROUP, this->vli.vtype);
|
ShowReplaceGroupVehicleWindow(ALL_GROUP, this->vli.vtype);
|
||||||
break;
|
break;
|
||||||
case ADI_SERVICE: // Send for servicing
|
case ADI_SERVICE: // Send for servicing
|
||||||
case ADI_DEPOT: // Send to Depots
|
case ADI_DEPOT: // Send to Depots
|
||||||
|
Loading…
Reference in New Issue
Block a user