Adjusted the protocol framework to support different types of falling block spawning.
In brief, with cProtocol, "say what you want done, not how you want me to do it". But still 1.4.6 crashes on falling block spawning. git-svn-id: http://mc-server.googlecode.com/svn/trunk@1104 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
fa6bfc154b
commit
17a2c1b388
@ -1416,6 +1416,15 @@ void cClientHandle::SendPickupSpawn(const cPickup & a_Pickup)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cClientHandle::SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock)
|
||||||
|
{
|
||||||
|
m_Protocol->SendSpawnFallingBlock(a_FallingBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cClientHandle::SendSpawnMob(const cMonster & a_Mob)
|
void cClientHandle::SendSpawnMob(const cMonster & a_Mob)
|
||||||
{
|
{
|
||||||
m_Protocol->SendSpawnMob(a_Mob);
|
m_Protocol->SendSpawnMob(a_Mob);
|
||||||
|
@ -30,6 +30,7 @@ class cPlayer;
|
|||||||
class cProtocol;
|
class cProtocol;
|
||||||
class cRedstone;
|
class cRedstone;
|
||||||
class cWindow;
|
class cWindow;
|
||||||
|
class cFallingBlock;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -109,7 +110,9 @@ public:
|
|||||||
void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch); // a_Src coords are Block * 8
|
void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch); // a_Src coords are Block * 8
|
||||||
void SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data);
|
void SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data);
|
||||||
void SendBlockBreakAnim (int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage);
|
void SendBlockBreakAnim (int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage);
|
||||||
|
void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock);
|
||||||
void SendSpawnMob (const cMonster & a_Mob);
|
void SendSpawnMob (const cMonster & a_Mob);
|
||||||
|
void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, short a_SpeedX, short a_SpeedY, short a_SpeedZ, Byte a_Yaw, Byte a_Pitch);
|
||||||
void SendTeleportEntity (const cEntity & a_Entity);
|
void SendTeleportEntity (const cEntity & a_Entity);
|
||||||
void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ);
|
void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ);
|
||||||
void SendTimeUpdate (Int64 a_WorldAge, Int64 a_TimeOfDay);
|
void SendTimeUpdate (Int64 a_WorldAge, Int64 a_TimeOfDay);
|
||||||
@ -121,7 +124,6 @@ public:
|
|||||||
void SendWindowClose (char a_WindowID);
|
void SendWindowClose (char a_WindowID);
|
||||||
void SendWindowOpen (char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots);
|
void SendWindowOpen (char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots);
|
||||||
void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ );
|
void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ );
|
||||||
void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, short a_SpeedX, short a_SpeedY, short a_SpeedZ, Byte a_Yaw, Byte a_Pitch);
|
|
||||||
|
|
||||||
const AString & GetUsername(void) const; //tolua_export
|
const AString & GetUsername(void) const; //tolua_export
|
||||||
void SetUsername( const AString & a_Username ); //tolua_export
|
void SetUsername( const AString & a_Username ); //tolua_export
|
||||||
|
@ -32,7 +32,7 @@ void cFallingBlock::Initialize(cWorld * a_World)
|
|||||||
|
|
||||||
void cFallingBlock::SpawnOn(cClientHandle & a_ClientHandle)
|
void cFallingBlock::SpawnOn(cClientHandle & a_ClientHandle)
|
||||||
{
|
{
|
||||||
a_ClientHandle.SendSpawnObject(*this, 70, m_BlockType, 0, 0, 0, 0, 0);
|
a_ClientHandle.SendSpawnFallingBlock(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,6 +25,9 @@ public:
|
|||||||
|
|
||||||
cFallingBlock(const Vector3i & a_BlockPosition, BLOCKTYPE a_BlockType);
|
cFallingBlock(const Vector3i & a_BlockPosition, BLOCKTYPE a_BlockType);
|
||||||
|
|
||||||
|
BLOCKTYPE GetBlockType(void) const { return m_BlockType; }
|
||||||
|
|
||||||
|
// cEntity overrides:
|
||||||
virtual void Initialize(cWorld * a_World) override;
|
virtual void Initialize(cWorld * a_World) override;
|
||||||
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
|
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
|
||||||
virtual void Tick(float a_Dt, MTRand & a_TickRandom) override;
|
virtual void Tick(float a_Dt, MTRand & a_TickRandom) override;
|
||||||
|
@ -25,6 +25,7 @@ class cPickup;
|
|||||||
class cMonster;
|
class cMonster;
|
||||||
class cChunkDataSerializer;
|
class cChunkDataSerializer;
|
||||||
class cWorld;
|
class cWorld;
|
||||||
|
class cFallingBlock;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -80,6 +81,7 @@ public:
|
|||||||
virtual void SendRespawn (void) = 0;
|
virtual void SendRespawn (void) = 0;
|
||||||
virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) = 0; // a_Src coords are Block * 8
|
virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) = 0; // a_Src coords are Block * 8
|
||||||
virtual void SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) = 0;
|
virtual void SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) = 0;
|
||||||
|
virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) = 0;
|
||||||
virtual void SendSpawnMob (const cMonster & a_Mob) = 0;
|
virtual void SendSpawnMob (const cMonster & a_Mob) = 0;
|
||||||
virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, short a_SpeedX, short a_SpeedY, short a_SpeedZ, Byte a_Yaw, Byte a_Pitch) = 0;
|
virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, short a_SpeedX, short a_SpeedY, short a_SpeedZ, Byte a_Yaw, Byte a_Pitch) = 0;
|
||||||
virtual void SendTeleportEntity (const cEntity & a_Entity) = 0;
|
virtual void SendTeleportEntity (const cEntity & a_Entity) = 0;
|
||||||
|
@ -23,6 +23,7 @@ Documentation:
|
|||||||
#include "../UI/Window.h"
|
#include "../UI/Window.h"
|
||||||
#include "../Root.h"
|
#include "../Root.h"
|
||||||
#include "../Server.h"
|
#include "../Server.h"
|
||||||
|
#include "../FallingBlock.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -614,6 +615,16 @@ void cProtocol125::SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_Src
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cProtocol125::SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock)
|
||||||
|
{
|
||||||
|
// This protocol version implements falling blocks using the spawn object / vehicle packet:
|
||||||
|
SendSpawnObject(a_FallingBlock, 70, a_FallingBlock.GetBlockType(), 0, 0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cProtocol125::SendSpawnMob(const cMonster & a_Mob)
|
void cProtocol125::SendSpawnMob(const cMonster & a_Mob)
|
||||||
{
|
{
|
||||||
cCSLock Lock(m_CSPacket);
|
cCSLock Lock(m_CSPacket);
|
||||||
|
@ -58,6 +58,7 @@ public:
|
|||||||
virtual void SendRespawn (void) override;
|
virtual void SendRespawn (void) override;
|
||||||
virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; // a_Src coords are Block * 8
|
virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; // a_Src coords are Block * 8
|
||||||
virtual void SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override;
|
virtual void SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override;
|
||||||
|
virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) override;
|
||||||
virtual void SendSpawnMob (const cMonster & a_Mob) override;
|
virtual void SendSpawnMob (const cMonster & a_Mob) override;
|
||||||
virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, short a_SpeedX, short a_SpeedY, short a_SpeedZ, Byte a_Yaw, Byte a_Pitch) override;
|
virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, short a_SpeedX, short a_SpeedY, short a_SpeedZ, Byte a_Yaw, Byte a_Pitch) override;
|
||||||
virtual void SendTeleportEntity (const cEntity & a_Entity) override;
|
virtual void SendTeleportEntity (const cEntity & a_Entity) override;
|
||||||
|
@ -23,6 +23,7 @@ Implements the 1.4.x protocol classes representing these protocols:
|
|||||||
#include "../Mobs/Monster.h"
|
#include "../Mobs/Monster.h"
|
||||||
#include "../UI/Window.h"
|
#include "../UI/Window.h"
|
||||||
#include "../Pickup.h"
|
#include "../Pickup.h"
|
||||||
|
#include "../FallingBlock.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -152,6 +153,71 @@ cProtocol146::cProtocol146(cClientHandle * a_Client) :
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cProtocol146::SendPickupSpawn(const cPickup & a_Pickup)
|
||||||
|
{
|
||||||
|
ASSERT(!a_Pickup.GetItem()->IsEmpty());
|
||||||
|
|
||||||
|
cCSLock Lock(m_CSPacket);
|
||||||
|
|
||||||
|
// Send a SPAWN_OBJECT packet for the base entity:
|
||||||
|
WriteByte(PACKET_SPAWN_OBJECT);
|
||||||
|
WriteInt (a_Pickup.GetUniqueID());
|
||||||
|
WriteByte(0x02);
|
||||||
|
WriteInt ((int)(a_Pickup.GetPosX() * 32));
|
||||||
|
WriteInt ((int)(a_Pickup.GetPosY() * 32));
|
||||||
|
WriteInt ((int)(a_Pickup.GetPosZ() * 32));
|
||||||
|
WriteInt (1);
|
||||||
|
WriteShort((short)(a_Pickup.GetSpeed().x * 32));
|
||||||
|
WriteShort((short)(a_Pickup.GetSpeed().y * 32));
|
||||||
|
WriteShort((short)(a_Pickup.GetSpeed().z * 32));
|
||||||
|
WriteByte(0);
|
||||||
|
WriteByte(0);
|
||||||
|
|
||||||
|
// Send a ENTITY_METADATA packet with the slot info:
|
||||||
|
WriteByte(PACKET_ENTITY_METADATA);
|
||||||
|
WriteInt(a_Pickup.GetUniqueID());
|
||||||
|
WriteByte(0xaa); // a slot value at index 10
|
||||||
|
WriteItem(*a_Pickup.GetItem());
|
||||||
|
WriteByte(0x7f); // End of metadata
|
||||||
|
Flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cProtocol146::SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock)
|
||||||
|
{
|
||||||
|
// Send two packets - spawn object, then entity metadata
|
||||||
|
cCSLock Lock(m_CSPacket);
|
||||||
|
|
||||||
|
WriteByte(PACKET_SPAWN_OBJECT);
|
||||||
|
WriteInt (a_FallingBlock.GetUniqueID());
|
||||||
|
WriteByte(70);
|
||||||
|
WriteInt ((int)(a_FallingBlock.GetPosX() * 32));
|
||||||
|
WriteInt ((int)(a_FallingBlock.GetPosY() * 32));
|
||||||
|
WriteInt ((int)(a_FallingBlock.GetPosZ() * 32));
|
||||||
|
WriteInt (0x800000);
|
||||||
|
WriteShort(0);
|
||||||
|
WriteShort(0);
|
||||||
|
WriteShort(0);
|
||||||
|
WriteByte (0);
|
||||||
|
WriteByte (0);
|
||||||
|
|
||||||
|
// TODO: This still doesn't work, although it is exactly the same that the vanilla server sends. WTF?
|
||||||
|
WriteByte(PACKET_ENTITY_METADATA);
|
||||||
|
WriteInt(a_FallingBlock.GetUniqueID());
|
||||||
|
WriteByte(0xaa); // a slot value at index 10
|
||||||
|
cItem Item(a_FallingBlock.GetBlockType(), 1);
|
||||||
|
WriteItem(Item);
|
||||||
|
WriteByte(0x7f); // End of metadata
|
||||||
|
Flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cProtocol146::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, short a_SpeedX, short a_SpeedY, short a_SpeedZ, Byte a_Yaw, Byte a_Pitch)
|
void cProtocol146::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, short a_SpeedX, short a_SpeedY, short a_SpeedZ, Byte a_Yaw, Byte a_Pitch)
|
||||||
{
|
{
|
||||||
cCSLock Lock(m_CSPacket);
|
cCSLock Lock(m_CSPacket);
|
||||||
@ -177,35 +243,3 @@ void cProtocol146::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cProtocol146::SendPickupSpawn(const cPickup & a_Pickup)
|
|
||||||
{
|
|
||||||
ASSERT(!a_Pickup.GetItem()->IsEmpty());
|
|
||||||
|
|
||||||
cCSLock Lock(m_CSPacket);
|
|
||||||
|
|
||||||
// Send a SPAWN_OBJECT packet for the base entity:
|
|
||||||
WriteByte(PACKET_SPAWN_OBJECT);
|
|
||||||
WriteInt (a_Pickup.GetUniqueID());
|
|
||||||
WriteByte(0x02);
|
|
||||||
WriteInt ((int)(a_Pickup.GetPosX() * 32));
|
|
||||||
WriteInt ((int)(a_Pickup.GetPosY() * 32));
|
|
||||||
WriteInt ((int)(a_Pickup.GetPosZ() * 32));
|
|
||||||
WriteInt (1);
|
|
||||||
WriteShort((short)(a_Pickup.GetSpeed().x * 32));
|
|
||||||
WriteShort((short)(a_Pickup.GetSpeed().y * 32));
|
|
||||||
WriteShort((short)(a_Pickup.GetSpeed().z * 32));
|
|
||||||
WriteByte(0);
|
|
||||||
WriteByte(0);
|
|
||||||
|
|
||||||
// Send a ENTITY_METADATA packet with the slot info:
|
|
||||||
WriteByte(PACKET_ENTITY_METADATA);
|
|
||||||
WriteInt(a_Pickup.GetUniqueID());
|
|
||||||
WriteByte(0xaa); // a slot value at index 10
|
|
||||||
WriteItem(*a_Pickup.GetItem()); // TODO: Still not good, needs GZIP!
|
|
||||||
WriteByte(0x7f); // End of metadata
|
|
||||||
Flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,8 +52,9 @@ class cProtocol146 :
|
|||||||
public:
|
public:
|
||||||
cProtocol146(cClientHandle * a_Client);
|
cProtocol146(cClientHandle * a_Client);
|
||||||
|
|
||||||
virtual void SendPickupSpawn (const cPickup & a_Pickup) override;
|
virtual void SendPickupSpawn (const cPickup & a_Pickup) override;
|
||||||
virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, short a_SpeedX, short a_SpeedY, short a_SpeedZ, Byte a_Yaw, Byte a_Pitch) override;
|
virtual void SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock) override;
|
||||||
|
virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, short a_SpeedX, short a_SpeedY, short a_SpeedZ, Byte a_Yaw, Byte a_Pitch) override;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
@ -406,6 +406,16 @@ void cProtocolRecognizer::SendSoundParticleEffect(int a_EffectID, int a_SrcX, in
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cProtocolRecognizer::SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock)
|
||||||
|
{
|
||||||
|
ASSERT(m_Protocol != NULL);
|
||||||
|
m_Protocol->SendSpawnFallingBlock(a_FallingBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cProtocolRecognizer::SendSpawnMob(const cMonster & a_Mob)
|
void cProtocolRecognizer::SendSpawnMob(const cMonster & a_Mob)
|
||||||
{
|
{
|
||||||
ASSERT(m_Protocol != NULL);
|
ASSERT(m_Protocol != NULL);
|
||||||
|
@ -83,6 +83,7 @@ public:
|
|||||||
virtual void SendRespawn (void) override;
|
virtual void SendRespawn (void) override;
|
||||||
virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override;
|
virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override;
|
||||||
virtual void SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override;
|
virtual void SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override;
|
||||||
|
virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) override;
|
||||||
virtual void SendSpawnMob (const cMonster & a_Mob) override;
|
virtual void SendSpawnMob (const cMonster & a_Mob) override;
|
||||||
virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, short a_SpeedX, short a_SpeedY, short a_SpeedZ, Byte a_Yaw, Byte a_Pitch) override;
|
virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, short a_SpeedX, short a_SpeedY, short a_SpeedZ, Byte a_Yaw, Byte a_Pitch) override;
|
||||||
virtual void SendTeleportEntity (const cEntity & a_Entity) override;
|
virtual void SendTeleportEntity (const cEntity & a_Entity) override;
|
||||||
|
Loading…
Reference in New Issue
Block a user