summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlapayo94@gmail.com <lapayo94@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2011-12-25 15:03:01 +0100
committerlapayo94@gmail.com <lapayo94@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2011-12-25 15:03:01 +0100
commit62737fd1632abd232e7e0ff00a19456bb28a4a37 (patch)
tree7bf91facfdbd586ff5c144eaf1ac6160b2965002
parentCode improvements (diff)
downloadcuberite-62737fd1632abd232e7e0ff00a19456bb28a4a37.tar
cuberite-62737fd1632abd232e7e0ff00a19456bb28a4a37.tar.gz
cuberite-62737fd1632abd232e7e0ff00a19456bb28a4a37.tar.bz2
cuberite-62737fd1632abd232e7e0ff00a19456bb28a4a37.tar.lz
cuberite-62737fd1632abd232e7e0ff00a19456bb28a4a37.tar.xz
cuberite-62737fd1632abd232e7e0ff00a19456bb28a4a37.tar.zst
cuberite-62737fd1632abd232e7e0ff00a19456bb28a4a37.zip
Diffstat (limited to '')
-rw-r--r--source/cClientHandle.cpp6
-rw-r--r--source/cPlayer.cpp28
-rw-r--r--source/cPlayer.h2
-rw-r--r--source/cWindow.cpp4
4 files changed, 32 insertions, 8 deletions
diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp
index fefdb8aec..902e3df2f 100644
--- a/source/cClientHandle.cpp
+++ b/source/cClientHandle.cpp
@@ -1095,10 +1095,13 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
case E_WINDOW_CLOSE:
{
cPacket_WindowClose* PacketData = reinterpret_cast<cPacket_WindowClose*>(a_Packet);
+ m_Player->CloseWindow(PacketData->m_Close);
+ /*
if( PacketData->m_Close > 0 ) // Don't care about closing inventory
{
m_Player->CloseWindow();
}
+ */
}
break;
case E_WINDOW_CLICK:
@@ -1176,10 +1179,9 @@ void cClientHandle::AuthenticateThread( void* a_Param )
cAuthenticator Authenticator;
if( !Authenticator.Authenticate( self->GetUsername(), cRoot::Get()->GetServer()->GetServerID() ) )
{
- self->Kick("You could not be authenticated, sorry buddy!");
+ self->Kick("Failed to verify username!");
return;
}
-
self->m_bSendLoginResponse = true;
}
diff --git a/source/cPlayer.cpp b/source/cPlayer.cpp
index 5a005005d..d13e1e5aa 100644
--- a/source/cPlayer.cpp
+++ b/source/cPlayer.cpp
@@ -108,7 +108,7 @@ cPlayer::~cPlayer(void)
SaveToDisk();
m_ClientHandle = 0;
- CloseWindow();
+ CloseWindow(-1);
if( m_Inventory )
{
delete m_Inventory;
@@ -401,14 +401,36 @@ Vector3d cPlayer::GetEyePosition()
void cPlayer::OpenWindow( cWindow* a_Window )
{
- CloseWindow();
+ CloseWindow(m_CurrentWindow ? (char)m_CurrentWindow->GetWindowType() : 0);
a_Window->Open( *this );
m_CurrentWindow = a_Window;
}
-void cPlayer::CloseWindow()
+void cPlayer::CloseWindow(char wID = -1)
{
if( m_CurrentWindow ) m_CurrentWindow->Close( *this );
+ if (wID == 0) {
+ if(GetInventory().GetWindow()->GetDraggingItem() && GetInventory().GetWindow()->GetDraggingItem()->m_ItemCount > 0)
+ {
+ LOG("Player holds item! Dropping it...");
+ TossItem( true, GetInventory().GetWindow()->GetDraggingItem()->m_ItemCount );
+ }
+
+ //Drop whats in the crafting slots (1, 2, 3, 4)
+ for( int i = 1; i <= 4; i++ )
+ {
+ cItem* Item = m_Inventory->GetSlot( i );
+ if( Item->m_ItemID > 0 && Item->m_ItemCount > 0 )
+ {
+ float vX = 0, vY = 0, vZ = 0;
+ EulerToVector( -GetRotation(), GetPitch(), vZ, vX, vY );
+ vY = -vY*2 + 1.f;
+ cPickup* Pickup = new cPickup( (int)(GetPosX()*32), (int)(GetPosY()*32) + (int)(1.6f*32), (int)(GetPosZ()*32), *Item, vX*2, vY*2, vZ*2 );
+ Pickup->Initialize( GetWorld() );
+ }
+ Item->Empty();
+ }
+ }
m_CurrentWindow = 0;
}
diff --git a/source/cPlayer.h b/source/cPlayer.h
index 195120fcd..c8bd6c473 100644
--- a/source/cPlayer.h
+++ b/source/cPlayer.h
@@ -46,7 +46,7 @@ public:
cWindow* GetWindow() { return m_CurrentWindow; }
void OpenWindow( cWindow* a_Window );
- void CloseWindow();
+ void CloseWindow(char wID);
cClientHandle* GetClientHandle() { return m_ClientHandle; } //tolua_export
void SetClientHandle( cClientHandle* a_Client ) { m_ClientHandle = a_Client; }
diff --git a/source/cWindow.cpp b/source/cWindow.cpp
index 3555c9c96..68c8d4142 100644
--- a/source/cWindow.cpp
+++ b/source/cWindow.cpp
@@ -224,9 +224,9 @@ void cWindow::OwnerDestroyed()
m_Owner = 0;
while( m_OpenedBy.size() > 1 )
{
- (*m_OpenedBy.begin() )->CloseWindow();
+ (*m_OpenedBy.begin() )->CloseWindow((char)GetWindowType());
}
- (*m_OpenedBy.begin() )->CloseWindow();
+ (*m_OpenedBy.begin() )->CloseWindow((char)GetWindowType());
}
void cWindow::Destroy()