OSDN Git Service

Vanillaにならって、キャラクターの状態を表わすグローバル変数の多くを
[hengband/hengband.git] / src / cmd4.c
index c771645..b767495 100644 (file)
@@ -224,23 +224,11 @@ errr do_cmd_write_nikki(int type, int num, cptr note)
        cptr note_level = "";
        bool do_level = TRUE;
 
-       s32b len = 20L * TOWN_DAWN;
-       s32b tick = turn % len + len / 4;
-
        static bool disable_nikki = FALSE;
 
-       if (disable_nikki) return(-1);
-
-       if ((p_ptr->prace == RACE_VAMPIRE) ||
-           (p_ptr->prace == RACE_SKELETON) ||
-           (p_ptr->prace == RACE_ZOMBIE) ||
-           (p_ptr->prace == RACE_SPECTRE))
-               day = (turn - (15L * TOWN_DAWN))/ len + 1;
-       else
-               day = (turn + (5L * TOWN_DAWN))/ len + 1;
+       extract_day_hour_min(&day, &hour, &min);
 
-       hour = (24 * tick / len) % 24;
-       min = (1440 * tick / len) % 60;
+       if (disable_nikki) return(-1);
 
        if (type == NIKKI_FIX_QUEST_C ||
            type == NIKKI_FIX_QUEST_F ||
@@ -1193,7 +1181,11 @@ void do_cmd_messages(int num_now)
 
        char shower[80];
        char finder[80];
+       int wid, hgt;
+
 
+       /* Get size */
+       Term_get_size(&wid, &hgt);
 
        /* Wipe finder */
        strcpy(finder, "");
@@ -1221,7 +1213,7 @@ void do_cmd_messages(int num_now)
                Term_clear();
 
                /* Dump up to 20 lines of messages */
-               for (j = 0; (j < 20) && (i + j < n); j++)
+               for (j = 0; (j < hgt - 4) && (i + j < n); j++)
                {
                        cptr msg = message_str(i+j);
 
@@ -1229,7 +1221,7 @@ void do_cmd_messages(int num_now)
                        msg = (strlen(msg) >= q) ? (msg + q) : "";
 
                        /* Dump the messages, bottom to top */
-                       Term_putstr(0, 21-j, -1, (bool)(i+j < num_now ? TERM_WHITE : TERM_SLATE), msg);
+                       Term_putstr(0, hgt-j-3, -1, (bool)(i+j < num_now ? TERM_WHITE : TERM_SLATE), msg);
 
                        /* Hilite "shower" */
                        if (shower[0])
@@ -1242,7 +1234,7 @@ void do_cmd_messages(int num_now)
                                        int len = strlen(shower);
 
                                        /* Display the match */
-                                       Term_putstr(str-msg, 21-j, len, TERM_YELLOW, shower);
+                                       Term_putstr(str-msg, hgt-j-3, len, TERM_YELLOW, shower);
 
                                        /* Advance */
                                        str += len;
@@ -1263,9 +1255,9 @@ void do_cmd_messages(int num_now)
 
                /* Display prompt (not very informative) */
 #ifdef JP
-               prt("[ 'p' ¤Ç¹¹¤Ë¸Å¤¤¤â¤Î, 'n' ¤Ç¹¹¤Ë¿·¤·¤¤¤â¤Î, '/' ¤Ç¸¡º÷, ESC ¤ÇÃæÃÇ ]", 23, 0);
+               prt("[ 'p' ¤Ç¹¹¤Ë¸Å¤¤¤â¤Î, 'n' ¤Ç¹¹¤Ë¿·¤·¤¤¤â¤Î, '/' ¤Ç¸¡º÷, ESC ¤ÇÃæÃÇ ]", hgt - 1, 0);
 #else
-               prt("[Press 'p' for older, 'n' for newer, ..., or ESCAPE]", 23, 0);
+               prt("[Press 'p' for older, 'n' for newer, ..., or ESCAPE]", hgt - 1, 0);
 #endif
 
 
@@ -1303,9 +1295,9 @@ void do_cmd_messages(int num_now)
                {
                        /* Prompt */
 #ifdef JP
-                       prt("¶¯Ä´: ", 23, 0);
+                       prt("¶¯Ä´: ", hgt - 1, 0);
 #else
-                       prt("Show: ", 23, 0);
+                       prt("Show: ", hgt - 1, 0);
 #endif
 
 
@@ -1323,9 +1315,9 @@ void do_cmd_messages(int num_now)
 
                        /* Prompt */
 #ifdef JP
-                       prt("¸¡º÷: ", 23, 0);
+                       prt("¸¡º÷: ", hgt - 1, 0);
 #else
-                       prt("Find: ", 23, 0);
+                       prt("Find: ", hgt - 1, 0);
 #endif
 
 
@@ -1552,13 +1544,13 @@ static void do_cmd_options_cheat(cptr info)
                        case 'Y':
                        case '6':
                        {
-                               if(!noscore)
+                               if(!p_ptr->noscore)
 #ifdef JP
                                        do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "º¾µ½¥ª¥×¥·¥ç¥ó¤òON¤Ë¤·¤Æ¡¢¥¹¥³¥¢¤ò»Ä¤»¤Ê¤¯¤Ê¤Ã¤¿¡£");
 #else
                                        do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "give up sending score to use cheating options.");
 #endif
-                               noscore |= (cheat_info[k].o_set * 256 + cheat_info[k].o_bit);
+                               p_ptr->noscore |= (cheat_info[k].o_set * 256 + cheat_info[k].o_bit);
                                (*cheat_info[k].o_var) = TRUE;
                                k = (k + 1) % n;
                                break;
@@ -2413,20 +2405,16 @@ void do_cmd_pref(void)
 void do_cmd_pickpref(void)
 {
        char buf[80];
-       errr err = -1; 
-       int i;
+       errr err;
 
 #ifdef JP
        if(!get_check("¼«Æ°½¦¤¤ÀßÄê¥Õ¥¡¥¤¥ë¤ò¥í¡¼¥É¤·¤Þ¤¹¤«? ")) return;
 #else
        if(!get_check("Reload auto-pick preference file? ")) return;
 #endif
-       /* ¤¤¤Þ¤Þ¤Ç»È¤Ã¤Æ¤¤¤¿¥á¥â¥ê²òÊü */
-       for( i = 0; i < max_autopick; i++){
-               string_free(autopick_name[i]);
-               string_free(autopick_insc[i]);
-       }
-       max_autopick = 0;
+
+       /* Free old entries */
+       init_autopicker();
 
        /* ¥­¥ã¥éËè¤ÎÀßÄê¥Õ¥¡¥¤¥ë¤ÎÆɤ߹þ¤ß */
 #ifdef JP
@@ -2434,8 +2422,10 @@ void do_cmd_pickpref(void)
 #else
        sprintf(buf, "pickpref-%s.prf", player_name);
 #endif
-       if( process_pickpref_file(buf) == 0 ){
-               err = 0;
+       err = process_pickpref_file(buf);
+
+       if(err == 0)
+       {
 #ifdef JP
                msg_format("%s¤òÆɤ߹þ¤ß¤Þ¤·¤¿¡£", buf);
 #else
@@ -2444,20 +2434,27 @@ void do_cmd_pickpref(void)
        }
 
        /* ¶¦Ä̤ÎÀßÄê¥Õ¥¡¥¤¥ëÆɤ߹þ¤ß */
+
+       /* Process 'pick????.prf' if 'pick????-<name>.prf' doesn't exist */
+       if (0 > err)
+       {
 #ifdef JP
-       if( process_pickpref_file("picktype.prf") == 0 )
+               err = process_pickpref_file("picktype.prf");
 #else
-       if( process_pickpref_file("pickpref.prf") == 0 )
+               err = process_pickpref_file("pickpref.prf");
 #endif
-       {
-               err = 0;
+
+               if(err == 0)
+               {
 #ifdef JP
-               msg_print("picktype.prf¤òÆɤ߹þ¤ß¤Þ¤·¤¿¡£");
+                       msg_print("picktype.prf¤òÆɤ߹þ¤ß¤Þ¤·¤¿¡£");
 #else
-               msg_print("loaded 'pickpref.prf'.");
+                       msg_print("loaded 'pickpref.prf'.");
 #endif
+               }
        }
 
+
 #ifdef JP
        if(err) msg_print("¼«Æ°½¦¤¤ÀßÄê¥Õ¥¡¥¤¥ë¤ÎÆɤ߹þ¤ß¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£");
 #else
@@ -3291,6 +3288,31 @@ void do_cmd_macros(void)
 }
 
 
+static void cmd_visuals_aux(int i, int *num, int max)
+{
+       if (iscntrl(i))
+       {
+               char str[10] = "";
+               int tmp;
+
+               sprintf(str, "%d", *num);
+
+               if (!get_string(format("Input new number(0-%d): ", max-1), str, 4))
+                       return;
+
+               tmp = strtol(str, NULL, 0);
+               if (tmp >= 0 && tmp < max)
+                       *num = tmp;
+               return;
+       }
+       else if (isupper(i))
+               *num = (*num + max - 1) % max;
+       else
+               *num = (*num + 1) % max;
+
+       return;
+}
+
 /*
  * Interact with "visuals"
  */
@@ -3644,6 +3666,8 @@ void do_cmd_visuals(void)
                        while (1)
                        {
                                monster_race *r_ptr = &r_info[r];
+                               char c;
+                               int t;
 
                                byte da = (r_ptr->d_attr);
                                byte dc = (r_ptr->d_char);
@@ -3673,6 +3697,13 @@ void do_cmd_visuals(void)
 
                                Term_putstr(40, 19, -1, TERM_WHITE, "<< ? >>");
                                Term_putch(43, 19, da, dc);
+                               if (use_bigtile)
+                               {
+                                       if (da & 0x80)
+                                               Term_putch(44, 19, 255, -1);
+                                       else
+                                               Term_putch(44, 19, 0, ' ');
+                               }
 
                                /* Label the Current values */
 #ifdef JP
@@ -3685,30 +3716,49 @@ void do_cmd_visuals(void)
 
                                Term_putstr(40, 20, -1, TERM_WHITE, "<< ? >>");
                                Term_putch(43, 20, ca, cc);
+                               if (use_bigtile)
+                               {
+                                       if (ca & 0x80)
+                                               Term_putch(44, 20, 255, -1);
+                                       else
+                                               Term_putch(44, 20, 0, ' ');
+                               }
 
                                /* Prompt */
 #ifdef JP
                                Term_putstr(0, 22, -1, TERM_WHITE,
-                                           "¥³¥Þ¥ó¥É (n/N/a/A/c/C): ");
+                                           "¥³¥Þ¥ó¥É (n/N/^N/a/A/^A/c/C/^C): ");
 #else
                                Term_putstr(0, 22, -1, TERM_WHITE,
-                                           "Command (n/N/a/A/c/C): ");
+                                           "Command (n/N/^N/a/A/^A/c/C/^C): ");
 #endif
 
-
                                /* Get a command */
                                i = inkey();
 
                                /* All done */
                                if (i == ESCAPE) break;
 
-                               /* Analyze */
-                               if (i == 'n') r = (r + max_r_idx + 1) % max_r_idx;
-                               if (i == 'N') r = (r + max_r_idx - 1) % max_r_idx;
-                               if (i == 'a') r_ptr->x_attr = (byte)(ca + 1);
-                               if (i == 'A') r_ptr->x_attr = (byte)(ca - 1);
-                               if (i == 'c') r_ptr->x_char = (byte)(cc + 1);
-                               if (i == 'C') r_ptr->x_char = (byte)(cc - 1);
+                               if (iscntrl(i)) c = 'a' + i - KTRL('A');
+                               else if (isupper(i)) c = 'a' + i - 'A';
+                               else c = i;
+
+                               switch (c)
+                               {
+                               case 'n':
+                                       cmd_visuals_aux(i, &r, max_r_idx);
+                                       break;
+                               case 'a':
+                                       t = (int)r_ptr->x_attr;
+                                       cmd_visuals_aux(i, &t, 256);
+                                       r_ptr->x_attr = (byte)t;
+                                       break;
+                               case 'c':
+                                       t = (int)r_ptr->x_char;
+                                       cmd_visuals_aux(i, &t, 256);
+                                       r_ptr->x_char = (byte)t;
+                                       break;
+                               }
                        }
                }
 
@@ -3729,6 +3779,8 @@ void do_cmd_visuals(void)
                        while (1)
                        {
                                object_kind *k_ptr = &k_info[k];
+                               char c;
+                               int t;
 
                                byte da = (byte)k_ptr->d_attr;
                                byte dc = (byte)k_ptr->d_char;
@@ -3758,6 +3810,13 @@ void do_cmd_visuals(void)
 
                                Term_putstr(40, 19, -1, TERM_WHITE, "<< ? >>");
                                Term_putch(43, 19, da, dc);
+                               if (use_bigtile)
+                               {
+                                       if (da & 0x80)
+                                               Term_putch(44, 19, 255, -1);
+                                       else
+                                               Term_putch(44, 19, 0, ' ');
+                               }
 
                                /* Label the Current values */
 #ifdef JP
@@ -3770,30 +3829,49 @@ void do_cmd_visuals(void)
 
                                Term_putstr(40, 20, -1, TERM_WHITE, "<< ? >>");
                                Term_putch(43, 20, ca, cc);
+                               if (use_bigtile)
+                               {
+                                       if (ca & 0x80)
+                                               Term_putch(44, 20, 255, -1);
+                                       else
+                                               Term_putch(44, 20, 0, ' ');
+                               }
 
                                /* Prompt */
 #ifdef JP
                                Term_putstr(0, 22, -1, TERM_WHITE,
-                                           "¥³¥Þ¥ó¥É (n/N/a/A/c/C): ");
+                                           "¥³¥Þ¥ó¥É (n/N/^N/a/A/^A/c/C/^C): ");
 #else
                                Term_putstr(0, 22, -1, TERM_WHITE,
-                                           "Command (n/N/a/A/c/C): ");
+                                           "Command (n/N/^N/a/A/^A/c/C/^C): ");
 #endif
 
