1
0

Creative mode now breaks blocks without providing block drops. Need to work with Player's Inventory for proper creative mode support. GAMEMODE is declared and set twice.

git-svn-id: http://mc-server.googlecode.com/svn/trunk@16 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
admin@omencraft.com 2011-10-26 18:47:50 +00:00
parent acd537d533
commit 7b00d28157
7 changed files with 18 additions and 7 deletions

View File

@ -1,5 +1,5 @@
[Server] [Server]
Port=11111 Port=25565
ServerID=- ServerID=-
[Plugins] [Plugins]

View File

@ -472,7 +472,7 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
case E_BLOCK_DIG: case E_BLOCK_DIG:
{ {
cPacket_BlockDig* PacketData = reinterpret_cast<cPacket_BlockDig*>(a_Packet); 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 if( PacketData->m_Status == 0x04 ) // Drop block
{ {
m_Player->TossItem( false ); m_Player->TossItem( false );
@ -482,10 +482,10 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
cWorld* World = cRoot::Get()->GetWorld(); cWorld* World = cRoot::Get()->GetWorld();
char OldBlock = World->GetBlock(PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ); 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); 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; 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 ); ENUM_ITEM_ID PickupID = cBlockToPickup::ToPickup( (ENUM_BLOCK_ID)OldBlock, m_Player->GetInventory().GetEquippedItem().m_ItemID );
PickupItem.m_ItemID = PickupID; PickupItem.m_ItemID = PickupID;

View File

@ -20,6 +20,7 @@ public:
~cClientHandle(); ~cClientHandle();
static const int VIEWDISTANCE = 13; static const int VIEWDISTANCE = 13;
static const int GAMEMODE = 1; //0 = Survival, 1 = Creative;
const cSocket & GetSocket(); const cSocket & GetSocket();
cPlayer* GetPlayer() { return m_Player; } // tolua_export cPlayer* GetPlayer() { return m_Player; } // tolua_export

View File

@ -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 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; virtual cPacket* Clone() const = 0;
static const int GAMEMODE = 1; //0 = Survival, 1 = Creative;
unsigned char m_PacketID; unsigned char m_PacketID;
cSocket m_Socket; // Current socket being used cSocket m_Socket; // Current socket being used
protected: protected:

View File

@ -10,7 +10,7 @@ public:
cPacket_Login() cPacket_Login()
: m_ProtocolVersion( 0 ) : m_ProtocolVersion( 0 )
, m_MapSeed( 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_Dimension( 0 )
, m_Difficulty( 0 ) , m_Difficulty( 0 )
, m_WorldHeight( 0 ) , m_WorldHeight( 0 )

View File

@ -9,7 +9,7 @@ public:
cPacket_Respawn() cPacket_Respawn()
: m_World( 0 ) : m_World( 0 )
, m_Difficulty( 0 ) , m_Difficulty( 0 )
, m_CreativeMode( 0 ) , m_CreativeMode( GAMEMODE )
, m_WorldHeight( 0 ) , m_WorldHeight( 0 )
, m_MapSeed( 0 ) , m_MapSeed( 0 )
{ m_PacketID = E_RESPAWN; } { m_PacketID = E_RESPAWN; }

View File

@ -4,5 +4,13 @@ Groups=Admins
[Duralex] [Duralex]
Groups=Admins Groups=Admins
[Player] [Luthrandel]
Groups=Admins Groups=Admins
[Cruisecho]
Groups=Admins
[Kwen]
Groups=Admins