Freeciv-3.2
Loading...
Searching...
No Matches
Functions
connecthand.h File Reference
#include "support.h"
#include "fc_types.h"

Go to the source code of this file.

Functions

void conn_set_access (struct connection *pconn, enum cmdlevel new_level, bool granted)
 
void establish_new_connection (struct connection *pconn)
 
void reject_new_connection (const char *msg, struct connection *pconn)
 
bool handle_login_request (struct connection *pconn, struct packet_server_join_req *req)
 
void lost_connection_to_client (struct connection *pconn)
 
void send_conn_info (struct conn_list *src, struct conn_list *dest)
 
void send_conn_info_remove (struct conn_list *src, struct conn_list *dest)
 
struct playerfind_uncontrolled_player (void)
 
bool connection_attach (struct connection *pconn, struct player *pplayer, bool observing)
 
void connection_detach (struct connection *pconn, bool remove_unused_player)
 
bool connection_delegate_take (struct connection *pconn, struct player *pplayer)
 
bool connection_delegate_restore (struct connection *pconn)
 
void connection_close_server (struct connection *pconn, const char *reason)
 

Function Documentation

◆ conn_set_access()

void conn_set_access ( struct connection pconn,
enum cmdlevel  new_level,
bool  granted 
)

Set the access level of a connection, and re-send some needed info. If granted is TRUE, then it will overwrite the granted_access_level too. Else, it will affect only the current access level.

NB: This function does not send updated connection information to other clients, you need to do that yourself afterwards.

Definition at line 72 of file connecthand.c.

Referenced by api_auth_set_cmdlevel(), firstlevel_command(), handle_single_want_hack_req(), restore_access_level(), set_cmdlevel(), and start_game().

◆ connection_attach()

bool connection_attach ( struct connection pconn,
struct player pplayer,
bool  observing 
)

Setup pconn as a client connected to pplayer or observer.

Definition at line 793 of file connecthand.c.

Referenced by connection_delegate_restore(), connection_delegate_take(), load_command(), observe_command(), and take_command().

◆ connection_close_server()

void connection_close_server ( struct connection pconn,
const char reason 
)

Close a connection. Use this in the server to take care of delegation stuff (reset the username of the controlled connection).

Definition at line 1006 of file connecthand.c.

Referenced by auth_process_status(), cut_client_connection(), cut_lagging_connection(), flush_packets(), incoming_client_packets(), kick_command(), and server_sniff_all_input().

◆ connection_delegate_restore()

bool connection_delegate_restore ( struct connection pconn)

Restore the original status of a delegate connection pconn after potentially using a delegation. pconn is detached from the delegated player, and reattached to its previous view (e.g. observer), if any. (Reattaching the original user to the delegated player is not handled here.)

Definition at line 945 of file connecthand.c.

Referenced by connection_close_server(), delegate_command(), and establish_new_connection().

◆ connection_delegate_take()

bool connection_delegate_take ( struct connection pconn,
struct player dplayer 
)

Use a delegation to get control over another player.

Definition at line 884 of file connecthand.c.

Referenced by delegate_command().

◆ connection_detach()

void connection_detach ( struct connection pconn,
bool  remove_unused_player 
)

Remove pconn as a client connected to pplayer: Updates pconn->playing, pconn->playing->connections, pconn->playing->is_connected and pconn->observer.

pconn remains a member of game.est_connections.

If remove_unused_player is TRUE, may remove a player left with no controlling connection (only in pregame, and not if explicitly /created).

Definition at line 809 of file connecthand.c.

Referenced by connection_delegate_restore(), connection_delegate_take(), connection_detach(), detach_command(), handle_edit_player_remove(), load_command(), lost_connection_to_client(), observe_command(), server_remove_player(), and take_command().

◆ establish_new_connection()

void establish_new_connection ( struct connection pconn)

This is used when a new player joins a server, before the game has started. If pconn is NULL, is an AI, else a client.

N.B. this only attaches a connection to a player if pconn->username == player->username

Here we send initial packets:

  • ruleset datas.
  • server settings.
  • scenario info.
  • game info.
  • players infos (note it's resent in srv_main.c::send_all_info(), see comment there).
  • connections infos.
  • running vote infos. ... and additional packets if the game already started.

Definition at line 130 of file connecthand.c.

Referenced by auth_handle_reply(), auth_user(), and handle_login_request().

◆ find_uncontrolled_player()

struct player * find_uncontrolled_player ( void  )

Search for first uncontrolled player

Definition at line 618 of file connecthand.c.

Referenced by connection_attach_real(), create_command_pregame(), and take_command().

◆ handle_login_request()

bool handle_login_request ( struct connection pconn,
struct packet_server_join_req req 
)

Returns FALSE if the clients gets rejected and the connection should be closed. Returns TRUE if the client get accepted.

Definition at line 396 of file connecthand.c.

Referenced by server_packet_input().

◆ lost_connection_to_client()

void lost_connection_to_client ( struct connection pconn)

High-level server stuff when connection to client is closed or lost. Reports loss to log, and to other players if the connection was a player. Also removes player in pregame, applies auto_toggle, and does check for turn done (since can depend on connection/ai status). Note you shouldn't this function directly. You should use server_break_connection() if you want to close the connection.

Definition at line 530 of file connecthand.c.

Referenced by really_close_connections().

◆ reject_new_connection()

void reject_new_connection ( const char msg,
struct connection pconn 
)

send the rejection packet to the client.

Definition at line 375 of file connecthand.c.

Referenced by auth_handle_reply(), auth_process_status(), auth_user(), and handle_login_request().

◆ send_conn_info()

void send_conn_info ( struct conn_list src,
struct conn_list dest 
)

Send conn_info packets to tell 'dest' connections all about 'src' connections.

Definition at line 601 of file connecthand.c.

Referenced by connection_attach_real(), connection_detach(), establish_new_connection(), and handle_single_want_hack_req().

◆ send_conn_info_remove()

void send_conn_info_remove ( struct conn_list src,
struct conn_list dest 
)

Like send_conn_info(), but turn off the 'used' bits to tell clients to remove info about these connections instead of adding it.

Definition at line 610 of file connecthand.c.

Referenced by lost_connection_to_client().