-
                                /* Get a command */
                                i = inkey();
 
                                /* All done */
                                if (i == ESCAPE) break;
 
-                               /* Analyze */
-                               if (i == 'n') k = (k + max_k_idx + 1) % max_k_idx;
-                               if (i == 'N') k = (k + max_k_idx - 1) % max_k_idx;
-                               if (i == 'a') k_info[k].x_attr = (byte)(ca + 1);
-                               if (i == 'A') k_info[k].x_attr = (byte)(ca - 1);
-                               if (i == 'c') k_info[k].x_char = (byte)(cc + 1);
-                               if (i == 'C') k_info[k].x_char = (byte)(cc - 1);
+                               if (iscntrl(i)) c = 'a' + i - KTRL('A');
+                               else if (isupper(i)) c = 'a' + i - 'A';
+                               else c = i;
+
+                               switch (c)
+                               {
+                               case 'n':
+                                       cmd_visuals_aux(i, &k, max_k_idx);
+                                       break;
+                               case 'a':
+                                       t = (int)k_info[k].x_attr;
+                                       cmd_visuals_aux(i, &t, 256);
+                                       k_info[k].x_attr = (byte)t;
+                                       break;
+                               case 'c':
+                                       t = (int)k_info[k].x_char;
+                                       cmd_visuals_aux(i, &t, 256);
+                                       k_info[k].x_char = (byte)t;
+                                       break;
+                               }
                        }
                }
 
