'sortloot' revamp

Change the sortloot option to use qsort() instead of naive insertion
sort.  After sorting, it reorders the linked list into the sorted
order, so might have some subtle change(s) in behavior since that
wasn't done before.

pickup.c includes some formatting cleanup.

modified:
  include/extern.h, hack.h, obj.h
  src/do.c, do_wear.c, end.c, invent.c, pickup.c
This commit is contained in:
PatR
2016-03-13 16:23:38 -07:00
parent b89e0a832f
commit b3b4953020
8 changed files with 278 additions and 219 deletions

View File

@@ -891,8 +891,7 @@ E int NDECL(midnight);
/* ### invent.c ### */
E struct obj **FDECL(objarr_init, (int));
E void FDECL(objarr_set, (struct obj *, int, struct obj **, BOOLEAN_P));
E void FDECL(sortloot, (struct obj **, unsigned, BOOLEAN_P));
E void FDECL(assigninvlet, (struct obj *));
E struct obj *FDECL(merge_choice, (struct obj *, struct obj *));
E int FDECL(merged, (struct obj **, struct obj **));
@@ -1755,10 +1754,10 @@ E int FDECL(out_container, (struct obj *));
#endif
E int FDECL(pickup, (int));
E int FDECL(pickup_object, (struct obj *, long, BOOLEAN_P));
E int FDECL(query_category,
(const char *, struct obj *, int, menu_item **, int));
E int FDECL(query_objlist, (const char *, struct obj *, int, menu_item **,
int, boolean (*)(OBJ_P)));
E int FDECL(query_category, (const char *, struct obj *, int,
menu_item **, int));
E int FDECL(query_objlist, (const char *, struct obj **, int,
menu_item **, int, boolean (*)(OBJ_P)));
E struct obj *FDECL(pick_obj, (struct obj *));
E int NDECL(encumber_msg);
E int NDECL(doloot);

View File

@@ -318,8 +318,13 @@ NEARDATA extern coord bhitpos; /* place where throw or zap hits or stops */
#define BASICENLIGHTENMENT 1 /* show mundane stuff */
#define MAGICENLIGHTENMENT 2 /* show intrinsics and such */
#define ENL_GAMEINPROGRESS 0
#define ENL_GAMEOVERALIVE 1 /* ascension, escape, quit, trickery */
#define ENL_GAMEOVERDEAD 2
#define ENL_GAMEOVERALIVE 1 /* ascension, escape, quit, trickery */
#define ENL_GAMEOVERDEAD 2
/* control flags for sortloot() */
#define SORTLOOT_PACK 0x01
#define SORTLOOT_INVLET 0x02
#define SORTLOOT_LOOT 0x04
/* Macros for messages referring to hands, eyes, feet, etc... */
#define ARM 0

View File

@@ -40,12 +40,13 @@ struct obj {
unsigned owt;
long quan; /* number of items */
schar spe; /* quality of weapon, armor or ring (+ or -)
number of charges for wand ( >= -1 )
marks your eggs, tin variety and spinach tins
royal coffers for a court ( == 2)
tells which fruit a fruit is
special for uball and amulet
schar spe; /* quality of weapon, armor or ring (+ or -);
number of charges for wand or charged tool ( >= -1 );
marks your eggs, tin variety and spinach tins;
Schroedinger's Box (1) or royal coffers for a court (2);
tells which fruit a fruit is;
special for uball and amulet;
scroll of mail (normal==0, bones or wishing==1, written==2);
historic and gender for statues */
#define STATUE_HISTORIC 0x01
#define STATUE_MALE 0x02