OpenTTD Source 20261112-master-gbcbec5e63f
network_command.cpp
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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
9
10#include "../stdafx.h"
11#include "network_admin.h"
12#include "network_client.h"
13#include "network_server.h"
14#include "../command_func.h"
15#include "../company_func.h"
16#include "../settings_type.h"
17#include "../airport_cmd.h"
18#include "../aircraft_cmd.h"
19#include "../autoreplace_cmd.h"
20#include "../company_cmd.h"
21#include "../depot_cmd.h"
22#include "../dock_cmd.h"
23#include "../economy_cmd.h"
24#include "../engine_cmd.h"
25#include "../error_func.h"
26#include "../goal_cmd.h"
27#include "../group_cmd.h"
28#include "../industry_cmd.h"
29#include "../landscape_cmd.h"
30#include "../league_cmd.h"
31#include "../misc_cmd.h"
32#include "../news_cmd.h"
33#include "../object_cmd.h"
34#include "../order_cmd.h"
35#include "../rail_cmd.h"
36#include "../road_cmd.h"
37#include "../roadveh_cmd.h"
38#include "../settings_cmd.h"
39#include "../signs_cmd.h"
41#include "../string_func.h"
42#include "../story_cmd.h"
43#include "../subsidy_cmd.h"
44#include "../terraform_cmd.h"
45#include "../timetable_cmd.h"
46#include "../town_cmd.h"
47#include "../train_cmd.h"
48#include "../tree_cmd.h"
49#include "../tunnelbridge_cmd.h"
50#include "../vehicle_cmd.h"
51#include "../viewport_cmd.h"
52#include "../water_cmd.h"
53#include "../waypoint_cmd.h"
55
56#include "../safeguards.h"
57
59static constexpr auto _callback_tuple = std::make_tuple(
60 (CommandCallback *)nullptr, // Make sure this is actually a pointer-to-function.
62 &CcBuildAirport,
64 &CcPlaySound_CONSTRUCTION_WATER,
65 &CcBuildDocks,
66 &CcFoundTown,
67 &CcBuildRoadTunnel,
68 &CcBuildRailTunnel,
70 &CcRoadDepot,
71 &CcRailDepot,
73 &CcPlaySound_EXPLOSION,
74 &CcPlaySound_CONSTRUCTION_OTHER,
75 &CcPlaySound_CONSTRUCTION_RAIL,
76 &CcStation,
77 &CcTerraform,
78 &CcAI,
81 &CcFoundRandomTown,
84 &CcGame,
88);
89
90#ifdef SILENCE_GCC_FUNCTION_POINTER_CAST
91/*
92 * We cast specialized function pointers to a generic one, but don't use the
93 * converted value to call the function, which is safe, except that GCC
94 * helpfully thinks it is not.
95 *
96 * "Any pointer to function can be converted to a pointer to a different function type.
97 * Calling the function through a pointer to a different function type is undefined,
98 * but converting such pointer back to pointer to the original function type yields
99 * the pointer to the original function." */
100# pragma GCC diagnostic push
101# pragma GCC diagnostic ignored "-Wcast-function-type"
102#endif
103
104/* Helpers to generate the callback table from the callback list. */
105
106constexpr size_t _callback_tuple_size = std::tuple_size_v<decltype(_callback_tuple)>;
107
108template <size_t... i>
109inline auto MakeCallbackTable(std::index_sequence<i...>) noexcept
110{
111 return std::array<CommandCallback *, sizeof...(i)>{{ reinterpret_cast<CommandCallback *>(reinterpret_cast<void(*)()>(std::get<i>(_callback_tuple)))... }}; // MingW64 fails linking when casting a pointer to its own type. To work around, cast it to some other type first.
112}
113
115static const auto _callback_table = MakeCallbackTable(std::make_index_sequence<_callback_tuple_size>{});
116
123{
124 return std::ranges::find(_callback_table, callback) != _callback_table.end();
125}
126
127template <typename T> struct CallbackArgsHelper;
128template <typename... Targs>
129struct CallbackArgsHelper<void(*const)(Commands, const CommandCost &, Targs...)> {
130 using Args = std::tuple<std::decay_t<Targs>...>;
131};
132
133
134/* Helpers to generate the command dispatch table from the command traits. */
135
136template <Commands Tcmd> static CommandDataBuffer SanitizeCmdStrings(const CommandDataBuffer &data);
137template <Commands Tcmd, size_t cb> static void UnpackNetworkCommand(const CommandPacket &cp);
138template <Commands Tcmd> static void NetworkReplaceCommandClientId(CommandPacket &cp, ClientID client_id);
139using UnpackNetworkCommandProc = void (*)(const CommandPacket &);
140using UnpackDispatchT = std::array<UnpackNetworkCommandProc, _callback_tuple_size>;
142 CommandDataBuffer(*Sanitize)(const CommandDataBuffer &);
143 void (*ReplaceClientId)(CommandPacket &, ClientID);
144 UnpackDispatchT Unpack;
145};
146
147template <Commands Tcmd, size_t Tcb>
148constexpr UnpackNetworkCommandProc MakeUnpackNetworkCommandCallback() noexcept
149{
150 /* Check if the callback matches with the command arguments. If not, don't generate an Unpack proc. */
151 using Tcallback = std::tuple_element_t<Tcb, decltype(_callback_tuple)>;
152 if constexpr (std::is_same_v<Tcallback, CommandCallback * const> || // Callback type is CommandCallback.
153 std::is_same_v<Tcallback, CommandCallbackData * const> || // Callback type is CommandCallbackData.
154 std::is_same_v<typename CommandTraits<Tcmd>::CbArgs, typename CallbackArgsHelper<Tcallback>::Args> || // Callback proc takes all command return values and parameters.
155 (!std::is_void_v<typename CommandTraits<Tcmd>::RetTypes> && std::is_same_v<typename CallbackArgsHelper<typename CommandTraits<Tcmd>::RetCallbackProc const>::Args, typename CallbackArgsHelper<Tcallback>::Args>)) { // Callback return is more than CommandCost and the proc takes all return values.
157 } else {
158 return nullptr;
159 }
160}
161
162template <Commands Tcmd, size_t... i>
163constexpr UnpackDispatchT MakeUnpackNetworkCommand(std::index_sequence<i...>) noexcept
164{
165 return UnpackDispatchT{{ MakeUnpackNetworkCommandCallback<Tcmd, i>()...}};
166}
167
168template <typename T, T... i, size_t... j>
169constexpr auto MakeDispatchTable(std::integer_sequence<T, i...>, std::index_sequence<j...>) noexcept
170{
171 return EnumIndexArray<CommandDispatch, Commands, static_cast<Commands>(sizeof...(i))>{{{ { &SanitizeCmdStrings<static_cast<Commands>(i)>, &NetworkReplaceCommandClientId<static_cast<Commands>(i)>, MakeUnpackNetworkCommand<static_cast<Commands>(i)>(std::make_index_sequence<_callback_tuple_size>{}) }... }}};
172}
174static constexpr auto _cmd_dispatch = MakeDispatchTable(std::make_integer_sequence<std::underlying_type_t<Commands>, to_underlying(Commands::End)>{}, std::make_index_sequence<_callback_tuple_size>{});
175
176#ifdef SILENCE_GCC_FUNCTION_POINTER_CAST
177# pragma GCC diagnostic pop
178#endif
179
184
185
191static size_t FindCallbackIndex(CommandCallback *callback)
192{
193 if (auto it = std::ranges::find(_callback_table, callback); it != std::end(_callback_table)) {
194 return static_cast<size_t>(std::distance(std::begin(_callback_table), it));
195 }
196
197 return std::numeric_limits<size_t>::max();
198}
199
208void NetworkSendCommand(Commands cmd, StringID err_message, CommandCallback *callback, CompanyID company, const CommandDataBuffer &cmd_data)
209{
211 c.company = company;
212 c.cmd = cmd;
213 c.err_msg = err_message;
214 c.callback = callback;
215 c.data = cmd_data;
216
217 if (_network_server) {
218 /* If we are the server, we queue the command in our 'special' queue.
219 * In theory, we could execute the command right away, but then the
220 * client on the server can do everything 1 tick faster than others.
221 * So to keep the game fair, we delay the command with 1 tick
222 * which gives about the same speed as most clients.
223 */
225 c.my_cmd = true;
226
227 _local_wait_queue.push_back(std::move(c));
228 return;
229 }
230
231 c.frame = 0; // The client can't tell which frame, so just make it 0
232
233 /* Clients send their command to the server and forget all about the packet */
235}
236
247{
248 for (auto &p : _local_execution_queue) {
249 CommandPacket &c = cs->outgoing_queue.emplace_back(p);
250 c.callback = nullptr;
251 }
252}
253
258{
259 assert(IsLocalCompany());
260
262
263 auto cp = queue.begin();
264 for (; cp != queue.end(); cp++) {
265 /* The queue is always in order, which means
266 * that the first element will be executed first. */
267 if (_frame_counter < cp->frame) break;
268
269 if (_frame_counter > cp->frame) {
270 /* If we reach here, it means for whatever reason, we've already executed
271 * past the command we need to execute. */
272 FatalError("[net] Trying to execute a packet in the past!");
273 }
274
275 /* We can execute this command */
276 _current_company = cp->company;
277 size_t cb_index = FindCallbackIndex(cp->callback);
278 assert(cb_index < _callback_tuple_size);
279 assert(_cmd_dispatch[cp->cmd].Unpack[cb_index] != nullptr);
280 _cmd_dispatch[cp->cmd].Unpack[cb_index](*cp);
281 }
282 queue.erase(queue.begin(), cp);
283
284 /* Local company may have changed, so we should not restore the old value */
286}
287
296
303{
304 CommandCallback *callback = cp.callback;
305 cp.frame = _frame_counter_max + 1;
306
307 for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
308 if (cs->status >= NetworkClientSocket::ClientStatus::Map) {
309 /* Callbacks are only send back to the client who sent them in the
310 * first place. This filters that out. */
311 cp.callback = (cs != owner) ? nullptr : callback;
312 cp.my_cmd = (cs == owner);
313 cs->outgoing_queue.push_back(cp);
314 }
315 }
316
317 cp.callback = (nullptr != owner) ? nullptr : callback;
318 cp.my_cmd = (nullptr == owner);
319 _local_execution_queue.push_back(cp);
320}
321
327static void DistributeQueue(CommandQueue &queue, const NetworkClientSocket *owner)
328{
329#ifdef DEBUG_DUMP_COMMANDS
330 /* When replaying we do not want this limitation. */
331 int to_go = UINT16_MAX;
332#else
333 int to_go = _settings_client.network.commands_per_frame;
334 if (owner == nullptr) {
335 /* This is the server, use the commands_per_frame_server setting if higher */
336 to_go = std::max<int>(to_go, _settings_client.network.commands_per_frame_server);
337 }
338#endif
339
340 /* Not technically the most performant way, but consider clients rarely click more than once per tick. */
341 for (auto cp = queue.begin(); cp != queue.end(); /* removing some items */) {
342 /* Do not distribute commands when paused and the command is not allowed while paused. */
343 if (_pause_mode.Any() && !IsCommandAllowedWhilePaused(cp->cmd)) {
344 ++cp;
345 continue;
346 }
347
348 /* Limit the number of commands per client per tick. */
349 if (--to_go < 0) break;
350
351 DistributeCommandPacket(*cp, owner);
352 NetworkAdminCmdLogging(owner, *cp);
353 cp = queue.erase(cp);
354 }
355}
356
359{
360 /* First send the server's commands. */
362
363 /* Then send the queues of the others. */
364 for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
365 DistributeQueue(cs->incoming_queue, cs);
366 }
367}
368
375std::optional<std::string_view> NetworkGameSocketHandler::ReceiveCommand(Packet &p, CommandPacket &cp)
376{
377 cp.company = (CompanyID)p.Recv_uint8();
378 cp.cmd = static_cast<Commands>(p.Recv_uint16());
379 if (!IsValidCommand(cp.cmd)) return "invalid command";
380 if (GetCommandFlags(cp.cmd).Test(CommandFlag::Offline)) return "single-player only command";
381 cp.err_msg = static_cast<StringID>(p.Recv_uint16());
382 cp.data = _cmd_dispatch[cp.cmd].Sanitize(p.Recv_buffer());
383
384 uint8_t callback = p.Recv_uint8();
385 if (callback >= _callback_table.size() || _cmd_dispatch[cp.cmd].Unpack[callback] == nullptr) return "invalid callback";
386
387 cp.callback = _callback_table[callback];
388 return std::nullopt;
389}
390
397{
398 p.Send_uint8(cp.company);
400 p.Send_uint16(cp.err_msg.base());
401 p.Send_buffer(cp.data);
402
403 size_t callback = FindCallbackIndex(cp.callback);
404 if (callback > UINT8_MAX || _cmd_dispatch[cp.cmd].Unpack[callback] == nullptr) {
405 Debug(Facility::Net, Severity::Critical, "Unknown callback for command; no callback sent (command: {})", cp.cmd);
406 callback = 0; // _callback_table[0] == nullptr
407 }
408 p.Send_uint8 ((uint8_t)callback);
409}
410
416template <class T>
417static inline void SetClientIdHelper(T &data, [[maybe_unused]] ClientID client_id)
418{
419 if constexpr (std::is_same_v<ClientID, T>) {
420 data = client_id;
421 }
422}
423
429template <class Ttuple, size_t... Tindices>
430static inline void SetClientIds(Ttuple &values, ClientID client_id, std::index_sequence<Tindices...>)
431{
432 ((SetClientIdHelper(std::get<Tindices>(values), client_id)), ...);
433}
434
435template <Commands Tcmd>
436static void NetworkReplaceCommandClientId(CommandPacket &cp, ClientID client_id)
437{
438 /* Unpack command parameters. */
439 auto params = EndianBufferReader::ToValue<typename CommandTraits<Tcmd>::Args>(cp.data);
440
441 /* Insert client id. */
442 SetClientIds(params, client_id, std::make_index_sequence<std::tuple_size_v<decltype(params)>>{});
443
444 /* Repack command parameters. */
445 cp.data = EndianBufferWriter<CommandDataBuffer>::FromValue(params);
446}
447
453void NetworkReplaceCommandClientId(CommandPacket &cp, ClientID client_id)
454{
455 _cmd_dispatch[cp.cmd].ReplaceClientId(cp, client_id);
456}
457
458
464template <class T>
465static inline void SanitizeSingleStringHelper([[maybe_unused]] CommandFlags cmd_flags, T &data)
466{
467 if constexpr (std::is_same_v<std::string, T>) {
468 if (!_network_server && cmd_flags.Test(CommandFlag::StrCtrl)) {
470 } else {
472 }
473 }
474}
475
481template <class Ttuple, size_t... Tindices>
482static inline void SanitizeStringsHelper(CommandFlags cmd_flags, Ttuple &values, std::index_sequence<Tindices...>)
483{
484 ((SanitizeSingleStringHelper(cmd_flags, std::get<Tindices>(values))), ...);
485}
486
493template <Commands Tcmd>
495{
496 auto args = EndianBufferReader::ToValue<typename CommandTraits<Tcmd>::Args>(data);
497 SanitizeStringsHelper(CommandTraits<Tcmd>::flags, args, std::make_index_sequence<std::tuple_size_v<typename CommandTraits<Tcmd>::Args>>{});
498 return EndianBufferWriter<CommandDataBuffer>::FromValue(args);
499}
500
507template <Commands Tcmd, size_t Tcb>
509{
510 auto args = EndianBufferReader::ToValue<typename CommandTraits<Tcmd>::Args>(cp.data);
511 Command<Tcmd>::PostFromNet(cp.err_msg, std::get<Tcb>(_callback_tuple), cp.my_cmd, args);
512}
Command definitions related to aircraft.
Command definitions related to airports.
Command definitions related to autoreplace.
void CcBuildBridge(Commands, const CommandCost &result, TileIndex end_tile, TileIndex tile_start, TransportType transport_type, BridgeType, RailType, RoadType)
Callback executed after a build Bridge CMD has been called.
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
static ClientNetworkGameSocketHandler * my_client
This is us!
static NetworkRecvStatus SendCommand(const CommandPacket &cp)
Send a command to the server.
Common return value for all commands.
std::optional< std::string_view > ReceiveCommand(Packet &p, CommandPacket &cp)
Receives a command from the network.
void SendCommand(Packet &p, const CommandPacket &cp)
Sends a command over the network.
CommandFlags GetCommandFlags(Commands cmd)
Get the command flags associated with the given command.
Definition command.cpp:112
bool IsCommandAllowedWhilePaused(Commands cmd)
Returns whether the command is allowed while the game is paused.
Definition command.cpp:136
bool IsValidCommand(Commands cmd)
This function range-checks a Commands.
Definition command.cpp:102
Functions related to commands.
void CommandCallback(Commands cmd, const CommandCost &result, TileIndex tile)
Define a callback function for the client, after the command is finished.
@ Offline
the command cannot be executed in a multiplayer game; single-player only
@ StrCtrl
the command's string may contain control strings
std::vector< uint8_t > CommandDataBuffer
Storage buffer for serialized command data.
EnumBitSet< CommandFlag, uint16_t > CommandFlags
Bitset of CommandFlag elements.
Commands
List of commands.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
CompanyID _current_company
Company currently doing an action.
Command definitions related to companies.
Functions related to companies.
bool IsLocalCompany()
Is the current company the local company?
#define Debug(facility, severity, format_string,...)
Output a line of debugging information.
Definition debug.h:36
@ Net
Net message facility.
Definition debug_type.h:33
@ Critical
Critical, user should know about this.
Definition debug_type.h:15
Command definitions related to depots.
void CcCloneVehicle(Commands, const CommandCost &result, VehicleID veh_id)
This is the Callback method after the cloning attempt of a vehicle.
Command definitions related to docks.
Command definitions related to the economy.
Command definitions related to engines.
#define T
Climate temperate.
Definition engines.h:91
constexpr std::underlying_type_t< enum_type > to_underlying(enum_type e)
Implementation of std::to_underlying (from C++23).
Definition enum_type.hpp:21
EnumClassIndexContainer< std::array< T, to_underlying(N)>, Index > EnumIndexArray
A typedef for EnumClassIndexContainer using std::array as the backing container type.
Error reporting related functions.
PauseModes _pause_mode
The current pause mode.
Definition gfx.cpp:46
Command definitions related to goals.
Command definitions related to engine groups.
void CcAddVehicleNewGroup(Commands, const CommandCost &result, GroupID new_group, GroupID, VehicleID, bool, const VehicleListIdentifier &)
Open rename window after adding a vehicle to a new group via drag and drop.
void CcCreateGroup(Commands, const CommandCost &result, GroupID new_group, VehicleType vt, GroupID)
Opens a 'Rename group' window for newly created group.
Command definitions related to industries.
Command definitions related to landscape (slopes etc.).
Command definitions related to league tables.
Miscellaneous command definitions.
uint32_t _frame_counter
The current frame.
Definition network.cpp:76
bool _network_server
network-server is active
Definition network.cpp:64
uint32_t _frame_counter_max
To where we may go with our clients.
Definition network.cpp:75
void NetworkAdminCmdLogging(const NetworkClientSocket *owner, const CommandPacket &cp)
Distribute CommandPacket details over the admin network for logging purposes.
Server part of the admin network protocol.
Client part of the network protocol.
static void SanitizeStringsHelper(CommandFlags cmd_flags, Ttuple &values, std::index_sequence< Tindices... >)
Helper function to perform validation on command data strings.
static constexpr auto _callback_tuple
Typed list of all possible callbacks.
void NetworkFreeLocalCommandQueue()
Free the local command queues.
static void SetClientIds(Ttuple &values, ClientID client_id, std::index_sequence< Tindices... >)
Set all invalid ClientIDs to the proper value.
static const auto _callback_table
Type-erased table of callbacks.
static size_t FindCallbackIndex(CommandCallback *callback)
Find the callback index of a callback pointer.
void NetworkExecuteLocalCommandQueue()
Execute all commands on the local command queue that ought to be executed this frame.
bool IsNetworkRegisteredCallback(CommandCallback *callback)
Helper function to ensure that callbacks used when Posting commands are actually registered for the n...
void NetworkDistributeCommands()
Distribute the commands of ourself and the clients.
static CommandQueue _local_wait_queue
Local queue of packets waiting for handling.
static void SetClientIdHelper(T &data, ClientID client_id)
Helper to process a single ClientID argument.
static void SanitizeSingleStringHelper(CommandFlags cmd_flags, T &data)
Validate a single string argument coming from network.
static CommandQueue _local_execution_queue
Local queue of packets waiting for execution.
static void DistributeCommandPacket(CommandPacket &cp, const NetworkClientSocket *owner)
"Send" a particular CommandPacket to all clients.
void NetworkSyncCommandQueue(NetworkClientSocket *cs)
Sync our local command queue to the command queue of the given socket.
static void UnpackNetworkCommand(const CommandPacket &cp)
Unpack a generic command packet into its actual typed components.
static void DistributeQueue(CommandQueue &queue, const NetworkClientSocket *owner)
"Send" a particular CommandQueue to all clients.
void NetworkSendCommand(Commands cmd, StringID err_message, CommandCallback *callback, CompanyID company, const CommandDataBuffer &cmd_data)
Prepare a DoCommand to be send over the network.
static CommandDataBuffer SanitizeCmdStrings(const CommandDataBuffer &data)
Validate and sanitize strings in command data.
static constexpr auto _cmd_dispatch
Command dispatch table.
class ServerNetworkGameSocketHandler NetworkClientSocket
Class for handling the server side of the game connection.
Server part of the network protocol.
ClientID
'Unique' identifier to be given to clients
Command definitions related to news messages.
Command definitions related to objects.
Command definitions related to orders.
Command definitions for rail.
Road related functions.
void CcRoadStop(Commands, const CommandCost &result, TileIndex tile, uint8_t width, uint8_t length, RoadStopType, bool is_drive_through, DiagDirection dir, RoadType, RoadStopClassID spec_class, uint16_t spec_index, StationID, bool)
Command callback for building road stops.
Definition road_gui.cpp:198
Command definitions related to road vehicles.
A number of safeguards to prevent using unsafe methods.
Command definitions related to scripts.
ClientSettings _settings_client
The current settings for this game.
Definition settings.cpp:60
Command definitions related to settings.
Types related to global configuration settings.
void CcPlaceSign(Commands, const CommandCost &result, SignID new_sign)
Callback function that is called after a sign is placed.
Command definitions related to signs.
void CcMoveStationName(Commands, const CommandCost &result, StationID station_id)
Callback function that is called after a name is moved.
Command definitions related to stations.
Definition of base types and functions in a cross-platform compatible way.
Command definitions related to stories.
void StrMakeValidInPlace(char *str, StringValidationSettings settings)
Scans the string for invalid characters and replaces them with a question mark '?
Definition string.cpp:156
Functions related to low-level strings.
@ ReplaceWithQuestionMark
Replace the unknown/bad bits with question marks.
Definition string_type.h:45
@ AllowControlCode
Allow the special control codes.
Definition string_type.h:47
StrongType::Typedef< uint32_t, struct StringIDTag, StrongType::Compare, StrongType::Integer > StringID
Numeric value that represents a string, independent of the selected language.
std::tuple< std::decay_t< Targs >... > Args
std::tuple with argument types for the callback.
Everything we need to know about a command to be able to execute it.
StringID err_msg
string ID of error message to use.
CommandDataBuffer data
command parameters.
CommandCallback * callback
any callback function executed upon successful completion of the command.
uint32_t frame
the frame in which this packet is executed
CompanyID company
company that is executing the command
bool my_cmd
did the command originate from "me"
Commands cmd
command being executed.
Defines the traits of a command.
uint16_t Recv_uint16()
Read a 16 bits integer from the packet.
Definition packet.cpp:330
uint8_t Recv_uint8()
Read a 8 bits integer from the packet.
Definition packet.cpp:316
void Send_uint8(uint8_t data)
Package a 8 bits integer in the packet.
Definition packet.cpp:118
void Send_buffer(const std::vector< uint8_t > &data)
Copy a sized byte buffer into the packet.
Definition packet.cpp:181
std::vector< uint8_t > Recv_buffer()
Extract a sized byte buffer from the packet.
Definition packet.cpp:383
void Send_uint16(uint16_t data)
Package a 16 bits integer in the packet.
Definition packet.cpp:128
Command definitions related to subsidies.
std::vector< CommandPacket > CommandQueue
A "queue" of CommandPackets.
Definition tcp_game.h:137
Command definitions related to terraforming.
Command definitions related to timetables.
Command definitions related to towns.
Command definitions related to trains.
void CcBuildWagon(Commands, const CommandCost &result, VehicleID new_veh_id, uint, uint16_t, CargoArray, TileIndex tile, EngineID, bool, CargoType, ClientID)
Callback for building wagons.
Definition train_gui.cpp:30
Command definitions related to tree tiles.
Command definitions related to tunnels and bridges.
Command definitions for vehicles.
void CcBuildPrimaryVehicle(Commands, const CommandCost &result, VehicleID new_veh_id, uint, uint16_t, CargoArray)
This is the Callback method after the construction attempt of a primary vehicle.
void CcStartStopVehicle(Commands, const CommandCost &result, VehicleID veh_id, bool)
This is the Callback method after attempting to start/stop a vehicle.
Command definitions related to viewports.
Command definitions related to water tiles.
void CcMoveWaypointName(Commands, const CommandCost &result, StationID waypoint_id)
Callback function that is called after a name is moved.
Command definitions related to waypoints.