@@ -3814,6 +3892,8 @@ void do_cmd_visuals(void)
                        while (1)
                        {
                                feature_type *f_ptr = &f_info[f];
+                               char c;
+                               int t;
 
                                byte da = (byte)f_ptr->d_attr;
                                byte dc = (byte)f_ptr->d_char;
@@ -3843,6 +3923,13 @@ void do_cmd_visuals(void)
 
                                Term_putstr(40, 19, -1, TERM_WHITE, "<< ? >>");
                                Term_putch(43, 19, da, dc);
+                               if (use_bigtile)
+                               {
+                                       if (da & 0x80)
+                                               Term_putch(44, 19, 255, -1);
+                                       else
+                                               Term_putch(44, 19, 0, ' ');
+                               }
 
                                /* Label the Current values */
 #ifdef JP
@@ -3855,30 +3942,49 @@ void do_cmd_visuals(void)
 
                                Term_putstr(40, 20, -1, TERM_WHITE, "<< ? >>");
                                Term_putch(43, 20, ca, cc);
+                               if (use_bigtile)
+                               {
+                                       if (ca & 0x80)
+                                               Term_putch(44, 20, 255, -1);
+                                       else
+                                               Term_putch(44, 20, 0, ' ');
+                               }
 
                                /* Prompt */
 #ifdef JP
                                Term_putstr(0, 22, -1, TERM_WHITE,
-                                           "¥³¥Þ¥ó¥É (n/N/a/A/c/C): ");
+                                           "¥³¥Þ¥ó¥É (n/N/^N/a/A/^A/c/C/^C): ");
 #else
                                Term_putstr(0, 22, -1, TERM_WHITE,
-                                           "Command (n/N/a/A/c/C): ");
+                                           "Command (n/N/^N/a/A/^A/c/C/^C): ");
 #endif
 
