From 8947147c25e2640519897bfdc8807e97ee291d70 Mon Sep 17 00:00:00 2001 From: KingCol13 <48412633+KingCol13@users.noreply.github.com> Date: Fri, 2 Oct 2020 00:33:32 +0300 Subject: Enchanting table shows detail on hover. Enchanting is deterministic. (#4937) * Use lapis for enchanting, subtract correct number of levels, ClientHandle now selects from pregenerated list. Co-authored-by: Tiger Wang --- src/UI/EnchantingWindow.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/UI/EnchantingWindow.cpp') diff --git a/src/UI/EnchantingWindow.cpp b/src/UI/EnchantingWindow.cpp index 4ce4bebb3..15d27fc63 100644 --- a/src/UI/EnchantingWindow.cpp +++ b/src/UI/EnchantingWindow.cpp @@ -28,13 +28,12 @@ cEnchantingWindow::cEnchantingWindow(Vector3i a_BlockPos, const AString & a_Titl void cEnchantingWindow::SetProperty(short a_Property, short a_Value, cPlayer & a_Player) { - if ((a_Property < 0) || (static_cast(a_Property) >= ARRAYCOUNT(m_PropertyValue))) + ASSERT(a_Property >= 0); + if (static_cast(a_Property) < m_PropertyValue.size()) { - ASSERT(!"a_Property is invalid"); - return; + m_PropertyValue[a_Property] = a_Value; } - m_PropertyValue[a_Property] = a_Value; Super::SetProperty(a_Property, a_Value, a_Player); } @@ -44,13 +43,12 @@ void cEnchantingWindow::SetProperty(short a_Property, short a_Value, cPlayer & a void cEnchantingWindow::SetProperty(short a_Property, short a_Value) { - if ((a_Property < 0) || (static_cast(a_Property) >= ARRAYCOUNT(m_PropertyValue))) + ASSERT(a_Property >= 0); + if (static_cast(a_Property) < m_PropertyValue.size()) { - ASSERT(!"a_Property is invalid"); - return; + m_PropertyValue[a_Property] = a_Value; } - m_PropertyValue[a_Property] = a_Value; Super::SetProperty(a_Property, a_Value); } @@ -58,9 +56,9 @@ void cEnchantingWindow::SetProperty(short a_Property, short a_Value) -short cEnchantingWindow::GetPropertyValue(short a_Property) +short cEnchantingWindow::GetProperty(short a_Property) { - if ((a_Property < 0) || (static_cast(a_Property) >= ARRAYCOUNT(m_PropertyValue))) + if ((a_Property < 0) || (static_cast(a_Property) >= m_PropertyValue.size())) { ASSERT(!"a_Property is invalid"); return 0; -- cgit v1.2.3