1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
/**
* @file
* @brief User interactions that need to be restarted if the game is forcibly
* saved (via SIGHUP/window close).
**/
#include "AppHdr.h"
#include "mpr.h"
#include "uncancel.h"
#include "acquire.h"
#include "decks.h"
#include "god-abil.h"
#include "item-use.h"
#include "libutil.h"
#include "state.h"
#include "tag-version.h"
#include "unwind.h"
void add_uncancel(uncancellable_type kind, int arg)
{
you.uncancel.emplace_back(kind, arg);
}
static bool running = false;
void run_uncancels()
{
// Run uncancels iteratively rather than recursively.
if (running)
return;
unwind_bool run(running, true);
while (!you.uncancel.empty() && !crawl_state.seen_hups)
{
// changed to -1 if we pop prematurely
int act = you.uncancel.size() - 1;
// Beware of race conditions: it is not enough to check seen_hups,
// the action must actually fail as well! And if it fails but there
// was no HUP, it's due to some other reason.
int arg = you.uncancel[act].second;
dprf("Running uncancel type=%d arg=%d", you.uncancel[act].first, arg);
switch (you.uncancel[act].first)
{
case UNC_DRAW_THREE:
if (!draw_three() && crawl_state.seen_hups)
return;
break;
case UNC_STACK_FIVE:
if (!stack_five(arg) && crawl_state.seen_hups)
return;
break;
#if TAG_MAJOR_VERSION == 34
case UNC_MERCENARY:
case UNC_ACQUIREMENT:
break;
#endif
case UNC_POTION_PETITION:
if (!gozag_potion_petition() && crawl_state.seen_hups)
return;
break;
case UNC_CALL_MERCHANT:
if (!gozag_call_merchant() && crawl_state.seen_hups)
return;
break;
case UNC_ENCHANT_WEAPON:
if (!uncancel_enchant_weapon() && crawl_state.seen_hups)
return;
break;
case UNC_ENCHANT_ARMOUR:
if (!uncancel_enchant_armour() && crawl_state.seen_hups)
return;
break;
case UNC_BRAND_WEAPON:
if (!uncancel_brand_weapon() && crawl_state.seen_hups)
return;
break;
case UNC_AMNESIA:
if (!uncancel_amnesia() && crawl_state.seen_hups)
return;
break;
case UNC_BLINKING:
if (!uncancel_blinking() && crawl_state.seen_hups)
return;
break;
case UNC_IDENTIFY:
if (!uncancel_identify() && crawl_state.seen_hups)
return;
break;
}
if (act != -1)
erase_any(you.uncancel, act);
}
}
|