OpenTTD Source 20241224-master-gf74b0cf984
vehicle_cmd.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
10#ifndef VEHICLE_CMD_H
11#define VEHICLE_CMD_H
12
13#include "command_type.h"
14#include "engine_type.h"
15#include "vehicle_type.h"
16#include "vehiclelist.h"
17#include "vehiclelist_cmd.h"
18#include "cargo_type.h"
19
20std::tuple<CommandCost, VehicleID, uint, uint16_t, CargoArray> CmdBuildVehicle(DoCommandFlag flags, TileIndex tile, EngineID eid, bool use_free_vehicles, CargoID cargo, ClientID client_id);
21CommandCost CmdSellVehicle(DoCommandFlag flags, VehicleID v_id, bool sell_chain, bool backup_order, ClientID client_id);
22std::tuple<CommandCost, uint, uint16_t, CargoArray> CmdRefitVehicle(DoCommandFlag flags, VehicleID veh_id, CargoID new_cid, uint8_t new_subtype, bool auto_refit, bool only_this, uint8_t num_vehicles);
24CommandCost CmdChangeServiceInt(DoCommandFlag flags, VehicleID veh_id, uint16_t serv_int, bool is_custom, bool is_percent);
25CommandCost CmdRenameVehicle(DoCommandFlag flags, VehicleID veh_id, const std::string &text);
26std::tuple<CommandCost, VehicleID> CmdCloneVehicle(DoCommandFlag flags, TileIndex tile, VehicleID veh_id, bool share_orders);
27CommandCost CmdStartStopVehicle(DoCommandFlag flags, VehicleID veh_id, bool evaluate_startstop_cb);
28CommandCost CmdMassStartStopVehicle(DoCommandFlag flags, TileIndex tile, bool do_start, bool vehicle_list_window, const VehicleListIdentifier &vli);
31
38DEF_CMD_TRAIT(CMD_CLONE_VEHICLE, CmdCloneVehicle, CMD_NO_TEST, CMDT_VEHICLE_CONSTRUCTION) // NewGRF callbacks influence building and refitting making it impossible to correctly estimate the cost
43
44void CcBuildPrimaryVehicle(Commands cmd, const CommandCost &result, VehicleID new_veh_id, uint, uint16_t, CargoArray);
45void CcStartStopVehicle(Commands cmd, const CommandCost &result, VehicleID veh_id, bool);
46
47template <typename Tcont, typename Titer>
48inline EndianBufferWriter<Tcont, Titer> &operator <<(EndianBufferWriter<Tcont, Titer> &buffer, const CargoArray &cargo_array)
49{
50 for (const uint &amt : cargo_array) {
51 buffer << amt;
52 }
53 return buffer;
54}
55
56inline EndianBufferReader &operator >>(EndianBufferReader &buffer, CargoArray &cargo_array)
57{
58 for (uint &amt : cargo_array) {
59 buffer >> amt;
60 }
61 return buffer;
62}
63
64#endif /* VEHICLE_CMD_H */
Types related to cargoes...
uint8_t CargoID
Cargo slots to indicate a cargo type within a game.
Definition cargo_type.h:22
Common return value for all commands.
Endian-aware buffer adapter that always reads values in little endian order.
Endian-aware buffer adapter that always writes values in little endian order.
Types related to commands.
@ CMDT_VEHICLE_CONSTRUCTION
Construction, modification (incl. refit) and destruction of vehicles.
@ CMDT_VEHICLE_MANAGEMENT
Stopping, starting, sending to depot, turning around, replace orders etc.
@ CMDT_OTHER_MANAGEMENT
Renaming stuff, changing company colours, placing signs, etc.
DoCommandFlag
List of flags for a command.
Commands
List of commands.
@ CMD_MASS_START_STOP
start/stop all vehicles (in a depot)
@ CMD_SELL_VEHICLE
sell a vehicle
@ CMD_CLONE_VEHICLE
clone a vehicle
@ CMD_BUILD_VEHICLE
build a vehicle
@ CMD_DEPOT_SELL_ALL_VEHICLES
sell all vehicles which are in a given depot
@ CMD_REFIT_VEHICLE
refit the cargo space of a vehicle
@ CMD_RENAME_VEHICLE
rename a whole vehicle
@ CMD_DEPOT_MASS_AUTOREPLACE
force the autoreplace to take action in a given depot
@ CMD_SEND_VEHICLE_TO_DEPOT
send a vehicle to a depot
@ CMD_START_STOP_VEHICLE
start or stop a vehicle
@ CMD_CHANGE_SERVICE_INT
change the server interval of a vehicle
@ CMD_LOCATION
the command has implicit location argument.
@ CMD_NO_TEST
the command's output may differ between test and execute due to town rating changes etc.
@ CMD_CLIENT_ID
set p2 with the ClientID of the sending client.
bool do_start
flag for starting playback of next_file at next opportunity
Definition dmusic.cpp:122
Types related to engines.
uint16_t EngineID
Unique identification number of an engine.
Definition engine_type.h:21
ClientID
'Unique' identifier to be given to clients
Class for storing amounts of cargo.
Definition cargo_type.h:114
The information about a vehicle list.
Definition vehiclelist.h:28
CommandCost CmdSendVehicleToDepot(DoCommandFlag flags, VehicleID veh_id, DepotCommand depot_cmd, const VehicleListIdentifier &vli)
Send a vehicle to the depot.
std::tuple< CommandCost, VehicleID > CmdCloneVehicle(DoCommandFlag flags, TileIndex tile, VehicleID veh_id, bool share_orders)
Clone a vehicle.
void CcStartStopVehicle(Commands cmd, const CommandCost &result, VehicleID veh_id, bool)
This is the Callback method after attempting to start/stop a vehicle.
CommandCost CmdSellVehicle(DoCommandFlag flags, VehicleID v_id, bool sell_chain, bool backup_order, ClientID client_id)
Sell a vehicle.
CommandCost CmdRenameVehicle(DoCommandFlag flags, VehicleID veh_id, const std::string &text)
Give a custom name to your vehicle.
std::tuple< CommandCost, VehicleID, uint, uint16_t, CargoArray > CmdBuildVehicle(DoCommandFlag flags, TileIndex tile, EngineID eid, bool use_free_vehicles, CargoID cargo, ClientID client_id)
Build a vehicle.
CommandCost CmdStartStopVehicle(DoCommandFlag flags, VehicleID veh_id, bool evaluate_startstop_cb)
Start/Stop a vehicle.
std::tuple< CommandCost, uint, uint16_t, CargoArray > CmdRefitVehicle(DoCommandFlag flags, VehicleID veh_id, CargoID new_cid, uint8_t new_subtype, bool auto_refit, bool only_this, uint8_t num_vehicles)
Refits a vehicle to the specified cargo type.
void CcBuildPrimaryVehicle(Commands cmd, const CommandCost &result, VehicleID new_veh_id, uint, uint16_t, CargoArray)
This is the Callback method after the construction attempt of a primary vehicle.
CommandCost CmdDepotSellAllVehicles(DoCommandFlag flags, TileIndex tile, VehicleType vehicle_type)
Sells all vehicles in a depot.
CommandCost CmdDepotMassAutoReplace(DoCommandFlag flags, TileIndex tile, VehicleType vehicle_type)
Autoreplace all vehicles in the depot.
CommandCost CmdChangeServiceInt(DoCommandFlag flags, VehicleID veh_id, uint16_t serv_int, bool is_custom, bool is_percent)
Change the service interval of a vehicle.
CommandCost CmdMassStartStopVehicle(DoCommandFlag flags, TileIndex tile, bool do_start, bool vehicle_list_window, const VehicleListIdentifier &vli)
Starts or stops a lot of vehicles.
Types related to vehicles.
VehicleType
Available vehicle types.
uint32_t VehicleID
The type all our vehicle IDs have.
DepotCommand
Flags for goto depot commands.
Functions and type for generating vehicle lists.
Functions and type for serializing vehicle lists.