From 83870f9fc0e19da646f408a2d6636adfe4b5c002 Mon Sep 17 00:00:00 2001 From: Dave Tucker Date: Mon, 23 Nov 2015 23:39:19 +0000 Subject: Add enum for Sound and Particle Effects Fixes #2603 Signed-off-by: Dave Tucker --- src/Protocol/Protocol.h | 3 ++- src/Protocol/Protocol17x.cpp | 4 ++-- src/Protocol/Protocol17x.h | 2 +- src/Protocol/Protocol18x.cpp | 5 +++-- src/Protocol/Protocol18x.h | 2 +- src/Protocol/ProtocolRecognizer.cpp | 2 +- src/Protocol/ProtocolRecognizer.h | 2 +- 7 files changed, 11 insertions(+), 9 deletions(-) (limited to 'src/Protocol') diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h index 4581da6a9..af0485a78 100644 --- a/src/Protocol/Protocol.h +++ b/src/Protocol/Protocol.h @@ -15,6 +15,7 @@ #include "../Scoreboard.h" #include "../Map.h" #include "../ByteBuffer.h" +#include "../EffectID.h" #include @@ -123,7 +124,7 @@ public: virtual void SendSetTitle (const cCompositeChat & a_Title) = 0; virtual void SendSetRawTitle (const AString & a_Title) = 0; virtual void SendSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) = 0; - virtual void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) = 0; + virtual void SendSoundParticleEffect (const EffectID 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 SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) = 0; diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 08ff4b268..010e1a8ba 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -1163,13 +1163,13 @@ void cProtocol172::SendSoundEffect(const AString & a_SoundName, double a_X, doub -void cProtocol172::SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) +void cProtocol172::SendSoundParticleEffect(const EffectID a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) { ASSERT(m_State == 3); // In game mode? ASSERT((a_SrcY >= 0) && (a_SrcY < 256)); cPacketizer Pkt(*this, 0x28); // Effect packet - Pkt.WriteBEInt32(a_EffectID); + Pkt.WriteBEInt32(static_cast(a_EffectID)); Pkt.WriteBEInt32(a_SrcX); Pkt.WriteBEUInt8(static_cast(a_SrcY)); Pkt.WriteBEInt32(a_SrcZ); diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h index cc201f840..747ffe186 100644 --- a/src/Protocol/Protocol17x.h +++ b/src/Protocol/Protocol17x.h @@ -121,7 +121,7 @@ public: virtual void SendSetTitle (const cCompositeChat & a_Title) override; virtual void SendSetRawTitle (const AString & a_Title) override; virtual void SendSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, 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 (const EffectID 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 SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) override; diff --git a/src/Protocol/Protocol18x.cpp b/src/Protocol/Protocol18x.cpp index 15dd085be..17b4dc6fd 100644 --- a/src/Protocol/Protocol18x.cpp +++ b/src/Protocol/Protocol18x.cpp @@ -19,6 +19,7 @@ Implements the 1.8.x protocol classes: #include "../Root.h" #include "../Server.h" #include "../World.h" +#include "../EffectID.h" #include "../StringCompression.h" #include "../CompositeChat.h" #include "../Statistics.h" @@ -1234,12 +1235,12 @@ void cProtocol180::SendSoundEffect(const AString & a_SoundName, double a_X, doub -void cProtocol180::SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) +void cProtocol180::SendSoundParticleEffect(const EffectID a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) { ASSERT(m_State == 3); // In game mode? cPacketizer Pkt(*this, 0x28); // Effect packet - Pkt.WriteBEInt32(a_EffectID); + Pkt.WriteBEInt32(static_cast(a_EffectID)); Pkt.WritePosition64(a_SrcX, a_SrcY, a_SrcZ); Pkt.WriteBEInt32(a_Data); Pkt.WriteBool(false); diff --git a/src/Protocol/Protocol18x.h b/src/Protocol/Protocol18x.h index aa73a4a6a..8b5b7ffa2 100644 --- a/src/Protocol/Protocol18x.h +++ b/src/Protocol/Protocol18x.h @@ -120,7 +120,7 @@ public: virtual void SendSetRawSubTitle (const AString & a_SubTitle) override; virtual void SendSetTitle (const cCompositeChat & a_Title) override; virtual void SendSetRawTitle (const AString & a_Title) override; - virtual void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override; + virtual void SendSoundParticleEffect (const EffectID 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 SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) override; diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index 845e7b56d..c88bd8639 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -709,7 +709,7 @@ void cProtocolRecognizer::SendSoundEffect(const AString & a_SoundName, double a_ -void cProtocolRecognizer::SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) +void cProtocolRecognizer::SendSoundParticleEffect(const EffectID a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) { ASSERT(m_Protocol != nullptr); m_Protocol->SendSoundParticleEffect(a_EffectID, a_SrcX, a_SrcY, a_SrcZ, a_Data); diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h index 7b5952bea..c548ad5ba 100644 --- a/src/Protocol/ProtocolRecognizer.h +++ b/src/Protocol/ProtocolRecognizer.h @@ -108,7 +108,7 @@ public: virtual void SendSetTitle (const cCompositeChat & a_Title) override; virtual void SendSetRawTitle (const AString & a_Title) override; virtual void SendSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, 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 (const EffectID 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 SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) override; -- cgit v1.2.3