From f9fc80e2dee979ff0d6caeba04c13474ea51b62d Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sat, 18 Feb 2012 16:19:59 +0100 Subject: [PATCH] Revise nation status command permissions Create new command capability NONVIS. Give it to players in any state except visitors (and STAT_UNUSED, but those must not exist). This makes it possible to have commands available to anyone but visitors. Command change fails when the player is a visitor. Simply make it unavailable instead, by requiring NONVIS. Make read unavailable to visitors, because it's useless: visitors can't receive telegrams (typed_wu() fails). Make census, commodity and sinfra unavailable to visitors. Visitors don't normally have sectors. Make map and nmap unavailable to visitors. Visitors don't have sectors, so their maps are always empty. Make them unavailable to new players (between add and newcap) and players in sanctuary, too. This is consistent with all the other commands to examine the environment. It also prevents people from trying multiple unbroken countries in a blitz to find the one with the nicest vicinity. Make resource available to new players, for consistency with census and commodity. Make country, echo and financial available to anyone. --- include/player.h | 1 + src/lib/commands/chan.c | 4 ---- src/lib/player/empmod.c | 22 +++++++++++----------- src/lib/player/init_nats.c | 5 +++-- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/include/player.h b/include/player.h index db1034cb6..3dcf429a7 100644 --- a/include/player.h +++ b/include/player.h @@ -42,6 +42,7 @@ #include "types.h" /* player command capabilities */ +#define NONVIS bit(0) /* can execute common commands (visitors can't) */ #define SANCT bit(1) /* can execute commands available in sanctuary */ #define NORM bit(2) /* can execute active player commands */ #define GOD bit(3) /* can execute deity commands */ diff --git a/src/lib/commands/chan.c b/src/lib/commands/chan.c index 2f59d2fdd..463305fda 100644 --- a/src/lib/commands/chan.c +++ b/src/lib/commands/chan.c @@ -49,10 +49,6 @@ chan(void) if (!p) return RET_SYN; us = getnatp(player->cnum); - if (us->nat_stat == STAT_VIS) { - pr("Visitor countries can't change their country name or representative.\n"); - return RET_FAIL; - } switch (*p) { case 'n': case 'c': diff --git a/src/lib/player/empmod.c b/src/lib/player/empmod.c index 265b02f0b..6233dbffd 100644 --- a/src/lib/player/empmod.c +++ b/src/lib/player/empmod.c @@ -70,15 +70,15 @@ struct cmndstr player_coms[] = { {"bye", 0, quit, 0, 0}, {"capital ", 0, capi, C_MOD, NORM}, {"cargo ", 0, carg, 0, NORM}, - {"census ", 0, cens, 0, 0}, - {"change ", 0, chan, C_MOD, 0}, + {"census ", 0, cens, 0, NONVIS}, + {"change ", 0, chan, C_MOD, NONVIS}, {"coastwatch ", 1, coas, C_MOD, NORM + CAP}, {"collect ", 2, coll, C_MOD, NORM + MONEY + CAP}, - {"commodity ", 0, comm, 0, 0}, + {"commodity ", 0, comm, 0, NONVIS}, {"consider ", 1, cons, C_MOD, NORM + CAP}, {"convert [sure?]", 2, conv, C_MOD, NORM + MONEY + CAP}, - {"country ", 0, coun, 0, NORM}, + {"country ", 0, coun, 0, 0}, {"cutoff ", 0, cuto, C_MOD, NORM}, {"declare ", 2, decl, C_MOD, NORM + CAP}, @@ -92,7 +92,7 @@ struct cmndstr player_coms[] = { {"drop ", 1, drop, C_MOD, NORM + MONEY + CAP}, {"dump []", 0, dump, 0, NORM}, - {"echo []", 0, echo, 0, NORM}, + {"echo []", 0, echo, 0, 0}, {"edit [ ]...", 0, edit, C_MOD, GOD}, {"enable", 0, enab, C_MOD, GOD}, @@ -100,7 +100,7 @@ struct cmndstr player_coms[] = { {"execute ", 0, execute, 0, EXEC}, {"explore ", 1, explore, C_MOD, NORM + MONEY + CAP}, - {"financial", 0, fina, 0, NORM}, + {"financial", 0, fina, 0, 0}, {"fire [TO-SECT | SHIP]", 1, multifire, C_MOD, NORM + MONEY + CAP}, {"flash []", 0, flash, 0, 0}, @@ -145,7 +145,7 @@ struct cmndstr player_coms[] = { 1, ltend, C_MOD, NORM + CAP}, {"lunload ", 1, lload, C_MOD, NORM + CAP}, - {"map [s|l|n|p|*|h]", 0, map, C_MOD, 0}, + {"map [s|l|n|p|*|h]", 0, map, C_MOD, NORM}, {"march ", 1, march, C_MOD, NORM + CAP}, {"market ", 0, mark, C_MOD, NORM}, {"mine ", 2, mine, C_MOD, NORM + MONEY + CAP}, @@ -164,7 +164,7 @@ struct cmndstr player_coms[] = { {"newcap ", 0, new, C_MOD, GOD}, {"neweff ", 0, newe, C_MOD, NORM}, {"newspaper [days]", 0, news, 0, 0}, - {"nmap [s|l|n|p|*|h]", 0, map, C_MOD, 0}, + {"nmap [s|l|n|p|*|h]", 0, map, C_MOD, NORM}, {"nuke ", 0, nuke, 0, NORM}, {"offer [ ]", 1, offe, C_MOD, NORM + MONEY + CAP}, @@ -190,7 +190,7 @@ struct cmndstr player_coms[] = { {"quit", 0, quit, 0, 0}, {"radar ", 1, rada, C_MOD, NORM + CAP}, {"range ", 1, range, C_MOD, NORM + CAP}, - {"read [yes|no|]", 0, rea, C_MOD, 0}, + {"read [yes|no|]", 0, rea, C_MOD, NONVIS}, {"realm []", 0, real, C_MOD, NORM}, {"recon ", 3, reco, C_MOD, NORM + MONEY + CAP}, @@ -201,7 +201,7 @@ struct cmndstr player_coms[] = { {"repay ", 1, repa, C_MOD, NORM + MONEY + CAP}, {"report ", 0, repo, 0, 0}, {"reset <0|price>", 1, rese, C_MOD, NORM + CAP}, - {"resource ", 0, reso, 0, NORM}, + {"resource ", 0, reso, 0, NONVIS}, {"retreat [i|t|s|h|b|d|u|c]", 1, retr, C_MOD, NORM + CAP}, {"route ", 1, rout, C_MOD, NORM}, @@ -229,7 +229,7 @@ struct cmndstr player_coms[] = { "\tshow updates []>", 0, show, 0, 0}, {"shutdown ", 0, shut, 0, GOD}, - {"sinfrastructure ", 0, sinfra, 0, 0}, + {"sinfrastructure ", 0, sinfra, 0, NONVIS}, {"skywatch ", 1, skyw, C_MOD, NORM + CAP}, {"smap [s|l|n|p|*|h]", 0, map, C_MOD, NORM}, {"sonar ", 1, sona, C_MOD, NORM + CAP}, diff --git a/src/lib/player/init_nats.c b/src/lib/player/init_nats.c index f2880209d..dee407cc0 100644 --- a/src/lib/player/init_nats.c +++ b/src/lib/player/init_nats.c @@ -29,7 +29,7 @@ * Known contributors to this file: * Dave Pare, 1994 * Steve McClure, 2000 - * Markus Armbruster, 2007 + * Markus Armbruster, 2007-2012 */ #include @@ -70,7 +70,8 @@ player_set_nstat(struct player *pl, struct natstr *np) { static int nstat[] = { /* must match nat_status */ - 0, 0, 0, SANCT, NORM, GOD | NORM | CAP | MONEY + 0, NONVIS, 0, SANCT | NONVIS, NORM | NONVIS, + GOD | NORM | NONVIS | CAP | MONEY }; if (CANT_HAPPEN(pl->cnum != np->nat_cnum)) -- 2.43.0