diff -pruN slashem-0.0.7E7F1-official-release/doc/Guidebook.mn slashem-0.0.7E7F1-preadjust/doc/Guidebook.mn --- slashem-0.0.7E7F1-official-release/doc/Guidebook.mn 2005-07-02 09:24:44.000000000 +0200 +++ slashem-0.0.7E7F1-preadjust/doc/Guidebook.mn 2005-10-27 23:02:29.000000000 +0200 @@ -1757,6 +1757,14 @@ A zero in any entry in such a sequence l entry unchanged; this feature is not available using the option syntax. Such a sequence can be continued to multiple lines by putting a `\e' at the end of each line to be continued. +If the PREADJUST compile-time option is enabled, any line starting with +``PREADJUST:'' causes an #adjust command to be performed on a corresponding +item in the starting inventory of a new character. For instance, +``PREADJUST:C-cloak'' will adjust an object whose name contains ``cloak'' +into the `C' slot; if the #sticky command is available, +``PREADJUST:C=cloak'' will also mark the object sticky. Note that common +prefixes like ``ring of'' do not appear in the internal name data for +objects, and so should not be included in your match string. Any line starting with ``TILESET='' defines a tile set in the same syntax as in SLASHEMOPTIONS (although the options are different). See the section on tile sets, below, for more information. diff -pruN slashem-0.0.7E7F1-official-release/doc/Guidebook.tex slashem-0.0.7E7F1-preadjust/doc/Guidebook.tex --- slashem-0.0.7E7F1-official-release/doc/Guidebook.tex 2005-07-02 09:24:44.000000000 +0200 +++ slashem-0.0.7E7F1-preadjust/doc/Guidebook.tex 2005-10-27 23:03:20.000000000 +0200 @@ -2422,8 +2422,18 @@ a sequence of decimal numbers giving the in the current font to be used in displaying each entry. A zero in any entry in such a sequence leaves the display of that entry unchanged; this feature is not available using the option syntax. -Such a sequence can be continued to multiple lines by putting a `{\tt $\backslash$ }' +Such a sequence can be continued to multiple lines by putting a `{\tt + $\backslash$ }' at the end of each line to be continued. + If the {\tt PREADJUST} compile-time option is enabled, any line starting +with ``{\tt PREADJUST:}'' causes an {\tt \#adjust} command to be performed +on a corresponding item in the starting inventory of a new character. For +instance, ``\mbox{\tt PREADJUST:C-cloak}'' will adjust an object whose name +contains ``cloak'' into the `C' slot; if the {\tt \#sticky} command is +available, ``\mbox{\tt PREADJUST:C=cloak}'' will also mark the object +sticky. Note that common prefixes like ``ring of'' do not appear in the +internal name data for objects, and so should not be included in your match +string. Any line starting with ``{\tt TILESET=}'' defines a tile set in the same syntax as in SLASHEMOPTIONS (although the options are different). See the section on tile sets, below, for more information. diff -pruN slashem-0.0.7E7F1-official-release/include/extern.h slashem-0.0.7E7F1-preadjust/include/extern.h --- slashem-0.0.7E7F1-official-release/include/extern.h 2005-07-02 09:24:44.000000000 +0200 +++ slashem-0.0.7E7F1-preadjust/include/extern.h 2005-10-27 22:59:59.000000000 +0200 @@ -891,6 +891,10 @@ E int NDECL(doprtool); E int NDECL(doprinuse); E void FDECL(useupf, (struct obj *,long)); E char *FDECL(let_to_name, (CHAR_P,BOOLEAN_P)); +#ifdef PREADJUST +/* This has to be up here so it won't collide with the sticky patch... */ +E void FDECL(doorganize_guts, (struct obj *, char, boolean)); +#endif /* PREADJUST */ E void NDECL(free_invbuf); E void NDECL(reassign); E int NDECL(doorganize); @@ -1497,6 +1501,11 @@ E int FDECL(fruitadd, (char *)); E int FDECL(choose_classes_menu, (const char *,int,BOOLEAN_P,char *,char *)); E void FDECL(add_menu_cmd_alias, (CHAR_P, CHAR_P)); E char FDECL(map_menu_cmd, (CHAR_P)); +#ifdef PREADJUST +E boolean FDECL(collect_preadjust, (char *)); +E void NDECL(apply_preadjust); +E void NDECL(cleanup_preadjust); +#endif /* PREADJUST */ E void FDECL(assign_warnings, (uchar *)); E char *FDECL(nh_getenv, (const char *)); E void FDECL(set_duplicate_opt_detection, (int)); diff -pruN slashem-0.0.7E7F1-official-release/src/allmain.c slashem-0.0.7E7F1-preadjust/src/allmain.c --- slashem-0.0.7E7F1-official-release/src/allmain.c 2005-07-02 09:24:44.000000000 +0200 +++ slashem-0.0.7E7F1-preadjust/src/allmain.c 2005-10-27 23:01:00.000000000 +0200 @@ -562,6 +562,10 @@ newgame() init_artifacts(); /* before u_init() in case $WIZKIT specifies * any artifacts */ u_init(); +#ifdef PREADJUST + apply_preadjust(); + cleanup_preadjust(); +#endif /* PREADJUST */ init_artifacts1(); /* must be after u_init() */ #ifndef NO_SIGNAL diff -pruN slashem-0.0.7E7F1-official-release/src/files.c slashem-0.0.7E7F1-preadjust/src/files.c --- slashem-0.0.7E7F1-official-release/src/files.c 2005-07-02 09:24:44.000000000 +0200 +++ slashem-0.0.7E7F1-preadjust/src/files.c 2005-10-27 22:59:59.000000000 +0200 @@ -2045,6 +2045,11 @@ char *tmp_levels; (void) get_uchars(fp, buf, bufp, translate, TRUE, WARNCOUNT, "WARNINGS"); assign_warnings(translate); +#ifdef PREADJUST + } else if (match_varname(buf, "PREADJUST", 6)) { + if (!collect_preadjust(bufp)) + return 0; +#endif /* PREADJUST */ #ifdef WIZARD } else if (match_varname(buf, "WIZKIT", 6)) { (void) strncpy(wizkit, bufp, WIZKIT_MAX-1); diff -pruN slashem-0.0.7E7F1-official-release/src/invent.c slashem-0.0.7E7F1-preadjust/src/invent.c --- slashem-0.0.7E7F1-official-release/src/invent.c 2005-07-02 09:24:44.000000000 +0200 +++ slashem-0.0.7E7F1-preadjust/src/invent.c 2005-10-27 22:59:59.000000000 +0200 @@ -2944,7 +2944,9 @@ doorganize() /* inventory organizer by D char alphabet[52+1], buf[52+1]; char qbuf[QBUFSZ]; char allowall[2]; +#ifndef PREADJUST const char *adj_type; +#endif /* PREADJUST */ if (!flags.invlet_constant) reassign(); /* get a pointer to the object the user wants to organize */ @@ -2987,7 +2989,22 @@ doorganize() /* inventory organizer by D } /* change the inventory and print the resulting item */ +#ifndef PREADJUST adj_type = "Moving:"; +#else + doorganize_guts(obj, let, FALSE); + return(0); +} + +void +doorganize_guts(obj, let, quiet) +struct obj *obj; +char let; +boolean quiet; +{ + struct obj *otmp; + const char *adj_type = "Moving:"; +#endif /* PREADJUST */ /* * don't use freeinv/addinv to avoid double-touching artifacts, @@ -3016,9 +3033,14 @@ doorganize() /* inventory organizer by D invent = obj; reorder_invent(); +#ifdef PREADJUST + if (!quiet) +#endif /* PREADJUST */ prinv(adj_type, obj, 0L); update_inventory(); +#ifndef PREADJUST return(0); +#endif /* PREADJUST */ } /* common to display_minventory and display_cinventory */ diff -pruN slashem-0.0.7E7F1-official-release/src/options.c slashem-0.0.7E7F1-preadjust/src/options.c --- slashem-0.0.7E7F1-official-release/src/options.c 2005-07-02 09:24:44.000000000 +0200 +++ slashem-0.0.7E7F1-preadjust/src/options.c 2005-10-27 22:59:59.000000000 +0200 @@ -482,6 +482,22 @@ static const menu_cmd_t default_menu_cmd static char mapped_menu_op[MAX_MENU_MAPPED_CMDS+1]; static short n_menu_mapped = 0; +#ifdef PREADJUST +/* Stuff for doing starting inventory pre-#adjusts. */ +typedef struct { + const char *descr; +# ifdef STICKY_OBJECTS + boolean sticky; +# endif /* STICKY_OBJECTS */ + char invlet; +} preadjust; + +static preadjust *preadj_list = 0; +static int n_preadjust = 0; +static int preadjust_size = 0; +#endif /* PREADJUST */ + + static boolean initial, from_file; STATIC_DCL void FDECL(doset_add_menu, (winid,const char *,int)); @@ -2806,6 +2822,84 @@ map_menu_cmd(ch) } +#ifdef PREADJUST +boolean +collect_preadjust(bufp) +char *bufp; +{ + preadjust adj; + + if (!*bufp) + return 0; + adj.invlet = *bufp++; + if (*bufp != '-' +# ifdef STICKY_OBJECTS + && *bufp != '=' +# endif /* STICKY_OBJECTS */ + ) + return 0; +# ifdef STICKY_OBJECTS + adj.sticky = (*bufp == '='); +# endif /* STICKY_OBJECTS */ + bufp++; + if (!*bufp) + return 0; + adj.descr = (char *)strdup(bufp); + + /* allocate additional space if necessary */ + if (preadjust_size == 0) { + preadjust_size = 10; + preadj_list = (preadjust *)alloc(10 * sizeof(preadjust)); + } else if (n_preadjust == preadjust_size) { + preadjust *tmp; + preadjust_size *= 2; + tmp = (preadjust *)alloc(preadjust_size * sizeof(preadjust)); + (void)memcpy((genericptr_t)tmp, (genericptr_t)preadj_list, + n_preadjust * sizeof(preadjust)); + free((genericptr_t)preadj_list); + preadj_list = tmp; + } + + preadj_list[n_preadjust++] = adj; + return 1; +} + +void +apply_preadjust() +{ + int i; + struct obj *obj; + + if (n_preadjust == 0) + return; + /* this is kind of expensive, I suppose, but it only happens once */ + for (i = 0; i < n_preadjust; i++) { + for (obj = invent; obj; obj = obj->nobj) { + if (strstri(OBJ_NAME(objects[obj->otyp]), preadj_list[i].descr)) { +# ifdef STICKY_OBJECTS + obj->sticky = preadj_list[i].sticky; +# endif /* STICKY_OBJECTS */ + doorganize_guts(obj, preadj_list[i].invlet, TRUE); + break; + } + } + } +} + +void +cleanup_preadjust() +{ + int i; + + if (n_preadjust == 0) + return; + for (i = 0; i < n_preadjust; i++) + free((genericptr_t)preadj_list[i].descr); + free((genericptr_t)preadj_list); +} +#endif /* PREADJUST */ + + #if defined(MICRO) || defined(MAC) || defined(WIN32) # define OPTIONS_HEADING "OPTIONS" #else diff -pruN slashem-0.0.7E7F1-official-release/src/restore.c slashem-0.0.7E7F1-preadjust/src/restore.c --- slashem-0.0.7E7F1-official-release/src/restore.c 2005-07-02 09:24:44.000000000 +0200 +++ slashem-0.0.7E7F1-preadjust/src/restore.c 2005-10-27 22:59:59.000000000 +0200 @@ -713,6 +713,9 @@ register int fd; run_timers(); /* expire all timers that have gone off while away */ docrt(); restoring = FALSE; +#ifdef PREADJUST + cleanup_preadjust(); /* we're now certain we don't need this */ +#endif /* PREADJUST */ clear_nhwindow(WIN_MESSAGE); program_state.something_worth_saving++; /* useful data now exists */