OpenTTD Source  12.2
network_admin.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 <http://www.gnu.org/licenses/>.
6  */
7 
10 #include "../stdafx.h"
11 #include "../strings_func.h"
12 #include "../date_func.h"
13 #include "core/game_info.h"
14 #include "network_admin.h"
15 #include "network_base.h"
16 #include "network_server.h"
17 #include "../command_func.h"
18 #include "../company_base.h"
19 #include "../console_func.h"
20 #include "../core/pool_func.hpp"
21 #include "../map_func.h"
22 #include "../rev.h"
23 #include "../game/game.hpp"
24 
25 #include "../safeguards.h"
26 
27 
28 /* This file handles all the admin network commands. */
29 
32 
35 
38 INSTANTIATE_POOL_METHODS(NetworkAdminSocket)
39 
40 
41 static const std::chrono::seconds ADMIN_AUTHORISATION_TIMEOUT(10);
42 
43 
56 };
59 
65 {
68  this->connect_time = std::chrono::steady_clock::now();
69 }
70 
75 {
77  Debug(net, 3, "[admin] '{}' ({}) has disconnected", this->admin_name, this->admin_version);
79 
83  }
84 }
85 
91 {
93  /* We can't go over the MAX_ADMINS limit here. However, if we accept
94  * the connection, there has to be space in the pool. */
97  return accept;
98 }
99 
102 {
104  if (as->status == ADMIN_STATUS_INACTIVE && std::chrono::steady_clock::now() > as->connect_time + ADMIN_AUTHORISATION_TIMEOUT) {
105  Debug(net, 2, "[admin] Admin did not send its authorisation within {} seconds", std::chrono::duration_cast<std::chrono::seconds>(ADMIN_AUTHORISATION_TIMEOUT).count());
106  as->CloseConnection(true);
107  continue;
108  }
109  if (as->writable) {
110  as->SendPackets();
111  }
112  }
113 }
114 
120 /* static */ void ServerNetworkAdminSocketHandler::AcceptConnection(SOCKET s, const NetworkAddress &address)
121 {
123  as->address = address; // Save the IP of the client
124 }
125 
126 /***********
127  * Sending functions for admin network
128  ************/
129 
135 {
137 
138  p->Send_uint8(error);
139  this->SendPacket(p);
140 
141  std::string error_message = GetString(GetNetworkErrorMsg(error));
142 
143  Debug(net, 1, "[admin] The admin '{}' ({}) made an error and has been disconnected: '{}'", this->admin_name, this->admin_version, error_message);
144 
145  return this->CloseConnection(true);
146 }
147 
150 {
152 
153  /* announce the protocol version */
155 
156  for (int i = 0; i < ADMIN_UPDATE_END; i++) {
157  p->Send_bool (true);
158  p->Send_uint16(i);
160  }
161 
162  p->Send_bool(false);
163  this->SendPacket(p);
164 
165  return this->SendWelcome();
166 }
167 
170 {
172 
176 
177  p->Send_string(""); // Used to be map-name.
181  p->Send_uint16(MapSizeX());
182  p->Send_uint16(MapSizeY());
183 
184  this->SendPacket(p);
185 
187 }
188 
191 {
193  this->SendPacket(p);
195 }
196 
199 {
201  this->SendPacket(p);
203 }
204 
207 {
209 
210  p->Send_uint32(_date);
211  this->SendPacket(p);
212 
214 }
215 
221 {
223 
224  p->Send_uint32(client_id);
225  this->SendPacket(p);
226 
228 }
229 
236 {
237  /* Only send data when we're a proper client, not just someone trying to query the server. */
238  if (ci == nullptr) return NETWORK_RECV_STATUS_OKAY;
239 
241 
242  p->Send_uint32(ci->client_id);
243  p->Send_string(cs == nullptr ? "" : const_cast<NetworkAddress &>(cs->client_address).GetHostname());
244  p->Send_string(ci->client_name);
245  p->Send_uint8 (0); // Used to be language
246  p->Send_uint32(ci->join_date);
247  p->Send_uint8 (ci->client_playas);
248 
249  this->SendPacket(p);
250 
252 }
253 
254 
260 {
262 
263  p->Send_uint32(ci->client_id);
264  p->Send_string(ci->client_name);
265  p->Send_uint8 (ci->client_playas);
266 
267  this->SendPacket(p);
268 
270 }
271 
277 {
279 
280  p->Send_uint32(client_id);
281  this->SendPacket(p);
282 
284 }
285 
292 {
294 
295  p->Send_uint32(client_id);
296  p->Send_uint8 (error);
297  this->SendPacket(p);
298 
300 }
301 
307 {
309  p->Send_uint8(company_id);
310 
311  this->SendPacket(p);
312 
314 }
315 
321 {
323 
324  p->Send_uint8 (c->index);
325  SetDParam(0, c->index);
326  p->Send_string(GetString(STR_COMPANY_NAME));
327  SetDParam(0, c->index);
328  p->Send_string(GetString(STR_PRESIDENT_NAME));
329  p->Send_uint8 (c->colour);
332  p->Send_bool (c->is_ai);
333  p->Send_uint8 (CeilDiv(c->months_of_bankruptcy, 3)); // send as quarters_of_bankruptcy
334 
335  for (size_t i = 0; i < lengthof(c->share_owners); i++) {
336  p->Send_uint8(c->share_owners[i]);
337  }
338 
339  this->SendPacket(p);
340 
342 }
343 
344 
350 {
352 
353  p->Send_uint8 (c->index);
354  SetDParam(0, c->index);
355  p->Send_string(GetString(STR_COMPANY_NAME));
356  SetDParam(0, c->index);
357  p->Send_string(GetString(STR_PRESIDENT_NAME));
358  p->Send_uint8 (c->colour);
360  p->Send_uint8 (CeilDiv(c->months_of_bankruptcy, 3)); // send as quarters_of_bankruptcy
361 
362  for (size_t i = 0; i < lengthof(c->share_owners); i++) {
363  p->Send_uint8(c->share_owners[i]);
364  }
365 
366  this->SendPacket(p);
367 
369 }
370 
377 {
379 
380  p->Send_uint8(company_id);
381  p->Send_uint8(acrr);
382 
383  this->SendPacket(p);
384 
386 }
387 
390 {
391  for (const Company *company : Company::Iterate()) {
392  /* Get the income. */
393  Money income = 0;
394  for (uint i = 0; i < lengthof(company->yearly_expenses[0]); i++) {
395  income -= company->yearly_expenses[0][i];
396  }
397 
399 
400  p->Send_uint8(company->index);
401 
402  /* Current information. */
403  p->Send_uint64(company->money);
404  p->Send_uint64(company->current_loan);
405  p->Send_uint64(income);
406  p->Send_uint16(static_cast<uint16>(std::min<uint64>(UINT16_MAX, company->cur_economy.delivered_cargo.GetSum<OverflowSafeInt64>())));
407 
408  /* Send stats for the last 2 quarters. */
409  for (uint i = 0; i < 2; i++) {
410  p->Send_uint64(company->old_economy[i].company_value);
411  p->Send_uint16(company->old_economy[i].performance_history);
412  p->Send_uint16(static_cast<uint16>(std::min<uint64>(UINT16_MAX, company->old_economy[i].delivered_cargo.GetSum<OverflowSafeInt64>())));
413  }
414 
415  this->SendPacket(p);
416  }
417 
418 
420 }
421 
424 {
425  /* Fetch the latest version of the stats. */
426  NetworkCompanyStats company_stats[MAX_COMPANIES];
427  NetworkPopulateCompanyStats(company_stats);
428 
429  /* Go through all the companies. */
430  for (const Company *company : Company::Iterate()) {
432 
433  /* Send the information. */
434  p->Send_uint8(company->index);
435 
436  for (uint i = 0; i < NETWORK_VEH_END; i++) {
437  p->Send_uint16(company_stats[company->index].num_vehicle[i]);
438  }
439 
440  for (uint i = 0; i < NETWORK_VEH_END; i++) {
441  p->Send_uint16(company_stats[company->index].num_station[i]);
442  }
443 
444  this->SendPacket(p);
445  }
446 
448 }
449 
458 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, int64 data)
459 {
461 
462  p->Send_uint8 (action);
463  p->Send_uint8 (desttype);
464  p->Send_uint32(client_id);
465  p->Send_string(msg);
466  p->Send_uint64(data);
467 
468  this->SendPacket(p);
470 }
471 
477 {
479 
480  p->Send_string(command);
481  this->SendPacket(p);
482 
484 }
485 
491 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendRcon(uint16 colour, const std::string_view result)
492 {
494 
495  p->Send_uint16(colour);
496  p->Send_string(result);
497  this->SendPacket(p);
498 
500 }
501 
503 {
504  if (this->status == ADMIN_STATUS_INACTIVE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
505 
506  std::string command = p->Recv_string(NETWORK_RCONCOMMAND_LENGTH);
507 
508  Debug(net, 3, "[admin] Rcon command from '{}' ({}): {}", this->admin_name, this->admin_version, command);
509 
511  IConsoleCmdExec(command.c_str());
513  return this->SendRconEnd(command);
514 }
515 
517 {
518  if (this->status == ADMIN_STATUS_INACTIVE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
519 
520  std::string json = p->Recv_string(NETWORK_GAMESCRIPT_JSON_LENGTH);
521 
522  Debug(net, 6, "[admin] GameScript JSON from '{}' ({}): {}", this->admin_name, this->admin_version, json);
523 
524  Game::NewEvent(new ScriptEventAdminPort(json));
526 }
527 
529 {
530  if (this->status == ADMIN_STATUS_INACTIVE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
531 
532  uint32 d1 = p->Recv_uint32();
533 
534  Debug(net, 6, "[admin] Ping from '{}' ({}): {}", this->admin_name, this->admin_version, d1);
535 
536  return this->SendPong(d1);
537 }
538 
544 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendConsole(const std::string_view origin, const std::string_view string)
545 {
546  /* If the length of both strings, plus the 2 '\0' terminations and 3 bytes of the packet
547  * are bigger than the MTU, just ignore the message. Better safe than sorry. It should
548  * never occur though as the longest strings are chat messages, which are still 30%
549  * smaller than COMPAT_MTU. */
550  if (origin.size() + string.size() + 2 + 3 >= COMPAT_MTU) return NETWORK_RECV_STATUS_OKAY;
551 
553 
554  p->Send_string(origin);
555  p->Send_string(string);
556  this->SendPacket(p);
557 
559 }
560 
566 {
567  /* At the moment we cannot transmit anything larger than MTU. So we limit
568  * the maximum amount of json data that can be sent. Account also for
569  * the trailing \0 of the string */
570  if (json.size() + 1 >= NETWORK_GAMESCRIPT_JSON_LENGTH) return NETWORK_RECV_STATUS_OKAY;
571 
573 
574  p->Send_string(json);
575  this->SendPacket(p);
576 
578 }
579 
582 {
584 
585  p->Send_uint32(d1);
586  this->SendPacket(p);
587 
589 }
590 
593 {
595 
596  for (uint i = 0; i < CMD_END; i++) {
597  const char *cmdname = GetCommandName(i);
598 
599  /* Should COMPAT_MTU be exceeded, start a new packet
600  * (magic 5: 1 bool "more data" and one uint16 "command id", one
601  * byte for string '\0' termination and 1 bool "no more data" */
602  if (!p->CanWriteToPacket(strlen(cmdname) + 5)) {
603  p->Send_bool(false);
604  this->SendPacket(p);
605 
607  }
608 
609  p->Send_bool(true);
610  p->Send_uint16(i);
611  p->Send_string(cmdname);
612  }
613 
614  /* Marker to notify the end of the packet has been reached. */
615  p->Send_bool(false);
616  this->SendPacket(p);
617 
619 }
620 
627 {
629 
630  p->Send_uint32(client_id);
631  p->Send_uint8 (cp->company);
632  p->Send_uint16(cp->cmd & CMD_ID_MASK);
633  p->Send_uint32(cp->p1);
634  p->Send_uint32(cp->p2);
635  p->Send_uint32(cp->tile);
636  p->Send_string(cp->text);
637  p->Send_uint32(cp->frame);
638 
639  this->SendPacket(p);
640 
642 }
643 
644 /***********
645  * Receiving functions
646  ************/
647 
649 {
650  if (this->status != ADMIN_STATUS_INACTIVE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
651 
652  std::string password = p->Recv_string(NETWORK_PASSWORD_LENGTH);
653 
655  _settings_client.network.admin_password.compare(password) != 0) {
656  /* Password is invalid */
657  return this->SendError(NETWORK_ERROR_WRONG_PASSWORD);
658  }
659 
662 
663  if (this->admin_name.empty() || this->admin_version.empty()) {
664  /* no name or version supplied */
665  return this->SendError(NETWORK_ERROR_ILLEGAL_PACKET);
666  }
667 
668  this->status = ADMIN_STATUS_ACTIVE;
669 
670  Debug(net, 3, "[admin] '{}' ({}) has connected", this->admin_name, this->admin_version);
671 
672  return this->SendProtocol();
673 }
674 
676 {
677  /* The admin is leaving nothing else to do */
678  return this->CloseConnection();
679 }
680 
682 {
683  if (this->status == ADMIN_STATUS_INACTIVE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
684 
687 
688  if (type >= ADMIN_UPDATE_END || (_admin_update_type_frequencies[type] & freq) != freq) {
689  /* The server does not know of this UpdateType. */
690  Debug(net, 1, "[admin] Not supported update frequency {} ({}) from '{}' ({})", type, freq, this->admin_name, this->admin_version);
691  return this->SendError(NETWORK_ERROR_ILLEGAL_PACKET);
692  }
693 
694  this->update_frequency[type] = freq;
695 
697 
699 }
700 
702 {
703  if (this->status == ADMIN_STATUS_INACTIVE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
704 
706  uint32 d1 = p->Recv_uint32();
707 
708  switch (type) {
709  case ADMIN_UPDATE_DATE:
710  /* The admin is requesting the current date. */
711  this->SendDate();
712  break;
713 
715  /* The admin is requesting client info. */
716  if (d1 == UINT32_MAX) {
718  for (const NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
719  this->SendClientInfo(cs, cs->GetInfo());
720  }
721  } else {
722  if (d1 == CLIENT_ID_SERVER) {
724  } else {
725  const NetworkClientSocket *cs = NetworkClientSocket::GetByClientID((ClientID)d1);
726  if (cs != nullptr) this->SendClientInfo(cs, cs->GetInfo());
727  }
728  }
729  break;
730 
732  /* The admin is asking for company info. */
733  if (d1 == UINT32_MAX) {
734  for (const Company *company : Company::Iterate()) {
735  this->SendCompanyInfo(company);
736  }
737  } else {
738  const Company *company = Company::GetIfValid(d1);
739  if (company != nullptr) this->SendCompanyInfo(company);
740  }
741  break;
742 
744  /* The admin is requesting economy info. */
745  this->SendCompanyEconomy();
746  break;
747 
749  /* the admin is requesting company stats. */
750  this->SendCompanyStats();
751  break;
752 
754  /* The admin is requesting the names of DoCommands. */
755  this->SendCmdNames();
756  break;
757 
758  default:
759  /* An unsupported "poll" update type. */
760  Debug(net, 1, "[admin] Not supported poll {} ({}) from '{}' ({}).", type, d1, this->admin_name, this->admin_version);
761  return this->SendError(NETWORK_ERROR_ILLEGAL_PACKET);
762  }
763 
765 }
766 
768 {
769  if (this->status == ADMIN_STATUS_INACTIVE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
770 
771  NetworkAction action = (NetworkAction)p->Recv_uint8();
772  DestType desttype = (DestType)p->Recv_uint8();
773  int dest = p->Recv_uint32();
774 
775  std::string msg = p->Recv_string(NETWORK_CHAT_LENGTH);
776 
777  switch (action) {
778  case NETWORK_ACTION_CHAT:
779  case NETWORK_ACTION_CHAT_CLIENT:
780  case NETWORK_ACTION_CHAT_COMPANY:
781  case NETWORK_ACTION_SERVER_MESSAGE:
782  NetworkServerSendChat(action, desttype, dest, msg, _network_own_client_id, 0, true);
783  break;
784 
785  default:
786  Debug(net, 1, "[admin] Invalid chat action {} from admin '{}' ({}).", action, this->admin_name, this->admin_version);
787  return this->SendError(NETWORK_ERROR_ILLEGAL_PACKET);
788  }
789 
791 }
792 
794 {
795  if (this->status == ADMIN_STATUS_INACTIVE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
796 
797  std::string source = p->Recv_string(NETWORK_CHAT_LENGTH);
798  TextColour colour = (TextColour)p->Recv_uint16();
799  std::string user = p->Recv_string(NETWORK_CHAT_LENGTH);
800  std::string msg = p->Recv_string(NETWORK_CHAT_LENGTH);
801 
802  if (!IsValidConsoleColour(colour)) {
803  Debug(net, 1, "[admin] Not supported chat colour {} ({}, {}, {}) from '{}' ({}).", (uint16)colour, source, user, msg, this->admin_name, this->admin_version);
804  return this->SendError(NETWORK_ERROR_ILLEGAL_PACKET);
805  }
806 
807  NetworkServerSendExternalChat(source, colour, user, msg);
808 
810 }
811 
812 /*
813  * Useful wrapper functions
814  */
815 
821 void NetworkAdminClientInfo(const NetworkClientSocket *cs, bool new_client)
822 {
824  if (as->update_frequency[ADMIN_UPDATE_CLIENT_INFO] & ADMIN_FREQUENCY_AUTOMATIC) {
825  as->SendClientInfo(cs, cs->GetInfo());
826  if (new_client) {
827  as->SendClientJoin(cs->client_id);
828  }
829  }
830  }
831 }
832 
838 {
840  if (as->update_frequency[ADMIN_UPDATE_CLIENT_INFO] & ADMIN_FREQUENCY_AUTOMATIC) {
841  as->SendClientUpdate(ci);
842  }
843  }
844 }
845 
851 {
853  if (as->update_frequency[ADMIN_UPDATE_CLIENT_INFO] & ADMIN_FREQUENCY_AUTOMATIC) {
854  as->SendClientQuit(client_id);
855  }
856  }
857 }
858 
865 {
867  if (as->update_frequency[ADMIN_UPDATE_CLIENT_INFO] & ADMIN_FREQUENCY_AUTOMATIC) {
868  as->SendClientError(client_id, error_code);
869  }
870  }
871 }
872 
878 void NetworkAdminCompanyInfo(const Company *company, bool new_company)
879 {
880  if (company == nullptr) {
881  Debug(net, 1, "[admin] Empty company given for update");
882  return;
883  }
884 
886  if (as->update_frequency[ADMIN_UPDATE_COMPANY_INFO] != ADMIN_FREQUENCY_AUTOMATIC) continue;
887 
888  as->SendCompanyInfo(company);
889  if (new_company) {
890  as->SendCompanyNew(company->index);
891  }
892  }
893 }
894 
899 void NetworkAdminCompanyUpdate(const Company *company)
900 {
901  if (company == nullptr) return;
902 
904  if (as->update_frequency[ADMIN_UPDATE_COMPANY_INFO] != ADMIN_FREQUENCY_AUTOMATIC) continue;
905 
906  as->SendCompanyUpdate(company);
907  }
908 }
909 
916 {
918  as->SendCompanyRemove(company_id, bcrr);
919  }
920 }
921 
922 
926 void NetworkAdminChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, int64 data, bool from_admin)
927 {
928  if (from_admin) return;
929 
931  if (as->update_frequency[ADMIN_UPDATE_CHAT] & ADMIN_FREQUENCY_AUTOMATIC) {
932  as->SendChat(action, desttype, client_id, msg, data);
933  }
934  }
935 }
936 
943 void NetworkServerSendAdminRcon(AdminIndex admin_index, TextColour colour_code, const std::string_view string)
944 {
945  ServerNetworkAdminSocketHandler::Get(admin_index)->SendRcon(colour_code, string);
946 }
947 
953 void NetworkAdminConsole(const std::string_view origin, const std::string_view string)
954 {
956  if (as->update_frequency[ADMIN_UPDATE_CONSOLE] & ADMIN_FREQUENCY_AUTOMATIC) {
957  as->SendConsole(origin, string);
958  }
959  }
960 }
961 
966 void NetworkAdminGameScript(const std::string_view json)
967 {
969  if (as->update_frequency[ADMIN_UPDATE_GAMESCRIPT] & ADMIN_FREQUENCY_AUTOMATIC) {
970  as->SendGameScript(json);
971  }
972  }
973 }
974 
980 void NetworkAdminCmdLogging(const NetworkClientSocket *owner, const CommandPacket *cp)
981 {
982  ClientID client_id = owner == nullptr ? _network_own_client_id : owner->client_id;
983 
985  if (as->update_frequency[ADMIN_UPDATE_CMD_LOGGING] & ADMIN_FREQUENCY_AUTOMATIC) {
986  as->SendCmdLogging(client_id, cp);
987  }
988  }
989 }
990 
995 {
997  as->SendWelcome();
998  }
999 }
1000 
1006 {
1008  for (int i = 0; i < ADMIN_UPDATE_END; i++) {
1009  if (as->update_frequency[i] & freq) {
1010  /* Update the admin for the required details */
1011  switch (i) {
1012  case ADMIN_UPDATE_DATE:
1013  as->SendDate();
1014  break;
1015 
1017  as->SendCompanyEconomy();
1018  break;
1019 
1021  as->SendCompanyStats();
1022  break;
1023 
1024  default: NOT_REACHED();
1025  }
1026  }
1027  }
1028  }
1029 }
NetworkCompanyStats::num_station
uint16 num_station[NETWORK_VEH_END]
How many stations are there of this type?
Definition: network_type.h:67
ADMIN_PACKET_SERVER_GAMESCRIPT
@ ADMIN_PACKET_SERVER_GAMESCRIPT
The server gives the admin information from the GameScript in JSON.
Definition: tcp_admin.h:60
CompanyProperties::is_ai
bool is_ai
If true, the company is (also) controlled by the computer (a NoAI program).
Definition: company_base.h:94
NetworkCompanyStats
Simple calculated statistics of a company.
Definition: network_type.h:65
CommandContainer::cmd
uint32 cmd
command being executed.
Definition: command_type.h:483
DestType
DestType
Destination of our chat messages.
Definition: network_type.h:89
ADMIN_UPDATE_CMD_NAMES
@ ADMIN_UPDATE_CMD_NAMES
The admin would like a list of all DoCommand names.
Definition: tcp_admin.h:83
ADMIN_UPDATE_COMPANY_INFO
@ ADMIN_UPDATE_COMPANY_INFO
Updates about the generic information of companies.
Definition: tcp_admin.h:78
ServerNetworkAdminSocketHandler::Receive_ADMIN_UPDATE_FREQUENCY
NetworkRecvStatus Receive_ADMIN_UPDATE_FREQUENCY(Packet *p) override
Register updates to be sent at certain frequencies (as announced in the PROTOCOL packet): uint16 Upda...
Definition: network_admin.cpp:681
GameCreationSettings::generation_seed
uint32 generation_seed
noise seed for world generation
Definition: settings_type.h:305
Pool::PoolItem<&_networkadminsocket_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:337
NetworkAdminSocketHandler::admin_version
std::string admin_version
Version string of the admin.
Definition: tcp_admin.h:114
NetworkAdminUpdate
void NetworkAdminUpdate(AdminUpdateFrequency freq)
Send (push) updates to the admin network as they have registered for these updates.
Definition: network_admin.cpp:1005
NetworkAdminSocketHandler::status
AdminStatus status
Status of this admin.
Definition: tcp_admin.h:115
NetworkAdminSocketHandler::CloseConnection
NetworkRecvStatus CloseConnection(bool error=true) override
This will put this socket handler in a close state.
Definition: tcp_admin.cpp:35
Pool::PoolItem<&_company_pool >::GetIfValid
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:348
NetworkServerSendChat
void NetworkServerSendChat(NetworkAction action, DestType type, int dest, const std::string &msg, ClientID from_id, int64 data=0, bool from_admin=false)
Send an actual chat message.
Definition: network_server.cpp:1182
NetworkClientInfo::client_name
std::string client_name
Name of the client.
Definition: network_base.h:26
NetworkAdminChat
void NetworkAdminChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, int64 data, bool from_admin)
Send chat to the admin network (if they did opt in for the respective update).
Definition: network_admin.cpp:926
GameCreationSettings::landscape
byte landscape
the landscape we're currently in
Definition: settings_type.h:321
ADMIN_PACKET_SERVER_CLIENT_QUIT
@ ADMIN_PACKET_SERVER_CLIENT_QUIT
The server tells the admin that a client quit.
Definition: tcp_admin.h:47
ServerNetworkAdminSocketHandler::SendError
NetworkRecvStatus SendError(NetworkErrorCode error)
Send an error to the admin.
Definition: network_admin.cpp:134
ServerNetworkAdminSocketHandler::SendRconEnd
NetworkRecvStatus SendRconEnd(const std::string_view command)
Send a notification indicating the rcon command has completed.
Definition: network_admin.cpp:476
ADMIN_UPDATE_CLIENT_INFO
@ ADMIN_UPDATE_CLIENT_INFO
Updates about the information of clients.
Definition: tcp_admin.h:77
ADMIN_PACKET_SERVER_COMPANY_INFO
@ ADMIN_PACKET_SERVER_COMPANY_INFO
The server gives the admin information about a company.
Definition: tcp_admin.h:50
NetworkClientInfo::client_playas
CompanyID client_playas
As which company is this client playing (CompanyID)
Definition: network_base.h:27
NetworkAdminSocketHandler::admin_name
std::string admin_name
Name of the admin.
Definition: tcp_admin.h:113
ServerNetworkAdminSocketHandler::SendCompanyEconomy
NetworkRecvStatus SendCompanyEconomy()
Send economic information of all companies.
Definition: network_admin.cpp:389
ServerNetworkAdminSocketHandler::SendRcon
NetworkRecvStatus SendRcon(uint16 colour, const std::string_view command)
Send the reply of an rcon command.
Definition: network_admin.cpp:491
CompanyProperties::inaugurated_year
Year inaugurated_year
Year of starting the company.
Definition: company_base.h:79
ServerNetworkAdminSocketHandler::update_frequency
AdminUpdateFrequency update_frequency[ADMIN_UPDATE_END]
Admin requested update intervals.
Definition: network_admin.h:40
ADMIN_UPDATE_CONSOLE
@ ADMIN_UPDATE_CONSOLE
The admin would like to have console messages.
Definition: tcp_admin.h:82
ADMIN_PACKET_SERVER_PONG
@ ADMIN_PACKET_SERVER_PONG
The server replies to a ping request from the admin.
Definition: tcp_admin.h:62
GetCommandName
const char * GetCommandName(uint32 cmd)
Definition: command.cpp:407
NetworkAction
NetworkAction
Actions that can be used for NetworkTextMessage.
Definition: network_type.h:99
ADMIN_UPDATE_CHAT
@ ADMIN_UPDATE_CHAT
The admin would like to have chat messages.
Definition: tcp_admin.h:81
CommandPacket::frame
uint32 frame
the frame in which this packet is executed
Definition: network_internal.h:112
Pool::PoolItem<&_networkadminsocket_pool >::index
Tindex index
Index of this pool item.
Definition: pool_type.hpp:235
NetworkPopulateCompanyStats
void NetworkPopulateCompanyStats(NetworkCompanyStats *stats)
Populate the company stats.
Definition: network_server.cpp:1434
ServerNetworkAdminSocketHandler::WelcomeAll
static void WelcomeAll()
Send a Welcome packet to all connected admins.
Definition: network_admin.cpp:994
NETWORK_CHAT_LENGTH
static const uint NETWORK_CHAT_LENGTH
The maximum length of a chat message, in bytes including '\0'.
Definition: config.h:66
ServerNetworkAdminSocketHandler::Receive_ADMIN_JOIN
NetworkRecvStatus Receive_ADMIN_JOIN(Packet *p) override
Join the admin network: string Password the server is expecting for this network.
Definition: network_admin.cpp:648
ADMIN_PACKET_SERVER_NEWGAME
@ ADMIN_PACKET_SERVER_NEWGAME
The server tells the admin its going to start a new game.
Definition: tcp_admin.h:40
NetworkClientInfo::join_date
Date join_date
Gamedate the client has joined.
Definition: network_base.h:28
ADMIN_FREQUENCY_DAILY
@ ADMIN_FREQUENCY_DAILY
The admin gets information about this on a daily basis.
Definition: tcp_admin.h:92
TextColour
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Definition: gfx_type.h:250
CommandContainer::p2
uint32 p2
parameter p2.
Definition: command_type.h:482
GetNetworkRevisionString
std::string_view GetNetworkRevisionString()
Get the network version string used by this build.
Definition: game_info.cpp:43
ServerNetworkAdminSocketHandler::IterateActive
static Pool::IterateWrapperFiltered< ServerNetworkAdminSocketHandler, ServerNetworkAdminSocketHandlerFilter > IterateActive(size_t from=0)
Returns an iterable ensemble of all active admin sockets.
Definition: network_admin.h:96
ADMIN_PACKET_SERVER_CHAT
@ ADMIN_PACKET_SERVER_CHAT
The server received a chat message and relays it.
Definition: tcp_admin.h:55
ADMIN_PACKET_SERVER_COMPANY_NEW
@ ADMIN_PACKET_SERVER_COMPANY_NEW
The server tells the admin that a new company has started.
Definition: tcp_admin.h:49
ServerNetworkAdminSocketHandler::SendCompanyUpdate
NetworkRecvStatus SendCompanyUpdate(const Company *c)
Send an update about a company.
Definition: network_admin.cpp:349
ADMIN_PACKET_SERVER_PROTOCOL
@ ADMIN_PACKET_SERVER_PROTOCOL
The server tells the admin its protocol version.
Definition: tcp_admin.h:38
ADMIN_UPDATE_CMD_LOGGING
@ ADMIN_UPDATE_CMD_LOGGING
The admin would like to have DoCommand information.
Definition: tcp_admin.h:84
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:52
ADMIN_FREQUENCY_MONTHLY
@ ADMIN_FREQUENCY_MONTHLY
The admin gets information about this on a monthly basis.
Definition: tcp_admin.h:94
GetNetworkErrorMsg
StringID GetNetworkErrorMsg(NetworkErrorCode err)
Retrieve the string id of an internal error number.
Definition: network.cpp:300
ADMIN_PACKET_SERVER_COMPANY_STATS
@ ADMIN_PACKET_SERVER_COMPANY_STATS
The server gives the admin some statistics about a company.
Definition: tcp_admin.h:54
NETWORK_CLIENT_NAME_LENGTH
static const uint NETWORK_CLIENT_NAME_LENGTH
The maximum length of a client's name, in bytes including '\0'.
Definition: config.h:63
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:18
NETWORK_GAME_ADMIN_VERSION
static const byte NETWORK_GAME_ADMIN_VERSION
What version of the admin network do we use?
Definition: config.h:50
Packet::Send_uint8
void Send_uint8(uint8 data)
Package a 8 bits integer in the packet.
Definition: packet.cpp:129
ServerNetworkAdminSocketHandler::SendCompanyInfo
NetworkRecvStatus SendCompanyInfo(const Company *c)
Send the admin some information about a company.
Definition: network_admin.cpp:320
ServerNetworkAdminSocketHandler::address
NetworkAddress address
Address of the admin.
Definition: network_admin.h:42
SetDParam
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings_func.h:196
INVALID_ADMIN_ID
static const AdminIndex INVALID_ADMIN_ID
An invalid admin marker.
Definition: network_type.h:62
NetworkAdminClientQuit
void NetworkAdminClientQuit(ClientID client_id)
Notify the admin network that a client quit (if they have opt in for the respective update).
Definition: network_admin.cpp:850
_redirect_console_to_admin
AdminIndex _redirect_console_to_admin
Redirection of the (remote) console to the admin.
Definition: network_admin.cpp:31
_networkadminsocket_pool
NetworkAdminSocketPool _networkadminsocket_pool("NetworkAdminSocket")
The pool with sockets/clients.
ServerNetworkAdminSocketHandler::Send
static void Send()
Send the packets for the server sockets.
Definition: network_admin.cpp:101
network_base.h
NetworkAdminClientInfo
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).
Definition: network_admin.cpp:821
GameSettings::game_creation
GameCreationSettings game_creation
settings used during the creation of a game (map)
Definition: settings_type.h:577
Packet::Send_uint32
void Send_uint32(uint32 data)
Package a 32 bits integer in the packet.
Definition: packet.cpp:150
Packet::Recv_string
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...
Definition: packet.cpp:380
NetworkAdminConsole
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).
Definition: network_admin.cpp:953
MapSizeX
static uint MapSizeX()
Get the size of the map along the X.
Definition: map_func.h:72
CommandContainer::text
std::string text
possible text sent for name changes etc.
Definition: command_type.h:485
Pool::MAX_SIZE
static constexpr size_t MAX_SIZE
Make template parameter accessible from outside.
Definition: pool_type.hpp:85
NetworkClientInfo::GetByClientID
static NetworkClientInfo * GetByClientID(ClientID client_id)
Return the CI given it's client-identifier.
Definition: network.cpp:113
NetworkAdminGameScript
void NetworkAdminGameScript(const std::string_view json)
Send GameScript JSON to the admin network (if they did opt in for the respective update).
Definition: network_admin.cpp:966
ADMIN_FREQUENCY_QUARTERLY
@ ADMIN_FREQUENCY_QUARTERLY
The admin gets information about this on a quarterly basis.
Definition: tcp_admin.h:95
CommandPacket::company
CompanyID company
company that is executing the command
Definition: network_internal.h:111
ADMIN_STATUS_INACTIVE
@ ADMIN_STATUS_INACTIVE
The admin is not connected nor active.
Definition: tcp_admin.h:69
ADMIN_PACKET_SERVER_DATE
@ ADMIN_PACKET_SERVER_DATE
The server tells the admin what the current game date is.
Definition: tcp_admin.h:43
ADMIN_PACKET_SERVER_ERROR
@ ADMIN_PACKET_SERVER_ERROR
The server tells the admin an error has occurred.
Definition: tcp_admin.h:37
CommandContainer::p1
uint32 p1
parameter p1.
Definition: command_type.h:481
ServerNetworkAdminSocketHandler::SendShutdown
NetworkRecvStatus SendShutdown()
Tell the admin we're shutting down.
Definition: network_admin.cpp:198
NetworkCompanyStats::num_vehicle
uint16 num_vehicle[NETWORK_VEH_END]
How many vehicles are there of this type?
Definition: network_type.h:66
Packet::Recv_uint32
uint32 Recv_uint32()
Read a 32 bits integer from the packet.
Definition: packet.cpp:335
CompanyProperties::colour
byte colour
Company colour.
Definition: company_base.h:70
ServerNetworkAdminSocketHandler::connect_time
std::chrono::steady_clock::time_point connect_time
Time of connection.
Definition: network_admin.h:41
CommandPacket
Everything we need to know about a command to be able to execute it.
Definition: network_internal.h:107
_date
Date _date
Current date in days (day counter)
Definition: date.cpp:28
COMPAT_MTU
static const uint16 COMPAT_MTU
Number of bytes we can pack in a single packet for backward compatibility.
Definition: config.h:48
MAX_ADMINS
static const AdminIndex MAX_ADMINS
Maximum number of allowed admins.
Definition: network_type.h:60
ServerNetworkAdminSocketHandler::SendConsole
NetworkRecvStatus SendConsole(const std::string_view origin, const std::string_view command)
Send console output of other clients.
Definition: network_admin.cpp:544
CompanyProperties::months_of_bankruptcy
byte months_of_bankruptcy
Number of months that the company is unable to pay its debts.
Definition: company_base.h:81
ServerNetworkAdminSocketHandler::SendCompanyRemove
NetworkRecvStatus SendCompanyRemove(CompanyID company_id, AdminCompanyRemoveReason bcrr)
Tell the admin that a company got removed.
Definition: network_admin.cpp:376
ConvertYMDToDate
Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
Definition: date.cpp:149
ClientID
ClientID
'Unique' identifier to be given to clients
Definition: network_type.h:47
NetworkAdminSocketHandler
Main socket handler for admin related connections.
Definition: tcp_admin.h:111
ADMIN_PACKET_SERVER_COMPANY_REMOVE
@ ADMIN_PACKET_SERVER_COMPANY_REMOVE
The server tells the admin that a company was removed.
Definition: tcp_admin.h:52
NetworkSettings::admin_password
std::string admin_password
password for the admin network
Definition: settings_type.h:284
ADMIN_FREQUENCY_POLL
@ ADMIN_FREQUENCY_POLL
The admin can poll this.
Definition: tcp_admin.h:91
ADMIN_PACKET_SERVER_CLIENT_ERROR
@ ADMIN_PACKET_SERVER_CLIENT_ERROR
The server tells the admin that a client caused an error.
Definition: tcp_admin.h:48
ADMIN_UPDATE_DATE
@ ADMIN_UPDATE_DATE
Updates about the date of the game.
Definition: tcp_admin.h:76
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:53
ServerNetworkAdminSocketHandler::AllowConnection
static bool AllowConnection()
Whether a connection is allowed or not at this moment.
Definition: network_admin.cpp:90
ServerNetworkAdminSocketHandler::SendWelcome
NetworkRecvStatus SendWelcome()
Send a welcome message to the admin.
Definition: network_admin.cpp:169
Game::NewEvent
static void NewEvent(class ScriptEvent *event)
Queue a new event for a Game Script.
Definition: game_core.cpp:141
ServerNetworkAdminSocketHandler::SendGameScript
NetworkRecvStatus SendGameScript(const std::string_view json)
Send GameScript JSON output.
Definition: network_admin.cpp:565
MAX_COMPANIES
@ MAX_COMPANIES
Maximum number of companies.
Definition: company_type.h:23
ADMIN_UPDATE_COMPANY_STATS
@ ADMIN_UPDATE_COMPANY_STATS
Updates about the statistics of companies.
Definition: tcp_admin.h:80
IsValidConsoleColour
bool IsValidConsoleColour(TextColour c)
Check whether the given TextColour is valid for console usage.
Definition: console_gui.cpp:524
ADMIN_UPDATE_COMPANY_ECONOMY
@ ADMIN_UPDATE_COMPANY_ECONOMY
Updates about the economy of companies.
Definition: tcp_admin.h:79
Packet::Send_uint16
void Send_uint16(uint16 data)
Package a 16 bits integer in the packet.
Definition: packet.cpp:139
NetworkTCPSocketHandler::SendPacket
virtual void SendPacket(Packet *packet)
This function puts the packet in the send-queue and it is send as soon as possible.
Definition: tcp.cpp:81
CLIENT_ID_SERVER
@ CLIENT_ID_SERVER
Servers always have this ID.
Definition: network_type.h:49
ServerNetworkAdminSocketHandler::~ServerNetworkAdminSocketHandler
~ServerNetworkAdminSocketHandler()
Clear everything related to this admin.
Definition: network_admin.cpp:74
ADMIN_PACKET_SERVER_RCON
@ ADMIN_PACKET_SERVER_RCON
The server's reply to a remove console command.
Definition: tcp_admin.h:56
ServerNetworkAdminSocketHandler::SendClientQuit
NetworkRecvStatus SendClientQuit(ClientID client_id)
Tell the admin that a client quit.
Definition: network_admin.cpp:276
AdminCompanyRemoveReason
AdminCompanyRemoveReason
Reasons for removing a company - communicated to admins.
Definition: tcp_admin.h:102
ADMIN_PACKET_SERVER_CONSOLE
@ ADMIN_PACKET_SERVER_CONSOLE
The server gives the admin the data that got printed to its console.
Definition: tcp_admin.h:57
ADMIN_PACKET_SERVER_CLIENT_UPDATE
@ ADMIN_PACKET_SERVER_CLIENT_UPDATE
The server gives the admin an information update on a client.
Definition: tcp_admin.h:46
MapSizeY
static uint MapSizeY()
Get the size of the map along the Y.
Definition: map_func.h:82
CompanyProperties::share_owners
Owner share_owners[4]
Owners of the 4 shares of the company. INVALID_OWNER if nobody has bought them yet.
Definition: company_base.h:77
network_server.h
_network_dedicated
bool _network_dedicated
are we a dedicated server?
Definition: network.cpp:60
ADMIN_UPDATE_GAMESCRIPT
@ ADMIN_UPDATE_GAMESCRIPT
The admin would like to have gamescript messages.
Definition: tcp_admin.h:85
Packet
Internal entity of a packet.
Definition: packet.h:44
ADMIN_FREQUENCY_ANUALLY
@ ADMIN_FREQUENCY_ANUALLY
The admin gets information about this on a yearly basis.
Definition: tcp_admin.h:96
ServerNetworkAdminSocketHandler::SendCmdNames
NetworkRecvStatus SendCmdNames()
Send the names of the commands.
Definition: network_admin.cpp:592
NetworkAdminCompanyRemove
void NetworkAdminCompanyRemove(CompanyID company_id, AdminCompanyRemoveReason bcrr)
Notify the admin network of a company to be removed (including the reason why).
Definition: network_admin.cpp:915
NETWORK_REVISION_LENGTH
static const uint NETWORK_REVISION_LENGTH
The maximum length of the revision, in bytes including '\0'.
Definition: config.h:60
NetworkCompanyIsPassworded
bool NetworkCompanyIsPassworded(CompanyID company_id)
Check if the company we want to join requires a password.
Definition: network.cpp:212
AdminUpdateType
AdminUpdateType
Update types an admin can register a frequency for.
Definition: tcp_admin.h:75
NetworkClientInfo::client_id
ClientID client_id
Client identifier (same as ClientState->client_id)
Definition: network_base.h:25
ADMIN_PACKET_SERVER_RCON_END
@ ADMIN_PACKET_SERVER_RCON_END
The server indicates that the remote console command has completed.
Definition: tcp_admin.h:61
NETWORK_PASSWORD_LENGTH
static const uint NETWORK_PASSWORD_LENGTH
The maximum length of the password, in bytes including '\0' (must be >= NETWORK_SERVER_ID_LENGTH)
Definition: config.h:61
ServerNetworkAdminSocketHandler::SendNewGame
NetworkRecvStatus SendNewGame()
Tell the admin we started a new game.
Definition: network_admin.cpp:190
Packet::Send_bool
void Send_bool(bool data)
Package a boolean in the packet.
Definition: packet.cpp:120
_network_own_client_id
ClientID _network_own_client_id
Our client identifier.
Definition: network.cpp:63
NetworkAdminCompanyUpdate
void NetworkAdminCompanyUpdate(const Company *company)
Notify the admin network of company updates.
Definition: network_admin.cpp:899
NetworkSettings::server_name
std::string server_name
name of the server
Definition: settings_type.h:281
ADMIN_PACKET_SERVER_CLIENT_JOIN
@ ADMIN_PACKET_SERVER_CLIENT_JOIN
The server tells the admin that a client has joined.
Definition: tcp_admin.h:44
NetworkAddress
Wrapper for (un)resolved network addresses; there's no reason to transform a numeric IP to a string a...
Definition: address.h:30
NETWORK_RCONCOMMAND_LENGTH
static const uint NETWORK_RCONCOMMAND_LENGTH
The maximum length of a rconsole command, in bytes including '\0'.
Definition: config.h:64
Pool::PoolItem<&_networkadminsocket_pool >::Iterate
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Definition: pool_type.hpp:386
ServerNetworkAdminSocketHandler::SendDate
NetworkRecvStatus SendDate()
Tell the admin the date.
Definition: network_admin.cpp:206
ServerNetworkAdminSocketHandler::SendCompanyNew
NetworkRecvStatus SendCompanyNew(CompanyID company_id)
Tell the admin that a new company was founded.
Definition: network_admin.cpp:306
Pool
Base class for all pools.
Definition: pool_type.hpp:81
ADMIN_PACKET_SERVER_CMD_NAMES
@ ADMIN_PACKET_SERVER_CMD_NAMES
The server sends out the names of the DoCommands to the admins.
Definition: tcp_admin.h:58
ServerNetworkAdminSocketHandler::Receive_ADMIN_QUIT
NetworkRecvStatus Receive_ADMIN_QUIT(Packet *p) override
Notification to the server that this admin is quitting.
Definition: network_admin.cpp:675
ADMIN_PACKET_SERVER_CLIENT_INFO
@ ADMIN_PACKET_SERVER_CLIENT_INFO
The server gives the admin information about a client.
Definition: tcp_admin.h:45
CMD_ID_MASK
@ CMD_ID_MASK
mask for the command ID
Definition: command_type.h:382
ServerNetworkAdminSocketHandler::SendPong
NetworkRecvStatus SendPong(uint32 d1)
Send ping-reply (pong) to admin.
Definition: network_admin.cpp:581
Packet::CanWriteToPacket
bool CanWriteToPacket(size_t bytes_to_write)
Is it safe to write to the packet, i.e.
Definition: packet.cpp:99
Packet::Send_uint64
void Send_uint64(uint64 data)
Package a 64 bits integer in the packet.
Definition: packet.cpp:163
ServerNetworkAdminSocketHandler::SendChat
NetworkRecvStatus SendChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, int64 data)
Send a chat message.
Definition: network_admin.cpp:458
ServerNetworkAdminSocketHandler::ServerNetworkAdminSocketHandler
ServerNetworkAdminSocketHandler(SOCKET s)
Sanity check.
Definition: network_admin.cpp:64
ServerNetworkAdminSocketHandler
Class for handling the server side of the game connection.
Definition: network_admin.h:25
NetworkRecvStatus
NetworkRecvStatus
Status of a network client; reasons why a client has quit.
Definition: core.h:22
ServerNetworkAdminSocketHandler::Receive_ADMIN_POLL
NetworkRecvStatus Receive_ADMIN_POLL(Packet *p) override
Poll the server for certain updates, an invalid poll (e.g.
Definition: network_admin.cpp:701
ServerNetworkAdminSocketHandler::SendClientInfo
NetworkRecvStatus SendClientInfo(const NetworkClientSocket *cs, const NetworkClientInfo *ci)
Send an initial set of data from some client's information.
Definition: network_admin.cpp:235
ADMIN_FREQUENCY_AUTOMATIC
@ ADMIN_FREQUENCY_AUTOMATIC
The admin gets information about this when it changes.
Definition: tcp_admin.h:97
NetworkServerSendExternalChat
void NetworkServerSendExternalChat(const std::string &source, TextColour colour, const std::string &user, const std::string &msg)
Send a chat message from external source.
Definition: network_server.cpp:1300
ADMIN_STATUS_ACTIVE
@ ADMIN_STATUS_ACTIVE
The admin is active.
Definition: tcp_admin.h:70
ADMIN_PACKET_SERVER_COMPANY_UPDATE
@ ADMIN_PACKET_SERVER_COMPANY_UPDATE
The server gives the admin an information update on a company.
Definition: tcp_admin.h:51
ServerNetworkAdminSocketHandler::SendProtocol
NetworkRecvStatus SendProtocol()
Send the protocol version to the admin.
Definition: network_admin.cpp:149
ServerNetworkAdminSocketHandler::Receive_ADMIN_PING
NetworkRecvStatus Receive_ADMIN_PING(Packet *p) override
Ping the server, requiring the server to reply with a pong packet.
Definition: network_admin.cpp:528
NetworkAddress::GetHostname
const std::string & GetHostname()
Get the hostname; in case it wasn't given the IPv4 dotted representation is given.
Definition: address.cpp:23
Pool::PoolItem<&_networkadminsocket_pool >::CanAllocateItem
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
Definition: pool_type.hpp:307
ADMIN_PACKET_SERVER_WELCOME
@ ADMIN_PACKET_SERVER_WELCOME
The server welcomes the admin to a game.
Definition: tcp_admin.h:39
game_info.h
GameCreationSettings::starting_year
Year starting_year
starting date
Definition: settings_type.h:306
Packet::Recv_uint8
uint8 Recv_uint8()
Read a 8 bits integer from the packet.
Definition: packet.cpp:306
ServerNetworkAdminSocketHandler::AcceptConnection
static void AcceptConnection(SOCKET s, const NetworkAddress &address)
Handle the acception of a connection.
Definition: network_admin.cpp:120
ServerNetworkAdminSocketHandler::SendClientUpdate
NetworkRecvStatus SendClientUpdate(const NetworkClientInfo *ci)
Send an update for some client's information.
Definition: network_admin.cpp:259
INSTANTIATE_POOL_METHODS
#define INSTANTIATE_POOL_METHODS(name)
Force instantiation of pool methods so we don't get linker errors.
Definition: pool_func.hpp:224
ADMIN_PACKET_SERVER_COMPANY_ECONOMY
@ ADMIN_PACKET_SERVER_COMPANY_ECONOMY
The server gives the admin some economy related company information.
Definition: tcp_admin.h:53
error
void CDECL error(const char *s,...)
Error handling for fatal non-user errors.
Definition: openttd.cpp:132
ADMIN_PACKET_SERVER_CMD_LOGGING
@ ADMIN_PACKET_SERVER_CMD_LOGGING
The server gives the admin copies of incoming command packets.
Definition: tcp_admin.h:59
Packet::Send_string
void Send_string(const std::string_view data)
Sends a string over the network.
Definition: packet.cpp:181
AdminIndex
uint8 AdminIndex
Indices into the admin tables.
Definition: network_type.h:57
Debug
#define Debug(name, level, format_string,...)
Ouptut a line of debugging information.
Definition: debug.h:37
NetworkAdminClientUpdate
void NetworkAdminClientUpdate(const NetworkClientInfo *ci)
Notify the admin network of a client update (if they did opt in for the respective update).
Definition: network_admin.cpp:837
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:378
ClientSettings::network
NetworkSettings network
settings related to the network
Definition: settings_type.h:595
OverflowSafeInt< int64 >
_network_admins_connected
byte _network_admins_connected
The amount of admins connected.
Definition: network_admin.cpp:34
IConsoleCmdExec
void IConsoleCmdExec(const char *cmdstr, const uint recurse_count)
Execute a given command passed to us.
Definition: console.cpp:302
ServerNetworkAdminSocketHandler::Receive_ADMIN_EXTERNAL_CHAT
NetworkRecvStatus Receive_ADMIN_EXTERNAL_CHAT(Packet *p) override
Send chat from the external source: string Name of the source this message came from.
Definition: network_admin.cpp:793
NETWORK_RECV_STATUS_OKAY
@ NETWORK_RECV_STATUS_OKAY
Everything is okay.
Definition: core.h:23
CeilDiv
static uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
Definition: math_func.hpp:254
ADMIN_FREQUENCY_WEEKLY
@ ADMIN_FREQUENCY_WEEKLY
The admin gets information about this on a weekly basis.
Definition: tcp_admin.h:93
ServerNetworkAdminSocketHandler::Receive_ADMIN_RCON
NetworkRecvStatus Receive_ADMIN_RCON(Packet *p) override
Execute a command on the servers console: string Command to be executed.
Definition: network_admin.cpp:502
_admin_update_type_frequencies
static const AdminUpdateFrequency _admin_update_type_frequencies[]
Frequencies, which may be registered for a certain update type.
Definition: network_admin.cpp:45
CMD_END
@ CMD_END
Must ALWAYS be on the end of this list!! (period)
Definition: command_type.h:338
ServerNetworkAdminSocketHandler::Receive_ADMIN_CHAT
NetworkRecvStatus Receive_ADMIN_CHAT(Packet *p) override
Send chat as the server: uint8 Action such as NETWORK_ACTION_CHAT_CLIENT (see NetworkAction).
Definition: network_admin.cpp:767
NetworkAdminCmdLogging
void NetworkAdminCmdLogging(const NetworkClientSocket *owner, const CommandPacket *cp)
Distribute CommandPacket details over the admin network for logging purposes.
Definition: network_admin.cpp:980
ServerNetworkAdminSocketHandler::Receive_ADMIN_GAMESCRIPT
NetworkRecvStatus Receive_ADMIN_GAMESCRIPT(Packet *p) override
Send a JSON string to the current active GameScript.
Definition: network_admin.cpp:516
network_admin.h
CommandContainer::tile
TileIndex tile
tile command being executed on.
Definition: command_type.h:480
ServerNetworkAdminSocketHandler::SendCompanyStats
NetworkRecvStatus SendCompanyStats()
Send statistics about the companies.
Definition: network_admin.cpp:423
NETWORK_GAMESCRIPT_JSON_LENGTH
static const uint NETWORK_GAMESCRIPT_JSON_LENGTH
The maximum length of a gamescript json string, in bytes including '\0'. Must not be longer than COMP...
Definition: config.h:65
ADMIN_AUTHORISATION_TIMEOUT
static const std::chrono::seconds ADMIN_AUTHORISATION_TIMEOUT(10)
The timeout for authorisation of the client.
ADMIN_UPDATE_END
@ ADMIN_UPDATE_END
Must ALWAYS be on the end of this list!! (period)
Definition: tcp_admin.h:86
Company
Definition: company_base.h:115
AdminUpdateFrequency
AdminUpdateFrequency
Update frequencies an admin can register.
Definition: tcp_admin.h:90
ServerNetworkAdminSocketHandler::SendClientJoin
NetworkRecvStatus SendClientJoin(ClientID client_id)
Tell the admin that a client joined.
Definition: network_admin.cpp:220
DebugReconsiderSendRemoteMessages
void DebugReconsiderSendRemoteMessages()
Reconsider whether we need to send debug messages to either NetworkAdminConsole or IConsolePrint.
Definition: debug.cpp:282
NetworkAdminCompanyInfo
void NetworkAdminCompanyInfo(const Company *company, bool new_company)
Notify the admin network of company details.
Definition: network_admin.cpp:878
NetworkErrorCode
NetworkErrorCode
The error codes we send around in the protocols.
Definition: network_type.h:119
NetworkClientInfo
Container for all information known about a client.
Definition: network_base.h:24
NetworkAdminClientError
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).
Definition: network_admin.cpp:864
Packet::Recv_uint16
uint16 Recv_uint16()
Read a 16 bits integer from the packet.
Definition: packet.cpp:320
ServerNetworkAdminSocketHandler::SendClientError
NetworkRecvStatus SendClientError(ClientID client_id, NetworkErrorCode error)
Tell the admin that a client made an error.
Definition: network_admin.cpp:291
ADMIN_PACKET_SERVER_SHUTDOWN
@ ADMIN_PACKET_SERVER_SHUTDOWN
The server tells the admin its shutting down.
Definition: tcp_admin.h:41
NetworkServerSendAdminRcon
void NetworkServerSendAdminRcon(AdminIndex admin_index, TextColour colour_code, const std::string_view string)
Pass the rcon reply to the admin.
Definition: network_admin.cpp:943
ServerNetworkAdminSocketHandler::SendCmdLogging
NetworkRecvStatus SendCmdLogging(ClientID client_id, const CommandPacket *cp)
Send a command for logging purposes.
Definition: network_admin.cpp:626