MCPcopy Create free account
hub / github.com/crawl/crawl / handle

Method handle

crawl-ref/source/delay.cc:529–611  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

527}
528
529void BaseRunDelay::handle()
530{
531 bool first_move = false;
532 if (!started)
533 {
534 first_move = true;
535 started = true;
536 }
537 // Handle inconsistencies between the delay queue and you.running.
538 // We don't want to send the game into a deadlock.
539 if (!you.running)
540 {
541 update_turn_count();
542 _pop_delay();
543 return;
544 }
545
546 if (you.turn_is_over)
547 return;
548
549 command_type cmd = CMD_NO_CMD;
550
551 if (want_move() && you.confused())
552 {
553 mprf("You're confused, stopping %s.",
554 you.running.runmode_name().c_str());
555 stop_running();
556 }
557 else if (!(unsafe_once && first_move) && !i_feel_safe(true, want_move())
558 || you.running.is_rest()
559 && (!can_rest_here(true) || regeneration_is_inhibited()))
560 {
561 stop_running();
562 }
563 else
564 cmd = move_cmd();
565
566 if (cmd != CMD_NO_CMD)
567 {
568 if (want_clear_messages())
569 clear_messages();
570 process_command(cmd);
571 if (you.turn_is_over
572 && (you.running.is_any_travel() || you.running.is_rest()))
573 {
574 you.running.turns_passed++;
575 // sanity check: if we get up to a large number of turns on
576 // an explore, run, or rest delay, something is extremely buggy
577 // and we should both rescue the player, and generate a crash
578 // report. The thresholds are very heuristic:
579 // Rest delay, 700 turns. A maxed ogre at hp 1 with no regen bonus
580 // takes around 510 turns to heal fully.
581 // Travel delay, 2000. Just a big number that is quite a bit
582 // bigger than any travel delay I have been able to generate. If
583 // anyone can generate this on demand it should be raised. (Or
584 // eventually, removed?)
585 // For debuggers: runmode if negative is a meaningful delay type,
586 // but when positive is used as a counter, so if it's a very large

Callers 1

handle_delayFunction · 0.45

Calls 15

update_turn_countFunction · 0.85
_pop_delayFunction · 0.85
mprfFunction · 0.85
stop_runningFunction · 0.85
i_feel_safeFunction · 0.85
can_rest_hereFunction · 0.85
clear_messagesFunction · 0.85
dprfFunction · 0.85
stop_delayFunction · 0.85
run_macroFunction · 0.85
nameFunction · 0.85

Tested by

no test coverage detected