diff options
author | Hownaer <franzi.moos@googlemail.com> | 2014-08-28 14:58:03 +0200 |
---|---|---|
committer | Hownaer <franzi.moos@googlemail.com> | 2014-08-28 14:58:03 +0200 |
commit | 6c3b80f04c7c2cca26efb57cc9827a7a1d20fcda (patch) | |
tree | 53ee50fb66b98dc4ac1e7d5d559273118226cce1 /src/ClientHandle.cpp | |
parent | Enchanting table improvements. (diff) | |
download | cuberite-6c3b80f04c7c2cca26efb57cc9827a7a1d20fcda.tar cuberite-6c3b80f04c7c2cca26efb57cc9827a7a1d20fcda.tar.gz cuberite-6c3b80f04c7c2cca26efb57cc9827a7a1d20fcda.tar.bz2 cuberite-6c3b80f04c7c2cca26efb57cc9827a7a1d20fcda.tar.lz cuberite-6c3b80f04c7c2cca26efb57cc9827a7a1d20fcda.tar.xz cuberite-6c3b80f04c7c2cca26efb57cc9827a7a1d20fcda.tar.zst cuberite-6c3b80f04c7c2cca26efb57cc9827a7a1d20fcda.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 8aa883144..1dd8ff31c 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -2857,11 +2857,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)) { |