+ if (leaving_quest)
+ {
+ quest_type* const q_ptr = &quest[leaving_quest];
+
+ if(((q_ptr->flags & QUEST_FLAG_ONCE) || (q_ptr->type == QUEST_TYPE_RANDOM)) &&
+ (q_ptr->status == QUEST_STATUS_TAKEN))
+ {
+ q_ptr->status = QUEST_STATUS_FAILED;
+ q_ptr->complev = (byte)p_ptr->lev;
+ update_playtime();
+ q_ptr->comptime = playtime;
+
+ /* Additional settings */
+ switch (q_ptr->type)
+ {
+ case QUEST_TYPE_TOWER:
+ quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
+ quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;
+ break;
+ case QUEST_TYPE_FIND_ARTIFACT:
+ a_info[q_ptr->k_idx].gen_flags &= ~(TRG_QUESTITEM);
+ break;
+ case QUEST_TYPE_RANDOM:
+ r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
+
+ /* Floor of random quest will be blocked */
+ prepare_change_floor_mode(CFM_NO_RETURN);
+ break;
+ }
+
+ /* Record finishing a quest */
+ if (q_ptr->type == QUEST_TYPE_RANDOM)
+ {
+ if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
+ }
+ else
+ {
+ if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
+ }
+ }
+ }
+}
+
+void leave_tower_check(void)
+{
+ leaving_quest = p_ptr->inside_quest;
+ /* Check for Tower Quest */