From caafec1bc75b72c73f6a53a1f94467bb43ac0edf Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Mon, 23 May 2016 22:19:43 +0300 Subject: [PATCH] Separate permonst valid location humidity function --- include/sp_lev.h | 11 ++++++----- src/sp_lev.c | 31 ++++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/include/sp_lev.h b/include/sp_lev.h index 03a68e71..6c42d9af 100644 --- a/include/sp_lev.h +++ b/include/sp_lev.h @@ -218,12 +218,13 @@ enum opcode_defs { #define SP_COORD_IS_RANDOM 0x01000000 /* Humidity flags for get_location() and friends, used with * SP_COORD_PACK_RANDOM() */ -#define DRY 0x1 -#define WET 0x2 -#define HOT 0x4 -#define SOLID 0x8 -#define ANY_LOC 0x10 /* even outside the level */ +#define DRY 0x01 +#define WET 0x02 +#define HOT 0x04 +#define SOLID 0x08 +#define ANY_LOC 0x10 /* even outside the level */ #define NO_LOC_WARN 0x20 /* no complaints and set x & y to -1, if no loc */ +#define SPACELOC 0x40 /* like DRY, but accepts furniture too */ #define SP_COORD_X(l) (l & 0xff) #define SP_COORD_Y(l) ((l >> 16) & 0xff) diff --git a/src/sp_lev.c b/src/sp_lev.c index 476a5c8f..6f0445bd 100644 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -72,6 +72,7 @@ STATIC_DCL void FDECL(create_door, (room_door *, struct mkroom *)); STATIC_DCL void FDECL(create_trap, (trap *, struct mkroom *)); STATIC_DCL int FDECL(noncoalignment, (ALIGNTYP_P)); STATIC_DCL boolean FDECL(m_bad_boulder_spot, (int, int)); +STATIC_DCL int FDECL(pm_to_humidity, (struct permonst *)); STATIC_DCL void FDECL(create_monster, (monster *, struct mkroom *)); STATIC_DCL void FDECL(create_object, (object *, struct mkroom *)); STATIC_DCL void FDECL(create_altar, (altar *, struct mkroom *)); @@ -895,6 +896,8 @@ register int humidity; || typ == CORR) return TRUE; } + if ((humidity & SPACELOC) && SPACE_POS(levl[x][y].typ)) + return TRUE; if ((humidity & WET) && is_pool(x, y)) return TRUE; if ((humidity & HOT) && is_lava(x, y)) @@ -1495,6 +1498,24 @@ int x, y; return FALSE; } +STATIC_OVL int +pm_to_humidity(pm) +struct permonst *pm; +{ + int loc = DRY; + if (!pm) + return loc; + if (pm->mlet == S_EEL || amphibious(pm) || is_swimmer(pm)) + loc = WET; + if (is_flyer(pm) || is_floater(pm)) + loc |= (HOT | WET); + if (passes_walls(pm) || noncorporeal(pm)) + loc |= SOLID; + if (flaming(pm)) + loc |= HOT; + return loc; +} + STATIC_OVL void create_monster(m, croom) monster *m; @@ -1543,15 +1564,7 @@ struct mkroom *croom; pm = (struct permonst *) 0; if (pm) { - int loc = DRY; - if (pm->mlet == S_EEL || amphibious(pm) || is_swimmer(pm)) - loc = WET; - if (is_flyer(pm) || is_floater(pm)) - loc |= (HOT | WET); - if (passes_walls(pm) || noncorporeal(pm)) - loc |= SOLID; - if (flaming(pm)) - loc |= HOT; + int loc = pm_to_humidity(pm); /* If water-liking monster, first try is without DRY */ get_location_coord(&x, &y, loc | NO_LOC_WARN, croom, m->coord); if (x == -1 && y == -1) { -- 2.11.4.GIT