static byte display_autopick;
static int match_autopick;
static object_type *autopick_obj;
+static int feat_priority;
/*
* Distance between two points via Newton-Raphson technique
/* Normal graphics */
if (!(streq(ANGBAND_SYS, "ibm")))
{
- (*cp) = r_info[randint(max_r_idx-1)].x_char;
- (*ap) = r_info[randint(max_r_idx-1)].x_attr;
+ (*cp) = r_info[randint1(max_r_idx-1)].x_char;
+ (*ap) = r_info[randint1(max_r_idx-1)].x_attr;
}
else
/* IBM-pseudo graphics */
{
n = strlen(image_monster_hack_ibm);
- (*cp) = (image_monster_hack_ibm[rand_int(n)]);
+ (*cp) = (image_monster_hack_ibm[randint0(n)]);
/* Random color */
- (*ap) = randint(15);
+ (*ap) = randint1(15);
}
}
else
/* Text mode */
{
- (*cp) = (image_monster_hack[rand_int(n)]);
+ (*cp) = (image_monster_hack[randint0(n)]);
/* Random color */
- (*ap) = randint(15);
+ (*ap) = randint1(15);
}
}
{
if (!(streq(ANGBAND_SYS, "ibm")))
{
- (*cp) = k_info[randint(max_k_idx-1)].x_char;
- (*ap) = k_info[randint(max_k_idx-1)].x_attr;
+ (*cp) = k_info[randint1(max_k_idx-1)].x_char;
+ (*ap) = k_info[randint1(max_k_idx-1)].x_attr;
}
else
{
n = strlen(image_object_hack_ibm);
- (*cp) = (image_object_hack_ibm[rand_int(n)]);
+ (*cp) = (image_object_hack_ibm[randint0(n)]);
/* Random color */
- (*ap) = randint(15);
+ (*ap) = randint1(15);
}
}
else
{
- (*cp) = (image_object_hack[rand_int(n)]);
+ (*cp) = (image_object_hack[randint0(n)]);
/* Random color */
- (*ap) = randint(15);
+ (*ap) = randint1(15);
}
}
static void image_random(byte *ap, char *cp)
{
/* Normally, assume monsters */
- if (rand_int(100) < 75)
+ if (randint0(100) < 75)
{
image_monster(ap, cp);
}
switch (feat)
{
- case FEAT_FLOOR:
- case FEAT_INVIS:
- case FEAT_GLYPH:
- case FEAT_LESS:
- case FEAT_MORE:
- case FEAT_LESS_LESS:
- case FEAT_MORE_MORE:
- case FEAT_SECRET:
- case FEAT_RUBBLE:
- case FEAT_MAGMA:
- case FEAT_QUARTZ:
- case FEAT_MAGMA_H:
- case FEAT_QUARTZ_H:
- case FEAT_MAGMA_K:
- case FEAT_QUARTZ_K:
- case FEAT_WALL_EXTRA:
- case FEAT_WALL_INNER:
- case FEAT_WALL_OUTER:
- case FEAT_WALL_SOLID:
- case FEAT_PERM_EXTRA:
- case FEAT_PERM_INNER:
- case FEAT_PERM_OUTER:
- case FEAT_PERM_SOLID:
- case FEAT_MINOR_GLYPH:
- case FEAT_DEEP_WATER:
- case FEAT_SHAL_WATER:
- case FEAT_DEEP_LAVA:
- case FEAT_SHAL_LAVA:
- case FEAT_DARK_PIT:
- case FEAT_DIRT:
- case FEAT_GRASS:
- case FEAT_FLOWER:
- case FEAT_DEEP_GRASS:
- case FEAT_TREES:
- case FEAT_MOUNTAIN:
- return TRUE;
- default:
- return FALSE;
+ case FEAT_FLOOR:
+ case FEAT_INVIS:
+ case FEAT_GLYPH:
+ case FEAT_LESS:
+ case FEAT_MORE:
+ case FEAT_LESS_LESS:
+ case FEAT_MORE_MORE:
+ case FEAT_SECRET:
+ case FEAT_RUBBLE:
+ case FEAT_MAGMA:
+ case FEAT_QUARTZ:
+ case FEAT_MAGMA_H:
+ case FEAT_QUARTZ_H:
+ case FEAT_MAGMA_K:
+ case FEAT_QUARTZ_K:
+ case FEAT_WALL_EXTRA:
+ case FEAT_WALL_INNER:
+ case FEAT_WALL_OUTER:
+ case FEAT_WALL_SOLID:
+ case FEAT_PERM_EXTRA:
+ case FEAT_PERM_INNER:
+ case FEAT_PERM_OUTER:
+ case FEAT_PERM_SOLID:
+ case FEAT_MINOR_GLYPH:
+ case FEAT_DEEP_WATER:
+ case FEAT_SHAL_WATER:
+ case FEAT_DEEP_LAVA:
+ case FEAT_SHAL_LAVA:
+ case FEAT_DARK_PIT:
+ case FEAT_DIRT:
+ case FEAT_GRASS:
+ case FEAT_FLOWER:
+ case FEAT_DEEP_GRASS:
+ case FEAT_TREES:
+ case FEAT_MOUNTAIN:
+ case FEAT_MIRROR:
+ return TRUE;
+ default:
+ return FALSE;
}
}
a = f_ptr->x_attr;
/* Special lighting effects */
- if (view_special_lite && (!p_ptr->wild_mode) && ((a == TERM_WHITE) || use_lighting))
+ if (view_special_lite && (!p_ptr->wild_mode) && ((a == TERM_WHITE) || use_graphics))
{
/* Handle "blind" */
if (p_ptr->blind)
/* Use darkened colour */
a = lighting_colours[a][1];
}
- else if (use_lighting && feat_supports_lighting(feat))
+ else if (use_graphics && feat_supports_lighting(feat))
{
/* Use a dark tile */
c++;
}
else
{
- if (use_lighting)
+ if (use_graphics)
{
/* Use a dark tile */
c++;
/* Use lightened colour */
a = lighting_colours[a][0];
}
- else if (use_lighting &&
+ else if (use_graphics &&
feat_supports_lighting(feat))
{
/* Use a brightly lit tile */
/* Torch lite */
if (view_yellow_lite)
{
- if (use_lighting)
+ if (use_graphics)
{
/* Use a brightly lit tile */
c += 2;
/* Use darkened colour */
a = lighting_colours[a][1];
}
- else if (use_lighting && feat_supports_lighting(feat))
+ else if (use_graphics && feat_supports_lighting(feat))
{
/* Use a dark tile */
c++;
}
else
{
- if (use_lighting)
+ if (use_graphics)
{
/* Use a dark tile */
c++;
/* Use darkened colour */
a = lighting_colours[a][1];
}
- else if (use_lighting && feat_supports_lighting(feat))
+ else if (use_graphics && feat_supports_lighting(feat))
{
/* Use a dark tile */
c++;
}
else
{
- if (use_lighting)
+ if (use_graphics)
{
/* Use a dark tile */
c++;
/* Unknown */
else
{
+ feat = FEAT_NONE;
+
/* Access darkness */
- f_ptr = &f_info[FEAT_NONE];
+ f_ptr = &f_info[feat];
/* Normal attr */
a = f_ptr->x_attr;
/* Use darkened colour */
a = lighting_colours[a][1];
}
- else if (use_lighting && feat_supports_lighting(feat))
+ else if (use_graphics && feat_supports_lighting(feat))
{
/* Use a dark tile */
c++;
else if (c_ptr->info & (CAVE_LITE | CAVE_MNLT))
{
/* Torch lite */
- if (view_yellow_lite && !p_ptr->wild_mode && ((use_lighting && feat_supports_lighting(feat)) || is_ascii_graphics(c,a)))
+ if (view_yellow_lite && !p_ptr->wild_mode && ((use_graphics && feat_supports_lighting(feat)) || is_ascii_graphics(c,a)))
{
if (is_ascii_graphics(c,a))
{
/* Use lightened colour */
a = lighting_colours[a][0];
}
- else if (use_lighting &&
+ else if (use_graphics &&
feat_supports_lighting(c_ptr->feat))
{
/* Use a brightly lit tile */
}
/* Handle "view_bright_lite" */
- else if (view_bright_lite && !p_ptr->wild_mode && ((use_lighting && feat_supports_lighting(feat)) || is_ascii_graphics(c,a)))
+ else if (view_bright_lite && !p_ptr->wild_mode && ((use_graphics && feat_supports_lighting(feat)) || is_ascii_graphics(c,a)))
{
/* Not viewable */
if (!(c_ptr->info & CAVE_VIEW))
/* Use darkened colour */
a = lighting_colours[a][1];
}
- else if (use_lighting && feat_supports_lighting(feat))
+ else if (use_graphics && feat_supports_lighting(feat))
{
/* Use a dark tile */
c++;
}
/* Special lighting effects */
else if (view_granite_lite && !p_ptr->wild_mode &&
- (((a == TERM_WHITE) && !use_lighting) ||
- (use_lighting && feat_supports_lighting(c_ptr->feat))))
+ (((a == TERM_WHITE) && !use_graphics) ||
+ (use_graphics && feat_supports_lighting(c_ptr->feat))))
{
/* Handle "blind" */
if (p_ptr->blind)
{
- if (use_lighting)
+ if (use_graphics)
{
/* Use a dark tile */
c++;
/* Torch lite */
if (view_yellow_lite && !p_ptr->wild_mode)
{
- if (use_lighting)
+ if (use_graphics)
{
/* Use a brightly lit tile */
c += 2;
/* Not viewable */
if (!(c_ptr->info & CAVE_VIEW))
{
- if (use_lighting)
+ if (use_graphics)
{
/* Use a dark tile */
c++;
/* Not glowing */
else if (!(c_ptr->info & CAVE_GLOW))
{
- if (use_lighting)
+ if (use_graphics)
{
/* Use a lit tile */
}
/* Check for "local" illumination */
if (!(cave[yy][xx].info & CAVE_GLOW))
{
- if (use_lighting)
+ if (use_graphics)
{
/* Use a lit tile */
}
/* "Simple Lighting" */
else
{
- /* Access feature */
- f_ptr = &f_info[feat];
-
/* Handle "blind" */
if (!(c_ptr->info & CAVE_MARK))
{
- /* Access darkness */
- f_ptr = &f_info[FEAT_NONE];
+ feat = FEAT_NONE;
}
+ /* Access feature */
+ f_ptr = &f_info[feat];
+
/* Normal attr */
a = f_ptr->x_attr;
}
}
+ if (feat_priority == -1)
+ {
+ switch (feat)
+ {
+ case FEAT_NONE:
+ case FEAT_DARK_PIT:
+ feat_priority = 1;
+ break;
+
+ case FEAT_FLOOR:
+ case FEAT_INVIS:
+ case FEAT_TRAP_TRAPDOOR:
+ case FEAT_TRAP_PIT:
+ case FEAT_TRAP_SPIKED_PIT:
+ case FEAT_TRAP_POISON_PIT:
+ case FEAT_TRAP_TY_CURSE:
+ case FEAT_TRAP_TELEPORT:
+ case FEAT_TRAP_FIRE:
+ case FEAT_TRAP_ACID:
+ case FEAT_TRAP_SLOW:
+ case FEAT_TRAP_LOSE_STR:
+ case FEAT_TRAP_LOSE_DEX:
+ case FEAT_TRAP_LOSE_CON:
+ case FEAT_TRAP_BLIND:
+ case FEAT_TRAP_CONFUSE:
+ case FEAT_TRAP_POISON:
+ case FEAT_TRAP_SLEEP:
+ case FEAT_TRAP_TRAPS:
+ case FEAT_DIRT:
+ case FEAT_GRASS:
+ case FEAT_FLOWER:
+ case FEAT_DEEP_GRASS:
+ case FEAT_SWAMP:
+ case FEAT_TREES:
+ case FEAT_SECRET:
+ case FEAT_RUBBLE:
+ case FEAT_MAGMA:
+ case FEAT_QUARTZ:
+ case FEAT_MAGMA_H:
+ case FEAT_QUARTZ_H:
+ case FEAT_WALL_EXTRA:
+ case FEAT_WALL_INNER:
+ case FEAT_WALL_OUTER:
+ case FEAT_WALL_SOLID:
+ case FEAT_DEEP_WATER:
+ case FEAT_SHAL_WATER:
+ case FEAT_DEEP_LAVA:
+ case FEAT_SHAL_LAVA:
+ feat_priority = 2;
+ break;
+
+ case FEAT_MAGMA_K:
+ case FEAT_QUARTZ_K:
+ feat_priority = 3;
+ break;
+
+ case FEAT_MOUNTAIN:
+ case FEAT_PERM_EXTRA:
+ case FEAT_PERM_INNER:
+ case FEAT_PERM_OUTER:
+ case FEAT_PERM_SOLID:
+ feat_priority = 5;
+ break;
+
+ /* default is feat_priority = 20; (doors and stores) */
+
+ case FEAT_GLYPH:
+ case FEAT_MINOR_GLYPH:
+ case FEAT_MIRROR:
+ case FEAT_PATTERN_START:
+ case FEAT_PATTERN_1:
+ case FEAT_PATTERN_2:
+ case FEAT_PATTERN_3:
+ case FEAT_PATTERN_4:
+ case FEAT_PATTERN_END:
+ case FEAT_PATTERN_OLD:
+ case FEAT_PATTERN_XTRA1:
+ case FEAT_PATTERN_XTRA2:
+ feat_priority = 16;
+ break;
+
+ /* objects have feat_priority = 20 */
+ /* monsters have feat_priority = 30 */
+
+ case FEAT_LESS:
+ case FEAT_MORE:
+ case FEAT_QUEST_ENTER:
+ case FEAT_QUEST_EXIT:
+ case FEAT_QUEST_DOWN:
+ case FEAT_QUEST_UP:
+ case FEAT_LESS_LESS:
+ case FEAT_MORE_MORE:
+ case FEAT_TOWN:
+ case FEAT_ENTRANCE:
+ feat_priority = 35;
+ break;
+
+ default:
+ feat_priority = 10;
+ break;
+ }
+ }
+
/* Hack -- rare random hallucination, except on outer dungeon walls */
- if (p_ptr->image && (c_ptr->feat < FEAT_PERM_SOLID) && !rand_int(256))
+ if (p_ptr->image && (c_ptr->feat < FEAT_PERM_SOLID) && !randint0(256))
{
/* Hallucinate */
image_random(ap, cp);
/* Normal attr */
(*ap) = object_attr(o_ptr);
+ feat_priority = 20;
+
/* Hack -- hallucination */
if (p_ptr->image) image_object(ap, cp);
/* Desired char */
c = r_ptr->x_char;
+ feat_priority = 30;
+
/* Mimics' colors vary */
if (strchr("\"!=", c) && !(r_ptr->flags1 & RF1_UNIQUE))
{
{
if (!(streq(ANGBAND_SYS, "ibm")))
{
- (*cp) = r_info[randint(max_r_idx-1)].x_char;
- (*ap) = r_info[randint(max_r_idx-1)].x_attr;
+ (*cp) = r_info[randint1(max_r_idx-1)].x_char;
+ (*ap) = r_info[randint1(max_r_idx-1)].x_attr;
}
else
{
int n = strlen(image_monster_hack_ibm);
- (*cp) = (image_monster_hack_ibm[rand_int(n)]);
+ (*cp) = (image_monster_hack_ibm[randint0(n)]);
/* Random color */
- (*ap) = randint(15);
+ (*ap) = randint1(15);
}
}
else
{
- (*cp) = (randint(25) == 1 ?
- image_object_hack[rand_int(strlen(image_object_hack))] :
- image_monster_hack[rand_int(strlen(image_monster_hack))]);
+ (*cp) = (one_in_(25) ?
+ image_object_hack[randint0(strlen(image_object_hack))] :
+ image_monster_hack[randint0(strlen(image_monster_hack))]);
}
}
else
/* Multi-hued attr */
if (r_ptr->flags2 & RF2_ATTR_ANY)
- (*ap) = randint(15);
- else switch (randint(7))
+ (*ap) = randint1(15);
+ else switch (randint1(7))
{
case 1:
(*ap) = TERM_RED;
{
monster_race *r_ptr = &r_info[0];
+ feat_priority = 31;
+
/* Get the "player" attr */
a = r_ptr->x_attr;
case CLASS_CHAOS_WARRIOR:
do
{
- a = randint(15);
+ a = randint1(15);
}
while (a == TERM_DARK);
break;
}
-
-
-/*
- * Display highest priority object in the RATIO by RATIO area
- */
-#define RATIO 3
-
-
-/*
- * Hack -- priority array (see below)
- *
- * Note that all "walls" always look like "secret doors" (see "map_info()").
- */
-static byte priority_table[][2] =
-{
- /* Dark */
- { FEAT_NONE, 2 },
-
- /* Floors */
- { FEAT_FLOOR, 5 },
-
- /* Walls */
- { FEAT_SECRET, 10 },
-
- /* Quartz */
- { FEAT_QUARTZ, 11 },
-
- /* Magma */
- { FEAT_MAGMA, 12 },
-
- /* Rubble */
- { FEAT_RUBBLE, 13 },
-
- /* Open doors */
- { FEAT_OPEN, 15 },
- { FEAT_BROKEN, 15 },
-
- /* Closed doors */
- { FEAT_DOOR_HEAD + 0x00, 17 },
-
- /* Hidden gold */
- { FEAT_QUARTZ_K, 19 },
- { FEAT_MAGMA_K, 19 },
-
- /* water, lava, & trees */
- { FEAT_DEEP_WATER, 20 },
- { FEAT_SHAL_WATER, 20 },
- { FEAT_DEEP_LAVA, 20 },
- { FEAT_SHAL_LAVA, 20 },
- { FEAT_DIRT, 6 },
- { FEAT_GRASS, 6 },
- { FEAT_FLOWER, 6 },
- { FEAT_DEEP_GRASS, 6 },
- { FEAT_DARK_PIT, 20 },
- { FEAT_TREES, 6 },
- { FEAT_MOUNTAIN, 20 },
-
- /* Stairs */
- { FEAT_LESS, 25 },
- { FEAT_MORE, 25 },
- { FEAT_LESS_LESS, 25 },
- { FEAT_MORE_MORE, 25 },
- { FEAT_ENTRANCE, 25 },
-
- { FEAT_QUEST_ENTER, 25 },
- { FEAT_QUEST_EXIT, 25 },
- { FEAT_QUEST_DOWN, 25 },
- { FEAT_QUEST_UP, 25 },
-
- /* End */
- { 0, 0 }
-};
-
-
-/*
- * Hack -- a priority function (see below)
- */
-static byte priority(byte a, char c)
-{
- int i, p0, p1;
-
- feature_type *f_ptr;
-
- /* Scan the table */
- for (i = 0; TRUE; i++)
- {
- /* Priority level */
- p1 = priority_table[i][1];
-
- /* End of table */
- if (!p1) break;
-
- /* Feature index */
- p0 = priority_table[i][0];
-
- /* Access the feature */
- f_ptr = &f_info[p0];
-
- /* Check character and attribute, accept matches */
- if ((f_ptr->x_char == c) && (f_ptr->x_attr == a)) return (p1);
- }
-
- /* Default */
- return (20);
-}
-
static cptr simplify_list[][2] =
{
#ifdef JP
/*
* Display a "small-scale" map of the dungeon in the active Term
- *
- * Note that the "map_info()" function must return fully colorized
- * data or this function will not work correctly.
- *
- * Note that this function must "disable" the special lighting
- * effects so that the "priority" function will work.
- *
- * Note the use of a specialized "priority" function to allow this
- * function to work with any graphic attr/char mappings, and the
- * attempts to optimize this function where possible.
*/
void display_map(int *cy, int *cx)
{
byte tp;
+ byte bigma[MAX_HGT+2][MAX_WID+2];
+ char bigmc[MAX_HGT+2][MAX_WID+2];
+ byte bigmp[MAX_HGT+2][MAX_WID+2];
+
byte ma[SCREEN_HGT + 2][SCREEN_WID + 2];
char mc[SCREEN_HGT + 2][SCREEN_WID + 2];
}
}
+ for (j = 0; j < cur_hgt + 2; ++j)
+ {
+ for (i = 0; i < cur_wid + 2; ++i)
+ {
+ /* Nothing here */
+ bigma[j][i] = TERM_WHITE;
+ bigmc[j][i] = ' ';
+
+ /* No priority */
+ bigmp[j][i] = 0;
+ }
+ }
+
/* Fill in the map */
for (i = 0; i < cur_wid; ++i)
{
match_autopick=-1;
autopick_obj=NULL;
+ feat_priority = -1;
/* Extract the current attr/char at that map location */
#ifdef USE_TRANSPARENCY
map_info(j, i, &ta, &tc);
#endif /* USE_TRANSPARENCY */
- /* Extract the priority of that attr/char */
- tp = priority(ta, tc);
+ /* Extract the priority */
+ tp = feat_priority;
if(match_autopick!=-1
&& (match_autopick_yx[y][x] == -1
tp = 0x7f;
}
+ /* Save the char, attr and priority */
+ bigmc[j+1][i+1] = tc;
+ bigma[j+1][i+1] = ta;
+ bigmp[j+1][i+1] = tp;
+ }
+ }
+
+ for (j = 0; j < cur_hgt; ++j)
+ {
+ for (i = 0; i < cur_wid; ++i)
+ {
+ /* Location */
+ x = i / xrat + 1;
+ y = j / yrat + 1;
+
+ tc = bigmc[j+1][i+1];
+ ta = bigma[j+1][i+1];
+ tp = bigmp[j+1][i+1];
+
+ /* rare feature has more priority */
+ if (mp[y][x] == tp)
+ {
+ int t;
+ int cnt = 0;
+
+ for (t = 0; t < 8; t++)
+ {
+ if (tc == bigmc[j+1+ddy_cdd[t]][i+1+ddx_cdd[t]] &&
+ ta == bigma[j+1+ddy_cdd[t]][i+1+ddx_cdd[t]])
+ cnt++;
+ }
+ if (cnt <= 4)
+ tp++;
+ }
+
/* Save "best" */
- if (mp[y][x] <= tp)
+ if (mp[y][x] < tp)
{
- /* Save the char */
+ /* Save the char, attr and priority */
mc[y][x] = tc;
-
- /* Save the attr */
ma[y][x] = ta;
-
- /* Save priority */
mp[y][x] = tp;
}
}
int y, x;
/* Create a table that controls the spread of scent */
- int scent_adjust[5][5] =
+ const int scent_adjust[5][5] =
{
- { 250, 0, 0, 0, 250 },
- { 0, 1, 1, 1, 0 },
- { 0, 1, 2, 1, 0 },
- { 0, 1, 1, 1, 0 },
- { 250, 0, 0, 0, 250 },
+ { -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++ == 250)
+ if (++scent_when == 254)
{
/* Scan the entire dungeon */
for (y = 0; y < cur_hgt; y++)
}
/* Restart */
- scent_when = 127;
+ scent_when = 126;
}
if (!player_has_los_bold(y, x)) continue;
/* Note grids that are too far away */
- if (scent_adjust[i][j] == 250) continue;
+ if (scent_adjust[i][j] == -1) continue;
/* Mark the grid with new scent */
c_ptr->when = scent_when + scent_adjust[i][j];
/* Calculate torch radius */
p_ptr->update |= (PU_TORCH);
+
+ /* Update monster flow */
+ p_ptr->update |= (PU_FLOW);
}
/* Flush the input if requested */