summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-08-25 17:06:51 +0200
committermadmaxoft <github@xoft.cz>2013-08-25 17:06:51 +0200
commit83811b69292bff0ef4b24087a4a4d3e523b0076a (patch)
tree50bf797896f5df82af4cfcd642759d005c598044
parentProjectile entities get saved into MCA files (diff)
parentReduced LeakFinder's stack buffers to half. (diff)
downloadcuberite-83811b69292bff0ef4b24087a4a4d3e523b0076a.tar
cuberite-83811b69292bff0ef4b24087a4a4d3e523b0076a.tar.gz
cuberite-83811b69292bff0ef4b24087a4a4d3e523b0076a.tar.bz2
cuberite-83811b69292bff0ef4b24087a4a4d3e523b0076a.tar.lz
cuberite-83811b69292bff0ef4b24087a4a4d3e523b0076a.tar.xz
cuberite-83811b69292bff0ef4b24087a4a4d3e523b0076a.tar.zst
cuberite-83811b69292bff0ef4b24087a4a4d3e523b0076a.zip
-rw-r--r--.gitignore1
-rw-r--r--source/Bindings.cpp160
-rw-r--r--source/Bindings.h2
-rw-r--r--source/BlockID.h70
-rw-r--r--source/Blocks/BlockCarpet.h12
-rw-r--r--source/Blocks/BlockDoor.cpp5
-rw-r--r--source/Blocks/BlockHandler.cpp5
-rw-r--r--source/Blocks/BlockSlab.h132
-rw-r--r--source/Blocks/BlockVine.h7
-rw-r--r--source/ClientHandle.cpp83
-rw-r--r--source/ClientHandle.h6
-rw-r--r--source/Entities/Pickup.cpp7
-rw-r--r--source/Items/ItemLighter.h9
-rw-r--r--source/LeakFinder.cpp11
-rw-r--r--source/Plugin.h7
-rw-r--r--source/PluginLua.cpp30
-rw-r--r--source/PluginLua.h3
-rw-r--r--source/PluginManager.cpp4
-rw-r--r--source/Simulator/RedstoneSimulator.cpp24
-rw-r--r--source/StringUtils.cpp43
-rw-r--r--source/Tracer.cpp4
-rw-r--r--source/World.cpp9
22 files changed, 497 insertions, 137 deletions
diff --git a/.gitignore b/.gitignore
index b8a60a580..7706ecc0a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,4 @@ cloc.xsl
*.user
*.suo
/EveryNight.cmd
+*.sublime-*
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
index 849473e81..90223303d 100644
--- a/source/Bindings.cpp
+++ b/source/Bindings.cpp
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 08/22/13 08:53:27.
+** Generated automatically by tolua++-1.0.92 on 08/25/13 17:06:06.
*/
#ifndef __cplusplus
@@ -9400,6 +9400,38 @@ static int tolua_AllToLua_cPickup_IsCollected00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* method: GetProjectileKind of class cProjectileEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cProjectileEntity_GetProjectileKind00
+static int tolua_AllToLua_cProjectileEntity_GetProjectileKind00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cProjectileEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cProjectileEntity* self = (const cProjectileEntity*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetProjectileKind'", NULL);
+#endif
+ {
+ cProjectileEntity::eKind tolua_ret = (cProjectileEntity::eKind) self->GetProjectileKind();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetProjectileKind'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: GetCreator of class cProjectileEntity */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cProjectileEntity_GetCreator00
static int tolua_AllToLua_cProjectileEntity_GetCreator00(lua_State* tolua_S)
@@ -9432,6 +9464,70 @@ static int tolua_AllToLua_cProjectileEntity_GetCreator00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* method: GetMCAClassName of class cProjectileEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cProjectileEntity_GetMCAClassName00
+static int tolua_AllToLua_cProjectileEntity_GetMCAClassName00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cProjectileEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cProjectileEntity* self = (const cProjectileEntity*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetMCAClassName'", NULL);
+#endif
+ {
+ AString tolua_ret = (AString) self->GetMCAClassName();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetMCAClassName'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: IsInGround of class cProjectileEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cProjectileEntity_IsInGround00
+static int tolua_AllToLua_cProjectileEntity_IsInGround00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cProjectileEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cProjectileEntity* self = (const cProjectileEntity*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'IsInGround'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->IsInGround();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'IsInGround'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: Get of class cPluginManager */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cPluginManager_Get00
static int tolua_AllToLua_cPluginManager_Get00(lua_State* tolua_S)
@@ -27519,14 +27615,14 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_constant(tolua_S,"E_META_DROPSPENSER_FACING_ZP",E_META_DROPSPENSER_FACING_ZP);
tolua_constant(tolua_S,"E_META_DROPSPENSER_FACING_XM",E_META_DROPSPENSER_FACING_XM);
tolua_constant(tolua_S,"E_META_DROPSPENSER_FACING_XP",E_META_DROPSPENSER_FACING_XP);
- tolua_constant(tolua_S,"E_META_DOUBLE_STEP_STONE",E_META_DOUBLE_STEP_STONE);
- tolua_constant(tolua_S,"E_META_DOUBLE_STEP_SANDSTONE",E_META_DOUBLE_STEP_SANDSTONE);
- tolua_constant(tolua_S,"E_META_DOUBLE_STEP_WOODEN",E_META_DOUBLE_STEP_WOODEN);
- tolua_constant(tolua_S,"E_META_DOUBLE_STEP_COBBLESTONE",E_META_DOUBLE_STEP_COBBLESTONE);
- tolua_constant(tolua_S,"E_META_DOUBLE_STEP_BRICK",E_META_DOUBLE_STEP_BRICK);
- tolua_constant(tolua_S,"E_META_DOUBLE_STEP_STONE_BRICK",E_META_DOUBLE_STEP_STONE_BRICK);
- tolua_constant(tolua_S,"E_META_DOUBLE_STEP_NETHER_BRICK",E_META_DOUBLE_STEP_NETHER_BRICK);
- tolua_constant(tolua_S,"E_META_DOUBLE_STEP_STONE_SECRET",E_META_DOUBLE_STEP_STONE_SECRET);
+ tolua_constant(tolua_S,"E_META_DOUBLE_STONE_SLAB_STONE",E_META_DOUBLE_STONE_SLAB_STONE);
+ tolua_constant(tolua_S,"E_META_DOUBLE_STONE_SLAB_SANDSTONE",E_META_DOUBLE_STONE_SLAB_SANDSTONE);
+ tolua_constant(tolua_S,"E_META_DOUBLE_STONE_SLAB_WOODEN",E_META_DOUBLE_STONE_SLAB_WOODEN);
+ tolua_constant(tolua_S,"E_META_DOUBLE_STONE_SLAB_COBBLESTONE",E_META_DOUBLE_STONE_SLAB_COBBLESTONE);
+ tolua_constant(tolua_S,"E_META_DOUBLE_STONE_SLAB_BRICK",E_META_DOUBLE_STONE_SLAB_BRICK);
+ tolua_constant(tolua_S,"E_META_DOUBLE_STONE_SLAB_STONE_BRICK",E_META_DOUBLE_STONE_SLAB_STONE_BRICK);
+ tolua_constant(tolua_S,"E_META_DOUBLE_STONE_SLAB_NETHER_BRICK",E_META_DOUBLE_STONE_SLAB_NETHER_BRICK);
+ tolua_constant(tolua_S,"E_META_DOUBLE_STONE_SLAB_STONE_SECRET",E_META_DOUBLE_STONE_SLAB_STONE_SECRET);
tolua_constant(tolua_S,"E_META_HOPPER_FACING_YM",E_META_HOPPER_FACING_YM);
tolua_constant(tolua_S,"E_META_HOPPER_UNATTACHED",E_META_HOPPER_UNATTACHED);
tolua_constant(tolua_S,"E_META_HOPPER_FACING_ZM",E_META_HOPPER_FACING_ZM);
@@ -27555,14 +27651,14 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_constant(tolua_S,"E_META_SILVERFISH_EGG_STONE",E_META_SILVERFISH_EGG_STONE);
tolua_constant(tolua_S,"E_META_SILVERFISH_EGG_COBBLESTONE",E_META_SILVERFISH_EGG_COBBLESTONE);
tolua_constant(tolua_S,"E_META_SILVERFISH_EGG_STONE_BRICK",E_META_SILVERFISH_EGG_STONE_BRICK);
- tolua_constant(tolua_S,"E_META_STEP_STONE",E_META_STEP_STONE);
- tolua_constant(tolua_S,"E_META_STEP_SANDSTONE",E_META_STEP_SANDSTONE);
- tolua_constant(tolua_S,"E_META_STEP_PLANKS",E_META_STEP_PLANKS);
- tolua_constant(tolua_S,"E_META_STEP_COBBLESTONE",E_META_STEP_COBBLESTONE);
- tolua_constant(tolua_S,"E_META_STEP_BRICK",E_META_STEP_BRICK);
- tolua_constant(tolua_S,"E_META_STEP_STONE_BRICK",E_META_STEP_STONE_BRICK);
- tolua_constant(tolua_S,"E_META_STEP_NETHER_BRICK",E_META_STEP_NETHER_BRICK);
- tolua_constant(tolua_S,"E_META_STEP_STONE_SECRET",E_META_STEP_STONE_SECRET);
+ tolua_constant(tolua_S,"E_META_STONE_SLAB_STONE",E_META_STONE_SLAB_STONE);
+ tolua_constant(tolua_S,"E_META_STONE_SLAB_SANDSTONE",E_META_STONE_SLAB_SANDSTONE);
+ tolua_constant(tolua_S,"E_META_STONE_SLAB_PLANKS",E_META_STONE_SLAB_PLANKS);
+ tolua_constant(tolua_S,"E_META_STONE_SLAB_COBBLESTONE",E_META_STONE_SLAB_COBBLESTONE);
+ tolua_constant(tolua_S,"E_META_STONE_SLAB_BRICK",E_META_STONE_SLAB_BRICK);
+ tolua_constant(tolua_S,"E_META_STONE_SLAB_STONE_BRICK",E_META_STONE_SLAB_STONE_BRICK);
+ tolua_constant(tolua_S,"E_META_STONE_SLAB_NETHER_BRICK",E_META_STONE_SLAB_NETHER_BRICK);
+ tolua_constant(tolua_S,"E_META_STONE_SLAB_STONE_SECRET",E_META_STONE_SLAB_STONE_SECRET);
tolua_constant(tolua_S,"E_META_STONE_BRICK_NORMAL",E_META_STONE_BRICK_NORMAL);
tolua_constant(tolua_S,"E_META_STONE_BRICK_MOSSY",E_META_STONE_BRICK_MOSSY);
tolua_constant(tolua_S,"E_META_STONE_BRICK_CRACKED",E_META_STONE_BRICK_CRACKED);
@@ -27579,14 +27675,14 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_constant(tolua_S,"E_META_TORCH_XP",E_META_TORCH_XP);
tolua_constant(tolua_S,"E_META_TORCH_ZM",E_META_TORCH_ZM);
tolua_constant(tolua_S,"E_META_TORCH_ZP",E_META_TORCH_ZP);
- tolua_constant(tolua_S,"E_META_WOODEN_DOUBLE_STEP_APPLE",E_META_WOODEN_DOUBLE_STEP_APPLE);
- tolua_constant(tolua_S,"E_META_WOODEN_DOUBLE_STEP_CONIFER",E_META_WOODEN_DOUBLE_STEP_CONIFER);
- tolua_constant(tolua_S,"E_META_WOODEN_DOUBLE_STEP_BIRCH",E_META_WOODEN_DOUBLE_STEP_BIRCH);
- tolua_constant(tolua_S,"E_META_WOODEN_DOUBLE_STEP_JUNGLE",E_META_WOODEN_DOUBLE_STEP_JUNGLE);
- tolua_constant(tolua_S,"E_META_WOODEN_STEP_APPLE",E_META_WOODEN_STEP_APPLE);
- tolua_constant(tolua_S,"E_META_WOODEN_STEP_CONIFER",E_META_WOODEN_STEP_CONIFER);
- tolua_constant(tolua_S,"E_META_WOODEN_STEP_BIRCH",E_META_WOODEN_STEP_BIRCH);
- tolua_constant(tolua_S,"E_META_WOODEN_STEP_JUNGLE",E_META_WOODEN_STEP_JUNGLE);
+ tolua_constant(tolua_S,"E_META_WOODEN_DOUBLE_SLAB_APPLE",E_META_WOODEN_DOUBLE_SLAB_APPLE);
+ tolua_constant(tolua_S,"E_META_WOODEN_DOUBLE_SLAB_CONIFER",E_META_WOODEN_DOUBLE_SLAB_CONIFER);
+ tolua_constant(tolua_S,"E_META_WOODEN_DOUBLE_SLAB_BIRCH",E_META_WOODEN_DOUBLE_SLAB_BIRCH);
+ tolua_constant(tolua_S,"E_META_WOODEN_DOUBLE_SLAB_JUNGLE",E_META_WOODEN_DOUBLE_SLAB_JUNGLE);
+ tolua_constant(tolua_S,"E_META_WOODEN_SLAB_APPLE",E_META_WOODEN_SLAB_APPLE);
+ tolua_constant(tolua_S,"E_META_WOODEN_SLAB_CONIFER",E_META_WOODEN_SLAB_CONIFER);
+ tolua_constant(tolua_S,"E_META_WOODEN_SLAB_BIRCH",E_META_WOODEN_SLAB_BIRCH);
+ tolua_constant(tolua_S,"E_META_WOODEN_SLAB_JUNGLE",E_META_WOODEN_SLAB_JUNGLE);
tolua_constant(tolua_S,"E_META_WOOL_WHITE",E_META_WOOL_WHITE);
tolua_constant(tolua_S,"E_META_WOOL_ORANGE",E_META_WOOL_ORANGE);
tolua_constant(tolua_S,"E_META_WOOL_MAGENTA",E_META_WOOL_MAGENTA);
@@ -27635,6 +27731,14 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_constant(tolua_S,"E_META_STAINED_CLAY_GREEN",E_META_STAINED_CLAY_GREEN);
tolua_constant(tolua_S,"E_META_STAINED_CLAY_RED",E_META_STAINED_CLAY_RED);
tolua_constant(tolua_S,"E_META_STAINED_CLAY_BLACK",E_META_STAINED_CLAY_BLACK);
+ tolua_constant(tolua_S,"E_META_SNOW_LAYER_ONE",E_META_SNOW_LAYER_ONE);
+ tolua_constant(tolua_S,"E_META_SNOW_LAYER_TWO",E_META_SNOW_LAYER_TWO);
+ tolua_constant(tolua_S,"E_META_SNOW_LAYER_THREE",E_META_SNOW_LAYER_THREE);
+ tolua_constant(tolua_S,"E_META_SNOW_LAYER_FOUR",E_META_SNOW_LAYER_FOUR);
+ tolua_constant(tolua_S,"E_META_SNOW_LAYER_FIVE",E_META_SNOW_LAYER_FIVE);
+ tolua_constant(tolua_S,"E_META_SNOW_LAYER_SIX",E_META_SNOW_LAYER_SIX);
+ tolua_constant(tolua_S,"E_META_SNOW_LAYER_SEVEN",E_META_SNOW_LAYER_SEVEN);
+ tolua_constant(tolua_S,"E_META_SNOW_LAYER_EIGHT",E_META_SNOW_LAYER_EIGHT);
tolua_constant(tolua_S,"E_META_COAL_NORMAL",E_META_COAL_NORMAL);
tolua_constant(tolua_S,"E_META_COAL_CHARCOAL",E_META_COAL_CHARCOAL);
tolua_constant(tolua_S,"E_META_DYE_BLACK",E_META_DYE_BLACK);
@@ -28092,10 +28196,16 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_constant(tolua_S,"pkSplashPotion",cProjectileEntity::pkSplashPotion);
tolua_constant(tolua_S,"pkWitherSkull",cProjectileEntity::pkWitherSkull);
tolua_constant(tolua_S,"pkFishingFloat",cProjectileEntity::pkFishingFloat);
+ tolua_function(tolua_S,"GetProjectileKind",tolua_AllToLua_cProjectileEntity_GetProjectileKind00);
tolua_function(tolua_S,"GetCreator",tolua_AllToLua_cProjectileEntity_GetCreator00);
+ tolua_function(tolua_S,"GetMCAClassName",tolua_AllToLua_cProjectileEntity_GetMCAClassName00);
+ tolua_function(tolua_S,"IsInGround",tolua_AllToLua_cProjectileEntity_IsInGround00);
tolua_endmodule(tolua_S);
tolua_cclass(tolua_S,"cArrowEntity","cArrowEntity","cProjectileEntity",NULL);
tolua_beginmodule(tolua_S,"cArrowEntity");
+ tolua_constant(tolua_S,"psNoPickup",cArrowEntity::psNoPickup);
+ tolua_constant(tolua_S,"psInSurvivalOrCreative",cArrowEntity::psInSurvivalOrCreative);
+ tolua_constant(tolua_S,"psInCreative",cArrowEntity::psInCreative);
tolua_endmodule(tolua_S);
tolua_cclass(tolua_S,"cPluginManager","cPluginManager","",NULL);
tolua_beginmodule(tolua_S,"cPluginManager");
diff --git a/source/Bindings.h b/source/Bindings.h
index edc43c022..8563cfeda 100644
--- a/source/Bindings.h
+++ b/source/Bindings.h
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 08/22/13 08:53:27.
+** Generated automatically by tolua++-1.0.92 on 08/25/13 17:06:07.
*/
/* Exported function */
diff --git a/source/BlockID.h b/source/BlockID.h
index 3c4381ae1..0eb3df96d 100644
--- a/source/BlockID.h
+++ b/source/BlockID.h
@@ -396,15 +396,17 @@ enum
E_META_DROPSPENSER_FACING_XM = 4,
E_META_DROPSPENSER_FACING_XP = 5,
- // E_BLOCK_DOUBLE_STEP metas:
- E_META_DOUBLE_STEP_STONE = 0,
- E_META_DOUBLE_STEP_SANDSTONE = 1,
- E_META_DOUBLE_STEP_WOODEN = 2,
- E_META_DOUBLE_STEP_COBBLESTONE = 3,
- E_META_DOUBLE_STEP_BRICK = 4,
- E_META_DOUBLE_STEP_STONE_BRICK = 5,
- E_META_DOUBLE_STEP_NETHER_BRICK = 6,
- E_META_DOUBLE_STEP_STONE_SECRET = 7,
+ // E_BLOCK_DOUBLE_STONE_SLAB metas:
+ E_META_DOUBLE_STONE_SLAB_STONE = 0,
+ E_META_DOUBLE_STONE_SLAB_SANDSTONE = 1,
+ E_META_DOUBLE_STONE_SLAB_WOODEN = 2,
+ E_META_DOUBLE_STONE_SLAB_COBBLESTONE = 3,
+ E_META_DOUBLE_STONE_SLAB_BRICK = 4,
+ E_META_DOUBLE_STONE_SLAB_STONE_BRICK = 5,
+ E_META_DOUBLE_STONE_SLAB_NETHER_BRICK = 6,
+ E_META_DOUBLE_STONE_SLAB_STONE_SECRET = 7,
+
+
// E_BLOCK_HOPPER metas:
E_META_HOPPER_FACING_YM = 0,
@@ -448,15 +450,15 @@ enum
E_META_SILVERFISH_EGG_COBBLESTONE = 1,
E_META_SILVERFISH_EGG_STONE_BRICK = 2,
- // E_BLOCK_STEP metas:
- E_META_STEP_STONE = 0,
- E_META_STEP_SANDSTONE = 1,
- E_META_STEP_PLANKS = 2,
- E_META_STEP_COBBLESTONE = 3,
- E_META_STEP_BRICK = 4,
- E_META_STEP_STONE_BRICK = 5,
- E_META_STEP_NETHER_BRICK = 6,
- E_META_STEP_STONE_SECRET = 7,
+ // E_BLOCK_STONE_SLAB metas:
+ E_META_STONE_SLAB_STONE = 0,
+ E_META_STONE_SLAB_SANDSTONE = 1,
+ E_META_STONE_SLAB_PLANKS = 2,
+ E_META_STONE_SLAB_COBBLESTONE = 3,
+ E_META_STONE_SLAB_BRICK = 4,
+ E_META_STONE_SLAB_STONE_BRICK = 5,
+ E_META_STONE_SLAB_NETHER_BRICK = 6,
+ E_META_STONE_SLAB_STONE_SECRET = 7,
// E_BLOCK_STONE_BRICKS metas:
E_META_STONE_BRICK_NORMAL = 0,
@@ -480,17 +482,17 @@ enum
E_META_TORCH_ZM = 3, // Torch attached to the ZM side of its block
E_META_TORCH_ZP = 4, // Torch attached to the ZP side of its block
- // E_BLOCK_WOODEN_DOUBLE_STEP metas:
- E_META_WOODEN_DOUBLE_STEP_APPLE = 0,
- E_META_WOODEN_DOUBLE_STEP_CONIFER = 1,
- E_META_WOODEN_DOUBLE_STEP_BIRCH = 2,
- E_META_WOODEN_DOUBLE_STEP_JUNGLE = 3,
+ // E_BLOCK_WOODEN_DOUBLE_SLAB metas:
+ E_META_WOODEN_DOUBLE_SLAB_APPLE = 0,
+ E_META_WOODEN_DOUBLE_SLAB_CONIFER = 1,
+ E_META_WOODEN_DOUBLE_SLAB_BIRCH = 2,
+ E_META_WOODEN_DOUBLE_SLAB_JUNGLE = 3,
- // E_BLOCK_WOODEN_STEP metas:
- E_META_WOODEN_STEP_APPLE = 0,
- E_META_WOODEN_STEP_CONIFER = 1,
- E_META_WOODEN_STEP_BIRCH = 2,
- E_META_WOODEN_STEP_JUNGLE = 3,
+ // E_BLOCK_WOODEN_SLAB metas:
+ E_META_WOODEN_SLAB_APPLE = 0,
+ E_META_WOODEN_SLAB_CONIFER = 1,
+ E_META_WOODEN_SLAB_BIRCH = 2,
+ E_META_WOODEN_SLAB_JUNGLE = 3,
// E_BLOCK_WOOL metas:
E_META_WOOL_WHITE = 0,
@@ -545,7 +547,17 @@ enum
E_META_STAINED_CLAY_GREEN = 13,
E_META_STAINED_CLAY_RED = 14,
E_META_STAINED_CLAY_BLACK = 15,
-
+
+ // E_BLOCK_SNOW metas:
+ E_META_SNOW_LAYER_ONE = 0,
+ E_META_SNOW_LAYER_TWO = 1,
+ E_META_SNOW_LAYER_THREE = 2,
+ E_META_SNOW_LAYER_FOUR = 3,
+ E_META_SNOW_LAYER_FIVE = 4,
+ E_META_SNOW_LAYER_SIX = 5,
+ E_META_SNOW_LAYER_SEVEN = 6,
+ E_META_SNOW_LAYER_EIGHT = 7,
+
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Item metas:
diff --git a/source/Blocks/BlockCarpet.h b/source/Blocks/BlockCarpet.h
index f70ff45b6..5eafd8c21 100644
--- a/source/Blocks/BlockCarpet.h
+++ b/source/Blocks/BlockCarpet.h
@@ -8,6 +8,8 @@
#pragma once
+#include "BlockHandler.h"
+
@@ -16,7 +18,11 @@ class cBlockCarpetHandler :
public cBlockHandler
{
public:
- cBlockCarpetHandler(BLOCKTYPE a_BlockType);
+ cBlockCarpetHandler(BLOCKTYPE a_BlockType) :
+ cBlockHandler(a_BlockType)
+ {
+ }
+
virtual const char * GetStepSound(void) override
{
@@ -39,13 +45,13 @@ public:
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
- a_Pickups.push_back(cItem(E_BLOCK_CARPET, a_BlockMeta));
+ a_Pickups.push_back(cItem(E_BLOCK_CARPET, 1, a_BlockMeta));
}
virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
- return ((a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) != E_BLOCK_AIR));
+ return (a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) != E_BLOCK_AIR);
}
} ;
diff --git a/source/Blocks/BlockDoor.cpp b/source/Blocks/BlockDoor.cpp
index 267486c47..02cbd28e2 100644
--- a/source/Blocks/BlockDoor.cpp
+++ b/source/Blocks/BlockDoor.cpp
@@ -47,7 +47,10 @@ void cBlockDoorHandler::OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY
void cBlockDoorHandler::OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
{
- cDoors::ChangeDoor(a_World, a_BlockX, a_BlockY, a_BlockZ);
+ if (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_WOODEN_DOOR)
+ {
+ cDoors::ChangeDoor(a_World, a_BlockX, a_BlockY, a_BlockZ);
+ }
}
diff --git a/source/Blocks/BlockHandler.cpp b/source/Blocks/BlockHandler.cpp
index 6584eeed4..5134c1103 100644
--- a/source/Blocks/BlockHandler.cpp
+++ b/source/Blocks/BlockHandler.cpp
@@ -104,6 +104,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_BROWN_MUSHROOM: return new cBlockMushroomHandler (a_BlockType);
case E_BLOCK_CACTUS: return new cBlockCactusHandler (a_BlockType);
case E_BLOCK_CARROTS: return new cBlockCropsHandler (a_BlockType);
+ case E_BLOCK_CARPET: return new cBlockCarpetHandler (a_BlockType);
case E_BLOCK_CAULDRON: return new cBlockCauldronHandler (a_BlockType);
case E_BLOCK_CHEST: return new cBlockChestHandler (a_BlockType);
case E_BLOCK_COAL_ORE: return new cBlockOreHandler (a_BlockType);
@@ -116,8 +117,8 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_DIAMOND_ORE: return new cBlockOreHandler (a_BlockType);
case E_BLOCK_DIRT: return new cBlockDirtHandler (a_BlockType);
case E_BLOCK_DISPENSER: return new cBlockDropSpenserHandler (a_BlockType);
- case E_BLOCK_DOUBLE_STONE_SLAB: return new cBlockSlabHandler (a_BlockType);
- case E_BLOCK_DOUBLE_WOODEN_SLAB: return new cBlockSlabHandler (a_BlockType);
+ case E_BLOCK_DOUBLE_STONE_SLAB: return new cBlockDoubleSlabHandler (a_BlockType);
+ case E_BLOCK_DOUBLE_WOODEN_SLAB: return new cBlockDoubleSlabHandler (a_BlockType);
case E_BLOCK_DROPPER: return new cBlockDropSpenserHandler (a_BlockType);
case E_BLOCK_EMERALD_ORE: return new cBlockOreHandler (a_BlockType);
case E_BLOCK_ENDER_CHEST: return new cBlockEnderchestHandler (a_BlockType);
diff --git a/source/Blocks/BlockSlab.h b/source/Blocks/BlockSlab.h
index f34f42bae..7c1251b28 100644
--- a/source/Blocks/BlockSlab.h
+++ b/source/Blocks/BlockSlab.h
@@ -1,7 +1,16 @@
+// BlockSlab.h
+
+// Declares cBlockSlabHandler and cBlockDoubleSlabHandler classes
+
+
+
+
+
#pragma once
#include "BlockHandler.h"
+#include "../Items/ItemHandler.h"
@@ -19,8 +28,7 @@ public:
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
- char Count = ((m_BlockType == E_BLOCK_DOUBLE_STONE_SLAB) || (m_BlockType == E_BLOCK_DOUBLE_WOODEN_SLAB)) ? 2 : 1;
- a_Pickups.push_back(cItem(m_BlockType, Count, a_BlockMeta));
+ a_Pickups.push_back(cItem(m_BlockType, 1, a_BlockMeta));
}
@@ -32,11 +40,55 @@ public:
) override
{
a_BlockType = m_BlockType;
+ BLOCKTYPE Type = (BLOCKTYPE) (a_Player->GetEquippedItem().m_ItemType);
NIBBLETYPE Meta = (NIBBLETYPE)(a_Player->GetEquippedItem().m_ItemDamage & 0x07);
+
+ // HandlePlaceBlock wants a cItemHandler pointer thing, so let's give it one
+ cItemHandler * ItemHandler = cItemHandler::GetItemHandler(GetDoubleSlabType(Type));
+
+ // Check if the block at the coordinates is a slab. Eligibility for combining has already been processed in ClientHandle
+ if (IsAnySlabType(a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ)))
+ {
+ // Call the function in ClientHandle that places a block when the client sends the packet,
+ // so that plugins may interfere with the placement.
+
+ if ((a_BlockFace == BLOCK_FACE_TOP) || (a_BlockFace == BLOCK_FACE_BOTTOM))
+ {
+ // Top and bottom faces need no parameter modification
+ a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler);
+ }
+ else
+ {
+ // The other faces need to distinguish between top and bottom cursor positions
+ if (a_CursorY > 7)
+ {
+ // Edit the call to use BLOCK_FACE_BOTTOM, otherwise it places incorrectly
+ a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_TOP, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler);
+ }
+ else
+ {
+ // Edit the call to use BLOCK_FACE_TOP, otherwise it places incorrectly
+ a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_BOTTOM, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler);
+ }
+ }
+ return false; // Cancel the event, because dblslabs were already placed, nothing else needed
+ }
+
+ // Place the single-slab with correct metas:
switch (a_BlockFace)
{
- case BLOCK_FACE_TOP: a_BlockMeta = Meta & 0x7; break; // Always bottom half of the slab when placing on top of something
- case BLOCK_FACE_BOTTOM: a_BlockMeta = Meta | 0x8; break; // Always top half of the slab when placing on bottom of something
+ case BLOCK_FACE_TOP:
+ {
+ // Bottom half slab block
+ a_BlockMeta = Meta & 0x7;
+ break;
+ }
+ case BLOCK_FACE_BOTTOM:
+ {
+ // Top half slab block
+ a_BlockMeta = Meta | 0x8;
+ break;
+ }
case BLOCK_FACE_EAST:
case BLOCK_FACE_NORTH:
case BLOCK_FACE_SOUTH:
@@ -44,15 +96,14 @@ public:
{
if (a_CursorY > 7)
{
- // Cursor at the top half of the face, place a top half of slab
- a_BlockMeta = Meta | 0x8;
+ // Cursor at top half of block, place top slab
+ a_BlockMeta = Meta | 0x8; break;
}
else
{
- // Cursor at the bottom half of the face, place a bottom half of slab:
- a_BlockMeta = Meta & 0x7;
+ // Cursor at bottom half of block, place bottom slab
+ a_BlockMeta = Meta & 0x7; break;
}
- break;
}
} // switch (a_BlockFace)
return true;
@@ -60,8 +111,69 @@ public:
virtual const char * GetStepSound(void) override
+ {
+ switch (m_BlockType)
+ {
+ case E_BLOCK_WOODEN_SLAB: return "step.wood";
+ case E_BLOCK_STONE_SLAB: return "step.stone";
+ }
+ ASSERT(!"Unhandled slab type!");
+ return "";
+ }
+
+
+ /// Returns true if the specified blocktype is one of the slabs handled by this handler
+ static bool IsAnySlabType(BLOCKTYPE a_BlockType)
+ {
+ return ((a_BlockType == E_BLOCK_WOODEN_SLAB) || (a_BlockType == E_BLOCK_STONE_SLAB));
+ }
+
+
+ /// Converts the single-slab blocktype to its equivalent double-slab blocktype
+ static BLOCKTYPE GetDoubleSlabType(BLOCKTYPE a_SingleSlabBlockType)
+ {
+ switch (a_SingleSlabBlockType)
+ {
+ case E_BLOCK_STONE_SLAB: return E_BLOCK_DOUBLE_STONE_SLAB;
+ case E_BLOCK_WOODEN_SLAB: return E_BLOCK_DOUBLE_WOODEN_SLAB;
+ }
+ ASSERT(!"Unhandled slab type!");
+ return E_BLOCK_AIR;
+ }
+
+} ;
+
+
+
+
+
+class cBlockDoubleSlabHandler :
+ public cBlockHandler
+{
+public:
+ cBlockDoubleSlabHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ if (m_BlockType == E_BLOCK_DOUBLE_STONE_SLAB)
+ {
+ m_BlockType = E_BLOCK_STONE_SLAB;
+ }
+ else
+ {
+ m_BlockType = E_BLOCK_WOODEN_SLAB;
+ }
+ a_Pickups.push_back(cItem(m_BlockType, 2, a_BlockMeta));
+ }
+
+
+ virtual const char * GetStepSound(void) override
{
- return ((m_BlockType == E_BLOCK_WOODEN_SLAB) || (m_BlockType == E_BLOCK_DOUBLE_WOODEN_SLAB)) ? "step.wood" : "step.stone";
+ return ((m_BlockType == E_BLOCK_DOUBLE_WOODEN_SLAB) || (m_BlockType == E_BLOCK_DOUBLE_WOODEN_SLAB)) ? "step.wood" : "step.stone";
}
} ;
diff --git a/source/Blocks/BlockVine.h b/source/Blocks/BlockVine.h
index 0bc935272..37d9f1a45 100644
--- a/source/Blocks/BlockVine.h
+++ b/source/Blocks/BlockVine.h
@@ -168,6 +168,13 @@ public:
return false;
}
+ virtual void OnUpdate(cWorld * a_World, int X, int Y, int Z)
+ {
+ if (a_World->GetBlock(X, Y - 1, Z) == E_BLOCK_AIR)
+ {
+ a_World->SetBlock(X, Y - 1, Z, E_BLOCK_VINES, a_World->GetBlockMeta(X, Y, Z));
+ }
+ }
virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override
{
diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp
index ed76ee086..bed9fab92 100644
--- a/source/ClientHandle.cpp
+++ b/source/ClientHandle.cpp
@@ -19,6 +19,7 @@
#include "OSSupport/Timer.h"
#include "Items/ItemHandler.h"
#include "Blocks/BlockHandler.h"
+#include "Blocks/BlockSlab.h"
#include "Vector3f.h"
#include "Vector3d.h"
@@ -850,36 +851,82 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, c
}
cWorld * World = m_Player->GetWorld();
+
+ BLOCKTYPE ClickedBlock;
+ NIBBLETYPE ClickedBlockMeta;
+ BLOCKTYPE EquippedBlock = (BLOCKTYPE)(m_Player->GetEquippedItem().m_ItemType);
+ NIBBLETYPE EquippedBlockDamage = (NIBBLETYPE)(m_Player->GetEquippedItem().m_ItemDamage);
+
+ if ((a_BlockY < 0) || (a_BlockY >= cChunkDef::Height))
+ {
+ // The block is being placed outside the world, ignore this packet altogether (#128)
+ return;
+ }
- // Check if the block ignores build collision (water, grass etc.):
- BLOCKTYPE ClickedBlock = World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
- cBlockHandler * Handler = cBlockHandler::GetBlockHandler(ClickedBlock);
- if (Handler->DoesIgnoreBuildCollision())
+ World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, ClickedBlock, ClickedBlockMeta);
+
+ // Special slab handling - placing a slab onto another slab produces a dblslab instead:
+ if (
+ cBlockSlabHandler::IsAnySlabType(ClickedBlock) && // Is there a slab already?
+ cBlockSlabHandler::IsAnySlabType(EquippedBlock) && // Is the player placing another slab?
+ ((ClickedBlockMeta & 0x07) == (EquippedBlockDamage & 0x07)) && // Is it the same slab type?
+ (
+ (a_BlockFace == BLOCK_FACE_TOP) || // Clicking the top of a bottom slab
+ (a_BlockFace == BLOCK_FACE_BOTTOM) // Clicking the bottom of a top slab
+ )
+ )
{
- Handler->OnDestroyedByPlayer(World, m_Player, a_BlockX, a_BlockY, a_BlockZ);
- // World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
+ // Coordinates at CLICKED block, don't move them anywhere
}
else
{
- AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
- // Check for Blocks not allowing placement on top
- if ((a_BlockFace == BLOCK_FACE_TOP) && !Handler->DoesAllowBlockOnTop())
+ // Check if the block ignores build collision (water, grass etc.):
+ cBlockHandler * Handler = cBlockHandler::GetBlockHandler(ClickedBlock);
+ if (Handler->DoesIgnoreBuildCollision())
{
- // Resend the old block
- // Some times the client still places the block O.o
- World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player);
- return;
+ Handler->OnDestroyedByPlayer(World, m_Player, a_BlockX, a_BlockY, a_BlockZ);
}
-
BLOCKTYPE PlaceBlock = World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
if (!BlockHandler(PlaceBlock)->DoesIgnoreBuildCollision())
{
- // Tried to place a block *into* another?
- return; // Happens when you place a block aiming at side of block like torch or stem
+ AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
+
+ if ((a_BlockY < 0) || (a_BlockY >= cChunkDef::Height))
+ {
+ // The block is being placed outside the world, ignore this packet altogether (#128)
+ return;
+ }
+
+ BLOCKTYPE PlaceBlock = World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
+
+ // Clicked on side of block, make sure that placement won't be cancelled if there is a slab able to be double slabbed.
+ // No need to do combinability (dblslab) checks, client will do that here.
+ if (cBlockSlabHandler::IsAnySlabType(PlaceBlock))
+ {
+ // It's a slab, don't do checks and proceed to double-slabbing
+ }
+ else
+ {
+ // Check for Blocks not allowing placement on top
+ if ((a_BlockFace == BLOCK_FACE_TOP) && !Handler->DoesAllowBlockOnTop())
+ {
+ // Resend the old block
+ // Sometimes the client still places the block O.o
+ World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player);
+ return;
+ }
+
+ if (!BlockHandler(PlaceBlock)->DoesIgnoreBuildCollision())
+ {
+ // Tried to place a block *into* another?
+ // Happens when you place a block aiming at side of block like torch or stem
+ return;
+ }
+ }
}
}
-
+
BLOCKTYPE BlockType;
NIBBLETYPE BlockMeta;
if (!a_ItemHandler.GetPlacementBlockTypeMeta(World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta))
@@ -914,7 +961,7 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, c
NewBlock->OnPlacedByPlayer(World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta);
// Step sound with 0.8f pitch is used as block placement sound
- World->BroadcastSoundEffect(NewBlock->GetStepSound(),a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 1.0f, 0.8f);
+ World->BroadcastSoundEffect(NewBlock->GetStepSound(), a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 1.0f, 0.8f);
cRoot::Get()->GetPluginManager()->CallHookPlayerPlacedBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta);
}
diff --git a/source/ClientHandle.h b/source/ClientHandle.h
index 62616ba08..9fae93d95 100644
--- a/source/ClientHandle.h
+++ b/source/ClientHandle.h
@@ -198,6 +198,9 @@ public:
/// Called when the player moves into a different world; queues sreaming the new chunks
void MoveToWorld(cWorld & a_World, bool a_SendRespawnPacket);
+ /// Handles the block placing packet when it is a real block placement (not block-using, item-using or eating)
+ void HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, cItemHandler & a_ItemHandler);
+
private:
int m_ViewDistance; // Number of chunks the player can see in each direction; 4 is the minimum ( http://wiki.vg/Protocol_FAQ#.E2.80.A6all_connecting_clients_spasm_and_jerk_uncontrollably.21 )
@@ -314,9 +317,6 @@ private:
/// Handles the DIG_FINISHED dig packet:
void HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta);
-
- /// Handles the block placing packet when it is a real block placement (not block-using, item-using or eating)
- void HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, cItemHandler & a_ItemHandler);
// cSocketThreads::cCallback overrides:
virtual void DataReceived (const char * a_Data, int a_Size) override; // Data is received from the client
diff --git a/source/Entities/Pickup.cpp b/source/Entities/Pickup.cpp
index 0417b861d..c8f36d503 100644
--- a/source/Entities/Pickup.cpp
+++ b/source/Entities/Pickup.cpp
@@ -73,18 +73,19 @@ void cPickup::Tick(float a_Dt, cChunk & a_Chunk)
if (!m_bCollected)
{
int BlockY = (int) floor(GetPosY());
- if (BlockY < cChunkDef::Height) // Don't do anything except for falling when above the world
+ if ((BlockY >= 0) && (BlockY < cChunkDef::Height)) // Don't do anything except for falling when outside the world
{
int BlockX = (int) floor(GetPosX());
int BlockZ = (int) floor(GetPosZ());
- //Position might have changed due to physics. So we have to make sure we have the correct chunk.
+ // Position might have changed due to physics. So we have to make sure we have the correct chunk.
cChunk * CurrentChunk = a_Chunk.GetNeighborChunk(BlockX, BlockZ);
if (CurrentChunk != NULL) // Make sure the chunk is loaded
{
int RelBlockX = BlockX - (CurrentChunk->GetPosX() * cChunkDef::Width);
int RelBlockZ = BlockZ - (CurrentChunk->GetPosZ() * cChunkDef::Width);
- BLOCKTYPE BlockBelow = CurrentChunk->GetBlock(RelBlockX, BlockY - 1, RelBlockZ);
+ // If the pickup is on the bottommost block position, make it think the void is made of air: (#131)
+ BLOCKTYPE BlockBelow = (BlockY > 0) ? CurrentChunk->GetBlock(RelBlockX, BlockY - 1, RelBlockZ) : E_BLOCK_AIR;
BLOCKTYPE BlockIn = CurrentChunk->GetBlock(RelBlockX, BlockY, RelBlockZ);
if (
diff --git a/source/Items/ItemLighter.h b/source/Items/ItemLighter.h
index 39534c7b1..4281a2d0c 100644
--- a/source/Items/ItemLighter.h
+++ b/source/Items/ItemLighter.h
@@ -40,10 +40,13 @@ public:
}
default:
{
- // Light a fire next to the block:
+ // Light a fire next to/on top of the block if air:
AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
- a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_FIRE, 0);
- break;
+ if (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_AIR)
+ {
+ a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_FIRE, 0);
+ break;
+ }
}
}
diff --git a/source/LeakFinder.cpp b/source/LeakFinder.cpp
index 3242bba04..272e313a0 100644
--- a/source/LeakFinder.cpp
+++ b/source/LeakFinder.cpp
@@ -116,12 +116,15 @@
/* _X: MSVC 2012 (MSC 1700) seems to use a different allocation scheme for STL containers,
* allocating lots of small objects and running out of memory very soon
* Thus for MSVC 2012 we cut the callstack buffer length in half
+*
+* _X 2013_08_25: The callstack tracking gets worse even for MSVC 2008, a single lua_state eats 50 MiB of RAM
+* Therefore I decided to further reduce the buffers from 0x2000 to 0x1000
*/
// Controlling the callstack depth
#if (_MSC_VER < 1700)
- #define MAX_CALLSTACK_LEN_BUF 0x2000
-#else
#define MAX_CALLSTACK_LEN_BUF 0x1000
+#else
+ #define MAX_CALLSTACK_LEN_BUF 0x0800
#endif
@@ -942,10 +945,10 @@ static int MyAllocHook(int nAllocType, void *pvData,
g_CurrentMemUsage += nSize ;
g_pCRTTable->Insert(lRequest, c, nSize);
- if (g_CurrentMemUsage > 1073741824) //This is 1 gb = 1024 * 1024* 1024.
+ if (g_CurrentMemUsage > 1536 * 1024* 1024)
{
printf("******************************************\n");
- printf("** Server reached 1 GiB memory usage, **\n");
+ printf("** Server reached 1.5 GiB memory usage, **\n");
printf("** something is probably wrong. **\n");
printf("** Writing memory dump into memdump.xml **\n");
printf("******************************************\n");
diff --git a/source/Plugin.h b/source/Plugin.h
index 6e3e5f1d2..be803bab2 100644
--- a/source/Plugin.h
+++ b/source/Plugin.h
@@ -113,13 +113,6 @@ public:
/// All bound console commands are to be removed, do any language-dependent cleanup here
virtual void ClearConsoleCommands(void) {} ;
- /** Called from cPluginManager::AddHook() to check if the hook can be added.
- Plugin API providers may check if the plugin is written correctly (has the hook handler function)
- Returns true if the hook can be added (handler exists)
- Descendants should also log the specific error message as a warning if they return false.
- */
- virtual bool CanAddHook(int a_Hook) = 0;
-
// tolua_begin
const AString & GetName(void) const { return m_Name; }
void SetName(const AString & a_Name) { m_Name = a_Name; }
diff --git a/source/PluginLua.cpp b/source/PluginLua.cpp
index 1c8cbef47..81a536838 100644
--- a/source/PluginLua.cpp
+++ b/source/PluginLua.cpp
@@ -1240,13 +1240,16 @@ void cPluginLua::ClearConsoleCommands(void)
-bool cPluginLua::CanAddHook(int a_Hook)
+bool cPluginLua::CanAddOldStyleHook(int a_HookType)
{
- const char * FnName = GetHookFnName(a_Hook);
+ const char * FnName = GetHookFnName(a_HookType);
if (FnName == NULL)
{
// Unknown hook ID
- LOGWARNING("Plugin %s wants to add an unknown hook ID (%d). The plugin need not work properly.", GetName().c_str(), a_Hook);
+ LOGWARNING("Plugin %s wants to add an unknown hook ID (%d). The plugin need not work properly.",
+ GetName().c_str(), a_HookType
+ );
+ m_LuaState.LogStackTrace();
return false;
}
@@ -1257,12 +1260,9 @@ bool cPluginLua::CanAddHook(int a_Hook)
}
LOGWARNING("Plugin %s wants to add a hook (%d), but it doesn't provide the callback function \"%s\" for it. The plugin need not work properly.",
- GetName().c_str(), a_Hook, FnName
+ GetName().c_str(), a_HookType, FnName
);
-
- // Lua stacktrace:
m_LuaState.LogStackTrace();
-
return false;
}
@@ -1270,9 +1270,9 @@ bool cPluginLua::CanAddHook(int a_Hook)
-const char * cPluginLua::GetHookFnName(int a_Hook)
+const char * cPluginLua::GetHookFnName(int a_HookType)
{
- switch (a_Hook)
+ switch (a_HookType)
{
case cPluginManager::HOOK_BLOCK_TO_PICKUPS: return "OnBlockToPickups";
case cPluginManager::HOOK_CHAT: return "OnChat";
@@ -1331,7 +1331,17 @@ bool cPluginLua::AddHookRef(int a_HookType, int a_FnRefIdx)
{
ASSERT(m_CriticalSection.IsLockedByCurrentThread()); // It probably has to be, how else would we have a LuaState?
- m_HookMap[a_HookType].push_back(new cLuaState::cRef(m_LuaState, a_FnRefIdx));
+ // Check if the function reference is valid:
+ cLuaState::cRef * Ref = new cLuaState::cRef(m_LuaState, a_FnRefIdx);
+ if ((Ref == NULL) || !Ref->IsValid())
+ {
+ LOGWARNING("Plugin %s tried to add a hook %d with bad handler function.", GetName().c_str(), a_HookType);
+ m_LuaState.LogStackTrace();
+ delete Ref;
+ return false;
+ }
+
+ m_HookMap[a_HookType].push_back(Ref);
return true;
}
diff --git a/source/PluginLua.h b/source/PluginLua.h
index 877de2274..fee9c4986 100644
--- a/source/PluginLua.h
+++ b/source/PluginLua.h
@@ -100,7 +100,8 @@ public:
virtual void ClearConsoleCommands(void) override;
- virtual bool CanAddHook(int a_Hook) override;
+ /// Returns true if the plugin contains the function for the specified hook type, using the old-style registration (#121)
+ bool CanAddOldStyleHook(int a_HookType);
// cWebPlugin override
virtual const AString GetWebTitle(void) const {return GetName(); }
diff --git a/source/PluginManager.cpp b/source/PluginManager.cpp
index a2726bd58..93ee71926 100644
--- a/source/PluginManager.cpp
+++ b/source/PluginManager.cpp
@@ -1619,10 +1619,6 @@ void cPluginManager::AddHook(cPlugin * a_Plugin, int a_Hook)
LOGWARN("Called cPluginManager::AddHook() with a_Plugin == NULL");
return;
}
- if (!a_Plugin->CanAddHook(a_Hook))
- {
- return;
- }
PluginList & Plugins = m_Hooks[a_Hook];
Plugins.remove(a_Plugin);
Plugins.push_back(a_Plugin);
diff --git a/source/Simulator/RedstoneSimulator.cpp b/source/Simulator/RedstoneSimulator.cpp
index 615e36a49..8526a888e 100644
--- a/source/Simulator/RedstoneSimulator.cpp
+++ b/source/Simulator/RedstoneSimulator.cpp
@@ -53,6 +53,10 @@ void cRedstoneSimulator::WakeUp(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk
}
switch (BlockType)
{
+ case E_BLOCK_PISTON:
+ case E_BLOCK_STICKY_PISTON:
+ case E_BLOCK_DISPENSER:
+ case E_BLOCK_DROPPER:
case E_BLOCK_REDSTONE_LAMP_OFF:
case E_BLOCK_REDSTONE_LAMP_ON:
case E_BLOCK_REDSTONE_REPEATER_OFF:
@@ -514,6 +518,20 @@ bool cRedstoneSimulator::PowerBlock(const Vector3i & a_BlockPos, const Vector3i
break;
}
+ case E_BLOCK_REDSTONE_LAMP_OFF:
+ {
+ m_World.FastSetBlock(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, E_BLOCK_REDSTONE_LAMP_ON, 0);
+ break;
+ }
+
+ case E_BLOCK_TNT:
+ {
+ m_World.BroadcastSoundEffect("random.fuse", a_BlockPos.x * 8, a_BlockPos.y * 8, a_BlockPos.z * 8, 0.5f, 0.6f);
+ m_World.SpawnPrimedTNT(a_BlockPos.x + 0.5, a_BlockPos.y + 0.5, a_BlockPos.z + 0.5, 4); // 4 seconds to boom
+ m_World.SetBlock(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, E_BLOCK_AIR, 0);
+ break;
+ }
+
default:
{
if (
@@ -614,6 +632,12 @@ int cRedstoneSimulator::UnPowerBlock(const Vector3i & a_BlockPos, const Vector3i
}
break;
}
+
+ case E_BLOCK_REDSTONE_LAMP_ON:
+ {
+ m_World.FastSetBlock(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, E_BLOCK_REDSTONE_LAMP_OFF, 0);
+ break;
+ }
default:
{
diff --git a/source/StringUtils.cpp b/source/StringUtils.cpp
index 403b10a7c..cb91a4da7 100644
--- a/source/StringUtils.cpp
+++ b/source/StringUtils.cpp
@@ -350,6 +350,33 @@ AString & RawBEToUTF8(short * a_RawData, int a_NumShorts, AString & a_UTF8)
// UTF-8 conversion code adapted from:
// http://stackoverflow.com/questions/2867123/convert-utf-16-to-utf-8-under-windows-and-linux-in-c
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Begin of Unicode, Inc.'s code / information
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+/*
+Notice from the original file:
+* Copyright 2001-2004 Unicode, Inc.
+*
+* Disclaimer
+*
+* This source code is provided as is by Unicode, Inc. No claims are
+* made as to fitness for any particular purpose. No warranties of any
+* kind are expressed or implied. The recipient agrees to determine
+* applicability of information provided. If this file has been
+* purchased on magnetic or optical media from Unicode, Inc., the
+* sole remedy for any claim will be exchange of defective media
+* within 90 days of receipt.
+*
+* Limitations on Rights to Redistribute This Code
+*
+* Unicode, Inc. hereby grants the right to freely use the information
+* supplied in this file in the creation of products supporting the
+* Unicode Standard, and to make copies of this file in any form
+* for internal or external distribution as long as this notice
+* remains attached.
+*/
+
#define UNI_MAX_BMP 0x0000FFFF
#define UNI_MAX_UTF16 0x0010FFFF
#define UNI_MAX_UTF32 0x7FFFFFFF
@@ -505,18 +532,24 @@ AString & UTF8ToRawBEUTF16(const char * a_UTF8, size_t a_UTF8Length, AString & a
} while (tmpBytesToRead > 0);
}
- --------------------------------------------------------------------- */
-
+ ---------------------------------------------------------------------
+*/
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// End of Unicode, Inc.'s code / information
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-/*
+
+
+
+#define HEX(x) ((x) > 9 ? (x) + 'A' - 10 : (x) + '0')
+
+/**
format binary data this way:
00001234: 31 32 33 34 35 36 37 38 39 30 61 62 63 64 65 66 1234567890abcdef
*/
-#define HEX(x) ((x) > 9 ? (x) + 'A' - 10 : (x) + '0')
-
AString & CreateHexDump(AString & a_Out, const void * a_Data, int a_Size, int a_LineLength)
{
ASSERT(a_LineLength <= 120); // Due to using a fixed size line buffer; increase line[]'s size to lift this max
diff --git a/source/Tracer.cpp b/source/Tracer.cpp
index 6d37f2ed8..42f1ae5dd 100644
--- a/source/Tracer.cpp
+++ b/source/Tracer.cpp
@@ -133,9 +133,9 @@ void cTracer::SetValues(const Vector3f & a_Start, const Vector3f & a_Direction)
int cTracer::Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int a_Distance)
{
- if (a_Start.y < 0)
+ if ((a_Start.y < 0) || (a_Start.y >= cChunkDef::Height))
{
- LOGD("%s: Start is below the world", __FUNCTION__);
+ LOGD("%s: Start Y is outside the world (%.2f), not tracing.", __FUNCTION__, a_Start.y);
return 0;
}
diff --git a/source/World.cpp b/source/World.cpp
index 75e2d5fd1..ab783d7a7 100644
--- a/source/World.cpp
+++ b/source/World.cpp
@@ -2204,15 +2204,12 @@ cPlayer * cWorld::FindClosestPlayer(const Vector3f & a_Pos, float a_SightLimit)
Vector3f Pos = (*itr)->GetPosition();
float Distance = (Pos - a_Pos).Length();
- if (Distance <= a_SightLimit)
+ if (Distance < ClosestDistance)
{
if (!LineOfSight.Trace(a_Pos,(Pos - a_Pos),(int)(Pos - a_Pos).Length()))
{
- if (Distance < ClosestDistance)
- {
- ClosestDistance = Distance;
- ClosestPlayer = *itr;
- }
+ ClosestDistance = Distance;
+ ClosestPlayer = *itr;
}
}
}