Freeciv21
Develop your civilization from humble roots to a global empire
connecthand.h
Go to the documentation of this file.
1 /**************************************************************************
2  Copyright (c) 1996-2020 Freeciv21 and Freeciv contributors. This file is
3  __ __ part of Freeciv21. Freeciv21 is free software: you can
4 / \\..// \ redistribute it and/or modify it under the terms of the GNU
5  ( oo ) General Public License as published by the Free Software
6  \__/ Foundation, either version 3 of the License, or (at your
7  option) any later version. You should have received
8  a copy of the GNU General Public License along with Freeciv21. If not,
9  see https://www.gnu.org/licenses/.
10 **************************************************************************/
11 #pragma once
12 
13 #include "connection.h" // cmdlevel
14 #include "support.h" // bool type
15 
16 #include "fc_types.h"
17 
18 class QString;
19 
20 struct connection;
21 struct conn_list;
22 struct packet_server_join_req;
23 
24 void conn_set_access(struct connection *pconn, enum cmdlevel new_level,
25  bool granted);
26 
27 void establish_new_connection(struct connection *pconn);
28 void reject_new_connection(const char *msg, struct connection *pconn);
29 
30 bool handle_login_request(struct connection *pconn,
31  struct packet_server_join_req *req);
32 
33 void lost_connection_to_client(struct connection *pconn);
34 
35 void send_conn_info(struct conn_list *src, struct conn_list *dest);
36 void send_conn_info_remove(struct conn_list *src, struct conn_list *dest);
37 
39 bool connection_attach(struct connection *pconn, struct player *pplayer,
40  bool observing);
41 void connection_detach(struct connection *pconn, bool remove_unused_player);
42 
43 bool connection_delegate_take(struct connection *pconn,
44  struct player *pplayer);
45 bool connection_delegate_restore(struct connection *pconn);
46 
47 void connection_close_server(struct connection *pconn,
48  const QString &reason);
void send_conn_info(struct conn_list *src, struct conn_list *dest)
Send conn_info packets to tell 'dest' connections all about 'src' connections.
bool connection_attach(struct connection *pconn, struct player *pplayer, bool observing)
Setup pconn as a client connected to pplayer or observer.
void reject_new_connection(const char *msg, struct connection *pconn)
send the rejection packet to the client.
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.
void lost_connection_to_client(struct connection *pconn)
High-level server stuff when connection to client is closed or lost.
struct player * find_uncontrolled_player()
Search for first uncontrolled player.
void connection_close_server(struct connection *pconn, const QString &reason)
Close a connection.
bool connection_delegate_take(struct connection *pconn, struct player *pplayer)
Use a delegation to get control over another player.
void connection_detach(struct connection *pconn, bool remove_unused_player)
Remove pconn as a client connected to pplayer: Updates pconn->playing, pconn->playing->connections,...
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.
Definition: connecthand.cpp:67
bool connection_delegate_restore(struct connection *pconn)
Restore the original status of a delegate connection pconn after potentially using a delegation.
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 connec...
void establish_new_connection(struct connection *pconn)
This is used when a new player joins a server, before the game has started.
Definition: player.h:231