summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteph Enders <smenders@gmail.com>2022-12-17 11:54:18 -0500
committerSteph Enders <smenders@gmail.com>2022-12-17 11:54:18 -0500
commit90909fb803e0c40a67b08cd41f6d0d447ee62f74 (patch)
treec3d2e010f0bd7cffdecf291f279505a536bd9fc8
parent8e101f8bfd995321ac08a16fea9a171b549a0ae4 (diff)
Fix door logic, off by 1 error
We were popping the door from the vector and then referencing it by it's index which meant we'd always reference the WRONG door
-rw-r--r--maps/lvl5/dng.map16
-rw-r--r--src/CApi.h2
2 files changed, 17 insertions, 1 deletions
diff --git a/maps/lvl5/dng.map b/maps/lvl5/dng.map
new file mode 100644
index 0000000..0ad94ca
--- /dev/null
+++ b/maps/lvl5/dng.map
@@ -0,0 +1,16 @@
+w w w w w w w w w
+w 0 0 0 0 a 0 2 w
+w p 0 0 0 w w w w
+w 0 0 0 0 b 0 3 w
+w 0 0 0 0 w w w w
+w 0 0 0 0 c 0 4 w
+w 0 0 0 0 w w w w
+w 0 0 0 0 d 1 t w
+w 0 0 0 0 w w w w
+w 0 0 0 0 d 0 4 w
+w 0 0 0 0 w w w w
+w 0 0 0 0 a 0 t w
+w 0 0 0 0 w w w w
+w 0 0 0 0 w w w w
+w 0 0 0 0 0 0 1 w
+w w w w w w w w w
diff --git a/src/CApi.h b/src/CApi.h
index c6ffea3..9dbf4d9 100644
--- a/src/CApi.h
+++ b/src/CApi.h
@@ -236,9 +236,9 @@ static int c_open_door(lua_State *L) {
can_open = true;
// erase key
lvl->heldKeys.erase(lvl->heldKeys.begin() + k);
- lvl->doorPositions.erase(lvl->doorPositions.begin() + i);
lvl->map[lvl->doorPositions[i].y][lvl->doorPositions[i].x] =
BLANK_SPACE;
+ lvl->doorPositions.erase(lvl->doorPositions.begin() + i);
break;
}
}