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

Freeciv-3.3

Loading...
Searching...
No Matches
Data Structures | Functions | Variables
servers.c File Reference
`#include "fc_prehdrs.h"`
`#include <errno.h>`
`#include <stdlib.h>`
`#include "cvercmp.h"`
`#include "fcintl.h"`
`#include "fcthread.h"`
`#include "log.h"`
`#include "mem.h"`
`#include "netfile.h"`
`#include "netintf.h"`
`#include "rand.h"`
`#include "registry.h"`
`#include "support.h"`
`#include "capstr.h"`
`#include "dataio.h"`
`#include "game.h"`
`#include "packets.h"`
`#include "version.h"`
`#include "chatline_common.h"`
`#include "chatline_g.h"`
`#include "client_main.h"`
`#include "options.h"`
`#include "servers.h"`
`#include "gui_main_g.h"`

Go to the source code of this file.

## Data Structures

struct | server_scan

## Functions

static void | delete_server_list (struct server_list *server_list)
static bool | begin_lanserver_scan (struct server_scan *scan)
static enum server_scan_status | get_lan_server_list (struct server_scan *scan)
struct server_scan * | server_scan_begin (enum server_scan_type type, ServerScanErrorFunc error_func)
enum server_scan_type | server_scan_get_type (const struct server_scan *scan)
enum server_scan_status | server_scan_poll (struct server_scan *scan)
struct srv_list * | server_scan_get_list (struct server_scan *scan)
void | server_scan_finish (struct server_scan *scan)

## Variables

enum announce_type | announce

## Function Documentation

## ◆ begin_lanserver_scan()

static bool begin_lanserver_scan | ( | struct server_scan * | scan | ) |

static

Broadcast an UDP package to all servers on LAN, requesting information about the server. The packet is send to all Freeciv servers in the same multicast group as the client.

Definition at line 385 of file servers.c.

Referenced by server_scan_begin().

## ◆ delete_server_list()

static void delete_server_list | ( | struct server_list * | server_list | ) |

static

Frees everything associated with a server list including the server list itself (so the server_list is no longer valid after calling this function)

Definition at line 349 of file servers.c.

Referenced by server_scan_finish().

## ◆ get_lan_server_list()

static enum server_scan_status get_lan_server_list | ( | struct server_scan * | scan | ) |

static

Listens for UDP packets broadcasted from a server that responded to the request-packet sent from the client.

Definition at line 618 of file servers.c.

Referenced by server_scan_poll().

## ◆ server_scan_begin()

struct server_scan * server_scan_begin | ( | enum server_scan_type | type,
|  | ServerScanErrorFunc | error_func
| ) |  |

Creates a new server scan and returns it, or NULL if impossible.

Depending on 'type' the scan will look for either local or internet games.

error_func provides a callback to be used in case of error; this callback probably should call server_scan_finish.

NB: You must call server_scan_finish() when you are done with the scan to free the memory and resources allocated by it.

Definition at line 755 of file servers.c.

Referenced by sdl_create_server_list(), fc_client::update_network_lists(), and update_network_lists().

## ◆ server_scan_finish()

void server_scan_finish | ( | struct server_scan * | scan | ) |

Closes the socket listening on the scan, frees the list of servers, and frees the memory allocated for 'scan' by server_scan_begin().

Definition at line 879 of file servers.c.

Referenced by close_connection_dialog(), destroy_server_scans(), fc_client::destroy_server_scans(), exit_meta_server_dlg_callback(), server_scan_begin(), and server_scan_error().

## ◆ server_scan_get_list()

struct srv_list * server_scan_get_list | ( | struct server_scan * | scan | ) |

Returns the srv_list currently held by the scan (may be NULL).

Definition at line 866 of file servers.c.

Referenced by check_server_scan(), fc_client::check_server_scan(), network_list_callback(), sdl_create_server_list(), and fc_client::slot_selection_changed().

## ◆ server_scan_get_type()

enum server_scan_type server_scan_get_type | ( | const struct server_scan * | scan | ) |

A simple query function to determine the type of a server scan (previously allocated in server_scan_begin).

Definition at line 809 of file servers.c.

Referenced by check_server_scan(), fc_client::check_server_scan(), and server_scan_error().

## ◆ server_scan_poll()

enum server_scan_status server_scan_poll | ( | struct server_scan * | scan | ) |

A function to query servers of the server scan. This will check any pending network data and update the server list.

The return value indicates the status of the server scan: SCAN_STATUS_ERROR - The scan failed and should be aborted. SCAN_STATUS_WAITING - The scan is in progress (continue polling). SCAN_STATUS_PARTIAL - The scan received some data, with more expected. Get the servers with server_scan_get_list(), and continue polling. SCAN_STATUS_DONE - The scan received all data it expected to receive. Get the servers with server_scan_get_list(), and stop calling this function. SCAN_STATUS_ABORT - The scan has been aborted

Definition at line 832 of file servers.c.

Referenced by check_server_scan(), fc_client::check_server_scan(), and sdl_create_server_list().

## Variable Documentation

## ◆ announce

enum announce_type announce

extern

Definition at line 148 of file client_main.c.

Referenced by addr_family_for_announce_type(), begin_lanserver_scan(), client_main(), and remove_trade_route().