-
                                /* Get a command */
                                i = inkey();
 
                                /* All done */
                                if (i == ESCAPE) break;
 
-                               /* Analyze */
-                               if (i == 'n') f = (f + max_f_idx + 1) % max_f_idx;
-                               if (i == 'N') f = (f + max_f_idx - 1) % max_f_idx;
-                               if (i == 'a') f_info[f].x_attr = (byte)(ca + 1);
-                               if (i == 'A') f_info[f].x_attr = (byte)(ca - 1);
-                               if (i == 'c') f_info[f].x_char = (byte)(cc + 1);
-                               if (i == 'C') f_info[f].x_char = (byte)(cc - 1);
+                               if (iscntrl(i)) c = 'a' + i - KTRL('A');
+                               else if (isupper(i)) c = 'a' + i - 'A';
+                               else c = i;
+
+                               switch (c)
+                               {
+                               case 'n':
+                                       cmd_visuals_aux(i, &f, max_f_idx);
+                                       break;
+                               case 'a':
+                                       t = (int)f_info[f].x_attr;
+                                       cmd_visuals_aux(i, &t, 256);
+                                       f_info[f].x_attr = (byte)t;
+                                       break;
+                               case 'c':
+                                       t = (int)f_info[f].x_char;
+                                       cmd_visuals_aux(i, &t, 256);
+                                       f_info[f].x_char = (byte)t;
+                                       break;
+                               }
                        }
                }
 
