Server part of the network protocol. More...
#include "../stdafx.h"#include "../strings_func.h"#include "../date_func.h"#include "network_admin.h"#include "network_server.h"#include "network_udp.h"#include "network_base.h"#include "../console_func.h"#include "../company_base.h"#include "../command_func.h"#include "../saveload/saveload.h"#include "../saveload/saveload_filter.h"#include "../station_base.h"#include "../genworld.h"#include "../company_func.h"#include "../company_gui.h"#include "../window_func.h"#include "../roadveh.h"#include "../order_backup.h"#include "../core/pool_func.hpp"#include "../core/random_func.hpp"#include "../rev.h"Go to the source code of this file.
Data Structures | |
| struct | PacketWriter |
| Writing a savegame directly to a number of packets. More... | |
Functions | |
| assert_compile (MAX_CLIENT_SLOTS > MAX_CLIENTS) | |
| Make very sure the preconditions given in network_type.h are actually followed. | |
| assert_compile (NetworkClientSocketPool::MAX_SIZE==MAX_CLIENT_SLOTS) | |
| static void | NetworkHandleCommandQueue (NetworkClientSocket *cs) |
| DEF_GAME_RECEIVE_COMMAND (Server, PACKET_CLIENT_COMPANY_INFO) | |
| DEF_GAME_RECEIVE_COMMAND (Server, PACKET_CLIENT_NEWGRFS_CHECKED) | |
| DEF_GAME_RECEIVE_COMMAND (Server, PACKET_CLIENT_JOIN) | |
| DEF_GAME_RECEIVE_COMMAND (Server, PACKET_CLIENT_GAME_PASSWORD) | |
| DEF_GAME_RECEIVE_COMMAND (Server, PACKET_CLIENT_COMPANY_PASSWORD) | |
| DEF_GAME_RECEIVE_COMMAND (Server, PACKET_CLIENT_GETMAP) | |
| DEF_GAME_RECEIVE_COMMAND (Server, PACKET_CLIENT_MAP_OK) | |
| DEF_GAME_RECEIVE_COMMAND (Server, PACKET_CLIENT_COMMAND) | |
| The client has done a command and wants us to handle it. | |
| DEF_GAME_RECEIVE_COMMAND (Server, PACKET_CLIENT_ERROR) | |
| DEF_GAME_RECEIVE_COMMAND (Server, PACKET_CLIENT_QUIT) | |
| DEF_GAME_RECEIVE_COMMAND (Server, PACKET_CLIENT_ACK) | |
| void | NetworkServerSendChat (NetworkAction action, DestType desttype, int dest, const char *msg, ClientID from_id, int64 data, bool from_admin) |
| DEF_GAME_RECEIVE_COMMAND (Server, PACKET_CLIENT_CHAT) | |
| DEF_GAME_RECEIVE_COMMAND (Server, PACKET_CLIENT_SET_PASSWORD) | |
| DEF_GAME_RECEIVE_COMMAND (Server, PACKET_CLIENT_SET_NAME) | |
| DEF_GAME_RECEIVE_COMMAND (Server, PACKET_CLIENT_RCON) | |
| DEF_GAME_RECEIVE_COMMAND (Server, PACKET_CLIENT_MOVE) | |
| void | NetworkPopulateCompanyStats (NetworkCompanyStats *stats) |
| Populate the company stats. | |
| void | NetworkUpdateClientInfo (ClientID client_id) |
| static void | NetworkCheckRestartMap () |
| static void | NetworkAutoCleanCompanies () |
| bool | NetworkFindName (char new_name[NETWORK_CLIENT_NAME_LENGTH]) |
| bool | NetworkServerChangeClientName (ClientID client_id, const char *new_name) |
| Change the client name of the given client. | |
| void | NetworkServerSetCompanyPassword (CompanyID company_id, const char *password, bool already_hashed) |
| Set/Reset a company password on the server end. | |
| void | NetworkServer_Tick (bool send_frame) |
| void | NetworkServerYearlyLoop () |
| Yearly "callback". | |
| void | NetworkServerMonthlyLoop () |
| Monthly "callback". | |
| void | NetworkServerDailyLoop () |
| Daily "callback". | |
| void | NetworkServerShowStatusToConsole () |
| void | NetworkServerSendConfigUpdate () |
| Send Config Update. | |
| void | NetworkServerUpdateCompanyPassworded (CompanyID company_id, bool passworded) |
| void | NetworkServerDoMove (ClientID client_id, CompanyID company_id) |
| Handle the tid-bits of moving a client from one company to another. | |
| void | NetworkServerSendRcon (ClientID client_id, TextColour colour_code, const char *string) |
| static void | NetworkServerSendError (ClientID client_id, NetworkErrorCode error) |
| void | NetworkServerKickClient (ClientID client_id) |
| uint | NetworkServerKickOrBanIP (ClientID client_id, bool ban) |
| uint | NetworkServerKickOrBanIP (const char *ip, bool ban) |
| bool | NetworkCompanyHasClients (CompanyID company) |
| void | NetworkPrintClients () |
| Print all the clients to the console. | |
Variables | |
| static ClientID | _network_client_id = CLIENT_ID_FIRST |
| The identifier counter for new clients (is never decreased). | |
| NetworkClientSocketPool | _networkclientsocket_pool ("NetworkClientSocket") |
Server part of the network protocol.
Definition in file network_server.cpp.
| DEF_GAME_RECEIVE_COMMAND | ( | Server | , | |
| PACKET_CLIENT_COMMAND | ||||
| ) |
The client has done a command and wants us to handle it.
| p | the packet in which the command was sent |
Only CMD_COMPANY_CTRL is always allowed, for the rest, playas needs to match the company in the packet. If it doesn't, the client has done something pretty naughty (or a bug), and will be kicked
Definition at line 1000 of file network_server.cpp.
References _settings_client, CC_ERROR, NetworkClientInfo::client_id, CLIENT_ID_SERVER, NetworkClientInfo::client_playas, CommandContainer::cmd, CMD_CLIENT_ID, CMD_COMPANY_CTRL, CMD_SERVER, CMD_SPECTATOR, CommandPacket::company, COMPANY_NEW_COMPANY, COMPANY_SPECTATOR, DESTTYPE_CLIENT, GetCommandFlags(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_company_pool >::GetNumItems(), IConsolePrintF(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), NetworkSettings::max_commands_in_queue, NetworkSettings::max_companies, ClientSettings::network, CommandContainer::p1, and CommandContainer::p2.
| void NetworkPopulateCompanyStats | ( | NetworkCompanyStats * | stats | ) |
Populate the company stats.
| stats | the stats to update |
Definition at line 1467 of file network_server.cpp.
References FACIL_AIRPORT, FACIL_BUS_STOP, FACIL_DOCK, FACIL_TRAIN, FACIL_TRUCK_STOP, BaseStation::facilities, FOR_ALL_VEHICLES, SpecializedVehicle< RoadVehicle, Type >::From(), RoadVehicle::IsBus(), Vehicle::IsPrimaryVehicle(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), MAX_COMPANIES, NetworkCompanyStats::num_station, NetworkCompanyStats::num_vehicle, BaseStation::owner, Vehicle::owner, BaseVehicle::type, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.
| bool NetworkServerChangeClientName | ( | ClientID | client_id, | |
| const char * | new_name | |||
| ) |
Change the client name of the given client.
| client_id | the client to change the name of | |
| new_name | the new name for the client |
Definition at line 1647 of file network_server.cpp.
References CC_DEFAULT, NetworkClientInfo::client_name, NetworkClientInfo::GetByClientID(), lastof, and strecpy().
| void NetworkServerDailyLoop | ( | ) |
Daily "callback".
Called whenever the date changes.
Definition at line 1803 of file network_server.cpp.
References _date, ADMIN_FREQUENCY_DAILY, ADMIN_FREQUENCY_WEEKLY, and NetworkAdminUpdate().
Referenced by OnNewDay().
Handle the tid-bits of moving a client from one company to another.
| client_id | id of the client we want to move. | |
| company_id | id of the company we want to move the client to. |
Definition at line 1882 of file network_server.cpp.
References _network_dedicated, CLIENT_ID_SERVER, NetworkClientInfo::client_playas, DESTTYPE_BROADCAST, NetworkClientInfo::GetByClientID(), and SetLocalCompany().
Referenced by CompanyWindow::OnClick().
| void NetworkServerMonthlyLoop | ( | ) |
Monthly "callback".
Called whenever the month changes.
Definition at line 1795 of file network_server.cpp.
References _cur_month, ADMIN_FREQUENCY_MONTHLY, ADMIN_FREQUENCY_QUARTERLY, and NetworkAdminUpdate().
Referenced by OnNewMonth().
| void NetworkServerSetCompanyPassword | ( | CompanyID | company_id, | |
| const char * | password, | |||
| bool | already_hashed | |||
| ) |
Set/Reset a company password on the server end.
| company_id | ID of the company the password should be changed for. | |
| password | The new password. | |
| already_hashed | Is the given password already hashed? |
Definition at line 1672 of file network_server.cpp.
References _settings_client, _settings_game, GameSettings::game_creation, GenerateCompanyPasswordHash(), GameCreationSettings::generation_seed, Company::IsValidHumanID(), lastof, ClientSettings::network, NetworkSettings::network_id, strecpy(), and StrEmpty().
Referenced by NetworkChangeCompanyPassword().
| void NetworkServerYearlyLoop | ( | ) |
Yearly "callback".
Called whenever the year changes.
Definition at line 1788 of file network_server.cpp.
References ADMIN_FREQUENCY_ANUALLY, and NetworkAdminUpdate().
Referenced by OnNewYear().
1.7.1