Fixes problems with windows:

- Changed cPlayer:OpenWindow to accept a ref, tolua adds a nil check
- Close open lua window in destructor, to avoid dangling pointers
This commit is contained in:
Lukas Pioch
2017-06-05 15:14:23 +02:00
parent 2b699dc749
commit 7922e6addb
15 changed files with 39 additions and 18 deletions
+1 -1
View File
@@ -1222,7 +1222,7 @@ void cMinecartWithChest::OnRightClicked(cPlayer & a_Player)
{
if (a_Player.GetWindow() != Window)
{
a_Player.OpenWindow(Window);
a_Player.OpenWindow(*Window);
}
}
}
+5 -5
View File
@@ -1310,15 +1310,15 @@ cTeam * cPlayer::UpdateTeam(void)
void cPlayer::OpenWindow(cWindow * a_Window)
void cPlayer::OpenWindow(cWindow & a_Window)
{
if (a_Window != m_CurrentWindow)
if (&a_Window != m_CurrentWindow)
{
CloseWindow(false);
}
a_Window->OpenedByPlayer(*this);
m_CurrentWindow = a_Window;
a_Window->SendWholeWindow(*GetClientHandle());
a_Window.OpenedByPlayer(*this);
m_CurrentWindow = &a_Window;
a_Window.SendWholeWindow(*GetClientHandle());
}
+1 -1
View File
@@ -229,7 +229,7 @@ public:
// tolua_begin
/** Opens the specified window; closes the current one first using CloseWindow() */
void OpenWindow(cWindow * a_Window);
void OpenWindow(cWindow & a_Window);
/** Closes the current window, resets current window to m_InventoryWindow. A plugin may refuse the closing if a_CanRefuse is true */
void CloseWindow(bool a_CanRefuse = true);