Freeciv-3.3: /fast/freeciv/nightly/main/client/connectdlg_common.c File Reference

Freeciv-3.3

Loading...
Searching...
No Matches
Macros | Functions | Variables
connectdlg_common.c File Reference
`#include "fc_prehdrs.h"`
`#include <fcntl.h>`
`#include <stdio.h>`
`#include <signal.h>`
`#include <string.h>`
`#include <time.h>`
`#include "astring.h"`
`#include "capability.h"`
`#include "deprecations.h"`
`#include "fciconv.h"`
`#include "fcintl.h"`
`#include "ioz.h"`
`#include "log.h"`
`#include "mem.h"`
`#include "netintf.h"`
`#include "rand.h"`
`#include "registry.h"`
`#include "shared.h"`
`#include "support.h"`
`#include "attribute.h"`
`#include "client_main.h"`
`#include "climisc.h"`
`#include "clinet.h"`
`#include <packhand_gen.h>`
`#include "chatline_common.h"`
`#include "connectdlg_g.h"`
`#include "connectdlg_common.h"`
`#include "tilespec.h"`

Go to the source code of this file.

## Macros

#define | WAIT_BETWEEN_TRIES 100000 /* usecs */
#define | NUMBER_OF_TRIES 500

## Functions

bool | is_server_running (void)
bool | can_client_access_hack (void)
void | client_kill_server (bool force)
bool | client_start_server (void)
static void | randomize_string (char *str, size_t n)
void | send_client_wants_hack (const char *filename)
void | handle_single_want_hack_reply (bool you_have_hack)
void | send_save_game (const char *filename)
void | handle_ruleset_choices (const struct packet_ruleset_choices *packet)
void | set_ruleset (const char *ruleset)

## Variables

bool | server_quitting = FALSE
static char | challenge_fullname [MAX_LEN_PATH]
static bool | client_has_hack = FALSE
int | internal_server_port

## Macro Definition Documentation

## ◆ NUMBER_OF_TRIES

#define NUMBER_OF_TRIES 500

Definition at line 74 of file connectdlg_common.c.

## ◆ WAIT_BETWEEN_TRIES

#define WAIT_BETWEEN_TRIES 100000 /* usecs */

Definition at line 69 of file connectdlg_common.c.

## Function Documentation

## ◆ can_client_access_hack()

bool can_client_access_hack | ( | void |  | ) |

Returns TRUE if the client has hack access.

Definition at line 141 of file connectdlg_common.c.

Referenced by mr_menu::menus_sensitive(), real_menus_init(), real_menus_update(), fc_client::update_buttons(), and update_start_page_buttons().

## ◆ client_kill_server()

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 153 of file connectdlg_common.c.

Referenced by client_conn_close_callback(), client_start_server(), disconnect_from_server(), emergency_exit(), and handle_single_want_hack_reply().

## ◆ client_start_server()

bool client_start_server | ( | void |  | ) |

Forks a server if it can. Returns FALSE if we find we couldn't start the server.

Definition at line 224 of file connectdlg_common.c.

Referenced by client_start_server_and_set_page(), real_set_client_page(), set_client_state(), fc_client::start_from_save(), fc_client::start_new_game(), start_new_game_callback(), start_new_game_callback(), and fc_client::start_scenario().

## ◆ handle_ruleset_choices()

void handle_ruleset_choices | ( | const struct packet_ruleset_choices * | packet | ) |

Handle the list of rulesets sent by the server.

Definition at line 757 of file connectdlg_common.c.

Referenced by client_handle_packet().

## ◆ handle_single_want_hack_reply()

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 715 of file connectdlg_common.c.

Referenced by client_handle_packet().

## ◆ is_server_running()

bool is_server_running | ( | void |  | ) |

Tests if the client has started the server.

Definition at line 124 of file connectdlg_common.c.

Referenced by mr_menu::back_to_menu(), client_kill_server(), handle_single_want_hack_reply(), leave_callback(), leave_callback(), load_selected_game_callback(), real_set_client_page(), refresh_chat_buttons(), resend_desired_settable_options(), fc_client::start_from_save(), fc_client::start_new_game(), start_new_game_callback(), start_new_game_callback(), fc_client::start_scenario(), fc_client::switch_page(), and chatwdg::update_widgets().

## ◆ randomize_string()

static void randomize_string | ( | char * | str,
|  | size_t | n
| ) |  |

static

Generate a random string.

Definition at line 651 of file connectdlg_common.c.

Referenced by send_client_wants_hack().

## ◆ 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 671 of file connectdlg_common.c.

Referenced by handle_server_join_reply().

## ◆ send_save_game()

void send_save_game | ( | const char * | filename | ) |

Send server command to save game.

Definition at line 743 of file connectdlg_common.c.

Referenced by mr_menu::save_game(), mr_menu::save_game_as(), save_game_callback(), save_game_callback(), save_game_callback(), and save_game_dialog_popup().

## ◆ set_ruleset()

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 784 of file connectdlg_common.c.

Referenced by pregame_options::ruleset_change(), and ruleset_selected().

## Variable Documentation

## ◆ challenge_fullname

char challenge_fullname[MAX_LEN_PATH]

static

Definition at line 91 of file connectdlg_common.c.

Referenced by handle_single_want_hack_reply(), and send_client_wants_hack().

## ◆ client_has_hack

bool client_has_hack = FALSE

static

Definition at line 92 of file connectdlg_common.c.

Referenced by can_client_access_hack(), client_kill_server(), and handle_single_want_hack_reply().

## ◆ internal_server_port

int internal_server_port

Definition at line 94 of file connectdlg_common.c.

Referenced by client_start_server().

## ◆ server_quitting

bool server_quitting = FALSE

Definition at line 89 of file connectdlg_common.c.

Referenced by client_kill_server(), client_start_server(), and is_server_running().