From aa154e523116b3b2ce3af628fa1d006bf1bfac52 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Fri, 1 Jan 2021 21:09:25 +0100 Subject: [PATCH] Clean up LoadMapObjects --- Source/objects.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Source/objects.cpp b/Source/objects.cpp index b212ca42f..b428db65a 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -730,14 +730,15 @@ void AddChestTraps() void LoadMapObjects(BYTE *pMap, int startx, int starty, int x1, int y1, int w, int h, int leveridx) { - int rw, rh, i, j, oi; + int rw, rh, i, j, oi, type; BYTE *lm; long mapoff; InitObjFlag = TRUE; - lm = pMap + 2; - rw = pMap[0]; + lm = pMap; + rw = lm[0]; + lm += 2; rh = *lm; mapoff = (rw * rh + 1) * 2; rw <<= 1; @@ -748,7 +749,8 @@ void LoadMapObjects(BYTE *pMap, int startx, int starty, int x1, int y1, int w, i for (j = 0; j < rh; j++) { for (i = 0; i < rw; i++) { if (*lm) { - AddObject(ObjTypeConv[*lm], startx + 16 + i, starty + 16 + j); + type = lm[0]; + AddObject(ObjTypeConv[type], startx + 16 + i, starty + 16 + j); oi = ObjIndex(startx + 16 + i, starty + 16 + j); SetObjMapRange(oi, x1, y1, x1 + w, y1 + h, leveridx); }