summaryrefslogtreecommitdiffstats
path: root/src/ClientHandle.cpp
diff options
context:
space:
mode:
authorHownaer <franzi.moos@googlemail.com>2014-08-28 14:58:03 +0200
committerHownaer <franzi.moos@googlemail.com>2014-08-28 14:58:03 +0200
commit6c3b80f04c7c2cca26efb57cc9827a7a1d20fcda (patch)
tree53ee50fb66b98dc4ac1e7d5d559273118226cce1 /src/ClientHandle.cpp
parentEnchanting table improvements. (diff)
downloadcuberite-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.cpp22
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))
{