Stop sharing requirement_unit_state_ereq().
[freeciv.git] / common / capstr.c
blob637ac969b874c5bf9f32a652f7a9c8f8db569282
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.
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 ***********************************************************************/
14 #ifdef HAVE_CONFIG_H
15 #include <fc_config.h>
16 #endif
18 #include <stdlib.h> /* getenv() */
20 /* utility */
21 #include "support.h"
23 /* common */
24 #include "connection.h" /* MAX_LEN_CAPSTR */
26 #include "capstr.h"
28 static char our_capability_internal[MAX_LEN_CAPSTR];
29 const char * const our_capability = our_capability_internal;
31 /* Capabilities: original author: Mitch Davis (mjd@alphalink.com.au)
33 * The capability string is a string clients and servers trade to find
34 * out if they can talk to each other, and using which protocol version,
35 * and which features and behaviors to expect. The string is a list of
36 * words, separated by whitespace and/or commas, where each word indicates
37 * a capability that this version of Freeciv understands.
38 * If a capability word is mandatory, it should start with a "+".
40 * eg, #define CAPABILITY "+1.6, MapScroll, +AutoSettlers"
42 * Client and server functions can test these strings for a particular
43 * capability by calling the functions in capability.c
45 * Each executable has a string our_capability (above), which gives the
46 * capabilities of the running executable. This is normally initialised
47 * with CAPABILITY, but can be changed at run-time by setting the
48 * FREECIV_CAPS environment variable, though that is probably mainly
49 * useful for testing purposes.
51 * For checking the connections of other executables, each
52 * "struct connection" has a capability string, which gives the
53 * capability of the executable at the other end of the connection.
54 * So for the client, the capability of the server is in
55 * client.conn.capability, and for the server, the capabilities of
56 * connected clients are in player_by_number(i)->conn.capability
57 * The client now also knows the capabilities of other clients,
58 * via player_by_number(i)->conn.capability.
60 * Note the connection struct is a parameter to the functions to send and
61 * receive packets, which may be convenient for adjusting how a packet is
62 * sent or interpreted based on the capabilities of the connection.
64 * At the time of a major release, the capability string may be
65 * simplified; eg, the example string above could be replaced by "+1.7".
66 * (This should probably only happen if a mandatory capability has
67 * been introduced since the previous release.)
68 * Whoever makes such a change has responsibility to search the Freeciv
69 * code, and look for places where people are using has_capability.
70 * If you're taking a capability out of the string, because now every
71 * client and server supports it, then you should take out the
72 * if (has_capability()) code so that this code is always executed.
74 * (The savefile and ruleset files have strings which are used similarly,
75 * and checked by the same has_capability function, but the strings there
76 * are not directly related to the capability strings discussed here.)
78 * The actual capability string is now defined in fc_version.
81 /**************************************************************************
82 Setup our internal network capability string.
83 **************************************************************************/
84 void init_our_capability(void)
86 const char *s;
88 s = getenv("FREECIV_CAPS");
89 if (!s) {
90 s = NETWORK_CAPSTRING;
92 sz_strlcpy(our_capability_internal, s);