25#ifdef FREECIV_HAVE_LIBREADLINE
26#include <readline/readline.h>
98#define OPTION_NAME_SPACE 25
106#define SPECHASH_TAG kick
107#define SPECHASH_ASTR_KEY_TYPE
108#define SPECHASH_IDATA_TYPE time_t *
109#define SPECHASH_UDATA_TYPE time_t
110#define SPECHASH_IDATA_COPY time_duplicate
111#define SPECHASH_IDATA_FREE (kick_hash_data_free_fn_t) free
112#define SPECHASH_UDATA_TO_IDATA(t) (&(t))
113#define SPECHASH_IDATA_TO_UDATA(p) (NULL != p ? *p : 0)
128 const char *level_name,
bool check);
130 enum ai_level
level,
bool check);
137 char *
str,
bool check);
141 bool check,
int read_recursion);
150 bool check,
int read_recursion);
152 char *script_filename,
bool from_cmdline,
153 bool check,
int read_recursion);
170 char *
str,
bool check);
172 char *
str,
bool check);
179"------------------------------------------------------------------------------";
199 fc_snprintf(buf, buflen,
_(
"Can't use an empty name."));
202 fc_snprintf(buf, buflen,
_(
"That name exceeds the maximum of %d chars."),
207 fc_snprintf(buf, buflen,
_(
"That name is not allowed."));
338 const char *cmdname = cmd <
CMD_NUM
350 "/%s: %s%s", cmdname, prefix, line);
364 if (caller != pconn) {
370 if (NULL != caller) {
383 const char *format, va_list ap)
391 while ((c1 = strstr(c0,
"\n"))) {
406 const char *format, ...)
410 const
char *format, ...)
413 va_start(ap, format);
425 va_start(ap, format);
439 switch (match_result) {
442 _(
"Name is empty, so cannot be a player."));
446 _(
"Name is too long, so cannot be a player."));
450 _(
"Player name prefix '%s' is ambiguous."),
name);
454 _(
"No player by the name of '%s'."),
name);
458 _(
"Unexpected match_result %d (%s) for '%s'."),
460 log_error(
"Unexpected match_result %d (%s) for '%s'.",
474 switch (match_result) {
477 _(
"Name is empty, so cannot be a connection."));
481 _(
"Name is too long, so cannot be a connection."));
485 _(
"Connection name prefix '%s' is ambiguous."),
name);
489 _(
"No connection by the name of '%s'."),
name);
493 _(
"Unexpected match_result %d (%s) for '%s'."),
495 log_error(
"Unexpected match_result %d (%s) for '%s'.",
509 _(
"Open metaserver connection to [%s]."),
522 _(
"Close metaserver connection to [%s]."),
536 || (!strcmp(arg,
"?"))) {
539 _(
"Metaserver connection is open."));
542 _(
"Metaserver connection is closed."));
561 _(
"Metaserver connection is already open."));
572 _(
"Metaserver connection is already closed."));
577 _(
"Argument must be 'u', 'up', 'd', 'down', 'p', 'persistent', or '?'."));
587 char *arg,
bool check)
598 _(
"Metaserver patches string set to '%s'."), arg);
601 _(
"Metaserver patches string set to '%s', "
602 "not reporting to metaserver."), arg);
612 char *arg,
bool check)
617 "Set metamessage setting instead."));
627 _(
"Metaserver message string set to '%s'."), arg);
630 _(
"Metaserver message string set to '%s', "
631 "not reporting to metaserver."), arg);
678 _(
"You cannot save games manually on this server."));
695 _(
"You cannot save games manually on this server."));
713 _(
"%s is now under AI control."),
722 _(
"%s is now under human control."),
764 const char *ai_type_name;
771 }
else if (ntokens == 2) {
772 ai_type_name = arg[1];
775 _(
"Wrong number of arguments to create command."));
782 NULL, NULL, buf,
sizeof(buf));
785 NULL, buf,
sizeof(buf));
796 if (strlen(buf) > 0) {
817 struct player **newplayer,
818 char *buf,
size_t buflen)
820 struct player *pplayer = NULL;
822 bool new_slot =
FALSE;
834 _(
"A living user already exists by that name."));
842 _(
"A living player already exists by that name."));
849 _(
"Can't create player, requested nation %s not in "
850 "current nation set."),
857 _(
"Can't create players, nation %s conflicts with %s."),
868 _(
"Can't create players, no nations available."));
873 if (pplayer == NULL) {
875 bool dead_found =
FALSE;
878 if (!aplayer->is_alive) {
886 _(
"Can't create players, no slots available."));
891 _(
"Maxplayers setting prevents creation of more players."));
908 _(
"%s is replacing dead player %s as an AI-controlled "
915 bool dead_found =
FALSE;
918 if (!aplayer->is_alive) {
922 _(
"%s is replacing dead player %s as an AI-controlled "
963 cat_snprintf(buf, buflen,
_(
" Nation of the new player: %s."),
988 if (newplayer != NULL) {
989 *newplayer = pplayer;
1004 struct player **newplayer,
1005 char *buf,
size_t buflen)
1008 struct player *pplayer = NULL;
1009 bool rand_name =
FALSE;
1011 if (
name[0] ==
'\0') {
1028 _(
"A player already exists by that name."));
1033 _(
"A user already exists by that name."));
1040 if (NULL == pplayer) {
1044 _(
"Can't add more players, server is full."));
1051 _(
"Can't add more players, not enough playable nations "
1052 "in current nation set (see 'nationset' setting)."));
1055 _(
"Can't add more players, not enough playable nations."));
1066 _(
"There is no AI type %s."), ai);
1083 _(
"%s replacing %s as an AI-controlled player."),
1094 _(
"Failed to create new player %s."),
name);
1099 _(
"%s has been added as an AI-controlled player (%s)."),
1119 if (newplayer != NULL) {
1120 *newplayer = pplayer;
1137 if (NULL == pplayer) {
1144 _(
"Command level '%s' or greater needed to remove a player "
1145 "once the game has started."), cmdlevel_name(ALLOW_ADMIN));
1154 if (!caller || caller->
used) {
1156 _(
"Removed player %s from the game."),
name);
1175 bool from_cmdline,
bool check)
1193 char *script_filename,
bool from_cmdline,
1194 bool check,
int read_recursion)
1197 char serv_filename[strlen(
script_extension) + strlen(script_filename) + 2];
1198 char tilde_filename[4096];
1199 const char *real_filename;
1204 log_error(
"Error: recursive calls to read!");
1209 fnlen = strlen(script_filename);
1210 real_filename = script_filename + fnlen
1213 fc_snprintf(serv_filename,
sizeof(serv_filename),
"%s%s",
1222 _(
"Name \"%s\" disallowed for security reasons."),
1228 interpret_tilde(tilde_filename,
sizeof(tilde_filename), serv_filename);
1232 if (!real_filename) {
1235 _(
"No command script found by the name \"%s\"."),
1240 real_filename = tilde_filename;
1246 && (script_file =
fc_fopen(real_filename,
"r"))) {
1254 fclose(script_file);
1261 _(
"Cannot read command line scriptfile '%s'."), real_filename);
1262 if (NULL != caller) {
1263 log_error(
_(
"Could not read script file '%s'."), real_filename);
1287 char real_filename[1024], buf[256];
1290 interpret_tilde(real_filename,
sizeof(real_filename), script_filename);
1293 && (script_file =
fc_fopen(real_filename,
"w"))) {
1294 fprintf(script_file,
1295 "#FREECIV SERVER COMMAND FILE, version %s\n", VERSION_STRING);
1296 fputs(
"# These are server options saved from a running freeciv-server.\n",
1305 fprintf(script_file,
"cmdlevel %s new\n",
1308 fprintf(script_file,
"cmdlevel %s first\n",
1311 fprintf(script_file,
"%s\n",
1326 fprintf(script_file,
"set %s \"%s\"\n",
setting_name(pset),
1330 fclose(script_file);
1334 log_error(
_(
"Could not write script file '%s'."), real_filename);
1347 _(
"You cannot use the write command on this server"
1348 " for security reasons."));
1350 }
else if (!check) {
1352 const char *real_filename;
1353 size_t arglen = strlen(arg);
1358 fc_snprintf(serv_filename,
sizeof(serv_filename),
"%s%s",
1367 _(
"Failed to write %s."), serv_filename);
1373 _(
"Wrote %s."), serv_filename);
1384 enum cmdlevel
level)
1399 _(
"Cannot decrease command access level '%s' "
1400 "for connection '%s'; you only have '%s'."),
1408 _(
"Command access level set to '%s' for connection %s."),
1458 _(
"Anyone can now become game organizer "
1459 "'%s' by issuing the 'first' command."),
1473 enum cmdlevel
level;
1482 _(
"Command access levels in effect:"));
1487 if (lvl_name != NULL) {
1495 _(
"Command access level for new connections: %s"),
1498 _(
"Command access level for first player to take it: %s"),
1506 if (!cmdlevel_is_valid(
level)) {
1507 const char *cmdlevel_names[CMDLEVEL_COUNT];
1511 for (
level = cmdlevel_begin();
level != cmdlevel_end();
1513 cmdlevel_names[i++] = cmdlevel_name(
level);
1517 _(
"Command access level must be one of %s."),
1523 _(
"Cannot increase command access level to '%s';"
1524 " you only have '%s' yourself."),
1536 if (pconn != caller) {
1550 _(
"Command access level set to '%s' for new players."),
1551 cmdlevel_name(
level));
1555 _(
"Command access level set to '%s' "
1556 "for first player to grab it."),
1557 cmdlevel_name(
level));
1564 _(
"Command access level set to '%s' for new players."),
1565 cmdlevel_name(
level));
1569 _(
"Command access level set to '%s' "
1570 "for first player to grab it."),
1571 cmdlevel_name(
level));
1579 _(
"Command access level set to '%s' "
1580 "for first player to grab it."),
1581 cmdlevel_name(
level));
1585 _(
"Command access level set to '%s' for new players."),
1586 cmdlevel_name(
level));
1614 _(
"The 'first' command makes no sense from the server command line."));
1618 _(
"You already have command access level '%s' or better."),
1623 _(
"Someone else is already game organizer."));
1625 }
else if (!check) {
1628 _(
"Connection %s has opted to become the game organizer."),
1641 _(
"Default cmdlevel lowered to 'basic' on game start."));
1655#ifdef FREECIV_HAVE_LIBREADLINE
1659static const char *olvlname_accessor(
int i)
1662 return "rulesetdir";
1663 }
else if (i < OLEVELS_NUM+1) {
1664 return sset_level_name(i-1);
1689 for (i = 0; i < ntokens; i++) {
1722 for (i = SSET_ALL; i < OLEVELS_NUM; i++) {
1732#define LOOKUP_OPTION_NO_RESULT (-1)
1733#define LOOKUP_OPTION_AMBIGUOUS (-2)
1734#define LOOKUP_OPTION_LEVEL_NAME (-3)
1735#define LOOKUP_OPTION_RULESETDIR (-4)
1760 }
else if (
'\0' !=
name[0]
1776 char val_buf[256], def_buf[256];
1778 const char *sethelp;
1792 if (strlen(sethelp) > 0) {
1802 ?
_(
"changeable") :
_(
"fixed")));
1811 _(
"Value:"), val_buf,
1813 _(
"Default:"), def_buf,
1832 _(
"Value:"), val_buf,
_(
"Default:"), def_buf);
1840 _(
"Possible values (option can take any number of these):"));
1846 _(
"Value:"), val_buf);
1848 _(
"Default:"), def_buf);
1868 _(
"Explanations are available for the following server options:"));
1882 if ((++j % 4) == 0) {
1889 if (buf[0] !=
'\0') {
1913 _(
"No explanation for that yet."));
1919 log_error(
"Unexpected case %d in %s line %d", cmd, __FILE__,
1936 _(
"Server Operator: %s"),
str);
1956 for (i = 0; c < bufsize -1 &&
str[i] !=
'\0'; i++) {
1957 if (
str[i] ==
'\\') {
1960 if (
str[i] ==
'n') {
1975 _(
"Connectmsg truncated to %u bytes."), bufsize);
1988 case AI_LEVEL_AWAY :
return CMD_AWAY;
1991 case AI_LEVEL_EASY :
return CMD_EASY;
1993 case AI_LEVEL_HARD :
return CMD_HARD;
1996 case AI_LEVEL_EXPERIMENTAL :
return CMD_EXPERIMENTAL;
2012 _(
"Player '%s' now has AI skill level '%s'."),
2014 ai_level_translated_name(
level));
2022 const char *level_name,
bool check)
2033 enum ai_level
level,
bool check)
2043 if (
is_ai(pplayer)) {
2050 _(
"Player '%s' now has AI skill level '%s'."),
2052 ai_level_translated_name(
level));
2055 _(
"%s is not controlled by the AI."),
2064 if (
is_ai(cplayer)) {
2068 _(
"Player '%s' now has AI skill level '%s'."),
2070 ai_level_translated_name(
level));
2076 _(
"Default AI skill level set to '%s'."),
2077 ai_level_translated_name(
level));
2092 if (caller == NULL) {
2100 _(
"Only players may use the away command."));
2130 bool check,
int read_recursion)
2132 char *show_arg =
"changed";
2135 if (read_recursion != 0) {
2166 char *
str,
bool check)
2169 enum sset_level
level = SSET_ALL;
2173 if (
str[0] !=
'\0') {
2183 _(
"Sorry, you do not have access to view option '%s'."),
2205 _(
"Current ruleset directory is \"%s\""),
2220#define cmd_reply_show(string) \
2221 cmd_reply(called_as, caller, C_COMMENT, "%s", string)
2224 const char *heading = NULL;
2229 heading =
_(
"All options with non-default values");
2232 heading =
_(
"All options");
2235 heading =
_(
"Vital options");
2237 case SSET_SITUATIONAL:
2238 heading =
_(
"Situational options");
2241 heading =
_(
"Rarely used options");
2244 heading =
_(
"Options locked by the ruleset");
2256 cmd_reply_show(
_(
"In the column '##' the status of the option is shown:"));
2257 cmd_reply_show(
_(
" - a '!' means the option is locked by the ruleset."));
2259 cmd_reply_show(
_(
" - a '~' means that option follows default value."));
2282 case SSET_SITUATIONAL:
2306 cmd_reply_show(
_(
"A help text for each option is available via 'help "
2309 if (
level == SSET_VITAL) {
2312 "Try 'show changed' to show settings with "
2313 "non-default values.\n"
2314 "Try 'show locked' to show settings locked "
2315 "by the ruleset."));
2320#undef cmd_reply_show
2352 if (prefix[0] ==
'\0') {
2353 memset(prefix,
' ',
sizeof(prefix)-1);
2369 char *p = strchr(nl,
'\n');
2385 }
else if (is_changed) {
2412 _(
"Cannot change teams once game has begun."));
2416 if (
str != NULL || strlen(
str) > 0) {
2422 _(
"Undefined argument. Usage:\n%s"),
2428 if (pplayer == NULL) {
2434 if (NULL == tslot) {
2442 if (NULL == tslot) {
2444 _(
"No such team %s. Please give a "
2445 "valid team name or number."), arg[1]);
2467 for (i = 0; i < ntokens; i++) {
2492 _(
"%s %d \"%s\" (needs %0.0f%%%s): %d for, "
2493 "%d against, and %d abstained out of %d players."),
2494 title, pvote->vote_no, pvote->cmdline,
2495 MIN(100, pvote->need_pc * 100 + 1),
2498 pvote->yes, pvote->no, pvote->abstain,
count_voters(pvote));
2505 _(
"There are no votes going on."));
2531 int ntokens = 0, i = 0, which = -1;
2533 struct vote *pvote = NULL;
2550 _(
"You are not allowed to use this command."));
2559 _(
"The argument \"%s\" is ambiguous."), arg[0]);
2564 _(
"Undefined argument. Usage:\n%s"),
2574 int num_votes = vote_list_size(
vote_list);
2575 if (num_votes == 0) {
2580 num_votes,
PL_(
"other vote running",
"other votes running",
2600 _(
"You are not allowed to vote on that."));
2614 _(
"You abstained from voting on \"%s\""), pvote->
cmdline);
2632 char *arg,
bool check)
2634 struct vote *pvote = NULL;
2646 if (arg[0] ==
'\0') {
2647 if (caller == NULL) {
2651 _(
"Missing argument <vote number> or "
2652 "the string \"all\"."));
2658 _(
"You don't have any vote going on."));
2665 _(
"There isn't any vote going on."));
2671 _(
"All votes have been removed."));
2675 _(
"You are not allowed to use this command."));
2690 _(
"You are not allowed to cancel this vote (%d)."),
2697 _(
"Usage: /cancelvote [<vote number>|all]"));
2707 _(
"%s has canceled the vote \"%s\" (number %d)."),
2714 _(
"The vote \"%s\" (number %d) has been canceled."),
2735 _(
"Can only use this command once game has begun."));
2742 if (
str != NULL && strlen(
str) > 0) {
2749 if (ntokens > 0 && strcmp(arg[0],
"diplomacy") == 0) {
2755 _(
"Undefined argument. Usage:\n%s"),
2760 if (pplayer == NULL) {
2774 }
else if (ntokens > 0 && strcmp(arg[0],
"tech") == 0) {
2780 _(
"Undefined argument. Usage:\n%s"),
2785 if (pplayer == NULL) {
2799 }
else if (ntokens > 0 && strcmp(arg[0],
"info") == 0) {
2800 int cities = 0, players = 0,
units = 0, citizen_count = 0;
2808 units += unit_list_size(plr->units);
2810 log_normal(
_(
"players=%d cities=%d citizens=%d units=%d"),
2813 _(
"players=%d cities=%d citizens=%d units=%d"),
2815 }
else if (ntokens > 0 && strcmp(arg[0],
"city") == 0) {
2822 _(
"Undefined argument. Usage:\n%s"),
2847 }
else if (ntokens > 0 && strcmp(arg[0],
"units") == 0) {
2853 _(
"Undefined argument. Usage:\n%s"),
2878 }
else if (ntokens > 0 && strcmp(arg[0],
"timing") == 0) {
2880 }
else if (ntokens > 0 && strcmp(arg[0],
"ferries") == 0) {
2889 }
else if (ntokens > 0 && strcmp(arg[0],
"unit") == 0) {
2895 _(
"Undefined argument. Usage:\n%s"),
2920 _(
"Undefined argument. Usage:\n%s"),
2924 for (i = 0; i < ntokens; i++) {
2952 _(
"Use the '%srulesetdir' command to change the ruleset "
2953 "directory."), caller ?
"/" :
"");
2974 char reject_msg[256] =
"";
2982 _(
"Undefined argument. Usage:\n%s"),
3008 reject_msg,
sizeof(reject_msg)))) {
3013 reject_msg,
sizeof(reject_msg))) {
3024 _(
"The parameter %s should only contain +- and 0-9."),
3032 sizeof(reject_msg))) {
3038 sizeof(reject_msg))) {
3052 sizeof(reject_msg))) {
3058 sizeof(reject_msg))) {
3072 reject_msg,
sizeof(reject_msg)))) {
3077 reject_msg,
sizeof(reject_msg))) {
3090 reject_msg,
sizeof(reject_msg)))) {
3095 reject_msg,
sizeof(reject_msg))) {
3111 if (!check && do_update) {
3154 struct player *pplayer,
bool will_obs,
3155 char *msg,
size_t msg_len)
3159 if (!pplayer && !will_obs) {
3163 fc_strlcpy(msg,
_(
"You cannot take a new player at this time."),
3171 PL_(
"You cannot take a new player because "
3172 "the maximum of %d player has already "
3173 "been reached (maxplayers setting).",
3174 "You cannot take a new player because "
3175 "the maximum of %d players has already "
3176 "been reached (maxplayers setting).",
3183 fc_strlcpy(msg,
_(
"You cannot take a new player because there "
3184 "are no free player slots."),
3204 if (!pplayer && will_obs) {
3208 fc_strlcpy(msg,
_(
"Sorry, one can't observe globally in this game."),
3216 _(
"Sorry, one can't observe barbarians in this game."),
3219 fc_strlcpy(msg,
_(
"Sorry, one can't take barbarians in this game."),
3228 _(
"Sorry, one can't observe dead players in this game."),
3232 _(
"Sorry, one can't take dead players in this game."),
3237 }
else if (
is_ai(pplayer)) {
3242 _(
"Sorry, one can't observe AI players in this game."),
3245 fc_strlcpy(msg,
_(
"Sorry, one can't take AI players in this game."),
3255 _(
"Sorry, one can't observe human players in this game."),
3259 _(
"Sorry, one can't take human players in this game."),
3268 if (will_obs && (*allow ==
'2' || *allow ==
'3')) {
3269 fc_strlcpy(msg,
_(
"Sorry, one can't observe in this game."), msg_len);
3273 if (!will_obs && *allow ==
'4') {
3274 fc_strlcpy(msg,
_(
"Sorry, one can't take players in this game."),
3280 && (*allow ==
'1' || *allow ==
'3')) {
3281 fc_strlcpy(msg,
_(
"Sorry, one can't take players already "
3282 "connected in this game."), msg_len);
3296 int i = 0, ntokens = 0;
3301 struct player *pplayer = NULL;
3310 if (!caller && ntokens < 1) {
3316 if (ntokens == 2 && (caller && caller->
access_level != ALLOW_HACK)) {
3318 _(
"Only the player name form is allowed."));
3368 _(
"%s already controls %s. Using 'observe' would remove %s"),
3379 _(
"%s is already observing %s."),
3384 _(
"%s is already observing."),
3427 for (i = 0; i < ntokens; i++) {
3444 int i = 0, ntokens = 0;
3449 struct player *pplayer = NULL;
3458 if (!caller && ntokens != 2) {
3464 if (caller && caller->
access_level != ALLOW_HACK && ntokens != 1) {
3466 _(
"Only the player name form is allowed."));
3484 if (strcmp(arg[i],
"-") == 0) {
3487 _(
"You cannot issue \"/take -\" when "
3488 "the game has already started."));
3512 "'%s'. /take not possible."),
3524 if ((NULL != pplayer && !pconn->
observer && pplayer == pconn->
playing)
3536 if (!pplayer && !pconn->
playing
3540 _(
"There is no free player slot for %s."),
3554 if (NULL == caller) {
3556 _(
"Reassigned nation to %s by server console."),
3560 _(
"Reassigned nation to %s by %s."),
3568 if (!aconn->observer) {
3612 _(
"%s failed to attach to any player."),
3618 for (i = 0; i < ntokens; i++) {
3633 int i = 0, ntokens = 0;
3637 struct player *pplayer = NULL;
3643 if (!caller && ntokens == 0) {
3663 if (pconn != caller && caller && caller->
access_level != ALLOW_HACK) {
3665 _(
"You can not detach other users."));
3672 if (!pplayer && !pconn->
observer) {
3674 _(
"%s is not attached to any player."), pconn->
username);
3699 aplayer->unassigned_user =
TRUE;
3710 for (i = 0; i < ntokens; i++) {
3740 struct timer *loadtimer, *uloadtimer;
3743 struct conn_list *global_observers;
3745 if (!filename || filename[0] ==
'\0') {
3752 _(
"Cannot load a game while another is running."));
3757 _(
"Name \"%s\" disallowed for security reasons."),
3765 const struct strvec *paths[] = {
3768 const char *exts[] = {
3769 "sav",
"gz",
"bz2",
"xz",
"sav.gz",
"sav.bz2",
"sav.xz",
"sav.zst", NULL
3771 const char **ext, *found = NULL;
3772 const struct strvec **path;
3781 for (path = paths; !found && *path; path++) {
3783 if (found != NULL) {
3789 for (path = paths; !found && *path; path++) {
3790 for (ext = exts; !found && *ext; ext++) {
3791 fc_snprintf(testfile,
sizeof(testfile),
"%s.%s", filename, *ext);
3793 if (found != NULL) {
3801 "scenario with the name \"%s\"."), filename);
3825 global_observers = conn_list_new();
3827 if (pconn->playing != NULL) {
3829 }
else if (pconn->observer) {
3830 conn_list_append(global_observers, pconn);
3855 log_verbose(
"Load time: %g seconds (%g apparent)",
3862 log_verbose(
"load_command() does send_rulesets()");
3882 if (strcmp(pconn->username, pplayer->username) == 0) {
3891 if (NULL == pconn->playing) {
3896 conn_list_destroy(global_observers);
3906 pack.
first = (pach->first == pplayer);
3928 const char *pfilename;
3930 if (NULL ==
str ||
'\0' ==
str[0]) {
3932 _(
"You must provide a ruleset name. Use \"/show ruleset\" to "
3933 "see what is the current ruleset."));
3938 _(
"This setting can't be modified after the game has started."));
3943 _(
"The ruleset of \"%s\" can be changed by switching to a"
3944 " compatible ruleset before loading it."),
3952 _(
"Ruleset directory is already \"%s\""),
str);
3959 _(
"Name \"%s\" disallowed for security reasons."),
3968 _(
"Ruleset directory \"%s\" not found"),
str);
3973 bool success =
TRUE;
3977 log_verbose(
"set_rulesetdir() does load_rulesets() with \"%s\"",
str);
4001 _(
"Ruleset directory set to \"%s\""),
str);
4004 _(
"Failed loading rulesets from directory \"%s\", using \"%s\""),
4022 if (NULL == caller) {
4024 _(
"That would be rather silly, since you are not a player."));
4029 if (NULL == ppattern) {
4031 _(
"%s. Try /help ignore"), buf);
4043 _(
"Added pattern %s as entry %d to your ignore list."),
4053 char *
str,
bool check)
4060 _(
"That would be rather silly, since you are not a player."));
4074 if (
'\0' == buf[0]) {
4076 _(
"Missing range. Try /help unignore."));
4078 }
else if ((c = strchr(buf,
'-'))) {
4080 if (
'\0' == buf[0]) {
4085 _(
"\"%s\" is not a valid range. Try /help unignore."), buf);
4093 _(
"\"%s\" is not a valid range. Try /help unignore."), buf);
4099 _(
"\"%s\" is not a valid range. Try /help unignore."), buf);
4105 if (!(1 <= first && first <= last && last <=
n)) {
4106 if (first == last) {
4108 _(
"Invalid entry number: %d."), first);
4111 _(
"Invalid range: %d to %d."), first, last);
4125 _(
"Removed pattern %s (entry %d) from your ignore list."),
4142 char *
str,
bool check)
4155 _(
"Two arguments needed. See '/help playercolor'."));
4182 _(
"Can only unset player color before game starts."));
4188 _(
"Invalid player color definition. See '/help playercolor'."));
4193 if (prgbcolor != NULL) {
4195 if (pother != pplayer && pother->
rgb != NULL
4199 _(
"Warning: new color [%s] for %s is identical to %s."),
4212 _(
"Color of player %s set to [%s]."),
player_name(pplayer),
4227 char *
str,
bool check)
4233 bool is_male =
FALSE;
4241 _(
"At least one argument needed. See '/help playernation'."));
4248 _(
"Can only set player nation before game starts."));
4265 _(
"Nation of player %s reset."),
player_name(pplayer));
4272 _(
"Unrecognized nation: %s."), token[1]);
4279 _(
"%s nation is not available for user selection."),
4287 _(
"%s nation is already in use."), token[1]);
4295 _(
"Leader sex must be given when setting nation."));
4300 if (!strcmp(token[2],
"0")) {
4302 }
else if (!strcmp(token[2],
"1")) {
4306 _(
"Unrecognized gender: %s, expecting 1 or 0."), token[2]);
4315 _(
"Unrecognized style: %s."), token[4]);
4324 char error_buf[256];
4327 pplayer->
style = pstyle;
4332 error_buf,
sizeof(error_buf))) {
4339 _(
"Nation of player %s set to [%s]."),
player_name(pplayer),
4394 bool check,
int read_recursion)
4398 char *cptr_s, *cptr_d;
4400 enum cmdlevel
level;
4404 if (
'\0' == *cptr_s ||
'#' == *cptr_s) {
4414 if (
'\0' == *cptr_s) {
4422 if (!check && caller) {
4429 _(
"Sorry, you are not allowed to use server commands."));
4454 _(
"Warning: '%s' interpreted as '%s', but it is ambiguous."
4460 caller ?
"/" :
"",
command, caller ?
"/" :
"");
4479 const struct player *teamplr;
4483 if (caller_had_vote) {
4486 _(
"Your new vote canceled your previous vote."));
4493 what =
_(
"New teamvote");
4498 what =
_(
"New vote");
4505 _(
"%s (number %d) by %s: %s"), what,
4515 _(
"Your new vote (\"%s\") was not "
4516 "legal or was not recognized."), full_command);
4524 &&
level == ALLOW_CTRL)
4527 _(
"You are not allowed to use this command."));
4532 struct conn_list *echo_list = NULL;
4533 bool echo_list_allocated =
FALSE;
4541 if (NULL == echo_list) {
4542 echo_list = conn_list_new();
4543 echo_list_allocated =
TRUE;
4545 conn_list_append(echo_list, pconn);
4554 if (NULL != echo_list) {
4560 "%s: '%s %s'",
_(
"(server prompt)"),
command, arg);
4562 if (echo_list_allocated) {
4563 conn_list_destroy(echo_list);
4610 case CMD_EXPERIMENTAL:
4630 return wall(arg, check);
4638 return read_command(caller, arg, check, read_recursion);
4646 return lua_command(caller, arg, check, read_recursion);
4688 log_error(
"Unknown command variant: %d.", cmd);
4702 _(
"Game is over."));
4706 _(
"Ending the game. The server will restart once all clients "
4707 "have disconnected."));
4711 _(
"Cannot end the game: no game running."));
4726 _(
"You are not allowed to use this command."));
4738 _(
"You have already conceded the game."));
4747 _(
"%s has conceded the game and can no longer win."),
4754#define SPECENUM_NAME reset_args
4755#define SPECENUM_VALUE0 RESET_GAME
4756#define SPECENUM_VALUE0NAME "game"
4757#define SPECENUM_VALUE1 RESET_RULESET
4758#define SPECENUM_VALUE1NAME "ruleset"
4759#define SPECENUM_VALUE2 RESET_SCRIPT
4760#define SPECENUM_VALUE2NAME "script"
4761#define SPECENUM_VALUE3 RESET_DEFAULT
4762#define SPECENUM_VALUE3NAME "default"
4770 i =
CLIP(0, i, reset_args_max());
4771 return reset_args_name((
enum reset_args) i);
4798 _(
"Guessing argument 'ruleset'."));
4799 ind = RESET_RULESET;
4802 _(
"Guessing argument 'game'."));
4810 _(
"The valid arguments are: 'game', 'ruleset', 'script' "
4825 _(
"Reset all settings to the values at the game start."));
4828 _(
"No saved settings from the game start available."));
4841 _(
"Reset all settings to ruleset values."));
4844 _(
"Failed to reset settings to ruleset values."));
4850 _(
"Reset all settings and rereading the server start "
4856 read_recursion + 1)) {
4857 if (NULL != caller) {
4859 _(
"Could not read script file '%s'."),
4868 _(
"Reset all settings to default values."));
4888 char reject_msg[256] =
"";
4906 _(
"Option '%s' reset to default value, and will track any "
4907 "default changes."), arg);
4914#define SPECENUM_NAME lua_args
4915#define SPECENUM_VALUE0 LUA_CMD
4916#define SPECENUM_VALUE0NAME "cmd"
4917#define SPECENUM_VALUE1 LUA_FILE
4918#define SPECENUM_VALUE1NAME "file"
4919#define SPECENUM_VALUE2 LUA_UNSAFE_CMD
4920#define SPECENUM_VALUE2NAME "unsafe-cmd"
4921#define SPECENUM_VALUE3 LUA_UNSAFE_FILE
4922#define SPECENUM_VALUE3NAME "unsafe-file"
4930 i =
CLIP(0, i, lua_args_max());
4931 return lua_args_name((
enum lua_args) i);
4940 struct stat statbuf;
4941 const char extension[] =
".lua", *real_filename = NULL;
4942 char luafile[4096], tilde_filename[4096];
4943 char *tokens[1], *luaarg = NULL;
4959 luaarg = arg + strlen(lua_args_name(ind));
4971 _(
"Fall back to old syntax '%slua <script command>'."),
4979 if (luaarg == NULL) {
4981 _(
"No lua command or lua script file. See '%shelp lua'."),
4991 case LUA_UNSAFE_CMD:
4992 if (read_recursion > 0) {
4994 _(
"Unsafe Lua code can only be run by explicit command."));
4999 _(
"You aren't allowed to run unsafe Lua code."));
5004 case LUA_UNSAFE_FILE:
5005 if (read_recursion > 0) {
5007 _(
"Unsafe Lua code can only be run by explicit command."));
5012 _(
"You aren't allowed to run unsafe Lua code."));
5020 real_filename = luaarg + strlen(luaarg) -
MIN(strlen(extension),
5022 if (strcmp(real_filename, extension) != 0) {
5023 fc_snprintf(luafile,
sizeof(luafile),
"%s%s", luaarg, extension);
5031 _(
"Freeciv script '%s' disallowed for security reasons."),
5042 if (!real_filename) {
5045 _(
"No Freeciv script found by the name '%s'."),
5051 real_filename = tilde_filename;
5065 case LUA_UNSAFE_CMD:
5070 _(
"Loading Freeciv script file '%s'."), real_filename);
5073 && !
fc_stat(real_filename, &statbuf)) {
5077 _(
"Cannot read Freeciv script '%s'."), real_filename);
5081 case LUA_UNSAFE_FILE:
5083 _(
"Loading Freeciv script file '%s'."), real_filename);
5086 && !
fc_stat(real_filename, &statbuf)) {
5090 _(
"Cannot read Freeciv script '%s'."), real_filename);
5102#define SPECENUM_NAME delegate_args
5103#define SPECENUM_VALUE0 DELEGATE_CANCEL
5104#define SPECENUM_VALUE0NAME "cancel"
5105#define SPECENUM_VALUE1 DELEGATE_RESTORE
5106#define SPECENUM_VALUE1NAME "restore"
5107#define SPECENUM_VALUE2 DELEGATE_SHOW
5108#define SPECENUM_VALUE2NAME "show"
5109#define SPECENUM_VALUE3 DELEGATE_TAKE
5110#define SPECENUM_VALUE3NAME "take"
5111#define SPECENUM_VALUE4 DELEGATE_TO
5112#define SPECENUM_VALUE4NAME "to"
5120 i =
CLIP(0, i, delegate_args_max());
5121 return delegate_args_name((
enum delegate_args) i);
5131 int ntokens, ind = delegate_args_invalid();
5133 bool player_specified =
FALSE;
5135 const char *username = NULL;
5136 struct player *dplayer = NULL;
5140 "cannot delegate yet."));
5159 ind = DELEGATE_SHOW;
5166 ind = delegate_args_invalid();
5172 ind = DELEGATE_SHOW;
5176 if (!delegate_args_is_valid(ind)) {
5178 enum delegate_args valid_args;
5180 for (valid_args = delegate_args_begin();
5181 valid_args != delegate_args_end();
5182 valid_args = delegate_args_next(valid_args)) {
5183 const char *
name = delegate_args_name(valid_args);
5187 if (valid_args != delegate_args_max()) {
5195 _(
"Valid arguments for 'delegate' are: %s."), buf);
5202 case DELEGATE_CANCEL:
5206 player_specified =
TRUE;
5215 _(
"Command level '%s' or greater needed to modify "
5216 "others' delegations."), cmdlevel_name(ALLOW_ADMIN));
5224 _(
"Please specify a player for whom delegation should "
5231 case DELEGATE_RESTORE:
5235 _(
"You can't switch players from the console."));
5243 player_specified =
TRUE;
5254 _(
"Please specify a player for whom the delegation should "
5265 _(
"You can't switch players from the console."));
5270 player_specified =
TRUE;
5279 _(
"Please specify a player to take control of."));
5301 _(
"Please specify a user to whom control is to be delegated."));
5306 player_specified =
TRUE;
5322 _(
"Command level '%s' or greater or special permission "
5323 "needed to modify others' delegations."),
5324 cmdlevel_name(ALLOW_ADMIN));
5332 _(
"You do not control a player."));
5357 _(
"Can't delegate control of '%s' belonging to %s while "
5358 "they are controlling another player."),
5360 }
else if (player_specified) {
5363 _(
"Can't change delegation of '%s' while controlled by "
5370 _(
"You can't delegate control while you are controlling "
5371 "a delegated player yourself."));
5380 if (player_specified) {
5384 _(
"%s already owns '%s', so cannot also be delegate. "
5385 "Use '%sdelegate cancel' to cancel an existing "
5393 _(
"You can't delegate control to yourself. "
5394 "Use '/delegate cancel' to cancel an existing "
5406 _(
"Control of player '%s' delegated to user %s."),
5418 _(
"No delegation defined for '%s'."),
5422 _(
"Control of player '%s' delegated to user %s."),
5428 case DELEGATE_CANCEL:
5432 _(
"No delegation defined for '%s'."),
5448 log_error(
"Failed to restore %s's connection as %s during "
5449 "'delegate cancel'.", pdelegate->
username,
5457 _(
"Your delegated control of player '%s' was canceled."),
5475 _(
"You are already controlling a delegated player. "
5476 "Use '/delegate restore' to relinquish control of your "
5477 "current player first."));
5489 _(
"Can't take player while you have delegated control "
5490 "yourself. Use '/delegate cancel' to cancel your own "
5491 "delegation first."));
5508 _(
"Control of player '%s' has not been delegated to you."),
5517 _(
"Another user already controls player '%s'."),
5525 log_error(
"%s failed to take control of '%s' during 'delegate take'.",
5533 _(
"%s is now controlling player '%s'."), caller->
username,
5538 case DELEGATE_RESTORE:
5545 _(
"You are not currently controlling a delegated player."));
5552 log_error(
"Failed to restore %s's connection as %s during "
5553 "'delegate restore'.", caller->
username,
5564 _(
"%s is now connected as %s."), caller->
username,
5588 }
else if (observer) {
5589 astr_set(&buf,
"%s",
_(
"global observer"));
5600#define SPECENUM_NAME mapimg_args
5601#define SPECENUM_VALUE0 MAPIMG_COLORTEST
5602#define SPECENUM_VALUE0NAME "colortest"
5603#define SPECENUM_VALUE1 MAPIMG_CREATE
5604#define SPECENUM_VALUE1NAME "create"
5605#define SPECENUM_VALUE2 MAPIMG_DEFINE
5606#define SPECENUM_VALUE2NAME "define"
5607#define SPECENUM_VALUE3 MAPIMG_DELETE
5608#define SPECENUM_VALUE3NAME "delete"
5609#define SPECENUM_VALUE4 MAPIMG_SHOW
5610#define SPECENUM_VALUE4NAME "show"
5611#define SPECENUM_COUNT MAPIMG_COUNT
5619 i =
CLIP(0, i, mapimg_args_max());
5620 return mapimg_args_name((
enum mapimg_args) i);
5629 int ind, ntokens,
id;
5647 _(
"Ambiguous 'mapimg' command."));
5660 enum mapimg_args valid_args;
5662 for (valid_args = mapimg_args_begin();
5663 valid_args != mapimg_args_end();
5664 valid_args = mapimg_args_next(valid_args)) {
5666 mapimg_args_name(valid_args));
5667 if (valid_args != mapimg_args_max()) {
5673 _(
"The valid arguments are: %s."), buf);
5688 _(
"Missing argument for 'mapimg define'."));
5712 "definition %d: '%s'."),
5721 _(
"Missing argument for 'mapimg delete'."));
5723 }
else if (ntokens == 2 && strcmp(token[1],
"all") == 0) {
5734 }
else if (ntokens == 2 && sscanf(token[1],
"%d", &
id) != 0) {
5750 _(
"Bad argument for 'mapimg delete': '%s'."), token[1]);
5756 if (ntokens < 2 || (ntokens == 2 && strcmp(token[1],
"all") == 0)) {
5762 }
else if (ntokens == 2 && sscanf(token[1],
"%d", &
id) != 0) {
5778 _(
"Bad argument for 'mapimg show': '%s'."), token[1]);
5783 case MAPIMG_COLORTEST:
5795 _(
"Missing argument for 'mapimg create'."));
5800 if (strcmp(token[1],
"all") == 0) {
5817 }
else if (sscanf(token[1],
"%d", &
id) != 0) {
5835 _(
"Bad argument for 'mapimg create': '%s'."), token[1]);
5855 char *tokens[1], *cmd = NULL;
5863 _(
"No player given for aicmd."));
5869 if (NULL == pplayer) {
5875 cmd = arg + strlen(tokens[0]);
5878 if (strlen(cmd) == 0) {
5880 _(
"No command for the AI console defined."));
5891 if (pplayer && pplayer->
ai) {
5894 _(
"AI console for player %s. Command: '%s'."),
5900 _(
"No AI console defined for the AI '%s' of player %s."),
5914#define SPECENUM_NAME fcdb_args
5915#define SPECENUM_VALUE0 FCDB_RELOAD
5916#define SPECENUM_VALUE0NAME "reload"
5917#define SPECENUM_VALUE1 FCDB_LUA
5918#define SPECENUM_VALUE1NAME "lua"
5919#define SPECENUM_COUNT FCDB_COUNT
5927 i =
CLIP(0, i, fcdb_args_max());
5928 return fcdb_args_name((
enum fcdb_args) i);
5944 _(
"Freeciv database script deactivated at compile time."));
5951 _(
"Freeciv database script not activated at server start. "
5952 "See the Freeciv server's --auth command line option."));
5970 _(
"Ambiguous fcdb command."));
5987 enum fcdb_args valid_args;
5989 for (valid_args = fcdb_args_begin();
5990 valid_args != fcdb_args_end();
5991 valid_args = fcdb_args_next(valid_args)) {
5993 fcdb_args_name(valid_args));
5994 if (valid_args != fcdb_args_max()) {
6000 _(
"The valid arguments are: %s."), buf);
6062 log_verbose(
"Reduced maxplayers from %d to %d to fit "
6063 "to the number of start positions.",
6082 log_verbose(
"Had to cut down the number of players to the "
6083 "number of map start positions, there must be "
6084 "something wrong with the savegame or you "
6085 "adjusted the maxplayers value.");
6104 _(
"Not enough human players ('minplayers' server setting has value %d); game will not start."),
6111 _(
"No players; game will not start."));
6116 _(
"Not enough nations in the current nation set "
6117 "for all players; game will not start. "
6118 "(See 'nationset' setting.)"));
6121 _(
"Not enough nations for all players; game will "
6127 _(
"Neither 'startcity' nor 'startunits' setting gives "
6128 "players anything to start game with; game will "
6133 }
else if (!caller) {
6138 _(
"All players are ready; starting game."));
6154 _(
"Cannot start the game: the game is waiting for all clients "
6161 _(
"Cannot start the game: it is already running."));
6193 _(
"Cutting connection %s."), ptarget->
username);
6216 time_t time_of_addr_kick, time_of_user_kick;
6217 time_t now, time_of_kick = 0;
6219 if (NULL != time_remaining) {
6220 *time_remaining = 0;
6228 &time_of_addr_kick)) {
6229 time_of_kick = time_of_addr_kick;
6233 && time_of_user_kick > time_of_kick) {
6234 time_of_kick = time_of_user_kick;
6237 if (0 == time_of_kick) {
6244 if (0 != time_of_addr_kick) {
6247 if (0 != time_of_user_kick) {
6253 if (NULL != time_remaining) {
6271 if (NULL == pconn) {
6277 const int MIN_UNIQUE_CONNS = 3;
6278 const char *unique_ipaddr[MIN_UNIQUE_CONNS];
6279 int i, num_unique_connections = 0;
6281 if (pconn == caller) {
6287 for (i = 0; i < num_unique_connections; i++) {
6288 if (0 == strcmp(unique_ipaddr[i], aconn->server.ipaddr)) {
6293 if (i >= num_unique_connections) {
6294 num_unique_connections++;
6295 if (MIN_UNIQUE_CONNS <= num_unique_connections) {
6299 unique_ipaddr[num_unique_connections - 1] = aconn->server.ipaddr;
6303 if (MIN_UNIQUE_CONNS > num_unique_connections) {
6305 _(
"There must be at least %d unique connections to the "
6306 "server for this command to be valid."), MIN_UNIQUE_CONNS);
6320 if (0 != strcmp(
ipaddr, aconn->server.ipaddr)) {
6327 aconn->playing->unassigned_user =
TRUE;
6348 _(
"Welcome - this is the introductory help text for the Freeciv "
6351 "Two important server concepts are Commands and Options. Commands, "
6352 "such as 'help', are used to interact with the server. Some commands "
6353 "take one or more arguments, separated by spaces. In many cases "
6354 "commands and command arguments may be abbreviated. Options are "
6355 "settings which control the server as it is running.\n"
6357 "To find out how to get more information about commands and options, "
6358 "use 'help help'.\n"
6360 "For the impatient, the main commands to get going are:\n"
6361 " show - to see current options\n"
6362 " set - to set options\n"
6363 " start - to start the game once players have connected\n"
6364 " save - to save the current game\n"
6365 " quit - to exit"));
6385 _(
"Command: %s - %s"),
6396 const char *syn =
_(
"Synopsis: ");
6397 size_t synlen = strlen(syn);
6400 fc_snprintf(prefix,
sizeof(prefix),
"%*s", (
int) synlen,
" ");
6429 _(
"The following server commands are available:"));
6432 for (i = 0; i <
CMD_NUM; i++) {
6440 for (i=0, j=0; i<
CMD_NUM; i++) {
6443 if ((++j % 4) == 0) {
6449 if (buf[0] !=
'\0') {
6463 int *matches,
int num_matches)
6466 const char *src, *end;
6470 if (accessor_fn == NULL || matches == NULL || num_matches < 1) {
6475 end = buf +
sizeof(buf) - 1;
6477 for (i = 0; i < num_matches && dest < end; i++) {
6478 src = accessor_fn(matches[i]);
6485 while (*src !=
'\0' && dest < end) {
6497#define SPECENUM_NAME help_general_args
6498#define SPECENUM_VALUE0 HELP_GENERAL_COMMANDS
6499#define SPECENUM_VALUE0NAME "commands"
6500#define SPECENUM_VALUE1 HELP_GENERAL_OPTIONS
6501#define SPECENUM_VALUE1NAME "options"
6502#define SPECENUM_COUNT HELP_GENERAL_COUNT
6511#define HELP_ARG_NUM (CMD_NUM + HELP_GENERAL_COUNT + settings_number())
6523 if (i < HELP_GENERAL_COUNT) {
6524 return help_general_args_name((
enum help_general_args) i);
6527 i -= HELP_GENERAL_COUNT;
6536 int matches[64], num_matches = 0;
6553 _(
"Help argument '%s' is ambiguous."), arg);
6555 matches, num_matches);
6560 _(
"No match for help argument '%s'."), arg);
6573 if (ind == HELP_GENERAL_OPTIONS) {
6577 if (ind == HELP_GENERAL_COMMANDS) {
6581 ind -= HELP_GENERAL_COUNT;
6601 _(
"List of connections to server:"));
6609 if (pconn->established) {
6610 cat_snprintf(buf,
sizeof(buf),
" command access level %s",
6611 cmdlevel_name(pconn->access_level));
6631 if (delegate_to != NULL) {
6634 : pplayer->username;
6638 _(
"%s delegates control over player '%s' to user %s%s."),
6661 if (NULL == caller) {
6663 _(
"That would be rather silly, since you are not a player."));
6720 if (strlen(pplayer->username) > 0
6721 && strcmp(pplayer->username,
"nouser") != 0) {
6722 cat_snprintf(buf,
sizeof(buf),
_(
", user %s"), pplayer->username);
6724 if (S_S_INITIAL ==
server_state() && pplayer->is_connected) {
6725 if (pplayer->is_ready) {
6731 buf +
n,
sizeof(buf) -
n,
6735 }
else if (!pplayer->is_alive) {
6744 }
else if (
is_ai(pplayer)) {
6749 if (
is_ai(pplayer)) {
6752 ai_level_translated_name(pplayer->ai_common.skill_level));
6754 n = conn_list_size(pplayer->connections);
6757 PL_(
", %d connection:",
", %d connections:",
n),
n);
6764 _(
"%s from %s (command access level %s), "
6765 "bufsize=%dkb"), pconn->username, pconn->addr,
6766 cmdlevel_name(pconn->access_level),
6767 (pconn->send_buffer->nsize >> 10));
6768 if (pconn->observer) {
6785 struct strvec *serv_list;
6789 _(
"List of rulesets available with '%sread' command:"),
6790 (caller ?
"/" :
""));
6808 struct fileinfo_list *files;
6823 fileinfo_list_destroy(files);
6835 _(
"List of nation sets available for 'nationset' option:"));
6840 int num_nations = 0;
6849 PL_(
" %-10s %s (%d playable)",
6850 " %-10s %s (%d playable)", num_nations),
6853 if (strlen(description) > 0) {
6854 static const char prefix[] =
" ";
6876 const struct player_list *members =
team_members(pteam);
6882 PL_(
"%2d : '%s' : %d player :",
6883 "%2d : '%s' : %d players :",
6884 player_list_size(members)),
6886 player_list_size(members));
6938#define SPECENUM_NAME list_args
6939#define SPECENUM_VALUE0 LIST_COLORS
6940#define SPECENUM_VALUE0NAME "colors"
6941#define SPECENUM_VALUE1 LIST_CONNECTIONS
6942#define SPECENUM_VALUE1NAME "connections"
6943#define SPECENUM_VALUE2 LIST_DELEGATIONS
6944#define SPECENUM_VALUE2NAME "delegations"
6945#define SPECENUM_VALUE3 LIST_IGNORE
6946#define SPECENUM_VALUE3NAME "ignored users"
6947#define SPECENUM_VALUE4 LIST_MAPIMG
6948#define SPECENUM_VALUE4NAME "map image definitions"
6949#define SPECENUM_VALUE5 LIST_PLAYERS
6950#define SPECENUM_VALUE5NAME "players"
6951#define SPECENUM_VALUE6 LIST_RULESETS
6952#define SPECENUM_VALUE6NAME "rulesets"
6953#define SPECENUM_VALUE7 LIST_SCENARIOS
6954#define SPECENUM_VALUE7NAME "scenarios"
6955#define SPECENUM_VALUE8 LIST_NATIONSETS
6956#define SPECENUM_VALUE8NAME "nationsets"
6957#define SPECENUM_VALUE9 LIST_TEAMS
6958#define SPECENUM_VALUE9NAME "teams"
6959#define SPECENUM_VALUE10 LIST_VOTES
6960#define SPECENUM_VALUE10NAME "votes"
6968 i =
CLIP(0, i, list_args_max());
6969 return list_args_name((
enum list_args) i);
6988 _(
"Bad list argument: '%s'. Try '%shelp list'."),
6989 arg, (caller ?
"/" :
""));
7001 case LIST_CONNECTIONS:
7004 case LIST_DELEGATIONS:
7018 case LIST_SCENARIOS:
7021 case LIST_NATIONSETS:
7033 "Internal error: ind %d in show_list", ind);
7034 log_error(
"Internal error: ind %d in show_list", ind);
7038#ifdef FREECIV_HAVE_LIBREADLINE
7053static char *generic_generator(
const char *text,
int state,
int num,
7054 const char*(*index2str)(
int))
7056 static int list_index,
len;
7057 const char *
name =
"";
7072 len = strlen(mytext);
7076 while ((num < 0 &&
name) || (list_index < num)) {
7077 name = index2str(list_index);
7088 return ((
char *)NULL);
7094static char *command_generator(
const char *text,
int state)
7102static char *option_generator(
const char *text,
int state)
7110static char *olevel_generator(
const char *text,
int state)
7112 return generic_generator(text, state,
settings_number() + OLEVELS_NUM + 1,
7120static int completion_option;
7121static const char *option_value_accessor(
int idx) {
7140static char *option_value_generator(
const char *text,
int state)
7142 return generic_generator(text, state, -1, option_value_accessor);
7148static const char *playername_accessor(
int idx)
7162static char *player_generator(
const char *text,
int state)
7165 playername_accessor);
7171static const char *connection_name_accessor(
int idx)
7179static char *connection_generator(
const char *text,
int state)
7182 connection_name_accessor);
7188static const char *cmdlevel_arg1_accessor(
int idx)
7190 return cmdlevel_name(idx);
7196static char *cmdlevel_arg1_generator(
const char *text,
int state)
7198 return generic_generator(text, state, cmdlevel_max()+1,
7199 cmdlevel_arg1_accessor);
7206static const char *cmdlevel_arg2_accessor(
int idx)
7208 return ((idx == 0) ?
"first" :
7209 (idx == 1) ?
"new" :
7210 connection_name_accessor(idx - 2));
7216static char *cmdlevel_arg2_generator(
const char *text,
int state)
7218 return generic_generator(text, state,
7221 cmdlevel_arg2_accessor);
7227static const char *aitype_accessor(
int idx)
7235static char *aitype_generator(
const char *text,
int state)
7244static char *reset_generator(
const char *text,
int state)
7246 return generic_generator(text, state, reset_args_max() + 1,
reset_accessor);
7252static char *vote_generator(
const char *text,
int state)
7260static char *delegate_generator(
const char *text,
int state)
7262 return generic_generator(text, state, delegate_args_max() + 1,
7269static char *mapimg_generator(
const char *text,
int state)
7271 return generic_generator(text, state, mapimg_args_max() + 1,
7278static char *fcdb_generator(
const char *text,
int state)
7280 return generic_generator(text, state, FCDB_COUNT,
fcdb_accessor);
7286static char *lua_generator(
const char *text,
int state)
7288 return generic_generator(text, state, lua_args_max() + 1,
lua_accessor);
7294static char *help_generator(
const char *text,
int state)
7302static char *list_generator(
const char *text,
int state)
7304 return generic_generator(text, state, list_args_max() + 1,
list_accessor);
7311static bool contains_token_before_start(
int start,
int token,
const char *arg,
7314 char *str_itr = rl_line_buffer;
7315 int arg_len = strlen(arg);
7319 while (str_itr < rl_line_buffer + start && !
fc_isalnum(*str_itr)) {
7322 while (str_itr < rl_line_buffer + start &&
fc_isalnum(*str_itr)) {
7328 while (str_itr < rl_line_buffer + start && !
fc_isalnum(*str_itr)) {
7343 for (; str_itr < rl_line_buffer + start; str_itr++) {
7358static bool contains_str_before_start(
int start,
const char *cmd,
7361 return contains_token_before_start(start, 0, cmd, allow_fluff);
7368static bool is_command(
int start)
7376 str_itr = rl_line_buffer;
7377 while (str_itr - rl_line_buffer < start) {
7389static int num_tokens(
int start)
7393 char *chptr = rl_line_buffer;
7395 while (chptr - rl_line_buffer < start) {
7413static const int player_cmd[] = {
7433static bool is_player(
int start)
7437 while (player_cmd[i] != -1) {
7450static const int connection_cmd[] = {
7459static bool is_connection(
int start)
7463 while (connection_cmd[i] != -1) {
7464 if (contains_str_before_start(start,
7478static bool is_cmdlevel_arg2(
int start)
7481 && num_tokens(start) == 2);
7487static bool is_cmdlevel_arg1(
int start)
7498static const int server_option_cmd[] = {
7509static bool is_server_option(
int start)
7513 while (server_option_cmd[i] != -1) {
7527static const int option_level_cmd[] = {
7536static bool is_option_level(
int start)
7540 while (option_level_cmd[i] != -1) {
7556static bool is_enum_option_value(
int start,
int *opt_p)
7567 if (contains_token_before_start(start, 1,
setting_name(pset),
7571 rl_completion_suppress_append = (
setting_type(pset) == SST_BITWISE);
7582static const int filename_cmd[] = {
7593static bool is_filename(
int start)
7597 while (filename_cmd[i] != -1) {
7610static bool is_create_arg2(
int start)
7613 && num_tokens(start) == 2);
7619static bool is_reset(
int start)
7621 return contains_str_before_start(start,
7629static bool is_vote(
int start)
7631 return contains_str_before_start(start,
7639static bool is_delegate_arg1(
int start)
7641 return contains_str_before_start(start,
7649static bool is_mapimg(
int start)
7651 return contains_str_before_start(start,
7659static bool is_fcdb(
int start)
7661 return contains_str_before_start(start,
7669static bool is_lua(
int start)
7671 return contains_str_before_start(start,
7679static bool is_help(
int start)
7687static bool is_list(
int start)
7699char **freeciv_completion(
const char *text,
int start,
int end)
7701 char **matches = (
char **)NULL;
7703 if (is_help(start)) {
7704 matches = rl_completion_matches(text, help_generator);
7705 }
else if (is_command(start)) {
7706 matches = rl_completion_matches(text, command_generator);
7707 }
else if (is_list(start)) {
7708 matches = rl_completion_matches(text, list_generator);
7709 }
else if (is_cmdlevel_arg2(start)) {
7710 matches = rl_completion_matches(text, cmdlevel_arg2_generator);
7711 }
else if (is_cmdlevel_arg1(start)) {
7712 matches = rl_completion_matches(text, cmdlevel_arg1_generator);
7713 }
else if (is_connection(start)) {
7714 matches = rl_completion_matches(text, connection_generator);
7715 }
else if (is_player(start)) {
7716 matches = rl_completion_matches(text, player_generator);
7717 }
else if (is_server_option(start)) {
7718 matches = rl_completion_matches(text, option_generator);
7719 }
else if (is_option_level(start)) {
7720 matches = rl_completion_matches(text, olevel_generator);
7721 }
else if (is_enum_option_value(start, &completion_option)) {
7722 matches = rl_completion_matches(text, option_value_generator);
7723 }
else if (is_filename(start)) {
7725 matches = rl_completion_matches(text, rl_filename_completion_function);
7726 }
else if (is_create_arg2(start)) {
7727 matches = rl_completion_matches(text, aitype_generator);
7728 }
else if (is_reset(start)) {
7729 matches = rl_completion_matches(text, reset_generator);
7730 }
else if (is_vote(start)) {
7731 matches = rl_completion_matches(text, vote_generator);
7732 }
else if (is_delegate_arg1(start)) {
7733 matches = rl_completion_matches(text, delegate_generator);
7734 }
else if (is_mapimg(start)) {
7735 matches = rl_completion_matches(text, mapimg_generator);
7736 }
else if (is_fcdb(start)) {
7737 matches = rl_completion_matches(text, fcdb_generator);
7738 }
else if (is_lua(start)) {
7739 matches = rl_completion_matches(text, lua_generator);
7746 rl_attempted_completion_over = 1;
bool achievement_player_has(const struct achievement *pach, const struct player *pplayer)
int achievement_index(const struct achievement *pach)
#define achievements_iterate_end
#define achievements_iterate(_ach_)
bool adv_data_phase_init(struct player *pplayer, bool is_new_phase)
const char * ai_name(const struct ai_type *ai)
struct ai_type * ai_type_by_name(const char *search)
int ai_type_get_count(void)
struct ai_type * get_ai_type(int id)
#define CALL_PLR_AI_FUNC(_func, _player,...)
const char * default_ai_type_name(void)
void astr_free(struct astring *astr)
const char * astr_build_or_list(struct astring *astr, const char *const *items, size_t number)
void astr_set(struct astring *astr, const char *format,...)
static const char * astr_str(const struct astring *astr) fc__attribute((nonnull(1)))
#define BV_ISSET(bv, bit)
#define SERVER_COMMAND_PREFIX
const char * city_name_get(const struct city *pcity)
#define city_list_iterate(citylist, pcity)
static citizens city_size_get(const struct city *pcity)
#define city_list_iterate_end
enum cmd_echo command_echo(const struct command *pcommand)
const char * command_name_by_number(int i)
const char * command_name(const struct command *pcommand)
const struct command * command_by_number(int i)
const char * command_short_help(const struct command *pcommand)
char * command_extra_help(const struct command *pcommand)
enum cmdlevel command_level(const struct command *pcommand)
const char * command_synopsis(const struct command *pcommand)
bool connection_attach(struct connection *pconn, struct player *pplayer, bool observing)
bool connection_delegate_take(struct connection *pconn, struct player *dplayer)
struct player * find_uncontrolled_player(void)
void connection_close_server(struct connection *pconn, const char *reason)
void connection_detach(struct connection *pconn, bool remove_unused_player)
void conn_set_access(struct connection *pconn, enum cmdlevel new_level, bool granted)
bool connection_delegate_restore(struct connection *pconn)
size_t conn_pattern_to_string(const struct conn_pattern *ppattern, char *buf, size_t buf_len)
struct player * conn_get_player(const struct connection *pconn)
struct connection * conn_by_user_prefix(const char *user_name, enum m_pre_result *result)
struct connection * conn_by_user(const char *user_name)
void conn_list_compression_thaw(const struct conn_list *pconn_list)
void conn_pattern_destroy(struct conn_pattern *ppattern)
void conn_list_compression_freeze(const struct conn_list *pconn_list)
bool conn_controls_player(const struct connection *pconn)
const char * conn_description(const struct connection *pconn)
struct conn_pattern * conn_pattern_from_string(const char *pattern, enum conn_pattern_type prefer, char *error_buf, size_t error_buf_len)
enum cmdlevel conn_get_access(const struct connection *pconn)
#define conn_pattern_list_iterate_end
#define conn_list_iterate(connlist, pconn)
#define conn_pattern_list_iterate(plist, ppatern)
#define conn_list_iterate_end
void con_set_style(bool i)
void con_write(enum rfc_status rfc_status, const char *message,...)
#define MAX_LEN_CONSOLE_LINE
#define log_deprecation(message,...)
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
void set_ai_level_directer(struct player *pplayer, enum ai_level level)
void free_tokens(char **tokens, size_t ntokens)
int get_tokens(const char *str, char **tokens, size_t num_tokens, const char *delimiterset)
char * internal_to_local_string_malloc(const char *text)
char * local_to_internal_string_malloc(const char *text)
#define PL_(String1, String2, n)
size_t featured_text_apply_tag(const char *text_source, char *featured_text, size_t featured_text_len, enum text_tag_type tag_type, ft_offset_t start_offset, ft_offset_t stop_offset,...)
const struct ft_color ftc_log
const struct ft_color ftc_command
const struct ft_color ftc_server
const struct ft_color ftc_any
VAR_ARG_CONST struct ft_color ftc_changed
const struct ft_color ftc_vote_team
const struct ft_color ftc_game_start
const struct ft_color ftc_server_prompt
const struct ft_color ftc_vote_public
struct unit * game_unit_by_number(int id)
#define GAME_MAX_READ_RECURSION
void send_scenario_description(struct conn_list *dest)
void send_scenario_info(struct conn_list *dest)
void send_game_info(struct conn_list *dest)
static GtkWidget * persistent
static char * leader_name
void handle_player_ready(struct player *pplayer, int player_no, bool is_ready)
#define fc_assert_ret(condition)
#define log_verbose(message,...)
#define fc_assert(condition)
#define log_testmatic_alt(altlvl, message,...)
#define fc_assert_ret_val(condition, val)
#define fc_assert_action(condition, action)
#define log_normal(message,...)
#define log_error(message,...)
struct tile * map_pos_to_tile(const struct civ_map *nmap, int map_x, int map_y)
int map_startpos_count(void)
bool mapimg_id2str(int id, char *str, size_t str_len)
bool mapimg_colortest(const char *savename, const char *path)
struct mapdef * mapimg_isvalid(int id)
bool mapimg_define(const char *maparg, bool check)
bool mapimg_delete(int id)
bool mapimg_create(struct mapdef *pmapdef, bool force, const char *savename, const char *path)
const char * mapimg_error(void)
bool mapimg_show(int id, char *str, size_t str_len, bool detail)
const char * nation_rule_name(const struct nation_type *pnation)
int nations_match(const struct nation_type *pnation1, const struct nation_type *pnation2, bool ignore_conflicts)
struct nation_type * nation_of_unit(const struct unit *punit)
const char * nation_adjective_for_player(const struct player *pplayer)
const char * nation_set_name_translation(const struct nation_set *pset)
struct nation_type * nation_of_player(const struct player *pplayer)
bool is_nation_playable(const struct nation_type *nation)
bool nation_is_in_set(const struct nation_type *pnation, const struct nation_set *pset)
const char * nation_set_description(const struct nation_set *pset)
int nation_set_count(void)
struct nation_type * nation_by_rule_name(const char *name)
const char * nation_plural_translation(const struct nation_type *pnation)
const char * nation_set_rule_name(const struct nation_set *pset)
const char * nation_plural_for_player(const struct player *pplayer)
struct government * init_government_of_nation(const struct nation_type *pnation)
struct nation_style * style_of_nation(const struct nation_type *pnation)
#define nation_sets_iterate_end
#define nation_sets_iterate(NAME_pset)
#define nations_iterate_end
#define nations_iterate(NAME_pnation)
#define NO_NATION_SELECTED
void notify_conn(struct conn_list *dest, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
void notify_team(const struct player *pplayer, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
void package_event(struct packet_chat_msg *packet, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
void event_cache_add_for_all(const struct packet_chat_msg *packet)
int send_packet_chat_msg(struct connection *pc, const struct packet_chat_msg *packet)
void dlsend_packet_game_load(struct conn_list *dest, bool load_successful, const char *load_filename)
void lsend_packet_achievement_info(struct conn_list *dest, const struct packet_achievement_info *packet)
struct city_list * cities
bool player_slot_is_used(const struct player_slot *pslot)
struct player * player_by_name_prefix(const char *name, enum m_pre_result *result)
struct player * player_by_number(const int player_id)
int player_slot_count(void)
struct player_slot * player_slot_by_number(int player_id)
int player_number(const struct player *pplayer)
const char * player_name(const struct player *pplayer)
struct player * player_by_name(const char *name)
struct player * player_by_user(const char *name)
bool player_set_nation(struct player *pplayer, struct nation_type *pnation)
struct player * player_slot_get_player(const struct player_slot *pslot)
#define ai_level_cmd(_level_)
#define players_iterate_end
#define players_iterate(_pplayer)
#define player_list_iterate(playerlist, pplayer)
static bool is_barbarian(const struct player *pplayer)
#define player_list_iterate_end
#define set_as_human(plr)
void server_player_set_name(struct player *pplayer, const char *name)
struct player * server_create_player(int player_id, const char *ai_tname, struct rgbcolor *prgbcolor, bool allow_ai_type_fallbacking)
void player_status_add(struct player *plr, enum player_status pstatus)
int normal_player_count(void)
void player_set_under_human_control(struct player *pplayer)
void server_player_set_color(struct player *pplayer, const struct rgbcolor *prgbcolor)
void player_set_to_ai_mode(struct player *pplayer, enum ai_level skill_level)
bool server_player_set_name_full(const struct connection *caller, struct player *pplayer, const struct nation_type *pnation, const char *name, char *error_buf, size_t error_buf_len)
bool player_delegation_active(const struct player *pplayer)
void player_info_thaw(void)
void player_info_freeze(void)
struct nation_type * pick_a_nation(const struct nation_list *choices, bool ignore_conflicts, bool needs_startpos, enum barbarian_type barb_type)
const char * player_color_ftstr(struct player *pplayer)
void send_player_info_c(struct player *src, struct conn_list *dest)
bool player_status_check(struct player *plr, enum player_status pstatus)
void player_delegation_set(struct player *pplayer, const char *username)
void server_remove_player(struct player *pplayer)
void server_player_init(struct player *pplayer, bool initmap, bool needs_team)
bool player_color_changeable(const struct player *pplayer, const char **reason)
void assign_player_colors(void)
bool client_can_pick_nation(const struct nation_type *pnation)
void send_player_diplstate_c(struct player *src, struct conn_list *dest)
const char * player_delegation_get(const struct player *pplayer)
bool nation_is_in_current_set(const struct nation_type *pnation)
void reset_all_start_commands(bool plrchange)
struct section_file * secfile_load(const char *filename, bool allow_duplicates)
const char * secfile_error(void)
void secfile_destroy(struct section_file *secfile)
void secfile_check_unused(const struct section_file *secfile)
struct section_file * secfile_load_section(const char *filename, const char *section, bool allow_duplicates)
bool secfile_lookup_bool_default(const struct section_file *secfile, bool def, const char *path,...)
struct research * research_get(const struct player *pplayer)
bool rgbcolor_from_hex(struct rgbcolor **prgbcolor, const char *hex)
void rgbcolor_destroy(struct rgbcolor *prgbcolor)
bool rgbcolors_are_equal(const struct rgbcolor *c1, const struct rgbcolor *c2)
bool load_rulesets(const char *restore, const char *alt, bool compat_mode, rs_conversion_logger logger, bool act, bool buffer_script, bool load_luadata)
bool reload_rulesets_settings(void)
void send_rulesets(struct conn_list *dest)
void savegame_load(struct section_file *sfile)
void save_game(const char *orig_filename, const char *save_reason, bool scenario)
void script_fcdb_free(void)
bool script_fcdb_do_string(struct connection *caller, const char *str)
bool script_fcdb_call(const char *func_name,...)
bool script_fcdb_init(const char *fcdb_luafile)
bool script_server_unsafe_do_string(struct connection *caller, const char *str)
bool script_server_do_string(struct connection *caller, const char *str)
bool script_server_unsafe_do_file(struct connection *caller, const char *filename)
bool script_server_do_file(struct connection *caller, const char *filename)
bool setting_int_validate(const struct setting *pset, int val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
void setting_action(const struct setting *pset)
const char * setting_default_name(const struct setting *pset, bool pretty, char *buf, size_t buf_len)
bool setting_enum_validate(const struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
struct setting * setting_by_name(const char *name)
void setting_set_to_default(struct setting *pset)
const char * setting_value_name(const struct setting *pset, bool pretty, char *buf, size_t buf_len)
const char * setting_extra_help(const struct setting *pset, bool constant)
int setting_number(const struct setting *pset)
struct setting * setting_by_number(int id)
bool setting_int_set(struct setting *pset, int val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
bool setting_is_visible(const struct setting *pset, struct connection *caller)
bool setting_locked(const struct setting *pset)
bool setting_non_default(const struct setting *pset)
enum sset_type setting_type(const struct setting *pset)
bool setting_str_set(struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
int setting_int_max(const struct setting *pset)
bool setting_bitwise_set(struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
int settings_number(void)
bool setting_str_validate(const struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
const char * setting_enum_val(const struct setting *pset, int val, bool pretty)
struct setting_list * level[OLEVELS_NUM]
void setting_changed(struct setting *pset)
enum setting_default_level setting_get_setdef(const struct setting *pset)
bool setting_enum_set(struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
const char * setting_short_help(const struct setting *pset)
const char * setting_bitwise_bit(const struct setting *pset, int bit, bool pretty)
int setting_int_min(const struct setting *pset)
bool setting_bitwise_validate(const struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
bool setting_bool_validate(const struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
bool setting_is_changeable(const struct setting *pset, struct connection *caller, char *reject_msg, size_t reject_msg_len)
void settings_reset(void)
const char * setting_name(const struct setting *pset)
bool settings_game_reset(void)
void settings_list_update(void)
bool setting_bool_set(struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
void send_server_setting(struct conn_list *dest, const struct setting *pset)
void send_server_settings(struct conn_list *dest)
#define settings_iterate(_level, _pset)
#define settings_iterate_end
const char * fileinfoname(const struct strvec *dirs, const char *filename)
void remove_trailing_spaces(char *s)
bool str_to_int(const char *str, int *pint)
const char * m_pre_description(enum m_pre_result result)
struct strvec * fileinfolist(const struct strvec *dirs, const char *suffix)
char * skip_leading_spaces(char *s)
enum m_pre_result match_prefix_full(m_pre_accessor_fn_t accessor_fn, size_t n_names, size_t max_len_name, m_pre_strncmp_fn_t cmp_fn, m_strlen_fn_t len_fn, const char *prefix, int *ind_result, int *matches, int max_matches, int *pnum_matches)
const struct strvec * get_scenario_dirs(void)
void interpret_tilde(char *buf, size_t buf_size, const char *filename)
const struct strvec * get_save_dirs(void)
void remove_leading_spaces(char *s)
enum m_pre_result match_prefix(m_pre_accessor_fn_t accessor_fn, size_t n_names, size_t max_len_name, m_pre_strncmp_fn_t cmp_fn, m_strlen_fn_t len_fn, const char *prefix, int *ind_result)
bool is_safe_filename(const char *name)
void remove_leading_trailing_spaces(char *s)
const struct strvec * get_data_dirs(void)
struct fileinfo_list * fileinfolist_infix(const struct strvec *dirs, const char *infix, bool nodups)
#define CLIP(lower, current, upper)
#define FC_MEMBER_SIZEOF(type, member)
#define fileinfo_list_iterate(list, pnode)
#define fileinfo_list_iterate_end
const char *(* m_pre_accessor_fn_t)(int)
#define CITY_LOG(loglevel, pcity, msg,...)
#define UNIT_LOG(loglevel, punit, msg,...)
void server_game_init(bool keep_ruleset_value)
void player_nation_defaults(struct player *pplayer, struct nation_type *pnation, bool set_name)
const char * aifill(int amount)
void set_server_state(enum server_states newstate)
bool game_was_started(void)
struct server_arguments srvarg
void check_for_full_turn_done(void)
enum server_states server_state(void)
void server_game_free(void)
static bool write_command(struct connection *caller, char *arg, bool check)
static const char * reset_accessor(int i)
static bool set_cmdlevel(struct connection *caller, struct connection *ptarget, enum cmdlevel level)
static struct setting * validate_setting_arg(enum command_id cmd, struct connection *caller, char *arg)
#define LOOKUP_OPTION_AMBIGUOUS
static const char * mapimg_accessor(int i)
void cmd_reply(enum command_id cmd, struct connection *caller, enum rfc_status rfc_status, const char *format,...)
static bool read_init_script_real(struct connection *caller, char *script_filename, bool from_cmdline, bool check, int read_recursion)
bool read_init_script(struct connection *caller, char *script_filename, bool from_cmdline, bool check)
static bool set_command(struct connection *caller, char *str, bool check)
static enum command_id cmd_of_level(enum ai_level level)
static void show_delegations(struct connection *caller)
static char setting_status(struct connection *caller, const struct setting *pset)
static void show_scenarios(struct connection *caller)
static bool delegate_command(struct connection *caller, char *arg, bool check)
static bool ignore_command(struct connection *caller, char *str, bool check)
static void show_help_command(struct connection *caller, enum command_id help_cmd, enum command_id id)
void set_running_game_access_level(void)
void notify_if_first_access_level_is_available(void)
static const char * lua_accessor(int i)
static const char * fcdb_accessor(int i)
static void show_help_command_list(struct connection *caller, enum command_id help_cmd)
void stdinhand_turn(void)
static void show_connections(struct connection *caller)
static bool explain_option(struct connection *caller, char *str, bool check)
static struct kick_hash * kick_table_by_user
bool conn_is_kicked(struct connection *pconn, int *time_remaining)
enum rfc_status create_command_newcomer(const char *name, const char *ai, bool check, struct nation_type *pnation, struct player **newplayer, char *buf, size_t buflen)
static void show_colors(struct connection *caller)
static bool set_ai_level(struct connection *caller, const char *name, enum ai_level level, bool check)
static struct kick_hash * kick_table_by_addr
static void show_help_option_list(struct connection *caller, enum command_id help_cmd)
void stdinhand_init(void)
static bool take_command(struct connection *caller, char *str, bool check)
static bool wall(char *str, bool check)
static enum cmdlevel default_access_level
static void show_ruleset_info(struct connection *caller, enum command_id cmd, bool check, int read_recursion)
void show_players(struct connection *caller)
static void cmd_reply_matches(enum command_id cmd, struct connection *caller, m_pre_accessor_fn_t accessor_fn, int *matches, int num_matches)
#define LOOKUP_OPTION_NO_RESULT
static const char * list_accessor(int i)
static int lookup_option(const char *name)
static bool reset_command(struct connection *caller, char *arg, bool check, int read_recursion)
static void show_teams(struct connection *caller)
static bool handle_stdin_input_real(struct connection *caller, char *str, bool check, int read_recursion)
enum rfc_status create_command_pregame(const char *name, const char *ai, bool check, struct player **newplayer, char *buf, size_t buflen)
static bool metaconnection_command(struct connection *caller, char *arg, bool check)
static bool show_serverid(struct connection *caller, char *arg)
static void show_nationsets(struct connection *caller)
static const char * helparg_accessor(int i)
static bool metamessage_command(struct connection *caller, char *arg, bool check)
static bool away_command(struct connection *caller, bool check)
enum cmdlevel access_level_for_next_connection(void)
static bool playercolor_command(struct connection *caller, char *str, bool check)
bool handle_stdin_input_free(struct connection *caller, char *str)
void set_ai_level_direct(struct player *pplayer, enum ai_level level)
static bool player_name_check(const char *name, char *buf, size_t buflen)
static bool default_command(struct connection *caller, char *arg, bool check)
static bool create_command(struct connection *caller, const char *str, bool check)
static void vcmd_reply_prefix(enum command_id cmd, struct connection *caller, enum rfc_status rfc_status, const char *prefix, const char *format, va_list ap)
static const char * delegate_accessor(int i)
static void show_rulesets(struct connection *caller)
static bool surrender_command(struct connection *caller, char *str, bool check)
static bool end_command(struct connection *caller, char *str, bool check)
static const char * delegate_player_str(struct player *pplayer, bool observer)
static void cmd_reply_prefix(enum command_id cmd, struct connection *caller, enum rfc_status rfc_status, const char *prefix, const char *format,...) fc__attribute((__format__(__printf__
#define LOOKUP_OPTION_RULESETDIR
static bool timeout_command(struct connection *caller, char *str, bool check)
static void cmd_reply_no_such_player(enum command_id cmd, struct connection *caller, const char *name, enum m_pre_result match_result)
static bool metaserver_command(struct connection *caller, char *arg, bool check)
bool handle_stdin_input(struct connection *caller, char *str)
static bool cut_client_connection(struct connection *caller, char *name, bool check)
static void open_metaserver_connection(struct connection *caller, bool persistent)
static time_t * time_duplicate(const time_t *t)
static void show_mapimg(struct connection *caller, enum command_id cmd)
static bool may_use_nothing(struct connection *caller)
static void show_votes(struct connection *caller)
static const char *const vote_args[]
static bool show_settings(struct connection *caller, enum command_id called_as, char *str, bool check)
static bool a_connection_exists(void)
void stdinhand_free(void)
static bool cmdlevel_command(struct connection *caller, char *str, bool check)
static bool is_first_access_level_taken(void)
#define LOOKUP_OPTION_LEVEL_NAME
static bool firstlevel_command(struct connection *caller, bool check)
static void start_cmd_reply(struct connection *caller, bool notify, char *msg)
static bool connectmsg_command(struct connection *caller, char *str, bool check)
static const char horiz_line[]
static void cmd_reply_no_such_conn(enum command_id cmd, struct connection *caller, const char *name, enum m_pre_result match_result)
static void cmd_reply_line(enum command_id cmd, struct connection *caller, enum rfc_status rfc_status, const char *prefix, const char *line)
static void show_help_intro(struct connection *caller, enum command_id help_cmd)
static bool cancelvote_command(struct connection *caller, char *arg, bool check)
bool load_command(struct connection *caller, const char *filename, bool check, bool cmdline_load)
static void show_settings_one(struct connection *caller, enum command_id cmd, struct setting *pset)
static bool toggle_ai_command(struct connection *caller, char *arg, bool check)
static bool playernation_command(struct connection *caller, char *str, bool check)
static bool team_command(struct connection *caller, char *str, bool check)
static bool quit_game(struct connection *caller, bool check)
static bool vote_command(struct connection *caller, char *str, bool check)
#define cmd_reply_show(string)
bool start_command(struct connection *caller, bool check, bool notify)
static const char * optname_accessor(int i)
static bool show_help(struct connection *caller, char *arg)
#define OPTION_NAME_SPACE
struct strvec * get_init_script_choices(void)
static bool remove_player_command(struct connection *caller, char *arg, bool check)
static bool debug_command(struct connection *caller, char *str, bool check)
static enum command_id command_named(const char *token, bool accept_ambiguity)
static bool fcdb_command(struct connection *caller, char *arg, bool check)
static bool set_rulesetdir(struct connection *caller, char *str, bool check, int read_recursion)
static bool mapimg_command(struct connection *caller, char *arg, bool check)
static bool unignore_command(struct connection *caller, char *str, bool check)
static bool observe_command(struct connection *caller, char *str, bool check)
static bool show_list(struct connection *caller, char *arg)
static bool scensave_command(struct connection *caller, char *arg, bool check)
static enum sset_level lookup_option_level(const char *name)
static bool may_use(struct connection *caller, enum command_id cmd)
static bool kick_command(struct connection *caller, char *name, bool check)
static const char * vote_arg_accessor(int i)
static bool is_restricted(struct connection *caller)
const char * script_extension
static bool show_command(struct connection *caller, char *str, bool check)
static bool lua_command(struct connection *caller, char *arg, bool check, int read_recursion)
static bool write_init_script(char *script_filename)
static enum cmdlevel first_access_level
static bool detach_command(struct connection *caller, char *str, bool check)
static bool aicmd_command(struct connection *caller, char *arg, bool check)
static void close_metaserver_connection(struct connection *caller)
static bool save_command(struct connection *caller, char *arg, bool check)
static bool set_ai_level_named(struct connection *caller, const char *name, const char *level_name, bool check)
static bool metapatches_command(struct connection *caller, char *arg, bool check)
static bool show_ignore(struct connection *caller)
static bool is_allowed_to_take(struct connection *requester, struct connection *taker, struct player *pplayer, bool will_obs, char *msg, size_t msg_len)
void toggle_ai_player_direct(struct connection *caller, struct player *pplayer)
static void show_help_option(struct connection *caller, enum command_id help_cmd, int id)
static bool read_command(struct connection *caller, char *arg, bool check, int read_recursion)
void strvec_destroy(struct strvec *psv)
#define strvec_iterate(psv, str)
#define strvec_iterate_end
struct ai_type::@14 funcs
void(* gained_control)(struct player *pplayer)
void(* player_console)(struct player *pplayer, const char *cmd)
struct city::@17::@19 server
struct civ_game::@30::@34 server
char start_units[MAX_LEN_STARTUNIT]
char connectmsg[MAX_LEN_MSG]
struct conn_list * est_connections
struct packet_game_info info
char rulesetdir[MAX_LEN_NAME]
struct packet_scenario_info scenario
struct conn_list * all_connections
char save_name[MAX_LEN_NAME]
char allow_take[MAX_LEN_ALLOW_TAKE]
struct connection::@57::@63::@64 delegation
enum cmdlevel access_level
char username[MAX_LEN_NAME]
struct connection::@57::@63 server
char ipaddr[MAX_LEN_ADDR]
struct conn_pattern_list * ignore_list
char message[MAX_LEN_MSG]
enum ai_level skill_level
enum ai_level skill_level
struct player_ai ai_common
struct government * target_government
char username[MAX_LEN_NAME]
struct government * government
const struct ai_type * ai
struct conn_list * connections
struct nation_style * style
struct player::@69::@71 server
char metaserver_addr[256]
struct unit::@80::@83 server
struct nation_style * style_by_rule_name(const char *name)
int fc_snprintf(char *str, size_t n, const char *format,...)
size_t fc_strlcpy(char *dest, const char *src, size_t n)
int fc_strcasecmp(const char *str0, const char *str1)
int cat_snprintf(char *str, size_t n, const char *format,...)
int fc_vsnprintf(char *str, size_t n, const char *format, va_list ap)
FILE * fc_fopen(const char *filename, const char *opentype)
int fc_break_lines(char *str, size_t desired_len)
int fc_stat(const char *filename, struct stat *buf)
bool is_reg_file_for_access(const char *name, bool write_access)
int fc_strncasecmp(const char *str0, const char *str1, size_t n)
#define sz_strlcpy(dest, src)
#define sz_strlcat(dest, src)
int team_index(const struct team *pteam)
const char * team_name_translation(const struct team *pteam)
struct team_slot * team_slot_by_number(int team_id)
const char * team_slot_name_translation(const struct team_slot *tslot)
bool team_add_player(struct player *pplayer, struct team *pteam)
struct team * team_new(struct team_slot *tslot)
struct team_slot * team_slot_by_rule_name(const char *team_name)
const struct player_list * team_members(const struct team *pteam)
void team_remove_player(struct player *pplayer)
#define teams_iterate_end
#define teams_iterate(_pteam)
struct city * tile_city(const struct tile *ptile)
struct timer * timer_new(enum timer_timetype type, enum timer_use use)
void timer_destroy(struct timer *t)
void timer_start(struct timer *t)
double timer_read_seconds(struct timer *t)
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_end
const char * unit_name_translation(const struct unit *punit)
int describe_vote(struct vote *pvote, char *buf, int buflen)
bool conn_can_vote(const struct connection *pconn, const struct vote *pvote)
struct vote * vote_new(struct connection *caller, const char *allargs, int command_id)
bool vote_is_team_only(const struct vote *pvote)
struct vote * get_vote_by_no(int vote_no)
bool vote_would_pass_immediately(const struct connection *caller, int command_id)
void clear_all_votes(void)
struct vote * get_vote_by_caller(const struct connection *caller)
void connection_vote(struct connection *pconn, struct vote *pvote, enum vote_type type)
struct vote_list * vote_list
const struct connection * vote_get_caller(const struct vote *pvote)
int count_voters(const struct vote *pvote)
void remove_vote(struct vote *pvote)
bool conn_can_see_vote(const struct connection *pconn, const struct vote *pvote)
#define vote_list_iterate_end
#define vote_list_iterate(alist, pvote)