Data Structures | Functions | Variables

network_server.cpp File Reference

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")

Detailed Description

Server part of the network protocol.

Definition in file network_server.cpp.


Function Documentation

DEF_GAME_RECEIVE_COMMAND ( Server  ,
PACKET_CLIENT_COMMAND   
)
void NetworkPopulateCompanyStats ( NetworkCompanyStats stats  ) 
bool NetworkServerChangeClientName ( ClientID  client_id,
const char *  new_name 
)

Change the client name of the given client.

Parameters:
client_id the client to change the name of
new_name the new name for the client
Returns:
true iff the name was changed

Definition at line 1649 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 1844 of file network_server.cpp.

References _date, ADMIN_FREQUENCY_DAILY, ADMIN_FREQUENCY_WEEKLY, and NetworkAdminUpdate().

Referenced by OnNewDay().

void NetworkServerDoMove ( ClientID  client_id,
CompanyID  company_id 
)

Handle the tid-bits of moving a client from one company to another.

Parameters:
client_id id of the client we want to move.
company_id id of the company we want to move the client to.
Returns:
void

Definition at line 1923 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 1836 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.

Parameters:
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 1674 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 1829 of file network_server.cpp.

References ADMIN_FREQUENCY_ANUALLY, and NetworkAdminUpdate().

Referenced by OnNewYear().