From 3ef6ecb8d2cdb45a3fdcc58485316d4b75c41139 Mon Sep 17 00:00:00 2001 From: "cedeel@gmail.com" Date: Fri, 15 Jun 2012 15:55:53 +0000 Subject: Basic handling of vines. No growth yet. git-svn-id: http://mc-server.googlecode.com/svn/trunk@615 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- VC2008/MCServer.vcproj | 4 ++++ VC2010/MCServer.vcxproj | 3 ++- VC2010/MCServer.vcxproj.filters | 5 ++++- source/cClientHandle.cpp | 31 ++++++++++++++++++------------- source/cVine.h | 24 ++++++++++++++++++++++++ 5 files changed, 52 insertions(+), 15 deletions(-) create mode 100644 source/cVine.h diff --git a/VC2008/MCServer.vcproj b/VC2008/MCServer.vcproj index f81bedf26..058f8be77 100644 --- a/VC2008/MCServer.vcproj +++ b/VC2008/MCServer.vcproj @@ -1388,6 +1388,10 @@ RelativePath="..\source\cTorch.h" > + + + @@ -705,4 +706,4 @@ - \ No newline at end of file + diff --git a/VC2010/MCServer.vcxproj.filters b/VC2010/MCServer.vcxproj.filters index 0db247c6c..0a3e16992 100644 --- a/VC2010/MCServer.vcxproj.filters +++ b/VC2010/MCServer.vcxproj.filters @@ -996,6 +996,9 @@ HandyStuff + + HandyStuff + cGroupManager @@ -1427,4 +1430,4 @@ - \ No newline at end of file + diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp index 645eb673b..df97b74f6 100644 --- a/source/cClientHandle.cpp +++ b/source/cClientHandle.cpp @@ -18,6 +18,7 @@ #include "cStep.h" #include "cDoors.h" #include "cLadder.h" +#include "cVine.h" #include "cSign.h" #include "cRedstone.h" #include "cPiston.h" @@ -307,7 +308,7 @@ void cClientHandle::Authenticate(void) m_Player->SetIP (m_Socket.GetIPString()); - cRoot::Get()->GetPluginManager()->CallHook(cPluginManager::E_PLUGIN_PLAYER_SPAWN, 1, m_Player); + cRoot::Get()->GetPluginManager()->CallHook(cPluginManager::HOOK_PLAYER_SPAWN, 1, m_Player); // Return a server login packet cPacket_Login LoginResponse; @@ -686,7 +687,7 @@ void cClientHandle::HandleLogin(cPacket_Login * a_Packet) return; } - if (cRoot::Get()->GetPluginManager()->CallHook(cPluginManager::E_PLUGIN_LOGIN, 1, a_Packet)) + if (cRoot::Get()->GetPluginManager()->CallHook(cPluginManager::HOOK_LOGIN, 1, a_Packet)) { Destroy(); return; @@ -796,7 +797,7 @@ void cClientHandle::HandleBlockDig(cPacket_BlockDig * a_Packet) BLOCKTYPE OldBlock = World->GetBlock(a_Packet->m_PosX, a_Packet->m_PosY, a_Packet->m_PosZ); NIBBLETYPE OldMeta = World->GetBlockMeta(a_Packet->m_PosX, a_Packet->m_PosY, a_Packet->m_PosZ); - if (cRoot::Get()->GetPluginManager()->CallHook(cPluginManager::E_PLUGIN_BLOCK_DIG, 4, a_Packet, m_Player, OldBlock, OldMeta)) + if (cRoot::Get()->GetPluginManager()->CallHook(cPluginManager::HOOK_BLOCK_DIG, 4, a_Packet, m_Player, OldBlock, OldMeta)) { // The plugin doesn't agree with the digging, replace the block on the client and quit: World->SendBlockTo(a_Packet->m_PosX, a_Packet->m_PosY, a_Packet->m_PosZ, m_Player); @@ -921,7 +922,7 @@ void cClientHandle::HandleBlockPlace(cPacket_BlockPlace * a_Packet) return; } - if (cRoot::Get()->GetPluginManager()->CallHook(cPluginManager::E_PLUGIN_BLOCK_PLACE, 2, a_Packet, m_Player)) + if (cRoot::Get()->GetPluginManager()->CallHook(cPluginManager::HOOK_BLOCK_PLACE, 2, a_Packet, m_Player)) { if (a_Packet->m_Direction > -1) { @@ -1032,7 +1033,6 @@ void cClientHandle::HandleBlockPlace(cPacket_BlockPlace * a_Packet) if (ClickedBlock == E_BLOCK_STEP) { // Only make double slab if meta values are the same and if player clicked either on top or on bottom of the block (direction either 0 or 1) - // TODO check if it works from beneath if (MetaData == ( m_Player->GetWorld()->GetBlockMeta(a_Packet->m_PosX, a_Packet->m_PosY, a_Packet->m_PosZ) & 0x7) && a_Packet->m_Direction <= 1) //if (MetaData == m_Player->GetWorld()->GetBlockMeta(a_Packet->m_PosX, a_Packet->m_PosY, a_Packet->m_PosZ) && a_Packet->m_Direction == 1) { @@ -1049,7 +1049,7 @@ void cClientHandle::HandleBlockPlace(cPacket_BlockPlace * a_Packet) } } - if ((ClickedBlock == E_BLOCK_SNOW) || (ClickedBlock == E_BLOCK_TALL_GRASS)) + if ((ClickedBlock == E_BLOCK_SNOW) || (ClickedBlock == E_BLOCK_TALL_GRASS) || (ClickedBlock == E_BLOCK_VINES)) { switch (a_Packet->m_Direction) { @@ -1216,11 +1216,11 @@ void cClientHandle::HandleBlockPlace(cPacket_BlockPlace * a_Packet) break; } - case E_BLOCK_STEP: - { - MetaData += cStep::DirectionToMetaData( a_Packet->m_Direction ); - break; - } + case E_BLOCK_STEP: + { + MetaData += cStep::DirectionToMetaData( a_Packet->m_Direction ); + break; + } case E_BLOCK_COBBLESTONE_STAIRS: case E_BLOCK_BRICK_STAIRS: @@ -1231,6 +1231,11 @@ void cClientHandle::HandleBlockPlace(cPacket_BlockPlace * a_Packet) MetaData = cStairs::RotationToMetaData(m_Player->GetRotation(), a_Packet->m_Direction); break; } + case E_BLOCK_VINES: + { + MetaData = cVine::DirectionToMetaData(a_Packet->m_Direction); + break; + } case E_BLOCK_LADDER: { MetaData = cLadder::DirectionToMetaData(a_Packet->m_Direction); @@ -1579,7 +1584,7 @@ void cClientHandle::HandleRespawn(void) void cClientHandle::HandleDisconnect(cPacket_Disconnect * a_Packet) { LOG("Received d/c packet from \"%s\"", m_Username.c_str()); - if (!cRoot::Get()->GetPluginManager()->CallHook(cPluginManager::E_PLUGIN_DISCONNECT, 2, a_Packet->m_Reason.c_str(), m_Player)) + if (!cRoot::Get()->GetPluginManager()->CallHook(cPluginManager::HOOK_DISCONNECT, 2, a_Packet->m_Reason.c_str(), m_Player)) { cPacket_Chat DisconnectMessage(m_Username + " disconnected: " + a_Packet->m_Reason); cRoot::Get()->GetServer()->Broadcast(DisconnectMessage); @@ -1838,7 +1843,7 @@ void cClientHandle::SendConfirmPosition(void) m_State = csConfirmingPos; - if (!cRoot::Get()->GetPluginManager()->CallHook(cPluginManager::E_PLUGIN_PLAYER_JOIN, 1, m_Player)) + if (!cRoot::Get()->GetPluginManager()->CallHook(cPluginManager::HOOK_PLAYER_JOIN, 1, m_Player)) { // Broadcast that this player has joined the game! Yay~ cPacket_Chat Joined(m_Username + " joined the game!"); diff --git a/source/cVine.h b/source/cVine.h new file mode 100644 index 000000000..6d2a92d15 --- /dev/null +++ b/source/cVine.h @@ -0,0 +1,24 @@ +#pragma once + +class cVine //tolua_export +{ //tolua_export +public: + + static char DirectionToMetaData( char a_Direction ) + { + switch (a_Direction) + { + case 0x2: + return 0x1; + case 0x3: + return 0x4; + case 0x4: + return 0x8; + case 0x5: + return 0x2; + default: + return 0xf; + }; + return 0xf; + } //tolua_export +}; //tolua_export \ No newline at end of file -- cgit v1.2.3