summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Bindings/AllToLua.pkg2
-rw-r--r--src/Bindings/Bindings.cpp243
-rw-r--r--src/Bindings/Bindings.h2
-rw-r--r--src/Bindings/tolua++.h13
-rw-r--r--src/Blocks/BlockFire.h13
-rw-r--r--src/Chunk.cpp32
-rw-r--r--src/Chunk.h2
-rw-r--r--src/ChunkMap.cpp33
-rw-r--r--src/ChunkMap.h2
-rw-r--r--src/ClientHandle.cpp37
-rw-r--r--src/ClientHandle.h4
-rw-r--r--src/Entities/Effects.h30
-rw-r--r--src/Entities/ExpOrb.cpp4
-rw-r--r--src/Entities/Player.cpp42
-rw-r--r--src/Entities/Player.h14
-rw-r--r--src/Entities/TNTEntity.h8
-rw-r--r--src/Globals.h1
-rw-r--r--src/Mobs/Monster.cpp6
-rw-r--r--src/OSSupport/IsThread.cpp2
-rw-r--r--src/Protocol/Protocol.h2
-rw-r--r--src/Protocol/Protocol125.cpp30
-rw-r--r--src/Protocol/Protocol125.h2
-rw-r--r--src/Protocol/Protocol17x.cpp58
-rw-r--r--src/Protocol/Protocol17x.h2
-rw-r--r--src/Protocol/ProtocolRecognizer.cpp20
-rw-r--r--src/Protocol/ProtocolRecognizer.h2
-rw-r--r--src/World.cpp18
-rw-r--r--src/World.h2
28 files changed, 598 insertions, 28 deletions
diff --git a/src/Bindings/AllToLua.pkg b/src/Bindings/AllToLua.pkg
index 2a70efedf..e9a5ea0c6 100644
--- a/src/Bindings/AllToLua.pkg
+++ b/src/Bindings/AllToLua.pkg
@@ -36,6 +36,8 @@ $cfile "../Entities/Pawn.h"
$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 aff8fb67a..46f8c8f40 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/11/13 12:34:21.
+** Generated automatically by tolua++-1.0.92 on 12/15/13 14:19:12.
*/
#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);
@@ -34,6 +34,8 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S);
#include "../Entities/Player.h"
#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"
@@ -218,7 +220,7 @@ static void tolua_reg_types (lua_State* tolua_S)
tolua_usertype(tolua_S,"cItemGrid");
tolua_usertype(tolua_S,"cHTTPServer::cCallbacks");
tolua_usertype(tolua_S,"cLuaWindow");
- tolua_usertype(tolua_S,"cServer");
+ tolua_usertype(tolua_S,"cInventory");
tolua_usertype(tolua_S,"cHopperEntity");
tolua_usertype(tolua_S,"std::vector<AString>");
tolua_usertype(tolua_S,"cBlockEntityWithItems");
@@ -226,15 +228,16 @@ static void tolua_reg_types (lua_State* tolua_S)
tolua_usertype(tolua_S,"cCraftingGrid");
tolua_usertype(tolua_S,"cBlockArea");
tolua_usertype(tolua_S,"cGroup");
- tolua_usertype(tolua_S,"cItem");
tolua_usertype(tolua_S,"cTracer");
+ tolua_usertype(tolua_S,"cItem");
+ tolua_usertype(tolua_S,"cBoundingBox");
tolua_usertype(tolua_S,"cArrowEntity");
tolua_usertype(tolua_S,"cDropSpenserEntity");
- tolua_usertype(tolua_S,"cBoundingBox");
tolua_usertype(tolua_S,"cCuboid");
tolua_usertype(tolua_S,"Vector3i");
- tolua_usertype(tolua_S,"cNoteEntity");
tolua_usertype(tolua_S,"Vector3d");
+ tolua_usertype(tolua_S,"cNoteEntity");
+ tolua_usertype(tolua_S,"cServer");
tolua_usertype(tolua_S,"cBlockEntity");
tolua_usertype(tolua_S,"cCriticalSection");
tolua_usertype(tolua_S,"HTTPTemplateRequest");
@@ -254,8 +257,8 @@ static void tolua_reg_types (lua_State* tolua_S)
tolua_usertype(tolua_S,"cDropperEntity");
tolua_usertype(tolua_S,"cProjectileEntity");
tolua_usertype(tolua_S,"cItemGrid::cListener");
- tolua_usertype(tolua_S,"cInventory");
tolua_usertype(tolua_S,"cPlayer");
+ tolua_usertype(tolua_S,"cTNTEntity");
}
/* method: new of class cIniFile */
@@ -10457,6 +10460,38 @@ static int tolua_AllToLua_cPlayer_IsEating00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* method: IsFlying of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_IsFlying00
+static int tolua_AllToLua_cPlayer_IsFlying00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cPlayer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cPlayer* self = (const cPlayer*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'IsFlying'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->IsFlying();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'IsFlying'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: Respawn of class cPlayer */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_Respawn00
static int tolua_AllToLua_cPlayer_Respawn00(lua_State* tolua_S)
@@ -10846,6 +10881,72 @@ static int tolua_AllToLua_cPlayer_SetSprint00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* method: SetFlying of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_SetFlying00
+static int tolua_AllToLua_cPlayer_SetFlying00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPlayer",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
+ bool a_IsFlying = ((bool) tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetFlying'", NULL);
+#endif
+ {
+ self->SetFlying(a_IsFlying);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetFlying'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetCanFly of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_SetCanFly00
+static int tolua_AllToLua_cPlayer_SetCanFly00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPlayer",0,&tolua_err) ||
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
+ bool a_CanFly = ((bool) tolua_toboolean(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetCanFly'", NULL);
+#endif
+ {
+ self->SetCanFly(a_CanFly);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetCanFly'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: IsSwimming of class cPlayer */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_IsSwimming00
static int tolua_AllToLua_cPlayer_IsSwimming00(lua_State* tolua_S)
@@ -10910,6 +11011,38 @@ static int tolua_AllToLua_cPlayer_IsSubmerged00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* method: CanFly of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_CanFly00
+static int tolua_AllToLua_cPlayer_CanFly00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cPlayer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cPlayer* self = (const cPlayer*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'CanFly'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->CanFly();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'CanFly'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: new of class cPickup */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cPickup_new00
static int tolua_AllToLua_cPickup_new00(lua_State* tolua_S)
@@ -11518,6 +11651,70 @@ static int tolua_AllToLua_cArrowEntity_SetIsCritical00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* method: GetCounterTime of class cTNTEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cTNTEntity_GetCounterTime00
+static int tolua_AllToLua_cTNTEntity_GetCounterTime00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cTNTEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cTNTEntity* self = (const cTNTEntity*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetCounterTime'", NULL);
+#endif
+ {
+ double tolua_ret = (double) self->GetCounterTime();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetCounterTime'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetMaxFuseTime of class cTNTEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cTNTEntity_GetMaxFuseTime00
+static int tolua_AllToLua_cTNTEntity_GetMaxFuseTime00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cTNTEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cTNTEntity* self = (const cTNTEntity*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetMaxFuseTime'", NULL);
+#endif
+ {
+ double tolua_ret = (double) self->GetMaxFuseTime();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetMaxFuseTime'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: GetDescription of class cServer */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cServer_GetDescription00
static int tolua_AllToLua_cServer_GetDescription00(lua_State* tolua_S)
@@ -30911,6 +31108,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"AddFoodExhaustion",tolua_AllToLua_cPlayer_AddFoodExhaustion00);
tolua_function(tolua_S,"FoodPoison",tolua_AllToLua_cPlayer_FoodPoison00);
tolua_function(tolua_S,"IsEating",tolua_AllToLua_cPlayer_IsEating00);
+ tolua_function(tolua_S,"IsFlying",tolua_AllToLua_cPlayer_IsFlying00);
tolua_function(tolua_S,"Respawn",tolua_AllToLua_cPlayer_Respawn00);
tolua_function(tolua_S,"SetVisible",tolua_AllToLua_cPlayer_SetVisible00);
tolua_function(tolua_S,"IsVisible",tolua_AllToLua_cPlayer_IsVisible00);
@@ -30923,8 +31121,11 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"SetSprintingMaxSpeed",tolua_AllToLua_cPlayer_SetSprintingMaxSpeed00);
tolua_function(tolua_S,"SetCrouch",tolua_AllToLua_cPlayer_SetCrouch00);
tolua_function(tolua_S,"SetSprint",tolua_AllToLua_cPlayer_SetSprint00);
+ tolua_function(tolua_S,"SetFlying",tolua_AllToLua_cPlayer_SetFlying00);
+ tolua_function(tolua_S,"SetCanFly",tolua_AllToLua_cPlayer_SetCanFly00);
tolua_function(tolua_S,"IsSwimming",tolua_AllToLua_cPlayer_IsSwimming00);
tolua_function(tolua_S,"IsSubmerged",tolua_AllToLua_cPlayer_IsSubmerged00);
+ tolua_function(tolua_S,"CanFly",tolua_AllToLua_cPlayer_CanFly00);
tolua_endmodule(tolua_S);
#ifdef __cplusplus
tolua_cclass(tolua_S,"cPickup","cPickup","cEntity",tolua_collect_cPickup);
@@ -30993,6 +31194,34 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_cclass(tolua_S,"cFireChargeEntity","cFireChargeEntity","cProjectileEntity",NULL);
tolua_beginmodule(tolua_S,"cFireChargeEntity");
tolua_endmodule(tolua_S);
+ tolua_cclass(tolua_S,"cTNTEntity","cTNTEntity","cEntity",NULL);
+ tolua_beginmodule(tolua_S,"cTNTEntity");
+ 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 c07c0588b..4805c260e 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/11/13 12:34:22.
+** Generated automatically by tolua++-1.0.92 on 12/15/13 14:19:13.
*/
/* Exported function */
diff --git a/src/Bindings/tolua++.h b/src/Bindings/tolua++.h
new file mode 100644
index 000000000..4dfd06318
--- /dev/null
+++ b/src/Bindings/tolua++.h
@@ -0,0 +1,13 @@
+
+// tolua++.h
+
+// Redirection file, needed because ToLua++ generates the Bindings.cpp file with >> #include "tolua++.h" <<
+
+
+
+
+#include "tolua++/include/tolua++.h"
+
+
+
+
diff --git a/src/Blocks/BlockFire.h b/src/Blocks/BlockFire.h
index 46b56d7e0..a69fe2131 100644
--- a/src/Blocks/BlockFire.h
+++ b/src/Blocks/BlockFire.h
@@ -67,9 +67,8 @@ public:
return 0;
}
- int newY = Y + 1;
-
- for (newY; newY < cChunkDef::Height; newY++)
+
+ for (int newY = Y + 1; newY < cChunkDef::Height; newY++)
{
BLOCKTYPE Block = a_World->GetBlock(X, newY, Z);
if ((Block == E_BLOCK_AIR) || (Block == E_BLOCK_FIRE))
@@ -155,7 +154,7 @@ public:
{
Dir = 1; // Set assumed direction (will change if portal turns out to be facing the other direction)
bool FoundFrameXP = false, FoundFrameXM = false;
- for (X1; ((a_World->GetBlock(X1, Y, Z) == E_BLOCK_OBSIDIAN) || (a_World->GetBlock(X1, Y + 1, Z) == E_BLOCK_OBSIDIAN)); X1++) // Check XP for obsidian blocks, exempting corners
+ for (; ((a_World->GetBlock(X1, Y, Z) == E_BLOCK_OBSIDIAN) || (a_World->GetBlock(X1, Y + 1, Z) == E_BLOCK_OBSIDIAN)); X1++) // Check XP for obsidian blocks, exempting corners
{
int Value = FindObsidianCeiling(X1, Y, Z, a_World, MaxY);
int ValueTwo = FindObsidianCeiling(X1, Y + 1, Z, a_World, MaxY); // For corners without obsidian
@@ -169,7 +168,7 @@ public:
return false; // Not valid slice, no portal can be formed
}
} XZP = X1 - 1; // Set boundary of frame interior, note that for some reason, the loop of X and the loop of Z go to different numbers, hence -1 here and -2 there
- for (X2; ((a_World->GetBlock(X2, Y, Z) == E_BLOCK_OBSIDIAN) || (a_World->GetBlock(X2, Y + 1, Z) == E_BLOCK_OBSIDIAN)); X2--) // Go the other direction (XM)
+ for (; ((a_World->GetBlock(X2, Y, Z) == E_BLOCK_OBSIDIAN) || (a_World->GetBlock(X2, Y + 1, Z) == E_BLOCK_OBSIDIAN)); X2--) // Go the other direction (XM)
{
int Value = FindObsidianCeiling(X2, Y, Z, a_World, MaxY);
int ValueTwo = FindObsidianCeiling(X2, Y + 1, Z, a_World, MaxY);
@@ -191,7 +190,7 @@ public:
{
Dir = 2;
bool FoundFrameZP = false, FoundFrameZM = false;
- for (Z1; ((a_World->GetBlock(X, Y, Z1) == E_BLOCK_OBSIDIAN) || (a_World->GetBlock(X, Y + 1, Z1) == E_BLOCK_OBSIDIAN)); Z1++)
+ for (; ((a_World->GetBlock(X, Y, Z1) == E_BLOCK_OBSIDIAN) || (a_World->GetBlock(X, Y + 1, Z1) == E_BLOCK_OBSIDIAN)); Z1++)
{
int Value = FindObsidianCeiling(X, Y, Z1, a_World, MaxY);
int ValueTwo = FindObsidianCeiling(X, Y + 1, Z1, a_World, MaxY);
@@ -205,7 +204,7 @@ public:
return false;
}
} XZP = Z1 - 2;
- for (Z2; ((a_World->GetBlock(X, Y, Z2) == E_BLOCK_OBSIDIAN) || (a_World->GetBlock(X, Y + 1, Z2) == E_BLOCK_OBSIDIAN)); Z2--)
+ for (; ((a_World->GetBlock(X, Y, Z2) == E_BLOCK_OBSIDIAN) || (a_World->GetBlock(X, Y + 1, Z2) == E_BLOCK_OBSIDIAN)); Z2--)
{
int Value = FindObsidianCeiling(X, Y, Z2, a_World, MaxY);
int ValueTwo = FindObsidianCeiling(X, Y + 1, Z2, a_World, MaxY);
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index b3c1896dc..3eb46213c 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -2589,6 +2589,22 @@ void cChunk::BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandl
+void cChunk::BroadcastEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude)
+{
+ for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ {
+ if (*itr == a_Exclude)
+ {
+ continue;
+ }
+ (*itr)->SendEntityEffect(a_Entity, a_EffectID, a_Amplifier, a_Duration);
+ } // for itr - LoadedByClient[]
+}
+
+
+
+
+
void cChunk::BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude)
{
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
@@ -2733,6 +2749,22 @@ void cChunk::BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation
+void cChunk::BroadcastRemoveEntityEffect(const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude)
+{
+ for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
+ {
+ if (*itr == a_Exclude)
+ {
+ continue;
+ }
+ (*itr)->SendRemoveEntityEffect(a_Entity, a_EffectID);
+ } // for itr - LoadedByClient[]
+}
+
+
+
+
+
void cChunk::BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude)
{
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
diff --git a/src/Chunk.h b/src/Chunk.h
index a5bc9863b..1d762c0ca 100644
--- a/src/Chunk.h
+++ b/src/Chunk.h
@@ -267,6 +267,7 @@ public:
void BroadcastChunkData (cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = NULL);
void BroadcastCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL);
void BroadcastDestroyEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
+ void BroadcastEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityHeadLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
@@ -276,6 +277,7 @@ public:
void BroadcastEntityStatus (const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityVelocity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityAnimation (const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = NULL);
+ void BroadcastRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude = NULL);
void BroadcastSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL); // a_Src coords are Block * 8
void BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = NULL);
void BroadcastSpawnEntity (cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index f2195741d..53b595545 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -445,6 +445,22 @@ void cChunkMap::BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHa
+void cChunkMap::BroadcastEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude)
+{
+ cCSLock Lock(m_CSLayers);
+ cChunkPtr Chunk = GetChunkNoGen(a_Entity.GetChunkX(), ZERO_CHUNK_Y, a_Entity.GetChunkZ());
+ if (Chunk == NULL)
+ {
+ return;
+ }
+ // It's perfectly legal to broadcast packets even to invalid chunks!
+ Chunk->BroadcastEntityEffect(a_Entity, a_EffectID, a_Amplifier, a_Duration);
+}
+
+
+
+
+
void cChunkMap::BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSLayers);
@@ -589,6 +605,23 @@ void cChunkMap::BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animat
+void cChunkMap::BroadcastRemoveEntityEffect(const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude)
+{
+ cCSLock Lock(m_CSLayers);
+
+ cChunkPtr Chunk = GetChunkNoGen(a_Entity.GetChunkX(), ZERO_CHUNK_Y, a_Entity.GetChunkZ());
+ if (Chunk == NULL)
+ {
+ return;
+ }
+ // It's perfectly legal to broadcast packets even to invalid chunks!
+ Chunk->BroadcastRemoveEntityEffect(a_Entity, a_EffectID, a_Exclude);
+}
+
+
+
+
+
void cChunkMap::BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSLayers);
diff --git a/src/ChunkMap.h b/src/ChunkMap.h
index f079c9a1b..dcc6abdc3 100644
--- a/src/ChunkMap.h
+++ b/src/ChunkMap.h
@@ -64,6 +64,7 @@ public:
void BroadcastChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = NULL);
void BroadcastCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL);
void BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
+ void BroadcastEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityHeadLook(const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityLook(const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
@@ -73,6 +74,7 @@ public:
void BroadcastEntityStatus(const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityVelocity(const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = NULL);
+ void BroadcastRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude = NULL);
void BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL); // a_Src coords are Block * 8
void BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = NULL);
void BroadcastSpawnEntity(cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index f7e18974f..d585eccf1 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -490,6 +490,16 @@ void cClientHandle::HandleCreativeInventory(short a_SlotNum, const cItem & a_Hel
+void cClientHandle::HandlePlayerAbilities(bool a_CanFly, bool a_IsFlying, float FlyingSpeed, float WalkingSpeed)
+{
+ m_Player->SetCanFly(a_CanFly);
+ m_Player->SetFlying(a_IsFlying);
+}
+
+
+
+
+
void cClientHandle::HandlePlayerPos(double a_PosX, double a_PosY, double a_PosZ, double a_Stance, bool a_IsOnGround)
{
if ((m_Player == NULL) || (m_State != csPlaying))
@@ -1673,6 +1683,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);
@@ -1822,6 +1841,15 @@ void cClientHandle::SendEntityAnimation(const cEntity & a_Entity, char a_Animati
+void cClientHandle::SendPlayerAbilities()
+{
+ m_Protocol->SendPlayerAbilities();
+}
+
+
+
+
+
void cClientHandle::SendPlayerListItem(const cPlayer & a_Player, bool a_IsOnline)
{
m_Protocol->SendPlayerListItem(a_Player, a_IsOnline);
@@ -1882,6 +1910,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..147a5b2b3 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);
@@ -115,11 +116,13 @@ public:
void SendInventorySlot (char a_WindowID, short a_SlotNum, const cItem & a_Item);
void SendPickupSpawn (const cPickup & a_Pickup);
void SendEntityAnimation (const cEntity & a_Entity, char a_Animation);
+ void SendPlayerAbilities (void);
void SendPlayerListItem (const cPlayer & a_Player, bool a_IsOnline);
void SendPlayerMaxSpeed (void); ///< Informs the client of the maximum player speed (1.6.1+)
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);
@@ -173,6 +176,7 @@ public:
void HandleKeepAlive (int a_KeepAliveID);
void HandleLeftClick (int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status);
void HandlePing (void);
+ void HandlePlayerAbilities (bool a_CanFly, bool a_IsFlying, float FlyingSpeed, float WalkingSpeed);
void HandlePlayerLook (float a_Rotation, float a_Pitch, bool a_IsOnGround);
void HandlePlayerMoveLook (double a_PosX, double a_PosY, double a_PosZ, double a_Stance, float a_Rotation, float a_Pitch, bool a_IsOnGround); // While m_bPositionConfirmed (normal gameplay)
void HandlePlayerPos (double a_PosX, double a_PosY, double a_PosZ, double a_Stance, bool a_IsOnGround);
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/ExpOrb.cpp b/src/Entities/ExpOrb.cpp
index 27d34f6ed..04ee85823 100644
--- a/src/Entities/ExpOrb.cpp
+++ b/src/Entities/ExpOrb.cpp
@@ -49,12 +49,12 @@ void cExpOrb::Tick(float a_Dt, cChunk & a_Chunk)
double Distance(a_Distance.Length());
if (Distance < 0.1f)
{
+ LOGD("Player %s picked up an ExpOrb. His reward is %i", a_ClosestPlayer->GetName().c_str(), m_Reward);
a_ClosestPlayer->DeltaExperience(m_Reward);
- a_ClosestPlayer->SendExperience();
Destroy(true);
}
a_Distance.Normalize();
- a_Distance *= ((float) (5.5 - Distance));
+ a_Distance *= ((float) (5.5 - Distance));
SetSpeedX( a_Distance.x );
SetSpeedY( a_Distance.y );
SetSpeedZ( a_Distance.z );
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 85833f31d..c2a76342d 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -63,6 +63,8 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
, m_IsSprinting(false)
, m_IsSwimming(false)
, m_IsSubmerged(false)
+ , m_IsFlying(false)
+ , m_CanFly(false)
, m_EatingFinishTick(-1)
, m_IsChargingBow(false)
, m_BowCharge(0)
@@ -557,9 +559,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_World->BroadcastRemoveEntityEffect(*this, E_EFFECT_HUNGER);
SendHealth();
}
+ else
+ {
+ m_World->BroadcastEntityEffect(*this, E_EFFECT_HUNGER, 0, 400); // Give the player the "Hunger" effect for 20 seconds.
+ }
}
@@ -747,6 +753,36 @@ void cPlayer::SetSprint(bool a_IsSprinting)
+void cPlayer::SetCanFly(bool a_CanFly)
+{
+ if (a_CanFly == m_CanFly)
+ {
+ return;
+ }
+
+ m_CanFly = a_CanFly;
+ m_ClientHandle->SendPlayerAbilities();
+}
+
+
+
+
+
+void cPlayer::SetFlying(bool a_IsFlying)
+{
+ if (a_IsFlying == m_IsFlying)
+ {
+ return;
+ }
+
+ m_IsFlying = a_IsFlying;
+ m_ClientHandle->SendPlayerAbilities();
+}
+
+
+
+
+
void cPlayer::DoTakeDamage(TakeDamageInfo & a_TDI)
{
if (a_TDI.DamageType != dtInVoid)
@@ -1704,6 +1740,10 @@ void cPlayer::HandleFood(void)
m_FoodPoisonedTicksRemaining--;
m_FoodExhaustionLevel += 0.025; // 0.5 per second = 0.025 per tick
}
+ else
+ {
+ m_World->BroadcastRemoveEntityEffect(*this, E_EFFECT_HUNGER); // Remove the "Hunger" effect.
+ }
// Apply food exhaustion that has accumulated:
if (m_FoodExhaustionLevel >= 4)
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index 44cab7d74..f3ee841e7 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -250,6 +250,8 @@ public:
/// Returns true if the player is currently in the process of eating the currently equipped item
bool IsEating(void) const { return (m_EatingFinishTick >= 0); }
+ /// Returns true if the player is currently flying.
+ bool IsFlying(void) const { return m_IsFlying; }
// tolua_end
/// Starts eating the currently equipped item. Resets the eating timer and sends the proper animation packet
@@ -319,12 +321,20 @@ public:
/// Starts or stops sprinting, sends the max speed update to the client, if needed
void SetSprint(bool a_IsSprinting);
+ /// Flags the player as flying
+ void SetFlying(bool a_IsFlying);
+
+ /// If true the player can fly even when he's not in creative.
+ void SetCanFly(bool a_CanFly);
+
/// Returns whether the player is swimming or not
virtual bool IsSwimming(void) const{ return m_IsSwimming; }
/// Return whether the player is under water or not
virtual bool IsSubmerged(void) const{ return m_IsSubmerged; }
+ /// Returns wheter the player can fly or not.
+ virtual bool CanFly(void) const { return m_CanFly; }
// tolua_end
// cEntity overrides:
@@ -415,10 +425,12 @@ protected:
bool m_IsCrouched;
bool m_IsSprinting;
-
+ bool m_IsFlying;
bool m_IsSwimming;
bool m_IsSubmerged;
+ bool m_CanFly; // If this is true the player can fly. Even if he is not in creative.
+
/// The world tick in which eating will be finished. -1 if not eating
Int64 m_EatingFinishTick;
diff --git a/src/Entities/TNTEntity.h b/src/Entities/TNTEntity.h
index eb5040e8a..d1fcae766 100644
--- a/src/Entities/TNTEntity.h
+++ b/src/Entities/TNTEntity.h
@@ -6,13 +6,14 @@
-
+// tolua_begin
class cTNTEntity :
public cEntity
{
typedef cEntity super;
public:
+ // tolua_end
CLASS_PROTODEF(cTNTEntity);
cTNTEntity(double a_X, double a_Y, double a_Z, double a_FuseTimeInSec);
@@ -21,11 +22,14 @@ public:
// cEntity overrides:
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+
+ double GetCounterTime(void) const { return m_Counter; } // tolua_export
+ double GetMaxFuseTime(void) const { return m_MaxFuseTime; } // tolua_export
protected:
double m_Counter; ///< How much time has elapsed since the object was created, in seconds
double m_MaxFuseTime; ///< How long the fuse is, in seconds
-};
+}; // tolua_export
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/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 091623c8a..0e2da942d 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -274,6 +274,7 @@ void cMonster::KilledBy(cEntity * a_Killer)
case cMonster::mtWolf:
{
Reward = m_World->GetTickRandomNumber(2) + 1;
+ break;
}
// Monsters
@@ -291,25 +292,30 @@ void cMonster::KilledBy(cEntity * a_Killer)
case cMonster::mtMagmaCube:
{
Reward = 6 + (m_World->GetTickRandomNumber(2));
+ break;
}
case cMonster::mtBlaze:
{
Reward = 10;
+ break;
}
// Bosses
case cMonster::mtEnderDragon:
{
Reward = 12000;
+ break;
}
case cMonster::mtWither:
{
Reward = 50;
+ break;
}
default:
{
Reward = 0;
+ break;
}
}
m_World->SpawnExperienceOrb(GetPosX(), GetPosY(), GetPosZ(), Reward);
diff --git a/src/OSSupport/IsThread.cpp b/src/OSSupport/IsThread.cpp
index 4da9f9949..7eb114a82 100644
--- a/src/OSSupport/IsThread.cpp
+++ b/src/OSSupport/IsThread.cpp
@@ -124,7 +124,7 @@ void cIsThread::Stop(void)
bool cIsThread::Wait(void)
{
- if (m_Handle == NULL)
+ if (m_Handle == NULL_HANDLE)
{
return true;
}
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..48f23801c 100644
--- a/src/Protocol/Protocol125.cpp
+++ b/src/Protocol/Protocol125.cpp
@@ -73,7 +73,9 @@ enum
PACKET_ENT_STATUS = 0x26,
PACKET_ATTACH_ENTITY = 0x27,
PACKET_METADATA = 0x28,
+ PACKET_ENTITY_EFFECT = 0x29,
PACKET_SPAWN_EXPERIENCE_ORB = 0x1A,
+ PACKET_REMOVE_ENTITY_EFFECT = 0x2a,
PACKET_EXPERIENCE = 0x2b,
PACKET_PRE_CHUNK = 0x32,
PACKET_MAP_CHUNK = 0x33,
@@ -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 bfb38904c..edf7d2529 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
@@ -478,7 +491,15 @@ void cProtocol172::SendPlayerAbilities(void)
{
Flags |= 0x01;
}
- // TODO: Other flags (god mode, flying, can fly
+ if (m_Client->GetPlayer()->IsFlying())
+ {
+ Flags |= 0x02;
+ }
+ if (m_Client->GetPlayer()->CanFly())
+ {
+ Flags |= 0x04;
+ }
+ // TODO: Other flags (god mode)
Pkt.WriteByte(Flags);
// TODO: Pkt.WriteFloat(m_Client->GetPlayer()->GetMaxFlyingSpeed());
Pkt.WriteFloat(0.05f);
@@ -585,6 +606,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
@@ -921,7 +953,6 @@ void cProtocol172::SendWindowProperty(const cWindow & a_Window, short a_Property
void cProtocol172::AddReceivedData(const char * a_Data, int a_Size)
{
- LOGD("Received %d bytes of data", a_Size);
if (!m_ReceivedData.Write(a_Data, a_Size))
{
// Too much data in the incoming queue, report to caller:
@@ -958,9 +989,6 @@ void cProtocol172::AddReceivedData(const char * a_Data, int a_Size)
return;
}
- // DEBUG:
- LOGD("Packet 0x%x, len %d (0x%x), start at %d", PacketType, PacketLen, PacketLen, PacketStart);
-
HandlePacket(bb, PacketType);
if (bb.GetReadableSpace() != 1)
@@ -1258,7 +1286,25 @@ void cProtocol172::HandlePacketPlayerAbilities(cByteBuffer & a_ByteBuffer)
HANDLE_READ(a_ByteBuffer, ReadByte, Byte, Flags);
HANDLE_READ(a_ByteBuffer, ReadBEFloat, float, FlyingSpeed);
HANDLE_READ(a_ByteBuffer, ReadBEFloat, float, WalkingSpeed);
- // TODO: m_Client->HandlePlayerAbilities();
+
+ bool IsFlying, CanFly;
+ if ((Flags & 2) != 0)
+ {
+ IsFlying = true;
+ }
+ else
+ {
+ IsFlying = false;
+ }
+ if ((Flags & 4) != 0)
+ {
+ CanFly = true;
+ }
+ else
+ {
+ CanFly = false;
+ }
+ m_Client->HandlePlayerAbilities(CanFly, IsFlying, FlyingSpeed, WalkingSpeed);
}
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;
diff --git a/src/World.cpp b/src/World.cpp
index 9ec389be9..35887c07d 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -1813,6 +1813,15 @@ void cWorld::BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandl
+void cWorld::BroadcastEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude)
+{
+ m_ChunkMap->BroadcastEntityEffect(a_Entity, a_EffectID, a_Amplifier, a_Duration, a_Exclude);
+}
+
+
+
+
+
void cWorld::BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude)
{
m_ChunkMap->BroadcastEntityEquipment(a_Entity, a_SlotNum, a_Item, a_Exclude);
@@ -1911,6 +1920,15 @@ void cWorld::BroadcastPlayerListItem (const cPlayer & a_Player, bool a_IsOnline,
+void cWorld::BroadcastRemoveEntityEffect(const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude)
+{
+ m_ChunkMap->BroadcastRemoveEntityEffect(a_Entity, a_EffectID, a_Exclude);
+}
+
+
+
+
+
void cWorld::BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude)
{
m_ChunkMap->BroadcastSoundEffect(a_SoundName, a_SrcX, a_SrcY, a_SrcZ, a_Volume, a_Pitch, a_Exclude);
diff --git a/src/World.h b/src/World.h
index 5cd8b41b6..16d7f5146 100644
--- a/src/World.h
+++ b/src/World.h
@@ -153,6 +153,7 @@ public:
void BroadcastChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = NULL);
void BroadcastCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL);
void BroadcastDestroyEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
+ void BroadcastEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityHeadLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
@@ -163,6 +164,7 @@ public:
void BroadcastEntityVelocity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityAnimation (const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = NULL);
void BroadcastPlayerListItem (const cPlayer & a_Player, bool a_IsOnline, const cClientHandle * a_Exclude = NULL);
+ void BroadcastRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude = NULL);
void BroadcastSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL); // tolua_export a_Src coords are Block * 8
void BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = NULL); // tolua_export
void BroadcastSpawnEntity (cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);