From f60cc3bfd9f2cc57082b1d330a7dcddc8bf6e8d4 Mon Sep 17 00:00:00 2001 From: ephphatha Date: Thu, 23 Sep 2021 22:39:59 +1000 Subject: [PATCH] Update calls to DeleteItem to use ActiveItems inline This highlights how all (except one) call sites duplicate the i argument. With the exception of the use in msg.cpp this can be treated as a offset into activeItems and doesn't care about the real index. --- Source/items.cpp | 2 +- Source/loadsave.cpp | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Source/items.cpp b/Source/items.cpp index 661ac9e44..775c22406 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -3567,7 +3567,7 @@ void CornerstoneLoad(Point position) int ii = dItem[position.x][position.y] - 1; for (int i = 0; i < ActiveItemCount; i++) { if (ActiveItems[i] == ii) { - DeleteItem(ii, i); + DeleteItem(ActiveItems[i], i); break; } } diff --git a/Source/loadsave.cpp b/Source/loadsave.cpp index 5151b4e43..b1cb568fe 100644 --- a/Source/loadsave.cpp +++ b/Source/loadsave.cpp @@ -928,11 +928,10 @@ void LoadDroppedItemLocations(LoadHelper &file, const std::unordered_map 0; i--) { - int ii = ActiveItems[i]; - auto &item = Items[ii]; + auto &item = Items[ActiveItems[i]]; if (item.isEmpty()) { dItem[item.position.x][item.position.y] = 0; - DeleteItem(ii, i); + DeleteItem(ActiveItems[i], i); } } }