@@ -4514,7 +4620,7 @@ void do_cmd_feeling(void)
        }
 
        /* Display the feeling */
-        if (turn - old_turn >= (3000 - dun_level*20) || cheat_xtra)
+        if (turn - old_turn >= (150 - dun_level)*TURNS_PER_TICK || cheat_xtra)
         {
                 if (p_ptr->muta3 & MUT3_GOOD_LUCK) msg_print(do_cmd_feeling_text_lucky[feeling]);
                 else {
@@ -4629,6 +4735,9 @@ void do_cmd_load_screen(void)
 
        char buf[1024];
 
+       int wid, hgt;
+
+       Term_get_size(&wid, &hgt);
 
        /* Hack -- drop permissions */
        safe_setuid_drop();
@@ -4659,13 +4768,13 @@ void do_cmd_load_screen(void)
 
 
        /* Load the screen */
-       for (y = 0; okay && (y < 24); y++)
+       for (y = 0; okay && (y < hgt); y++)
        {
                /* Get a line of data */
                if (photo_fgets(fff, buf, 1024)) okay = FALSE;
 
                /* Show each row */
-               for (x = 0; x < 79; x++)
+               for (x = 0; x < wid - 1; x++)
                {
                        /* Put the attr/char */
                        Term_draw(x, y, TERM_WHITE, buf[x]);
@@ -4677,13 +4786,13 @@ void do_cmd_load_screen(void)
 
 
        /* Dump the screen */
-       for (y = 0; okay && (y < 24); y++)
+       for (y = 0; okay && (y < hgt); y++)
        {
                /* Get a line of data */
                if (photo_fgets(fff, buf, 1024)) okay = FALSE;
 
                /* Dump each row */
-               for (x = 0; x < 79; x++)
+               for (x = 0; x < wid - 1; x++)
                {
                        /* Get the attr/char */
                        (void)(Term_what(x, y, &a, &c));
@@ -5016,7 +5125,7 @@ static void do_cmd_knowledge_inven(void)
 #ifdef JP
          strcpy(where, "²È");
 #else
-         strcpy(where, "H ");/*nanka*/
+         strcpy(where, "H ");
 #endif
              
          /* Dump all available items */
@@ -5053,24 +5162,28 @@ void do_cmd_save_screen_html_aux(char *filename, int message)
        char buf[2048];
 
        int yomikomu = 0;
-       char *tags[4] = {
+       cptr tags[4] = {
                "HEADER_START:",
                "HEADER_END:",
                "FOOTER_START:",
                "FOOTER_END:",
        };
 
-       char *html_head[] = {
+       cptr html_head[] = {
                "<html>\n<body text=\"#ffffff\" bgcolor=\"#000000\">\n",
                "<pre>",
                0,
        };
-       char *html_foot[] = {
+       cptr html_foot[] = {
                "</pre>\n",
                "</body>\n</html>\n",
                0,
        };
 
+       int wid, hgt;
+
+       Term_get_size(&wid, &hgt);
+
        /* File type is "TEXT" */
        FILE_TYPE(FILE_TYPE_TEXT);
 
@@ -5118,17 +5231,17 @@ void do_cmd_save_screen_html_aux(char *filename, int message)
        }
 
        /* Dump the screen */
-       for (y = 0; y < 24; y++)
+       for (y = 0; y < hgt; y++)
        {
                /* Start the row */
                if (y != 0)
                        fprintf(fff, "\n");
 
                /* Dump each row */
-               for (x = 0; x < 79; x++)
+               for (x = 0; x < wid - 1; x++)
                {
                        int rv, gv, bv;
-                       char *cc = NULL;
+                       cptr cc = NULL;
                        /* Get the attr/char */
                        (void)(Term_what(x, y, &a, &c));
 
@@ -5205,7 +5318,7 @@ void do_cmd_save_screen_html_aux(char *filename, int message)
 /*
  * Hack -- save a screen dump to a file
  */
-void do_cmd_save_screen_html(void)
+static void do_cmd_save_screen_html(void)
 {
        char buf[1024], tmp[256] = "screen.html";
 
@@ -5242,18 +5355,36 @@ void (*screendump_aux)(void) = NULL;
  */
 void do_cmd_save_screen(void)
 {
+       bool old_use_graphics = use_graphics;
+
+       int wid, hgt;
+
+       Term_get_size(&wid, &hgt);
+
+       if (old_use_graphics)
+       {
+               use_graphics = FALSE;
+               reset_visuals();
+
+               /* Redraw everything */
+               p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
+
+               /* Hack -- update */
+               handle_stuff();
+       }
+
 #ifdef JP
-       if (get_check("HTML¤Ç½ÐÎϤ·¤Þ¤¹¤«¡©"))
+       if (get_check_strict("HTML¤Ç½ÐÎϤ·¤Þ¤¹¤«¡©", CHECK_NO_HISTORY))
 #else
-       if (get_check("Save screen dump as HTML? "))
+       if (get_check_strict("Save screen dump as HTML? ", CHECK_NO_HISTORY))
 #endif
        {
                do_cmd_save_screen_html();
-               return;
+               do_cmd_redraw();
        }
 
        /* Do we use a special screendump function ? */
-       if (screendump_aux)
+       else if (screendump_aux)
        {
                /* Dump the screen to a graphics file */
                (*screendump_aux)();
@@ -5302,10 +5433,10 @@ void do_cmd_save_screen(void)
 
 
                /* Dump the screen */
-               for (y = 0; y < 24; y++)
+               for (y = 0; y < hgt; y++)
                {
                        /* Dump each row */
-                       for (x = 0; x < 79; x++)
+                       for (x = 0; x < wid - 1; x++)
                        {
                                /* Get the attr/char */
                                (void)(Term_what(x, y, &a, &c));
@@ -5326,10 +5457,10 @@ void do_cmd_save_screen(void)
 
 
                /* Dump the screen */
-               for (y = 0; y < 24; y++)
+               for (y = 0; y < hgt; y++)
                {
                        /* Dump each row */
-                       for (x = 0; x < 79; x++)
+                       for (x = 0; x < wid - 1; x++)
                        {
                                /* Get the attr/char */
                                (void)(Term_what(x, y, &a, &c));
@@ -5368,6 +5499,18 @@ void do_cmd_save_screen(void)
                /* Restore the screen */
                screen_load();
        }
+
+       if (old_use_graphics)
+       {
+               use_graphics = TRUE;
+               reset_visuals();
+
+               /* Redraw everything */
+               p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
+
+               /* Hack -- update */
+               handle_stuff();
+       }
 }
 
 
@@ -5455,7 +5598,7 @@ static void ang_sort_art_swap(vptr u, vptr v, int a, int b)
 /*
  * Check the status of "artifacts"
  */
-void do_cmd_knowledge_artifacts(void)
+static void do_cmd_knowledge_artifacts(void)
 {
        int i, k, z, x, y, n = 0;
        u16b why = 3;
@@ -5854,17 +5997,17 @@ static void do_cmd_knowledge_weapon_exp(void)
                                {
                                        if((k_ptr->tval == TV_BOW) && (k_ptr->sval == SV_CRIMSON)) continue;
 
-                                       if(weapon_exp[4-i][num]<4000) shougou=0;
-                                       else if(weapon_exp[4-i][num]<6000) shougou=1;
-                                       else if(weapon_exp[4-i][num]<7000) shougou=2;
-                                       else if(weapon_exp[4-i][num]<8000) shougou=3;
+                                       if(p_ptr->weapon_exp[4-i][num]<4000) shougou=0;
+                                       else if(p_ptr->weapon_exp[4-i][num]<6000) shougou=1;
+                                       else if(p_ptr->weapon_exp[4-i][num]<7000) shougou=2;
+                                       else if(p_ptr->weapon_exp[4-i][num]<8000) shougou=3;
                                        else shougou=4;
                                        strip_name(tmp, j);
                                        fprintf(fff,"%-25s ",tmp);
-                                       if (weapon_exp[4-i][num] >= s_info[p_ptr->pclass].w_max[4-i][num]) fprintf(fff,"!");
+                                       if (p_ptr->weapon_exp[4-i][num] >= s_info[p_ptr->pclass].w_max[4-i][num]) fprintf(fff,"!");
                                        else fprintf(fff," ");
                                        fprintf(fff,"%s",shougou_moji[shougou]);
-                                       if (cheat_xtra) fprintf(fff," %d",weapon_exp[4-i][num]);
+                                       if (cheat_xtra) fprintf(fff," %d",p_ptr->weapon_exp[4-i][num]);
                                        fprintf(fff,"\n");
                                        break;
                                }
@@ -5930,10 +6073,10 @@ static void do_cmd_knowledge_spell_exp(void)
                                s_ptr = &mp_ptr->info[p_ptr->realm1 - 1][i];
                        }
                        if(s_ptr->slevel == 99) continue;
-                       if(spell_exp[i]<900) shougou=0;
-                       else if(spell_exp[i]<1200) shougou=1;
-                       else if(spell_exp[i]<1400) shougou=2;
-                       else if(spell_exp[i]<1600) shougou=3;
+                       if(p_ptr->spell_exp[i]<900) shougou=0;
+                       else if(p_ptr->spell_exp[i]<1200) shougou=1;
+                       else if(p_ptr->spell_exp[i]<1400) shougou=2;
+                       else if(p_ptr->spell_exp[i]<1600) shougou=3;
                        else shougou=4;
                        fprintf(fff,"%-25s ",spell_names[technic2magic(p_ptr->realm1)-1][i]);
                        if (p_ptr->realm1 == REALM_HISSATSU)
@@ -5944,7 +6087,7 @@ static void do_cmd_knowledge_spell_exp(void)
                                else fprintf(fff," ");
                                fprintf(fff,"%s",shougou_moji[shougou]);
                        }
-                       if (cheat_xtra) fprintf(fff," %d",spell_exp[i]);
+                       if (cheat_xtra) fprintf(fff," %d",p_ptr->spell_exp[i]);
                        fprintf(fff,"\n");
                }
        }
@@ -5964,15 +6107,15 @@ static void do_cmd_knowledge_spell_exp(void)
                        }
                        if(s_ptr->slevel == 99) continue;
 
-                       if(spell_exp[i+32]<900) shougou=0;
-                       else if(spell_exp[i+32]<1200) shougou=1;
-                       else if(spell_exp[i+32]<1400) shougou=2;
+                       if(p_ptr->spell_exp[i+32]<900) shougou=0;
+                       else if(p_ptr->spell_exp[i+32]<1200) shougou=1;
+                       else if(p_ptr->spell_exp[i+32]<1400) shougou=2;
                        else shougou=3;
                        fprintf(fff,"%-25s ",spell_names[technic2magic(p_ptr->realm2)-1][i]);
                        if (shougou == 3) fprintf(fff,"!");
                        else fprintf(fff," ");
                        fprintf(fff,"%s",shougou_moji[shougou]);
-                       if (cheat_xtra) fprintf(fff," %d",spell_exp[i+32]);
+                       if (cheat_xtra) fprintf(fff," %d",p_ptr->spell_exp[i+32]);
                        fprintf(fff,"\n");
                }
        }
@@ -6025,25 +6168,25 @@ static void do_cmd_knowledge_skill_exp(void)
        {
                if(i == GINOU_RIDING)
                {
-                       if(skill_exp[i]<500) shougou=0;
-                       else if(skill_exp[i]<2000) shougou=1;
-                       else if(skill_exp[i]<5000) shougou=2;
-                       else if(skill_exp[i]<8000) shougou=3;
+                       if(p_ptr->skill_exp[i]<500) shougou=0;
+                       else if(p_ptr->skill_exp[i]<2000) shougou=1;
+                       else if(p_ptr->skill_exp[i]<5000) shougou=2;
+                       else if(p_ptr->skill_exp[i]<8000) shougou=3;
                        else shougou=4;
                }
                else
                {
-                       if(skill_exp[i]<4000) shougou=0;
-                       else if(skill_exp[i]<6000) shougou=1;
-                       else if(skill_exp[i]<7000) shougou=2;
-                       else if(skill_exp[i]<8000) shougou=3;
+                       if(p_ptr->skill_exp[i]<4000) shougou=0;
+                       else if(p_ptr->skill_exp[i]<6000) shougou=1;
+                       else if(p_ptr->skill_exp[i]<7000) shougou=2;
+                       else if(p_ptr->skill_exp[i]<8000) shougou=3;
                        else shougou=4;
                }
                fprintf(fff,"%-20s ",skill_name[i]);
-               if (skill_exp[i] == s_info[p_ptr->pclass].s_max[i]) fprintf(fff,"!");
+               if (p_ptr->skill_exp[i] == s_info[p_ptr->pclass].s_max[i]) fprintf(fff,"!");
                else fprintf(fff," ");
                fprintf(fff,"%s",shougou_moji[shougou]);
-               if (cheat_xtra) fprintf(fff," %d",skill_exp[i]);
+               if (cheat_xtra) fprintf(fff," %d",p_ptr->skill_exp[i]);
                fprintf(fff,"\n");
        }
 
@@ -6488,7 +6631,7 @@ static void do_cmd_knowledge_objects(void)
                object_kind *k_ptr = &k_info[k];
 
                /* Hack -- skip artifacts */
-               if (k_ptr->flags3 & (TR3_INSTA_ART)) continue;
+               if (k_ptr->gen_flags & (TRG_INSTA_ART)) continue;
 
                /* List known flavored objects */
                if (k_ptr->flavor && k_ptr->aware)
@@ -6530,7 +6673,7 @@ static void do_cmd_knowledge_objects(void)
 * List virtues & status
 *
 */
-void do_cmd_knowledge_kubi(void)
+static void do_cmd_knowledge_kubi(void)
 {
        int i;
        FILE *fff;
@@ -6594,7 +6737,7 @@ show_file(TRUE, file_name, "
 * List virtues & status
 *
 */
-void do_cmd_knowledge_virtues(void)
+static void do_cmd_knowledge_virtues(void)
 {
        FILE *fff;
        
@@ -6642,7 +6785,7 @@ show_file(TRUE, file_name, "Ȭ
 * Dungeon
 *
 */
-void do_cmd_knowledge_dungeon(void)
+static void do_cmd_knowledge_dungeon(void)
 {
        FILE *fff;
        
@@ -6723,7 +6866,7 @@ static void do_cmd_knowledge_stat(void)
        
        if (fff)
        {
-               percent = (int)(((long)player_hp[PY_MAX_LEVEL - 1] * 200L) /
+               percent = (int)(((long)p_ptr->player_hp[PY_MAX_LEVEL - 1] * 200L) /
                        (2 * p_ptr->hitdie +
                        ((PY_MAX_LEVEL - 1+3) * (p_ptr->hitdie + 1))));
 
@@ -7093,7 +7236,7 @@ sprintf(rand_tmp_str,"%s (%d 
        if (!total) fprintf(fff, "Nothing.\n");
 #endif
 
-       if (wizard) {
+       if (p_ptr->wizard) {
 #ifdef JP
        fprintf(fff, "\n¡Ô»Ä¤ê¤Î¥é¥ó¥À¥à¥¯¥¨¥¹¥È¡Õ\n");
 #else
@@ -7148,7 +7291,7 @@ sprintf(rand_tmp_str,"%s (%d 
 * List my home
 *
 */
-void do_cmd_knowledge_home(void)
+static void do_cmd_knowledge_home(void)
 {
        FILE *fff;
        
@@ -7279,8 +7422,8 @@ static void do_cmd_knowledge_autopick(void)
 
        for (k = 0; k < max_autopick; k++)
        {
-               char *tmp;
-               byte act = autopick_action[k];
+               cptr tmp;
+               byte act = autopick_list[k].action;
                if (act & DONT_AUTOPICK)
                {
 #ifdef JP
@@ -7311,9 +7454,9 @@ static void do_cmd_knowledge_autopick(void)
                else
                        fprintf(fff, "%11s", format("(%s)", tmp));
 
-               fprintf(fff, " %s", autopick_name[k]);
-               if(autopick_insc[k] != NULL)
-                       fprintf(fff, " {%s}", autopick_insc[k]);
+               tmp = autopick_line_from_entry(&autopick_list[k]);
+               fprintf(fff, " %s", tmp);
+               string_free(tmp);
                fprintf(fff, "\n");
        }
        /* Close the file */
@@ -7330,7 +7473,6 @@ static void do_cmd_knowledge_autopick(void)
 }
 
 
-
 /*
  * Interact with "knowledge"
  */
@@ -7523,18 +7665,8 @@ void do_cmd_time(void)
 
        FILE *fff;
 
-       s32b len = 20L * TOWN_DAWN;
-       s32b tick = turn % len + len / 4;
+       extract_day_hour_min(&day, &hour, &min);
 
-       if ((p_ptr->prace == RACE_VAMPIRE) ||
-           (p_ptr->prace == RACE_SKELETON) ||
-           (p_ptr->prace == RACE_ZOMBIE) ||
-           (p_ptr->prace == RACE_SPECTRE))
-               day = (turn - (15L * TOWN_DAWN))/ len + 1;
-       else
-               day = (turn + (5L * TOWN_DAWN))/ len + 1;
-       hour = (24 * tick / len) % 24;
-       min = (1440 * tick / len) % 60;
        full = hour * 100 + min;
 
        start = 9999;