summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authoradmin@omencraft.com <admin@omencraft.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2011-10-26 20:47:50 +0200
committeradmin@omencraft.com <admin@omencraft.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2011-10-26 20:47:50 +0200
commit7b00d2815765f16b4a5cac8b5d0bf6d13d56acda (patch)
tree057af5ee1604c7a0b8d423bb2d138839762797ca /source
parentAdded CreateInventoryAction packet for creative mode. Used cPacketEntityEquipment as template. Forced server into Creative Mode. Can't break blocks yet. Player can stil be damaged in creative mode and dying takes you back to survival mode. (diff)
downloadcuberite-7b00d2815765f16b4a5cac8b5d0bf6d13d56acda.tar
cuberite-7b00d2815765f16b4a5cac8b5d0bf6d13d56acda.tar.gz
cuberite-7b00d2815765f16b4a5cac8b5d0bf6d13d56acda.tar.bz2
cuberite-7b00d2815765f16b4a5cac8b5d0bf6d13d56acda.tar.lz
cuberite-7b00d2815765f16b4a5cac8b5d0bf6d13d56acda.tar.xz
cuberite-7b00d2815765f16b4a5cac8b5d0bf6d13d56acda.tar.zst
cuberite-7b00d2815765f16b4a5cac8b5d0bf6d13d56acda.zip
Diffstat (limited to 'source')
-rw-r--r--source/cClientHandle.cpp6
-rw-r--r--source/cClientHandle.h1
-rw-r--r--source/packets/cPacket.h2
-rw-r--r--source/packets/cPacket_Login.h2
-rw-r--r--source/packets/cPacket_Respawn.h2
5 files changed, 8 insertions, 5 deletions
diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp
index f21815e52..9b1e886dd 100644
--- a/source/cClientHandle.cpp
+++ b/source/cClientHandle.cpp
@@ -472,7 +472,7 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
case E_BLOCK_DIG:
{
cPacket_BlockDig* PacketData = reinterpret_cast<cPacket_BlockDig*>(a_Packet);
- //LOG("OnBlockDig: %i %i %i Dir: %i Stat: %i", PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ, PacketData->m_Direction, PacketData->m_Status );
+ LOG("OnBlockDig: %i %i %i Dir: %i Stat: %i", PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ, PacketData->m_Direction, PacketData->m_Status );
if( PacketData->m_Status == 0x04 ) // Drop block
{
m_Player->TossItem( false );
@@ -482,10 +482,10 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
cWorld* World = cRoot::Get()->GetWorld();
char OldBlock = World->GetBlock(PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ);
char MetaData = World->GetBlockMeta(PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ);
- bool bBroken = (PacketData->m_Status == 0x02) || g_BlockOneHitDig[(int)OldBlock];
+ bool bBroken = (PacketData->m_Status == 0x02) || g_BlockOneHitDig[(int)OldBlock] || ( (PacketData->m_Status == 0x00) && (GAMEMODE == 1) ); //need to change to check for client's gamemode.
cItem PickupItem;
- if( bBroken ) // broken
+ if( bBroken && !(GAMEMODE == 1) ) // broken
{
ENUM_ITEM_ID PickupID = cBlockToPickup::ToPickup( (ENUM_BLOCK_ID)OldBlock, m_Player->GetInventory().GetEquippedItem().m_ItemID );
PickupItem.m_ItemID = PickupID;
diff --git a/source/cClientHandle.h b/source/cClientHandle.h
index 224ba46b3..a704ffc0e 100644
--- a/source/cClientHandle.h
+++ b/source/cClientHandle.h
@@ -20,6 +20,7 @@ public:
~cClientHandle();
static const int VIEWDISTANCE = 13;
+ static const int GAMEMODE = 1; //0 = Survival, 1 = Creative;
const cSocket & GetSocket();
cPlayer* GetPlayer() { return m_Player; } // tolua_export
diff --git a/source/packets/cPacket.h b/source/packets/cPacket.h
index 304d6b8d3..ff4366c7a 100644
--- a/source/packets/cPacket.h
+++ b/source/packets/cPacket.h
@@ -22,6 +22,8 @@ public:
virtual bool Send( cSocket & a_Socket) { a_Socket=0; printf("ERROR: Undefined NEW Send function %x\n", m_PacketID ); return false; }
virtual cPacket* Clone() const = 0;
+ static const int GAMEMODE = 1; //0 = Survival, 1 = Creative;
+
unsigned char m_PacketID;
cSocket m_Socket; // Current socket being used
protected:
diff --git a/source/packets/cPacket_Login.h b/source/packets/cPacket_Login.h
index 812893d54..81c8af39b 100644
--- a/source/packets/cPacket_Login.h
+++ b/source/packets/cPacket_Login.h
@@ -10,7 +10,7 @@ public:
cPacket_Login()
: m_ProtocolVersion( 0 )
, m_MapSeed( 0 )
- , m_ServerMode( 1 ) //0 for survival, 1 for creative
+ , m_ServerMode( GAMEMODE ) //0 for survival, 1 for creative
, m_Dimension( 0 )
, m_Difficulty( 0 )
, m_WorldHeight( 0 )
diff --git a/source/packets/cPacket_Respawn.h b/source/packets/cPacket_Respawn.h
index ab8fbe72a..9a87d11ae 100644
--- a/source/packets/cPacket_Respawn.h
+++ b/source/packets/cPacket_Respawn.h
@@ -9,7 +9,7 @@ public:
cPacket_Respawn()
: m_World( 0 )
, m_Difficulty( 0 )
- , m_CreativeMode( 0 )
+ , m_CreativeMode( GAMEMODE )
, m_WorldHeight( 0 )
, m_MapSeed( 0 )
{ m_PacketID = E_RESPAWN; }