Freeciv-3.2
Loading...
Searching...
No Matches
capstr.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18#include <stdlib.h> /* getenv() */
19
20/* gen_headers */
21#include "version_gen.h"
22
23/* utility */
24#include "support.h"
25
26/* common */
27#include "connection.h" /* MAX_LEN_CAPSTR */
28
29#include "capstr.h"
30
33
34/* Capabilities: original author: Mitch Davis (mjd@alphalink.com.au)
35 *
36 * The capability string is a string clients and servers trade to find
37 * out if they can talk to each other, and using which protocol version,
38 * and which features and behaviors to expect. The string is a list of
39 * words, separated by whitespace and/or commas, where each word indicates
40 * a capability that this version of Freeciv understands.
41 * If a capability word is mandatory, it should start with a "+".
42 *
43 * eg, #define CAPABILITY "+1.6, MapScroll, +AutoSettlers"
44 *
45 * Client and server functions can test these strings for a particular
46 * capability by calling the functions in capability.c
47 *
48 * Each executable has a string our_capability (above), which gives the
49 * capabilities of the running executable. This is normally initialised
50 * with CAPABILITY, but can be changed at run-time by setting the
51 * FREECIV_CAPS environment variable, though that is probably mainly
52 * useful for testing purposes.
53 *
54 * For checking the connections of other executables, each
55 * "struct connection" has a capability string, which gives the
56 * capability of the executable at the other end of the connection.
57 * So for the client, the capability of the server is in
58 * client.conn.capability, and for the server, the capabilities of
59 * connected clients are in player_by_number(i)->conn.capability
60 * The client now also knows the capabilities of other clients,
61 * via player_by_number(i)->conn.capability.
62 *
63 * Note the connection struct is a parameter to the functions to send and
64 * receive packets, which may be convenient for adjusting how a packet is
65 * sent or interpreted based on the capabilities of the connection.
66 *
67 * At the time of a major release, the capability string may be
68 * simplified; eg, the example string above could be replaced by "+1.7".
69 * (This should probably only happen if a mandatory capability has
70 * been introduced since the previous release.)
71 * Whoever makes such a change has responsibility to search the Freeciv
72 * code, and look for places where people are using has_capability.
73 * If you're taking a capability out of the string, because now every
74 * client and server supports it, then you should take out the
75 * if (has_capability()) code so that this code is always executed.
76 *
77 * (The savefile and ruleset files have strings which are used similarly,
78 * and checked by the same has_capability function, but the strings there
79 * are not directly related to the capability strings discussed here.)
80 *
81 * The actual capability string is now defined in fc_version.
82 */
83
84/**********************************************************************/
88{
89 const char *s;
90
91 s = getenv("FREECIV_CAPS");
92 if (!s) {
94 }
96}
const char *const our_capability
Definition capstr.c:32
void init_our_capability(void)
Definition capstr.c:87
static char our_capability_internal[MAX_LEN_CAPSTR]
Definition capstr.c:31
char * incite_cost
Definition comments.c:75
#define MAX_LEN_CAPSTR
Definition conn_types.h:30
#define sz_strlcpy(dest, src)
Definition support.h:195