1
0

Command block fixes

This commit is contained in:
andrew 2014-01-18 21:27:54 +02:00
parent 992053b32a
commit a037172465
3 changed files with 17 additions and 43 deletions

View File

@ -20,24 +20,7 @@ cCommandBlockEntity::cCommandBlockEntity(int a_X, int a_Y, int a_Z, cWorld * a_W
super(E_BLOCK_COMMAND_BLOCK, a_X, a_Y, a_Z, a_World),
m_ShouldExecute(false),
m_IsPowered(false)
{
SetBlockEntity(this); // cBlockEntityWindowOwner
}
cCommandBlockEntity::~cCommandBlockEntity()
{
// Tell window its owner is destroyed
cWindow * Window = GetWindow();
if (Window != NULL)
{
Window->OwnerDestroyed();
}
}
{}
@ -46,21 +29,8 @@ cCommandBlockEntity::~cCommandBlockEntity()
void cCommandBlockEntity::UsedBy(cPlayer * a_Player)
{
cWindow * Window = GetWindow();
if (Window == NULL)
{
// TODO 2014-01-18 xdot: Open the appropriate window.
// OpenWindow(new cCommandBlockWindow(m_PosX, m_PosY, m_PosZ, this));
Window = GetWindow();
}
if (Window != NULL)
{
if (a_Player->GetWindow() != Window)
{
a_Player->OpenWindow(Window);
}
}
// Nothing to do
UNUSED(a_Player);
}

View File

@ -9,8 +9,7 @@
#pragma once
#include "BlockEntityWithItems.h"
#include "../UI/WindowOwner.h"
#include "BlockEntity.h"
@ -28,8 +27,7 @@ namespace Json
// tolua_begin
class cCommandBlockEntity :
public cBlockEntity,
public cBlockEntityWindowOwner
public cBlockEntity
{
typedef cBlockEntity super;
@ -39,7 +37,6 @@ public:
/// Creates a new empty command block entity
cCommandBlockEntity(int a_X, int a_Y, int a_Z, cWorld * a_World);
virtual ~cCommandBlockEntity();
bool LoadFromJson( const Json::Value& a_Value );
virtual void SaveToJson(Json::Value& a_Value ) override;

View File

@ -570,19 +570,26 @@ void cClientHandle::HandleCommandBlockMessage(const char* a_Data, unsigned int a
return;
}
cByteBuffer Buffer(a_Length);
Buffer.Write(a_Data, a_Length);
int BlockX, BlockY, BlockZ;
AString Command;
switch (a_Data[0])
char Mode;
Buffer.ReadChar(Mode);
switch (Mode)
{
case 0x00:
{
BlockX = GetBEInt(a_Data + 1);
BlockY = GetBEInt(a_Data + 5);
BlockZ = GetBEInt(a_Data + 9);
Buffer.ReadBEInt(BlockX);
Buffer.ReadBEInt(BlockY);
Buffer.ReadBEInt(BlockZ);
Command = AString(a_Data + 14, (int)a_Data[13]);
Buffer.ReadVarUTF8String(Command);
break;
}