OSDN Git Service

[Refactor] #37353 world_type を world.c/h へ移動。
[hengband/hengband.git] / src / util.c
index 7020942..5913bf0 100644 (file)
 /* Purpose: Angband utilities -BEN- */
 
 #include "angband.h"
+#include "util.h"
 #include "monsterrace-hook.h"
+#include "view-mainwindow.h"
+#include "quest.h"
+#include "floor.h"
+#include "world.h"
 
 
 static int num_more = 0;
@@ -1139,8 +1144,6 @@ void text_to_ascii(char *buf, concptr str)
                {
                        /* Skip the backslash */
                        str++;
-
-                       /* Paranoia */
                        if (!(*str)) break;
 
                        /* Macro Trigger */
@@ -1681,7 +1684,7 @@ void select_floor_music(void)
        /* No sound */
        if (!use_music) return;
 
-       if(ambush_flag)
+       if(p_ptr->ambush_flag)
        {
                play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_AMBUSH);
                return;
@@ -1718,7 +1721,7 @@ void select_floor_music(void)
        { // TODO マクロで類似条件を統合すること
                if(quest[i].status == QUEST_STATUS_TAKEN &&
                        (quest[i].type == QUEST_TYPE_KILL_LEVEL || quest[i].type == QUEST_TYPE_RANDOM) &&
-                        quest[i].level == dun_level && dungeon_type == quest[i].dungeon)
+                        quest[i].level == current_floor_ptr->dun_level && p_ptr->dungeon_idx == quest[i].dungeon)
                {
                        if(play_music(TERM_XTRA_MUSIC_QUEST, i)) 
                        {
@@ -1728,16 +1731,16 @@ void select_floor_music(void)
                }
        }
 
-       if(dungeon_type)
+       if(p_ptr->dungeon_idx)
        {
                if(p_ptr->feeling == 2) play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_DUN_FEEL2);
                else if(p_ptr->feeling >= 3 && p_ptr->feeling <= 5) play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_DUN_FEEL1);
                else
                {
-                       if(play_music(TERM_XTRA_MUSIC_DUNGEON, dungeon_type))
+                       if(play_music(TERM_XTRA_MUSIC_DUNGEON, p_ptr->dungeon_idx))
                        {
-                               if(dun_level < 40) play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_DUN_LOW);
-                               else if(dun_level < 80) play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_DUN_MED);
+                               if(current_floor_ptr->dun_level < 40) play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_DUN_LOW);
+                               else if(current_floor_ptr->dun_level < 80) play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_DUN_MED);
                                else play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_DUN_HIGH);
                        }
                }
@@ -1753,7 +1756,7 @@ void select_floor_music(void)
                return;
        }
 
-       if(!dun_level)
+       if(!current_floor_ptr->dun_level)
        {
                if(p_ptr->lev >= 45) play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_FIELD3);
                else if(p_ptr->lev >= 25) play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_FIELD2);
@@ -2699,7 +2702,7 @@ static void msg_flush(int x)
        byte a = TERM_L_BLUE;
        bool nagasu = FALSE;
 
-       if ((auto_more && !now_damaged) || num_more < 0){
+       if ((auto_more && !p_ptr->now_damaged) || num_more < 0){
                int i;
                for (i = 0; i < 8; i++)
                {
@@ -2714,7 +2717,7 @@ static void msg_flush(int x)
                        nagasu = TRUE;
                }
        }
-       now_damaged = FALSE;
+       p_ptr->now_damaged = FALSE;
 
        if (!p_ptr->playing || !nagasu)
        {
@@ -2783,7 +2786,7 @@ void msg_print(concptr msg)
        char *t;
        char buf[1024];
 
-       if (world_monster) return;
+       if (current_world_ptr->timewalk_m_idx) return;
 
        /* Hack -- Reset */
        if (!msg_flag) {
@@ -2809,8 +2812,6 @@ void msg_print(concptr msg)
 
        /* No message */
        if (!msg) return;
-
-       /* Paranoia */
        if (n > 1000) return;
 
        /* Copy it */
@@ -2820,7 +2821,7 @@ void msg_print(concptr msg)
        }
        else
        {
-               sprintf(buf, ("T:%d - %s"), (int)turn, msg);
+               sprintf(buf, ("T:%d - %s"), (int)current_world_ptr->game_turn, msg);
        }
 
        /* New Message Length */
@@ -3570,8 +3571,6 @@ bool askfor(char *buf, int len)
 bool get_string(concptr prompt, char *buf, int len)
 {
        bool res;
-
-       /* Paranoia */
        msg_print(NULL);
 
        /* Display prompt */
@@ -3618,8 +3617,6 @@ bool get_check_strict(concptr prompt, BIT_FLAGS mode)
                handle_stuff();
                num_more = 0;
        }
-
-       /* Paranoia */
        msg_print(NULL);
 
        if (!rogue_like_commands)
@@ -3721,7 +3718,6 @@ bool get_check_strict(concptr prompt, BIT_FLAGS mode)
  */
 bool get_com(concptr prompt, char *command, bool z_escape)
 {
-       /* Paranoia */
        msg_print(NULL);
 
        /* Display a prompt */
@@ -3799,8 +3795,6 @@ QUANTITY get_quantity(concptr prompt, QUANTITY max)
                /* Use that prompt */
                prompt = tmp;
        }
-
-       /* Paranoia */
        msg_print(NULL);
 
        /* Display prompt */
@@ -4230,7 +4224,7 @@ static char inkey_from_menu(void)
                                        if (p_ptr->pclass == special_menu_info[hoge].jouken_naiyou) menu_name = special_menu_info[hoge].name;
                                        break;
                                case MENU_WILD:
-                                       if (!dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
+                                       if (!current_floor_ptr->dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
                                        {
                                                if ((byte)p_ptr->wild_mode == special_menu_info[hoge].jouken_naiyou) menu_name = special_menu_info[hoge].name;
                                        }
@@ -4540,8 +4534,6 @@ void request_command(int shopping)
                        continue;
                }
 
-
-               /* Paranoia */
                if (!cmd) continue;
 
 
@@ -4602,8 +4594,6 @@ void request_command(int shopping)
                concptr s;
 
                object_type *o_ptr = &inventory[i];
-
-               /* Skip non-objects */
                if (!o_ptr->k_idx) continue;
 
                /* No inscription */
@@ -4777,8 +4767,6 @@ int get_keymap_dir(char ch)
                        }
                }
        }
-
-       /* Paranoia */
        if (d == 5) d = 0;
 
        /* Return direction */
@@ -5274,8 +5262,6 @@ size_t my_strcpy(char *buf, concptr src, size_t bufsize)
 
        size_t len = strlen(src);
        size_t ret = len;
-
-       /* Paranoia */
        if (bufsize == 0) return ret;
 
        /* Truncate */
@@ -5563,3 +5549,4 @@ int inkey_special(bool numpad_cursor)
        /* Return normal keycode */
        return (int)((unsigned char)key);
 }
+