OSDN Git Service

[Refactor] #37353 コメント整理 / Refactor comments.
[hengband/hengband.git] / src / grid.c
1 /*!
2  * @file grid.c
3  * @brief ダンジョンの生成処理の基幹部分 / low-level dungeon creation primitives
4  * @date 2014/01/04
5  * @author
6  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke\n
7  *\n
8  * This software may be copied and distributed for educational, research,\n
9  * and not for profit purposes provided that this copyright and statement\n
10  * are included in all such copies.  Other copyrights may also apply.\n
11  * \n
12  * 2014 Deskull Doxygen向けのコメント整理\n
13  */
14
15 #include "angband.h"
16 #include "generate.h"
17 #include "grid.h"
18 #include "trap.h"
19
20
21 /*!
22  * @brief 新規フロアに入りたてのプレイヤーをランダムな場所に配置する / Returns random co-ordinates for player/monster/object
23  * @return 配置に成功したらTRUEを返す
24  */
25 bool new_player_spot(void)
26 {
27         POSITION y = 0, x = 0;
28         int max_attempts = 10000;
29
30         cave_type *c_ptr;
31         feature_type *f_ptr;
32
33         /* Place the player */
34         while (max_attempts--)
35         {
36                 /* Pick a legal spot */
37                 y = (POSITION)rand_range(1, cur_hgt - 2);
38                 x = (POSITION)rand_range(1, cur_wid - 2);
39
40                 c_ptr = &cave[y][x];
41
42                 /* Must be a "naked" floor grid */
43                 if (c_ptr->m_idx) continue;
44                 if (dun_level)
45                 {
46                         f_ptr = &f_info[c_ptr->feat];
47
48                         if (max_attempts > 5000) /* Rule 1 */
49                         {
50                                 if (!have_flag(f_ptr->flags, FF_FLOOR)) continue;
51                         }
52                         else /* Rule 2 */
53                         {
54                                 if (!have_flag(f_ptr->flags, FF_MOVE)) continue;
55                                 if (have_flag(f_ptr->flags, FF_HIT_TRAP)) continue;
56                         }
57
58                         /* Refuse to start on anti-teleport grids in dungeon */
59                         if (!have_flag(f_ptr->flags, FF_TELEPORTABLE)) continue;
60                 }
61                 if (!player_can_enter(c_ptr->feat, 0)) continue;
62                 if (!in_bounds(y, x)) continue;
63
64                 /* Refuse to start on anti-teleport grids */
65                 if (c_ptr->info & (CAVE_ICKY)) continue;
66
67                 break;
68         }
69
70         if (max_attempts < 1) /* Should be -1, actually if we failed... */
71                 return FALSE;
72
73         /* Save the new player grid */
74         p_ptr->y = y;
75         p_ptr->x = x;
76
77         return TRUE;
78 }
79
80
81
82 /*!
83  * @brief 所定の位置に上り階段か下り階段を配置する / Place an up/down staircase at given location
84  * @param y 配置を試みたいマスのY座標
85  * @param x 配置を試みたいマスのX座標
86  * @return なし
87  */
88 void place_random_stairs(POSITION y, POSITION x)
89 {
90         bool up_stairs = TRUE;
91         bool down_stairs = TRUE;
92         cave_type *c_ptr;
93
94         /* Paranoia */
95         c_ptr = &cave[y][x];
96         if (!is_floor_grid(c_ptr) || c_ptr->o_idx) return;
97
98         /* Town */
99         if (!dun_level)
100                 up_stairs = FALSE;
101
102         /* Ironman */
103         if (ironman_downward)
104                 up_stairs = FALSE;
105
106         /* Bottom */
107         if (dun_level >= d_info[dungeon_type].maxdepth)
108                 down_stairs = FALSE;
109
110         /* Quest-level */
111         if (quest_number(dun_level) && (dun_level > 1))
112                 down_stairs = FALSE;
113
114         /* We can't place both */
115         if (down_stairs && up_stairs)
116         {
117                 /* Choose a staircase randomly */
118                 if (randint0(100) < 50)
119                         up_stairs = FALSE;
120                 else
121                         down_stairs = FALSE;
122         }
123
124         /* Place the stairs */
125         if (up_stairs)
126                 place_up_stairs(y, x);
127         else if (down_stairs)
128                 place_down_stairs(y, x);
129 }
130
131 /*!
132  * @brief 所定の位置にさまざまな状態や種類のドアを配置する / Place a random type of door at the given location
133  * @param y ドアの配置を試みたいマスのY座標
134  * @param x ドアの配置を試みたいマスのX座標
135  * @param room 部屋に接している場合向けのドア生成か否か
136  * @return なし
137  */
138 void place_random_door(POSITION y, POSITION x, bool room)
139 {
140         int tmp, type;
141         FEAT_IDX feat = feat_none;
142         cave_type *c_ptr = &cave[y][x];
143
144         /* Initialize mimic info */
145         c_ptr->mimic = 0;
146
147         if (d_info[dungeon_type].flags1 & DF1_NO_DOORS)
148         {
149                 place_floor_bold(y, x);
150                 return;
151         }
152
153         type = ((d_info[dungeon_type].flags1 & DF1_CURTAIN) &&
154                 one_in_((d_info[dungeon_type].flags1 & DF1_NO_CAVE) ? 16 : 256)) ? DOOR_CURTAIN :
155                 ((d_info[dungeon_type].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR);
156
157         /* Choose an object */
158         tmp = randint0(1000);
159
160         /* Open doors (300/1000) */
161         if (tmp < 300)
162         {
163                 /* Create open door */
164                 feat = feat_door[type].open;
165         }
166
167         /* Broken doors (100/1000) */
168         else if (tmp < 400)
169         {
170                 /* Create broken door */
171                 feat = feat_door[type].broken;
172         }
173
174         /* Secret doors (200/1000) */
175         else if (tmp < 600)
176         {
177                 /* Create secret door */
178                 place_closed_door(y, x, type);
179
180                 if (type != DOOR_CURTAIN)
181                 {
182                         /* Hide. If on the edge of room, use outer wall. */
183                         c_ptr->mimic = room ? feat_wall_outer : fill_type[randint0(100)];
184
185                         /* Floor type terrain cannot hide a door */
186                         if (feat_supports_los(c_ptr->mimic) && !feat_supports_los(c_ptr->feat))
187                         {
188                                 if (have_flag(f_info[c_ptr->mimic].flags, FF_MOVE) || have_flag(f_info[c_ptr->mimic].flags, FF_CAN_FLY))
189                                 {
190                                         c_ptr->feat = one_in_(2) ? c_ptr->mimic : floor_type[randint0(100)];
191                                 }
192                                 c_ptr->mimic = 0;
193                         }
194                 }
195         }
196
197         /* Closed, locked, or stuck doors (400/1000) */
198         else place_closed_door(y, x, type);
199
200         if (tmp < 400)
201         {
202                 if (feat != feat_none)
203                 {
204                         set_cave_feat(y, x, feat);
205                 }
206                 else
207                 {
208                         place_floor_bold(y, x);
209                 }
210         }
211
212         delete_monster(y, x);
213 }
214
215 /*!
216  * @brief 所定の位置に各種の閉じたドアを配置する / Place a random type of normal door at the given location.
217  * @param y ドアの配置を試みたいマスのY座標
218  * @param x ドアの配置を試みたいマスのX座標
219  * @param type ドアの地形ID
220  * @return なし
221  */
222 void place_closed_door(POSITION y, POSITION x, int type)
223 {
224         int tmp;
225         FEAT_IDX feat = feat_none;
226
227         if (d_info[dungeon_type].flags1 & DF1_NO_DOORS)
228         {
229                 place_floor_bold(y, x);
230                 return;
231         }
232
233         /* Choose an object */
234         tmp = randint0(400);
235
236         /* Closed doors (300/400) */
237         if (tmp < 300)
238         {
239                 /* Create closed door */
240                 feat = feat_door[type].closed;
241         }
242
243         /* Locked doors (99/400) */
244         else if (tmp < 399)
245         {
246                 /* Create locked door */
247                 feat = feat_locked_door_random(type);
248         }
249
250         /* Stuck doors (1/400) */
251         else
252         {
253                 /* Create jammed door */
254                 feat = feat_jammed_door_random(type);
255         }
256
257         if (feat != feat_none)
258         {
259                 cave_set_feat(y, x, feat);
260
261                 /* Now it is not floor */
262                 cave[y][x].info &= ~(CAVE_MASK);
263         }
264         else
265         {
266                 place_floor_bold(y, x);
267         }
268 }
269
270 /*!
271 * @brief 鍵のかかったドアを配置する
272 * @param y 配置したいフロアのY座標
273 * @param x 配置したいフロアのX座標
274 * @return なし
275 */
276 void place_locked_door(POSITION y, POSITION x)
277 {
278         if (d_info[dungeon_type].flags1 & DF1_NO_DOORS)
279         {
280                 place_floor_bold(y, x);
281         }
282         else
283         {
284                 set_cave_feat(y, x, feat_locked_door_random((d_info[dungeon_type].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR));
285                 cave[y][x].info &= ~(CAVE_FLOOR);
286                 delete_monster(y, x);
287         }
288 }
289
290
291 /*!
292 * @brief 隠しドアを配置する
293 * @param y 配置したいフロアのY座標
294 * @param x 配置したいフロアのX座標
295 * @param type DOOR_DEFAULT / DOOR_DOOR / DOOR_GLASS_DOOR / DOOR_CURTAIN のいずれか
296 * @return なし
297 */
298 void place_secret_door(POSITION y, POSITION x, int type)
299 {
300         if (d_info[dungeon_type].flags1 & DF1_NO_DOORS)
301         {
302                 place_floor_bold(y, x);
303         }
304         else
305         {
306                 cave_type *c_ptr = &cave[y][x];
307
308                 if (type == DOOR_DEFAULT)
309                 {
310                         type = ((d_info[dungeon_type].flags1 & DF1_CURTAIN) &&
311                                 one_in_((d_info[dungeon_type].flags1 & DF1_NO_CAVE) ? 16 : 256)) ? DOOR_CURTAIN :
312                                 ((d_info[dungeon_type].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR);
313                 }
314
315                 /* Create secret door */
316                 place_closed_door(y, x, type);
317
318                 if (type != DOOR_CURTAIN)
319                 {
320                         /* Hide by inner wall because this is used in rooms only */
321                         c_ptr->mimic = feat_wall_inner;
322
323                         /* Floor type terrain cannot hide a door */
324                         if (feat_supports_los(c_ptr->mimic) && !feat_supports_los(c_ptr->feat))
325                         {
326                                 if (have_flag(f_info[c_ptr->mimic].flags, FF_MOVE) || have_flag(f_info[c_ptr->mimic].flags, FF_CAN_FLY))
327                                 {
328                                         c_ptr->feat = one_in_(2) ? c_ptr->mimic : floor_type[randint0(100)];
329                                 }
330                                 c_ptr->mimic = 0;
331                         }
332                 }
333
334                 c_ptr->info &= ~(CAVE_FLOOR);
335                 delete_monster(y, x);
336         }
337 }
338
339 /*
340  * Routine used by the random vault creators to add a door to a location
341  * Note that range checking has to be done in the calling routine.
342  *
343  * The doors must be INSIDE the allocated region.
344  */
345 void add_door(POSITION x, POSITION y)
346 {
347         /* Need to have a wall in the center square */
348         if (!is_outer_bold(y, x)) return;
349
350         /* look at:
351         *  x#x
352         *  .#.
353         *  x#x
354         *
355         *  where x=don't care
356         *  .=floor, #=wall
357         */
358
359         if (is_floor_bold(y - 1, x) && is_floor_bold(y + 1, x) &&
360                 (is_outer_bold(y, x - 1) && is_outer_bold(y, x + 1)))
361         {
362                 /* secret door */
363                 place_secret_door(y, x, DOOR_DEFAULT);
364
365                 /* set boundarys so don't get wide doors */
366                 place_solid_bold(y, x - 1);
367                 place_solid_bold(y, x + 1);
368         }
369
370
371         /* look at:
372         *  x#x
373         *  .#.
374         *  x#x
375         *
376         *  where x = don't care
377         *  .=floor, #=wall
378         */
379         if (is_outer_bold(y - 1, x) && is_outer_bold(y + 1, x) &&
380                 is_floor_bold(y, x - 1) && is_floor_bold(y, x + 1))
381         {
382                 /* secret door */
383                 place_secret_door(y, x, DOOR_DEFAULT);
384
385                 /* set boundarys so don't get wide doors */
386                 place_solid_bold(y - 1, x);
387                 place_solid_bold(y + 1, x);
388         }
389 }
390
391 /*!
392 * @brief 隣接4マスに存在する通路の数を返す / Count the number of "corridor" grids adjacent to the given grid.
393 * @param y1 基準となるマスのY座標
394 * @param x1 基準となるマスのX座標
395 * @return 通路の数
396 * @note Assumes "in_bounds(y1, x1)"
397 * @details
398 * XXX XXX This routine currently only counts actual "empty floor"\n
399 * grids which are not in rooms.  We might want to also count stairs,\n
400 * open doors, closed doors, etc.
401 */
402 static int next_to_corr(POSITION y1, POSITION x1)
403 {
404         int i, k = 0;
405         POSITION y, x;
406
407         cave_type *c_ptr;
408
409         /* Scan adjacent grids */
410         for (i = 0; i < 4; i++)
411         {
412                 /* Extract the location */
413                 y = y1 + ddy_ddd[i];
414                 x = x1 + ddx_ddd[i];
415                 c_ptr = &cave[y][x];
416
417                 /* Skip non floors */
418                 if (cave_have_flag_grid(c_ptr, FF_WALL)) continue;
419
420                 /* Skip non "empty floor" grids */
421                 if (!is_floor_grid(c_ptr))
422                         continue;
423
424                 /* Skip grids inside rooms */
425                 if (c_ptr->info & (CAVE_ROOM)) continue;
426
427                 /* Count these grids */
428                 k++;
429         }
430
431         /* Return the number of corridors */
432         return (k);
433 }
434
435 /*!
436 * @brief ドアを設置可能な地形かを返す / Determine if the given location is "between" two walls, and "next to" two corridor spaces.
437 * @param y 判定を行いたいマスのY座標
438 * @param x 判定を行いたいマスのX座標
439 * @return ドアを設置可能ならばTRUEを返す
440 * @note Assumes "in_bounds(y1, x1)"
441 * @details
442 * \n
443 * Assumes "in_bounds(y, x)"\n
444 */
445 static bool possible_doorway(POSITION y, POSITION x)
446 {
447         /* Count the adjacent corridors */
448         if (next_to_corr(y, x) >= 2)
449         {
450                 /* Check Vertical */
451                 if (cave_have_flag_bold(y - 1, x, FF_WALL) &&
452                         cave_have_flag_bold(y + 1, x, FF_WALL))
453                 {
454                         return (TRUE);
455                 }
456
457                 /* Check Horizontal */
458                 if (cave_have_flag_bold(y, x - 1, FF_WALL) &&
459                         cave_have_flag_bold(y, x + 1, FF_WALL))
460                 {
461                         return (TRUE);
462                 }
463         }
464
465         /* No doorway */
466         return (FALSE);
467 }
468
469 /*!
470 * @brief ドアの設置を試みる / Places door at y, x position if at least 2 walls found
471 * @param y 設置を行いたいマスのY座標
472 * @param x 設置を行いたいマスのX座標
473 * @return なし
474 */
475 void try_door(POSITION y, POSITION x)
476 {
477         /* Paranoia */
478         if (!in_bounds(y, x)) return;
479
480         /* Ignore walls */
481         if (cave_have_flag_bold(y, x, FF_WALL)) return;
482
483         /* Ignore room grids */
484         if (cave[y][x].info & (CAVE_ROOM)) return;
485
486         /* Occasional door (if allowed) */
487         if ((randint0(100) < dun_tun_jct) && possible_doorway(y, x) && !(d_info[dungeon_type].flags1 & DF1_NO_DOORS))
488         {
489                 /* Place a door */
490                 place_random_door(y, x, FALSE);
491         }
492 }
493
494
495 /*!
496  * @brief 長方形の空洞を生成する / Make an empty square floor, for the middle of rooms
497  * @param x1 長方形の左端X座標(-1)
498  * @param x2 長方形の右端X座標(+1)
499  * @param y1 長方形の上端Y座標(-1)
500  * @param y2 長方形の下端Y座標(+1)
501  * @param light 照明の有無
502  * @return なし
503  */
504 void place_floor(POSITION x1, POSITION x2, POSITION y1, POSITION y2, bool light)
505 {
506         POSITION x, y;
507
508         /* Place a full floor under the room */
509         for (y = y1 - 1; y <= y2 + 1; y++)
510         {
511                 for (x = x1 - 1; x <= x2 + 1; x++)
512                 {
513                         place_floor_bold(y, x);
514                         add_cave_info(y, x, CAVE_ROOM);
515                         if (light) add_cave_info(y, x, CAVE_GLOW);
516                 }
517         }
518 }
519
520
521 /*!
522  * @brief 長方形の部屋を生成する / Make an empty square room, only floor and wall grids
523  * @param x1 長方形の左端X座標(-1)
524  * @param x2 長方形の右端X座標(+1)
525  * @param y1 長方形の上端Y座標(-1)
526  * @param y2 長方形の下端Y座標(+1)
527  * @param light 照明の有無
528  * @return なし
529  */
530 void place_room(POSITION x1, POSITION x2, POSITION y1, POSITION y2, bool light)
531 {
532         POSITION y, x;
533
534         place_floor(x1, x2, y1, y2, light);
535
536         /* Walls around the room */
537         for (y = y1 - 1; y <= y2 + 1; y++)
538         {
539                 place_outer_bold(y, x1 - 1);
540                 place_outer_bold(y, x2 + 1);
541         }
542         for (x = x1 - 1; x <= x2 + 1; x++)
543         {
544                 place_outer_bold(y1 - 1, x);
545                 place_outer_bold(y2 + 1, x);
546         }
547 }
548
549
550 /*!
551  * @brief 特殊な部屋向けに各種アイテムを配置する / Create up to "num" objects near the given coordinates
552  * @param y 配置したい中心マスのY座標
553  * @param x 配置したい中心マスのX座標
554  * @param num 配置したい数
555  * @return なし
556  * @details
557  * Only really called by some of the "vault" routines.
558  */
559 void vault_objects(POSITION y, POSITION x, int num)
560 {
561         int dummy = 0;
562         int i = 0, j = y, k = x;
563
564         cave_type *c_ptr;
565
566
567         /* Attempt to place 'num' objects */
568         for (; num > 0; --num)
569         {
570                 /* Try up to 11 spots looking for empty space */
571                 for (i = 0; i < 11; ++i)
572                 {
573                         /* Pick a random location */
574                         while (dummy < SAFE_MAX_ATTEMPTS)
575                         {
576                                 j = rand_spread(y, 2);
577                                 k = rand_spread(x, 3);
578                                 dummy++;
579                                 if (!in_bounds(j, k)) continue;
580                                 break;
581                         }
582
583
584                         if (dummy >= SAFE_MAX_ATTEMPTS && cheat_room)
585                         {
586                                 msg_print(_("警告!地下室のアイテムを配置できません!", "Warning! Could not place vault object!"));
587                         }
588
589
590                         /* Require "clean" floor space */
591                         c_ptr = &cave[j][k];
592                         if (!is_floor_grid(c_ptr) || c_ptr->o_idx) continue;
593
594                         /* Place an item */
595                         if (randint0(100) < 75)
596                         {
597                                 place_object(j, k, 0L);
598                         }
599
600                         /* Place gold */
601                         else
602                         {
603                                 place_gold(j, k);
604                         }
605
606                         /* Placement accomplished */
607                         break;
608                 }
609         }
610 }
611
612 /*!
613  * @brief 特殊な部屋向けに各種アイテムを配置する(vault_trapのサブセット) / Place a trap with a given displacement of point
614  * @param y トラップを配置したいマスの中心Y座標
615  * @param x トラップを配置したいマスの中心X座標
616  * @param yd Y方向の配置分散マス数
617  * @param xd X方向の配置分散マス数
618  * @return なし
619  * @details
620  * Only really called by some of the "vault" routines.
621  */
622 void vault_trap_aux(POSITION y, POSITION x, POSITION yd, POSITION xd)
623 {
624         int count = 0, y1 = y, x1 = x;
625         int dummy = 0;
626
627         cave_type *c_ptr;
628
629         /* Place traps */
630         for (count = 0; count <= 5; count++)
631         {
632                 /* Get a location */
633                 while (dummy < SAFE_MAX_ATTEMPTS)
634                 {
635                         y1 = rand_spread(y, yd);
636                         x1 = rand_spread(x, xd);
637                         dummy++;
638                         if (!in_bounds(y1, x1)) continue;
639                         break;
640                 }
641
642                 if (dummy >= SAFE_MAX_ATTEMPTS && cheat_room)
643                 {
644                         msg_print(_("警告!地下室のトラップを配置できません!", "Warning! Could not place vault trap!"));
645                 }
646
647                 /* Require "naked" floor grids */
648                 c_ptr = &cave[y1][x1];
649                 if (!is_floor_grid(c_ptr) || c_ptr->o_idx || c_ptr->m_idx) continue;
650
651                 /* Place the trap */
652                 place_trap(y1, x1);
653
654                 break;
655         }
656 }
657
658 /*!
659  * @brief 特殊な部屋向けに各種アイテムを配置する(メインルーチン) / Place some traps with a given displacement of given location
660  * @param y トラップを配置したいマスの中心Y座標
661  * @param x トラップを配置したいマスの中心X座標
662  * @param yd Y方向の配置分散マス数
663  * @param xd X方向の配置分散マス数
664  * @param num 配置したいトラップの数
665  * @return なし
666  * @details
667  * Only really called by some of the "vault" routines.
668  */
669 void vault_traps(POSITION y, POSITION x, POSITION yd, POSITION xd, int num)
670 {
671         int i;
672
673         for (i = 0; i < num; i++)
674         {
675                 vault_trap_aux(y, x, yd, xd);
676         }
677 }
678
679 /*!
680  * @brief 特殊な部屋地形向けにモンスターを配置する / Hack -- Place some sleeping monsters near the given location
681  * @param y1 モンスターを配置したいマスの中心Y座標
682  * @param x1 モンスターを配置したいマスの中心X座標
683  * @param num 配置したいモンスターの数
684  * @return なし
685  * @details
686  * Only really called by some of the "vault" routines.
687  */
688 void vault_monsters(POSITION y1, POSITION x1, int num)
689 {
690         int k, i;
691         POSITION y, x;
692         cave_type *c_ptr;
693
694         /* Try to summon "num" monsters "near" the given location */
695         for (k = 0; k < num; k++)
696         {
697                 /* Try nine locations */
698                 for (i = 0; i < 9; i++)
699                 {
700                         int d = 1;
701
702                         /* Pick a nearby location */
703                         scatter(&y, &x, y1, x1, d, 0);
704
705                         /* Require "empty" floor grids */
706                         c_ptr = &cave[y][x];
707                         if (!cave_empty_grid(c_ptr)) continue;
708
709                         /* Place the monster (allow groups) */
710                         monster_level = base_level + 2;
711                         (void)place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
712                         monster_level = base_level;
713                 }
714         }
715 }
716
717
718 /*!
719  * @brief build_tunnel用に通路を掘るための方向を位置関係通りに決める / Always picks a correct direction
720  * @param rdir Y方向に取るべきベクトル値を返す参照ポインタ
721  * @param cdir X方向に取るべきベクトル値を返す参照ポインタ
722  * @param y1 始点Y座標
723  * @param x1 始点X座標
724  * @param y2 終点Y座標
725  * @param x2 終点X座標
726  * @return なし
727  */
728 void correct_dir(int *rdir, int *cdir, POSITION y1, POSITION x1, POSITION y2, POSITION x2)
729 {
730         /* Extract vertical and horizontal directions */
731         *rdir = (y1 == y2) ? 0 : (y1 < y2) ? 1 : -1;
732         *cdir = (x1 == x2) ? 0 : (x1 < x2) ? 1 : -1;
733
734         /* Never move diagonally */
735         if (*rdir && *cdir)
736         {
737                 if (randint0(100) < 50)
738                         *rdir = 0;
739                 else
740                         *cdir = 0;
741         }
742 }
743
744 /*!
745  * @brief build_tunnel用に通路を掘るための方向をランダムに決める / Pick a random direction
746  * @param rdir Y方向に取るべきベクトル値を返す参照ポインタ
747  * @param cdir X方向に取るべきベクトル値を返す参照ポインタ
748  * @return なし
749  */
750 void rand_dir(int *rdir, int *cdir)
751 {
752         /* Pick a random direction */
753         int i = randint0(4);
754
755         /* Extract the dy/dx components */
756         *rdir = ddy_ddd[i];
757         *cdir = ddx_ddd[i];
758 }
759
760 /*!
761  * @brief 指定のマスが床系地形であるかを返す / Function that sees if a square is a floor.  (Includes range checking.)
762  * @param x チェックするマスのX座標
763  * @param y チェックするマスのY座標
764  * @return 床系地形ならばTRUE
765  */
766 bool get_is_floor(POSITION x, POSITION y)
767 {
768         if (!in_bounds(y, x))
769         {
770                 /* Out of bounds */
771                 return (FALSE);
772         }
773
774         /* Do the real check */
775         if (is_floor_bold(y, x)) return (TRUE);
776
777         return (FALSE);
778 }
779
780 /*!
781  * @brief 指定のマスを床地形に変える / Set a square to be floor.  (Includes range checking.)
782  * @param x 地形を変えたいマスのX座標
783  * @param y 地形を変えたいマスのY座標
784  * @return なし
785  */
786 void set_floor(POSITION x, POSITION y)
787 {
788         if (!in_bounds(y, x))
789         {
790                 /* Out of bounds */
791                 return;
792         }
793
794         if (cave[y][x].info & CAVE_ROOM)
795         {
796                 /* A room border don't touch. */
797                 return;
798         }
799
800         /* Set to be floor if is a wall (don't touch lakes). */
801         if (is_extra_bold(y, x))
802                 place_floor_bold(y, x);
803 }
804
805