OSDN Git Service

呪術で途中で解呪しても影のクロークの効果が消えないのを修正。解呪すると詠唱を中止する。
[hengband/hengband.git] / src / main-gcu.c
index 43f995d..0afe8df 100644 (file)
@@ -651,7 +651,7 @@ static bool check_file(cptr s)
 /*
  * Initialize sound
  */
-static bool init_sound()
+static bool init_sound(void)
 {
    /* Initialize once */
    if (!can_use_sound)
@@ -664,14 +664,14 @@ static bool init_sound()
       /* Prepare the sounds */
       for (i = 1; i < SOUND_MAX; i++)
       {
-         /* Extract name of sound file */
-         sprintf(wav, "%s.wav", angband_sound_name[i]);
+        /* Extract name of sound file */
+        sprintf(wav, "%s.wav", angband_sound_name[i]);
 
-         /* Access the sound */
-         path_build(buf, 1024, ANGBAND_DIR_XTRA_SOUND, wav);
+        /* Access the sound */
+        path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_SOUND, wav);
 
-         /* Save the sound filename, if it exists */
-         if (check_file(buf)) sound_file[i] = string_make(buf);
+        /* Save the sound filename, if it exists */
+        if (check_file(buf)) sound_file[i] = string_make(buf);
       }
 
       /* Sound available */
@@ -929,8 +929,8 @@ static errr Term_xtra_gcu_react(void)
        {
                /* Set one color (note scaling) */
                init_color(i, angband_color_table[i][1] * 1000 / 255,
-                             angband_color_table[i][2] * 1000 / 255,
-                             angband_color_table[i][3] * 1000 / 255);
+                             angband_color_table[i][2] * 1000 / 255,
+                             angband_color_table[i][3] * 1000 / 255);
        }
 
 #endif
@@ -964,7 +964,7 @@ static errr Term_xtra_gcu(int n, int v)
 #ifdef USE_SOUND
       /* Make a special sound */
       case TERM_XTRA_SOUND:
-         return (Term_xtra_gcu_sound(v));
+        return (Term_xtra_gcu_sound(v));
 #endif
 
       /* Flush the Curses buffer */
@@ -1174,6 +1174,17 @@ static errr term_data_init(term_data *td, int rows, int cols, int y, int x)
    return (0);
 }
 
+
+static void hook_quit(cptr str)
+{
+       /* Unused */
+       (void)str;
+
+       /* Exit curses */
+       endwin();
+}
+
+
 /*
  * Prepare "curses" for use by the file "term.c"
  *
@@ -1189,10 +1200,15 @@ errr init_gcu(int argc, char *argv[])
    int num_term = 4, next_win = 0;
    char path[1024];
 
+   /* Unused */
+   (void)argc;
+   (void)argv;
+
+
 #ifdef USE_SOUND
 
    /* Build the "sound" path */
-   path_build(path, 1024, ANGBAND_DIR_XTRA, "sound");
+   path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "sound");
 
    /* Allocate the path */
    ANGBAND_DIR_XTRA_SOUND = string_make(path);
@@ -1210,6 +1226,10 @@ errr init_gcu(int argc, char *argv[])
    if (initscr() == (WINDOW*)ERR) return (-1);
 #endif
 
+   /* Activate hooks */
+   quit_aux = hook_quit;
+   core_aux = hook_quit;
+
    /* Hack -- Require large screen, or Quit with message */
    i = ((LINES < 24) || (COLS < 80));
    if (i) quit("Angband needs an 80x24 'curses' screen");
@@ -1221,12 +1241,12 @@ errr init_gcu(int argc, char *argv[])
 
    /* Do we have color, and enough color, available? */
    can_use_color = ((start_color() != ERR) && has_colors() &&
-                    (COLORS >= 8) && (COLOR_PAIRS >= 8));
+                   (COLORS >= 8) && (COLOR_PAIRS >= 8));
 
 #ifdef REDEFINE_COLORS
        /* Can we change colors? */
        can_fix_color = (can_use_color && can_change_color() &&
-                        (COLORS >= 16) && (COLOR_PAIRS > 8));
+                        (COLORS >= 16) && (COLOR_PAIRS > 8));
 #endif
 
    /* Attempt to use customized colors */
