OSDN Git Service

[Refactor] #38997 #37353 update_smell() に floor_type * 引数を追加して floor.c/h へ移動. / Add...
authordeskull <deskull@users.sourceforge.jp>
Mon, 4 Nov 2019 06:50:20 +0000 (15:50 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Mon, 4 Nov 2019 06:50:20 +0000 (15:50 +0900)
src/core.c
src/floor.c
src/floor.h
src/grid.c
src/grid.h

index 536c168..87fadba 100644 (file)
@@ -4882,7 +4882,7 @@ static void process_player(player_type *creature_ptr)
        }
 
        /* Update scent trail */
-       update_smell();
+       update_smell(creature_ptr->current_floor_ptr);
 }
 
 /*!
index b8944eb..e8913eb 100644 (file)
@@ -85,3 +85,87 @@ void place_secret_door(floor_type *floor_ptr, POSITION y, POSITION x, int type)
                delete_monster(y, x);
        }
 }
+
+
+static int scent_when = 0;
+
+/*
+ * Characters leave scent trails for perceptive monsters to track.
+ *
+ * Smell is rather more limited than sound.  Many creatures cannot use
+ * it at all, it doesn't extend very far outwards from the character's
+ * current position, and monsters can use it to home in the character,
+ * but not to run away from him.
+ *
+ * Smell is valued according to age.  When a character takes his current_world_ptr->game_turn,
+ * scent is aged by one, and new scent of the current age is laid down.
+ * Speedy characters leave more scent, true, but it also ages faster,
+ * which makes it harder to hunt them down.
+ *
+ * Whenever the age count loops, most of the scent trail is erased and
+ * the age of the remainder is recalculated.
+ */
+void update_smell(floor_type *floor_ptr)
+{
+       POSITION i, j;
+       POSITION y, x;
+
+       /* Create a table that controls the spread of scent */
+       const int scent_adjust[5][5] =
+       {
+               { -1, 0, 0, 0,-1 },
+               {  0, 1, 1, 1, 0 },
+               {  0, 1, 2, 1, 0 },
+               {  0, 1, 1, 1, 0 },
+               { -1, 0, 0, 0,-1 },
+       };
+
+       /* Loop the age and adjust scent values when necessary */
+       if (++scent_when == 254)
+       {
+               /* Scan the entire dungeon */
+               for (y = 0; y < floor_ptr->height; y++)
+               {
+                       for (x = 0; x < floor_ptr->width; x++)
+                       {
+                               int w = floor_ptr->grid_array[y][x].when;
+                               floor_ptr->grid_array[y][x].when = (w > 128) ? (w - 128) : 0;
+                       }
+               }
+
+               /* Restart */
+               scent_when = 126;
+       }
+
+
+       /* Lay down new scent */
+       for (i = 0; i < 5; i++)
+       {
+               for (j = 0; j < 5; j++)
+               {
+                       grid_type *g_ptr;
+
+                       /* Translate table to map grids */
+                       y = i + p_ptr->y - 2;
+                       x = j + p_ptr->x - 2;
+
+                       /* Check Bounds */
+                       if (!in_bounds(floor_ptr, y, x)) continue;
+
+                       g_ptr = &floor_ptr->grid_array[y][x];
+
+                       /* Walls, water, and lava cannot hold scent. */
+                       if (!cave_have_flag_grid(g_ptr, FF_MOVE) && !is_closed_door(g_ptr->feat)) continue;
+
+                       /* Grid must not be blocked by walls from the character */
+                       if (!player_has_los_bold(y, x)) continue;
+
+                       /* Note grids that are too far away */
+                       if (scent_adjust[i][j] == -1) continue;
+
+                       /* Mark the grid with new scent */
+                       g_ptr->when = scent_when + scent_adjust[i][j];
+               }
+       }
+}
+
index 81c3db3..72c25cc 100644 (file)
@@ -372,5 +372,7 @@ extern saved_floor_type saved_floors[MAX_SAVED_FLOORS];
 #define GRID_X(G) \
        ((int)((G) % 256U))
 
