[Freeciv-Dev] (PR#9434) Patch: Option levels
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] (PR#9434) Patch: Option levels |
From: |
"Gregory Richards" <akaquinn@xxxxxxxxxxx> |
Date: |
Mon, 19 Jul 2004 20:56:14 -0700 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=9434 >
> [jdorje - Tue Jul 20 03:46:58 2004]:
>
> > [gregorr - Tue Jul 20 03:35:37 2004]:
>
> > Done.
>
> The levels should be translated for users, I think. They should be
in
> an array. Look at how it's done for the categories.
>
> jason
>
>
Done.
diff -ruN -X freeciv-cvs-Jul-18/diff_ignore
freeciv-cvs-Jul-18/server/stdinhand.c
freeciv-cvs-Jul-18-optionlevels/server/stdinhand.c
--- freeciv-cvs-Jul-18/server/stdinhand.c 2004-07-12 22:14:48.000000000
-0700
+++ freeciv-cvs-Jul-18-optionlevels/server/stdinhand.c 2004-07-19
21:00:09.000000000 -0700
@@ -1,4 +1,4 @@
-/**********************************************************************
+/**********************************************************************
Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -73,7 +73,7 @@
static bool show_help(struct connection *caller, char *arg);
static bool show_list(struct connection *caller, char *arg);
static void show_connections(struct connection *caller);
-static bool set_ai_level(struct connection *caller, char *name, int level,
+static bool set_ai_level(struct connection *caller, char *name, int level,
bool check);
static bool set_away(struct connection *caller, char *name, bool check);
@@ -151,6 +151,21 @@
N_("Internal"),
N_("Networking") };
+/* Levels allow options to be subdivided and thus easier to navigate */
+enum sset_level {
+ SSET_NONE,
+ SSET_ALL,
+ SSET_VITAL,
+ SSET_SITUATIONAL,
+ SSET_RARE
+};
+
+const char *sset_level_names[]= { N_("None"),
+ N_("All"),
+ N_("Vital"),
+ N_("Situational"),
+ N_("Rare") };
+
#define SSET_MAX_LEN 16 /* max setting name length (plus nul) */
#define TOKEN_DELIMITERS " \t\n,"
@@ -197,6 +212,8 @@
const char *string_default_value;
bool (*string_validate)(const char * value, const char **reject_message);
size_t string_value_size; /* max size we can write into string_value */
+
+ enum sset_level level;
};
/*
@@ -226,23 +243,23 @@
return TRUE;
}
-#define GEN_BOOL(name, value, sclass, scateg, to_client, short_help,
extra_help, func, default) \
+#define GEN_BOOL(name, value, sclass, scateg, to_client, short_help,
extra_help, func, default, level) \
{ name, sclass, to_client, short_help, extra_help, SSET_BOOL, scateg, \
&value, default, func, \
NULL, 0, NULL, 0, 0, \
- NULL, NULL, NULL, 0 },
+ NULL, NULL, NULL, 0, level },
-#define GEN_INT(name, value, sclass, scateg, to_client, short_help,
extra_help, func, min, max, default) \
+#define GEN_INT(name, value, sclass, scateg, to_client, short_help,
extra_help, func, min, max, default, level) \
{ name, sclass, to_client, short_help, extra_help, SSET_INT, scateg, \
NULL, FALSE, NULL, \
&value, default, func, min, max, \
- NULL, NULL, NULL, 0 },
+ NULL, NULL, NULL, 0, level },
-#define GEN_STRING(name, value, sclass, scateg, to_client, short_help,
extra_help, func, default) \
+#define GEN_STRING(name, value, sclass, scateg, to_client, short_help,
extra_help, func, default, level) \
{ name, sclass, to_client, short_help, extra_help, SSET_STRING, scateg, \
NULL, FALSE, NULL, \
NULL, 0, NULL, 0, 0, \
- value, default, func, sizeof(value)},
+ value, default, func, sizeof(value), level },
#define GEN_END \
{ NULL, SSET_LAST, SSET_SERVER_ONLY, NULL, NULL, SSET_INT,
SSET_NUM_CATEGORIES, \
@@ -260,8 +277,8 @@
N_("This value is used to determine xsize and ysize\n"
" size = 4 is a normal map of 4,000 tiles (default)\n"
" size = 20 is a huge map of 20,000 tiles"), NULL,
- MAP_MIN_SIZE, MAP_MAX_SIZE, MAP_DEFAULT_SIZE)
- GEN_INT("topology", map.topology_id, SSET_MAP_SIZE, SSET_GEOLOGY,
+ MAP_MIN_SIZE, MAP_MAX_SIZE, MAP_DEFAULT_SIZE, SSET_VITAL)
+ GEN_INT("topology", map.topology_id, SSET_MAP_SIZE, SSET_GEOLOGY,
SSET_TO_CLIENT,
N_("The map topology index"),
N_("Two-dimensional maps can wrap at the north-south or \n"
@@ -276,7 +293,7 @@
" 6 Uranus (isometric)\n"
" 7 Donut World (isometric)"
), NULL,
- MAP_MIN_TOPO, MAP_MAX_TOPO, MAP_DEFAULT_TOPO)
+ MAP_MIN_TOPO, MAP_MAX_TOPO, MAP_DEFAULT_TOPO, SSET_VITAL)
/* Map generation parameters: once we have a map these are of historical
* interest only, and cannot be changed.
@@ -296,65 +313,65 @@
"Note: values 2,3 and 4 generate \"fairer\" (but more boring) "
"maps.\n"
"(Zero indicates a scenario map.)"), NULL,
- MAP_MIN_GENERATOR, MAP_MAX_GENERATOR, MAP_DEFAULT_GENERATOR)
+ MAP_MIN_GENERATOR, MAP_MAX_GENERATOR, MAP_DEFAULT_GENERATOR,
SSET_VITAL)
GEN_BOOL("tinyisles", map.tinyisles, SSET_MAP_GEN, SSET_GEOLOGY,
SSET_TO_CLIENT,
N_("Presence of 1x1 islands"),
N_("0 = no 1x1 islands; 1 = some 1x1 islands"), NULL,
- MAP_DEFAULT_TINYISLES)
+ MAP_DEFAULT_TINYISLES, SSET_RARE)
GEN_BOOL("separatepoles", map.separatepoles, SSET_MAP_GEN, SSET_GEOLOGY,
SSET_TO_CLIENT,
N_("Whether the poles are separate continents"),
N_("0 = continents may attach to poles; 1 = poles will "
"be separate"), NULL,
- MAP_DEFAULT_SEPARATE_POLES)
+ MAP_DEFAULT_SEPARATE_POLES, SSET_SITUATIONAL)
GEN_BOOL("alltemperate", map.alltemperate, SSET_MAP_GEN, SSET_GEOLOGY,
SSET_TO_CLIENT,
N_("All the map is temperate (no poles or equatorial regions)"),
N_("0 = normal Earth-like planet; 1 = all-temperate planet "),
- NULL, MAP_DEFAULT_ALLTEMPERATE)
+ NULL, MAP_DEFAULT_ALLTEMPERATE, SSET_RARE)
GEN_INT("landmass", map.landpercent, SSET_MAP_GEN, SSET_GEOLOGY,
SSET_TO_CLIENT,
N_("Amount of land vs ocean"), "", NULL,
- MAP_MIN_LANDMASS, MAP_MAX_LANDMASS, MAP_DEFAULT_LANDMASS)
+ MAP_MIN_LANDMASS, MAP_MAX_LANDMASS, MAP_DEFAULT_LANDMASS,
SSET_SITUATIONAL)
GEN_INT("mountains", map.mountains, SSET_MAP_GEN, SSET_GEOLOGY,
SSET_TO_CLIENT,
N_("Amount of hills/mountains"),
N_("Small values give flat maps, higher values give more "
"hills and mountains."), NULL,
- MAP_MIN_MOUNTAINS, MAP_MAX_MOUNTAINS, MAP_DEFAULT_MOUNTAINS)
+ MAP_MIN_MOUNTAINS, MAP_MAX_MOUNTAINS, MAP_DEFAULT_MOUNTAINS,
SSET_SITUATIONAL)
GEN_INT("rivers", map.riverlength, SSET_MAP_GEN, SSET_GEOLOGY,
SSET_TO_CLIENT,
N_("Amount of river squares"), "", NULL,
- MAP_MIN_RIVERS, MAP_MAX_RIVERS, MAP_DEFAULT_RIVERS)
+ MAP_MIN_RIVERS, MAP_MAX_RIVERS, MAP_DEFAULT_RIVERS, SSET_SITUATIONAL)
GEN_INT("grass", map.grasssize, SSET_MAP_GEN, SSET_ECOLOGY, SSET_TO_CLIENT,
N_("Amount of grass squares"), "", NULL,
- MAP_MIN_GRASS, MAP_MAX_GRASS, MAP_DEFAULT_GRASS)
+ MAP_MIN_GRASS, MAP_MAX_GRASS, MAP_DEFAULT_GRASS, SSET_SITUATIONAL)
GEN_INT("forests", map.forestsize, SSET_MAP_GEN, SSET_ECOLOGY,
SSET_TO_CLIENT,
N_("Amount of forest squares"), "", NULL,
- MAP_MIN_FORESTS, MAP_MAX_FORESTS, MAP_DEFAULT_FORESTS)
+ MAP_MIN_FORESTS, MAP_MAX_FORESTS, MAP_DEFAULT_FORESTS,
SSET_SITUATIONAL)
GEN_INT("swamps", map.swampsize, SSET_MAP_GEN, SSET_ECOLOGY, SSET_TO_CLIENT,
N_("Amount of swamp squares"), "", NULL,
- MAP_MIN_SWAMPS, MAP_MAX_SWAMPS, MAP_DEFAULT_SWAMPS)
+ MAP_MIN_SWAMPS, MAP_MAX_SWAMPS, MAP_DEFAULT_SWAMPS, SSET_SITUATIONAL)
GEN_INT("deserts", map.deserts, SSET_MAP_GEN, SSET_ECOLOGY, SSET_TO_CLIENT,
N_("Amount of desert squares"), "", NULL,
- MAP_MIN_DESERTS, MAP_MAX_DESERTS, MAP_DEFAULT_DESERTS)
+ MAP_MIN_DESERTS, MAP_MAX_DESERTS, MAP_DEFAULT_DESERTS,
SSET_SITUATIONAL)
GEN_INT("seed", map.seed, SSET_MAP_GEN, SSET_INTERNAL, SSET_SERVER_ONLY,
N_("Map generation random seed"),
N_("The same seed will always produce the same map; "
"for zero (the default) a seed will be chosen based on "
"the time, to give a random map."), NULL,
- MAP_MIN_SEED, MAP_MAX_SEED, MAP_DEFAULT_SEED)
+ MAP_MIN_SEED, MAP_MAX_SEED, MAP_DEFAULT_SEED, SSET_RARE)
/* Map additional stuff: huts and specials. randseed also goes here
* because huts and specials are the first time the randseed gets used (?)
@@ -366,18 +383,18 @@
N_("General random seed"),
N_("For zero (the default) a seed will be chosen based "
"on the time."), NULL,
- GAME_MIN_RANDSEED, GAME_MAX_RANDSEED, GAME_DEFAULT_RANDSEED)
+ GAME_MIN_RANDSEED, GAME_MAX_RANDSEED, GAME_DEFAULT_RANDSEED,
SSET_RARE)
GEN_INT("specials", map.riches, SSET_MAP_ADD, SSET_ECOLOGY, SSET_TO_CLIENT,
N_("Amount of \"special\" resource squares"),
N_("Special resources improve the basic terrain type they "
"are on. The server variable's scale is parts per "
"thousand."), NULL,
- MAP_MIN_RICHES, MAP_MAX_RICHES, MAP_DEFAULT_RICHES)
+ MAP_MIN_RICHES, MAP_MAX_RICHES, MAP_DEFAULT_RICHES, SSET_VITAL)
GEN_INT("huts", map.huts, SSET_MAP_ADD, SSET_GEOLOGY, SSET_TO_CLIENT,
N_("Amount of huts (minor tribe villages)"), "", NULL,
- MAP_MIN_HUTS, MAP_MAX_HUTS, MAP_DEFAULT_HUTS)
+ MAP_MIN_HUTS, MAP_MAX_HUTS, MAP_DEFAULT_HUTS, SSET_VITAL)
/* Options affecting numbers of players and AI players. These only
* affect the start of the game and can not be adjusted after that.
@@ -389,7 +406,7 @@
N_("Minimum number of players"),
N_("There must be at least this many players (connected "
"players or AI's) before the game can start."), NULL,
- GAME_MIN_MIN_PLAYERS, GAME_MAX_MIN_PLAYERS, GAME_DEFAULT_MIN_PLAYERS)
+ GAME_MIN_MIN_PLAYERS, GAME_MAX_MIN_PLAYERS, GAME_DEFAULT_MIN_PLAYERS,
SSET_VITAL)
GEN_INT("maxplayers", game.max_players, SSET_PLAYERS, SSET_INTERNAL,
SSET_TO_CLIENT,
@@ -398,7 +415,7 @@
"the game. When this number of players are connected in "
"the pregame state, any new players who try to connect "
"will be rejected."), valid_max_players,
- GAME_MIN_MAX_PLAYERS, GAME_MAX_MAX_PLAYERS, GAME_DEFAULT_MAX_PLAYERS)
+ GAME_MIN_MAX_PLAYERS, GAME_MAX_MAX_PLAYERS, GAME_DEFAULT_MAX_PLAYERS,
SSET_VITAL)
GEN_INT("aifill", game.aifill, SSET_PLAYERS, SSET_INTERNAL, SSET_TO_CLIENT,
N_("Number of players to fill to with AI's"),
@@ -406,7 +423,7 @@
"game starts, extra AI players will be created to "
"increase the total number of players to the value of "
"this option."), NULL,
- GAME_MIN_AIFILL, GAME_MAX_AIFILL, GAME_DEFAULT_AIFILL)
+ GAME_MIN_AIFILL, GAME_MAX_AIFILL, GAME_DEFAULT_AIFILL, SSET_VITAL)
/* Game initialization parameters (only affect the first start of the game,
* and not reloads). Can not be changed after first start of game.
@@ -428,31 +445,31 @@
" D = Good defense unit (eg. Phalanx)\n"
" a = Fast attack unit (eg. Horsemen)\n"
" A = Strong attack unit (eg. Catapult)\n"),
- is_valid_startunits, GAME_DEFAULT_START_UNITS)
+ is_valid_startunits, GAME_DEFAULT_START_UNITS, SSET_VITAL)
GEN_INT("dispersion", game.dispersion, SSET_GAME_INIT, SSET_SOCIOLOGY,
SSET_TO_CLIENT,
N_("Area where initial units are located"),
N_("This is half the length of a side of the square within "
"which the initial units are dispersed."), NULL,
- GAME_MIN_DISPERSION, GAME_MAX_DISPERSION, GAME_DEFAULT_DISPERSION)
+ GAME_MIN_DISPERSION, GAME_MAX_DISPERSION, GAME_DEFAULT_DISPERSION,
SSET_SITUATIONAL)
GEN_INT("gold", game.gold, SSET_GAME_INIT, SSET_ECONOMICS, SSET_TO_CLIENT,
N_("Starting gold per player"), "", NULL,
- GAME_MIN_GOLD, GAME_MAX_GOLD, GAME_DEFAULT_GOLD)
+ GAME_MIN_GOLD, GAME_MAX_GOLD, GAME_DEFAULT_GOLD, SSET_VITAL)
GEN_INT("techlevel", game.tech, SSET_GAME_INIT, SSET_SCIENCE,
SSET_TO_CLIENT,
N_("Number of initial advances per player"), "", NULL,
- GAME_MIN_TECHLEVEL, GAME_MAX_TECHLEVEL, GAME_DEFAULT_TECHLEVEL)
+ GAME_MIN_TECHLEVEL, GAME_MAX_TECHLEVEL, GAME_DEFAULT_TECHLEVEL,
SSET_VITAL)
- GEN_INT("researchcost", game.researchcost, SSET_RULES, SSET_SCIENCE,
+ GEN_INT("researchcost", game.researchcost, SSET_RULES, SSET_SCIENCE,
SSET_TO_CLIENT,
N_("Points required to gain a new advance"),
N_("This affects how quickly players can research new "
"technology."), NULL,
GAME_MIN_RESEARCHCOST, GAME_MAX_RESEARCHCOST,
- GAME_DEFAULT_RESEARCHCOST)
+ GAME_DEFAULT_RESEARCHCOST, SSET_SITUATIONAL)
GEN_INT("techpenalty", game.techpenalty, SSET_RULES, SSET_SCIENCE,
SSET_TO_CLIENT,
@@ -462,7 +479,7 @@
"research points. This does not apply if you have just gained "
"tech this turn."), NULL,
GAME_MIN_TECHPENALTY, GAME_MAX_TECHPENALTY,
- GAME_DEFAULT_TECHPENALTY)
+ GAME_DEFAULT_TECHPENALTY, SSET_RARE)
GEN_INT("diplcost", game.diplcost, SSET_RULES, SSET_SCIENCE, SSET_TO_CLIENT,
N_("Penalty when getting tech from treaty"),
@@ -470,7 +487,7 @@
"research points equal to this percentage of the cost to "
"research an new advance. You can end up with negative "
"research points if this is non-zero."), NULL,
- GAME_MIN_DIPLCOST, GAME_MAX_DIPLCOST, GAME_DEFAULT_DIPLCOST)
+ GAME_MIN_DIPLCOST, GAME_MAX_DIPLCOST, GAME_DEFAULT_DIPLCOST,
SSET_RARE)
GEN_INT("conquercost", game.conquercost, SSET_RULES, SSET_SCIENCE,
SSET_TO_CLIENT,
@@ -480,7 +497,7 @@
"to research an new advance. You can end up with negative "
"research points if this is non-zero."), NULL,
GAME_MIN_CONQUERCOST, GAME_MAX_CONQUERCOST,
- GAME_DEFAULT_CONQUERCOST)
+ GAME_DEFAULT_CONQUERCOST, SSET_RARE)
GEN_INT("freecost", game.freecost, SSET_RULES, SSET_SCIENCE, SSET_TO_CLIENT,
N_("Penalty when getting a free tech"),
@@ -490,11 +507,11 @@
"percentage of the cost to research a new advance. You can "
"end up with negative research points if this is non-zero."),
NULL,
- GAME_MIN_FREECOST, GAME_MAX_FREECOST, GAME_DEFAULT_FREECOST)
+ GAME_MIN_FREECOST, GAME_MAX_FREECOST, GAME_DEFAULT_FREECOST,
SSET_RARE)
GEN_INT("foodbox", game.foodbox, SSET_RULES, SSET_ECONOMICS, SSET_TO_CLIENT,
N_("Food required for a city to grow"), "", NULL,
- GAME_MIN_FOODBOX, GAME_MAX_FOODBOX, GAME_DEFAULT_FOODBOX)
+ GAME_MIN_FOODBOX, GAME_MAX_FOODBOX, GAME_DEFAULT_FOODBOX,
SSET_SITUATIONAL)
GEN_INT("aqueductloss", game.aqueductloss, SSET_RULES, SSET_ECONOMICS,
SSET_TO_CLIENT,
@@ -504,7 +521,7 @@
"of its foodbox (or half that amount if it has a "
"Granary)."), NULL,
GAME_MIN_AQUEDUCTLOSS, GAME_MAX_AQUEDUCTLOSS,
- GAME_DEFAULT_AQUEDUCTLOSS)
+ GAME_DEFAULT_AQUEDUCTLOSS, SSET_RARE)
GEN_INT("fulltradesize", game.fulltradesize, SSET_RULES, SSET_ECONOMICS,
SSET_TO_CLIENT,
@@ -515,7 +532,7 @@
"except the normal corruption) for size=fulltradesize. "
"See also notradesize."), valid_fulltradesize,
GAME_MIN_FULLTRADESIZE, GAME_MAX_FULLTRADESIZE,
- GAME_DEFAULT_FULLTRADESIZE)
+ GAME_DEFAULT_FULLTRADESIZE, SSET_RARE)
GEN_INT("notradesize", game.notradesize, SSET_RULES, SSET_ECONOMICS,
SSET_TO_CLIENT,
@@ -526,7 +543,7 @@
"than fulltradesize. See also fulltradesize."),
valid_notradesize,
GAME_MIN_NOTRADESIZE, GAME_MAX_NOTRADESIZE,
- GAME_DEFAULT_NOTRADESIZE)
+ GAME_DEFAULT_NOTRADESIZE, SSET_RARE)
GEN_INT("unhappysize", game.unhappysize, SSET_RULES, SSET_SOCIOLOGY,
SSET_TO_CLIENT,
@@ -535,7 +552,7 @@
"city are content, and subsequent citizens are unhappy. "
"See also cityfactor."), NULL,
GAME_MIN_UNHAPPYSIZE, GAME_MAX_UNHAPPYSIZE,
- GAME_DEFAULT_UNHAPPYSIZE)
+ GAME_DEFAULT_UNHAPPYSIZE, SSET_RARE)
GEN_BOOL("angrycitizen", game.angrycitizen, SSET_RULES, SSET_SOCIOLOGY,
SSET_TO_CLIENT,
@@ -544,7 +561,7 @@
"citizens have to become unhappy before any other class "
"of citizens may be considered. See also unhappysize, "
"cityfactor and governments."), NULL,
- GAME_DEFAULT_ANGRYCITIZEN)
+ GAME_DEFAULT_ANGRYCITIZEN, SSET_SITUATIONAL)
GEN_INT("cityfactor", game.cityfactor, SSET_RULES, SSET_SOCIOLOGY,
SSET_TO_CLIENT,
@@ -554,7 +571,7 @@
"adjustments; see also unhappysize. This assumes a "
"Democracy; for other governments the effect occurs at "
"smaller numbers of cities."), NULL,
- GAME_MIN_CITYFACTOR, GAME_MAX_CITYFACTOR, GAME_DEFAULT_CITYFACTOR)
+ GAME_MIN_CITYFACTOR, GAME_MAX_CITYFACTOR, GAME_DEFAULT_CITYFACTOR,
SSET_RARE)
GEN_INT("citymindist", game.citymindist, SSET_RULES, SSET_SOCIOLOGY,
SSET_TO_CLIENT,
@@ -566,7 +583,7 @@
"to 0 (default), it is overwritten by the current ruleset "
"when the game starts."), NULL,
GAME_MIN_CITYMINDIST, GAME_MAX_CITYMINDIST,
- GAME_DEFAULT_CITYMINDIST)
+ GAME_DEFAULT_CITYMINDIST, SSET_SITUATIONAL)
GEN_INT("rapturedelay", game.rapturedelay, SSET_RULES, SSET_SOCIOLOGY,
SSET_TO_CLIENT,
@@ -574,14 +591,14 @@
N_("Sets the number of turns between rapture growth of a city. "
"If set to n a city will grow after rapturing n+1 turns."), NULL,
GAME_MIN_RAPTUREDELAY, GAME_MAX_RAPTUREDELAY,
- GAME_DEFAULT_RAPTUREDELAY)
+ GAME_DEFAULT_RAPTUREDELAY, SSET_SITUATIONAL)
GEN_INT("razechance", game.razechance, SSET_RULES, SSET_MILITARY,
SSET_TO_CLIENT,
N_("Chance for conquered building destruction"),
N_("When a player conquers a city, each City Improvement has this "
"percentage chance to be destroyed."), NULL,
- GAME_MIN_RAZECHANCE, GAME_MAX_RAZECHANCE, GAME_DEFAULT_RAZECHANCE)
+ GAME_MIN_RAZECHANCE, GAME_MAX_RAZECHANCE, GAME_DEFAULT_RAZECHANCE,
SSET_RARE)
GEN_INT("civstyle", game.civstyle, SSET_RULES, SSET_MILITARY, SSET_TO_CLIENT,
N_("Style of Civ rules"),
@@ -589,7 +606,7 @@
"Currently this option affects the following rules:\n"
" - Apollo shows whole map in Civ2, only cities in Civ1.\n"
"See also README.rulesets."), NULL,
- GAME_MIN_CIVSTYLE, GAME_MAX_CIVSTYLE, GAME_DEFAULT_CIVSTYLE)
+ GAME_MIN_CIVSTYLE, GAME_MAX_CIVSTYLE, GAME_DEFAULT_CIVSTYLE,
SSET_RARE)
GEN_INT("occupychance", game.occupychance, SSET_RULES, SSET_MILITARY,
SSET_TO_CLIENT,
@@ -601,7 +618,7 @@
"set to a value between 0 and 100, this will be used as "
"the percent chance of \"occupying\" territory."), NULL,
GAME_MIN_OCCUPYCHANCE, GAME_MAX_OCCUPYCHANCE,
- GAME_DEFAULT_OCCUPYCHANCE)
+ GAME_DEFAULT_OCCUPYCHANCE, SSET_RARE)
GEN_INT("killcitizen", game.killcitizen, SSET_RULES, SSET_MILITARY,
SSET_TO_CLIENT,
@@ -614,7 +631,7 @@
" 4 = heli\n"
" 8 = air"), NULL,
GAME_MIN_KILLCITIZEN, GAME_MAX_KILLCITIZEN,
- GAME_DEFAULT_KILLCITIZEN)
+ GAME_DEFAULT_KILLCITIZEN, SSET_RARE)
GEN_INT("wtowervision", game.watchtower_vision, SSET_RULES, SSET_MILITARY,
SSET_TO_CLIENT,
@@ -626,7 +643,7 @@
"'Watchtower' in the techs ruleset. Also see wtowerevision."),
NULL,
GAME_MIN_WATCHTOWER_VISION, GAME_MAX_WATCHTOWER_VISION,
- GAME_DEFAULT_WATCHTOWER_VISION)
+ GAME_DEFAULT_WATCHTOWER_VISION, SSET_RARE)
GEN_INT("wtowerevision", game.watchtower_extra_vision, SSET_RULES,
SSET_MILITARY, SSET_TO_CLIENT,
@@ -639,14 +656,14 @@
"value of wtowervision and wtowerevision will be used. "
"Also see wtowervision."), NULL,
GAME_MIN_WATCHTOWER_EXTRA_VISION, GAME_MAX_WATCHTOWER_EXTRA_VISION,
- GAME_DEFAULT_WATCHTOWER_EXTRA_VISION)
+ GAME_DEFAULT_WATCHTOWER_EXTRA_VISION, SSET_RARE)
GEN_INT("borders", game.borders, SSET_RULES, SSET_MILITARY, SSET_TO_CLIENT,
N_("National border's radius"),
N_("If this is set to greater than 0, nations will have territory "
"delineated by borders placed on the loci between cities, with "
"the maximum distance from any city specified."), NULL,
- GAME_MIN_BORDERS, GAME_MAX_BORDERS, GAME_DEFAULT_BORDERS)
+ GAME_MIN_BORDERS, GAME_MAX_BORDERS, GAME_DEFAULT_BORDERS,
SSET_SITUATIONAL)
GEN_INT("diplomacy", game.diplomacy, SSET_RULES, SSET_MILITARY,
SSET_TO_CLIENT,
@@ -657,7 +674,7 @@
"If set to 3, diplomacy is restricted to teams.\n"
"If set to 4, diplomacy is disabled for all.\n"
"You can always do diplomacy with players on your team."), NULL,
- GAME_MIN_DIPLOMACY, GAME_MAX_DIPLOMACY, GAME_DEFAULT_DIPLOMACY)
+ GAME_MIN_DIPLOMACY, GAME_MAX_DIPLOMACY, GAME_DEFAULT_DIPLOMACY,
SSET_SITUATIONAL)
GEN_INT("citynames", game.allowed_city_names, SSET_RULES, SSET_SOCIOLOGY,
SSET_TO_CLIENT,
@@ -671,7 +688,7 @@
"If set to 3, a player isn't allowed to use a default city name "
"of another nations."),NULL,
GAME_MIN_ALLOWED_CITY_NAMES, GAME_MAX_ALLOWED_CITY_NAMES,
- GAME_DEFAULT_ALLOWED_CITY_NAMES)
+ GAME_DEFAULT_ALLOWED_CITY_NAMES, SSET_RARE)
/* Flexible rules: these can be changed after the game has started.
*
@@ -695,14 +712,14 @@
"3 - frequent barbarian uprising \n"
"4 - raging hordes, lots of barbarians"), NULL,
GAME_MIN_BARBARIANRATE, GAME_MAX_BARBARIANRATE,
- GAME_DEFAULT_BARBARIANRATE)
+ GAME_DEFAULT_BARBARIANRATE, SSET_VITAL)
GEN_INT("onsetbarbs", game.onsetbarbarian, SSET_RULES_FLEXIBLE,
SSET_MILITARY, SSET_TO_CLIENT,
N_("Barbarian onset year"),
N_("Barbarians will not appear before this year."), NULL,
GAME_MIN_ONSETBARBARIAN, GAME_MAX_ONSETBARBARIAN,
- GAME_DEFAULT_ONSETBARBARIAN)
+ GAME_DEFAULT_ONSETBARBARIAN, SSET_VITAL)
GEN_INT("revolen", game.revolution_length, SSET_RULES_FLEXIBLE,
SSET_SOCIOLOGY, SSET_TO_CLIENT,
@@ -713,7 +730,7 @@
" Setting this value to 0 will give a random"
" length of 1-6 turns."), NULL,
GAME_MIN_REVOLUTION_LENGTH, GAME_MAX_REVOLUTION_LENGTH,
- GAME_DEFAULT_REVOLUTION_LENGTH)
+ GAME_DEFAULT_REVOLUTION_LENGTH, SSET_RARE)
GEN_BOOL("fogofwar", game.fogofwar, SSET_RULES_FLEXIBLE, SSET_MILITARY,
SSET_TO_CLIENT,
@@ -722,7 +739,7 @@
"the sightrange of your own units and cities will be "
"revealed to you. You will not see new cities or terrain "
"changes in squares not observed."), NULL,
- GAME_DEFAULT_FOGOFWAR)
+ GAME_DEFAULT_FOGOFWAR, SSET_RARE)
GEN_INT("diplchance", game.diplchance, SSET_RULES_FLEXIBLE, SSET_MILITARY,
SSET_TO_CLIENT,
@@ -737,13 +754,13 @@
"Defending Spys are generally twice as capable as "
"Diplomats, veteran units 50% more capable than "
"non-veteran ones."), NULL,
- GAME_MIN_DIPLCHANCE, GAME_MAX_DIPLCHANCE, GAME_DEFAULT_DIPLCHANCE)
+ GAME_MIN_DIPLCHANCE, GAME_MAX_DIPLCHANCE, GAME_DEFAULT_DIPLCHANCE,
SSET_SITUATIONAL)
GEN_BOOL("spacerace", game.spacerace, SSET_RULES_FLEXIBLE, SSET_SCIENCE,
SSET_TO_CLIENT,
N_("Whether to allow space race"),
N_("If this option is 1, players can build spaceships."), NULL,
- GAME_DEFAULT_SPACERACE)
+ GAME_DEFAULT_SPACERACE, SSET_VITAL)
GEN_INT("civilwarsize", game.civilwarsize, SSET_RULES_FLEXIBLE,
SSET_SOCIOLOGY, SSET_TO_CLIENT,
@@ -753,7 +770,7 @@
"this option is set to the maximum value, civil wars are "
"turned off altogether."), NULL,
GAME_MIN_CIVILWARSIZE, GAME_MAX_CIVILWARSIZE,
- GAME_DEFAULT_CIVILWARSIZE)
+ GAME_DEFAULT_CIVILWARSIZE, SSET_RARE)
GEN_INT("contactturns", game.contactturns, SSET_RULES_FLEXIBLE,
SSET_MILITARY, SSET_TO_CLIENT,
@@ -762,7 +779,7 @@
"after their units have last met. Set this to zero "
"to turn this feature off entirely."), NULL,
GAME_MIN_CONTACTTURNS, GAME_MAX_CONTACTTURNS,
- GAME_DEFAULT_CONTACTTURNS)
+ GAME_DEFAULT_CONTACTTURNS, SSET_RARE)
GEN_BOOL("savepalace", game.savepalace, SSET_RULES_FLEXIBLE, SSET_MILITARY,
SSET_TO_CLIENT,
@@ -770,14 +787,14 @@
N_("If this is set to 1 when the capital is conquered, palace "
"is automatically rebuilt for free in another randomly "
"choosed city, regardless on the knowledge of Masonry."), NULL,
- GAME_DEFAULT_SAVEPALACE)
+ GAME_DEFAULT_SAVEPALACE, SSET_RARE)
GEN_BOOL("naturalcitynames", game.natural_city_names,
SSET_RULES_FLEXIBLE, SSET_SOCIOLOGY, SSET_TO_CLIENT,
N_("Whether to use natural city names"),
N_("If enabled, the default city names will be determined based "
"on the surrounding terrain."),
- NULL, GAME_DEFAULT_NATURALCITYNAMES)
+ NULL, GAME_DEFAULT_NATURALCITYNAMES, SSET_RARE)
/* Meta options: these don't affect the internal rules of the game, but
* do affect players. Also options which only produce extra server
@@ -818,18 +835,18 @@
" 4 = No controller allowed, observers allowed;\n\n"
"* \"Displacing a connection\" means that you may take over "
"a player that another user already has control of."),
- is_valid_allowtake, GAME_DEFAULT_ALLOW_TAKE)
+ is_valid_allowtake, GAME_DEFAULT_ALLOW_TAKE, SSET_RARE)
GEN_BOOL("autotoggle", game.auto_ai_toggle, SSET_META, SSET_NETWORK,
SSET_TO_CLIENT,
N_("Whether AI-status toggles with connection"),
N_("If this is set to 1, AI status is turned off when a player "
"connects, and on when a player disconnects."), autotoggle,
- GAME_DEFAULT_AUTO_AI_TOGGLE)
+ GAME_DEFAULT_AUTO_AI_TOGGLE, SSET_SITUATIONAL)
GEN_INT("endyear", game.end_year, SSET_META, SSET_SOCIOLOGY, SSET_TO_CLIENT,
N_("Year the game ends"), "", NULL,
- GAME_MIN_END_YEAR, GAME_MAX_END_YEAR, GAME_DEFAULT_END_YEAR)
+ GAME_MIN_END_YEAR, GAME_MAX_END_YEAR, GAME_DEFAULT_END_YEAR,
SSET_VITAL)
#ifndef NDEBUG
GEN_INT( "timeout", game.timeout, SSET_META, SSET_INTERNAL, SSET_TO_CLIENT,
@@ -839,7 +856,7 @@
"means there is no timeout. In DEBUG servers, a timeout "
"of -1 sets the autogame test mode. Use this with the command "
"\"timeoutincrease\" to have a dynamic timer."), NULL,
- GAME_MIN_TIMEOUT, GAME_MAX_TIMEOUT, GAME_DEFAULT_TIMEOUT)
+ GAME_MIN_TIMEOUT, GAME_MAX_TIMEOUT, GAME_DEFAULT_TIMEOUT, SSET_VITAL)
#else
GEN_INT( "timeout", game.timeout, SSET_META, SSET_INTERNAL, SSET_TO_CLIENT,
N_("Maximum seconds per turn"),
@@ -847,7 +864,7 @@
"time is up, then the turn ends automatically. Zero "
"means there is no timeout. Use this with the command "
"\"timeoutincrease\" to have a dynamic timer."), NULL,
- GAME_MIN_TIMEOUT, GAME_MAX_TIMEOUT, GAME_DEFAULT_TIMEOUT)
+ GAME_MIN_TIMEOUT, GAME_MAX_TIMEOUT, GAME_DEFAULT_TIMEOUT, SSET_VITAL)
#endif
GEN_INT("tcptimeout", game.tcptimeout, SSET_META, SSET_NETWORK,
@@ -857,7 +874,7 @@
"this value, then the TCP connection is closed. Zero "
"means there is no timeout beyond that enforced by the "
"TCP protocol implementation itself."), NULL,
- GAME_MIN_TCPTIMEOUT, GAME_MAX_TCPTIMEOUT, GAME_DEFAULT_TCPTIMEOUT)
+ GAME_MIN_TCPTIMEOUT, GAME_MAX_TCPTIMEOUT, GAME_DEFAULT_TCPTIMEOUT,
SSET_RARE)
GEN_INT("netwait", game.netwait, SSET_META, SSET_NETWORK, SSET_TO_CLIENT,
N_("Max seconds for TCP buffers to drain"),
@@ -865,20 +882,20 @@
"parameter in seconds, for all client connection TCP "
"buffers to unblock. Zero means the server will not "
"wait at all."), NULL,
- GAME_MIN_NETWAIT, GAME_MAX_NETWAIT, GAME_DEFAULT_NETWAIT)
+ GAME_MIN_NETWAIT, GAME_MAX_NETWAIT, GAME_DEFAULT_NETWAIT, SSET_RARE)
GEN_INT("pingtime", game.pingtime, SSET_META, SSET_NETWORK, SSET_TO_CLIENT,
N_("Seconds between PINGs"),
N_("The civserver will poll the clients with a PING request "
"each time this period elapses."), NULL,
- GAME_MIN_PINGTIME, GAME_MAX_PINGTIME, GAME_DEFAULT_PINGTIME)
+ GAME_MIN_PINGTIME, GAME_MAX_PINGTIME, GAME_DEFAULT_PINGTIME,
SSET_RARE)
GEN_INT("pingtimeout", game.pingtimeout, SSET_META, SSET_NETWORK,
SSET_TO_CLIENT,
N_("Time to cut a client"),
N_("If a client doesn't reply to a PONG in this time the "
"client is disconnected."), NULL,
- GAME_MIN_PINGTIMEOUT, GAME_MAX_PINGTIMEOUT, GAME_DEFAULT_PINGTIMEOUT)
+ GAME_MIN_PINGTIMEOUT, GAME_MAX_PINGTIMEOUT, GAME_DEFAULT_PINGTIMEOUT,
SSET_RARE)
GEN_BOOL("turnblock", game.turnblock, SSET_META, SSET_INTERNAL,
SSET_TO_CLIENT,
@@ -886,7 +903,7 @@
N_("If this is set to 1 the game turn is not advanced "
"until all players have finished their turn, including "
"disconnected players."), NULL,
- GAME_DEFAULT_TURNBLOCK)
+ GAME_DEFAULT_TURNBLOCK, SSET_SITUATIONAL)
GEN_BOOL("fixedlength", game.fixedlength, SSET_META, SSET_INTERNAL,
SSET_TO_CLIENT,
@@ -894,7 +911,7 @@
N_("If this is set to 1 the game turn will not advance "
"until the timeout has expired, irrespective of players "
"clicking on \"Turn Done\"."), NULL,
- FALSE)
+ FALSE, SSET_SITUATIONAL)
GEN_STRING("demography", game.demography, SSET_META, SSET_INTERNAL,
SSET_TO_CLIENT,
@@ -919,14 +936,14 @@
" b = display \"best nation\" column\n"
"(The order of these characters is not significant, but their
case is.)"),
is_valid_demography,
- GAME_DEFAULT_DEMOGRAPHY)
+ GAME_DEFAULT_DEMOGRAPHY, SSET_SITUATIONAL)
GEN_INT("saveturns", game.save_nturns, SSET_META, SSET_INTERNAL,
SSET_SERVER_ONLY,
N_("Turns per auto-save"),
N_("The game will be automatically saved per this number of turns.\n"
"Zero means never auto-save."), NULL,
- 0, 200, 10)
+ 0, 200, 10, SSET_VITAL)
/* Could undef entire option if !HAVE_LIBZ, but this way users get to see
* what they're missing out on if they didn't compile with zlib? --dwp
@@ -941,7 +958,7 @@
"this server was not compiled to use zlib."), NULL,
GAME_MIN_COMPRESS_LEVEL, GAME_MAX_COMPRESS_LEVEL,
- GAME_DEFAULT_COMPRESS_LEVEL)
+ GAME_DEFAULT_COMPRESS_LEVEL, SSET_RARE)
#else
GEN_INT("compress", game.save_compress_level, SSET_META, SSET_INTERNAL,
SSET_SERVER_ONLY,
@@ -952,7 +969,7 @@
"this server was not compiled to use zlib."), NULL,
GAME_NO_COMPRESS_LEVEL, GAME_NO_COMPRESS_LEVEL,
- GAME_NO_COMPRESS_LEVEL)
+ GAME_NO_COMPRESS_LEVEL, SSET_RARE)
#endif
GEN_STRING("savename", game.save_name, SSET_META, SSET_INTERNAL,
@@ -961,7 +978,7 @@
N_("Automatically saved games will have name "
"\"<prefix><year>.sav\".\nThis setting sets "
"the <prefix> part."), NULL,
- GAME_DEFAULT_SAVE_NAME)
+ GAME_DEFAULT_SAVE_NAME, SSET_VITAL)
GEN_BOOL("scorelog", game.scorelog, SSET_META, SSET_INTERNAL,
SSET_SERVER_ONLY,
@@ -969,7 +986,7 @@
N_("If this is set to 1, player statistics are appended to "
"the file \"civscore.log\" every turn. These statistics "
"can be used to create power graphs after the game."), NULL,
- GAME_DEFAULT_SCORELOG)
+ GAME_DEFAULT_SCORELOG, SSET_SITUATIONAL)
GEN_INT("gamelog", gamelog_level, SSET_META, SSET_INTERNAL, SSET_SERVER_ONLY,
N_("Detail level for logging game events"),
@@ -977,7 +994,7 @@
"(with the -g command line option). "
"Levels: 0=no logging, 20=standard logging, 30=detailed logging, "
"40=debuging logging."), NULL,
- 0, 40, 20)
+ 0, 40, 20, SSET_SITUATIONAL)
GEN_END
};
@@ -2603,6 +2620,21 @@
}
/**************************************************************************
+Find option level number by name.
+**************************************************************************/
+static enum sset_level lookup_option_level(const char *name)
+{
+ enum sset_level i;
+ for (i = SSET_ALL; i <= SSET_RARE; i++) {
+ if (0 == mystrcasecmp(name, sset_level_names[i])) {
+ return i;
+ }
+ }
+
+ return SSET_NONE;
+}
+
+/**************************************************************************
Find option index by name. Return index (>=0) on success, -1 if no
suitable options were found, -2 if several matches were found.
**************************************************************************/
@@ -2611,6 +2643,11 @@
enum m_pre_result result;
int ind;
+ // Check for option levels, first off
+ if (lookup_option_level(name) != SSET_NONE) {
+ return -3;
+ }
+
result = match_prefix(optname_accessor, SETTINGS_NUM, 0, mystrncasecmp,
name, &ind);
@@ -3019,6 +3056,7 @@
char buf[MAX_LEN_CONSOLE_LINE];
char command[MAX_LEN_CONSOLE_LINE], *cptr_s, *cptr_d;
int cmd,i,len1;
+ enum sset_level level = SSET_VITAL;
size_t clen = 0;
for (cptr_s = str; *cptr_s != '\0' && !my_isalnum(*cptr_s); cptr_s++) {
@@ -3031,6 +3069,7 @@
if (*command != '\0') {
cmd=lookup_option(command);
if (cmd>=0 && !may_view_option(caller, cmd)) {
+ level=SSET_NONE;
cmd_reply(CMD_SHOW, caller, C_FAIL,
_("Sorry, you do not have access to view option '%s'."),
command);
@@ -3044,6 +3083,10 @@
/* allow ambiguous: show all matching */
clen = strlen(command);
}
+ if (cmd==-3) {
+ /* Option level */
+ level = lookup_option_level(command);
+ }
} else {
cmd = -1; /* to indicate that no comannd was specified */
}
@@ -3054,6 +3097,22 @@
/* under SSET_MAX_LEN, so it fits into 80 cols more easily - rp */
cmd_reply_show(horiz_line);
+ switch(level) {
+ case SSET_NONE:
+ break;
+ case SSET_ALL:
+ cmd_reply_show(N_("All options"));
+ break;
+ case SSET_VITAL:
+ cmd_reply_show(N_("Vital options"));
+ break;
+ case SSET_SITUATIONAL:
+ cmd_reply_show(N_("Situational options"));
+ break;
+ case SSET_RARE:
+ cmd_reply_show(N_("Rarely used options"));
+ break;
+ }
cmd_reply_show(_("+ means you may change the option"));
cmd_reply_show(_("= means the option is on its default value"));
cmd_reply_show(horiz_line);
@@ -3069,55 +3128,61 @@
for (i=0;settings[i].name;i++) {
if (may_view_option(caller, i)
- && (cmd==-1 || cmd==i
+ && (cmd==-1 || cmd==-3 || cmd==i
|| (cmd==-2 && mystrncasecmp(settings[i].name, command, clen)==0)))
{
/* in the cmd==i case, this loop is inefficient. never mind - rp */
struct settings_s *op = &settings[i];
int len = 0;
- switch (op->type) {
- case SSET_BOOL:
- len = my_snprintf(buf, sizeof(buf),
- "%-*s %c%c%-5d (0,1)", OPTION_NAME_SPACE, op->name,
- may_set_option_now(caller, i) ? '+' : ' ',
- ((*op->bool_value == op->bool_default_value) ?
- '=' : ' '), (*op->bool_value) ? 1 : 0);
- break;
-
- case SSET_INT:
- len = my_snprintf(buf, sizeof(buf),
- "%-*s %c%c%-5d (%d,%d)", OPTION_NAME_SPACE,
- op->name, may_set_option_now(caller,
- i) ? '+' : ' ',
- ((*op->int_value == op->int_default_value) ?
- '=' : ' '),
- *op->int_value, op->int_min_value,
- op->int_max_value);
- break;
-
- case SSET_STRING:
- len = my_snprintf(buf, sizeof(buf),
- "%-*s %c%c\"%s\"", OPTION_NAME_SPACE, op->name,
- may_set_option_now(caller, i) ? '+' : ' ',
- ((strcmp(op->string_value,
- op->string_default_value) == 0) ?
- '=' : ' '), op->string_value);
- break;
- }
- if (len == -1) {
- len = sizeof(buf) - 1;
- }
- /* Line up the descriptions: */
- if(len < len1) {
- cat_snprintf(buf, sizeof(buf), "%*s", (len1-len), " ");
- } else {
- sz_strlcat(buf, " ");
+ if (level == SSET_ALL || op->level == level) {
+ switch (op->type) {
+ case SSET_BOOL:
+ len = my_snprintf(buf, sizeof(buf),
+ "%-*s %c%c%-5d (0,1)", OPTION_NAME_SPACE, op->name,
+ may_set_option_now(caller, i) ? '+' : ' ',
+ ((*op->bool_value == op->bool_default_value) ?
+ '=' : ' '), (*op->bool_value) ? 1 : 0);
+ break;
+
+ case SSET_INT:
+ len = my_snprintf(buf, sizeof(buf),
+ "%-*s %c%c%-5d (%d,%d)", OPTION_NAME_SPACE,
+ op->name, may_set_option_now(caller,
+ i) ? '+' : ' ',
+ ((*op->int_value == op->int_default_value) ?
+ '=' : ' '),
+ *op->int_value, op->int_min_value,
+ op->int_max_value);
+ break;
+
+ case SSET_STRING:
+ len = my_snprintf(buf, sizeof(buf),
+ "%-*s %c%c\"%s\"", OPTION_NAME_SPACE, op->name,
+ may_set_option_now(caller, i) ? '+' : ' ',
+ ((strcmp(op->string_value,
+ op->string_default_value) == 0) ?
+ '=' : ' '), op->string_value);
+ break;
+ }
+ if (len == -1) {
+ len = sizeof(buf) - 1;
+ }
+ /* Line up the descriptions: */
+ if(len < len1) {
+ cat_snprintf(buf, sizeof(buf), "%*s", (len1-len), " ");
+ } else {
+ sz_strlcat(buf, " ");
+ }
+ sz_strlcat(buf, _(op->short_help));
+ cmd_reply_show(buf);
}
- sz_strlcat(buf, _(op->short_help));
- cmd_reply_show(buf);
}
}
cmd_reply_show(horiz_line);
+ if (level == SSET_VITAL) {
+ cmd_reply_show(_("Try 'show situational' or 'show rare' to show more
options"));
+ cmd_reply_show(horiz_line);
+ }
return TRUE;
#undef cmd_reply_show
#undef OPTION_NAME_SPACE
- [Freeciv-Dev] (PR#9434) Patch: Option levels,
Gregory Richards <=
|
|