/* Test whether angle between "left_angle" and "right_angle", or at least
* "middle_angle", is captured inside one of the shadow angles in "shadows". If
- * so, set hex in "fov_map" indexed by "pos_in_map" to HIDDEN. If the whole
- * angle and not just "middle_angle" is captured, return 1. Any other case: 0.
+ * so, set hex in "fov_map" indexed by "pos_in_map" to 'H'. If the whole angle
+ * and not just "middle_angle" is captured, return 1. Any other case: 0.
*/
static uint8_t shade_hex(uint32_t left_angle, uint32_t right_angle,
uint32_t middle_angle, struct shadow_angle ** shadows,
- uint16_t pos_in_map, uint8_t * fov_map);
-
-/* Test whether angle between "left_angle" and "right_angle", or at least
- * "middle_angle", is captured inside one of the shadow angles in "shadows". If
- * so, set hex in "fov_map" indexed by "pos_in_map" to HIDDEN. If the whole
- * angle and not just "middle_angle" is captured, return 1. Any other case: 0.
- */
-static uint8_t shade_hex(uint32_t left_angle, uint32_t right_angle,
- uint32_t middle_angle, struct shadow_angle ** shadows,
- uint16_t pos_in_map, uint8_t * fov_map);
+ uint16_t pos_in_map, char * fov_map);
/* Free shadow angles list "angles". */
static void free_angles(struct shadow_angle * angles);
* the circle's rightmost point), for setting shaded hexes in "fov_map" and
* potentially adding a new shadow to linked shadow angle list "shadows".
*/
-static void eval_position(uint16_t dist, uint16_t hex_i, uint8_t * fov_map,
+static void eval_position(uint16_t dist, uint16_t hex_i, char * fov_map,
struct yx_uint8 * test_pos,
struct shadow_angle ** shadows);
static uint8_t shade_hex(uint32_t left_angle, uint32_t right_angle,
uint32_t middle_angle, struct shadow_angle ** shadows,
- uint16_t pos_in_map, uint8_t * fov_map)
+ uint16_t pos_in_map, char * fov_map)
{
struct shadow_angle * shadow_i;
- if (fov_map[pos_in_map] == VISIBLE)
+ if (fov_map[pos_in_map] == 'v')
{
for (shadow_i = *shadows; shadow_i; shadow_i = shadow_i->next)
{
if ( left_angle <= shadow_i->left_angle
&& right_angle >= shadow_i->right_angle)
{
- fov_map[pos_in_map] = HIDDEN;
+ fov_map[pos_in_map] = 'H';
return 1;
}
if ( middle_angle < shadow_i->left_angle
&& middle_angle > shadow_i->right_angle)
{
- fov_map[pos_in_map] = HIDDEN;
+ fov_map[pos_in_map] = 'H';
}
}
}
-static void eval_position(uint16_t dist, uint16_t hex_i, uint8_t * fov_map,
+static void eval_position(uint16_t dist, uint16_t hex_i, char * fov_map,
struct yx_uint8 * test_pos,
struct shadow_angle ** shadows)
{
uint32_t i;
for (i = 0; i < map_size; i++)
{
- if (' ' == t->mem_map[i] && t->fov_map[i] == VISIBLE)
+ if (' ' == t->mem_map[i] && t->fov_map[i] == 'v')
{
t->mem_map[i] = world.map.cells[i];
}
{
uint32_t map_size = world.map.length * world.map.length;
t->fov_map = t->fov_map ? t->fov_map : try_malloc(map_size, __func__);
- memset(t->fov_map, VISIBLE, map_size);
+ memset(t->fov_map, 'v', map_size);
struct yx_uint8 test_pos = t->pos;
struct shadow_angle * shadows = NULL;
char * circle_dirs = "xswedc";
#include "../common/rexit.h" /* exit_trouble() */
#include "../common/try_malloc.h" /* try_malloc() */
#include "cleanup.h" /* set_cleanup_flag() */
-#include "field_of_view.h" /* VISIBLE */
#include "hardcoded_strings.h" /* s */
#include "things.h" /* Thing, ThingType, ThingAction, get_thing_type(),
* get_player()
uint32_t pos_i;
for (pos_i = 0; pos_i < map_size; pos_i++)
{
- if (player->fov_map[pos_i] == VISIBLE)
+ if (player->fov_map[pos_i] == 'v')
{
visible_map[pos_i] = world.map.cells[pos_i];
}
{
for (t = world.things; t != 0; t = t->next)
{
- if ( ( player->fov_map[t->pos.y * world.map.length +t->pos.x]
- == VISIBLE)
+ if ( 'v'==player->fov_map[t->pos.y*world.map.length+t->pos.x]
&& ( (0 == i && 0 == t->lifepoints)
|| (1 == i && 0 < t->lifepoints)))
{