diff --git a/include/econfig-spec.h b/include/econfig-spec.h index f15f61a8..7ba4dd4c 100644 --- a/include/econfig-spec.h +++ b/include/econfig-spec.h @@ -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") 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, "How long until announcements expire (<0 means never)") EMPCFBOTH("news_keep_days", news_keep_days, int, NSC_INT, KM_INTERNAL, diff --git a/src/lib/global/constants.c b/src/lib/global/constants.c index b911aaf5..f0230c74 100644 --- a/src/lib/global/constants.c +++ b/src/lib/global/constants.c @@ -43,7 +43,9 @@ char *privlog = "careless@invalid"; /* Divine hosts and networks */ 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_Y = 32; /* World size - y */ diff --git a/src/lib/player/empdis.c b/src/lib/player/empdis.c index 83d445e3..fc5acf96 100644 --- a/src/lib/player/empdis.c +++ b/src/lib/player/empdis.c @@ -44,6 +44,7 @@ #include "com.h" #include "file.h" #include "empio.h" +#include "match.h" #include "subs.h" #include "common.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[] */ static int player_commands_index = 0; +static void disable_coms(void); + /* * Get a command from the current player into COMBUFP[1024], in UTF-8. * 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) *player_commands[i] = 0; + + disable_coms(); } void @@ -158,6 +163,26 @@ explain(void) 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 */