summaryrefslogtreecommitdiffstats
path: root/src/ClientHandle.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-09-02 21:38:37 +0200
committerMattes D <github@xoft.cz>2014-09-02 21:38:37 +0200
commit82f203714677a7ae45804393853c3591c628e864 (patch)
treeea87cb927f0448e2960dff6d1763777942500213 /src/ClientHandle.cpp
parentRe-added alternate spellings of darkgraywool. (diff)
parentChanged the IsEnchantable() comment again. (diff)
downloadcuberite-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.cpp22
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))
{