summaryrefslogtreecommitdiff
path: root/src/map/npc.cpp
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2013-02-18 19:20:35 -0800
committerBen Longbons <b.r.longbons@gmail.com>2013-02-20 18:27:30 -0800
commit25823b36905a84d92f9299ba7f9f0c713141c8fb (patch)
treea335120de1c4618c9b41391e70bc621a4218010c /src/map/npc.cpp
parenta5d231b6a60a4ab868918850be24640e88843825 (diff)
downloadtmwa-25823b36905a84d92f9299ba7f9f0c713141c8fb.tar.gz
tmwa-25823b36905a84d92f9299ba7f9f0c713141c8fb.tar.bz2
tmwa-25823b36905a84d92f9299ba7f9f0c713141c8fb.tar.xz
tmwa-25823b36905a84d92f9299ba7f9f0c713141c8fb.zip
Strictify map cells
Also fix a small but major bug in map_randfreecell.
Diffstat (limited to 'src/map/npc.cpp')
-rw-r--r--src/map/npc.cpp22
1 files changed, 14 insertions, 8 deletions
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);
}
}
}