|
@@ -948,13 +948,13 @@ static void NormaliseTrainConsist(Vehicl
|
|
|
int32 CmdMoveRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|
|
{
|
|
|
VehicleID s = GB(p1, 0, 16);
|
|
|
VehicleID d = GB(p1, 16, 16);
|
|
|
Vehicle *src, *dst, *src_head, *dst_head;
|
|
|
|
|
|
if (!IsVehicleIndex(s)) return CMD_ERROR;
|
|
|
if (!IsValidVehicleID(s)) return CMD_ERROR;
|
|
|
|
|
|
src = GetVehicle(s);
|
|
|
|
|
|
if (src->type != VEH_Train) return CMD_ERROR;
|
|
|
|
|
|
// if nothing is selected as destination, try and find a matching vehicle to drag to.
|
|
@@ -1227,13 +1227,13 @@ int32 CmdMoveRailVehicle(TileIndex tile,
|
|
|
*/
|
|
|
int32 CmdStartStopTrain(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|
|
{
|
|
|
Vehicle *v;
|
|
|
uint16 callback;
|
|
|
|
|
|
if (!IsVehicleIndex(p1)) return CMD_ERROR;
|
|
|
if (!IsValidVehicleID(p1)) return CMD_ERROR;
|
|
|
|
|
|
v = GetVehicle(p1);
|
|
|
|
|
|
if (v->type != VEH_Train || !CheckOwnership(v->owner)) return CMD_ERROR;
|
|
|
|
|
|
/* Check if this train can be started/stopped. The callback will fail or
|
|
@@ -1272,13 +1272,13 @@ int32 CmdStartStopTrain(TileIndex tile,
|
|
|
int32 CmdSellRailWagon(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|
|
{
|
|
|
Vehicle *v, *tmp, *first;
|
|
|
Vehicle *new_f = NULL;
|
|
|
int32 cost = 0;
|
|
|
|
|
|
if (!IsVehicleIndex(p1) || p2 > 2) return CMD_ERROR;
|
|
|
if (!IsValidVehicleID(p1) || p2 > 2) return CMD_ERROR;
|
|
|
|
|
|
v = GetVehicle(p1);
|
|
|
|
|
|
if (v->type != VEH_Train || !CheckOwnership(v->owner)) return CMD_ERROR;
|
|
|
|
|
|
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
|
|
@@ -1668,13 +1668,13 @@ static void ReverseTrainDirection(Vehicl
|
|
|
* @param p2 if true, reverse a unit in a train (needs to be in a depot)
|
|
|
*/
|
|
|
int32 CmdReverseTrainDirection(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|
|
{
|
|
|
Vehicle *v;
|
|
|
|
|
|
if (!IsVehicleIndex(p1)) return CMD_ERROR;
|
|
|
if (!IsValidVehicleID(p1)) return CMD_ERROR;
|
|
|
|
|
|
v = GetVehicle(p1);
|
|
|
|
|
|
if (v->type != VEH_Train || !CheckOwnership(v->owner)) return CMD_ERROR;
|
|
|
|
|
|
if (p2) {
|
|
@@ -1717,13 +1717,13 @@ int32 CmdReverseTrainDirection(TileIndex
|
|
|
* @param p2 unused
|
|
|
*/
|
|
|
int32 CmdForceTrainProceed(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|
|
{
|
|
|
Vehicle *v;
|
|
|
|
|
|
if (!IsVehicleIndex(p1)) return CMD_ERROR;
|
|
|
if (!IsValidVehicleID(p1)) return CMD_ERROR;
|
|
|
|
|
|
v = GetVehicle(p1);
|
|
|
|
|
|
if (v->type != VEH_Train || !CheckOwnership(v->owner)) return CMD_ERROR;
|
|
|
|
|
|
if (flags & DC_EXEC) v->u.rail.force_proceed = 0x50;
|
|
@@ -1743,13 +1743,13 @@ int32 CmdRefitRailVehicle(TileIndex tile
|
|
|
CargoID new_cid = GB(p2, 0, 8);
|
|
|
byte new_subtype = GB(p2, 8, 8);
|
|
|
Vehicle *v;
|
|
|
int32 cost;
|
|
|
uint num;
|
|
|
|
|
|
if (!IsVehicleIndex(p1)) return CMD_ERROR;
|
|
|
if (!IsValidVehicleID(p1)) return CMD_ERROR;
|
|
|
|
|
|
v = GetVehicle(p1);
|
|
|
|
|
|
if (v->type != VEH_Train || !CheckOwnership(v->owner)) return CMD_ERROR;
|
|
|
if (CheckTrainStoppedInDepot(v) < 0) return_cmd_error(STR_TRAIN_MUST_BE_STOPPED);
|
|
|
|
|
@@ -1927,13 +1927,13 @@ static TrainFindDepotData FindClosestTra
|
|
|
*/
|
|
|
int32 CmdSendTrainToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|
|
{
|
|
|
Vehicle *v;
|
|
|
TrainFindDepotData tfdd;
|
|
|
|
|
|
if (!IsVehicleIndex(p1)) return CMD_ERROR;
|
|
|
if (!IsValidVehicleID(p1)) return CMD_ERROR;
|
|
|
|
|
|
v = GetVehicle(p1);
|
|
|
|
|
|
if (v->type != VEH_Train || !CheckOwnership(v->owner)) return CMD_ERROR;
|
|
|
|
|
|
if (v->vehstatus & VS_CRASHED) return CMD_ERROR;
|