git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3521 c06c8d41-db1a-0410-9941-cceddc491573
RPGERJQMO2J4ZDYTRHJCLZMXDVSTUOOJURSZ7FPWOUFHTXIV5VIAC GSPHLNMEIUY5KSOV2LPKQLGJVBPGHXZENIXSJELA6ZBT74F5ZGRQC 3GLHLYH34NUBL2C5HSECKNVAO4ZFAAYXCW3Q5VZ2PXDDZ4SDD7LQC EAAACIJUVSBDOB6S73O4NFSMRDLFLQTFO7SXWWALGMVDZTQTHQBQC K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC GT7BSR54BVJKHUCLEBTELGBMNBFFDQW52EVC4XKVEMUVG2UGZMDAC FVT2J6IVMSQZYKQGUHQVGT4ADYM7AWUQ4U7766GBRRFMSR2WBMLAC NQIXUYGUIQTKZUB2IQDII7BBDMZ4VN4NUUTGT2ARQBZTDJUMPKRQC HSRRNAU5UAYC6B6IQWGJPFROMZBTJICPCH6DJVZDHDTAGOQ6IOYAC CE6FLTWU5PYFBSGVTIJXQXRMHOIHQ3VJCKHQVIMUUAIFHQ73X7NAC 4GFCF6N3MZSCHUB77Z3SQYJ3FYR5N3VBW2CGWANLJ74O5FEQH3CQC 4MPLCIJZL4YNUWK2RTKNE6N4UWNBMO5WDRKW737ENVE3RKV5LCRAC QFM6WJTFHB4KCQYVROAQD4KRAYV2FZKDL5PJZQN5MS7WDYSLJBIAC RPOZZWKG5GLPHVZZ7ZKMKS64ZMV2LDCQSARBJFJ6FZOTOKCQO7FAC 5V47S4NNTHWTSAHV3YLO2VGH7JTUIYJ3GBPDN5ZM4UQALT2ZEXDQC TRZAZJJA5VQBJ65SO5H5DNSILIZEJHIZCBYEBHEATCT6ZSMWIFKQC }static bool Hack_Ignore_F_Inscription = false; // only for "why can't I fire" feedbackstatic bool fire_item_okay(const item_def &item, unsigned flags){return (fire_item_matches(item, flags)&& (Hack_Ignore_F_Inscription || strstr(item.inscription.c_str(), "=f") == 0)&& you.equip[EQ_WEAPON] != item.link);
// Search all items in pack for a fire_item_okay item.// If check_quiver, quiver item is checked first.// Then, check all items in the loop determined by start and forwardstatic int find_fire_item_matching(unsigned fire_type, int start,bool forward, bool check_quiver)
// Not free, but not a performance issue either.static bool Hack_Ignore_F_Inscription = false; // only for "why can't I fire" feedbackstatic void _get_fire_order(std::vector<int>& fire_order)
if (check_quiver){const int q = you.quiver[get_quiver_type()];if (q >= 0 && q < ENDOFPACK && fire_item_okay(you.inv[q], fire_type))return (q);}const int dir = forward? 1 : -1;int end = forward? ENDOFPACK : -1;for (int i = start; i != end; )
for (unsigned int i_inv=Options.fire_items_start; i_inv<ENDOFPACK; i_inv++)
if (i >= Options.fire_items_start&& fire_item_okay(you.inv[i], fire_type)){return (i);}
const item_def& item = you.inv[i_inv];if (!is_valid_item(item))continue;// =f prevents item from being in fire orderif (!Hack_Ignore_F_Inscription &&strstr(item.inscription.c_str(), "=f"))continue;
// Note: This is a simple implementation, not an efficient one. -- bwr//// Returns item index or ENDOFPACK if no item found for auto-firingint get_fire_item_index(int start_from, bool forward, bool check_quiver)
int get_next_fire_item(int current, int direction)
const unsigned fire_flags = Options.fire_order[i];if ((item =find_fire_item_matching(fire_flags,start_from,forward,check_quiver)) != ENDOFPACK)break;
if (fire_order[i] == current){unsigned next = (i + fire_order.size() + direction) % fire_order.size();return fire_order[next];}
// either item was found or is still ENDOFPACK for no itemreturn (item);
int get_current_fire_item(){std::vector<int> fire_order;_get_fire_order(fire_order);if (fire_order.size() == 0)return ENDOFPACK;const int q = you.quiver[get_quiver_type()];for (unsigned i = 0; i < fire_order.size(); i++)if (q == fire_order[i])return q;return fire_order[0];
const int direction = (key == CONTROL('N')) ? +1 : -1;const int start = (item + ENDOFPACK + direction) % ENDOFPACK;const int next = get_fire_item_index(start, (direction==1), false);
const int direction = (key == CONTROL('P')) ? -1 : +1;const int next = get_next_fire_item(item, direction);