From: <gi...@cr...> - 2025-07-19 12:00:10
|
via 1d9b2a2d9d895fd0744b551bb47ea7c2468f2956 (commit) via 8052acedeece4ce4b9f96075280769d7f12da915 (commit) via 302e0d9ae39a3834cfaac2822f80506c3e2298b9 (commit) via 5969bbf2d0e1da04c89e953bd2301b8a1d9a3522 (commit) via 820aee5b568a1f944c9c347b322248cacbaa2212 (commit) from bd44c153c20f292a9553762e1000ff4a829e58c6 (commit) ----------------------------------------------------------------------- commit 1d9b2a2d9d895fd0744b551bb47ea7c2468f2956 Author: DracoOmega <dra...@gm...> Date: Sat Jul 19 09:28:25 2025 -0230 Don't prevent page up/down from working normally in drop menu. Yes, this makes < and > no longer swap pages (as had been requested), but I think interfering with pgup/pgdown is a worse sin. commit 8052acedeece4ce4b9f96075280769d7f12da915 Author: DracoOmega <dra...@gm...> Date: Sat Jul 19 09:25:32 2025 -0230 Fix a rare Nobody / shadow mimic crash (DewdropsOTG) If you brought Nobody to 0 HP, triggered Pyrric Recollection, rolled for a Dith shadow melee followup, and Nobody landed somewhere still in melee range of your shadow, the attack would crash (since Nobody still looked 'dead') Rather than check for this in shadow mimic specifically, I think it may be better to change the behavior of this assert (since there are several other things that can trigger it, and probably will be more in future). Now, attempting to attack a mid-revival monster just does nothing (but still takes time). It's perfectly valid for those to be on the grid, so this isn't really a 'bug', per se, and doesn't need to crash. This fixes #4668 commit 302e0d9ae39a3834cfaac2822f80506c3e2298b9 Author: DracoOmega <dra...@gm...> Date: Sat Jul 19 08:47:50 2025 -0230 Fix drop menu not sorting properly (Ogregutan) Apparently it was only using the default sort conditions at all because its type wasn't yet set to 'drop menu' until after items were added and sorted. This stopped being the case in 1ca2ae5. (But this also means that the sort_menu option for drop menus likely never worked properly before now, either.) commit 5969bbf2d0e1da04c89e953bd2301b8a1d9a3522 Author: DracoOmega <dra...@gm...> Date: Sat Jul 19 08:45:01 2025 -0230 Fix drop menu defaulting to wrong page sometimes If the player had zero items of a given inventory category (ie: gear, potions, scrolls, evocables), cycling through each page at start would land on something other then gear (since cycling skips empty pages.) Instead, view each page manually, to make sure we end up at the same default every time. commit 820aee5b568a1f944c9c347b322248cacbaa2212 Author: DracoOmega <dra...@gm...> Date: Sat Jul 19 08:43:13 2025 -0230 Fix misleading warning prompts when changing gear letters (DewdropsOTG) Adjusting the letter of 'dangerous' gear in your inventory would prompt you as if you were about to equip or unequip them. ----------------------------------------------------------------------- Summary of changes: crawl-ref/docs/options_guide.txt | 3 +- crawl-ref/source/adjust.cc | 20 ++++++-------- crawl-ref/source/adjust.h | 4 +-- crawl-ref/source/describe.cc | 2 +- crawl-ref/source/fight.cc | 17 ++++++++++-- crawl-ref/source/initfile.cc | 1 + crawl-ref/source/invent.cc | 59 ++++++++++++++++++++++++---------------- crawl-ref/source/invent.h | 1 + 8 files changed, 67 insertions(+), 40 deletions(-) diff --git a/crawl-ref/docs/options_guide.txt b/crawl-ref/docs/options_guide.txt index debe155740..c6dd582d13 100644 --- a/crawl-ref/docs/options_guide.txt +++ b/crawl-ref/docs/options_guide.txt @@ -1369,7 +1369,8 @@ sort_menus = [menu:](true | false | auto:X)[:sort_order] By default pickup menus are sorted, and the sort criteria are: "equipped, basename, qualname, curse, qty". - Inv menus are sorted by "equipped, charged, usefulness". + Inv and drop menus are sorted by "equipped, charged, identified, + usefulness, slot". spell_slot ^= <regex>:<list of spell letters> (Ordered list option, one value per line) diff --git a/crawl-ref/source/adjust.cc b/crawl-ref/source/adjust.cc index 6b748ec52e..8db16402ab 100644 --- a/crawl-ref/source/adjust.cc +++ b/crawl-ref/source/adjust.cc @@ -29,13 +29,13 @@ void adjust() const int keyin = toalower(get_ch()); if (keyin == 'g') - adjust_item(OPER_EQUIP); + adjust_item(OSEL_GEAR); else if (keyin == 'p') - adjust_item(OPER_QUAFF); + adjust_item(OBJ_POTIONS); else if (keyin == 'r') - adjust_item(OPER_READ); + adjust_item(OBJ_SCROLLS); else if (keyin == 'v') - adjust_item(OPER_EVOKE); + adjust_item(OSEL_EVOKABLE); else if (keyin == 's') _adjust_spell(); else if (keyin == 'a') @@ -46,7 +46,7 @@ void adjust() canned_msg(MSG_HUH); } -void adjust_item(operation_types oper, item_def* to_adjust) +void adjust_item(int selector, item_def* to_adjust) { #ifdef USE_TILE_WEB ui::cutoff_point ui_cutoff_point; @@ -61,17 +61,15 @@ void adjust_item(operation_types oper, item_def* to_adjust) if (to_adjust) { if (inventory_category_for(*to_adjust) == INVENT_CONSUMABLE) - oper = item_to_oper(to_adjust); + selector = default_osel(item_to_oper(to_adjust)); else - oper = OPER_EQUIP; + selector = OSEL_GEAR; } if (!to_adjust) { - int sel = oper == OPER_EQUIP ? OSEL_GEAR : default_osel(oper); - const int from_slot = prompt_invent_item("Adjust which item?", - menu_type::invlist, sel, oper); + menu_type::invlist, selector, OPER_ANY); if (prompt_failed(from_slot)) return; @@ -82,7 +80,7 @@ void adjust_item(operation_types oper, item_def* to_adjust) const int to_slot = prompt_invent_item("Adjust to which letter? ", menu_type::invlist, - default_osel(oper), oper, + selector, OPER_ANY, invprompt_flag::unthings_ok | invprompt_flag::manual_list); if (to_slot == PROMPT_ABORT diff --git a/crawl-ref/source/adjust.h b/crawl-ref/source/adjust.h index 90df87bdf6..21ebc687ca 100644 --- a/crawl-ref/source/adjust.h +++ b/crawl-ref/source/adjust.h @@ -5,10 +5,10 @@ #pragma once -#include "operation-types.h" +#include "object-selector-type.h" struct item_def; void adjust(); -void adjust_item(operation_types oper = OPER_ANY, item_def* to_adjust = nullptr); +void adjust_item(int selector = OSEL_ANY, item_def* to_adjust = nullptr); void swap_inv_slots(item_def& to_adjust, int new_letter, bool verbose); diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc index 1c0784550c..1094894d5c 100644 --- a/crawl-ref/source/describe.cc +++ b/crawl-ref/source/describe.cc @@ -4009,7 +4009,7 @@ static bool _do_action(item_def &item, const command_type action) return true; drop_item(slot, item.quantity); break; - case CMD_ADJUST_INVENTORY: adjust_item(OPER_ANY, &you.inv[slot]); + case CMD_ADJUST_INVENTORY: adjust_item(0, &you.inv[slot]); break; case CMD_EVOKE: if (!check_warning_inscriptions(you.inv[slot], OPER_EVOKE)) diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index aa18293e87..5c134f0208 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -430,8 +430,21 @@ bool fight_melee(actor *attacker, actor *defender, bool *did_hit, bool simu) ASSERT(defender); // XXX: change to actor &defender // A dead defender would result in us returning true without actually - // taking an action. - ASSERT(defender->alive()); + // taking an action. But allow just passing our turn if we try to attack a + // monster mid-revival (since they're still actually supposed to be there). + if (!defender->alive()) + { + if (defender->is_monster() + && (defender->as_monster()->flags & MF_PENDING_REVIVAL)) + { + return true; + } + else + { + die("%s trying to attack a dead %s", attacker->name(DESC_THE).c_str(), + defender->name(DESC_THE).c_str()); + } + } if (defender->is_player()) { diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index 1eb04127bf..01ddf0d76e 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -3418,6 +3418,7 @@ void game_options::set_menu_sort(const string &field) sort_menus.clear(); set_menu_sort("pickup: true"); set_menu_sort("inv: true : equipped, charged, identified, usefulness, slot"); + set_menu_sort("drop: true : equipped, charged, identified, usefulness, slot"); return; } diff --git a/crawl-ref/source/invent.cc b/crawl-ref/source/invent.cc index 895e638bb9..0b5db0ab03 100644 --- a/crawl-ref/source/invent.cc +++ b/crawl-ref/source/invent.cc @@ -400,26 +400,42 @@ int InvMenu::pre_process(int key) return key; } +const static int modes[] = +{ + OSEL_GEAR, + OBJ_POTIONS, + OBJ_SCROLLS, + OSEL_EVOKABLE, +}; + void InvMenu::cycle_page(int dir) { + do + { + int new_osel = cur_osel; + new_osel += dir; + if (new_osel < 0) + new_osel = ARRAYSZ(modes) - 1; + if (new_osel >= static_cast<int>(ARRAYSZ(modes))) + new_osel = 0; + + set_page(new_osel); + } + // If this page is empty, go to the next one. + // XXX: (Theoretically, this could cause an infinite loop, but other code + // should already prevent opening a menu when you have no items.) + while (items.empty()); +} + +void InvMenu::set_page(int page) +{ + ASSERT(page >= 0 && page < static_cast<int>(ARRAYSZ(modes))); + if (!(flags & MF_PAGED_INVENTORY)) return; - const static int modes[] = - { - OSEL_GEAR, - OBJ_POTIONS, - OBJ_SCROLLS, - OSEL_EVOKABLE, - }; - - // Determine new page const int old_osel = cur_osel; - cur_osel += dir; - if (cur_osel < 0) - cur_osel = ARRAYSZ(modes) - 1; - if (cur_osel >= static_cast<int>(ARRAYSZ(modes))) - cur_osel = 0; + cur_osel = page; // Save selected items from our current page get_selected(&sel); @@ -433,12 +449,6 @@ void InvMenu::cycle_page(int dir) reset(); update_menu(true); - // If this page is empty, go to the next one. - // XXX: (Theoretically, this could cause an infinite loop, but other code - // should already prevent opening a menu when you have no items.) - if (items.empty()) - cycle_page(dir); - // If the player has selected items on this new page previously, restore // those selections. for (SelItem& sel_item : offscreen_sel[cur_osel]) @@ -479,12 +489,12 @@ bool InvMenu::process_command(command_type cmd) lastch = CK_ESCAPE; // XX is this correct? return is_set(MF_UNCANCEL) && !crawl_state.seen_hups; } - else if (cmd == CMD_MENU_LEFT || cmd == CMD_MENU_PAGE_UP) + else if (cmd == CMD_MENU_LEFT) { cycle_page(-1); return true; } - else if (cmd == CMD_MENU_RIGHT || cmd == CMD_MENU_PAGE_DOWN) + else if (cmd == CMD_MENU_RIGHT) { cycle_page(1); return true; @@ -1483,8 +1493,11 @@ static int _invent_select(const char *title = nullptr, // Cycle through all pages to properly apply pre-selections immediately. if (flags & MF_PAGED_INVENTORY) + { for (int i = 0; i < 4; ++i) - menu.cycle_page(1); + menu.set_page(i); + menu.set_page(0); + } menu.show(true); diff --git a/crawl-ref/source/invent.h b/crawl-ref/source/invent.h index 2cff466cab..7ee5b897a6 100644 --- a/crawl-ref/source/invent.h +++ b/crawl-ref/source/invent.h @@ -175,6 +175,7 @@ public: bool mode_special_drop() const; void cycle_page(int dir); + void set_page(int page); protected: void do_preselect(InvEntry *ie); -- Dungeon Crawl Stone Soup |