-extern uint8_t is_passable(struct yx_uint8 pos)
-{
- uint8_t passable = 0;
- if (pos.x < world.map.length && pos.y < world.map.length)
- {
- passable = ('.' == world.map.cells[(pos.y * world.map.length) + pos.x]);
- }
- return passable;
-}
-
-
-
extern uint8_t mv_yx_in_dir_legal(char dir, struct yx_uint8 * yx)
{
uint8_t wraptest = mv_yx_in_dir_wrap(dir, yx, 0);
*/
extern void remake_map();
-/* Check if coordinate "pos" on (or beyond) world.map is accessible to thing
- * movement.
- */
-extern uint8_t is_passable(struct yx_uint8 pos);
-
/* Wrapper to mv_yx_in_dir_wrap(), returns 1 if the wrapped function moved "yx"
* within the wrap borders and the map size, else 0.
*/
* set_thing_position(), get_thing_type(),
* free_things_in_memory()
*/
-#include "map.h" /* mv_yx_in_dir_legal(), is_passable() */
+#include "map.h" /* mv_yx_in_dir_legal() */
#include "yx_uint8.h" /* mv_yx_in_dir_wrap(), yx_uint8_cmp() */
#include "world.h" /* global world */
}
}
}
- uint8_t passable = legal_move && is_passable(target);
+ char target_cell = world.map.cells[target.y * world.map.length + target.x];
+ uint8_t passable = legal_move && '.' == target_cell;
if (passable)
{
set_thing_position(t, target);
#include "../common/yx_uint8.h" /* yx_uint8 */
#include "cleanup.h" /* set_cleanup_flag() */
#include "hardcoded_strings.h" /* s */
-#include "map.h" /* is_passable() */
#include "rrand.h" /* rrand() */
#include "thing_actions.h" /* actor_wait */
#include "world.h" /* world */
struct yx_uint8 pos;
while (1)
{
- char * err = "Space to put thing on too hard to find."
- "Map too small?";
+ char * err="Space to put thing on too hard to find. Map too small?";
uint16_t i_pos = 0;
- for (pos.y = pos.x = 0; 0 == is_passable(pos); i_pos++)
+ for (pos.y = pos.x = 0;
+ '.' != world.map.cells[pos.y * world.map.length + pos.x];
+ i_pos++)
{
exit_err(UINT16_MAX == i_pos, err);
pos.y = rrand() % world.map.length;