OpenTTD Source
20240917-master-g9ab0a47812
|
Go to the documentation of this file.
10 #include "../stdafx.h"
11 #include "../strings_func.h"
12 #include "../timer/timer_game_calendar.h"
13 #include "../timer/timer_game_calendar.h"
14 #include "core/network_game_info.h"
18 #include "../command_func.h"
19 #include "../company_base.h"
20 #include "../console_func.h"
21 #include "../core/pool_func.hpp"
22 #include "../map_func.h"
24 #include "../game/game.hpp"
26 #include "../safeguards.h"
109 Debug(net, 2,
"[admin] Admin did not send its authorisation within {} seconds", std::chrono::duration_cast<std::chrono::seconds>(
ADMIN_AUTHORISATION_TIMEOUT).count());
110 as->CloseConnection(
true);
145 p->Send_uint8(error);
150 Debug(net, 1,
"[admin] The admin '{}' ({}) made an error and has been disconnected: '{}'", this->
admin_name, this->
admin_version, error_message);
183 p->Send_string(GetNetworkRevisionString());
233 p->Send_uint32(client_id);
289 p->Send_uint32(client_id);
304 p->Send_uint32(client_id);
305 p->Send_uint8 (error);
318 p->Send_uint8(company_id);
333 p->Send_uint8 (c->
index);
335 p->Send_string(
GetString(STR_COMPANY_NAME));
337 p->Send_string(
GetString(STR_PRESIDENT_NAME));
338 p->Send_uint8 (c->
colour);
341 p->Send_bool (c->
is_ai);
358 p->Send_uint8 (c->
index);
360 p->Send_string(
GetString(STR_COMPANY_NAME));
362 p->Send_string(
GetString(STR_PRESIDENT_NAME));
363 p->Send_uint8 (c->
colour);
381 p->Send_uint8(company_id);
394 Money income = -std::reduce(std::begin(company->yearly_expenses[0]), std::end(company->yearly_expenses[0]));
398 p->Send_uint8(company->index);
401 p->Send_uint64(company->money);
402 p->Send_uint64(company->current_loan);
403 p->Send_uint64(income);
404 p->Send_uint16(
static_cast<uint16_t
>(std::min<uint64_t>(UINT16_MAX, company->cur_economy.delivered_cargo.GetSum<
OverflowSafeInt64>())));
407 for (uint i = 0; i < 2; i++) {
408 p->Send_uint64(company->old_economy[i].company_value);
409 p->Send_uint16(company->old_economy[i].performance_history);
410 p->Send_uint16(
static_cast<uint16_t
>(std::min<uint64_t>(UINT16_MAX, company->old_economy[i].delivered_cargo.GetSum<
OverflowSafeInt64>())));
432 p->Send_uint8(company->index);
434 for (uint i = 0; i < NETWORK_VEH_END; i++) {
435 p->Send_uint16(company_stats[company->index].
num_vehicle[i]);
438 for (uint i = 0; i < NETWORK_VEH_END; i++) {
439 p->Send_uint16(company_stats[company->index].
num_station[i]);
460 p->Send_uint8 (action);
461 p->Send_uint8 (desttype);
462 p->Send_uint32(client_id);
464 p->Send_uint64(data);
478 p->Send_string(command);
493 p->Send_uint16(colour);
494 p->Send_string(result);
552 p->Send_string(origin);
553 p->Send_string(
string);
567 p->Send_string(json);
589 for (uint16_t i = 0; i <
CMD_END; i++) {
595 if (!p->CanWriteToPacket(strlen(cmdname) + 5)) {
604 p->Send_string(cmdname);
623 p->Send_uint32(client_id);
625 p->Send_uint16(cp.
cmd);
626 p->Send_buffer(cp.
data);
627 p->Send_uint32(cp.
frame);
644 return this->
SendError(NETWORK_ERROR_NOT_AUTHORIZED);
652 return this->
SendError(NETWORK_ERROR_WRONG_PASSWORD);
658 if (this->
admin_name.empty() || this->admin_version.empty()) {
660 return this->
SendError(NETWORK_ERROR_ILLEGAL_PACKET);
684 return this->
SendError(NETWORK_ERROR_ILLEGAL_PACKET);
709 if (d1 == UINT32_MAX) {
711 for (
const NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
718 const NetworkClientSocket *cs = NetworkClientSocket::GetByClientID((
ClientID)d1);
726 if (d1 == UINT32_MAX) {
754 return this->
SendError(NETWORK_ERROR_ILLEGAL_PACKET);
771 case NETWORK_ACTION_CHAT:
772 case NETWORK_ACTION_CHAT_CLIENT:
773 case NETWORK_ACTION_CHAT_COMPANY:
774 case NETWORK_ACTION_SERVER_MESSAGE:
780 return this->
SendError(NETWORK_ERROR_ILLEGAL_PACKET);
796 Debug(net, 1,
"[admin] Not supported chat colour {} ({}, {}, {}) from '{}' ({}).", (uint16_t)colour, source, user, msg, this->
admin_name, this->
admin_version);
797 return this->
SendError(NETWORK_ERROR_ILLEGAL_PACKET);
820 if (this->
admin_name.empty() || this->admin_version.empty()) {
822 return this->
SendError(NETWORK_ERROR_ILLEGAL_PACKET);
826 if (!handler->CanBeUsed())
return this->
SendError(NETWORK_ERROR_NO_AUTHENTICATION_METHOD_AVAILABLE);
831 return this->SendAuthRequest();
867 this->SendEnableEncryption();
876 return this->SendAuthRequest();
881 return this->
SendError(NETWORK_ERROR_WRONG_PASSWORD);
898 as->SendClientInfo(cs, cs->GetInfo());
900 as->SendClientJoin(cs->client_id);
914 as->SendClientUpdate(ci);
927 as->SendClientQuit(client_id);
941 as->SendClientError(client_id, error_code);
952 if (company ==
nullptr) {
953 Debug(net, 1,
"[admin] Empty company given for update");
960 as->SendCompanyNew(company->
index);
961 as->SendCompanyInfo(company);
971 if (company ==
nullptr)
return;
976 as->SendCompanyUpdate(company);
988 as->SendCompanyRemove(company_id, bcrr);
998 if (from_admin)
return;
1002 as->SendChat(action, desttype, client_id, msg, data);
1027 as->SendConsole(origin,
string);
1040 as->SendGameScript(json);
1056 as->SendCmdLogging(client_id, cp);
1079 if (as->update_frequency[i] & freq) {
1087 as->SendCompanyEconomy();
1091 as->SendCompanyStats();
1094 default: NOT_REACHED();
NetworkRecvStatus SendPong(uint32_t d1)
Send ping-reply (pong) to admin.
uint16_t num_station[NETWORK_VEH_END]
How many stations are there of this type?
bool is_ai
If true, the company is (also) controlled by the computer (a NoAI program).
Simple calculated statistics of a company.
@ ADMIN_PACKET_SERVER_COMPANY_NEW
The server tells the admin that a new company has started.
@ ADMIN_UPDATE_CMD_NAMES
The admin would like a list of all DoCommand names.
@ ADMIN_UPDATE_COMPANY_INFO
Updates about the generic information of companies.
@ ADMIN_PACKET_SERVER_SHUTDOWN
The server tells the admin its shutting down.
uint16_t NetworkAuthenticationMethodMask
The mask of authentication methods that can be used.
static Titem * Get(size_t index)
Returns Titem with given index.
std::string admin_version
Version string of the admin.
void NetworkAdminUpdate(AdminUpdateFrequency freq)
Send (push) updates to the admin network as they have registered for these updates.
virtual void SendPacket(std::unique_ptr< Packet > &&packet)
This function puts the packet in the send-queue and it is send as soon as possible.
NetworkRecvStatus Receive_ADMIN_UPDATE_FREQUENCY(Packet &p) override
Register updates to be sent at certain frequencies (as announced in the PROTOCOL packet): uint16_t Up...
std::unique_ptr< class NetworkEncryptionHandler > send_encryption_handler
The handler for encrypting sent packets.
AdminStatus status
Status of this admin.
void NetworkAdminChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, int64_t data, bool from_admin)
Send chat to the admin network (if they did opt in for the respective update).
NetworkRecvStatus CloseConnection(bool error=true) override
This will put this socket handler in a close state.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
std::string client_name
Name of the client.
NetworkRecvStatus SendError(NetworkErrorCode error)
Send an error to the admin.
NetworkRecvStatus SendRconEnd(const std::string_view command)
Send a notification indicating the rcon command has completed.
@ ADMIN_UPDATE_CLIENT_INFO
Updates about the information of clients.
uint32_t frame
the frame in which this packet is executed
CompanyID client_playas
As which company is this client playing (CompanyID)
std::string admin_name
Name of the admin.
NetworkRecvStatus SendCompanyEconomy()
Send economic information of all companies.
void NetworkAdminCmdLogging(const NetworkClientSocket *owner, const CommandPacket &cp)
Distribute CommandPacket details over the admin network for logging purposes.
AdminUpdateFrequency update_frequency[ADMIN_UPDATE_END]
Admin requested update intervals.
@ ADMIN_UPDATE_CONSOLE
The admin would like to have console messages.
NetworkRecvStatus Receive_ADMIN_POLL(Packet &p) override
Poll the server for certain updates, an invalid poll (e.g.
NetworkAction
Actions that can be used for NetworkTextMessage.
@ ADMIN_UPDATE_CHAT
The admin would like to have chat messages.
@ ADMIN_PACKET_SERVER_PONG
The server replies to a ping request from the admin.
NetworkRecvStatus Receive_ADMIN_AUTH_RESPONSE(Packet &p) override
Admin responds to ADMIN_PACKET_SERVER_AUTH_REQUEST with the appropriate data given the agreed upon Ne...
Owner
Enum for all companies/owners.
Tindex index
Index of this pool item.
Default implementation of the password provider.
void NetworkPopulateCompanyStats(NetworkCompanyStats *stats)
Populate the company stats.
static void WelcomeAll()
Send a Welcome packet to all connected admins.
static const uint NETWORK_CHAT_LENGTH
The maximum length of a chat message, in bytes including '\0'.
@ ADMIN_PACKET_SERVER_CMD_NAMES
The server sends out the names of the DoCommands to the admins.
static std::unique_ptr< NetworkAuthenticationServerHandler > Create(const NetworkAuthenticationPasswordProvider *password_provider, const NetworkAuthenticationAuthorizedKeyHandler *authorized_key_handler, NetworkAuthenticationMethodMask client_supported_method_mask=~static_cast< NetworkAuthenticationMethodMask >(0))
Create a NetworkAuthenticationServerHandler.
@ ADMIN_FREQUENCY_DAILY
The admin gets information about this on a daily basis.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
DestType
Destination of our chat messages.
static Pool::IterateWrapperFiltered< ServerNetworkAdminSocketHandler, ServerNetworkAdminSocketHandlerFilter > IterateActive(size_t from=0)
Returns an iterable ensemble of all active admin sockets.
NetworkRecvStatus SendCompanyUpdate(const Company *c)
Send an update about a company.
constexpr uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
@ ADMIN_UPDATE_CMD_LOGGING
The admin would like to have DoCommand information.
ClientSettings _settings_client
The current settings for this game.
@ ADMIN_FREQUENCY_MONTHLY
The admin gets information about this on a monthly basis.
Default implementation for the authorized key handler.
StringID GetNetworkErrorMsg(NetworkErrorCode err)
Retrieve the string id of an internal error number.
@ ADMIN_PACKET_SERVER_RCON_END
The server indicates that the remote console command has completed.
void NetworkServerSendChat(NetworkAction action, DestType type, int dest, const std::string &msg, ClientID from_id, int64_t data=0, bool from_admin=false)
Send an actual chat message.
@ ADMIN_PACKET_SERVER_RCON
The server's reply to a remove console command.
static const uint NETWORK_CLIENT_NAME_LENGTH
The maximum length of a client's name, in bytes including '\0'.
NetworkRecvStatus SendCompanyInfo(const Company *c)
Send the admin some information about a company.
uint8_t landscape
the landscape we're currently in
@ ADMIN_PACKET_SERVER_NEWGAME
The server tells the admin its going to start a new game.
NetworkAddress address
Address of the admin.
static const AdminIndex INVALID_ADMIN_ID
An invalid admin marker.
void NetworkAdminClientQuit(ClientID client_id)
Notify the admin network that a client quit (if they have opt in for the respective update).
AdminIndex _redirect_console_to_admin
Redirection of the (remote) console to the admin.
@ ADMIN_PACKET_SERVER_CMD_LOGGING
The server gives the admin copies of incoming command packets.
@ ADMIN_PACKET_SERVER_CLIENT_ERROR
The server tells the admin that a client caused an error.
NetworkAdminSocketPool _networkadminsocket_pool("NetworkAdminSocket")
The pool with sockets/clients.
#define Debug(category, level, format_string,...)
Ouptut a line of debugging information.
static void Send()
Send the packets for the server sockets.
void NetworkAdminClientInfo(const NetworkClientSocket *cs, bool new_client)
Notify the admin network of a new client (if they did opt in for the respective update).
GameCreationSettings game_creation
settings used during the creation of a game (map)
NetworkRecvStatus Receive_ADMIN_GAMESCRIPT(Packet &p) override
Send a JSON string to the current active GameScript.
std::string Recv_string(size_t length, StringValidationSettings settings=SVS_REPLACE_WITH_QUESTION_MARK)
Reads characters (bytes) from the packet until it finds a '\0', or reaches a maximum of length charac...
void NetworkAdminConsole(const std::string_view origin, const std::string_view string)
Send console to the admin network (if they did opt in for the respective update).
static constexpr size_t MAX_SIZE
Make template parameter accessible from outside.
@ ADMIN_PACKET_SERVER_PROTOCOL
The server tells the admin its protocol version.
@ ADMIN_PACKET_SERVER_CHAT
The server received a chat message and relays it.
static NetworkClientInfo * GetByClientID(ClientID client_id)
Return the CI given it's client-identifier.
void NetworkAdminGameScript(const std::string_view json)
Send GameScript JSON to the admin network (if they did opt in for the respective update).
@ ADMIN_FREQUENCY_QUARTERLY
The admin gets information about this on a quarterly basis.
static const uint8_t NETWORK_GAME_ADMIN_VERSION
What version of the admin network do we use?
CompanyID company
company that is executing the command
@ ADMIN_STATUS_INACTIVE
The admin is not connected nor active.
@ ADMIN_PACKET_SERVER_COMPANY_ECONOMY
The server gives the admin some economy related company information.
@ NETWORK_AUTH_METHOD_X25519_KEY_EXCHANGE_ONLY
No actual authentication is taking place, just perform a x25519 key exchange. This method is not supp...
NetworkRecvStatus SendShutdown()
Tell the admin we're shutting down.
NetworkRecvStatus Receive_ADMIN_PING(Packet &p) override
Ping the server, requiring the server to reply with a pong packet.
std::chrono::steady_clock::time_point connect_time
Time of connection.
Everything we need to know about a command to be able to execute it.
static const AdminIndex MAX_ADMINS
Maximum number of allowed admins.
uint32_t Recv_uint32()
Read a 32 bits integer from the packet.
@ ADMIN_PACKET_SERVER_CLIENT_UPDATE
The server gives the admin an information update on a client.
NetworkRecvStatus SendConsole(const std::string_view origin, const std::string_view command)
Send console output of other clients.
uint16_t num_vehicle[NETWORK_VEH_END]
How many vehicles are there of this type?
void IConsoleCmdExec(const std::string &command_string, const uint recurse_count)
Execute a given command passed to us.
@ NOT_AUTHENTICATED
All authentications for this handler have been exhausted.
NetworkRecvStatus SendCompanyRemove(CompanyID company_id, AdminCompanyRemoveReason bcrr)
Tell the admin that a company got removed.
static Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
Colours colour
Company colour.
Main socket handler for admin related connections.
@ ADMIN_PACKET_SERVER_GAMESCRIPT
The server gives the admin information from the GameScript in JSON.
@ ADMIN_PACKET_SERVER_WELCOME
The server welcomes the admin to a game.
std::string admin_password
password for the admin network
@ AUTHENTICATED
The client was authenticated successfully.
@ ADMIN_FREQUENCY_POLL
The admin can poll this.
@ ADMIN_UPDATE_DATE
Updates about the date of the game.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
static bool AllowConnection()
Whether a connection is allowed or not at this moment.
NetworkRecvStatus SendWelcome()
Send a welcome message to the admin.
static void NewEvent(class ScriptEvent *event)
Queue a new event for a Game Script.
NetworkRecvStatus SendGameScript(const std::string_view json)
Send GameScript JSON output.
@ ADMIN_UPDATE_COMPANY_STATS
Updates about the statistics of companies.
TimerGameCalendar::Year starting_year
starting date
bool IsValidConsoleColour(TextColour c)
Check whether the given TextColour is valid for console usage.
#define lengthof(array)
Return the length of an fixed size array.
@ ADMIN_UPDATE_COMPANY_ECONOMY
Updates about the economy of companies.
NetworkRecvStatus Receive_ADMIN_CHAT(Packet &p) override
Send chat as the server: uint8_t Action such as NETWORK_ACTION_CHAT_CLIENT (see NetworkAction).
@ ADMIN_PACKET_SERVER_CONSOLE
The server gives the admin the data that got printed to its console.
NetworkRecvStatus SendCmdLogging(ClientID client_id, const CommandPacket &cp)
Send a command for logging purposes.
@ ADMIN_STATUS_AUTHENTICATE
The admin is connected and working on authentication.
NetworkRecvStatus Receive_ADMIN_JOIN_SECURE(Packet &p) override
Join the admin network using a secure authentication method: string Name of the application being use...
~ServerNetworkAdminSocketHandler()
Clear everything related to this admin.
uint8_t months_of_bankruptcy
Number of months that the company is unable to pay its debts.
NetworkRecvStatus SendClientQuit(ClientID client_id)
Tell the admin that a client quit.
@ ADMIN_PACKET_SERVER_CLIENT_JOIN
The server tells the admin that a client has joined.
AdminCompanyRemoveReason
Reasons for removing a company - communicated to admins.
NetworkRecvStatus Receive_ADMIN_EXTERNAL_CHAT(Packet &p) override
Send chat from the external source: string Name of the source this message came from.
@ ADMIN_PACKET_SERVER_CLIENT_INFO
The server gives the admin information about a client.
bool _network_dedicated
are we a dedicated server?
@ ADMIN_UPDATE_GAMESCRIPT
The admin would like to have gamescript messages.
Internal entity of a packet.
@ ADMIN_PACKET_SERVER_DATE
The server tells the admin what the current game date is.
@ ADMIN_FREQUENCY_ANUALLY
The admin gets information about this on a yearly basis.
NetworkRecvStatus SendCmdNames()
Send the names of the commands.
void NetworkAdminCompanyRemove(CompanyID company_id, AdminCompanyRemoveReason bcrr)
Notify the admin network of a company to be removed (including the reason why).
static const uint NETWORK_REVISION_LENGTH
The maximum length of the revision, in bytes including '\0'.
AdminUpdateType
Update types an admin can register a frequency for.
ClientID client_id
Client identifier (same as ClientState->client_id)
static const uint NETWORK_PASSWORD_LENGTH
The maximum length of the password, in bytes including '\0'.
NetworkRecvStatus Receive_ADMIN_RCON(Packet &p) override
Execute a command on the servers console: string Command to be executed.
NetworkRecvStatus SendNewGame()
Tell the admin we started a new game.
@ ADMIN_PACKET_SERVER_CLIENT_QUIT
The server tells the admin that a client quit.
ClientID _network_own_client_id
Our client identifier.
void NetworkAdminCompanyUpdate(const Company *company)
Notify the admin network of company updates.
static debug_inline uint SizeX()
Get the size of the map along the X.
std::string server_name
name of the server
TimerGameEconomy::Year inaugurated_year
Economy year of starting the company.
Wrapper for (un)resolved network addresses; there's no reason to transform a numeric IP to a string a...
static const uint NETWORK_RCONCOMMAND_LENGTH
The maximum length of a rconsole command, in bytes including '\0'.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
NetworkRecvStatus SendDate()
Tell the admin the date.
NetworkRecvStatus SendCompanyNew(CompanyID company_id)
Tell the admin that a new company was founded.
Base class for all pools.
NetworkRecvStatus Receive_ADMIN_QUIT(Packet &p) override
Notification to the server that this admin is quitting.
uint32_t generation_seed
noise seed for world generation
ClientID
'Unique' identifier to be given to clients
@ CMD_END
Must ALWAYS be on the end of this list!! (period)
bool allow_insecure_admin_login
Whether to allow logging in as admin using the insecure old JOIN packet.
ServerNetworkAdminSocketHandler(SOCKET s)
Sanity check.
CommandDataBuffer data
command parameters.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
Class for handling the server side of the game connection.
NetworkRecvStatus
Status of a network client; reasons why a client has quit.
NetworkRecvStatus SendClientInfo(const NetworkClientSocket *cs, const NetworkClientInfo *ci)
Send an initial set of data from some client's information.
@ ADMIN_FREQUENCY_AUTOMATIC
The admin gets information about this when it changes.
void NetworkServerSendExternalChat(const std::string &source, TextColour colour, const std::string &user, const std::string &msg)
Send a chat message from external source.
@ ADMIN_STATUS_ACTIVE
The admin is active.
NetworkRecvStatus SendProtocol()
Send the protocol version to the admin.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with all the associated DParam lookups and formatting.
const char * GetCommandName(Commands cmd)
This function mask the parameter with CMD_ID_MASK and returns the name which belongs to the given com...
NetworkRecvStatus SendChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, int64_t data)
Send a chat message.
const std::string & GetHostname()
Get the hostname; in case it wasn't given the IPv4 dotted representation is given.
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
std::unique_ptr< NetworkAuthenticationServerHandler > authentication_handler
The handler for the authentication.
static const size_t COMPAT_MTU
Number of bytes we can pack in a single packet for backward compatibility.
static void AcceptConnection(SOCKET s, const NetworkAddress &address)
Handle the acception of a connection.
@ ADMIN_PACKET_SERVER_ENABLE_ENCRYPTION
The server tells that authentication has completed and requests to enable encryption with the keys of...
NetworkRecvStatus SendClientUpdate(const NetworkClientInfo *ci)
Send an update for some client's information.
#define INSTANTIATE_POOL_METHODS(name)
Force instantiation of pool methods so we don't get linker errors.
void NetworkAdminCompanyNew(const Company *company)
Notify the admin network of a new company.
@ ADMIN_PACKET_SERVER_COMPANY_STATS
The server gives the admin some statistics about a company.
void NetworkAdminClientUpdate(const NetworkClientInfo *ci)
Notify the admin network of a client update (if they did opt in for the respective update).
@ ADMIN_PACKET_SERVER_AUTH_REQUEST
The server gives the admin the used authentication method and required parameters.
NetworkSettings network
settings related to the network
@ RETRY_NEXT_METHOD
The client failed to authenticate, but there is another method to try.
@ ADMIN_PACKET_SERVER_ERROR
The server tells the admin an error has occurred.
@ NETWORK_RECV_STATUS_OKAY
Everything is okay.
std::unique_ptr< class NetworkEncryptionHandler > receive_encryption_handler
The handler for decrypting received packets.
static Date date
Current date in days (day counter).
@ ADMIN_FREQUENCY_WEEKLY
The admin gets information about this on a weekly basis.
NetworkAuthorizedKeys admin_authorized_keys
Public keys of clients that are authorized to use the admin network.
Commands
List of commands.
static const AdminUpdateFrequency _admin_update_type_frequencies[]
Frequencies, which may be registered for a certain update type.
@ MAX_COMPANIES
Maximum number of companies.
static NetworkAuthenticationDefaultAuthorizedKeyHandler _admin_authorized_key_handler(_settings_client.network.admin_authorized_keys)
Provides the authorized key handling for the game authentication.
uint16_t Recv_uint16()
Read a 16 bits integer from the packet.
uint8_t _network_admins_connected
The amount of admins connected.
NetworkRecvStatus SendCompanyStats()
Send statistics about the companies.
static const uint NETWORK_GAMESCRIPT_JSON_LENGTH
The maximum length of a receiving gamescript json string, in bytes including '\0'.
static const std::chrono::seconds ADMIN_AUTHORISATION_TIMEOUT(10)
The timeout for authorisation of the client.
@ ADMIN_UPDATE_END
Must ALWAYS be on the end of this list!! (period)
@ ADMIN_PACKET_SERVER_COMPANY_REMOVE
The server tells the admin that a company was removed.
constexpr T ClrBit(T &x, const uint8_t y)
Clears a bit in a variable.
AdminUpdateFrequency
Update frequencies an admin can register.
@ ADMIN_PACKET_SERVER_COMPANY_INFO
The server gives the admin information about a company.
@ CLIENT_ID_SERVER
Servers always have this ID.
@ ADMIN_PACKET_SERVER_COMPANY_UPDATE
The server gives the admin an information update on a company.
NetworkRecvStatus SendClientJoin(ClientID client_id)
Tell the admin that a client joined.
void DebugReconsiderSendRemoteMessages()
Reconsider whether we need to send debug messages to either NetworkAdminConsole or IConsolePrint.
uint8_t AdminIndex
Indices into the admin tables.
NetworkErrorCode
The error codes we send around in the protocols.
Container for all information known about a client.
TimerGameEconomy::Date join_date
Gamedate the client has joined.
uint8_t Recv_uint8()
Read a 8 bits integer from the packet.
NetworkRecvStatus Receive_ADMIN_JOIN(Packet &p) override
Join the admin network using an unsecured password exchange: string Unsecured password the server is ...
void NetworkAdminClientError(ClientID client_id, NetworkErrorCode error_code)
Notify the admin network of a client error (if they have opt in for the respective update).
NetworkRecvStatus SendRcon(uint16_t colour, const std::string_view command)
Send the reply of an rcon command.
static uint SizeY()
Get the size of the map along the Y.
NetworkRecvStatus SendClientError(ClientID client_id, NetworkErrorCode error)
Tell the admin that a client made an error.
Commands cmd
command being executed.
void NetworkServerSendAdminRcon(AdminIndex admin_index, TextColour colour_code, const std::string_view string)
Pass the rcon reply to the admin.
static NetworkAuthenticationDefaultPasswordProvider _admin_password_provider(_settings_client.network.admin_password)
Provides the password validation for the game's password.