diff options
author | Mattes D <github@xoft.cz> | 2014-09-02 21:38:37 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-09-02 21:38:37 +0200 |
commit | 82f203714677a7ae45804393853c3591c628e864 (patch) | |
tree | ea87cb927f0448e2960dff6d1763777942500213 /src/ClientHandle.cpp | |
parent | Re-added alternate spellings of darkgraywool. (diff) | |
parent | Changed the IsEnchantable() comment again. (diff) | |
download | cuberite-82f203714677a7ae45804393853c3591c628e864.tar cuberite-82f203714677a7ae45804393853c3591c628e864.tar.gz cuberite-82f203714677a7ae45804393853c3591c628e864.tar.bz2 cuberite-82f203714677a7ae45804393853c3591c628e864.tar.lz cuberite-82f203714677a7ae45804393853c3591c628e864.tar.xz cuberite-82f203714677a7ae45804393853c3591c628e864.tar.zst cuberite-82f203714677a7ae45804393853c3591c628e864.zip |
Diffstat (limited to 'src/ClientHandle.cpp')
-rw-r--r-- | src/ClientHandle.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index f9c6a664c..4a768771e 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -2858,11 +2858,27 @@ void cClientHandle::SocketClosed(void) -void cClientHandle::HandleEnchantItem(Byte & WindowID, Byte & Enchantment) +void cClientHandle::HandleEnchantItem(Byte & a_WindowID, Byte & a_Enchantment) { - cEnchantingWindow * Window = (cEnchantingWindow*)m_Player->GetWindow(); + if (a_Enchantment > 2) + { + LOGWARNING("%s attempt to crash the server with invalid enchanting selection!", GetUsername().c_str()); + Kick("Invalid enchanting!"); + return; + } + + if ( + (m_Player->GetWindow() == NULL) || + (m_Player->GetWindow()->GetWindowID() != a_WindowID) || + (m_Player->GetWindow()->GetWindowType() != cWindow::wtEnchantment) + ) + { + return; + } + + cEnchantingWindow * Window = (cEnchantingWindow*) m_Player->GetWindow(); cItem Item = *Window->m_SlotArea->GetSlot(0, *m_Player); - int BaseEnchantmentLevel = Window->GetPropertyValue(Enchantment); + int BaseEnchantmentLevel = Window->GetPropertyValue(a_Enchantment); if (Item.EnchantByXPLevels(BaseEnchantmentLevel)) { |