1
0

Updated the thunderbolt packet. Lightning and rain can be tested with a workbench and a chest. >:)

git-svn-id: http://mc-server.googlecode.com/svn/trunk@48 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
admin@omencraft.com 2011-11-03 00:42:53 +00:00
parent a5af50c293
commit 39fd1697e4
3 changed files with 42 additions and 11 deletions

View File

@ -57,6 +57,7 @@
#include "packets/cPacket_EntityEquipment.h"
#include "packets/cPacket_CreateInventoryAction.h"
#include "packets/cPacket_NewInvalidState.h"
#include "packets/cPacket_Thunderbolt.h" //for testing.
#include "packets/cPacket_UseEntity.h"
#include "packets/cPacket_WindowClose.h"
#include "packets/cPacket_13.h"
@ -485,8 +486,9 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
break;
case E_BLOCK_DIG:
{
LOG("TimeP: %f", m_Player->GetLastBlockActionTime() );
LOG("TimeN: %f", cRoot::Get()->GetWorld()->GetTime() );
//LOG("TimeP: %f", m_Player->GetLastBlockActionTime() );
//LOG("TimeN: %f", cRoot::Get()->GetWorld()->GetTime() );
if ( cRoot::Get()->GetWorld()->GetTime() - m_Player->GetLastBlockActionTime() < 0.1 ) { //only allow block interactions every 0.1 seconds
LOGWARN("Player %s tried to interact with a block too quickly! (could indicate bot)", GetUsername() );
m_Player->SetLastBlockActionTime(); //Player tried to interact with a block. Reset last block interation time.
@ -603,8 +605,8 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
break;
case E_BLOCK_PLACE:
{
LOG("TimeP: %f", m_Player->GetLastBlockActionTime() );
LOG("TimeN: %f", cRoot::Get()->GetWorld()->GetTime() );
//LOG("TimeP: %f", m_Player->GetLastBlockActionTime() );
//LOG("TimeN: %f", cRoot::Get()->GetWorld()->GetTime() );
if ( cRoot::Get()->GetWorld()->GetTime() - m_Player->GetLastBlockActionTime() < 0.1 ) { //only allow block interactions every 0.1 seconds
LOGWARN("Player %s tried to interact with a block too quickly! (could indicate bot)", GetUsername() );
m_Player->SetLastBlockActionTime(); //Player tried to interact with a block. Reset last block interation time.
@ -642,10 +644,17 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
{
case E_BLOCK_WORKBENCH:
{
LOG("WorkBench");
////////////// For testing V
cPacket_NewInvalidState RainPacket;
RainPacket.m_Reason = 1; //begin rain
Send( RainPacket );
Send( RainPacket );
//also strike table with lightning for test purposes
cPacket_Thunderbolt ThunderboltPacket;
ThunderboltPacket.m_xLBPos = PacketData->m_PosX;
ThunderboltPacket.m_yLBPos = PacketData->m_PosY;
ThunderboltPacket.m_zLBPos = PacketData->m_PosZ;
Send( ThunderboltPacket );
////////////// For testing ^
bPlaceBlock = false;
cWindow* Window = new cCraftingWindow( 0, true );
m_Player->OpenWindow( Window );
@ -654,10 +663,11 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
case E_BLOCK_FURNACE:
case E_BLOCK_CHEST:
{
LOG("Chest");
////////////// For testing V
cPacket_NewInvalidState RainPacket;
RainPacket.m_Reason = 2; //end rain
Send( RainPacket );
////////////// For testing ^
bPlaceBlock = false;
cBlockEntity* BlockEntity = m_Player->GetWorld()->GetBlockEntity( PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ );
if( BlockEntity )

View File

@ -1,5 +1,20 @@
#include "cPacket_Thunderbolt.h"
cPacket_Thunderbolt::cPacket_Thunderbolt( const cPacket_Thunderbolt & a_Copy )
{
m_PacketID = E_THUNDERBOLT;
m_UniqueID = 237183; //just a random Ent ID. I don't think this matters at all.
m_Unknown = true;
m_xLBPos = a_Copy.m_xLBPos;
m_yLBPos = a_Copy.m_yLBPos;
m_zLBPos = a_Copy.m_zLBPos;
printf("blot-packet %i %i %i\n", m_xLBPos,m_yLBPos,m_zLBPos);
}
bool cPacket_Thunderbolt::Send(cSocket & a_Socket)
{
unsigned int TotalSize = c_Size;
@ -9,9 +24,14 @@ bool cPacket_Thunderbolt::Send(cSocket & a_Socket)
AppendByte ( (char)m_PacketID, Message, i );
AppendInteger ( m_UniqueID, Message, i );
AppendBool ( m_Unknown, Message, i );
AppendInteger ( m_xLBPos, Message, i );
AppendInteger ( m_yLBPos, Message, i );
AppendInteger ( m_zLBPos, Message, i );
AppendInteger ( m_xLBPos*32, Message, i );
AppendInteger ( m_yLBPos*32, Message, i );
AppendInteger ( m_zLBPos*32, Message, i );
for( unsigned int iii = 1; iii < TotalSize; ++iii ){
printf("packetdata %i\n", (int)Message[iii]);
}
bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
delete [] Message;

View File

@ -12,7 +12,8 @@ public:
, m_xLBPos( 0 )
, m_yLBPos( 0 )
, m_zLBPos( 0 )
{ m_PacketID = E_THUNDERBOLT;}
{ m_PacketID = E_THUNDERBOLT; m_Unknown = true; }
cPacket_Thunderbolt( const cPacket_Thunderbolt & a_Copy );
virtual cPacket* Clone() const { return new cPacket_Thunderbolt(*this); }
bool Send(cSocket & a_Socket);