@@ -1235,17 +1255,17 @@ errr init_gcu(int argc, char *argv[])
       /* Prepare the color pairs */
       for (i = 1; i <= 63; i++)
       {
-         /* Reset the color */
-         if (init_pair(i, (i - 1) % 8, (i - 1) / 8) == ERR)
-         {
-            quit("Color pair init failed");
-         }
+        /* Reset the color */
+        if (init_pair(i, (i - 1) % 8, (i - 1) / 8) == ERR)
+        {
+           quit("Color pair init failed");
+        }
 
        /* Set up the colormap */
        colortable[i - 1] = (COLOR_PAIR(i) | A_NORMAL);
        colortable[i + 7] = (COLOR_PAIR(i) | A_BRIGHT);
 
-        /* XXX XXX XXX Take account of "gamma correction" */
+       /* XXX XXX XXX Take account of "gamma correction" */
 
        /* Prepare the "Angband Colors" */
        Term_xtra_gcu_react();
@@ -1254,7 +1274,7 @@ errr init_gcu(int argc, char *argv[])
    /* Attempt to use colors */
    else if (can_use_color)
    {
-                /* Color-pair 0 is *always* WHITE on BLACK */
+               /* Color-pair 0 is *always* WHITE on BLACK */
 
                /* Prepare the color pairs */
                init_pair(1, COLOR_RED,     COLOR_BLACK);
@@ -1295,11 +1315,11 @@ errr init_gcu(int argc, char *argv[])
       /* Initialize (if needed) */
       if (arg_sound && !init_sound())
       {
-         /* Warning */
-         plog("Cannot initialize sound!");
+        /* Warning */
+        plog("Cannot initialize sound!");
 
-         /* Cannot enable */
-         arg_sound = FALSE;
+        /* Cannot enable */
+        arg_sound = FALSE;
       }
 
       /* Change setting */
@@ -1335,6 +1355,7 @@ errr init_gcu(int argc, char *argv[])
    cbreak();
    noecho();
    nonl();
+   raw();
 
    /* Extract the game keymap */
    keymap_game_prepare();
@@ -1348,33 +1369,33 @@ errr init_gcu(int argc, char *argv[])
 
       switch (i)
       {
-         /* Upper left */
-         case 0: rows = 24;
-            cols = 80;
-            y = x = 0;
-            break;
-         /* Lower left */
-         case 1: rows = LINES - 25;
-            cols = 80;
-            y = 24;
-            x = 0;
-            break;
-         /* Upper right */
-         case 2: rows = 24;
-            cols = COLS - 81;
-            y = 0;
-            x = 81;
-            break;
-         /* Lower right */
-         case 3: rows = LINES - 25;
-            cols = COLS - 81;
-            y = 24;
-            x = 81;
-            break;
-         /* XXX */
-         default: rows = cols = 0;
-             y = x = 0;
-             break;
+        /* Upper left */
+        case 0: rows = 24;
+           cols = 80;
+           y = x = 0;
+           break;
+        /* Lower left */
+        case 1: rows = LINES - 25;
+           cols = 80;
+           y = 24;
+           x = 0;
+           break;
+        /* Upper right */
+        case 2: rows = 24;
+           cols = COLS - 81;
+           y = 0;
+           x = 81;
+           break;
+        /* Lower right */
+        case 3: rows = LINES - 25;
+           cols = COLS - 81;
+           y = 24;
+           x = 81;
+           break;
+        /* XXX */
+        default: rows = cols = 0;
+            y = x = 0;
+            break;
       }
 
       /* No non-windows */