Codechange: Un-bitstuff vehicle/engine commands.
This commit is contained in:
@@ -776,9 +776,7 @@ struct RefitWindow : public Window {
|
||||
StringID GetCapacityString(RefitOption *option) const
|
||||
{
|
||||
assert(_current_company == _local_company);
|
||||
Vehicle *v = Vehicle::Get(this->window_number);
|
||||
CommandCost cost = Command<CMD_REFIT_VEHICLE>::Do(DC_QUERY_COST, v->tile, this->selected_vehicle, option->cargo |
|
||||
option->subtype << 8 | this->num_vehicles << 16 | (int)this->auto_refit << 24, {});
|
||||
CommandCost cost = Command<CMD_REFIT_VEHICLE>::Do(DC_QUERY_COST, this->selected_vehicle, option->cargo, option->subtype, this->auto_refit, false, this->num_vehicles);
|
||||
|
||||
if (cost.Failed()) return INVALID_STRING_ID;
|
||||
|
||||
@@ -1038,7 +1036,7 @@ struct RefitWindow : public Window {
|
||||
|
||||
if (this->order == INVALID_VEH_ORDER_ID) {
|
||||
bool delete_window = this->selected_vehicle == v->index && this->num_vehicles == UINT8_MAX;
|
||||
if (Command<CMD_REFIT_VEHICLE>::Post(GetCmdRefitVehMsg(v), v->tile, this->selected_vehicle, this->cargo->cargo | this->cargo->subtype << 8 | this->num_vehicles << 16, {}) && delete_window) this->Close();
|
||||
if (Command<CMD_REFIT_VEHICLE>::Post(GetCmdRefitVehMsg(v), v->tile, this->selected_vehicle, this->cargo->cargo, this->cargo->subtype, false, false, this->num_vehicles) && delete_window) this->Close();
|
||||
} else {
|
||||
if (Command<CMD_ORDER_REFIT>::Post(v->tile, v->index, this->order, this->cargo->cargo)) this->Close();
|
||||
}
|
||||
@@ -1899,7 +1897,7 @@ public:
|
||||
|
||||
case WID_VL_STOP_ALL:
|
||||
case WID_VL_START_ALL:
|
||||
Command<CMD_MASS_START_STOP>::Post(0, (1 << 1) | (widget == WID_VL_START_ALL ? (1 << 0) : 0), this->window_number, {});
|
||||
Command<CMD_MASS_START_STOP>::Post(0, widget == WID_VL_START_ALL, true, this->vli);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1924,7 +1922,7 @@ public:
|
||||
break;
|
||||
case ADI_SERVICE: // Send for servicing
|
||||
case ADI_DEPOT: // Send to Depots
|
||||
Command<CMD_SEND_VEHICLE_TO_DEPOT>::Post(GetCmdSendToDepotMsg(this->vli.vtype), 0, DEPOT_MASS_SEND | (index == ADI_SERVICE ? DEPOT_SERVICE : (DepotCommand)0), this->window_number, {});
|
||||
Command<CMD_SEND_VEHICLE_TO_DEPOT>::Post(GetCmdSendToDepotMsg(this->vli.vtype), 0, DepotCommand::MassSend | (index == ADI_SERVICE ? DepotCommand::Service : DepotCommand::None), this->vli);
|
||||
break;
|
||||
|
||||
default: NOT_REACHED();
|
||||
@@ -2427,7 +2425,7 @@ struct VehicleDetailsWindow : Window {
|
||||
mod = GetServiceIntervalClamped(mod + v->GetServiceInterval(), v->ServiceIntervalIsPercent());
|
||||
if (mod == v->GetServiceInterval()) return;
|
||||
|
||||
Command<CMD_CHANGE_SERVICE_INT>::Post(STR_ERROR_CAN_T_CHANGE_SERVICING, v->tile, v->index, mod | (1 << 16) | (v->ServiceIntervalIsPercent() << 17), {});
|
||||
Command<CMD_CHANGE_SERVICE_INT>::Post(STR_ERROR_CAN_T_CHANGE_SERVICING, v->index, mod, true, v->ServiceIntervalIsPercent());
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2463,7 +2461,7 @@ struct VehicleDetailsWindow : Window {
|
||||
bool iscustom = index != 0;
|
||||
bool ispercent = iscustom ? (index == 2) : Company::Get(v->owner)->settings.vehicle.servint_ispercent;
|
||||
uint16 interval = GetServiceIntervalClamped(v->GetServiceInterval(), ispercent);
|
||||
Command<CMD_CHANGE_SERVICE_INT>::Post(STR_ERROR_CAN_T_CHANGE_SERVICING, v->tile, v->index, interval | (iscustom << 16) | (ispercent << 17), {});
|
||||
Command<CMD_CHANGE_SERVICE_INT>::Post(STR_ERROR_CAN_T_CHANGE_SERVICING, v->index, interval, iscustom, ispercent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2628,8 +2626,8 @@ void CcStartStopVehicle(Commands cmd, const CommandCost &result, TileIndex tile,
|
||||
{
|
||||
if (result.Failed()) return;
|
||||
|
||||
auto [tile_, p1, p2, text] = EndianBufferReader::ToValue<CommandTraits<CMD_START_STOP_VEHICLE>::Args>(data);
|
||||
const Vehicle *v = Vehicle::GetIfValid(p1);
|
||||
VehicleID veh_id = std::get<0>(EndianBufferReader::ToValue<CommandTraits<CMD_START_STOP_VEHICLE>::Args>(data));
|
||||
const Vehicle *v = Vehicle::GetIfValid(veh_id);
|
||||
if (v == nullptr || !v->IsPrimaryVehicle() || v->owner != _local_company) return;
|
||||
|
||||
StringID msg = (v->vehstatus & VS_STOPPED) ? STR_VEHICLE_COMMAND_STOPPED : STR_VEHICLE_COMMAND_STARTED;
|
||||
@@ -2645,7 +2643,7 @@ void CcStartStopVehicle(Commands cmd, const CommandCost &result, TileIndex tile,
|
||||
void StartStopVehicle(const Vehicle *v, bool texteffect)
|
||||
{
|
||||
assert(v->IsPrimaryVehicle());
|
||||
Command<CMD_START_STOP_VEHICLE>::Post(_vehicle_msg_translation_table[VCT_CMD_START_STOP][v->type], texteffect ? CcStartStopVehicle : nullptr, v->tile, v->index, 0, {});
|
||||
Command<CMD_START_STOP_VEHICLE>::Post(_vehicle_msg_translation_table[VCT_CMD_START_STOP][v->type], texteffect ? CcStartStopVehicle : nullptr, v->tile, v->index, false);
|
||||
}
|
||||
|
||||
/** Checks whether the vehicle may be refitted at the moment.*/
|
||||
@@ -2969,7 +2967,7 @@ public:
|
||||
break;
|
||||
|
||||
case WID_VV_GOTO_DEPOT: // goto hangar
|
||||
Command<CMD_SEND_VEHICLE_TO_DEPOT>::Post(GetCmdSendToDepotMsg(v), v->tile, v->index | (_ctrl_pressed ? DEPOT_SERVICE : 0U), 0, {});
|
||||
Command<CMD_SEND_VEHICLE_TO_DEPOT>::Post(GetCmdSendToDepotMsg(v), v->index, _ctrl_pressed ? DepotCommand::Service : DepotCommand::None, {});
|
||||
break;
|
||||
case WID_VV_REFIT: // refit
|
||||
ShowVehicleRefitWindow(v, INVALID_VEH_ORDER_ID, this);
|
||||
@@ -2995,19 +2993,19 @@ public:
|
||||
* most likely already open, but is also visible in the vehicle viewport. */
|
||||
Command<CMD_CLONE_VEHICLE>::Post(_vehicle_msg_translation_table[VCT_CMD_CLONE_VEH][v->type],
|
||||
_ctrl_pressed ? nullptr : CcCloneVehicle,
|
||||
v->tile, v->index, _ctrl_pressed ? 1 : 0, {});
|
||||
v->tile, v->index, _ctrl_pressed);
|
||||
break;
|
||||
case WID_VV_TURN_AROUND: // turn around
|
||||
assert(v->IsGroundVehicle());
|
||||
if (v->type == VEH_ROAD) {
|
||||
Command<CMD_TURN_ROADVEH>::Post(_vehicle_msg_translation_table[VCT_CMD_TURN_AROUND][v->type], v->tile, v->index, 0, {});
|
||||
Command<CMD_TURN_ROADVEH>::Post(_vehicle_msg_translation_table[VCT_CMD_TURN_AROUND][v->type], v->tile, v->index);
|
||||
} else {
|
||||
Command<CMD_REVERSE_TRAIN_DIRECTION>::Post(_vehicle_msg_translation_table[VCT_CMD_TURN_AROUND][v->type], v->tile, v->index, 0, {});
|
||||
Command<CMD_REVERSE_TRAIN_DIRECTION>::Post(_vehicle_msg_translation_table[VCT_CMD_TURN_AROUND][v->type], v->tile, v->index, false);
|
||||
}
|
||||
break;
|
||||
case WID_VV_FORCE_PROCEED: // force proceed
|
||||
assert(v->type == VEH_TRAIN);
|
||||
Command<CMD_FORCE_TRAIN_PROCEED>::Post(STR_ERROR_CAN_T_MAKE_TRAIN_PASS_SIGNAL, v->tile, v->index, 0, {});
|
||||
Command<CMD_FORCE_TRAIN_PROCEED>::Post(STR_ERROR_CAN_T_MAKE_TRAIN_PASS_SIGNAL, v->tile, v->index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -3016,7 +3014,7 @@ public:
|
||||
{
|
||||
if (str == nullptr) return;
|
||||
|
||||
Command<CMD_RENAME_VEHICLE>::Post(STR_ERROR_CAN_T_RENAME_TRAIN + Vehicle::Get(this->window_number)->type, 0, this->window_number, 0, str);
|
||||
Command<CMD_RENAME_VEHICLE>::Post(STR_ERROR_CAN_T_RENAME_TRAIN + Vehicle::Get(this->window_number)->type, this->window_number, str);
|
||||
}
|
||||
|
||||
void OnMouseOver(Point pt, int widget) override
|
||||
|
Reference in New Issue
Block a user