diff options
author | Mattes D <github@xoft.cz> | 2015-04-22 07:52:30 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2015-04-22 07:52:30 +0200 |
commit | 6d99a0b9684cc94ba76dd211b60eceb846339901 (patch) | |
tree | a99e995df3c92f6aad3bd9343c164676f5285184 | |
parent | Hotfixed some chunk presence issues when generating. (diff) | |
parent | Narrowed WindowID to use only 7 bits. (diff) | |
download | cuberite-6d99a0b9684cc94ba76dd211b60eceb846339901.tar cuberite-6d99a0b9684cc94ba76dd211b60eceb846339901.tar.gz cuberite-6d99a0b9684cc94ba76dd211b60eceb846339901.tar.bz2 cuberite-6d99a0b9684cc94ba76dd211b60eceb846339901.tar.lz cuberite-6d99a0b9684cc94ba76dd211b60eceb846339901.tar.xz cuberite-6d99a0b9684cc94ba76dd211b60eceb846339901.tar.zst cuberite-6d99a0b9684cc94ba76dd211b60eceb846339901.zip |
Diffstat (limited to '')
-rw-r--r-- | src/UI/Window.cpp | 8 | ||||
-rw-r--r-- | src/UI/Window.h | 2 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index bb2e2a807..d1c08acec 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -21,19 +21,23 @@ -char cWindow::m_WindowIDCounter = 1; +Byte cWindow::m_WindowIDCounter = 0; cWindow::cWindow(WindowType a_WindowType, const AString & a_WindowTitle) : - m_WindowID((++m_WindowIDCounter) % 127), + m_WindowID(static_cast<char>((++m_WindowIDCounter) % 127)), m_WindowType(a_WindowType), m_WindowTitle(a_WindowTitle), m_IsDestroyed(false), m_Owner(nullptr) { + // The window ID is signed in protocol 1.7, unsigned in protocol 1.8. Keep out of trouble by using only 7 bits: + // Ref.: http://forum.mc-server.org/showthread.php?tid=1876 + ASSERT((m_WindowID >= 0) && (m_WindowID < 127)); + if (a_WindowType == wtInventory) { m_WindowID = 0; diff --git a/src/UI/Window.h b/src/UI/Window.h index 9821aade1..156028465 100644 --- a/src/UI/Window.h +++ b/src/UI/Window.h @@ -185,7 +185,7 @@ protected: cWindowOwner * m_Owner; - static char m_WindowIDCounter; + static Byte m_WindowIDCounter; /// Sets the internal flag as "destroyed"; notifies the owner that the window is destroying virtual void Destroy(void); |