diff options
Diffstat (limited to '')
-rw-r--r-- | src/Bindings/AllToLua.pkg | 1 | ||||
-rw-r--r-- | src/Bindings/Bindings.cpp | 28 | ||||
-rw-r--r-- | src/Bindings/Bindings.h | 2 | ||||
-rw-r--r-- | src/ClientHandle.cpp | 18 | ||||
-rw-r--r-- | src/ClientHandle.h | 2 | ||||
-rw-r--r-- | src/Entities/Effects.h | 30 | ||||
-rw-r--r-- | src/Entities/Player.cpp | 10 | ||||
-rw-r--r-- | src/Globals.h | 1 | ||||
-rw-r--r-- | src/Protocol/Protocol.h | 2 | ||||
-rw-r--r-- | src/Protocol/Protocol125.cpp | 30 | ||||
-rw-r--r-- | src/Protocol/Protocol125.h | 2 | ||||
-rw-r--r-- | src/Protocol/Protocol17x.cpp | 24 | ||||
-rw-r--r-- | src/Protocol/Protocol17x.h | 2 | ||||
-rw-r--r-- | src/Protocol/ProtocolRecognizer.cpp | 20 | ||||
-rw-r--r-- | src/Protocol/ProtocolRecognizer.h | 2 |
15 files changed, 170 insertions, 4 deletions
diff --git a/src/Bindings/AllToLua.pkg b/src/Bindings/AllToLua.pkg index 6db7b2b0e..e9a5ea0c6 100644 --- a/src/Bindings/AllToLua.pkg +++ b/src/Bindings/AllToLua.pkg @@ -37,6 +37,7 @@ $cfile "../Entities/Player.h" $cfile "../Entities/Pickup.h" $cfile "../Entities/ProjectileEntity.h" $cfile "../Entities/TNTEntity.h" +$cfile "../Entities/Effects.h" $cfile "../Server.h" $cfile "../World.h" $cfile "../Inventory.h" diff --git a/src/Bindings/Bindings.cpp b/src/Bindings/Bindings.cpp index 090d8047a..f4fb3f791 100644 --- a/src/Bindings/Bindings.cpp +++ b/src/Bindings/Bindings.cpp @@ -1,6 +1,6 @@ /* ** Lua binding: AllToLua -** Generated automatically by tolua++-1.0.92 on 12/14/13 16:22:45. +** Generated automatically by tolua++-1.0.92 on 12/14/13 22:33:52. */ #ifndef __cplusplus @@ -8,7 +8,7 @@ #endif #include "string.h" -#include "tolua++/include/tolua++.h" +#include "tolua++.h" /* Exported function */ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S); @@ -35,6 +35,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S); #include "../Entities/Pickup.h" #include "../Entities/ProjectileEntity.h" #include "../Entities/TNTEntity.h" +#include "../Entities/Effects.h" #include "../Server.h" #include "../World.h" #include "../Inventory.h" @@ -31064,6 +31065,29 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_function(tolua_S,"GetCounterTime",tolua_AllToLua_cTNTEntity_GetCounterTime00); tolua_function(tolua_S,"GetMaxFuseTime",tolua_AllToLua_cTNTEntity_GetMaxFuseTime00); tolua_endmodule(tolua_S); + tolua_constant(tolua_S,"E_EFFECT_SPEED",E_EFFECT_SPEED); + tolua_constant(tolua_S,"E_EFFECT_SLOWNESS",E_EFFECT_SLOWNESS); + tolua_constant(tolua_S,"E_EFFECT_HASTE",E_EFFECT_HASTE); + tolua_constant(tolua_S,"E_EFFECT_MINING_FATIGUE",E_EFFECT_MINING_FATIGUE); + tolua_constant(tolua_S,"E_EFFECT_STENGTH",E_EFFECT_STENGTH); + tolua_constant(tolua_S,"E_EFFECT_INSTANT_HEALTH",E_EFFECT_INSTANT_HEALTH); + tolua_constant(tolua_S,"E_EFFECT_INSTANT_DAMAGE",E_EFFECT_INSTANT_DAMAGE); + tolua_constant(tolua_S,"E_EFFECT_JUMP_BOOST",E_EFFECT_JUMP_BOOST); + tolua_constant(tolua_S,"E_EFFECT_NAUSEA",E_EFFECT_NAUSEA); + tolua_constant(tolua_S,"E_EFFECT_REGENERATION",E_EFFECT_REGENERATION); + tolua_constant(tolua_S,"E_EFFECT_RESISTANCE",E_EFFECT_RESISTANCE); + tolua_constant(tolua_S,"E_EFFECT_FIRE_RESISTANCE",E_EFFECT_FIRE_RESISTANCE); + tolua_constant(tolua_S,"E_EFFECT_WATER_BREATHING",E_EFFECT_WATER_BREATHING); + tolua_constant(tolua_S,"E_EFFECT_INVISIBILITY",E_EFFECT_INVISIBILITY); + tolua_constant(tolua_S,"E_EFFECT_BLINDNESS",E_EFFECT_BLINDNESS); + tolua_constant(tolua_S,"E_EFFECT_NIGHT_VISION",E_EFFECT_NIGHT_VISION); + tolua_constant(tolua_S,"E_EFFECT_HUNGER",E_EFFECT_HUNGER); + tolua_constant(tolua_S,"E_EFFECT_WEAKNESS",E_EFFECT_WEAKNESS); + tolua_constant(tolua_S,"E_EFFECT_POISON",E_EFFECT_POISON); + tolua_constant(tolua_S,"E_EFFECT_WITHER",E_EFFECT_WITHER); + tolua_constant(tolua_S,"E_EFFECT_HEALTH_BOOST",E_EFFECT_HEALTH_BOOST); + tolua_constant(tolua_S,"E_EFFECT_ABSORPTION",E_EFFECT_ABSORPTION); + tolua_constant(tolua_S,"E_EFFECT_SATURATION",E_EFFECT_SATURATION); tolua_cclass(tolua_S,"cServer","cServer","",NULL); tolua_beginmodule(tolua_S,"cServer"); tolua_function(tolua_S,"GetDescription",tolua_AllToLua_cServer_GetDescription00); diff --git a/src/Bindings/Bindings.h b/src/Bindings/Bindings.h index 73cf3c7d8..e8f766b43 100644 --- a/src/Bindings/Bindings.h +++ b/src/Bindings/Bindings.h @@ -1,6 +1,6 @@ /* ** Lua binding: AllToLua -** Generated automatically by tolua++-1.0.92 on 12/14/13 16:22:46. +** Generated automatically by tolua++-1.0.92 on 12/14/13 22:33:53. */ /* Exported function */ diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index f7e18974f..8a92e1344 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1673,6 +1673,15 @@ void cClientHandle::SendEditSign(int a_BlockX, int a_BlockY, int a_BlockZ) +void cClientHandle::SendEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration) +{ + m_Protocol->SendEntityEffect(a_Entity, a_EffectID, a_Amplifier, a_Duration); +} + + + + + void cClientHandle::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) { m_Protocol->SendEntityEquipment(a_Entity, a_SlotNum, a_Item); @@ -1882,6 +1891,15 @@ void cClientHandle::SendPlayerSpawn(const cPlayer & a_Player) +void cClientHandle::SendRemoveEntityEffect(const cEntity & a_Entity, int a_EffectID) +{ + m_Protocol->SendRemoveEntityEffect(a_Entity, a_EffectID); +} + + + + + void cClientHandle::SendRespawn(void) { m_Protocol->SendRespawn(); diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 2ff75b28a..19ebc023d 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -100,6 +100,7 @@ public: void SendDestroyEntity (const cEntity & a_Entity); void SendDisconnect (const AString & a_Reason); void SendEditSign (int a_BlockX, int a_BlockY, int a_BlockZ); + void SendEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration); void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item); void SendEntityHeadLook (const cEntity & a_Entity); void SendEntityLook (const cEntity & a_Entity); @@ -120,6 +121,7 @@ public: void SendPlayerMoveLook (void); void SendPlayerPosition (void); void SendPlayerSpawn (const cPlayer & a_Player); + void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID); void SendRespawn (void); void SendExperience (void); void SendExperienceOrb (const cExpOrb & a_ExpOrb); diff --git a/src/Entities/Effects.h b/src/Entities/Effects.h new file mode 100644 index 000000000..e7611847d --- /dev/null +++ b/src/Entities/Effects.h @@ -0,0 +1,30 @@ +#pragma once + +// tolua_begin +enum ENUM_ENTITY_EFFECT +{ + E_EFFECT_SPEED = 1, + E_EFFECT_SLOWNESS = 2, + E_EFFECT_HASTE = 3, + E_EFFECT_MINING_FATIGUE = 4, + E_EFFECT_STENGTH = 5, + E_EFFECT_INSTANT_HEALTH = 6, + E_EFFECT_INSTANT_DAMAGE = 7, + E_EFFECT_JUMP_BOOST = 8, + E_EFFECT_NAUSEA = 9, + E_EFFECT_REGENERATION = 10, + E_EFFECT_RESISTANCE = 11, + E_EFFECT_FIRE_RESISTANCE = 12, + E_EFFECT_WATER_BREATHING = 13, + E_EFFECT_INVISIBILITY = 14, + E_EFFECT_BLINDNESS = 15, + E_EFFECT_NIGHT_VISION = 16, + E_EFFECT_HUNGER = 17, + E_EFFECT_WEAKNESS = 18, + E_EFFECT_POISON = 19, + E_EFFECT_WITHER = 20, + E_EFFECT_HEALTH_BOOST = 21, + E_EFFECT_ABSORPTION = 22, + E_EFFECT_SATURATION = 23, +} ; +// tolua_end
\ No newline at end of file diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 85833f31d..b2485a8e2 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -557,9 +557,13 @@ void cPlayer::FoodPoison(int a_NumTicks) m_FoodPoisonedTicksRemaining = std::max(m_FoodPoisonedTicksRemaining, a_NumTicks); if (!HasBeenFoodPoisoned) { - // TODO: Send the poisoning indication to the client - how? + m_ClientHandle->SendRemoveEntityEffect(*this, E_EFFECT_HUNGER); SendHealth(); } + else + { + m_ClientHandle->SendEntityEffect(*this, E_EFFECT_HUNGER, 0, 20); + } } @@ -1704,6 +1708,10 @@ void cPlayer::HandleFood(void) m_FoodPoisonedTicksRemaining--; m_FoodExhaustionLevel += 0.025; // 0.5 per second = 0.025 per tick } + else + { + m_ClientHandle->SendRemoveEntityEffect(*this, E_EFFECT_HUNGER); // remove the "Hunger" effect. + } // Apply food exhaustion that has accumulated: if (m_FoodExhaustionLevel >= 4) diff --git a/src/Globals.h b/src/Globals.h index cb67d9fda..fe6aee5c5 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -220,6 +220,7 @@ public: // Common headers (part 2, with macros): #include "ChunkDef.h" #include "BlockID.h" +#include "Entities/Effects.h" diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h index ff6541aeb..d90ece2b0 100644 --- a/src/Protocol/Protocol.h +++ b/src/Protocol/Protocol.h @@ -62,6 +62,7 @@ public: virtual void SendDestroyEntity (const cEntity & a_Entity) = 0; virtual void SendDisconnect (const AString & a_Reason) = 0; virtual void SendEditSign (int a_BlockX, int a_BlockY, int a_BlockZ) = 0; ///< Request the client to open up the sign editor for the sign (1.6+) + virtual void SendEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration) = 0; virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) = 0; virtual void SendEntityHeadLook (const cEntity & a_Entity) = 0; virtual void SendEntityLook (const cEntity & a_Entity) = 0; @@ -85,6 +86,7 @@ public: virtual void SendPlayerMoveLook (void) = 0; virtual void SendPlayerPosition (void) = 0; virtual void SendPlayerSpawn (const cPlayer & a_Player) = 0; + virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) = 0; virtual void SendRespawn (void) = 0; virtual void SendExperience (void) = 0; virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) = 0; diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index 9334e6f2d..d4c1f0dd5 100644 --- a/src/Protocol/Protocol125.cpp +++ b/src/Protocol/Protocol125.cpp @@ -43,6 +43,8 @@ enum PACKET_HANDSHAKE = 0x02, PACKET_CHAT = 0x03, PACKET_UPDATE_TIME = 0x04, + PACKET_ENTITY_EFFECT = 0x1D, + PACKET_REMOVE_ENTITY_EFFECT = 0x1E, PACKET_ENTITY_EQUIPMENT = 0x05, PACKET_USE_ENTITY = 0x07, PACKET_UPDATE_HEALTH = 0x08, @@ -300,6 +302,21 @@ void cProtocol125::SendEditSign(int a_BlockX, int a_BlockY, int a_BlockZ) +void cProtocol125::SendEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration) +{ + cCSLock Lock(m_CSPacket); + WriteByte (PACKET_ENTITY_EFFECT); + WriteInt (a_Entity.GetUniqueID()); + WriteByte (a_EffectID); + WriteByte (a_Amplifier); + WriteShort(a_Duration); + Flush(); +} + + + + + void cProtocol125::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) { cCSLock Lock(m_CSPacket); @@ -678,6 +695,19 @@ void cProtocol125::SendPlayerSpawn(const cPlayer & a_Player) +void cProtocol125::SendRemoveEntityEffect(const cEntity & a_Entity, int a_EffectID) +{ + cCSLock Lock(m_CSPacket); + WriteByte (PACKET_REMOVE_ENTITY_EFFECT); + WriteInt (a_Entity.GetUniqueID()); + WriteByte (a_EffectID); + Flush(); +} + + + + + void cProtocol125::SendRespawn(void) { cCSLock Lock(m_CSPacket); diff --git a/src/Protocol/Protocol125.h b/src/Protocol/Protocol125.h index 32efef4e8..ebbcd762a 100644 --- a/src/Protocol/Protocol125.h +++ b/src/Protocol/Protocol125.h @@ -38,6 +38,7 @@ public: virtual void SendDestroyEntity (const cEntity & a_Entity) override; virtual void SendDisconnect (const AString & a_Reason) override; virtual void SendEditSign (int a_BlockX, int a_BlockY, int a_BlockZ) override; ///< Request the client to open up the sign editor for the sign (1.6+) + virtual void SendEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration) override; virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) override; virtual void SendEntityHeadLook (const cEntity & a_Entity) override; virtual void SendEntityLook (const cEntity & a_Entity) override; @@ -61,6 +62,7 @@ public: virtual void SendPlayerMoveLook (void) override; virtual void SendPlayerPosition (void) override; virtual void SendPlayerSpawn (const cPlayer & a_Player) override; + virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override; virtual void SendRespawn (void) override; virtual void SendExperience (void) override; virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) override; diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 83db17e78..0daf1c932 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -236,6 +236,19 @@ void cProtocol172::SendEditSign(int a_BlockX, int a_BlockY, int a_BlockZ) +void cProtocol172::SendEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration) +{ + cPacketizer Pkt(*this, 0x1D); // Entity Effect packet + Pkt.WriteInt(a_Entity.GetUniqueID()); + Pkt.WriteByte(a_EffectID); + Pkt.WriteByte(a_Amplifier); + Pkt.WriteShort(a_Duration); +} + + + + + void cProtocol172::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) { cPacketizer Pkt(*this, 0x04); // Entity Equipment packet @@ -585,6 +598,17 @@ void cProtocol172::SendPlayerSpawn(const cPlayer & a_Player) +void cProtocol172::SendRemoveEntityEffect(const cEntity & a_Entity, int a_EffectID) +{ + cPacketizer Pkt(*this, 0x1E); + Pkt.WriteInt(a_Entity.GetUniqueID()); + Pkt.WriteByte(a_EffectID); +} + + + + + void cProtocol172::SendRespawn(void) { cPacketizer Pkt(*this, 0x07); // Respawn packet diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h index b8c91fbeb..4a91f0e56 100644 --- a/src/Protocol/Protocol17x.h +++ b/src/Protocol/Protocol17x.h @@ -47,6 +47,7 @@ public: virtual void SendDestroyEntity (const cEntity & a_Entity) override; virtual void SendDisconnect (const AString & a_Reason) override; virtual void SendEditSign (int a_BlockX, int a_BlockY, int a_BlockZ) override; ///< Request the client to open up the sign editor for the sign (1.6+) + virtual void SendEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration) override; virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) override; virtual void SendEntityHeadLook (const cEntity & a_Entity) override; virtual void SendEntityLook (const cEntity & a_Entity) override; @@ -70,6 +71,7 @@ public: virtual void SendPlayerMoveLook (void) override; virtual void SendPlayerPosition (void) override; virtual void SendPlayerSpawn (const cPlayer & a_Player) override; + virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) 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 SendExperience (void) override; diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index 683700d37..30b48a92f 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -216,6 +216,16 @@ void cProtocolRecognizer::SendEditSign(int a_BlockX, int a_BlockY, int a_BlockZ) +void cProtocolRecognizer::SendEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration) +{ + ASSERT(m_Protocol != NULL); + m_Protocol->SendEntityEffect(a_Entity, a_EffectID, a_Amplifier, a_Duration); +} + + + + + void cProtocolRecognizer::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) { ASSERT(m_Protocol != NULL); @@ -456,6 +466,16 @@ void cProtocolRecognizer::SendPlayerSpawn(const cPlayer & a_Player) +void cProtocolRecognizer::SendRemoveEntityEffect(const cEntity & a_Entity, int a_EffectID) +{ + ASSERT(m_Protocol != NULL); + m_Protocol->SendRemoveEntityEffect(a_Entity, a_EffectID); +} + + + + + void cProtocolRecognizer::SendRespawn(void) { ASSERT(m_Protocol != NULL); diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h index 83fc23c22..0d69e9406 100644 --- a/src/Protocol/ProtocolRecognizer.h +++ b/src/Protocol/ProtocolRecognizer.h @@ -73,6 +73,7 @@ public: virtual void SendDestroyEntity (const cEntity & a_Entity) override; virtual void SendDisconnect (const AString & a_Reason) override; virtual void SendEditSign (int a_BlockX, int a_BlockY, int a_BlockZ) override; ///< Request the client to open up the sign editor for the sign (1.6+) + virtual void SendEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration) override; virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) override; virtual void SendEntityHeadLook (const cEntity & a_Entity) override; virtual void SendEntityLook (const cEntity & a_Entity) override; @@ -96,6 +97,7 @@ public: virtual void SendPlayerMoveLook (void) override; virtual void SendPlayerPosition (void) override; virtual void SendPlayerSpawn (const cPlayer & a_Player) override; + virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override; virtual void SendRespawn (void) override; virtual void SendExperience (void) override; virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) override; |