#
# J. Ellis 4/18/98 (patch file)
# A. Molitor (code)
#
# Several years ago Andrew wrote a nifty /switch for CrystalMUSH that
# essentially implemented +pex in hard code.
#
# I acquired the patch diffs from him for TinyMUSH 2.2.2, and then had
# to manually apply them on 2.2.3 because the patch process collided
# badly in look.c. (Patch thought it was right, but it wasn't.)
#
# This file is an extract I did from my own source tree, applied back
# to the Standard 2.2.3 Release, and then extracted again.
#
# This patch adds the switch /pretty to @examine and @decompile.
# It assumes you're starting from the standard 2.2.3 distribution.
# It does not appear to collide with any other patches in my collection.
#
# To apply this patch:
#
# 1) Acquire this patch file in a safe fashion. FTP is recommended.
# 2) cd into tinymush-2.2.3
# 3) patch <pretty.patch
# 4) make; make install
#
# If you have trouble applying the patch itself, contact me. If you
# don't like the format of the output, well, you'll have to cajole
# Andrew into altering it for you, because I haven't studied it closely
# enough to change it. I like it the way it is.
#
*** src/command.c 1995/03/20 23:59:47 1.11
--- src/command.c 1998/04/18 23:23:18
***************
*** 71,76 ****
--- 71,83 ----
{(char *) "preserve", 2, CA_WIZARD, CLONE_PRESERVE | SW_MULTIPLE},
{NULL, 0, 0, 0}};
+ #ifdef PRETTY
+ NAMETAB decompile_sw[] =
+ {
+ {(char *) "pretty", 1, CA_PUBLIC, DECOMPILE_PRETTY},
+ {NULL, 0, 0, 0}};
+
+ #endif /* PRETTY */
NAMETAB destroy_sw[] =
{
{(char *) "override", 8, CA_PUBLIC, DEST_OVERRIDE},
***************
*** 126,131 ****
--- 133,141 ----
{(char *) "debug", 1, CA_WIZARD, EXAM_DEBUG},
{(char *) "full", 1, CA_PUBLIC, EXAM_LONG},
{(char *) "parent", 1, CA_PUBLIC, EXAM_PARENT},
+ #ifdef PRETTY
+ {(char *) "pretty", 1, CA_PUBLIC, EXAM_PRETTY},
+ #endif /* PRETTY */
{NULL, 0, 0, 0}};
NAMETAB femit_sw[] =
***************
*** 396,402 ****
--- 406,416 ----
0, CS_ONE_ARG | CS_INTERP, do_cut},
{(char *) "@dbck", NULL, CA_WIZARD,
0, CS_NO_ARGS, do_dbck},
+ #ifndef PRETTY
{(char *) "@decompile", NULL, 0,
+ #else
+ {(char *) "@decompile", decompile_sw, 0,
+ #endif /* PRETTY */
0, CS_TWO_ARG | CS_INTERP, do_decomp},
{(char *) "@destroy", destroy_sw,
CA_NO_SLAVE | CA_NO_GUEST | CA_GBL_BUILD,
*** src/externs.h 1995/03/21 00:00:11 1.9
--- src/externs.h 1998/04/18 23:23:19
***************
*** 376,381 ****
--- 376,384 ----
#define DBCK_TYPES 1024 /* Check for valid & appropriate types */
#define DBCK_SPARE 2048 /* Make sure spare header fields are NOTHING */
#define DBCK_HOMES 4096 /* Make sure homes and droptos are valid */
+ #ifdef PRETTY
+ #define DECOMPILE_PRETTY 1 /* decompile it pretty-printed */
+ #endif /* PRETTY */
#define DEST_ONE 1 /* object */
#define DEST_ALL 2 /* owner */
#define DEST_OVERRIDE 4 /* override Safe() */
***************
*** 394,399 ****
--- 397,405 ----
#define EXAM_LONG 2 /* Nonowner sees public attrs too */
#define EXAM_DEBUG 4 /* Display more info for finding db problems */
#define EXAM_PARENT 8 /* Get attr from parent when exam obj/attr */
+ #ifdef PRETTY
+ #define EXAM_PRETTY 16 /* Pretty-printed output */
+ #endif /* PRETTY */
#define FIXDB_OWNER 1 /* Fix OWNER field */
#define FIXDB_LOC 2 /* Fix LOCATION field */
#define FIXDB_CON 4 /* Fix CONTENTS field */
*** src/look.c 1995/03/21 00:00:37 1.8
--- src/look.c 1998/04/18 23:23:20
***************
*** 111,116 ****
--- 111,340 ----
#define CONTENTS_NESTED 1
#define CONTENTS_REMOTE 2
+ #ifdef PRETTY
+
+ /*
+ * pretty-print an attribute into a buffer. It assumes that dest is an lbuf.
+ */
+
+ #define INDENT_STR " "
+
+ static void
+ pretty_print_guts(dest, cp, p)
+ char *dest, **cp, *p;
+ {
+ int indent, i;
+
+ indent = 1;
+ safe_chr('\n', dest, cp);
+ for (i = 0; i < indent; i++)
+ safe_str(INDENT_STR, dest, cp);
+
+ while (*p) {
+ switch (*p) {
+ case '\\':
+ /* Skip escaped chars */
+ safe_chr(*p, dest, cp);
+ p++;
+ safe_chr(*p, dest, cp);
+ if (*p == '\0')
+ return; /* we're done */
+ break;
+ case '{':
+ safe_chr('\n', dest, cp);
+ for (i = 0; i < indent; i++)
+ safe_str(INDENT_STR, dest, cp);
+ safe_chr('{', dest, cp);
+ safe_chr('\n', dest, cp);
+ indent++;
+ for (i = 0; i < indent; i++)
+ safe_str(INDENT_STR, dest, cp);
+ while (p[1] == ' ')
+ p++;
+ break;
+ case '}':
+ if (indent > 1)
+ indent--;
+ safe_chr('\n', dest, cp);
+ for (i = 0; i < indent; i++)
+ safe_str(INDENT_STR, dest, cp);
+ safe_chr('}', dest, cp);
+ safe_chr('\n', dest, cp);
+ for (i = 0; i < indent; i++)
+ safe_str(INDENT_STR, dest, cp);
+ while (p[1] == ' ')
+ p++;
+ break;
+ case ';':
+ safe_chr(';', dest, cp);
+ safe_chr('\n', dest, cp);
+ for (i = 0; i < indent; i++)
+ safe_str(INDENT_STR, dest, cp);
+ while (p[1] == ' ')
+ p++;
+ break;
+ default:
+ safe_chr(*p, dest, cp);
+ break;
+ }
+ p++;
+ }
+ }
+
+ static void
+ pretty_print(dest, name, text, separator)
+ char *dest;
+ char *name;
+ char *text;
+ char separator;
+ {
+ char *cp, *p, *word;
+
+ cp = dest;
+ p = text;
+
+ safe_str(name, dest, &cp);
+ safe_chr(separator, dest, &cp);
+
+ /* Now pretty-print 'text' into 'dest' */
+
+ switch (*text) {
+ case '$':
+ case '^':
+ /* These are $foo: cases */
+ while (*p && *p != ':') {
+ safe_chr(*p, dest, &cp);
+ p++;
+ }
+ /* Do the ':' */
+ if (*p == ':') {
+ safe_chr(':', dest, &cp);
+ } else {
+ return;
+ }
+
+ p++;
+ /* Fall through to format up the rest */
+
+ case '@':
+ case '&':
+
+ /* Do normal formatting here */
+
+ pretty_print_guts(dest, &cp, p);
+ break;
+
+ case '#':
+ /* Check for special case of: 1st word starts with #, there */
+ /* is a second word, and it does NOT start with a #, since */
+ /* these are guessed to be force commands. */
+
+ word = p;
+ while (*word && *word != ' ' && *word != '\t')
+ word++;
+
+ while (*word && (*word == ' ' || *word == ' '))
+ word++;
+
+ if (*word == '\0' || *word == '#') {
+ /* No second word, or this is looking like a list */
+ /* of dbrefs, bail out here */
+
+ safe_str(p, dest, &cp);
+ return;
+ }
+ pretty_print_guts(dest, &cp, p);
+
+ break;
+
+ default:
+ /* Just oridnary text */
+
+ safe_str(p, dest, &cp);
+ }
+ safe_chr('\n', dest, &cp);
+ safe_chr('-', dest, &cp);
+ /* safe_chr('\n', dest, &cp); */
+ }
+
+
+
+ static void
+ view_atr_pretty(player, thing, ap, text, aowner, aflags, skip_tag)
+ dbref player, thing, aowner;
+ int aflags, skip_tag;
+ ATTR *ap;
+ char *text;
+ {
+ char *buf;
+ char *name_buf;
+ char xbuf[6];
+ char *xbufp;
+ BOOLEXP *bool;
+
+ if (ap->flags & AF_IS_LOCK) {
+ bool = parse_boolexp(player, text, 1);
+ text = unparse_boolexp(player, bool);
+ free_boolexp(bool);
+ }
+ /*
+ * If we don't control the object or own the attribute, hide the attr
+ * owner and flag info.
+ */
+
+ if (!Controls(player, thing) && (Owner(player) != aowner)) {
+ if (skip_tag && (ap->number == A_DESC)) {
+ buf = text;
+ notify(player, buf);
+ } else {
+ buf = alloc_lbuf("view_atr_pretty1");
+ pretty_print(buf, ap->name, text, ':');
+ notify(player, buf);
+ free_lbuf(buf);
+ }
+ return;
+ }
+ /* Generate flags */
+
+ xbufp = xbuf;
+ if (aflags & AF_LOCK)
+ *xbufp++ = '+';
+ if (aflags & AF_NOPROG)
+ *xbufp++ = '$';
+ if (aflags & AF_PRIVATE)
+ *xbufp++ = 'I';
+ if (aflags & AF_VISUAL)
+ *xbufp++ = 'V';
+ if (aflags & AF_DARK)
+ *xbufp++ = 'd';
+ if (aflags & AF_GOD)
+ *xbufp++ = 'g';
+ if (aflags & AF_MDARK)
+ *xbufp++ = 'm';
+ if (aflags & AF_WIZARD)
+ *xbufp++ = 'w';
+ *xbufp = '\0';
+
+ buf = alloc_lbuf("view_atr_pretty2");
+ if ((aowner != Owner(thing)) && (aowner != NOTHING)) {
+ name_buf = tprintf("%s(#%d%s)", ap->name, aowner, xbuf);
+ pretty_print(buf, name_buf, text, ':');
+ } else if (*xbuf) {
+ name_buf = tprintf("%s(%s)", ap->name, xbuf);
+ pretty_print(buf, name_buf, text, ':');
+ } else if (!skip_tag || (ap->number != A_DESC)) {
+ pretty_print(buf, ap->name, text, ':');
+ } else {
+ char *cp;
+
+ cp = buf;
+ safe_str("THIS SHOULD NOT OCCUR", buf, &cp);
+ }
+ notify(player, buf);
+ free_lbuf(buf);
+ }
+
+ #endif /* PRETTY */
#ifndef PUEBLO_SUPPORT
static void
***************
*** 285,293 ****
--- 509,525 ----
}
static void
+ #ifndef PRETTY
look_atrs1(player, thing, othing, check_exclude, hash_insert)
+ #else
+ look_atrs1(player, thing, othing, check_exclude, hash_insert, do_pretty)
+ #endif /* PRETTY */
dbref player, thing, othing;
+ #ifndef PRETTY
int check_exclude, hash_insert;
+ #else
+ int check_exclude, hash_insert, do_pretty;
+ #endif /* PRETTY */
{
dbref aowner;
int ca, aflags;
***************
*** 313,319 ****
--- 545,559 ----
if (!(check_exclude && (aflags & AF_PRIVATE))) {
if (hash_insert)
nhashadd(ca, (int *) attr, &mudstate.parent_htab);
+ #ifndef PRETTY
view_atr(player, thing, attr, buf, aowner, aflags, 0);
+ #else
+ if (do_pretty)
+ view_atr_pretty(player, thing, attr, buf, aowner,
+ aflags, 0);
+ else
+ view_atr(player, thing, attr, buf, aowner, aflags, 0);
+ #endif /* PRETTY */
}
}
free_lbuf(buf);
***************
*** 321,335 ****
--- 561,587 ----
}
static void
+ #ifndef PRETTY
look_atrs(player, thing, check_parents)
+ #else
+ look_atrs(player, thing, check_parents, do_pretty)
+ #endif /* PRETTY */
dbref player, thing;
+ #ifndef PRETTY
int check_parents;
+ #else
+ int check_parents, do_pretty;
+ #endif /* PRETTY */
{
dbref parent;
int lev, check_exclude, hash_insert;
if (!check_parents) {
+ #ifndef PRETTY
look_atrs1(player, thing, thing, 0, 0);
+ #else
+ look_atrs1(player, thing, thing, 0, 0, do_pretty);
+ #endif /* PRETTY */
} else {
hash_insert = 1;
check_exclude = 0;
***************
*** 338,344 ****
--- 590,600 ----
if (!Good_obj(Parent(parent)))
hash_insert = 0;
look_atrs1(player, parent, thing,
+ #ifndef PRETTY
check_exclude, hash_insert);
+ #else
+ check_exclude, hash_insert, do_pretty);
+ #endif /* PRETTY */
check_exclude = 1;
}
}
***************
*** 375,381 ****
--- 631,641 ----
#endif /* ! PUEBLO_SUPPORT */
if (!mudconf.quiet_look && (!Terse(player) || mudconf.terse_look)) {
+ #ifndef PRETTY
look_atrs(player, thing, 0);
+ #else
+ look_atrs(player, thing, 0, 0);
+ #endif /* PRETTY */
}
}
***************
*** 508,514 ****
--- 768,778 ----
/* tell him the attributes, contents and exits */
if ((key & LK_SHOWATTR) && !mudconf.quiet_look && !is_terse)
+ #ifndef PRETTY
look_atrs(player, loc, 0);
+ #else
+ look_atrs(player, loc, 0, 0);
+ #endif /* PRETTY */
if (!is_terse || mudconf.terse_contents)
look_contents(player, loc, "Contents:", CONTENTS_LOCAL);
if ((key & LK_SHOWEXIT) && (!is_terse || mudconf.terse_exits))
***************
*** 664,672 ****
--- 928,944 ----
}
static void
+ #ifndef PRETTY
exam_wildattrs(player, thing, do_parent)
+ #else
+ exam_wildattrs(player, thing, do_parent, do_pretty)
+ #endif /* PRETTY */
dbref player, thing;
+ #ifndef PRETTY
int do_parent;
+ #else
+ int do_parent, do_pretty;
+ #endif /* PRETTY */
{
int atr, aflags, got_any;
char *buf;
***************
*** 697,717 ****
--- 969,1016 ----
if (Examinable(player, thing) &&
Read_attr(player, thing, ap, aowner, aflags)) {
got_any = 1;
+ #ifndef PRETTY
view_atr(player, thing, ap, buf,
aowner, aflags, 0);
+ #else
+ if(do_pretty)
+ view_atr_pretty(player, thing, ap, buf,
+ aowner, aflags, 0);
+ else
+ view_atr(player, thing, ap, buf,
+ aowner, aflags, 0);
+ #endif /* PRETTY */
} else if (isPlayer(thing) &&
Read_attr(player, thing, ap, aowner, aflags)) {
got_any = 1;
if (aowner == Owner(player)) {
+ #ifndef PRETTY
view_atr(player, thing, ap, buf,
aowner, aflags, 0);
+ #else
+ if (do_pretty)
+ view_atr_pretty(player, thing, ap, buf,
+ aowner, aflags, 0);
+ else
+ view_atr(player, thing, ap, buf,
+ aowner, aflags, 0);
+ #endif /* PRETTY */
} else if ((atr == A_DESC) &&
(mudconf.read_rem_desc ||
nearby(player, thing))) {
show_desc(player, thing, 0);
} else if (atr != A_DESC) {
+ #ifndef PRETTY
view_atr(player, thing, ap, buf,
aowner, aflags, 0);
+ #else
+ if (do_pretty)
+ view_atr_pretty(player, thing, ap, buf,
+ aowner, aflags, 0);
+ else
+ view_atr(player, thing, ap, buf,
+ aowner, aflags, 0);
+ #endif /* PRETTY */
} else {
notify(player,
"");
***************
*** 719,733 ****
--- 1018,1050 ----
} else if (Read_attr(player, thing, ap, aowner, aflags)) {
got_any = 1;
if (aowner == Owner(player)) {
+ #ifndef PRETTY
view_atr(player, thing, ap, buf,
aowner, aflags, 0);
+ #else
+ if (do_pretty)
+ view_atr_pretty(player, thing, ap, buf,
+ aowner, aflags, 0);
+ else
+ view_atr(player, thing, ap, buf,
+ aowner, aflags, 0);
+ #endif /* PRETTY */
} else if ((atr == A_DESC) &&
(mudconf.read_rem_desc ||
nearby(player, thing))) {
show_desc(player, thing, 0);
} else if (nearby(player, thing)) {
+ #ifndef PRETTY
view_atr(player, thing, ap, buf,
aowner, aflags, 0);
+ #else
+ if (do_pretty)
+ view_atr_pretty(player, thing, ap, buf,
+ aowner, aflags, 0);
+ else
+ view_atr(player, thing, ap, buf,
+ aowner, aflags, 0);
+ #endif /* PRETTY */
} else {
notify(player,
"");
***************
*** 751,757 ****
--- 1068,1078 ----
char savec;
char *temp, *buf, *buf2;
BOOLEXP *bool;
+ #ifndef PRETTY
int control, aflags, do_parent;
+ #else
+ int control, aflags, do_parent, do_pretty;
+ #endif /* PRETTY */
/* This command is pointless if the player can't hear. */
***************
*** 759,764 ****
--- 1080,1088 ----
return;
do_parent = key & EXAM_PARENT;
+ #ifdef PRETTY
+ do_pretty = key & EXAM_PRETTY;
+ #endif /* PRETTY */
thing = NOTHING;
if (!name || !*name) {
if ((thing = Location(player)) == NOTHING)
***************
*** 767,773 ****
--- 1091,1101 ----
/* Check for obj/attr first. */
if (parse_attrib_wild(player, name, &thing, do_parent, 1, 0)) {
+ #ifndef PRETTY
exam_wildattrs(player, thing, do_parent);
+ #else
+ exam_wildattrs(player, thing, do_parent, do_pretty);
+ #endif /* PRETTY */
return;
}
/* Look it up */
***************
*** 872,878 ****
--- 1200,1210 ----
free_lbuf(buf2);
}
}
+ #ifndef PRETTY
look_atrs(player, thing, do_parent);
+ #else
+ look_atrs(player, thing, do_parent,do_pretty);
+ #endif /* PRETTY */
/* show him interesting stuff */
***************
*** 1367,1374 ****
--- 1699,1714 ----
{
BOOLEXP *bool;
char *got, *thingname, *as, *ltext, *buff;
+ #ifdef PRETTY
+ char *pp_prefix, *pp_prefix_cp;
+ char *pp_buffer;
+ #endif /* PRETTY */
dbref aowner, thing;
+ #ifndef PRETTY
int val, aflags, ca, wild_decomp;
+ #else
+ int val, aflags, ca, wild_decomp, do_pretty;
+ #endif /* PRETTY */
ATTR *attr;
NAMETAB *np;
***************
*** 1398,1403 ****
--- 1738,1754 ----
* report the command to make the thing.
*/
+ #ifdef PRETTY
+ do_pretty = key & DECOMPILE_PRETTY;
+
+ /* Make sure these get freed later, if(do_pretty) */
+
+ if (do_pretty) {
+ pp_buffer = alloc_lbuf("do_decomp.pp_buffer");
+ pp_prefix = alloc_lbuf("do_decomp.pp_prefix");
+ }
+
+ #endif /* PRETTY */
if (qual && *qual) {
strcpy(thingname, qual);
} else {
***************
*** 1464,1474 ****
--- 1815,1855 ----
attr->name, thingname, ltext));
} else {
strcpy(buff, attr->name);
+ #ifndef PRETTY
notify(player,
tprintf("%c%s %s=%s",
((ca < A_USER_START) ?
'@' : '&'),
buff, thingname, got));
+ #else
+ if (do_pretty) {
+ /* Build a prefix string */
+
+ pp_prefix_cp = pp_prefix;
+ safe_chr(((ca < A_USER_START) ? '@' : '&'),
+ pp_prefix, &pp_prefix_cp);
+ safe_str(buff, pp_prefix, &pp_prefix_cp);
+ safe_chr(' ', pp_prefix, &pp_prefix_cp);
+ safe_str(thingname, pp_prefix, &pp_prefix_cp);
+
+ /*
+ * Now paste the prefix and the raw
+ * attribute together
+ */
+
+ pretty_print(pp_buffer, pp_prefix, got, '=');
+
+ /* Now ship it out */
+
+ notify(player, pp_buffer);
+ } else {
+ notify(player,
+ tprintf("%c%s %s=%s",
+ ((ca < A_USER_START) ?
+ '@' : '&'),
+ buff, thingname, got));
+ }
+ #endif /* PRETTY */
if (aflags & AF_LOCK) {
notify(player, tprintf("@lock %s/%s",
***************
*** 1494,1499 ****
--- 1875,1887 ----
free_lbuf(got);
}
free_sbuf(buff);
+ #ifdef PRETTY
+
+ if (do_pretty) {
+ free_lbuf(pp_prefix);
+ free_lbuf(pp_buffer);
+ }
+ #endif /* PRETTY */
if (!wild_decomp)
decompile_flags(player, thing, thingname);
*** text/help.txt 1998/04/18 20:11:16 1.1
--- text/help.txt 1998/04/19 02:29:54 1.1.5.1
***************
*** 148,153 ****
--- 148,154 ----
attributes set on the object in addition to the owner's name.
/parent - Includes attributes that are not present on the object itself
but which are inherited from the object's parent.
+ /pretty - Displays attribute contents in a format similar to +pex.
See also: look, @decompile, VISUAL, ATTRIBUTE OWNERSHIP.
& get
***************
*** 6678,6683 ****
--- 6679,6686 ----
dumped (no flags, etc.) The wildcard pattern is identical to the type
used by the 'examine' command and the 'lattr()' function.
+ The following switch is available:
+ /pretty - Displays attribute contents in a format similar to +pex.
& Patchlevel
User-visible changes in TinyMUSH 2.2
| Frames Homepage | Non-Frames Homepage |
|
In memory of those who died Sept. 11, 2001 at the World Trade Center, the Pentagon, and on American Airlines Flight 11, United Airlines Flight 175, American Airlines Flight 77, and United Airlines Flight 93 | |
|---|---|---|
|
Honoring Marsh & McLennan professionals I've worked with,
including: Jack Aron, Valerie Hanna, Joe Sisolak, Greg Reda, and Cathy Fagan. |
||
| Shattered Photoessay by James Nachtewy | ||
Comments may be sent to gyles19@nospam.visi.com
This page last updated Sunday, 17-May-1998 22:20:06 CDT.