diff --git a/include/hack.h b/include/hack.h index 9ed519431..69645f086 100644 --- a/include/hack.h +++ b/include/hack.h @@ -548,6 +548,18 @@ enum hunger_state_types { STARVED = 6 }; +/* inventory counts (slots in tty parlance) + * a...zA..Z invlet_basic (52) + * $a...zA..Z# 2 special additions + */ +enum inventory_counts { + invlet_basic = 52, + invlet_gold = 1, + invlet_overflow = 1, + invlet_max = invlet_basic + invlet_gold + invlet_overflow, + /* 2023/11/30 invlet_max is not yet used anywhere */ +}; + struct kinfo { struct kinfo *next; /* chain of delayed killers */ int id; /* uprop keys to ID a delayed killer */ diff --git a/src/eat.c b/src/eat.c index a400dbd9e..8587b0338 100644 --- a/src/eat.c +++ b/src/eat.c @@ -361,7 +361,7 @@ touchfood(struct obj *otmp) if (carried(otmp)) { freeinv(otmp); - if (inv_cnt(FALSE) >= 52) { + if (inv_cnt(FALSE) >= invlet_basic) { sellobj_state(SELL_DONTSELL); dropy(otmp); sellobj_state(SELL_NORMAL); diff --git a/src/files.c b/src/files.c index fcfaceffe..0b256ca90 100644 --- a/src/files.c +++ b/src/files.c @@ -3887,7 +3887,7 @@ wizkit_addinv(struct obj *obj) if (Role_if(PM_CLERIC)) obj->bknown = 1; /* ok to bypass set_bknown() */ /* same criteria as lift_object()'s check for available inventory slot */ - if (obj->oclass != COIN_CLASS && inv_cnt(FALSE) >= 52 + if (obj->oclass != COIN_CLASS && inv_cnt(FALSE) >= invlet_basic && !merge_choice(gi.invent, obj)) { /* inventory overflow; can't just place & stack object since hero isn't in position yet, so schedule for arrival later */ diff --git a/src/hack.c b/src/hack.c index 6eb1101ab..4b9bc0c6c 100644 --- a/src/hack.c +++ b/src/hack.c @@ -499,7 +499,8 @@ moverock(void) pick up a boulder if you have a free slot or into the overflow ('#') slot unless already carrying at least one */ - && (inv_cnt(FALSE) < 52 || !carrying(BOULDER))), + && (inv_cnt(FALSE) < invlet_basic + || !carrying(BOULDER))), willpickup = (canpickup && (flags.pickup && !gc.context.nopick) && autopick_testobj(otmp, TRUE)); diff --git a/src/invent.c b/src/invent.c index ceca0936d..6306488a9 100644 --- a/src/invent.c +++ b/src/invent.c @@ -401,8 +401,8 @@ invletter_value(char c) return ('a' <= c && c <= 'z') ? (c - 'a' + 2) : ('A' <= c && c <= 'Z') ? (c - 'A' + 2 + 26) : (c == '$') ? 1 - : (c == '#') ? 1 + 52 + 1 - : 1 + 52 + 1 + 1; /* none of the above (shouldn't happen) */ + : (c == '#') ? 1 + invlet_basic + 1 + : 1 + invlet_basic + 1 + 1; /* none of the above (shouldn't happen) */ } /* qsort comparison routine for sortloot() */ @@ -700,7 +700,7 @@ sortloot( void assigninvlet(struct obj *otmp) { - boolean inuse[52]; + boolean inuse[invlet_basic]; register int i; register struct obj *obj; @@ -710,7 +710,7 @@ assigninvlet(struct obj *otmp) return; } - for (i = 0; i < 52; i++) + for (i = 0; i < invlet_basic; i++) inuse[i] = FALSE; for (obj = gi.invent; obj; obj = obj->nobj) if (obj != otmp) { @@ -726,7 +726,7 @@ assigninvlet(struct obj *otmp) && (('a' <= i && i <= 'z') || ('A' <= i && i <= 'Z'))) return; for (i = gl.lastinvnr + 1; i != gl.lastinvnr; i++) { - if (i == 52) { + if (i == invlet_basic) { i = -1; continue; } @@ -1242,8 +1242,9 @@ hold_another_object( drop_arg = strcpy(buf, drop_arg); obj = addinv_core0(obj, (struct obj *) 0, FALSE); - if (inv_cnt(FALSE) > 52 || ((obj->otyp != LOADSTONE || !obj->cursed) - && near_capacity() > prev_encumbr)) { + if (inv_cnt(FALSE) > invlet_basic + || ((obj->otyp != LOADSTONE || !obj->cursed) + && near_capacity() > prev_encumbr)) { /* undo any merge which took place */ if (obj->quan > oquan) obj = splitobj(obj, oquan); @@ -5108,7 +5109,7 @@ doprtool(void) { struct obj *otmp; int ct = 0; - char lets[52 + 1]; + char lets[invlet_basic + 1]; for (otmp = gi.invent; otmp; otmp = otmp->nobj) if (tool_being_used(otmp)) { @@ -5464,8 +5465,8 @@ doorganize_core(struct obj *obj) char let; #define GOLD_INDX 0 #define GOLD_OFFSET 1 -#define OVRFLW_INDX (GOLD_OFFSET + 52) /* past gold and 2*26 letters */ - char lets[1 + 52 + 1 + 1]; /* room for '$a-zA-Z#\0' */ +#define OVRFLW_INDX (GOLD_OFFSET + invlet_basic) /* past gold & 2*26 letters */ + char lets[1 + invlet_basic + 1 + 1]; /* room for '$a-zA-Z#\0' */ char qbuf[QBUFSZ]; char *objname, *otmpname; const char *adj_type; @@ -5498,7 +5499,7 @@ doorganize_core(struct obj *obj) lets[OVRFLW_INDX] = ' '; lets[sizeof lets - 1] = '\0'; /* for floating inv letters, truncate list after the first open slot */ - if (!flags.invlet_constant && (ix = inv_cnt(FALSE)) < 52) + if (!flags.invlet_constant && (ix = inv_cnt(FALSE)) < invlet_basic) lets[ix + (splitting ? 1 : 2)] = '\0'; /* blank out all the letters currently in use in the inventory @@ -5624,7 +5625,7 @@ doorganize_core(struct obj *obj) adj_type = "Splitting and merging:"; obj = otmp; extract_nobj(obj, &gi.invent); - } else if (inv_cnt(FALSE) >= 52) { + } else if (inv_cnt(FALSE) >= invlet_basic) { (void) merged(&splitting, &obj); /* undo split */ /* "knapsack cannot accommodate any more items" */ Your("pack is too full."); diff --git a/src/pickup.c b/src/pickup.c index 04bd13277..1f96bff7d 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -1638,7 +1638,7 @@ lift_object( availability of open inventory slot iff not already carrying one */ if (obj->otyp == LOADSTONE || (obj->otyp == BOULDER && throws_rocks(gy.youmonst.data))) { - if (inv_cnt(FALSE) < 52 || !carrying(obj->otyp) + if (inv_cnt(FALSE) < invlet_basic || !carrying(obj->otyp) || merge_choice(gi.invent, obj)) return 1; /* lift regardless of current situation */ /* if we reach here, we're out of slots and already have at least @@ -1655,7 +1655,8 @@ lift_object( } else if (obj->oclass != COIN_CLASS /* [exception for gold coins will have to change if silver/copper ones ever get implemented] */ - && inv_cnt(FALSE) >= 52 && !merge_choice(gi.invent, obj)) { + && inv_cnt(FALSE) >= invlet_basic + && !merge_choice(gi.invent, obj)) { /* if there is some gold here (and we haven't already skipped it), we aren't limited by the 52 item limit for it, but caller and "grandcaller" aren't prepared to skip stuff and then pickup diff --git a/src/shk.c b/src/shk.c index bfa03aa40..07c778050 100644 --- a/src/shk.c +++ b/src/shk.c @@ -151,7 +151,8 @@ money2u(struct monst* mon, long amount) mongold = splitobj(mongold, amount); obj_extract_self(mongold); - if (!merge_choice(gi.invent, mongold) && inv_cnt(FALSE) >= 52) { + if (!merge_choice(gi.invent, mongold) + && inv_cnt(FALSE) >= invlet_basic) { You("have no room for the gold!"); dropy(mongold); } else { diff --git a/src/uhitm.c b/src/uhitm.c index 5180f4084..8e290b0d3 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -2683,7 +2683,8 @@ mhitm_ad_sgld( if (mongold) { obj_extract_self(mongold); - if (merge_choice(gi.invent, mongold) || inv_cnt(FALSE) < 52) { + if (merge_choice(gi.invent, mongold) + || inv_cnt(FALSE) < invlet_basic) { addinv(mongold); Your("purse feels heavier."); } else { diff --git a/src/wield.c b/src/wield.c index bf5441b75..4e127391d 100644 --- a/src/wield.c +++ b/src/wield.c @@ -390,7 +390,8 @@ dowield(void) return doswapweapon(); } else if (wep == uquiver) { /* offer to split stack if multiple are quivered */ - if (uquiver->quan > 1L && inv_cnt(FALSE) < 52 && splittable(uquiver)) { + if (uquiver->quan > 1L && inv_cnt(FALSE) < invlet_basic + && splittable(uquiver)) { Sprintf(qbuf, "You have %ld %s readied. Wield one?", uquiver->quan, simpleonames(uquiver)); switch (ynq(qbuf)) { @@ -556,7 +557,8 @@ doquiver_core(const char *verb) /* "ready" or "fire" */ return weld_res ? ECMD_TIME : ECMD_OK; } /* offer to split stack if wielding more than 1 */ - if (uwep->quan > 1L && inv_cnt(FALSE) < 52 && splittable(uwep)) { + if (uwep->quan > 1L && inv_cnt(FALSE) < invlet_basic + && splittable(uwep)) { Sprintf(qbuf, "You are wielding %ld %s. Ready %ld of them?", uwep->quan, simpleonames(uwep), uwep->quan - 1L); switch (ynq(qbuf)) { @@ -590,7 +592,7 @@ doquiver_core(const char *verb) /* "ready" or "fire" */ untwoweapon(); was_uwep = TRUE; } else if (newquiver == uswapwep) { - if (uswapwep->quan > 1L && inv_cnt(FALSE) < 52 + if (uswapwep->quan > 1L && inv_cnt(FALSE) < invlet_basic && splittable(uswapwep)) { Sprintf(qbuf, "%s %ld %s. Ready %ld of them?", u.twoweap ? "You are dual wielding" diff --git a/src/zap.c b/src/zap.c index b5e9d9e19..fbe786802 100644 --- a/src/zap.c +++ b/src/zap.c @@ -5636,7 +5636,7 @@ destroy_item(int osym, int dmgtyp) int i, deferral_indx = 0; /* 1+52+1: try to handle a full inventory; it doesn't matter if inventory actually has more, even if everything should be deferred */ - unsigned short deferrals[1 + 52 + 1]; /* +1: gold, overflow */ + unsigned short deferrals[invlet_gold + invlet_basic + invlet_overflow]; (void) memset((genericptr_t) deferrals, 0, sizeof deferrals); /* diff --git a/win/curses/cursinit.c b/win/curses/cursinit.c index ff0b240fa..59ccbc1c0 100644 --- a/win/curses/cursinit.c +++ b/win/curses/cursinit.c @@ -683,7 +683,7 @@ int curses_character_dialog(const char **choices, const char *prompt) { int count, count2, ret, curletter; - char used_letters[52]; + char used_letters[invlet_basic]; /* a..zA..Z */ anything identifier; menu_item *selected = NULL; winid wid = curses_get_wid(NHW_MENU); diff --git a/win/tty/wintty.c b/win/tty/wintty.c index 0412f25de..45be4c595 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -261,8 +261,7 @@ static int bordercol[border_elements] = { 0, 0, 0 }; /* left, middle, right */ static int ttyinvmode = InvNormal; /* enum is in wintype.h */ static int inuse_only_start = 0; /* next slot to use for in-use-only mode */ static boolean done_tty_perm_invent_init = FALSE; -enum { tty_slots = 1 + 52 + 1 }; /* 54 [0..53]: for !show_gold a..zA..Z with - * 2 unused, or for 'show_gold' $a..zA..Z# */ +enum { tty_slots = invlet_basic + inv_special_slotcount }; /* 52 + 2 */ static boolean slot_tracker[tty_slots]; static long last_glyph_reset_when; #ifndef NOINVSYM /* invent.c */