X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=src%2Fmisc.c;h=683346f84efd974538a501f904b18f1d909e5ae7;hb=e4f2a14c7385d99d49cf831cd3fd92234caf71b5;hp=d4d0ae691b699369e2b89290c838d606440c7108;hpb=868c0fd39978607ad2f68edd426f48a491ac1a2d;p=plomrogue diff --git a/src/misc.c b/src/misc.c index d4d0ae6..683346f 100644 --- a/src/misc.c +++ b/src/misc.c @@ -4,9 +4,11 @@ #include "windows.h" #include "keybindings.h" #include "readwrite.h" -#include "objects_on_map.h" +#include "map_objects.h" +#include "map_object_actions.h" #include "map.h" #include "main.h" +#include "yx_uint16.h" extern uint16_t rrand(char use_seed, uint32_t new_seed) { // Pseudo-random number generator (LGC algorithm). Use instead of rand() to ensure portable predictability. @@ -59,7 +61,7 @@ extern void turn_over (struct World * world, char action) { world->turn++; rrand(1, world->seed * world->turn); struct Monster * monster; - for (monster = world->monster; monster != 0; monster = monster->cmo.next) + for (monster = world->monster; monster != 0; monster = monster->map_obj.next) move_monster(world, monster); } extern void save_game(struct World * world) { @@ -98,6 +100,14 @@ extern void growshrink_active_window (struct WinMeta * win_meta, char change) { else if (change == '*') size.x++; resize_active_win (win_meta, size); } } +extern struct yx_uint16 find_passable_pos (struct Map * map) { +// Return a random passable position on map. + struct yx_uint16 pos; + for (pos.y = pos.x = 0; 0 == is_passable(map, pos);) { + pos.y = rrand(0, 0) % map->size.y; + pos.x = rrand(0, 0) % map->size.x; } + return pos; } + extern unsigned char meta_keys(int key, struct World * world, struct WinMeta * win_meta, struct Win * win_keys, struct Win * win_map, struct Win * win_info, struct Win * win_log) {