![]() |
Freeciv21
Develop your civilization from humble roots to a global empire
|
#include <fc_config.h>#include <QCoreApplication>#include <QDebug>#include <QDir>#include <QProcess>#include <QStandardPaths>#include <QTcpServer>#include <QUrl>#include <QUuid>#include <cstring>#include "fcintl.h"#include "log.h"#include "rand.h"#include "registry.h"#include "registry_ini.h"#include "shared.h"#include "support.h"#include "chatline_common.h"#include "client_main.h"#include "clinet.h"#include "connectdlg_common.h"#include "packhand_gen.h"#include "qtg_cxxside.h"
Include dependency graph for connectdlg_common.cpp:Go to the source code of this file.
Classes | |
| class | serverProcess |
Macros | |
| #define | WAIT_BETWEEN_TRIES 100000 |
| #define | NUMBER_OF_TRIES 500 |
Functions | |
| bool | is_server_running () |
| The general chain of events: More... | |
| bool | can_client_access_hack () |
| Returns TRUE if the client has hack access. More... | |
| void | client_kill_server (bool force) |
| Kills the server if the client has started it. More... | |
| bool | client_start_server (const QString &user_name) |
| Forks a server if it can. More... | |
| static void | randomize_string (char *str, size_t n) |
| Generate a random string. More... | |
| void | send_client_wants_hack (const char *filename) |
| If the client is capable of 'wanting hack', then the server will send the client a filename in the packet_join_game_reply packet. More... | |
| void | handle_single_want_hack_reply (bool you_have_hack) |
| Handle response (by the server) if the client has got hack or not. More... | |
| void | send_save_game (const char *filename) |
| Send server command to save game. More... | |
| void | handle_ruleset_choices (const struct packet_ruleset_choices *packet) |
| Handle the list of rulesets sent by the server. More... | |
| void | set_ruleset (const char *ruleset) |
| Called by the GUI code when the user sets the ruleset. More... | |
Variables | |
| bool | server_quitting = false |
| static char | challenge_fullname [MAX_LEN_PATH] |
| static bool | client_has_hack = false |
| int | internal_server_port |
| #define NUMBER_OF_TRIES 500 |
Definition at line 47 of file connectdlg_common.cpp.
| #define WAIT_BETWEEN_TRIES 100000 |
Definition at line 46 of file connectdlg_common.cpp.
| bool can_client_access_hack | ( | ) |
Returns TRUE if the client has hack access.
Definition at line 136 of file connectdlg_common.cpp.
Referenced by mr_menu::nonunit_sensitivity(), and page_pregame::update_buttons().
| void client_kill_server | ( | bool | force | ) |
Kills the server if the client has started it.
If the 'force' parameter is unset, we just do a /quit. If it's set, then we'll send a signal to the server to kill it (use this when the socket is disconnected already).
Definition at line 145 of file connectdlg_common.cpp.
Referenced by client_conn_close_callback(), client_start_server(), disconnect_from_server(), emergency_exit(), and handle_single_want_hack_reply().
| bool client_start_server | ( | const QString & | user_name | ) |
Forks a server if it can.
Returns FALSE if we find we couldn't start the server.
Definition at line 179 of file connectdlg_common.cpp.
Referenced by client_start_server_and_set_page(), client_state(), fc_client::start_from_file(), fc_client::start_new_game(), and fc_client::start_tutorial().
| void handle_ruleset_choices | ( | const struct packet_ruleset_choices * | packet | ) |
Handle the list of rulesets sent by the server.
Definition at line 398 of file connectdlg_common.cpp.
| void handle_single_want_hack_reply | ( | bool | you_have_hack | ) |
Handle response (by the server) if the client has got hack or not.
Definition at line 358 of file connectdlg_common.cpp.
| bool is_server_running | ( | ) |
The general chain of events:
Two distinct paths are taken depending on the choice of mode:
if the user selects the multi- player mode, then a packet_req_join_game packet is sent to the server. It is either successful or not. The end.
If the user selects a single- player mode (either a new game or a save game) then:
Definition at line 125 of file connectdlg_common.cpp.
Referenced by mr_menu::back_to_menu(), client_kill_server(), fc_client::current_page(), handle_server_join_reply(), handle_single_want_hack_reply(), chat_widget::set_chat_visible(), fc_client::start_from_file(), fc_client::start_new_game(), and chat_widget::update_widgets().
|
static |
Generate a random string.
Definition at line 299 of file connectdlg_common.cpp.
Referenced by send_client_wants_hack().
| void send_client_wants_hack | ( | const char * | filename | ) |
If the client is capable of 'wanting hack', then the server will send the client a filename in the packet_join_game_reply packet.
This function creates the file with a suitably random string in it and then sends the string to the server. If the server can open and read the string, then the client is given hack access.
Definition at line 319 of file connectdlg_common.cpp.
Referenced by handle_server_join_reply().
| void send_save_game | ( | const char * | filename | ) |
Send server command to save game.
Definition at line 386 of file connectdlg_common.cpp.
Referenced by mr_menu::save_game(), and mr_menu::save_game_as().
| void set_ruleset | ( | const char * | ruleset | ) |
Called by the GUI code when the user sets the ruleset.
The ruleset passed in here should match one of the strings given to set_rulesets().
Definition at line 419 of file connectdlg_common.cpp.
Referenced by pregame_options::ruleset_change().
|
static |
Definition at line 51 of file connectdlg_common.cpp.
Referenced by handle_single_want_hack_reply(), and send_client_wants_hack().
|
static |
Definition at line 52 of file connectdlg_common.cpp.
Referenced by can_client_access_hack(), client_kill_server(), and handle_single_want_hack_reply().
| int internal_server_port |
Definition at line 54 of file connectdlg_common.cpp.
| bool server_quitting = false |
Definition at line 49 of file connectdlg_common.cpp.
Referenced by client_kill_server(), client_start_server(), and is_server_running().