From d7068b35a85f0c0248a5533240087747d02e1a17 Mon Sep 17 00:00:00 2001 From: "lapayo94@gmail.com" Date: Sun, 1 Jan 2012 04:55:17 +0000 Subject: - implemented separated inventory for creative mode (cSurvivalInventory and cCreativeInventory) (Separation is not perfect yet, because maybe there are some mayor changes needed :D) - implemented CreativeInventoryAction (was mistakenly called CreateInventoryAction) -> Fixed meta data for creative selected blocks ->->Slabs/Steps are now placed correctly - slabs can now be build to a double slab - fixed a bug in the inventory which put items with different meta values in the same slot git-svn-id: http://mc-server.googlecode.com/svn/trunk@160 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cPlayer.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'source/cPlayer.cpp') diff --git a/source/cPlayer.cpp b/source/cPlayer.cpp index baba0174a..12f3c5a30 100644 --- a/source/cPlayer.cpp +++ b/source/cPlayer.cpp @@ -1,6 +1,7 @@ #include "cPlayer.h" #include "cServer.h" -#include "cInventory.h" +#include "cCreativeInventory.h" +#include "cSurvivalInventory.h" #include "cClientHandle.h" #include "cWorld.h" #include "cPickup.h" @@ -82,7 +83,8 @@ cPlayer::cPlayer(cClientHandle* a_Client, const char* a_PlayerName) m_EntityType = E_PLAYER; SetMaxHealth(20); SetMaxFoodLevel(125); - m_Inventory = new cInventory( this ); + m_Inventory = new cSurvivalInventory( this ); + m_CreativeInventory = new cCreativeInventory(this); cTimer t1; m_LastPlayerListTime = t1.GetNowTime(); @@ -118,6 +120,10 @@ cPlayer::~cPlayer(void) delete m_Inventory; m_Inventory = 0; } + if(m_CreativeInventory) + { + delete m_CreativeInventory; + } delete m_pState; GetWorld()->RemovePlayer( this ); // TODO - Remove from correct world? Or get rid of this? } @@ -398,10 +404,10 @@ void cPlayer::OpenWindow( cWindow* a_Window ) void cPlayer::CloseWindow(char a_WindowType) { if (a_WindowType == 0) { // Inventory - if(GetInventory().GetWindow()->GetDraggingItem() && GetInventory().GetWindow()->GetDraggingItem()->m_ItemCount > 0) + if(m_Inventory->GetWindow()->GetDraggingItem() && m_Inventory->GetWindow()->GetDraggingItem()->m_ItemCount > 0) { LOG("Player holds item! Dropping it..."); - TossItem( true, GetInventory().GetWindow()->GetDraggingItem()->m_ItemCount ); + TossItem( true, m_Inventory->GetWindow()->GetDraggingItem()->m_ItemCount ); } //Drop whats in the crafting slots (1, 2, 3, 4) @@ -458,6 +464,7 @@ void cPlayer::SetGameMode( int a_GameMode ) GameModePacket.m_Reason = 3; //GameModeChange GameModePacket.m_GameMode = (char)a_GameMode; //GameModeChange m_ClientHandle->Send ( GameModePacket ); + GetInventory().SendWholeInventory(m_ClientHandle); } } } @@ -651,7 +658,7 @@ void cPlayer::TossItem( bool a_bDraggingItem, int a_Amount /* = 1 */ ) { if( a_bDraggingItem ) { - cItem* Item = GetInventory().GetWindow()->GetDraggingItem(); + cItem* Item = GetSurvivalInventory().GetWindow()->GetDraggingItem(); if( Item->m_ItemID > 0 && Item->m_ItemCount >= a_Amount ) { float vX = 0, vY = 0, vZ = 0; -- cgit v1.2.3