• R/O
  • HTTP
  • SSH
  • HTTPS

hengband: Commit

変愚蛮怒のメインリポジトリです


Commit MetaInfo

Revisionc34ef4e6cb0fbc5710d960929edd7b97924d2d5d (tree)
Time2019-02-20 11:56:37
AuthorDeskull <deskull@user...>
CommiterDeskull

Log Message

[Refactor] #37353 geometry.c/h を作成して coords_to_dir() を移動。 / Move coords_to_dir() to geometry.c/h.

Change Summary

Incremental Difference

--- a/Hengband_vcs2017/Hengband/Hengband.vcxproj
+++ b/Hengband_vcs2017/Hengband/Hengband.vcxproj
@@ -150,6 +150,7 @@
150150 <ClCompile Include="..\..\src\floor-events.c" />
151151 <ClCompile Include="..\..\src\floor-generate.c" />
152152 <ClCompile Include="..\..\src\floor-save.c" />
153+ <ClCompile Include="..\..\src\geometry.c" />
153154 <ClCompile Include="..\..\src\history.c" />
154155 <ClCompile Include="..\..\src\monster-process.c" />
155156 <ClCompile Include="..\..\src\monster-status.c" />
@@ -278,6 +279,7 @@
278279 <ClInclude Include="..\..\src\gameoption.h" />
279280 <ClInclude Include="..\..\src\gamevalue.h" />
280281 <ClInclude Include="..\..\src\generate.h" />
282+ <ClInclude Include="..\..\src\geometry.h" />
281283 <ClInclude Include="..\..\src\grid.h" />
282284 <ClInclude Include="..\..\src\h-basic.h" />
283285 <ClInclude Include="..\..\src\h-config.h" />
--- a/src/cmd2.c
+++ b/src/cmd2.c
@@ -24,6 +24,7 @@
2424 #include "avatar.h"
2525 #include "player-status.h"
2626 #include "realm-hex.h"
27+#include "geometry.h"
2728
2829 /*!
2930 * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
@@ -682,26 +683,6 @@ static int count_chests(POSITION *y, POSITION *x, bool trapped)
682683 }
683684
684685
685-/*!
686- * @brief プレイヤーから指定の座標がどの方角にあるかを返す /
687- * Convert an adjacent location to a direction.
688- * @param y 方角を確認したY座標
689- * @param x 方角を確認したX座標
690- * @return 方向ID
691- */
692-static DIRECTION coords_to_dir(POSITION y, POSITION x)
693-{
694- int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
695- DIRECTION dy, dx;
696-
697- dy = y - p_ptr->y;
698- dx = x - p_ptr->x;
699-
700- /* Paranoia */
701- if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
702-
703- return d[dx + 1][dy + 1];
704-}
705686
706687 /*!
707688 * @brief 「開ける」動作コマンドのサブルーチン /
--- /dev/null
+++ b/src/geometry.c
@@ -0,0 +1,22 @@
1+#include "angband.h"
2+
3+/*!
4+ * @brief プレイヤーから指定の座標がどの方角にあるかを返す /
5+ * Convert an adjacent location to a direction.
6+ * @param y 方角を確認したY座標
7+ * @param x 方角を確認したX座標
8+ * @return 方向ID
9+ */
10+DIRECTION coords_to_dir(POSITION y, POSITION x)
11+{
12+ DIRECTION d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
13+ POSITION dy, dx;
14+
15+ dy = y - p_ptr->y;
16+ dx = x - p_ptr->x;
17+
18+ /* Paranoia */
19+ if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
20+
21+ return d[dx + 1][dy + 1];
22+}
--- /dev/null
+++ b/src/geometry.h
@@ -0,0 +1,3 @@
1+#pragma once
2+
3+DIRECTION coords_to_dir(POSITION y, POSITION x);
Show on old repository browser