Network functions used by other parts of OpenTTD. More...
#include "core/address.h"
#include "network_type.h"
#include "../console_type.h"
#include "../gfx_type.h"
#include "../openttd.h"
#include "../company_type.h"
#include "../console_type.h"
Go to the source code of this file.
Functions | |
byte | NetworkSpectatorCount () |
void | NetworkUpdateClientName () |
bool | NetworkCompanyHasClients (CompanyID company) |
const char * | NetworkChangeCompanyPassword (CompanyID company_id, const char *password, bool already_hashed=true) |
Change the company password of a given company. | |
void | NetworkReboot () |
void | NetworkDisconnect (bool blocking=false, bool close_admins=true) |
We want to disconnect from the host/clients. | |
void | NetworkGameLoop () |
void | NetworkUDPGameLoop () |
void | ParseConnectionString (const char **company, const char **port, char *connection_string) |
Converts a string to ip/port/company Format: IP:port::company. | |
void | NetworkStartDebugLog (NetworkAddress address) |
void | NetworkPopulateCompanyStats (NetworkCompanyStats *stats) |
Populate the company stats. | |
void | NetworkUpdateClientInfo (ClientID client_id) |
void | NetworkClientsToSpectators (CompanyID cid) |
void | NetworkClientConnectGame (NetworkAddress address, CompanyID join_as, const char *join_server_password=NULL, const char *join_company_password=NULL) |
void | NetworkClientRequestMove (CompanyID company, const char *pass="") |
Notify the server of this client wanting to be moved to another company. | |
void | NetworkClientSendRcon (const char *password, const char *command) |
void | NetworkClientSendChat (NetworkAction action, DestType type, int dest, const char *msg, int64 data=0) |
bool | NetworkClientPreferTeamChat (const NetworkClientInfo *cio) |
Tell whether the client has team members where he/she can chat to. | |
bool | NetworkCompanyIsPassworded (CompanyID company_id) |
Check if the company we want to join requires a password. | |
bool | NetworkMaxCompaniesReached () |
Check if max_companies has been reached on the server (local check only). | |
bool | NetworkMaxSpectatorsReached () |
Check if max_spectatos has been reached on the server (local check only). | |
void | NetworkPrintClients () |
Print all the clients to the console. | |
void | NetworkHandlePauseChange (PauseMode prev_mode, PauseMode changed_mode) |
Handle the pause mode change so we send the right messages to the chat. | |
void | NetworkServerDailyLoop () |
Daily "callback". | |
void | NetworkServerMonthlyLoop () |
Monthly "callback". | |
void | NetworkServerYearlyLoop () |
Yearly "callback". | |
void | NetworkServerSendConfigUpdate () |
Send Config Update. | |
void | NetworkServerShowStatusToConsole () |
bool | NetworkServerStart () |
void | NetworkServerUpdateCompanyPassworded (CompanyID company_id, bool passworded) |
bool | NetworkServerChangeClientName (ClientID client_id, const char *new_name) |
Change the client name of the given client. | |
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) |
void | NetworkServerSendChat (NetworkAction action, DestType type, int dest, const char *msg, ClientID from_id, int64 data=0, bool from_admin=false) |
void | NetworkServerKickClient (ClientID client_id) |
uint | NetworkServerKickOrBanIP (ClientID client_id, bool ban) |
uint | NetworkServerKickOrBanIP (const char *ip, bool ban) |
void | NetworkInitChatMessage () |
void CDECL | NetworkAddChatMessage (TextColour colour, uint duration, const char *message,...) WARN_FORMAT(3 |
void CDECL void | NetworkUndrawChatMessage () |
Hide the chatbox. | |
void | NetworkChatMessageLoop () |
Check if a message is expired. | |
void | NetworkAfterNewGRFScan () |
Rebuild the GRFConfig's of the servers in the game list as we did a rescan and might have found new NewGRFs. | |
Variables | |
NetworkServerGameInfo | _network_game_info |
NetworkCompanyState * | _network_company_states |
ClientID | _network_own_client_id |
ClientID | _redirect_console_to_client |
bool | _network_need_advertise |
uint32 | _network_last_advertise_frame |
uint8 | _network_reconnect |
StringList | _network_bind_list |
StringList | _network_host_list |
StringList | _network_ban_list |
Network functions used by other parts of OpenTTD.
Definition in file network_func.h.
const char* NetworkChangeCompanyPassword | ( | CompanyID | company_id, | |
const char * | password, | |||
bool | already_hashed | |||
) |
Change the company password of a given company.
company_id | ID of the company the password should be changed for. | |
password | The unhashed password we like to set ('*' or '' resets the password) |
Definition at line 159 of file network.cpp.
References NetworkClientSetCompanyPassword(), and NetworkServerSetCompanyPassword().
Referenced by CmdCompanyCtrl().
void NetworkChatMessageLoop | ( | ) |
Check if a message is expired.
Definition at line 184 of file network_chat_gui.cpp.
References _realtime_tick.
bool NetworkClientPreferTeamChat | ( | const NetworkClientInfo * | cio | ) |
Tell whether the client has team members where he/she can chat to.
cio | client to check members of. |
Definition at line 1216 of file network_client.cpp.
References _settings_client, NetworkClientInfo::client_playas, ClientSettings::gui, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), and GUISettings::prefer_teamchat.
Referenced by MainWindow::OnKeyPress().
void NetworkClientRequestMove | ( | CompanyID | company_id, | |
const char * | pass | |||
) |
Notify the server of this client wanting to be moved to another company.
company_id | id of the company the client wishes to be moved to. | |
pass | the password, is only checked on the server end if a password is needed. |
Definition at line 1156 of file network_client.cpp.
Referenced by CompanyWindow::OnClick(), and CompanyWindow::OnQueryTextFinished().
bool NetworkCompanyIsPassworded | ( | CompanyID | company_id | ) |
Check if the company we want to join requires a password.
company_id | id of the company we want to check the 'passworded' flag for. |
Definition at line 211 of file network.cpp.
References HasBit().
Referenced by CompanyWindow::DrawWidget(), and CompanyWindow::OnClick().
void NetworkDisconnect | ( | bool | blocking, | |
bool | close_admins | |||
) |
We want to disconnect from the host/clients.
blocking | whether to wait till everything has been closed. | |
close_admins | Whether the admin sockets need to be closed as well. |
Definition at line 769 of file network.cpp.
References _settings_client, DeleteWindowById(), ClientSettings::network, NetworkClose(), NetworkUDPRemoveAdvertise(), NetworkTCPSocketHandler::SendPackets(), and NetworkSettings::server_advertise.
Referenced by NetworkShutDown(), NetworkJoinStatusWindow::OnClick(), TCPQueryConnecter::OnFailure(), NetworkJoinStatusWindow::OnQueryTextFinished(), and SafeLoad().
Handle the pause mode change so we send the right messages to the chat.
prev_mode | The previous pause mode. | |
changed_mode | The pause mode that got changed. |
Definition at line 330 of file network.cpp.
References _pause_mode, CC_DEFAULT, DRAW_STRING_BUFFER, lastof, PM_PAUSED_ACTIVE_CLIENTS, PM_PAUSED_JOIN, PM_PAUSED_NORMAL, PM_UNPAUSED, and SetDParam().
Referenced by CmdPause().
bool NetworkMaxCompaniesReached | ( | ) |
Check if max_companies has been reached on the server (local check only).
Definition at line 1233 of file network_client.cpp.
References _network_server, _settings_client, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_company_pool >::GetNumItems(), NetworkSettings::max_companies, and ClientSettings::network.
Referenced by PopupMainCompanyToolbMenu().
bool NetworkMaxSpectatorsReached | ( | ) |
Check if max_spectatos has been reached on the server (local check only).
Definition at line 1242 of file network_client.cpp.
References _network_server, _settings_client, NetworkSettings::max_spectators, and ClientSettings::network.
Referenced by PopupMainCompanyToolbMenu().
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 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 1805 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 1884 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 1797 of file network_server.cpp.
References _cur_month, ADMIN_FREQUENCY_MONTHLY, ADMIN_FREQUENCY_QUARTERLY, and NetworkAdminUpdate().
Referenced by OnNewMonth().
void NetworkServerYearlyLoop | ( | ) |
Yearly "callback".
Called whenever the year changes.
Definition at line 1790 of file network_server.cpp.
References ADMIN_FREQUENCY_ANUALLY, and NetworkAdminUpdate().
Referenced by OnNewYear().
void ParseConnectionString | ( | const char ** | company, | |
const char ** | port, | |||
char * | connection_string | |||
) |
Converts a string to ip/port/company Format: IP:port::company.
connection_string will be re-terminated to seperate out the hostname, and company and port will be set to the company and port strings given by the user, inside the memory area originally occupied by connection_string.
Definition at line 452 of file network.cpp.
Referenced by NetworkHTTPSocketHandler::Connect().