network_func.h File Reference

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"

Go to the source code of this file.

Functions

byte NetworkSpectatorCount ()
void NetworkUpdateClientName ()
bool NetworkCompanyHasClients (CompanyID company)
const char * NetworkChangeCompanyPassword (const char *)
 Sets/resets company password.
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.
NetworkClientInfoNetworkFindClientInfoFromClientID (ClientID client_id)
 Return the CI given it's client-identifier.
const char * GetClientIP (NetworkClientInfo *ci)
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, ConsoleColour 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 (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

Detailed Description

Network functions used by other parts of OpenTTD.

Definition in file network_func.h.


Function Documentation

const char* NetworkChangeCompanyPassword ( const char *  password  ) 

Sets/resets company password.

Parameters:
password new password, "" or "*" resets password
Returns:
new password

Definition at line 1255 of file network_client.cpp.

References _network_server, and HashCurrentCompanyPassword().

Referenced by CmdCompanyCtrl().

void NetworkChatMessageLoop (  ) 

Check if a message is expired.

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

Parameters:
cio client to check members of.
Returns:
true if there is at least one team member.

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

Parameters:
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.
Returns:
void

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

Parameters:
company_id id of the company we want to check the 'passworded' flag for.
Returns:
true if the company requires a password.

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

Parameters:
blocking whether to wait till everything has been closed.
close_admins Whether the admin sockets need to be closed as well.

Definition at line 719 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().

NetworkClientInfo* NetworkFindClientInfoFromClientID ( ClientID  client_id  ) 

Return the CI given it's client-identifier.

Parameters:
client_id the ClientID to search for
Returns:
return a pointer to the corresponding NetworkClientInfo struct or NULL when not found

Definition at line 111 of file network.cpp.

References NetworkClientInfo::client_id.

Referenced by CmdCompanyCtrl(), NetworkChatWindow::DrawWidget(), NetworkServerChangeClientName(), NetworkServerDoMove(), MainWindow::OnKeyPress(), and NetworkChatWindow::UpdateWidgetSize().

void NetworkHandlePauseChange ( PauseMode  prev_mode,
PauseMode  changed_mode 
)

Handle the pause mode change so we send the right messages to the chat.

Parameters:
prev_mode The previous pause mode.
changed_mode The pause mode that got changed.

Definition at line 277 of file network.cpp.

References _pause_mode, 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).

Returns:
true if the max value has been reached or exceeded, false otherwise.

Definition at line 1272 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).

Returns:
true if the max value has been reached or exceeded, false otherwise.

Definition at line 1281 of file network_client.cpp.

References _network_server, _settings_client, NetworkSettings::max_spectators, and ClientSettings::network.

Referenced by PopupMainCompanyToolbMenu().

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 1613 of file network_server.cpp.

References NetworkClientInfo::client_name, lastof, NetworkFindClientInfoFromClientID(), and strecpy().

void NetworkServerDailyLoop (  ) 

Daily "callback".

Called whenever the date changes.

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

References _network_dedicated, CLIENT_ID_SERVER, NetworkClientInfo::client_playas, COMPANY_SPECTATOR, DESTTYPE_BROADCAST, NetworkFindClientInfoFromClientID(), NetworkFindClientStateFromClientID(), and SetLocalCompany().

Referenced by CompanyWindow::OnClick().

void NetworkServerMonthlyLoop (  ) 

Monthly "callback".

Called whenever the month changes.

Definition at line 1741 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 1734 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 399 of file network.cpp.

Referenced by NetworkHTTPSocketHandler::Connect().


Generated on Fri Dec 31 17:15:46 2010 for OpenTTD by  doxygen 1.6.1