/* * Return a target set of target_able monsters. */ static struct point_set *target_set_interactive_prepare(int mode) { int y, x; struct point_set *targets = point_set_new(TS_INITIAL_SIZE); /* Scan the current panel */ for (y = Term->offset_y; y < Term->offset_y + SCREEN_HGT; y++) { for (x = Term->offset_x; x < Term->offset_x + SCREEN_WID; x++) { /* Check bounds */ if (!cave_in_bounds_fully(cave, y, x)) continue; /* Require "interesting" contents */ if (!target_set_interactive_accept(y, x)) continue; /* Special mode */ if (mode & (TARGET_KILL)) { /* Must contain a monster */ if (!(cave->m_idx[y][x] > 0)) continue; /* Must be a targettable monster */ if (!target_able(cave_monster_at(cave, y, x))) continue; } /* Save the location */ add_to_point_set(targets, y, x); } } sort(targets->pts, point_set_size(targets), sizeof(*(targets->pts)), cmp_distance); return targets; }
/* XXX: Untangle this. The whole temp_* thing is complete madness. */ static void target_set_interactive_prepare(int mode) { int y, x; struct point *pts = mem_zalloc(sizeof(*pts) * SCREEN_HGT * SCREEN_WID); unsigned int n = 0; /* Scan the current panel */ for (y = Term->offset_y; y < Term->offset_y + SCREEN_HGT; y++) { for (x = Term->offset_x; x < Term->offset_x + SCREEN_WID; x++) { /* Check bounds */ if (!in_bounds_fully(y, x)) continue; /* Require "interesting" contents */ if (!target_set_interactive_accept(y, x)) continue; /* Special mode */ if (mode & (TARGET_KILL)) { /* Must contain a monster */ if (!(cave_m_idx[y][x] > 0)) continue; /* Must be a targettable monster */ if (!target_able(cave_m_idx[y][x])) continue; } /* Save the location */ pts[n].x = x; pts[n].y = y; n++; } } sort(pts, n, sizeof(*pts), cmp_distance); /* Reset "temp" array */ temp_n = n; while (n--) { temp_x[n] = pts[n].x; temp_y[n] = pts[n].y; } }
/* * Prepare the "temp" array for "target_interactive_set" * * Return the number of target_able monsters in the set. */ static void target_set_interactive_prepare(int mode) { int y, x; /* Reset "temp" array */ temp_n = 0; /* Scan the current panel */ for (y = Term->offset_y; y < Term->offset_y + SCREEN_HGT; y++) { for (x = Term->offset_x; x < Term->offset_x + SCREEN_WID; x++) { /* Check bounds */ if (!in_bounds_fully(y, x)) continue; /* Require "interesting" contents */ if (!target_set_interactive_accept(y, x)) continue; /* Special mode */ if (mode & (TARGET_KILL)) { /* Must contain a monster */ if (!(cave_m_idx[y][x] > 0)) continue; /* Must be a targettable monster */ if (!target_able(cave_m_idx[y][x])) continue; } /* Save the location */ temp_x[temp_n] = x; temp_y[temp_n] = y; temp_n++; } } /* Set the sort hooks */ ang_sort_comp = ang_sort_comp_distance; ang_sort_swap = ang_sort_swap_distance; /* Sort the positions */ ang_sort(temp_x, temp_y, temp_n); }
/* * Prepare the "temp" array for "target_interactive_set" * * Return the number of target_able monsters in the set. */ static void target_set_interactive_prepare(int mode) { int y, x; bool expand_look = (mode & (TARGET_LOOK)) ? TRUE : FALSE; /* Reset "temp" array */ clear_temp_array(); /* Scan the current panel */ for (y = Term->offset_y; y < Term->offset_y + SCREEN_HGT; y++) { for (x = Term->offset_x; x < Term->offset_x + SCREEN_WID; x++) { bool do_continue = FALSE; /* Check overflow */ if (temp_n >= TEMP_MAX) continue; /* Check bounds */ if (!in_bounds_fully(y, x)) continue; /* Require line of sight, unless "look" is "expanded" */ if (!player_has_los_bold(y, x) && (!expand_look)) continue; /* Require "interesting" contents */ if (!target_set_interactive_accept(y, x)) continue; /* Special mode */ if (mode & (TARGET_KILL)) { /* Must contain a monster */ if (!(cave_m_idx[y][x] > 0)) do_continue = TRUE; /* Must be a targettable monster */ if (!target_able(cave_m_idx[y][x])) do_continue = TRUE; } /* Don't continue on the trap exception, or if probing. */ if ((mode & (TARGET_TRAP)) && target_able_trap(y, x)) do_continue = FALSE; else if (mode & (TARGET_PROBE)) do_continue = FALSE; if (do_continue) continue; /* * Hack - don't go over redundant elemental terrain \ * (since we have large lakes and pools of the same terrain) */ if ((p_ptr->target_row > 0) || (p_ptr->target_col > 0)) { if (cave_feat[p_ptr->target_row][p_ptr->target_col] == cave_feat[y][x]) { if (cave_ff3_match(y, x, TERRAIN_MASK)) continue; } } /* Save the location */ temp_x[temp_n] = x; temp_y[temp_n] = y; temp_n++; } } /* Set the sort hooks */ ang_sort_comp = ang_sort_comp_distance; ang_sort_swap = ang_sort_swap_distance; /* Sort the positions */ ang_sort(temp_x, temp_y, temp_n); }
/* * Prepare the "temp" array for "target_interactive_set" * * Return the number of target_able monsters in the set. */ static void target_set_interactive_prepare(int mode) { int y, x; bool expand_look = (mode & (TARGET_LOOK)) ? TRUE : FALSE; /* Reset "temp" array */ target_grids.clear(); // Not needed. if (mode & (TARGET_GRID)) return; QRect vis = visible_dungeon(); /* Scan the current panel */ for (y = vis.y(); y <= vis.y() + vis.height(); y++) { for (x = vis.x(); x <= vis.x() + vis.width(); x++) { bool do_continue = FALSE; /* Check bounds */ if (!in_bounds_fully(y, x)) continue; /* Require line of sight, unless "look" is "expanded" */ if (!player_has_los_bold(y, x) && (!expand_look)) continue; /* Require "interesting" contents */ if (!target_set_interactive_accept(mode, y, x)) continue; /* Special mode */ if (mode & (TARGET_KILL)) { /* Must contain a monster */ if (!dungeon_info[y][x].has_monster()) do_continue = TRUE; /* Must be a targetable monster */ if (!target_able(dungeon_info[y][x].monster_idx, FALSE)) do_continue = TRUE; } /* Don't continue on the trap exception, or if probing. */ if ((mode & (TARGET_TRAP)) && target_able_trap(y, x)) do_continue = FALSE; else if (mode & (TARGET_PROBE)) do_continue = FALSE; if (do_continue) continue; /* * Hack - don't go over redundant elemental terrain \ * (since we have large lakes and pools of the same terrain) */ if ((p_ptr->target_row > 0) || (p_ptr->target_col > 0)) { if (dungeon_info[p_ptr->target_row][p_ptr->target_col].feature_idx == dungeon_info[y][x].feature_idx) { if (cave_ff3_match(y, x, TERRAIN_MASK)) continue; } } /* Save the location */ target_grids.append(make_coords(y, x)); } } // Sort by distance qSort(target_grids.begin(), target_grids.end(), coords_sort_distance); }