From 25823b36905a84d92f9299ba7f9f0c713141c8fb Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Mon, 18 Feb 2013 19:20:35 -0800 Subject: Strictify map cells Also fix a small but major bug in map_randfreecell. --- src/map/npc.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/map/npc.cpp') diff --git a/src/map/npc.cpp b/src/map/npc.cpp index 610a274..b65c263 100644 --- a/src/map/npc.cpp +++ b/src/map/npc.cpp @@ -1014,11 +1014,14 @@ int npc_parse_warp(const char *w1, const char *, const char *w3, const char *w4) { for (j = 0; j < xs; j++) { - int t; - t = map_getcell(m, x - xs / 2 + j, y - ys / 2 + i); - if (t == 1 || t == 5) + int x_lo = x - xs / 2; + int y_lo = y - ys / 2; + int xc = x_lo + j; + int yc = y_lo + i; + MapCell t = map_getcell(m, xc, yc); + if (bool(t & MapCell::UNWALKABLE)) continue; - map_setcell(m, x - xs / 2 + j, y - ys / 2 + i, t | 0x80); + map_setcell(m, xc, yc, t | MapCell::NPC_NEAR); } } @@ -1317,11 +1320,14 @@ int npc_parse_script(char *w1, char *w2, char *w3, char *w4, { for (j = 0; j < xs; j++) { - int t; - t = map_getcell(m, x - xs / 2 + j, y - ys / 2 + i); - if (t == 1 || t == 5) + int x_lo = x - xs / 2; + int y_lo = y - ys / 2; + int xc = x_lo + j; + int yc = y_lo + i; + MapCell t = map_getcell(m, xc, yc); + if (bool(t & MapCell::UNWALKABLE)) continue; - map_setcell(m, x - xs / 2 + j, y - ys / 2 + i, t | 0x80); + map_setcell(m, xc, yc, t | MapCell::NPC_NEAR); } } } -- cgit v1.2.3-60-g2f50