Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 Adelie 8/14/85; site adelie.UUCP Path: utzoo!watmath!clyde!burl!ulysses!gamma!epsilon!zeta!sabre!petrus!bellcore!decvax!decwrl!pyramid!ut-sally!topaz!harvard!adelie!barry From: barry@adelie.UUCP (Barry A. Burke) Newsgroups: net.games.hack Subject: Sorted Inventory List for 1.0.3 (UN*X Version) Message-ID: <570@adelie.UUCP> Date: Mon, 13-Jan-86 22:24:17 EST Article-I.D.: adelie.570 Posted: Mon Jan 13 22:24:17 1986 Date-Received: Wed, 15-Jan-86 08:16:04 EST Reply-To: barry@adelie.UUCP (Barry A. Burke) Distribution: net Organization: Adelie Corporation, Newtonville MA Lines: 390 Summary: User defined sort order via HACKOPTIONS ough for login name .99 */ boolean in_mklev, restoring; --- 5,11 ----- char nul[40]; /* contains zeros */ char plname[PL_NSIZ]; /* player name */ char lock[PL_NSIZ+4] = "1lock"; /* long enough for login name .99 */ + char sortlist[SOBJLEN+1]; /* sort order for inventory list */ boolean in_mklev, restoring; *** hack.invent.c.old Tue Dec 31 15:48:32 1985 --- hack.invent.c Mon Jan 6 22:54:27 1986 *************** *** 43,48 (i < 26) ? ('a'+i) : ('A'+i-26)); lastinvnr = i; } struct obj * addinv(obj) --- 43,50 ----- (i < 26) ? ('a'+i) : ('A'+i-26)); lastinvnr = i; } + /* Barry A. Burke modified addinv() Jan 6, 1985 to + sort the inventory list by type. */ struct obj * addinv(obj) *************** *** 49,54 register struct obj *obj; { register struct obj *otmp; /* merge or attach to end of chain */ if(!invent) { --- 51,58 ----- register struct obj *obj; { register struct obj *otmp; + int i; + extern char sortlist[]; /* merge or attach to end of chain */ if(!invent) { *************** *** 65,91 } obj->nobj = 0; ! if(flags.invlet_constant) { ! assigninvlet(obj); ! /* ! * The ordering of the chain is nowhere significant ! * so in case you prefer some other order than the ! * historical one, change the code below. ! */ ! if(otmp) { /* find proper place in chain */ ! otmp->nobj = 0; ! if((invent->invlet ^ 040) > (obj->invlet ^ 040)) { ! obj->nobj = invent; ! invent = obj; ! } else ! for(otmp = invent; ; otmp = otmp->nobj) { ! if(!otmp->nobj || ! (otmp->nobj->invlet ^ 040) > (obj->invlet ^ 040)){ ! obj->nobj = otmp->nobj; ! otmp->nobj = obj; ! break; ! } ! } } } --- 69,95 ----- } obj->nobj = 0; ! if(flags.invlet_constant) ! assigninvlet(obj); /* gotta have a letter assigned! */ ! ! /* Now, let's sort the new object into the list by object type. */ ! i = (int) (index(sortlist, obj->olet) - sortlist); ! if ( i <= 0 ) ! i = 100; ! ! if(otmp) { /* find proper place in chain */ ! otmp->nobj = 0; ! if ( i < (int) (index(sortlist, invent->olet) - sortlist)) { ! obj->nobj = invent; ! invent = obj; ! } else ! for(otmp = invent; ; otmp = otmp->nobj) { ! if(!otmp->nobj || ! (i<(int)(index(sortlist,otmp->nobj->olet)-sortlist))) { ! obj->nobj = otmp->nobj; ! otmp->nobj = obj; ! break; ! } } } *** hack.options.c.orig Mon Dec 23 11:40:24 1985 --- hack.options.c Wed Jan 8 14:23:38 1986 *************** *** 5,10 #include "hack.h" extern char *eos(); initoptions() { register char *opts; --- 5,12 ----- #include "hack.h" extern char *eos(); + extern char sortlist[]; + initoptions() { register char *opts; *************** *** 17,22 flags.end_top = 5; flags.end_around = 4; flags.female = FALSE; /* players are usually male */ if(opts = getenv("HACKOPTIONS")) parseoptions(opts,TRUE); --- 19,26 ----- flags.end_top = 5; flags.end_around = 4; flags.female = FALSE; /* players are usually male */ + (void) strcpy( sortlist, "$" ); /* gotta seed it for `index' */ + (void) strncat( sortlist, SORTOBJ, strlen(SORTOBJ) ); if(opts = getenv("HACKOPTIONS")) parseoptions(opts,TRUE); *************** *** 107,112 return; } /* endgame:5t[op] 5a[round] o[wn] */ if(!strncmp(opts,"endgame",3)) { op = index(opts,':'); --- 111,129 ----- return; } + /* sortobj:string */ + if(!strncmp(opts,"sortobj",4)) { + if(!from_env) { + pline("The inventory sort list can be set only from HACKOPTIONS."); + return; + } + op = index(opts,':'); + if(!op) goto bad; + (void) strcpy(sortlist, "$"); /* Need an offset of 1 */ + (void) strncat(sortlist, op+1, SOBJLEN-1); + return; + } + /* endgame:5t[op] 5a[round] o[wn] */ if(!strncmp(opts,"endgame",3)) { op = index(opts,':'); *************** *** 145,151 if(!strncmp(opts, "help", 4)) { pline("%s%s%s", "To set options use `HACKOPTIONS=\"\"' in your environment, or ", ! "give the command 'o' followed by the line `' while playing. ", "Here is a list of