<ClCompile Include="..\..\src\store\sell-order.c" />\r
<ClCompile Include="..\..\src\store\service-checker.c" />\r
<ClCompile Include="..\..\src\target\grid-selector.c" />\r
+ <ClCompile Include="..\..\src\target\projection-path-calculator.c" />\r
<ClCompile Include="..\..\src\target\target-describer.c" />\r
<ClCompile Include="..\..\src\target\target-getter.c" />\r
<ClCompile Include="..\..\src\target\target-preparation.c" />\r
<ClInclude Include="..\..\src\system\dungeon-data-definition.h" />\r
<ClInclude Include="..\..\src\system\floor-type-definition.h" />\r
<ClInclude Include="..\..\src\target\grid-selector.h" />\r
+ <ClInclude Include="..\..\src\target\projection-path-calculator.h" />\r
<ClInclude Include="..\..\src\target\target-describer.h" />\r
<ClInclude Include="..\..\src\target\target-getter.h" />\r
<ClInclude Include="..\..\src\target\target-preparation.h" />\r
<ClCompile Include="..\..\src\cmd-item\cmd-destroy.c">
<Filter>cmd-item</Filter>
</ClCompile>
+ <ClCompile Include="..\..\src\target\projection-path-calculator.c">
+ <Filter>target</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\combat\shoot.h">
<ClInclude Include="..\..\src\cmd-item\cmd-destroy.h">
<Filter>cmd-item</Filter>
</ClInclude>
+ <ClInclude Include="..\..\src\target\projection-path-calculator.h">
+ <Filter>target</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\src\wall.bmp" />
system/gamevalue.h \
\
target/grid-selector.c target/grid-selector.h \
+ target/projection-path-calculator.c target/projection-path-calculator.h
target/target-checker.c target/target-checker.h \
target/target-describer.c target/target-describer.h \
target/target-getter.c target/target-getter.h \
#include "flavor/object-flavor-types.h"
#include "floor/cave.h"
#include "floor/floor-object.h"
-#include "floor/floor.h"
#include "game-option/cheat-types.h"
#include "game-option/special-options.h"
#include "grid/feature-flag-types.h"
#include "sv-definition/sv-bow-types.h"
#include "system/artifact-type-definition.h"
#include "system/floor-type-definition.h"
+#include "target/projection-path-calculator.h"
#include "target/target-checker.h"
#include "target/target-getter.h"
#include "util/bit-flags-calculator.h"
}
/* Get projection path length */
- tdis = project_path(shooter_ptr, path_g, project_length, shooter_ptr->y, shooter_ptr->x, ty, tx, PROJECT_PATH | PROJECT_THRU) - 1;
+ tdis = projection_path(shooter_ptr, path_g, project_length, shooter_ptr->y, shooter_ptr->x, ty, tx, PROJECT_PATH | PROJECT_THRU) - 1;
project_length = 0; /* reset to default */
#include "spell/range-calc.h"
#include "spell/spell-types.h"
#include "system/floor-type-definition.h"
+#include "target/projection-path-calculator.h"
#include "term/gameterm.h"
#include "util/bit-flags-calculator.h"
#include "view/display-messages.h"
#include "room/door-definition.h"
#include "system/artifact-type-definition.h"
#include "system/floor-type-definition.h"
+#include "target/projection-path-calculator.h"
#include "util/bit-flags-calculator.h"
#include "view/display-messages.h"
#include "world/world-object.h"
}
/*!
- * @brief 始点から終点への直線経路を返す /
- * Determine the path taken by a projection.
- * @param player_ptr プレーヤーへの参照ポインタ
- * @param gp 経路座標リストを返す参照ポインタ
- * @param range 距離
- * @param y1 始点Y座標
- * @param x1 始点X座標
- * @param y2 終点Y座標
- * @param x2 終点X座標
- * @param flg フラグID
- * @return リストの長さ
- */
-int projection_path(player_type *player_ptr, u16b *gp, POSITION range, POSITION y1, POSITION x1, POSITION y2, POSITION x2, BIT_FLAGS flg)
-{
- if ((x1 == x2) && (y1 == y2))
- return 0;
-
- POSITION y, x;
- POSITION ay, ax;
- POSITION sy, sx;
- int frac;
- int m;
-
- if (y2 < y1) {
- ay = (y1 - y2);
- sy = -1;
- } else {
- ay = (y2 - y1);
- sy = 1;
- }
-
- if (x2 < x1) {
- ax = (x1 - x2);
- sx = -1;
- } else {
- ax = (x2 - x1);
- sx = 1;
- }
-
- int half = (ay * ax);
- int full = half << 1;
- floor_type *floor_ptr = player_ptr->current_floor_ptr;
- int n = 0;
- int k = 0;
-
- /* Vertical */
- if (ay > ax) {
- m = ax * ax * 2;
- y = y1 + sy;
- x = x1;
- frac = m;
- if (frac > half) {
- x += sx;
- frac -= full;
- k++;
- }
-
- while (TRUE) {
- gp[n++] = GRID(y, x);
- if ((n + (k >> 1)) >= range)
- break;
-
- if (!(flg & PROJECT_THRU)) {
- if ((x == x2) && (y == y2))
- break;
- }
-
- if (flg & PROJECT_DISI) {
- if ((n > 0) && cave_stop_disintegration(floor_ptr, y, x))
- break;
- } else if (flg & PROJECT_LOS) {
- if ((n > 0) && !cave_los_bold(floor_ptr, y, x))
- break;
- } else if (!(flg & PROJECT_PATH)) {
- if ((n > 0) && !cave_have_flag_bold(floor_ptr, y, x, FF_PROJECT))
- break;
- }
-
- if (flg & PROJECT_STOP) {
- if ((n > 0) && (player_bold(player_ptr, y, x) || floor_ptr->grid_array[y][x].m_idx != 0))
- break;
- }
-
- if (!in_bounds(floor_ptr, y, x))
- break;
-
- if (m) {
- frac += m;
- if (frac > half) {
- x += sx;
- frac -= full;
- k++;
- }
- }
-
- y += sy;
- }
-
- return n;
- }
-
- /* Horizontal */
- if (ax > ay) {
- m = ay * ay * 2;
- y = y1;
- x = x1 + sx;
- frac = m;
- if (frac > half) {
- y += sy;
- frac -= full;
- k++;
- }
-
- while (TRUE) {
- gp[n++] = GRID(y, x);
- if ((n + (k >> 1)) >= range)
- break;
-
- if (!(flg & (PROJECT_THRU))) {
- if ((x == x2) && (y == y2))
- break;
- }
-
- if (flg & (PROJECT_DISI)) {
- if ((n > 0) && cave_stop_disintegration(floor_ptr, y, x))
- break;
- } else if (flg & (PROJECT_LOS)) {
- if ((n > 0) && !cave_los_bold(floor_ptr, y, x))
- break;
- } else if (!(flg & (PROJECT_PATH))) {
- if ((n > 0) && !cave_have_flag_bold(floor_ptr, y, x, FF_PROJECT))
- break;
- }
-
- if (flg & (PROJECT_STOP)) {
- if ((n > 0) && (player_bold(player_ptr, y, x) || floor_ptr->grid_array[y][x].m_idx != 0))
- break;
- }
-
- if (!in_bounds(floor_ptr, y, x))
- break;
-
- if (m) {
- frac += m;
- if (frac > half) {
- y += sy;
- frac -= full;
- k++;
- }
- }
-
- x += sx;
- }
-
- return n;
- }
-
- y = y1 + sy;
- x = x1 + sx;
-
- while (TRUE) {
- gp[n++] = GRID(y, x);
- if ((n + (n >> 1)) >= range)
- break;
-
- if (!(flg & (PROJECT_THRU))) {
- if ((x == x2) && (y == y2))
- break;
- }
-
- if (flg & (PROJECT_DISI)) {
- if ((n > 0) && cave_stop_disintegration(floor_ptr, y, x))
- break;
- } else if (flg & (PROJECT_LOS)) {
- if ((n > 0) && !cave_los_bold(floor_ptr, y, x))
- break;
- } else if (!(flg & (PROJECT_PATH))) {
- if ((n > 0) && !cave_have_flag_bold(floor_ptr, y, x, FF_PROJECT))
- break;
- }
-
- if (flg & (PROJECT_STOP)) {
- if ((n > 0) && (player_bold(player_ptr, y, x) || floor_ptr->grid_array[y][x].m_idx != 0))
- break;
- }
-
- if (!in_bounds(floor_ptr, y, x))
- break;
-
- y += sy;
- x += sx;
- }
-
- return n;
-}
-
-/*!
* @brief 指定のマスを床地形に変える / Set a square to be floor. (Includes range checking.)
* @param player_ptr プレーヤーへの参照ポインタ
* @param x 地形を変えたいマスのX座標
extern floor_type floor_info;
/*
- * Convert a "location" (Y,X) into a "grid" (G)
- */
-#define GRID(Y,X) \
- (256 * (Y) + (X))
-
-/*
* Convert a "grid" (G) into a "location" (Y)
*/
#define GRID_Y(G) \
bool get_is_floor(floor_type *floor_ptr, POSITION x, POSITION y);
FEAT_IDX conv_dungeon_feat(floor_type *floor_ptr, FEAT_IDX newfeat);
void vault_objects(player_type *player_ptr, POSITION y, POSITION x, int num);
-int projection_path(player_type *player_ptr, u16b *gp, POSITION range, POSITION y1, POSITION x1, POSITION y2, POSITION x2, BIT_FLAGS flg);
void set_floor(player_type *player_ptr, POSITION x, POSITION y);
void place_object(player_type *owner_ptr, POSITION y, POSITION x, BIT_FLAGS mode);
void place_gold(player_type *player_ptr, POSITION y, POSITION x);
#include "grid/grid.h"
#include "io/screen-util.h"
#include "system/floor-type-definition.h"
+#include "target/projection-path-calculator.h"
#include "term/term-color-types.h"
#include "view/display-map.h"
#include "window/main-window-util.h"
#include "status/element-resistance.h"
#include "status/temporary-resistance.h"
#include "system/floor-type-definition.h"
+#include "target/projection-path-calculator.h"
#include "target/target-checker.h"
#include "target/target-getter.h"
#include "util/bit-flags-calculator.h"
#include "spell/range-calc.h"
#include "spell/spell-types.h"
#include "system/floor-type-definition.h"
+#include "target/projection-path-calculator.h"
#include "util/bit-flags-calculator.h"
#include "view/display-messages.h"
#include "world/world.h"
#include "spell/range-calc.h"
#include "spell/spell-types.h"
#include "system/floor-type-definition.h"
+#include "target/projection-path-calculator.h"
/*!
* @brief モンスターが敵対モンスターにビームを当てること可能かを判定する /
#include "monster/monster-update.h"
#include "system/floor-type-definition.h"
#include "system/object-type-definition.h"
+#include "target/projection-path-calculator.h"
#include "target/target-checker.h"
#include "target/target-setter.h"
#include "target/target-types.h"
m_ptr = &caster_ptr->current_floor_ptr->m_list[m_idx];
monster_desc(caster_ptr, m_name, m_ptr, 0);
msg_format(_("%sを引き戻した。", "You pull back %s."), m_name);
- path_n = project_path(caster_ptr, path_g, get_max_range(caster_ptr), target_row, target_col, caster_ptr->y, caster_ptr->x, 0);
+ path_n = projection_path(caster_ptr, path_g, get_max_range(caster_ptr), target_row, target_col, caster_ptr->y, caster_ptr->x, 0);
ty = target_row, tx = target_col;
for (i = 1; i < path_n; i++) {
POSITION ny = GRID_Y(path_g[i]);
--- /dev/null
+#include "target/projection-path-calculator.h"
+#include "effect/effect-characteristics.h"
+#include "floor/cave.h"
+#include "grid/feature-flag-types.h"
+#include "grid/grid.h"
+#include "system/floor-type-definition.h"
+
+/*
+ * @brief Convert a "location" (Y, X) into a "grid" (G)
+ * @param y Y\8dÀ\95W
+ * @param x X\8dÀ\95W
+ * return \8co\98H\8dÀ\95W
+ */
+static u16b location_to_grid(POSITION y, POSITION x) { return 256 * y + x; }
+
+/*!
+ * @brief \8en\93_\82©\82ç\8fI\93_\82Ö\82Ì\92¼\90ü\8co\98H\82ð\95Ô\82· /
+ * Determine the path taken by a projection.
+ * @param player_ptr \83v\83\8c\81[\83\84\81[\82Ö\82Ì\8eQ\8fÆ\83|\83C\83\93\83^
+ * @param gp \8co\98H\8dÀ\95W\83\8a\83X\83g\82ð\95Ô\82·\8eQ\8fÆ\83|\83C\83\93\83^
+ * @param range \8b\97\97£
+ * @param y1 \8en\93_Y\8dÀ\95W
+ * @param x1 \8en\93_X\8dÀ\95W
+ * @param y2 \8fI\93_Y\8dÀ\95W
+ * @param x2 \8fI\93_X\8dÀ\95W
+ * @param flg \83t\83\89\83OID
+ * @return \83\8a\83X\83g\82Ì\92·\82³
+ */
+int projection_path(player_type *player_ptr, u16b *gp, POSITION range, POSITION y1, POSITION x1, POSITION y2, POSITION x2, BIT_FLAGS flg)
+{
+ if ((x1 == x2) && (y1 == y2))
+ return 0;
+
+ POSITION y, x;
+ POSITION ay, ax;
+ POSITION sy, sx;
+ int frac;
+ int m;
+
+ if (y2 < y1) {
+ ay = (y1 - y2);
+ sy = -1;
+ } else {
+ ay = (y2 - y1);
+ sy = 1;
+ }
+
+ if (x2 < x1) {
+ ax = (x1 - x2);
+ sx = -1;
+ } else {
+ ax = (x2 - x1);
+ sx = 1;
+ }
+
+ int half = (ay * ax);
+ int full = half << 1;
+ floor_type *floor_ptr = player_ptr->current_floor_ptr;
+ int n = 0;
+ int k = 0;
+
+ /* Vertical */
+ if (ay > ax) {
+ m = ax * ax * 2;
+ y = y1 + sy;
+ x = x1;
+ frac = m;
+ if (frac > half) {
+ x += sx;
+ frac -= full;
+ k++;
+ }
+
+ while (TRUE) {
+ gp[n++] = location_to_grid(y, x);
+ if ((n + (k >> 1)) >= range)
+ break;
+
+ if (!(flg & PROJECT_THRU)) {
+ if ((x == x2) && (y == y2))
+ break;
+ }
+
+ if (flg & PROJECT_DISI) {
+ if ((n > 0) && cave_stop_disintegration(floor_ptr, y, x))
+ break;
+ } else if (flg & PROJECT_LOS) {
+ if ((n > 0) && !cave_los_bold(floor_ptr, y, x))
+ break;
+ } else if (!(flg & PROJECT_PATH)) {
+ if ((n > 0) && !cave_have_flag_bold(floor_ptr, y, x, FF_PROJECT))
+ break;
+ }
+
+ if (flg & PROJECT_STOP) {
+ if ((n > 0) && (player_bold(player_ptr, y, x) || floor_ptr->grid_array[y][x].m_idx != 0))
+ break;
+ }
+
+ if (!in_bounds(floor_ptr, y, x))
+ break;
+
+ if (m) {
+ frac += m;
+ if (frac > half) {
+ x += sx;
+ frac -= full;
+ k++;
+ }
+ }
+
+ y += sy;
+ }
+
+ return n;
+ }
+
+ /* Horizontal */
+ if (ax > ay) {
+ m = ay * ay * 2;
+ y = y1;
+ x = x1 + sx;
+ frac = m;
+ if (frac > half) {
+ y += sy;
+ frac -= full;
+ k++;
+ }
+
+ while (TRUE) {
+ gp[n++] = location_to_grid(y, x);
+ if ((n + (k >> 1)) >= range)
+ break;
+
+ if (!(flg & (PROJECT_THRU))) {
+ if ((x == x2) && (y == y2))
+ break;
+ }
+
+ if (flg & (PROJECT_DISI)) {
+ if ((n > 0) && cave_stop_disintegration(floor_ptr, y, x))
+ break;
+ } else if (flg & (PROJECT_LOS)) {
+ if ((n > 0) && !cave_los_bold(floor_ptr, y, x))
+ break;
+ } else if (!(flg & (PROJECT_PATH))) {
+ if ((n > 0) && !cave_have_flag_bold(floor_ptr, y, x, FF_PROJECT))
+ break;
+ }
+
+ if (flg & (PROJECT_STOP)) {
+ if ((n > 0) && (player_bold(player_ptr, y, x) || floor_ptr->grid_array[y][x].m_idx != 0))
+ break;
+ }
+
+ if (!in_bounds(floor_ptr, y, x))
+ break;
+
+ if (m) {
+ frac += m;
+ if (frac > half) {
+ y += sy;
+ frac -= full;
+ k++;
+ }
+ }
+
+ x += sx;
+ }
+
+ return n;
+ }
+
+ y = y1 + sy;
+ x = x1 + sx;
+
+ while (TRUE) {
+ gp[n++] = location_to_grid(y, x);
+ if ((n + (n >> 1)) >= range)
+ break;
+
+ if (!(flg & PROJECT_THRU)) {
+ if ((x == x2) && (y == y2))
+ break;
+ }
+
+ if (flg & PROJECT_DISI) {
+ if ((n > 0) && cave_stop_disintegration(floor_ptr, y, x))
+ break;
+ } else if (flg & PROJECT_LOS) {
+ if ((n > 0) && !cave_los_bold(floor_ptr, y, x))
+ break;
+ } else if (!(flg & PROJECT_PATH)) {
+ if ((n > 0) && !cave_have_flag_bold(floor_ptr, y, x, FF_PROJECT))
+ break;
+ }
+
+ if (flg & PROJECT_STOP) {
+ if ((n > 0) && (player_bold(player_ptr, y, x) || floor_ptr->grid_array[y][x].m_idx != 0))
+ break;
+ }
+
+ if (!in_bounds(floor_ptr, y, x))
+ break;
+
+ y += sy;
+ x += sx;
+ }
+
+ return n;
+}
--- /dev/null
+#pragma once
+
+#include "system/angband.h"
+
+int projection_path(player_type *player_ptr, u16b *gp, POSITION range, POSITION y1, POSITION x1, POSITION y2, POSITION x2, BIT_FLAGS flg);