From d2940e8f7f0aea892dc12918f02b190ea64f7546 Mon Sep 17 00:00:00 2001 From: ephphatha Date: Sun, 10 Oct 2021 00:40:07 +1100 Subject: [PATCH] Update GetObjectStr to take a const Object& Brings it in line with GetItemStr --- Source/control.cpp | 2 +- Source/objects.cpp | 18 +++++++++--------- Source/objects.h | 6 +++++- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Source/control.cpp b/Source/control.cpp index d86725e14..03a5cfb50 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -1386,7 +1386,7 @@ void DrawInfoBox(const Surface &out) if (pcursitem != -1) GetItemStr(Items[pcursitem]); else if (pcursobj != -1) - GetObjectStr(pcursobj); + GetObjectStr(Objects[pcursobj]); if (pcursmonst != -1) { if (leveltype != DTYPE_TOWN) { const auto &monster = Monsters[pcursmonst]; diff --git a/Source/objects.cpp b/Source/objects.cpp index 96f199ccc..95cd7ac7f 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -5332,9 +5332,9 @@ void SyncObjectAnim(Object &object) } } -void GetObjectStr(int i) +void GetObjectStr(const Object &object) { - switch (Objects[i]._otype) { + switch (object._otype) { case OBJ_CRUX1: case OBJ_CRUX2: case OBJ_CRUX3: @@ -5350,11 +5350,11 @@ void GetObjectStr(int i) case OBJ_L2RDOOR: case OBJ_L3LDOOR: case OBJ_L3RDOOR: - if (Objects[i]._oVar4 == 1) + if (object._oVar4 == 1) strcpy(infostr, _("Open Door")); - if (Objects[i]._oVar4 == 0) + if (object._oVar4 == 0) strcpy(infostr, _("Closed Door")); - if (Objects[i]._oVar4 == 2) + if (object._oVar4 == 2) strcpy(infostr, _("Blocked Door")); break; case OBJ_BOOK2L: @@ -5406,7 +5406,7 @@ void GetObjectStr(int i) break; case OBJ_SHRINEL: case OBJ_SHRINER: - strcpy(tempstr, fmt::format(_(/* TRANSLATORS: {:s} will be a name from the Shrine block above */ "{:s} Shrine"), _(ShrineNames[Objects[i]._oVar1])).c_str()); + strcpy(tempstr, fmt::format(_(/* TRANSLATORS: {:s} will be a name from the Shrine block above */ "{:s} Shrine"), _(ShrineNames[object._oVar1])).c_str()); strcpy(infostr, tempstr); break; case OBJ_SKELBOOK: @@ -5456,7 +5456,7 @@ void GetObjectStr(int i) strcpy(infostr, _("Pedestal of Blood")); break; case OBJ_STORYBOOK: - strcpy(infostr, _(StoryBookName[Objects[i]._oVar3])); + strcpy(infostr, _(StoryBookName[object._oVar3])); break; case OBJ_WEAPONRACK: strcpy(infostr, _("Weapon Rack")); @@ -5474,13 +5474,13 @@ void GetObjectStr(int i) break; } if (Players[MyPlayerId]._pClass == HeroClass::Rogue) { - if (Objects[i]._oTrapFlag) { + if (object._oTrapFlag) { strcpy(tempstr, fmt::format(_(/* TRANSLATORS: {:s} will either be a chest or a door */ "Trapped {:s}"), infostr).c_str()); strcpy(infostr, tempstr); InfoColor = UiFlags::ColorRed; } } - if (Objects[i].IsDisabled()) { + if (object.IsDisabled()) { strcpy(tempstr, fmt::format(_(/* TRANSLATORS: If user enabled diablo.ini setting "Disable Crippling Shrines" is set to 1; also used for Na-Kruls leaver */ "{:s} (disabled)"), infostr).c_str()); strcpy(infostr, tempstr); InfoColor = UiFlags::ColorRed; diff --git a/Source/objects.h b/Source/objects.h index f6575b913..7a7fac893 100644 --- a/Source/objects.h +++ b/Source/objects.h @@ -169,7 +169,11 @@ void SyncOpObject(int pnum, int cmd, int i); void BreakObject(int pnum, int oi); void SyncBreakObj(int pnum, int oi); void SyncObjectAnim(Object &object); -void GetObjectStr(int i); +/** + * @brief Updates the text drawn in the info box to describe the given object + * @param object The currently highlighted object +*/ +void GetObjectStr(const Object &object); void OperateNakrulLever(); void SyncNakrulRoom(); void AddNakrulLeaver();