From 98ed0ad89cb0268cce21e99bcc226c8d2fc81234 Mon Sep 17 00:00:00 2001 From: Ari Johnson Date: Tue, 20 Feb 2007 20:17:35 +0000 Subject: [PATCH] @decompile/prefix --- game/txt/hlp/cobra_cmd.hlp | 35 +++++++++++++++++------------ hdrs/game.h | 6 ++--- src/SWITCHES | 1 + src/cmds.c | 28 +++++++++++++++++------- src/command.c | 2 +- src/look.c | 45 +++++++++++++++++--------------------- 6 files changed, 66 insertions(+), 51 deletions(-) diff --git a/game/txt/hlp/cobra_cmd.hlp b/game/txt/hlp/cobra_cmd.hlp index c749d02..ff17554 100644 --- a/game/txt/hlp/cobra_cmd.hlp +++ b/game/txt/hlp/cobra_cmd.hlp @@ -820,13 +820,17 @@ See also: ATTRIBUTES, NON-STANDARD ATTRIBUTES & @decompile @decompile[] [/] - @decompile/tf / + @decompile/prefix [/]= This command produces a list of the commands that you would have to enter in order to recreate . Useful for either copying objects from one MUSH to another, or for making logs of important objects to protect against an accidental @nuke or a crash. + When the /prefix switch is specified, and a prefix is given, all output + lines will be prefixed with . Good for creating client-side + scripts to edit code with. + You can either @decompile an entire object, or just certain parts of it. To @decompile just a few attributes, for example, you could type: @@ -854,24 +858,27 @@ See also: ATTRIBUTES, NON-STANDARD ATTRIBUTES (continued in help @decompile3) & @decompile3 - @decompile/tf / + @decompile/tf [/] + + Supplying the /tf switch makes @decompile act exactly as if you typed: + @decompile/prefix [/]=FugueEdit >%b - The /tf switch is useful only for users of the popular "TinyFugue" - client program (available from ftp.tcp.com in the directory - /pub/muds/Clients/tinyfugue). If you do have this program, this - switch is invaluable for editing code online, because it will grab the - code to set that attribute and put it into your buffer. + You can use a string other than "FugueEdit > " by setting your TFPREFIX + attribute. You are strongly urged to do so. Using @decompile/tf with + the default prefix presents the opportunity for a malicious player + to load your TinyFugue command line with a harmful command for you to + execute inadvertently. - To use @dec/tf, first type this command into TinyFugue: + The /tf switch is handy for grabbing code and placing it right + into your input window. To do this: - /def -ag -mglob -p100 -t"FugueEdit > *" fe = /grab %-2 + In TinyFugue: + /def -ag -mglob -p100 -t"FugueEdit > *" fe = /grab %-2 - (you can also put this into your .tfrc so it will automatically - be entered every time you start TinyFugue (tf).) This command works - just like the 'FugueEdit' object originally created by van@TinyTIM. + In SimpleMU: + Set your Options -> Grab Password + @set me=tfprefix:FugueEdit >%b - You can use a string other than "FugueEdit > " by setting your - TFPREFIX attribute. This is probably a good idea. See also: CLIENTS, ATTRIBUTES, WILDCARDS, MUSHCODE & @describe @describe [=] diff --git a/hdrs/game.h b/hdrs/game.h index 93d4b81..1731c6d 100644 --- a/hdrs/game.h +++ b/hdrs/game.h @@ -75,9 +75,9 @@ extern void do_sweep(dbref player, const char *arg1); enum ent_type { ENT_EXITS, ENT_THINGS, ENT_PLAYERS, ENT_ROOMS, ENT_ALL }; extern void do_entrances(dbref player, const char *where, char **argv, enum ent_type val); -enum dec_type { DEC_NORMAL, DEC_DB, DEC_TF, DEC_FLAG, DEC_ATTR }; -extern void do_decompile - (dbref player, const char *name, enum dec_type dbflag, int skipdef); +enum dec_type { DEC_NORMAL, DEC_DB, DEC_FLAG, DEC_ATTR }; +extern void do_decompile(dbref player, const char *name, const char *prefix, + enum dec_type dbflag, int skipdef); /* From move.c */ extern void do_get(dbref player, const char *what); diff --git a/src/SWITCHES b/src/SWITCHES index a8ee94e..4e72e1a 100644 --- a/src/SWITCHES +++ b/src/SWITCHES @@ -102,6 +102,7 @@ PARANOID PLAYERS PORT POWERS +PREFIX PRESERVE PRINT PRIVS diff --git a/src/cmds.c b/src/cmds.c index 8c9e2d0..9235ed6 100644 --- a/src/cmds.c +++ b/src/cmds.c @@ -214,17 +214,29 @@ COMMAND (cmd_dbck) { } COMMAND (cmd_decompile) { - if (SW_ISSET(sw, SWITCH_DB)) - do_decompile(player, arg_left, DEC_DB, SW_ISSET(sw, SWITCH_SKIPDEFAULTS)); - else if (SW_ISSET(sw, SWITCH_TF)) - do_decompile(player, arg_left, DEC_TF, SW_ISSET(sw, SWITCH_SKIPDEFAULTS)); + char prefix[BUFFER_LEN]; + int sd = SW_ISSET(sw, SWITCH_SKIPDEFAULTS); + *prefix = '\0'; + if (SW_ISSET(sw, SWITCH_TF)) { + /* @dec/tf overrides @dec/prefix */ + ATTR *a; + if (((a = atr_get_noparent(player, "TFPREFIX")) != NULL) && + AL_STR(a) && *AL_STR(a)) { + strcpy(prefix, atr_value(a)); + } else { + strcpy(prefix, "FugueEdit > "); + } + } else if (SW_ISSET(sw, SWITCH_PREFIX)) { + strcpy(prefix, arg_right); + } + if (SW_ISSET(sw, SWITCH_DB) || SW_ISSET(sw, SWITCH_TF)) + do_decompile(player, arg_left, prefix, DEC_DB, sd); else if (SW_ISSET(sw, SWITCH_FLAGS)) - do_decompile(player, arg_left, DEC_FLAG, SW_ISSET(sw, SWITCH_SKIPDEFAULTS)); + do_decompile(player, arg_left, prefix, DEC_FLAG, sd); else if (SW_ISSET(sw, SWITCH_ATTRIBS)) - do_decompile(player, arg_left, DEC_ATTR, SW_ISSET(sw, SWITCH_SKIPDEFAULTS)); + do_decompile(player, arg_left, prefix, DEC_ATTR, sd); else - do_decompile(player, arg_left, DEC_NORMAL, - SW_ISSET(sw, SWITCH_SKIPDEFAULTS)); + do_decompile(player, arg_left, prefix, DEC_NORMAL, sd); } COMMAND (cmd_teach) { diff --git a/src/command.c b/src/command.c index 01be4f1..e1fece1 100644 --- a/src/command.c +++ b/src/command.c @@ -113,7 +113,7 @@ COMLIST commands[] = { #endif {"@DBCK", NULL, cmd_dbck, CMD_T_ANY, "POWER^SITE"}, - {"@DECOMPILE", "DB TF FLAGS ATTRIBS SKIPDEFAULTS", cmd_decompile, + {"@DECOMPILE", "DB PREFIX TF FLAGS ATTRIBS SKIPDEFAULTS", cmd_decompile, CMD_T_ANY, NULL}, {"@DESTROY", "OVERRIDE", cmd_destroy, CMD_T_ANY, NULL}, diff --git a/src/look.c b/src/look.c index 530e70f..34a79b9 100644 --- a/src/look.c +++ b/src/look.c @@ -1522,12 +1522,12 @@ decompile_locks(dbref player, dbref thing, const char *name, int skipdef) * \param skipdef if true, skip showing default flags on attributes/locks. */ void -do_decompile(dbref player, const char *name, enum dec_type dbflag, int skipdef) +do_decompile(dbref player, const char *name, const char *prefix, + enum dec_type dbflag, int skipdef) { dbref thing; const char *object = NULL; char *attrib; - ATTR *a; char dbnum[40]; /* @decompile must always have an argument */ @@ -1554,20 +1554,13 @@ do_decompile(dbref player, const char *name, enum dec_type dbflag, int skipdef) if (attrib && *attrib) { switch (dbflag) { case DEC_DB: - decompile_atrs(player, thing, dbnum, attrib, "", skipdef); - break; - case DEC_TF: - if (((a = atr_get_noparent(player, "TFPREFIX")) != NULL) && - AL_STR(a) && *AL_STR(a)) { - decompile_atrs(player, thing, dbnum, attrib, atr_value(a), skipdef); - } else - decompile_atrs(player, thing, dbnum, attrib, "FugueEdit > ", skipdef); + decompile_atrs(player, thing, dbnum, attrib, prefix, skipdef); break; default: if (IsRoom(thing)) - decompile_atrs(player, thing, "here", attrib, "", skipdef); + decompile_atrs(player, thing, "here", attrib, prefix, skipdef); else - decompile_atrs(player, thing, Name(thing), attrib, "", skipdef); + decompile_atrs(player, thing, Name(thing), attrib, prefix, skipdef); break; } return; @@ -1594,7 +1587,7 @@ do_decompile(dbref player, const char *name, enum dec_type dbflag, int skipdef) } else object = Name(thing); if (dbflag != DEC_ATTR) - notify_format(player, "@create %s", object); + notify_format(player, "%s@create %s", prefix, object); break; case TYPE_ROOM: if (dbflag == DEC_DB) { @@ -1603,7 +1596,7 @@ do_decompile(dbref player, const char *name, enum dec_type dbflag, int skipdef) } else object = "here"; if (dbflag != DEC_ATTR) - notify_format(player, "@dig/teleport %s", Name(thing)); + notify_format(player, "%s@dig/teleport %s", prefix, Name(thing)); break; case TYPE_EXIT: if (dbflag == DEC_DB) { @@ -1611,7 +1604,7 @@ do_decompile(dbref player, const char *name, enum dec_type dbflag, int skipdef) } else { object = shortname(thing); if (dbflag != DEC_ATTR) - notify_format(player, "@open %s", Name(thing)); + notify_format(player, "%s@open %s", prefix, Name(thing)); } break; case TYPE_DIVISION: @@ -1621,37 +1614,39 @@ do_decompile(dbref player, const char *name, enum dec_type dbflag, int skipdef) object = shortname(thing); } if (dbflag != DEC_ATTR) - notify_format(player, "@division/create %s", object); + notify_format(player, "%s@division/create %s", prefix, object); break; } if (dbflag != DEC_ATTR) { if (Mobile(thing)) { if (GoodObject(Home(thing))) - notify_format(player, "@link %s = #%d", object, Home(thing)); + notify_format(player, "%s@link %s = #%d", prefix, object, Home(thing)); else if (Home(thing) == HOME) - notify_format(player, "@link %s = HOME", object); + notify_format(player, "%s@link %s = HOME", prefix, object); } else { if (GoodObject(Destination(thing))) - notify_format(player, "@link %s = #%d", object, Destination(thing)); + notify_format(player, "%s@link %s = #%d", prefix, object, + Destination(thing)); else if (Destination(thing) == AMBIGUOUS) - notify_format(player, "@link %s = VARIABLE", object); + notify_format(player, "%s@link %s = VARIABLE", prefix, object); else if (Destination(thing) == HOME) - notify_format(player, "@link %s = HOME", object); + notify_format(player, "%s@link %s = HOME", prefix, object); } if (GoodObject(Zone(thing))) - notify_format(player, "@chzone %s = #%d", object, Zone(thing)); + notify_format(player, "%s@chzone %s = #%d", prefix, object, Zone(thing)); if (GoodObject(Parent(thing))) - notify_format(player, "@parent %s = #%d", object, Parent(thing)); + notify_format(player, "%s@parent %s=#%d", prefix, object, Parent(thing)); if (GoodObject(SDIV(thing).object) && IsDivision(SDIV(thing).object)) - notify_format(player, "@division %s = #%d", object, SDIV(thing).object); + notify_format(player, "%s@division %s = #%d", prefix, object, + SDIV(thing).object); decompile_locks(player, thing, object, skipdef); decompile_flags(player, thing, object); decompile_powers(player, thing, object); } if (dbflag != DEC_FLAG) { - decompile_atrs(player, thing, object, "**", "", skipdef); + decompile_atrs(player, thing, object, "**", prefix, skipdef); } } -- 2.30.2