From 1bf319bc11d82bf745b6f36fe07d90be4a830846 Mon Sep 17 00:00:00 2001 From: Juliano Leal Goncalves Date: Sun, 30 May 2021 19:24:32 -0300 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Leverage=20'Point'=20struc?= =?UTF-8?q?t=20on=20'ItemPlace'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/items.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/items.cpp b/Source/items.cpp index 4f4bf2593..00dc392c4 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -420,19 +420,19 @@ void InitItemGFX() memset(UniqueItemFlags, 0, sizeof(UniqueItemFlags)); } -bool ItemPlace(int xp, int yp) +bool ItemPlace(Point position) { - if (dMonster[xp][yp] != 0) + if (dMonster[position.x][position.y] != 0) return false; - if (dPlayer[xp][yp] != 0) + if (dPlayer[position.x][position.y] != 0) return false; - if (dItem[xp][yp] != 0) + if (dItem[position.x][position.y] != 0) return false; - if (dObject[xp][yp] != 0) + if (dObject[position.x][position.y] != 0) return false; - if ((dFlags[xp][yp] & BFLAG_POPULATED) != 0) + if ((dFlags[position.x][position.y] & BFLAG_POPULATED) != 0) return false; - if (nSolidTable[dPiece[xp][yp]]) + if (nSolidTable[dPiece[position.x][position.y]]) return false; return true; @@ -443,7 +443,7 @@ Point GetRandomAvailableItemPosition() Point position = {}; do { position = Point { 16, 16 } + Point { GenerateRnd(80), GenerateRnd(80) }; - } while (!ItemPlace(position.x, position.y)); + } while (!ItemPlace(position)); return position; }