+extern void update_smell(floor_type *floor_ptr);
+
 extern void place_secret_door(floor_type *floor_ptr, POSITION y, POSITION x, int type);
 extern void place_locked_door(floor_type *floor_ptr, POSITION y, POSITION x);
index 4b8be00..5be9252 100644 (file)
@@ -1638,91 +1638,6 @@ void update_flow(void)
        }
 }
 
-
-static int scent_when = 0;
-
-/*
- * Characters leave scent trails for perceptive monsters to track.
- *
- * Smell is rather more limited than sound.  Many creatures cannot use
- * it at all, it doesn't extend very far outwards from the character's
- * current position, and monsters can use it to home in the character,
- * but not to run away from him.
- *
- * Smell is valued according to age.  When a character takes his current_world_ptr->game_turn,
- * scent is aged by one, and new scent of the current age is laid down.
- * Speedy characters leave more scent, true, but it also ages faster,
- * which makes it harder to hunt them down.
- *
- * Whenever the age count loops, most of the scent trail is erased and
- * the age of the remainder is recalculated.
- */
-void update_smell(void)
-{
-       POSITION i, j;
-       POSITION y, x;
-
-       /* Create a table that controls the spread of scent */
-       const int scent_adjust[5][5] =
-       {
-               { -1, 0, 0, 0,-1 },
-               {  0, 1, 1, 1, 0 },
-               {  0, 1, 2, 1, 0 },
-               {  0, 1, 1, 1, 0 },
-               { -1, 0, 0, 0,-1 },
-       };
-
-       /* Loop the age and adjust scent values when necessary */
-       if (++scent_when == 254)
-       {
-               /* Scan the entire dungeon */
-               for (y = 0; y < p_ptr->current_floor_ptr->height; y++)
-               {
-                       for (x = 0; x < p_ptr->current_floor_ptr->width; x++)
-                       {
-                               int w = p_ptr->current_floor_ptr->grid_array[y][x].when;
-                               p_ptr->current_floor_ptr->grid_array[y][x].when = (w > 128) ? (w - 128) : 0;
-                       }
-               }
-
-               /* Restart */
-               scent_when = 126;
-       }
-
-
-       /* Lay down new scent */
-       for (i = 0; i < 5; i++)
-       {
-               for (j = 0; j < 5; j++)
-               {
-                       grid_type *g_ptr;
-
-                       /* Translate table to map grids */
-                       y = i + p_ptr->y - 2;
-                       x = j + p_ptr->x - 2;
-
-                       /* Check Bounds */
-                       if (!in_bounds(p_ptr->current_floor_ptr, y, x)) continue;
-
-                       g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
-
-                       /* Walls, water, and lava cannot hold scent. */
-                       if (!cave_have_flag_grid(g_ptr, FF_MOVE) && !is_closed_door(g_ptr->feat)) continue;
-
-                       /* Grid must not be blocked by walls from the character */
-                       if (!player_has_los_bold(y, x)) continue;
-
-                       /* Note grids that are too far away */
-                       if (scent_adjust[i][j] == -1) continue;
-
-                       /* Mark the grid with new scent */
-                       g_ptr->when = scent_when + scent_adjust[i][j];
-               }
-       }
-}
-
-
-
 /*
  * Change the "feat" flag for a grid, and notice/redraw the grid
  */
index 74e7f19..d6a4cce 100644 (file)
@@ -415,7 +415,6 @@ extern void lite_spot(POSITION y, POSITION x);
 extern void delayed_visual_update(void);
 extern void forget_flow(void);
 extern void update_flow(void);
-extern void update_smell(void);
 extern void cave_set_feat(POSITION y, POSITION x, FEAT_IDX feat);
 extern FEAT_IDX conv_dungeon_feat(FEAT_IDX newfeat);
 extern FEAT_IDX feat_state(FEAT_IDX feat, int action);