# # Patch name: @flag # Patch version: 2 # Author's name: Shawn Wagner (Raevnos@M*U*S*H) # Author's email: shawnw@wpi.edu # Version of PennMUSH: 1.7.2p15 # Date patch made: 9/16/98 # Author is willing to support (yes/no): yes # Patch format: diff -c # # # This is a contributed PennMUSH patch. Its use is subject to the # same restrictions found in PennMUSH's hdrs/copyrite.h file. # # No warranty is given for this patch. It is not necessarily going # to work on your system, with any version of PennMUSH other than # the one above, etc. # # If the author given above was willing to support the patch, you # should write to the author if you have any questions or problems. Do # *NOT* send email messages to Javelin or any PennMUSH mailing list about # this patch! # # Below this line is the author's description of the patch, # followed by the patch itself. If the patch is in context diff # format, you'll probably apply it by typing: patch < patchfile # in your top-level MUSH directory, unless instructed otherwise # below. # # # What it does: # Add a wizard-only @flag command that works a bit like @attribute or # @command. # @flag : Shows you the flag's various permissions. # @flag/set =: Sets the flag's permissions (The perms # field). # @flag/see =: Same as @flag/set, meant for visibilty # settings while /set is for who can @set it. Purely cosmetic switch. # @flag/unset =: Sets the flag's removal permissions. (The # negate_perms field). # *** ../vanilla/src/SWITCHES Fri Aug 14 11:50:57 1998 --- src/SWITCHES Wed Sep 16 16:47:51 1998 *************** *** 102,107 **** --- 102,108 ---- TRACE UNCLEAR UNFOLDER + UNSET UNTAG URGENT WHAT *** ../vanilla/src/command.c Wed Sep 16 16:59:30 1998 --- src/command.c Wed Sep 16 16:56:00 1998 *************** *** 100,105 **** --- 100,106 ---- {"@FIND", NULL, cmd_find, CMD_T_ANY | CMD_T_EQSPLIT | CMD_T_RS_ARGS | CMD_T_NOGAGGED, 0, 0, 0}, {"@FIRSTEXIT", NULL, cmd_firstexit, CMD_T_ANY, 0, 0, 0}, {"@FIXDB", "LOCATION CONTENTS EXITS NEXT", cmd_fixdb, CMD_T_ANY | CMD_T_EQSPLIT, 0, 0, 0}, + {"@FLAG", "SET SEE UNSET", cmd_flag, CMD_T_ANY | CMD_T_EQSPLIT, 0, 0, 0}, {"@FORCE", NULL, cmd_force, CMD_T_ANY | CMD_T_EQSPLIT | CMD_T_NOGAGGED, 0, 0, 0}, {"@FUNCTION", "DELETE", cmd_function, CMD_T_ANY | CMD_T_EQSPLIT | CMD_T_RS_ARGS | CMD_T_NOGAGGED, 0, 0, 0}, {"@GEDIT", NULL, cmd_edit, CMD_T_ANY | CMD_T_EQSPLIT | CMD_T_RS_ARGS | CMD_T_RS_NOPARSE | CMD_T_NOGAGGED, 0, 0, 0}, *** ../vanilla/src/cmds.c Fri Aug 14 11:50:07 1998 --- src/cmds.c Wed Sep 16 16:56:45 1998 *************** *** 320,325 **** --- 320,334 ---- notify(player, "Command MUST have a switch."); } + COMMAND (cmd_flag) { + if (SW_ISSET(sw, SWITCH_UNSET)) + do_flag(player, arg_left, arg_right, 0); + else if (SW_ISSET(sw, SWITCH_SET) || SW_ISSET(sw, SWITCH_SEE)) + do_flag(player, arg_left, arg_right, 1); + else + do_flag(player, arg_left, NULL, 2); + } + COMMAND (cmd_force) { do_force(player, arg_left, arg_right); } *** ../vanilla/src/flags.c Fri Aug 14 11:50:22 1998 --- src/flags.c Wed Sep 16 16:54:25 1998 *************** *** 23,28 **** --- 23,29 ---- #include "intrface.h" #include "match.h" #include "htab.h" + #include "privtab.h" #include "confmagic.h" extern void hide_player _((dbref player, int hide)); *************** *** 85,93 **** --- 86,110 ---- void set_flag _((dbref player, dbref thing, char *flag, int negate, int hear, int listener)); int handle_flaglists _((dbref player, char *name, char *fstr, int type)); int sees_flag _((dbref privs, dbref thing, char *name)); + void do_flag _((dbref player, const char *flag, const char *perms, int mode)); HASHTAB htab_flag; + PRIV flag_privs[] = + { + {"any", '\0', F_ANY, F_ANY}, + {"inherit", '\0', F_INHERIT, F_INHERIT}, + {"owned", '\0', F_OWNED, F_OWNED}, + {"royal", '\0', F_ROYAL, F_ROYAL}, + {"wizard", '\0', F_WIZARD, F_WIZARD}, + {"god", '\0', F_GOD, F_GOD}, + {"internal", '\0', F_INTERNAL, F_INTERNAL}, + {"dark", '\0', F_DARK, F_DARK}, + {"mortal_dark", '\0', F_MDARK, F_MDARK}, + {"owner_dark", '\0', F_ODARK, F_ODARK}, + {NULL, '\0', 0, 0} + }; + /* Name Lettter Type Flag Perms Negate_Perm */ FLAG flag_table[] = { *************** *** 1314,1316 **** --- 1331,1379 ---- /* Got nothing. Return -1 */ return -1; } + + + void do_flag(dbref player, const char *flag, const char *perms, int mode) { + FLAG *f; + char tbuf1[BUFFER_LEN]; + int flags = 0; + + if (!Wizard(player)) { + notify(player, "Only wizards can use that command."); + return; + } + + if ((f = flag_hash_lookup(upcasestr((char *)flag))) == NULL) { + notify(player,"No such flag."); + return; + } + if (mode == 2) { /* Display current permissions. */ + switch (f->type) { + case NOTYPE: + strcpy(tbuf1, "All"); + break; + case TYPE_PLAYER: + strcpy(tbuf1, "Player"); + break; + case TYPE_ROOM: + strcpy(tbuf1, "Room"); + break; + case TYPE_EXIT: + strcpy(tbuf1, "Exit"); + break; + case TYPE_THING: + strcpy(tbuf1, "Object"); + break; + default: + strcpy(tbuf1, "Invalid type!"); + } + notify(player, tprintf("Flag: %s\nType: %s\nSet and See Permissions: %s\nUnset Permissions: %s\n", f->name, tbuf1, privs_to_string(flag_privs, f->perms), privs_to_string(flag_privs, f->negate_perms))); + else if (mode == 1) { /* Change the set/see permissions */ + if (f->perms & F_INTERNAL) + notify(player, "That is an internal flag, and cannot be changed."); + else { + flags = string_to_privs(flag_privs, perms, f->perms); + if (!flags) + notify(player, "I don't understand those permissions."); + else { + f->perms = flags; + notify(player, "Permissions set."); + } + } + } else if (mode == 0) { /* Change the unset permissions */ + /* Permissions for unsetting the flag. */ + if (f->negate_perms & F_INTERNAL) + notify(player, "That is an internal flag, and cannot be changed."); + else { + flags = string_to_privs(flag_privs, perms, f->negate_perms); + if (!flags) + notify(player, "I don't understand those permissions."); + else { + f->negate_perms = flags; + notify(player, "Permissions set."); + } + } + } + } +