OSDN Git Service

Simplify the critical-shot-calcuration
[hengband/hengband.git] / src / cave.c
index 7739bf8..2939187 100644 (file)
@@ -968,7 +968,7 @@ void map_info(int y, int x, byte *ap, char *cp, byte *tap, char *tcp)
                        else if (darkened_grid(c_ptr))
                        {
                                /* Unsafe cave grid -- idea borrowed from Unangband */
-                               feat = (view_unsafe_grids && (c_ptr->info & CAVE_UNSAFE)) ? FEAT_UNDETECTED : FEAT_NONE;
+                               feat = (view_unsafe_grids && (c_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
 
                                /* Access darkness */
                                f_ptr = &f_info[feat];
@@ -1019,10 +1019,7 @@ void map_info(int y, int x, byte *ap, char *cp, byte *tap, char *tcp)
                else
                {
                        /* Unsafe cave grid -- idea borrowed from Unangband */
-                       if (view_unsafe_grids && (c_ptr->info & (CAVE_UNSAFE)))
-                               feat = FEAT_UNDETECTED;
-                       else
-                               feat = FEAT_NONE;
+                       feat = (view_unsafe_grids && (c_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
 
                        /* Access darkness */
                        f_ptr = &f_info[feat];
@@ -1061,7 +1058,7 @@ void map_info(int y, int x, byte *ap, char *cp, byte *tap, char *tcp)
                                if (have_flag(f_ptr->flags, FF_LOS) && have_flag(f_ptr->flags, FF_PROJECT))
                                {
                                        /* Unsafe cave grid -- idea borrowed from Unangband */
-                                       feat = (view_unsafe_grids && (c_ptr->info & CAVE_UNSAFE)) ? FEAT_UNDETECTED : FEAT_NONE;
+                                       feat = (view_unsafe_grids && (c_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
 
                                        /* Access darkness */
                                        f_ptr = &f_info[feat];
@@ -1135,10 +1132,7 @@ void map_info(int y, int x, byte *ap, char *cp, byte *tap, char *tcp)
                else
                {
                        /* Unsafe cave grid -- idea borrowed from Unangband */
-                       if (view_unsafe_grids && (c_ptr->info & (CAVE_UNSAFE)))
-                               feat = FEAT_UNDETECTED;
-                       else
-                               feat = FEAT_NONE;
+                       feat = (view_unsafe_grids && (c_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
 
                        /* Access feature */
                        f_ptr = &f_info[feat];
@@ -1534,6 +1528,9 @@ void note_spot(int y, int x)
                        c_ptr->info |= (CAVE_MARK);
                }
        }
+
+       /* Memorize terrain of the grid */
+       c_ptr->info |= (CAVE_KNOWN);
 }
 
 
@@ -1572,7 +1569,7 @@ void display_dungeon(void)
                                /* Clear out-of-bound tiles */
 
                                /* Access darkness */
-                               feature_type *f_ptr = &f_info[FEAT_NONE];
+                               feature_type *f_ptr = &f_info[feat_none];
 
                                /* Normal attr */
                                a = f_ptr->x_attr[F_LIT_STANDARD];
@@ -2138,33 +2135,33 @@ void display_map(int *cy, int *cx)
        for (y = 0; y < (hgt + 2); y++)
        {
                /* Free one row each array */
-               C_FREE(ma[y], (wid + 2), byte);
-               C_FREE(mc[y], (wid + 2), char);
-               C_FREE(mp[y], (wid + 2), byte);
-               C_FREE(match_autopick_yx[y], (wid + 2), int);
-               C_FREE(object_autopick_yx[y], (wid + 2), object_type **);
+               C_KILL(ma[y], (wid + 2), byte);
+               C_KILL(mc[y], (wid + 2), char);
+               C_KILL(mp[y], (wid + 2), byte);
+               C_KILL(match_autopick_yx[y], (wid + 2), int);
+               C_KILL(object_autopick_yx[y], (wid + 2), object_type *);
        }
 
        /* Free each line map */
-       C_FREE(ma, (hgt + 2), byte_ptr);
-       C_FREE(mc, (hgt + 2), char_ptr);
-       C_FREE(mp, (hgt + 2), byte_ptr);
-       C_FREE(match_autopick_yx, (hgt + 2), sint_ptr);
-       C_FREE(object_autopick_yx, (hgt + 2), object_type **);
+       C_KILL(ma, (hgt + 2), byte_ptr);
+       C_KILL(mc, (hgt + 2), char_ptr);
+       C_KILL(mp, (hgt + 2), byte_ptr);
+       C_KILL(match_autopick_yx, (hgt + 2), sint_ptr);
+       C_KILL(object_autopick_yx, (hgt + 2), object_type **);
 
        /* Free each line map */
        for (y = 0; y < (cur_hgt + 2); y++)
        {
                /* Free one row each array */
-               C_FREE(bigma[y], (cur_wid + 2), byte);
-               C_FREE(bigmc[y], (cur_wid + 2), char);
-               C_FREE(bigmp[y], (cur_wid + 2), byte);
+               C_KILL(bigma[y], (cur_wid + 2), byte);
+               C_KILL(bigmc[y], (cur_wid + 2), char);
+               C_KILL(bigmp[y], (cur_wid + 2), byte);
        }
 
        /* Free each line map */
-       C_FREE(bigma, (cur_hgt + 2), byte_ptr);
-       C_FREE(bigmc, (cur_hgt + 2), char_ptr);
-       C_FREE(bigmp, (cur_hgt + 2), byte_ptr);
+       C_KILL(bigma, (cur_hgt + 2), byte_ptr);
+       C_KILL(bigmc, (cur_hgt + 2), char_ptr);
+       C_KILL(bigmp, (cur_hgt + 2), byte_ptr);
 }
 
 
@@ -2744,7 +2741,7 @@ void update_lite(void)
                                if (d > p) continue;
 
                                /* Viewable, nearby, grids get "torch lit" */
-                               if (player_has_los_bold(y, x))
+                               if (cave[y][x].info & CAVE_VIEW)
                                {
                                        /* This grid is "torch lit" */
                                        cave_lite_hack(y, x);
@@ -4310,6 +4307,9 @@ void map_area(int range)
 
                        c_ptr = &cave[y][x];
 
+                       /* Memorize terrain of the grid */
+                       c_ptr->info |= (CAVE_KNOWN);
+
                        /* Feature code (applying "mimic" field) */
                        feat = get_feat_mimic(c_ptr);
                        f_ptr = &f_info[feat];
@@ -4398,6 +4398,9 @@ void wiz_lite(bool ninja)
                {
                        cave_type *c_ptr = &cave[y][x];
 
+                       /* Memorize terrain of the grid */
+                       c_ptr->info |= (CAVE_KNOWN);
+
                        /* Feature code (applying "mimic" field) */
                        feat = get_feat_mimic(c_ptr);
                        f_ptr = &f_info[feat];
@@ -4477,7 +4480,7 @@ void wiz_dark(void)
                        cave_type *c_ptr = &cave[y][x];
 
                        /* Process the grid */
-                       c_ptr->info &= ~(CAVE_MARK | CAVE_IN_DETECT);
+                       c_ptr->info &= ~(CAVE_MARK | CAVE_IN_DETECT | CAVE_KNOWN);
                        c_ptr->info |= (CAVE_UNSAFE);
                }
        }
@@ -4508,9 +4511,12 @@ void wiz_dark(void)
                if (o_ptr->held_m_idx) continue;
 
                /* Forget the object */
-               o_ptr->marked = 0;
+               o_ptr->marked &= OM_TOUCHED;
        }
 
+       /* Forget travel route when we have forgotten map */
+       forget_travel_flow();
+
        /* Mega-Hack -- Forget the view and lite */
        p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
 
@@ -4654,7 +4660,7 @@ int conv_dungeon_feat(int newfeat)
 
        if (have_flag(f_ptr->flags, FF_CONVERT))
        {
-               switch (f_ptr->power)
+               switch (f_ptr->subtype)
                {
                case CONVERT_TYPE_FLOOR:
                        return floor_type[randint0(100)];
@@ -5009,10 +5015,12 @@ void object_kind_track(int k_idx)
  *
  * All disturbance cancels repeated commands, resting, and running.
  */
-void disturb(int stop_search, int unused_flag)
+void disturb(int stop_search, int stop_travel)
 {
+#ifndef TRAVEL
        /* Unused */
-       unused_flag = unused_flag;
+       stop_travel = stop_travel;
+#endif
 
        /* Cancel auto-commands */
        /* command_new = 0; */
@@ -5050,6 +5058,20 @@ void disturb(int stop_search, int unused_flag)
                p_ptr->update |= (PU_FLOW);
        }
 
+#ifdef TRAVEL
+       if (stop_travel)
+       {
+               /* Cancel */
+               travel.run = 0;
+
+               /* Check for new panel if appropriate */
+               if (center_player && !center_running) verify_panel();
+
+               /* Calculate torch radius */
+               p_ptr->update |= (PU_TORCH);
+       }
+#endif
+
        /* Flush the input if requested */
        if (flush_disturb) flush();
 }