OSDN Git Service

ソースの至る所にちらばっていたクエストから出る時のコードをleave_quest_check()という関数にしてまとめた。
authorhabu <habu@0568b783-4c39-0410-ac80-bf13821ea2a2>
Fri, 22 Feb 2002 10:15:34 +0000 (10:15 +0000)
committerhabu <habu@0568b783-4c39-0410-ac80-bf13821ea2a2>
Fri, 22 Feb 2002 10:15:34 +0000 (10:15 +0000)
src/bldg.c
src/cmd1.c
src/cmd2.c
src/dungeon.c
src/externs.h
src/spells3.c
src/wizard2.c

index 6ae5788..18f7469 100644 (file)
@@ -4395,23 +4395,7 @@ msg_print("
                p_ptr->oldpy = 0;
                p_ptr->oldpx = 0;
 
-               leaving_quest = p_ptr->inside_quest;
-
-               /* Leaving an 'only once' quest marks it as failed */
-               if (leaving_quest &&
-                       ((quest[leaving_quest].flags & QUEST_FLAG_ONCE) || (quest[leaving_quest].type == QUEST_TYPE_RANDOM)) &&
-                       (quest[leaving_quest].status == QUEST_STATUS_TAKEN))
-               {
-                       quest[leaving_quest].status = QUEST_STATUS_FAILED;
-                       quest[leaving_quest].complev = (byte)p_ptr->lev;
-                       if (quest[leaving_quest].type == QUEST_TYPE_RANDOM)
-                       {
-                               r_info[quest[leaving_quest].r_idx].flags1 &= ~(RF1_QUESTOR);
-                               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);
-               }
+               leave_quest_check();
 
                p_ptr->inside_quest = cave[py][px].special;
                if(quest[leaving_quest].type != QUEST_TYPE_RANDOM) dun_level = 1;
index a7784ce..ddfcae5 100644 (file)
@@ -4679,22 +4679,7 @@ msg_format("%s
                                msg_print(NULL);
                        }
 
-                       leaving_quest = p_ptr->inside_quest;
-
-                       /* Leaving an 'only once' quest marks it as failed */
-                       if (leaving_quest &&
-                               ((quest[leaving_quest].flags & QUEST_FLAG_ONCE) || (quest[leaving_quest].type == QUEST_TYPE_RANDOM)) &&
-                               (quest[leaving_quest].status == QUEST_STATUS_TAKEN))
-                       {
-                               if ((quest[leaving_quest].type == QUEST_TYPE_RANDOM) && 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);
-                               quest[leaving_quest].status = QUEST_STATUS_FAILED;
-                               quest[leaving_quest].complev = (byte)p_ptr->lev;
-                               if (quest[leaving_quest].type == QUEST_TYPE_RANDOM)
-                                       r_info[quest[leaving_quest].r_idx].flags1 &= ~(RF1_QUESTOR);
-                       }
+                       leave_quest_check();
 
                        p_ptr->inside_quest = cave[y][x].special;
                        dun_level = 0;
index b93102f..115934d 100644 (file)
@@ -44,25 +44,9 @@ void do_cmd_go_up(void)
 #endif
 
 
-               leaving_quest = p_ptr->inside_quest;
-               p_ptr->inside_quest = c_ptr->special;
+               leave_quest_check();
 
-               /* Leaving an 'only once' quest marks it as failed */
-               if (leaving_quest &&
-                       ((quest[leaving_quest].flags & QUEST_FLAG_ONCE) || (quest[leaving_quest].type == QUEST_TYPE_RANDOM)) &&
-                       (quest[leaving_quest].status == QUEST_STATUS_TAKEN))
-               {
-                       quest[leaving_quest].status = QUEST_STATUS_FAILED;
-                       quest[leaving_quest].complev = (byte)p_ptr->lev;
-                       if (quest[leaving_quest].type == QUEST_TYPE_RANDOM)
-                       {
-                               r_info[quest[leaving_quest].r_idx].flags1 &= ~(RF1_QUESTOR);
-                               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);
-               }
+               p_ptr->inside_quest = c_ptr->special;
 
                /* Activate the quest */
                if (!quest[p_ptr->inside_quest].status)
@@ -118,25 +102,9 @@ if (get_check("
 
                        if (p_ptr->inside_quest)
                        {
-                               leaving_quest = p_ptr->inside_quest;
-                               if (quest[leaving_quest].type != QUEST_TYPE_RANDOM) dun_level = 1;
+                               if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM) dun_level = 1;
 
-                               /* Leaving an 'only once' quest marks it as failed */
-                               if (leaving_quest &&
-                                       ((quest[leaving_quest].flags & QUEST_FLAG_ONCE) || (quest[leaving_quest].type == QUEST_TYPE_RANDOM)) &&
-                                       (quest[leaving_quest].status == QUEST_STATUS_TAKEN))
-                               {
-                                       quest[leaving_quest].status = QUEST_STATUS_FAILED;
-                                       quest[leaving_quest].complev = (byte)p_ptr->lev;
-                                       if (quest[leaving_quest].type == QUEST_TYPE_RANDOM)
-                                       {
-                                               r_info[quest[leaving_quest].r_idx].flags1 &= ~(RF1_QUESTOR);
-                                               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);
-                               }
+                               leave_quest_check();
 
                                p_ptr->inside_quest = c_ptr->special;
                        }
@@ -250,24 +218,7 @@ void do_cmd_go_down(void)
 #endif
 
 
-               leaving_quest = p_ptr->inside_quest;
-
-               /* Leaving an 'only once' quest marks it as failed */
-               if (leaving_quest &&
-                       ((quest[leaving_quest].flags & QUEST_FLAG_ONCE) || (quest[leaving_quest].type == QUEST_TYPE_RANDOM)) &&
-                       (quest[leaving_quest].status == QUEST_STATUS_TAKEN))
-               {
-                       quest[leaving_quest].status = QUEST_STATUS_FAILED;
-                       quest[leaving_quest].complev = (byte)p_ptr->lev;
-                       if (quest[leaving_quest].type == QUEST_TYPE_RANDOM)
-                       {
-                               r_info[quest[leaving_quest].r_idx].flags1 &= ~(RF1_QUESTOR);
-                               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);
-               }
+               leave_quest_check();
 
                p_ptr->inside_quest = c_ptr->special;
 
@@ -3134,24 +3085,7 @@ void do_cmd_stay(int pickup)
                        msg_print(NULL);
                }
 
-               leaving_quest = p_ptr->inside_quest;
-
-               /* Leaving an 'only once' quest marks it as failed */
-               if (leaving_quest &&
-                       ((quest[leaving_quest].flags & QUEST_FLAG_ONCE) || (quest[leaving_quest].type == QUEST_TYPE_RANDOM)) &&
-                       (quest[leaving_quest].status == QUEST_STATUS_TAKEN))
-               {
-                       quest[leaving_quest].status = QUEST_STATUS_FAILED;
-                       quest[leaving_quest].complev = (byte)p_ptr->lev;
-                       if (quest[leaving_quest].type == QUEST_TYPE_RANDOM)
-                       {
-                               r_info[quest[leaving_quest].r_idx].flags1 &= ~(RF1_QUESTOR);
-                               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);
-               }
+               leave_quest_check();
 
                p_ptr->inside_quest = cave[py][px].special;
                dun_level = 0;
index 596bc39..b587bf3 100644 (file)
@@ -1111,6 +1111,30 @@ msg_print("
 }
 
 
+void leave_quest_check(void)
+{
+       /* Save quset number for dungeon pref file ($LEAVING_QUEST) */
+       leaving_quest = p_ptr->inside_quest;
+
+       /* Leaving an 'only once' quest marks it as failed */
+       if (leaving_quest &&
+           ((quest[leaving_quest].flags & QUEST_FLAG_ONCE)  || (quest[leaving_quest].type == QUEST_TYPE_RANDOM)) &&
+           (quest[leaving_quest].status == QUEST_STATUS_TAKEN))
+       {
+               quest[leaving_quest].status = QUEST_STATUS_FAILED;
+               quest[leaving_quest].complev = (byte)p_ptr->lev;
+               if (quest[leaving_quest].type == QUEST_TYPE_RANDOM)
+               {
+                       r_info[quest[leaving_quest].r_idx].flags1 &= ~(RF1_QUESTOR);
+                       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);
+       }
+}
+
+
 /*
  * Forcibly pseudo-identify an object in the inventory
  * (or on the floor)
@@ -3498,24 +3522,7 @@ msg_print("
                                dun_level = 0;
                                dungeon_type = 0;
 
-                               leaving_quest = p_ptr->inside_quest;
-
-                               /* Leaving an 'only once' quest marks it as failed */
-                               if (leaving_quest &&
-                                       ((quest[leaving_quest].flags & QUEST_FLAG_ONCE)  || (quest[leaving_quest].type == QUEST_TYPE_RANDOM)) &&
-                                       (quest[leaving_quest].status == QUEST_STATUS_TAKEN))
-                               {
-                                       quest[leaving_quest].status = QUEST_STATUS_FAILED;
-                                       quest[leaving_quest].complev = (byte)p_ptr->lev;
-                                       if (quest[leaving_quest].type == QUEST_TYPE_RANDOM)
-                                       {
-                                               r_info[quest[leaving_quest].r_idx].flags1 &= ~(RF1_QUESTOR);
-                                               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);
-                               }
+                               leave_quest_check();
 
                                p_ptr->inside_quest = 0;
                                p_ptr->leaving = TRUE;
index e71abb2..d428bdd 100644 (file)
@@ -690,6 +690,7 @@ extern void do_cmd_use(void);
 extern void do_cmd_magic_eater(void);
 
 /* dungeon.c */
+extern void leave_quest_check(void);
 extern void play_game(bool new_game);
 extern bool psychometry(void);
 extern void leave_level(int level);
index 16838df..69979fb 100644 (file)
@@ -592,23 +592,7 @@ msg_print("
 
                if (!dun_level) dungeon_type = 0;
 
-               leaving_quest = p_ptr->inside_quest;
-
-               if (leaving_quest &&
-                       ((quest[leaving_quest].flags & QUEST_FLAG_ONCE)  || (quest[leaving_quest].type == QUEST_TYPE_RANDOM)) &&
-                       (quest[leaving_quest].status == QUEST_STATUS_TAKEN))
-               {
-                       quest[leaving_quest].status = QUEST_STATUS_FAILED;
-                       quest[leaving_quest].complev = (byte)p_ptr->lev;
-                       if (quest[leaving_quest].type == QUEST_TYPE_RANDOM)
-                       {
-                               r_info[quest[leaving_quest].r_idx].flags1 &= ~(RF1_QUESTOR);
-                               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);
-               }
+               leave_quest_check();
 
                /* Leaving */
                p_ptr->inside_quest = 0;
index 03f7fa1..c943caf 100644 (file)
@@ -1478,18 +1478,8 @@ static void do_cmd_wiz_jump(void)
 
        if (!dun_level) dungeon_type = 0;
        p_ptr->inside_arena = FALSE;
-       leaving_quest = p_ptr->inside_quest;
 
-       /* Leaving an 'only once' quest marks it as failed */
-       if (leaving_quest &&
-               (quest[leaving_quest].flags & QUEST_FLAG_ONCE) &&
-               (quest[leaving_quest].status == QUEST_STATUS_TAKEN))
-       {
-               quest[leaving_quest].status = QUEST_STATUS_FAILED;
-               quest[leaving_quest].complev = (byte)p_ptr->lev;
-               if (record_fix_quest)
-                       do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
-       }
+       leave_quest_check();
 
        if (record_stair) do_cmd_write_nikki(NIKKI_WIZ_TELE,0,NULL);