|
@@ -203,25 +203,25 @@ int32 CmdBuildRoadVeh(TileIndex tile, ui
|
|
|
}
|
|
|
|
|
|
/** Start/Stop a road vehicle.
|
|
|
* @param tile unused
|
|
|
* @param p1 road vehicle ID to start/stop
|
|
|
* @param p2 unused
|
|
|
*/
|
|
|
int32 CmdStartStopRoadVeh(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_Road || !CheckOwnership(v->owner)) return CMD_ERROR;
|
|
|
|
|
|
/* Check if this road veh can be started/stopped. The callback will fail or
|
|
|
* return 0xFF if it can. */
|
|
|
callback = GetVehicleCallback(CBID_VEHICLE_START_STOP_CHECK, 0, 0, v->engine_type, v);
|
|
|
if (callback != CALLBACK_FAILED && callback != 0xFF) {
|
|
|
StringID error = GetGRFStringID(GetEngineGRFID(v->engine_type), 0xD000 + callback);
|
|
|
return_cmd_error(error);
|
|
|
}
|
|
@@ -253,25 +253,25 @@ void ClearSlot(Vehicle *v)
|
|
|
DEBUG(ms, 3) ("Multistop: Clearing slot at 0x%X", rs->xy);
|
|
|
}
|
|
|
|
|
|
/** Sell a road vehicle.
|
|
|
* @param tile unused
|
|
|
* @param p1 vehicle ID to be sold
|
|
|
* @param p2 unused
|
|
|
*/
|
|
|
int32 CmdSellRoadVeh(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_Road || !CheckOwnership(v->owner)) return CMD_ERROR;
|
|
|
|
|
|
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
|
|
|
|
|
|
if (!IsRoadVehInDepotStopped(v)) {
|
|
|
return_cmd_error(STR_9013_MUST_BE_STOPPED_INSIDE);
|
|
|
}
|
|
|
|
|
|
if (flags & DC_EXEC) {
|
|
@@ -355,25 +355,25 @@ static const Depot* FindClosestRoadDepot
|
|
|
}
|
|
|
|
|
|
/** Send a road vehicle to the depot.
|
|
|
* @param tile unused
|
|
|
* @param p1 vehicle ID to send to the depot
|
|
|
* @param p2 unused
|
|
|
*/
|
|
|
int32 CmdSendRoadVehToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|
|
{
|
|
|
Vehicle *v;
|
|
|
const Depot *dep;
|
|
|
|
|
|
if (!IsVehicleIndex(p1)) return CMD_ERROR;
|
|
|
if (!IsValidVehicleID(p1)) return CMD_ERROR;
|
|
|
|
|
|
v = GetVehicle(p1);
|
|
|
|
|
|
if (v->type != VEH_Road || !CheckOwnership(v->owner)) return CMD_ERROR;
|
|
|
|
|
|
if (v->vehstatus & VS_CRASHED) return CMD_ERROR;
|
|
|
|
|
|
/* If the current orders are already goto-depot */
|
|
|
if (v->current_order.type == OT_GOTO_DEPOT) {
|
|
|
if (flags & DC_EXEC) {
|
|
|
/* If the orders to 'goto depot' are in the orders list (forced servicing),
|
|
|
* then skip to the next order; effectively cancelling this forced service */
|
|
@@ -402,25 +402,25 @@ int32 CmdSendRoadVehToDepot(TileIndex ti
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
/** Turn a roadvehicle around.
|
|
|
* @param tile unused
|
|
|
* @param p1 vehicle ID to turn
|
|
|
* @param p2 unused
|
|
|
*/
|
|
|
int32 CmdTurnRoadVeh(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_Road || !CheckOwnership(v->owner)) return CMD_ERROR;
|
|
|
|
|
|
if (v->vehstatus & (VS_HIDDEN | VS_STOPPED) ||
|
|
|
v->u.road.crashed_ctr != 0 ||
|
|
|
v->breakdown_ctr != 0 ||
|
|
|
v->u.road.overtaking != 0 ||
|
|
|
v->cur_speed < 5) {
|
|
|
return CMD_ERROR;
|
|
|
}
|
|
@@ -1748,25 +1748,25 @@ void RoadVehiclesYearlyLoop(void)
|
|
|
* @param p2 Bitstuffed elements
|
|
|
* - p2 = (bit 0-7) - the new cargo type to refit to
|
|
|
* - p2 = (bit 8-15) - the new cargo subtype to refit to
|
|
|
*/
|
|
|
int32 CmdRefitRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|
|
{
|
|
|
Vehicle *v;
|
|
|
int32 cost;
|
|
|
CargoID new_cid = GB(p2, 0, 8);
|
|
|
byte new_subtype = GB(p2, 8, 8);
|
|
|
uint16 capacity = CALLBACK_FAILED;
|
|
|
|
|
|
if (!IsVehicleIndex(p1)) return CMD_ERROR;
|
|
|
if (!IsValidVehicleID(p1)) return CMD_ERROR;
|
|
|
|
|
|
v = GetVehicle(p1);
|
|
|
|
|
|
if (v->type != VEH_Road || !CheckOwnership(v->owner)) return CMD_ERROR;
|
|
|
if (!IsRoadVehInDepotStopped(v)) return_cmd_error(STR_9013_MUST_BE_STOPPED_INSIDE);
|
|
|
|
|
|
if (new_cid > NUM_CARGO || !CanRefitTo(v->engine_type, new_cid)) return CMD_ERROR;
|
|
|
|
|
|
SET_EXPENSES_TYPE(EXPENSES_ROADVEH_RUN);
|
|
|
|
|
|
if (HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_REFIT_CAPACITY)) {
|
|
|
/* Back up the cargo type */
|