(disabled_commands): New econfig key.

(disable_coms): New, implements disabled_commands.
(init_player_commands): Call it.
This commit is contained in:
Markus Armbruster 2006-06-17 20:27:36 +00:00
parent db1ac2edf4
commit b63c69ef20
3 changed files with 30 additions and 1 deletions

View file

@ -397,6 +397,8 @@ EMPCFBOTH("trade_ally_cut", trade_ally_cut, float, NSC_FLOAT, 0,
"Bonus your ally gets for you cashing in with them") "Bonus your ally gets for you cashing in with them")
EMPCF_COMMENT("\n\n### Misc.") EMPCF_COMMENT("\n\n### Misc.")
EMPCFBOTH("disabled_commands", disabled_commands, char *, NSC_STRING, KM_INTERNAL,
"Disabled commands, separated by space")
EMPCFBOTH("anno_keep_days", anno_keep_days, int, NSC_INT, KM_INTERNAL, EMPCFBOTH("anno_keep_days", anno_keep_days, int, NSC_INT, KM_INTERNAL,
"How long until announcements expire (<0 means never)") "How long until announcements expire (<0 means never)")
EMPCFBOTH("news_keep_days", news_keep_days, int, NSC_INT, KM_INTERNAL, EMPCFBOTH("news_keep_days", news_keep_days, int, NSC_INT, KM_INTERNAL,

View file

@ -43,7 +43,9 @@ char *privlog = "careless@invalid";
/* Divine hosts and networks */ /* Divine hosts and networks */
char *privip = "127.0.0.1 ::1 ::ffff:127.0.0.1"; char *privip = "127.0.0.1 ::1 ::ffff:127.0.0.1";
int keep_journal = 0; char *disabled_commands = "";
int keep_journal = 0; /* journal log file enabled */
int WORLD_X = 64; /* World size - x */ int WORLD_X = 64; /* World size - x */
int WORLD_Y = 32; /* World size - y */ int WORLD_Y = 32; /* World size - y */

View file

@ -44,6 +44,7 @@
#include "com.h" #include "com.h"
#include "file.h" #include "file.h"
#include "empio.h" #include "empio.h"
#include "match.h"
#include "subs.h" #include "subs.h"
#include "common.h" #include "common.h"
#include "optlist.h" #include "optlist.h"
@ -63,6 +64,8 @@ static char player_commands[KEEP_COMMANDS][1024 + 8];
/* the slot holding the most recent command in player_commands[] */ /* the slot holding the most recent command in player_commands[] */
static int player_commands_index = 0; static int player_commands_index = 0;
static void disable_coms(void);
/* /*
* Get a command from the current player into COMBUFP[1024], in UTF-8. * Get a command from the current player into COMBUFP[1024], in UTF-8.
* This may block for input, yielding the processor. Flush buffered * This may block for input, yielding the processor. Flush buffered
@ -105,6 +108,8 @@ init_player_commands(void)
for (i = 0; i < KEEP_COMMANDS; ++i) for (i = 0; i < KEEP_COMMANDS; ++i)
*player_commands[i] = 0; *player_commands[i] = 0;
disable_coms();
} }
void void
@ -158,6 +163,26 @@ explain(void)
return RET_OK; return RET_OK;
} }
static void
disable_coms(void)
{
char *tmp = strdup(disabled_commands);
char *name;
int cmd;
for (name = strtok(tmp, " \t"); name; name = strtok(NULL, " \t")) {
cmd = comtch(name, player_coms, -1);
if (cmd < 0) {
logerror("Warning: not disabling %s command %s\n",
cmd == M_NOTUNIQUE ? "ambiguous" : "unknown", name);
continue;
}
player_coms[cmd].c_permit |= GOD;
}
free(tmp);
}
/* /*
* returns true if down * returns true if down
*/ */