summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CONTRIBUTING.md38
-rw-r--r--MCServer/Plugins/APIDump/APIDesc.lua4
-rw-r--r--src/Bindings/ManualBindings.cpp64
-rw-r--r--src/BlockArea.cpp12
-rw-r--r--src/BlockArea.h57
-rw-r--r--src/BlockID.cpp4
-rw-r--r--src/BlockID.h10
-rw-r--r--src/Blocks/BlockBed.cpp25
-rw-r--r--src/Blocks/BlockCauldron.h24
-rw-r--r--src/Blocks/BlockHandler.cpp4
-rw-r--r--src/Blocks/BlockLeaves.h2
-rw-r--r--src/Blocks/BlockNewLeaves.h42
-rw-r--r--src/Chunk.cpp7
-rw-r--r--src/Chunk.h1
-rw-r--r--src/ChunkDef.h1
-rw-r--r--src/ChunkMap.cpp4
-rw-r--r--src/ClientHandle.cpp97
-rw-r--r--src/ClientHandle.h72
-rw-r--r--src/Generating/Trees.cpp18
-rw-r--r--src/Generating/Trees.h6
-rw-r--r--src/LightingThread.h6
-rw-r--r--src/Mobs/Wolf.cpp44
-rw-r--r--src/OSSupport/Queue.h6
-rw-r--r--src/Server.cpp4
-rw-r--r--src/Simulator/FireSimulator.cpp1
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator.cpp35
-rw-r--r--src/Simulator/SandSimulator.cpp2
-rw-r--r--src/World.cpp10
-rw-r--r--src/main.cpp4
29 files changed, 462 insertions, 142 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 83173a6af..a0a332f30 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,35 +1,39 @@
Code Stuff
----------
- * Because some devs use MSVC2008, we use C++03 - no C++11 magic for now at least :(
+ * We use C++03
* Use the provided wrappers for OS stuff:
- - Threading is done by inheriting from cIsThread, thread synchronization through cCriticalSection, cSemaphore and cEvent, file access and filesystem operations through the cFile class, high-precision timers through cTimer, high-precision sleep through cSleep
+ - Threading is done by inheriting from `cIsThread`, thread synchronization through `cCriticalSection`, `cSemaphore` and `cEvent`, file access and filesystem operations through the `cFile` class, high-precision timers through `cTimer`, high-precision sleep through `cSleep`
* No magic numbers, use named constants:
- - E_ITEM_XXX, E_BLOCK_XXX and E_META_XXX for items and blocks
- - E_ENTITY_TYPE_XXX for mob types
- - dimNether, dimOverworld and dimEnd for world dimension
- - gmSurvival, gmCreative, gmAdventure for game modes
- - wSunny, wRain, wThunderstorm for weather
- - cChunkDef::Width, cChunkDef::Height for chunk dimensions (C++)
+ - `E_ITEM_XXX`, `E_BLOCK_XXX` and `E_META_XXX` for items and blocks
+ - `cEntity::etXXX` for entity types, `cMonster::mtXXX` for mob types
+ - `dimNether`, `dimOverworld` and `dimEnd` for world dimension
+ - `gmSurvival`, `gmCreative`, `gmAdventure` for game modes
+ - `wSunny`, `wRain`, `wThunderstorm` for weather
+ - `cChunkDef::Width`, `cChunkDef::Height` for chunk dimensions (C++)
- etc.
- * Instead of checking for specific value, use Is functions, if available:
- - cPlayer:IsGameModeCreative() instead of (cPlayer:GetGameMode() == gmCreative)
- * Please use tabs for indentation and spaces for alignment. This means that if it's at line start, it's a tab; if it's in the middle of a line, it's a space
+ * Instead of checking for a specific value, use an `IsXXX` function, if available:
+ - `cPlayer:IsGameModeCreative()` instead of` (cPlayer:GetGameMode() == gmCreative)` (the player can also inherit the gamemode from the world, which the value-d condition doesn't catch)
+ * Please use **tabs for indentation and spaces for alignment**. This means that if it's at line start, it's a tab; if it's in the middle of a line, it's a space
* Alpha-sort stuff that makes sense alpha-sorting - long lists of similar items etc.
* Keep individual functions spaced out by 5 empty lines, this enhances readability and makes navigation in the source file easier.
* Add those extra parentheses to conditions, especially in C++
- - "if ((a == 1) && ((b == 2) || (c == 3)))" instead of ambiguous "if (a == 1 && b == 2 || c == 3)"
- - This helps prevent mistakes such as "if (a & 1 == 0)"
+ - `if ((a == 1) && ((b == 2) || (c == 3)))` instead of ambiguous `if (a == 1 && b == 2 || c == 3)`
+ - This helps prevent mistakes such as `if (a & 1 == 0)`
* White space is free, so use it freely
- "freely" as in "plentifully", not "arbitrarily"
* Each and every control statement deserves its braces. This helps maintainability later on when the file is edited, lines added or removed - the control logic doesn't break so easily.
- * Please leave the first line of all source files blank, to get around an IDE bug.
- * Also leave the last line of all source files blank (GCC and GIT can complain otherwise)
+ - The only exception: a `switch` statement with all `case` statements being a single short statement is allowed to use the short brace-less form.
+ * Add an empty last line in all source files (GCC and GIT can complain otherwise)
+ * Use doxy-comments for functions in the header file, format as `/** Description */`
+ * Use spaces after the comment markers: `// Comment` instead of `//Comment`
Copyright
---------
-Your work should be licensed under the Apache license, and you should add yourself to the CONTRIBUTORS file.
+Your work must be licensed at least under the Apache license.
-If your work is not licensed under the Apache license, then it must be compatible and marked as such. Note that only plugins may choose a different license; MC-server's internals need to be single-license.
+You can add yourself to the CONTRIBUTORS file if you wish.
+
+**PLUGINS ONLY**: If your plugin is not licensed under the Apache license, then it must be compatible and marked as such. This is only valid for the plugins included within the MCServer source; plugins developed on separate repositories can use whatever license they want.
diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua
index 8e9d239fa..1fffbfcd0 100644
--- a/MCServer/Plugins/APIDump/APIDesc.lua
+++ b/MCServer/Plugins/APIDump/APIDesc.lua
@@ -111,6 +111,7 @@ g_APIDesc =
GetBlockType = { Params = "BlockX, BlockY, BlockZ", Return = "BLOCKTYPE", Notes = "Returns the block type at the specified absolute coords" },
GetBlockTypeMeta = { Params = "BlockX, BlockY, BlockZ", Return = "BLOCKTYPE, NIBBLETYPE", Notes = "Returns the block type and meta at the specified absolute coords" },
GetDataTypes = { Params = "", Return = "number", Notes = "Returns the mask of datatypes that the objectis currently holding" },
+ GetOrigin = { Params = "", Return = "OriginX, OriginY, OriginZ", Notes = "Returns the origin coords of where the area was read from." },
GetOriginX = { Params = "", Return = "number", Notes = "Returns the origin x-coord" },
GetOriginY = { Params = "", Return = "number", Notes = "Returns the origin y-coord" },
GetOriginZ = { Params = "", Return = "number", Notes = "Returns the origin z-coord" },
@@ -119,9 +120,11 @@ g_APIDesc =
GetRelBlockSkyLight = { Params = "RelBlockX, RelBlockY, RelBlockZ", Return = "NIBBLETYPE", Notes = "Returns the skylight at the specified relative coords" },
GetRelBlockType = { Params = "RelBlockX, RelBlockY, RelBlockZ", Return = "BLOCKTYPE", Notes = "Returns the block type at the specified relative coords" },
GetRelBlockTypeMeta = { Params = "RelBlockX, RelBlockY, RelBlockZ", Return = "BLOCKTYPE, NIBBLETYPE", Notes = "Returns the block type and meta at the specified relative coords" },
+ GetSize = { Params = "", Return = "SizeX, SizeY, SizeZ", Notes = "Returns the size of the area in all 3 axes." },
GetSizeX = { Params = "", Return = "number", Notes = "Returns the size of the held data in the x-axis" },
GetSizeY = { Params = "", Return = "number", Notes = "Returns the size of the held data in the y-axis" },
GetSizeZ = { Params = "", Return = "number", Notes = "Returns the size of the held data in the z-axis" },
+ GetVolume = { Params = "", Return = "number", Notes = "Returns the volume of the area - the total number of blocks stored within." },
HasBlockLights = { Params = "", Return = "bool", Notes = "Returns true if current datatypes include blocklight" },
HasBlockMetas = { Params = "", Return = "bool", Notes = "Returns true if current datatypes include block metas" },
HasBlockSkyLights = { Params = "", Return = "bool", Notes = "Returns true if current datatypes include skylight" },
@@ -448,6 +451,7 @@ end
GetUniqueID = { Params = "", Return = "number", Notes = "Returns the UniqueID of the client used to identify the client in the server" },
GetUsername = { Params = "", Return = "string", Notes = "Returns the username that the client has provided" },
GetViewDistance = { Params = "", Return = "number", Notes = "Returns the viewdistance (number of chunks loaded for the player in each direction)" },
+ HasPluginChannel = { Params = "ChannelName", Return = "bool", Notes = "Returns true if the client has registered to receive messages on the specified plugin channel." },
Kick = { Params = "Reason", Return = "", Notes = "Kicks the user with the specified reason" },
SendPluginMessage = { Params = "Channel, Message", Return = "", Notes = "Sends the plugin message on the specified channel." },
SetUsername = { Params = "Name", Return = "", Notes = "Sets the username" },
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp
index f2d21a682..2f3f3ee91 100644
--- a/src/Bindings/ManualBindings.cpp
+++ b/src/Bindings/ManualBindings.cpp
@@ -2350,6 +2350,37 @@ static int tolua_cBlockArea_GetBlockTypeMeta(lua_State * tolua_S)
+static int tolua_cBlockArea_GetOrigin(lua_State * tolua_S)
+{
+ // function cBlockArea::GetOrigin()
+ // Returns all three coords of the origin point
+ // Exported manually because there's no direct C++ equivalent,
+ // plus tolua would generate extra input params for the outputs
+
+ cLuaState L(tolua_S);
+ if (!L.CheckParamUserType(1, "cBlockArea"))
+ {
+ return 0;
+ }
+
+ cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL);
+ if (self == NULL)
+ {
+ tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetOrigin'", NULL);
+ return 0;
+ }
+
+ // Push the three origin coords:
+ lua_pushnumber(tolua_S, self->GetOriginX());
+ lua_pushnumber(tolua_S, self->GetOriginY());
+ lua_pushnumber(tolua_S, self->GetOriginZ());
+ return 3;
+}
+
+
+
+
+
static int tolua_cBlockArea_GetRelBlockTypeMeta(lua_State * tolua_S)
{
// function cBlockArea::GetRelBlockTypeMeta()
@@ -2385,6 +2416,37 @@ static int tolua_cBlockArea_GetRelBlockTypeMeta(lua_State * tolua_S)
+static int tolua_cBlockArea_GetSize(lua_State * tolua_S)
+{
+ // function cBlockArea::GetSize()
+ // Returns all three sizes of the area
+ // Exported manually because there's no direct C++ equivalent,
+ // plus tolua would generate extra input params for the outputs
+
+ cLuaState L(tolua_S);
+ if (!L.CheckParamUserType(1, "cBlockArea"))
+ {
+ return 0;
+ }
+
+ cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL);
+ if (self == NULL)
+ {
+ tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetSize'", NULL);
+ return 0;
+ }
+
+ // Push the three origin coords:
+ lua_pushnumber(tolua_S, self->GetSizeX());
+ lua_pushnumber(tolua_S, self->GetSizeY());
+ lua_pushnumber(tolua_S, self->GetSizeZ());
+ return 3;
+}
+
+
+
+
+
static int tolua_cBlockArea_LoadFromSchematicFile(lua_State * tolua_S)
{
// function cBlockArea::LoadFromSchematicFile
@@ -2461,7 +2523,9 @@ void ManualBindings::Bind(lua_State * tolua_S)
tolua_beginmodule(tolua_S, "cBlockArea");
tolua_function(tolua_S, "GetBlockTypeMeta", tolua_cBlockArea_GetBlockTypeMeta);
+ tolua_function(tolua_S, "GetOrigin", tolua_cBlockArea_GetOrigin);
tolua_function(tolua_S, "GetRelBlockTypeMeta", tolua_cBlockArea_GetRelBlockTypeMeta);
+ tolua_function(tolua_S, "GetSize", tolua_cBlockArea_GetSize);
tolua_function(tolua_S, "LoadFromSchematicFile", tolua_cBlockArea_LoadFromSchematicFile);
tolua_function(tolua_S, "SaveToSchematicFile", tolua_cBlockArea_SaveToSchematicFile);
tolua_endmodule(tolua_S);
diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp
index 194e2d68a..df154d3af 100644
--- a/src/BlockArea.cpp
+++ b/src/BlockArea.cpp
@@ -878,7 +878,7 @@ void cBlockArea::RotateCCW(void)
int NewX = z;
for (int y = 0; y < m_SizeY; y++)
{
- int NewIdx = NewX + NewZ * m_SizeX + y * m_SizeX * m_SizeZ;
+ int NewIdx = NewX + NewZ * m_SizeZ + y * m_SizeX * m_SizeZ;
int OldIdx = MakeIndex(x, y, z);
NewTypes[NewIdx] = m_BlockTypes[OldIdx];
NewMetas[NewIdx] = BlockHandler(m_BlockTypes[OldIdx])->MetaRotateCCW(m_BlockMetas[OldIdx]);
@@ -923,7 +923,7 @@ void cBlockArea::RotateCW(void)
int NewX = m_SizeZ - z - 1;
for (int y = 0; y < m_SizeY; y++)
{
- int NewIdx = NewX + NewZ * m_SizeX + y * m_SizeX * m_SizeZ;
+ int NewIdx = NewX + NewZ * m_SizeZ + y * m_SizeX * m_SizeZ;
int OldIdx = MakeIndex(x, y, z);
NewTypes[NewIdx] = m_BlockTypes[OldIdx];
NewMetas[NewIdx] = BlockHandler(m_BlockTypes[OldIdx])->MetaRotateCW(m_BlockMetas[OldIdx]);
@@ -1075,7 +1075,7 @@ void cBlockArea::RotateCCWNoMeta(void)
int NewX = z;
for (int y = 0; y < m_SizeY; y++)
{
- NewTypes[NewX + NewZ * m_SizeX + y * m_SizeX * m_SizeZ] = m_BlockTypes[MakeIndex(x, y, z)];
+ NewTypes[NewX + NewZ * m_SizeZ + y * m_SizeX * m_SizeZ] = m_BlockTypes[MakeIndex(x, y, z)];
} // for y
} // for z
} // for x
@@ -1093,7 +1093,7 @@ void cBlockArea::RotateCCWNoMeta(void)
int NewX = z;
for (int y = 0; y < m_SizeY; y++)
{
- NewMetas[NewX + NewZ * m_SizeX + y * m_SizeX * m_SizeZ] = m_BlockMetas[MakeIndex(x, y, z)];
+ NewMetas[NewX + NewZ * m_SizeZ + y * m_SizeX * m_SizeZ] = m_BlockMetas[MakeIndex(x, y, z)];
} // for y
} // for z
} // for x
@@ -1120,7 +1120,7 @@ void cBlockArea::RotateCWNoMeta(void)
int NewZ = x;
for (int y = 0; y < m_SizeY; y++)
{
- NewTypes[NewX + NewZ * m_SizeX + y * m_SizeX * m_SizeZ] = m_BlockTypes[MakeIndex(x, y, z)];
+ NewTypes[NewX + NewZ * m_SizeZ + y * m_SizeX * m_SizeZ] = m_BlockTypes[MakeIndex(x, y, z)];
} // for y
} // for x
} // for z
@@ -1138,7 +1138,7 @@ void cBlockArea::RotateCWNoMeta(void)
int NewZ = x;
for (int y = 0; y < m_SizeY; y++)
{
- NewMetas[NewX + NewZ * m_SizeX + y * m_SizeX * m_SizeZ] = m_BlockMetas[MakeIndex(x, y, z)];
+ NewMetas[NewX + NewZ * m_SizeZ + y * m_SizeX * m_SizeZ] = m_BlockMetas[MakeIndex(x, y, z)];
} // for y
} // for x
} // for z
diff --git a/src/BlockArea.h b/src/BlockArea.h
index b4a161f32..5ef814d0e 100644
--- a/src/BlockArea.h
+++ b/src/BlockArea.h
@@ -24,7 +24,7 @@ class cBlockArea
public:
- /// What data is to be queried (bit-mask)
+ /** What data is to be queried (bit-mask) */
enum
{
baTypes = 1,
@@ -44,7 +44,7 @@ public:
cBlockArea(void);
~cBlockArea();
- /// Clears the data stored to reclaim memory
+ /** Clears the data stored to reclaim memory */
void Clear(void);
/** Creates a new area of the specified size and contents.
@@ -53,31 +53,31 @@ public:
*/
void Create(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes = baTypes | baMetas);
- /// Resets the origin. No other changes are made, contents are untouched.
+ /** Resets the origin. No other changes are made, contents are untouched. */
void SetOrigin(int a_OriginX, int a_OriginY, int a_OriginZ);
- /// Reads an area of blocks specified. Returns true if successful. All coords are inclusive.
+ /** Reads an area of blocks specified. Returns true if successful. All coords are inclusive. */
bool Read(cForEachChunkProvider * a_ForEachChunkProvider, int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ, int a_DataTypes = baTypes | baMetas);
// TODO: Write() is not too good an interface: if it fails, there's no way to repeat only for the parts that didn't write
// A better way may be to return a list of cBlockAreas for each part that didn't succeed writing, so that the caller may try again
- /// Writes the area back into cWorld at the coords specified. Returns true if successful in all chunks, false if only partially / not at all
+ /** Writes the area back into cWorld at the coords specified. Returns true if successful in all chunks, false if only partially / not at all */
bool Write(cForEachChunkProvider * a_ForEachChunkProvider, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes = baTypes | baMetas);
- /// Copies this object's contents into the specified BlockArea.
+ /** Copies this object's contents into the specified BlockArea. */
void CopyTo(cBlockArea & a_Into) const;
- /// Copies the contents from the specified BlockArea into this object.
+ /** Copies the contents from the specified BlockArea into this object. */
void CopyFrom(const cBlockArea & a_From);
- /// For testing purposes only, dumps the area into a file.
+ /** For testing purposes only, dumps the area into a file. */
void DumpToRawFile(const AString & a_FileName);
- /// Crops the internal contents by the specified amount of blocks from each border.
+ /** Crops the internal contents by the specified amount of blocks from each border. */
void Crop(int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY, int a_AddMinZ, int a_SubMaxZ);
- /// Expands the internal contents by the specified amount of blocks from each border
+ /** Expands the internal contents by the specified amount of blocks from each border */
void Expand(int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ);
/** Merges another block area into this one, using the specified block combinating strategy
@@ -117,49 +117,49 @@ public:
*/
void Merge(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_RelZ, eMergeStrategy a_Strategy);
- /// Fills the entire block area with the specified data
+ /** Fills the entire block area with the specified data */
void Fill(int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0, NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f);
- /// Fills a cuboid inside the block area with the specified data
+ /** Fills a cuboid inside the block area with the specified data */
void FillRelCuboid(int a_MinRelX, int a_MaxRelX, int a_MinRelY, int a_MaxRelY, int a_MinRelZ, int a_MaxRelZ,
int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0,
NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f
);
- /// Draws a line from between two points with the specified data
+ /** Draws a line from between two points with the specified data */
void RelLine(int a_RelX1, int a_RelY1, int a_RelZ1, int a_RelX2, int a_RelY2, int a_RelZ2,
int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0,
NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f
);
- /// Rotates the entire area counter-clockwise around the Y axis
+ /** Rotates the entire area counter-clockwise around the Y axis */
void RotateCCW(void);
- /// Rotates the entire area clockwise around the Y axis
+ /** Rotates the entire area clockwise around the Y axis */
void RotateCW(void);
- /// Mirrors the entire area around the XY plane
+ /** Mirrors the entire area around the XY plane */
void MirrorXY(void);
- /// Mirrors the entire area around the XZ plane
+ /** Mirrors the entire area around the XZ plane */
void MirrorXZ(void);
- /// Mirrors the entire area around the YZ plane
+ /** Mirrors the entire area around the YZ plane */
void MirrorYZ(void);
- /// Rotates the entire area counter-clockwise around the Y axis, doesn't use blockhandlers for block meta
+ /** Rotates the entire area counter-clockwise around the Y axis, doesn't use blockhandlers for block meta */
void RotateCCWNoMeta(void);
- /// Rotates the entire area clockwise around the Y axis, doesn't use blockhandlers for block meta
+ /** Rotates the entire area clockwise around the Y axis, doesn't use blockhandlers for block meta */
void RotateCWNoMeta(void);
- /// Mirrors the entire area around the XY plane, doesn't use blockhandlers for block meta
+ /** Mirrors the entire area around the XY plane, doesn't use blockhandlers for block meta */
void MirrorXYNoMeta(void);
- /// Mirrors the entire area around the XZ plane, doesn't use blockhandlers for block meta
+ /** Mirrors the entire area around the XZ plane, doesn't use blockhandlers for block meta */
void MirrorXZNoMeta(void);
- /// Mirrors the entire area around the YZ plane, doesn't use blockhandlers for block meta
+ /** Mirrors the entire area around the YZ plane, doesn't use blockhandlers for block meta */
void MirrorYZNoMeta(void);
// Setters:
@@ -197,11 +197,14 @@ public:
int GetSizeY(void) const { return m_SizeY; }
int GetSizeZ(void) const { return m_SizeZ; }
+ /** Returns the volume of the area, as number of blocks */
+ int GetVolume(void) const { return m_SizeX * m_SizeY * m_SizeZ; }
+
int GetOriginX(void) const { return m_OriginX; }
int GetOriginY(void) const { return m_OriginY; }
int GetOriginZ(void) const { return m_OriginZ; }
- /// Returns the datatypes that are stored in the object (bitmask of baXXX values)
+ /** Returns the datatypes that are stored in the object (bitmask of baXXX values) */
int GetDataTypes(void) const;
bool HasBlockTypes (void) const { return (m_BlockTypes != NULL); }
@@ -212,7 +215,7 @@ public:
// tolua_end
// Clients can use these for faster access to all blocktypes. Be careful though!
- /// Returns the internal pointer to the block types
+ /** Returns the internal pointer to the block types */
BLOCKTYPE * GetBlockTypes (void) const { return m_BlockTypes; }
NIBBLETYPE * GetBlockMetas (void) const { return m_BlockMetas; } // NOTE: one byte per block!
NIBBLETYPE * GetBlockLight (void) const { return m_BlockLight; } // NOTE: one byte per block!
@@ -263,7 +266,7 @@ protected:
NIBBLETYPE * m_BlockLight; // Each light value is stored as a separate byte for faster access
NIBBLETYPE * m_BlockSkyLight; // Each light value is stored as a separate byte for faster access
- /// Clears the data stored and prepares a fresh new block area with the specified dimensions
+ /** Clears the data stored and prepares a fresh new block area with the specified dimensions */
bool SetSize(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes);
// Basic Setters:
@@ -282,7 +285,7 @@ protected:
void ExpandBlockTypes(int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ);
void ExpandNibbles (NIBBLEARRAY & a_Array, int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ);
- /// Sets the specified datatypes at the specified location.
+ /** Sets the specified datatypes at the specified location. */
void RelSetData(
int a_RelX, int a_RelY, int a_RelZ,
int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta,
diff --git a/src/BlockID.cpp b/src/BlockID.cpp
index c38db0bfe..ff1c54e3f 100644
--- a/src/BlockID.cpp
+++ b/src/BlockID.cpp
@@ -644,9 +644,11 @@ public:
g_BlockPistonBreakable[E_BLOCK_DEAD_BUSH] = true;
g_BlockPistonBreakable[E_BLOCK_FIRE] = true;
g_BlockPistonBreakable[E_BLOCK_FLOWER] = true;
+ g_BlockPistonBreakable[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE] = true;
g_BlockPistonBreakable[E_BLOCK_INACTIVE_COMPARATOR] = true;
g_BlockPistonBreakable[E_BLOCK_IRON_DOOR] = true;
g_BlockPistonBreakable[E_BLOCK_JACK_O_LANTERN] = true;
+ g_BlockPistonBreakable[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE] = true;
g_BlockPistonBreakable[E_BLOCK_LADDER] = true;
g_BlockPistonBreakable[E_BLOCK_LAVA] = true;
g_BlockPistonBreakable[E_BLOCK_LEVER] = true;
@@ -727,10 +729,12 @@ public:
g_BlockRequiresSpecialTool[E_BLOCK_END_STONE] = true;
g_BlockRequiresSpecialTool[E_BLOCK_GOLD_BLOCK] = true;
g_BlockRequiresSpecialTool[E_BLOCK_GOLD_ORE] = true;
+ g_BlockRequiresSpecialTool[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE] = true;
g_BlockRequiresSpecialTool[E_BLOCK_IRON_BLOCK] = true;
g_BlockRequiresSpecialTool[E_BLOCK_IRON_ORE] = true;
g_BlockRequiresSpecialTool[E_BLOCK_LAPIS_BLOCK] = true;
g_BlockRequiresSpecialTool[E_BLOCK_LAPIS_ORE] = true;
+ g_BlockRequiresSpecialTool[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE] = true;
g_BlockRequiresSpecialTool[E_BLOCK_MOSSY_COBBLESTONE] = true;
g_BlockRequiresSpecialTool[E_BLOCK_NETHERRACK] = true;
g_BlockRequiresSpecialTool[E_BLOCK_NETHER_BRICK] = true;
diff --git a/src/BlockID.h b/src/BlockID.h
index 740c5fc90..3413555f4 100644
--- a/src/BlockID.h
+++ b/src/BlockID.h
@@ -527,10 +527,12 @@ enum
E_META_SANDSTONE_SMOOTH = 2,
// E_BLOCK_SAPLING metas (lowest 3 bits):
- E_META_SAPLING_APPLE = 0,
- E_META_SAPLING_CONIFER = 1,
- E_META_SAPLING_BIRCH = 2,
- E_META_SAPLING_JUNGLE = 3,
+ E_META_SAPLING_APPLE = 0,
+ E_META_SAPLING_CONIFER = 1,
+ E_META_SAPLING_BIRCH = 2,
+ E_META_SAPLING_JUNGLE = 3,
+ E_META_SAPLING_ACACIA = 4,
+ E_META_SAPLING_DARK_OAK = 5,
// E_BLOCK_SILVERFISH_EGG metas:
E_META_SILVERFISH_EGG_STONE = 0,
diff --git a/src/Blocks/BlockBed.cpp b/src/Blocks/BlockBed.cpp
index a6f3c36b6..3dad4feba 100644
--- a/src/Blocks/BlockBed.cpp
+++ b/src/Blocks/BlockBed.cpp
@@ -63,20 +63,29 @@ void cBlockBedHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface
if (a_WorldInterface.GetTimeOfDay() > 13000)
{
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
- if (Meta & 0x8)
+ if (Meta & 0x4)
{
- // Is pillow
- a_WorldInterface.GetBroadcastManager().BroadcastUseBed(*a_Player, a_BlockX, a_BlockY, a_BlockZ);
+ a_Player->SendMessageFailure("This bed is occupied.");
}
else
{
- // Is foot end
- Vector3i Direction = MetaDataToDirection( Meta & 0x7 );
- if (a_ChunkInterface.GetBlock(a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z) == E_BLOCK_BED) // Must always use pillow location for sleeping
+ if (Meta & 0x8)
{
- a_WorldInterface.GetBroadcastManager().BroadcastUseBed(*a_Player, a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z);
+ // Is pillow
+ a_WorldInterface.GetBroadcastManager().BroadcastUseBed(*a_Player, a_BlockX, a_BlockY, a_BlockZ);
}
+ else
+ {
+ // Is foot end
+ Vector3i Direction = MetaDataToDirection( Meta & 0x7 );
+ if (a_ChunkInterface.GetBlock(a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z) == E_BLOCK_BED) // Must always use pillow location for sleeping
+ {
+ a_WorldInterface.GetBroadcastManager().BroadcastUseBed(*a_Player, a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z);
+ }
+ }
+ a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, (Meta | (1 << 2)));
}
+
} else {
a_Player->SendMessageFailure("You can only sleep at night");
}
@@ -86,3 +95,5 @@ void cBlockBedHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface
+
+
diff --git a/src/Blocks/BlockCauldron.h b/src/Blocks/BlockCauldron.h
index 09d5c3cbb..2e1032d2b 100644
--- a/src/Blocks/BlockCauldron.h
+++ b/src/Blocks/BlockCauldron.h
@@ -21,24 +21,30 @@ public:
a_Pickups.push_back(cItem(E_ITEM_CAULDRON, 1, 0));
}
- void OnUse(cChunkInterface * a_ChunkInterface, cWorldInterface * a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
+ virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
{
- char Meta = a_ChunkInterface->GetBlockMeta( a_BlockX, a_BlockY, a_BlockZ );
- switch( a_Player->GetEquippedItem().m_ItemType )
+ char Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
+ switch (a_Player->GetEquippedItem().m_ItemType)
{
case E_ITEM_WATER_BUCKET:
{
- a_ChunkInterface->SetBlockMeta( a_BlockX, a_BlockY, a_BlockZ, 3 );
- a_Player->GetInventory().RemoveOneEquippedItem();
- cItem NewItem(E_ITEM_BUCKET, 1);
- a_Player->GetInventory().AddItem(NewItem);
+ if (Meta < 3)
+ {
+ a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, 3);
+ if (!a_Player->IsGameModeCreative())
+ {
+ a_Player->GetInventory().RemoveOneEquippedItem();
+ cItem NewItem(E_ITEM_BUCKET, 1);
+ a_Player->GetInventory().AddItem(NewItem);
+ }
+ }
break;
}
case E_ITEM_GLASS_BOTTLE:
{
- if( Meta > 0 )
+ if (Meta > 0)
{
- a_ChunkInterface->SetBlockMeta( a_BlockX, a_BlockY, a_BlockZ, --Meta);
+ a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, --Meta);
a_Player->GetInventory().RemoveOneEquippedItem();
cItem NewItem(E_ITEM_POTIONS, 1, 0);
a_Player->GetInventory().AddItem(NewItem);
diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp
index 09a1244ea..834727c9a 100644
--- a/src/Blocks/BlockHandler.cpp
+++ b/src/Blocks/BlockHandler.cpp
@@ -39,6 +39,7 @@
#include "BlockIce.h"
#include "BlockLadder.h"
#include "BlockLeaves.h"
+#include "BlockNewLeaves.h"
#include "BlockLever.h"
#include "BlockMelon.h"
#include "BlockMushroom.h"
@@ -108,6 +109,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
switch(a_BlockType)
{
// Block handlers, alphabetically sorted:
+ case E_BLOCK_ACACIA_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType);
case E_BLOCK_ACTIVATOR_RAIL: return new cBlockRailHandler (a_BlockType);
case E_BLOCK_BED: return new cBlockBedHandler (a_BlockType);
case E_BLOCK_BIRCH_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType);
@@ -126,6 +128,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_COBBLESTONE_STAIRS: return new cBlockStairsHandler (a_BlockType);
case E_BLOCK_COBWEB: return new cBlockCobWebHandler (a_BlockType);
case E_BLOCK_CROPS: return new cBlockCropsHandler (a_BlockType);
+ case E_BLOCK_DARK_OAK_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType);
case E_BLOCK_DEAD_BUSH: return new cBlockDeadBushHandler (a_BlockType);
case E_BLOCK_DETECTOR_RAIL: return new cBlockRailHandler (a_BlockType);
case E_BLOCK_DIAMOND_ORE: return new cBlockOreHandler (a_BlockType);
@@ -169,6 +172,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_NETHER_BRICK_STAIRS: return new cBlockStairsHandler (a_BlockType);
case E_BLOCK_NETHER_PORTAL: return new cBlockPortalHandler (a_BlockType);
case E_BLOCK_NETHER_WART: return new cBlockNetherWartHandler (a_BlockType);
+ case E_BLOCK_NEW_LEAVES: return new cBlockNewLeavesHandler (a_BlockType);
case E_BLOCK_NEW_LOG: return new cBlockSidewaysHandler (a_BlockType);
case E_BLOCK_NOTE_BLOCK: return new cBlockNoteHandler (a_BlockType);
case E_BLOCK_PISTON: return new cBlockPistonHandler (a_BlockType);
diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h
index ad6e440e2..7b8f0b378 100644
--- a/src/Blocks/BlockLeaves.h
+++ b/src/Blocks/BlockLeaves.h
@@ -139,6 +139,8 @@ bool HasNearLog(cBlockArea & a_Area, int a_BlockX, int a_BlockY, int a_BlockZ)
{
switch (Types[i])
{
+ case E_BLOCK_NEW_LEAVES:
+ case E_BLOCK_NEW_LOG:
case E_BLOCK_LEAVES:
case E_BLOCK_LOG:
{
diff --git a/src/Blocks/BlockNewLeaves.h b/src/Blocks/BlockNewLeaves.h
new file mode 100644
index 000000000..5a267e8c6
--- /dev/null
+++ b/src/Blocks/BlockNewLeaves.h
@@ -0,0 +1,42 @@
+#pragma once
+#include "BlockHandler.h"
+#include "BlockLeaves.h"
+#include "../World.h"
+
+
+
+
+
+
+class cBlockNewLeavesHandler :
+ public cBlockLeavesHandler
+{
+public:
+ cBlockNewLeavesHandler(BLOCKTYPE a_BlockType)
+ : cBlockLeavesHandler(a_BlockType)
+ {
+ }
+
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ MTRand rand;
+
+ // Only the first 2 bits contain the display information, the others are for growing
+ if (rand.randInt(5) == 0)
+ {
+ a_Pickups.push_back(cItem(E_BLOCK_SAPLING, 1, (a_BlockMeta & 3) + 4));
+ }
+ }
+
+
+ void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ) override
+ {
+ cBlockHandler::OnDestroyed(a_ChunkInterface, a_WorldInterface, a_BlockX, a_BlockY, a_BlockZ);
+ }
+} ;
+
+
+
+
+
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index 4f301c209..8dfbbeef5 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -562,13 +562,6 @@ void cChunk::Tick(float a_Dt)
{
BroadcastPendingBlockChanges();
- // Unload the chunk from all clients that have queued unloading:
- for (cClientHandleList::iterator itr = m_UnloadQuery.begin(), end = m_UnloadQuery.end(); itr != end; ++itr)
- {
- (*itr)->SendUnloadChunk(m_PosX, m_PosZ);
- }
- m_UnloadQuery.clear();
-
// Set all blocks that have been queued for setting later:
ProcessQueuedSetBlocks();
diff --git a/src/Chunk.h b/src/Chunk.h
index 1b7a6fa07..c9e9697ca 100644
--- a/src/Chunk.h
+++ b/src/Chunk.h
@@ -405,7 +405,6 @@ private:
// A critical section is not needed, because all chunk access is protected by its parent ChunkMap's csLayers
cClientHandleList m_LoadedByClient;
- cClientHandleList m_UnloadQuery;
cEntityList m_Entities;
cBlockEntityList m_BlockEntities;
diff --git a/src/ChunkDef.h b/src/ChunkDef.h
index f48dc4fd5..7be2fa2df 100644
--- a/src/ChunkDef.h
+++ b/src/ChunkDef.h
@@ -92,6 +92,7 @@ public:
/// Converts absolute block coords into relative (chunk + block) coords:
inline static void AbsoluteToRelative(/* in-out */ int & a_X, int & a_Y, int & a_Z, /* out */ int & a_ChunkX, int & a_ChunkZ )
{
+ UNUSED(a_Y);
BlockToChunk(a_X, a_Z, a_ChunkX, a_ChunkZ);
a_X = a_X - a_ChunkX * Width;
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index fbb8706e0..b5795fbaf 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -805,6 +805,10 @@ void cChunkMap::WakeUpSimulators(int a_BlockX, int a_BlockY, int a_BlockZ)
/// Wakes up the simulators for the specified area of blocks
void cChunkMap::WakeUpSimulatorsInArea(int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ)
{
+ // Limit the Y coords:
+ a_MinBlockY = std::max(a_MinBlockY, 0);
+ a_MaxBlockY = std::min(a_MaxBlockY, cChunkDef::Height - 1);
+
cSimulatorManager * SimMgr = m_World->GetSimulatorManager();
int MinChunkX, MinChunkZ, MaxChunkX, MaxChunkZ;
cChunkDef::BlockToChunk(a_MinBlockX, a_MinBlockZ, MinChunkX, MinChunkZ);
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index a6a74bf4a..b08ceb5f6 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -32,6 +32,7 @@
#include "Protocol/ProtocolRecognizer.h"
#include "CompositeChat.h"
+#include "Items/ItemSword.h"
@@ -542,19 +543,23 @@ void cClientHandle::HandlePlayerPos(double a_PosX, double a_PosY, double a_PosZ,
void cClientHandle::HandlePluginMessage(const AString & a_Channel, const AString & a_Message)
{
- if (a_Channel == "MC|AdvCdm") // Command block, set text, Client -> Server
+ if (a_Channel == "MC|AdvCdm")
{
- const char* Data = a_Message.c_str();
- HandleCommandBlockMessage(Data, a_Message.size());
- return;
+ // Command block, set text, Client -> Server
+ HandleCommandBlockMessage(a_Message.c_str(), a_Message.size());
}
- else if (a_Channel == "MC|Brand") // Client <-> Server branding exchange
+ else if (a_Channel == "MC|Brand")
{
- // We are custom,
- // We are awesome,
- // We are MCServer.
+ // Client <-> Server branding exchange
SendPluginMessage("MC|Brand", "MCServer");
- return;
+ }
+ else if (a_Channel == "REGISTER")
+ {
+ RegisterPluginChannels(BreakApartPluginChannels(a_Message));
+ }
+ else if (a_Channel == "UNREGISTER")
+ {
+ UnregisterPluginChannels(BreakApartPluginChannels(a_Message));
}
cPluginManager::Get()->CallHookPluginMessage(*this, a_Channel, a_Message);
@@ -564,7 +569,61 @@ void cClientHandle::HandlePluginMessage(const AString & a_Channel, const AString
-void cClientHandle::HandleCommandBlockMessage(const char* a_Data, unsigned int a_Length)
+AStringVector cClientHandle::BreakApartPluginChannels(const AString & a_PluginChannels)
+{
+ // Break the string on each NUL character.
+ // Note that StringSplit() doesn't work on this because NUL is a special char - string terminator
+ size_t len = a_PluginChannels.size();
+ size_t first = 0;
+ AStringVector res;
+ for (size_t i = 0; i < len; i++)
+ {
+ if (a_PluginChannels[i] != 0)
+ {
+ continue;
+ }
+ if (i > first)
+ {
+ res.push_back(a_PluginChannels.substr(first, i - first));
+ }
+ first = i + 1;
+ } // for i - a_PluginChannels[]
+ if (first < len)
+ {
+ res.push_back(a_PluginChannels.substr(first, len - first));
+ }
+ return res;
+}
+
+
+
+
+
+void cClientHandle::RegisterPluginChannels(const AStringVector & a_ChannelList)
+{
+ for (AStringVector::const_iterator itr = a_ChannelList.begin(), end = a_ChannelList.end(); itr != end; ++itr)
+ {
+ m_PluginChannels.insert(*itr);
+ } // for itr - a_ChannelList[]
+}
+
+
+
+
+
+void cClientHandle::UnregisterPluginChannels(const AStringVector & a_ChannelList)
+{
+ for (AStringVector::const_iterator itr = a_ChannelList.begin(), end = a_ChannelList.end(); itr != end; ++itr)
+ {
+ m_PluginChannels.erase(*itr);
+ } // for itr - a_ChannelList[]
+}
+
+
+
+
+
+void cClientHandle::HandleCommandBlockMessage(const char * a_Data, unsigned int a_Length)
{
if (a_Length < 14)
{
@@ -736,6 +795,15 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc
return;
}
+ if (
+ m_Player->IsGameModeCreative() &&
+ ItemCategory::IsSword(m_Player->GetInventory().GetEquippedItem().m_ItemType)
+ )
+ {
+ // Players can't destroy blocks with a Sword in the hand.
+ return;
+ }
+
if (cRoot::Get()->GetPluginManager()->CallHookPlayerBreakingBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_OldBlock, a_OldMeta))
{
// A plugin doesn't agree with the breaking. Bail out. Send the block back to the client, so that it knows:
@@ -2490,6 +2558,15 @@ void cClientHandle::SetViewDistance(int a_ViewDistance)
+bool cClientHandle::HasPluginChannel(const AString & a_PluginChannel)
+{
+ return (m_PluginChannels.find(a_PluginChannel) != m_PluginChannels.end());
+}
+
+
+
+
+
bool cClientHandle::WantsSendChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
{
if (m_State >= csDestroying)
diff --git a/src/ClientHandle.h b/src/ClientHandle.h
index 8911164bf..194533402 100644
--- a/src/ClientHandle.h
+++ b/src/ClientHandle.h
@@ -73,10 +73,10 @@ public:
inline bool IsLoggedIn(void) const { return (m_State >= csAuthenticating); }
- /// Called while the client is being ticked from the world via its cPlayer object
+ /** Called while the client is being ticked from the world via its cPlayer object */
void Tick(float a_Dt);
- /// Called while the client is being ticked from the cServer object
+ /** Called while the client is being ticked from the cServer object */
void ServerTick(float a_Dt);
void Destroy(void);
@@ -154,23 +154,28 @@ public:
void SendWindowOpen (const cWindow & a_Window);
void SendWindowProperty (const cWindow & a_Window, int a_Property, int a_Value);
- const AString & GetUsername(void) const; // tolua_export
- void SetUsername( const AString & a_Username ); // tolua_export
+ // tolua_begin
+ const AString & GetUsername(void) const;
+ void SetUsername( const AString & a_Username );
- inline short GetPing(void) const { return m_Ping; } // tolua_export
+ inline short GetPing(void) const { return m_Ping; }
- void SetViewDistance(int a_ViewDistance); // tolua_export
- int GetViewDistance(void) const { return m_ViewDistance; } // tolua_export
+ void SetViewDistance(int a_ViewDistance);
+ int GetViewDistance(void) const { return m_ViewDistance; }
- void SetLocale(AString & a_Locale) { m_Locale = a_Locale; } // tolua_export
- AString GetLocale(void) const { return m_Locale; } // tolua_export
+ void SetLocale(AString & a_Locale) { m_Locale = a_Locale; }
+ AString GetLocale(void) const { return m_Locale; }
- int GetUniqueID() const { return m_UniqueID; } // tolua_export
+ int GetUniqueID(void) const { return m_UniqueID; }
- /// Returns true if the client wants the chunk specified to be sent (in m_ChunksToSend)
+ bool HasPluginChannel(const AString & a_PluginChannel);
+
+ // tolua_end
+
+ /** Returns true if the client wants the chunk specified to be sent (in m_ChunksToSend) */
bool WantsSendChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ);
- /// Adds the chunk specified to the list of chunks wanted for sending (m_ChunksToSend)
+ /** Adds the chunk specified to the list of chunks wanted for sending (m_ChunksToSend) */
void AddWantedChunk(int a_ChunkX, int a_ChunkZ);
// Calls that cProtocol descendants use to report state:
@@ -221,14 +226,17 @@ public:
void SendData(const char * a_Data, int a_Size);
- /// Called when the player moves into a different world; queues sreaming the new chunks
+ /** 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)
+ /** 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, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, cItemHandler & a_ItemHandler);
private:
+ /** The type used for storing the names of registered plugin channels. */
+ typedef std::set<AString> cChannels;
+
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 )
static const int GENERATEDISTANCE = 2; // Server generates this many chunks AHEAD of player sight. 2 is the minimum, since foliage is generated 1 step behind chunk terrain generation
@@ -261,7 +269,7 @@ private:
int m_LastStreamedChunkX;
int m_LastStreamedChunkZ;
- /// Seconds since the last packet data was received (updated in Tick(), reset in DataReceived())
+ /** Seconds since the last packet data was received (updated in Tick(), reset in DataReceived()) */
float m_TimeSinceLastPacket;
short m_Ping;
@@ -283,7 +291,7 @@ private:
int m_LastDigBlockY;
int m_LastDigBlockZ;
- /// Used while csDestroyedWaiting for counting the ticks until the connection is closed
+ /** Used while csDestroyedWaiting for counting the ticks until the connection is closed */
int m_TicksSinceDestruction;
enum eState
@@ -303,10 +311,10 @@ private:
eState m_State;
- /// m_State needs to be locked in the Destroy() function so that the destruction code doesn't run twice on two different threads
+ /** m_State needs to be locked in the Destroy() function so that the destruction code doesn't run twice on two different threads */
cCriticalSection m_CSDestroyingState;
- /// If set to true during csDownloadingWorld, the tick thread calls CheckIfWorldDownloaded()
+ /** If set to true during csDownloadingWorld, the tick thread calls CheckIfWorldDownloaded() */
bool m_ShouldCheckDownloaded;
/** Number of explosions sent this tick */
@@ -315,27 +323,39 @@ private:
static int s_ClientCount;
int m_UniqueID;
- /// Set to true when the chunk where the player is is sent to the client. Used for spawning the player
+ /** Set to true when the chunk where the player is is sent to the client. Used for spawning the player */
bool m_HasSentPlayerChunk;
- /// Client Settings
+ /** Client Settings */
AString m_Locale;
+
+ /** The plugin channels that the client has registered. */
+ cChannels m_PluginChannels;
- /// Returns true if the rate block interactions is within a reasonable limit (bot protection)
+ /** Returns true if the rate block interactions is within a reasonable limit (bot protection) */
bool CheckBlockInteractionsRate(void);
- /// Adds a single chunk to be streamed to the client; used by StreamChunks()
+ /** Adds a single chunk to be streamed to the client; used by StreamChunks() */
void StreamChunk(int a_ChunkX, int a_ChunkZ);
- /// Handles the DIG_STARTED dig packet:
+ /** Handles the DIG_STARTED dig packet: */
void HandleBlockDigStarted (int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta);
- /// Handles the DIG_FINISHED dig packet:
+ /** Handles the DIG_FINISHED dig packet: */
void HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta);
- /// Handles the "MC|AdvCdm" plugin message
- void HandleCommandBlockMessage(const char* a_Data, unsigned int a_Length);
+ /** Converts the protocol-formatted channel list (NUL-separated) into a proper string vector. */
+ AStringVector BreakApartPluginChannels(const AString & a_PluginChannels);
+
+ /** Adds all of the channels to the list of current plugin channels. Handles duplicates gracefully. */
+ void RegisterPluginChannels(const AStringVector & a_ChannelList);
+
+ /** Removes all of the channels from the list of current plugin channels. Ignores channels that are not found. */
+ void UnregisterPluginChannels(const AStringVector & a_ChannelList);
+
+ /** Handles the "MC|AdvCdm" plugin message */
+ void HandleCommandBlockMessage(const char * a_Data, unsigned int a_Length);
// cSocketThreads::cCallback overrides:
virtual void DataReceived (const char * a_Data, int a_Size) override; // Data is received from the client
diff --git a/src/Generating/Trees.cpp b/src/Generating/Trees.cpp
index 7e8a3c75f..a660285d1 100644
--- a/src/Generating/Trees.cpp
+++ b/src/Generating/Trees.cpp
@@ -382,6 +382,24 @@ void GetBirchTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Nois
+void GetAcaciaTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks)
+{
+ // TODO
+}
+
+
+
+
+
+void GetDarkoakTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks)
+{
+ // TODO
+}
+
+
+
+
+
void GetTallBirchTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks)
{
int Height = 9 + (a_Noise.IntNoise3DInt(a_BlockX + 64 * a_Seq, a_BlockY, a_BlockZ) % 3);
diff --git a/src/Generating/Trees.h b/src/Generating/Trees.h
index 514158eb7..00f343a3d 100644
--- a/src/Generating/Trees.h
+++ b/src/Generating/Trees.h
@@ -63,6 +63,12 @@ void GetLargeAppleTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a
/// Generates an image of a random birch tree
void GetBirchTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks);
+/// Generates an image of a random acacia tree
+void GetAcaciaTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks);
+
+/// Generates an image of a random darkoak tree
+void GetDarkoakTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks);
+
/// Generates an image of a random large birch tree
void GetTallBirchTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks,sSetBlockVector & a_OtherBlocks);
diff --git a/src/LightingThread.h b/src/LightingThread.h
index 81dd9d61f..72d561348 100644
--- a/src/LightingThread.h
+++ b/src/LightingThread.h
@@ -82,7 +82,11 @@ protected:
cLightingChunkStay(cLightingThread & a_LightingThread, int a_ChunkX, int a_ChunkZ, cChunkCoordCallback * a_CallbackAfter);
protected:
- virtual void OnChunkAvailable(int a_ChunkX, int a_ChunkZ) override {}
+ virtual void OnChunkAvailable(int a_ChunkX, int a_ChunkZ) override
+ {
+ UNUSED(a_ChunkX);
+ UNUSED(a_ChunkZ);
+ }
virtual bool OnAllChunksAvailable(void) override;
virtual void OnDisabled(void) override;
} ;
diff --git a/src/Mobs/Wolf.cpp b/src/Mobs/Wolf.cpp
index 2736c3dd1..0d3619166 100644
--- a/src/Mobs/Wolf.cpp
+++ b/src/Mobs/Wolf.cpp
@@ -4,6 +4,7 @@
#include "Wolf.h"
#include "../World.h"
#include "../Entities/Player.h"
+#include "../Items/ItemHandler.h"
@@ -86,23 +87,44 @@ void cWolf::OnRightClicked(cPlayer & a_Player)
}
else if (IsTame())
{
- if (a_Player.GetName() == m_OwnerName) // Is the player the owner of the dog?
+ switch (a_Player.GetEquippedItem().m_ItemType)
{
- if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_DYE)
+ case E_ITEM_RAW_BEEF:
+ case E_ITEM_STEAK:
+ case E_ITEM_RAW_PORKCHOP:
+ case E_ITEM_COOKED_PORKCHOP:
+ case E_ITEM_RAW_CHICKEN:
+ case E_ITEM_COOKED_CHICKEN:
+ case E_ITEM_ROTTEN_FLESH:
{
- SetCollarColor(15 - a_Player.GetEquippedItem().m_ItemDamage);
- if (!a_Player.IsGameModeCreative())
+ if (m_Health < m_MaxHealth)
{
- a_Player.GetInventory().RemoveOneEquippedItem();
+ Heal(ItemHandler(a_Player.GetEquippedItem().m_ItemType)->GetFoodInfo().FoodLevel);
+ if (!a_Player.IsGameModeCreative())
+ {
+ a_Player.GetInventory().RemoveOneEquippedItem();
+ }
}
- }
- else if (IsSitting())
+ break;
+ }
+ case E_ITEM_DYE:
{
- SetIsSitting(false);
+ if (a_Player.GetName() == m_OwnerName) // Is the player the owner of the dog?
+ {
+ SetCollarColor(15 - a_Player.GetEquippedItem().m_ItemDamage);
+ if (!a_Player.IsGameModeCreative())
+ {
+ a_Player.GetInventory().RemoveOneEquippedItem();
+ }
+ }
+ break;
}
- else
+ default:
{
- SetIsSitting(true);
+ if (a_Player.GetName() == m_OwnerName) // Is the player the owner of the dog?
+ {
+ SetIsSitting(!IsSitting());
+ }
}
}
}
@@ -136,6 +158,8 @@ void cWolf::Tick(float a_Dt, cChunk & a_Chunk)
case E_ITEM_RAW_CHICKEN:
case E_ITEM_COOKED_CHICKEN:
case E_ITEM_ROTTEN_FLESH:
+ case E_ITEM_RAW_PORKCHOP:
+ case E_ITEM_COOKED_PORKCHOP:
{
if (!IsBegging())
{
diff --git a/src/OSSupport/Queue.h b/src/OSSupport/Queue.h
index 6c3d58295..beb6a63f1 100644
--- a/src/OSSupport/Queue.h
+++ b/src/OSSupport/Queue.h
@@ -29,7 +29,11 @@ public:
static void Delete(T) {};
/// Called when an Item is inserted with EnqueueItemIfNotPresent and there is another equal value already inserted
- static void Combine(T & a_existing, const T & a_new) {};
+ static void Combine(T & a_existing, const T & a_new)
+ {
+ UNUSED(a_existing);
+ UNUSED(a_new);
+ };
};
diff --git a/src/Server.cpp b/src/Server.cpp
index ab1458da4..c60418b41 100644
--- a/src/Server.cpp
+++ b/src/Server.cpp
@@ -39,7 +39,9 @@ extern "C" {
// For the "dumpmem" server command:
/// Synchronize this with main.cpp - the leak finder needs initialization before it can be used to dump memory
-#define ENABLE_LEAK_FINDER
+// _X 2014_02_20: Disabled for canon repo, it makes the debug version too slow in MSVC2013
+// and we haven't had a memory leak for over a year anyway.
+// #define ENABLE_LEAK_FINDER
#if defined(_MSC_VER) && defined(_DEBUG) && defined(ENABLE_LEAK_FINDER)
#pragma warning(push)
diff --git a/src/Simulator/FireSimulator.cpp b/src/Simulator/FireSimulator.cpp
index d7c5ab3b4..b77fa1658 100644
--- a/src/Simulator/FireSimulator.cpp
+++ b/src/Simulator/FireSimulator.cpp
@@ -169,6 +169,7 @@ bool cFireSimulator::IsFuel(BLOCKTYPE a_BlockType)
case E_BLOCK_FENCE:
case E_BLOCK_TNT:
case E_BLOCK_VINES:
+ case E_BLOCK_HAY_BALE:
{
return true;
}
diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp
index 60dabaf84..91de9e0cc 100644
--- a/src/Simulator/IncrementalRedstoneSimulator.cpp
+++ b/src/Simulator/IncrementalRedstoneSimulator.cpp
@@ -6,6 +6,7 @@
#include "../BlockEntities/NoteEntity.h"
#include "../BlockEntities/CommandBlockEntity.h"
#include "../Entities/TNTEntity.h"
+#include "../Entities/Pickup.h"
#include "../Blocks/BlockTorch.h"
#include "../Blocks/BlockDoor.h"
#include "../Piston.h"
@@ -87,7 +88,8 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
((Block == E_BLOCK_LEVER) && !IsLeverOn(Meta)) ||
((Block == E_BLOCK_DETECTOR_RAIL) && (Meta & 0x08) == 0) ||
(((Block == E_BLOCK_STONE_BUTTON) || (Block == E_BLOCK_WOODEN_BUTTON)) && (!IsButtonOn(Meta))) ||
- (((Block == E_BLOCK_STONE_PRESSURE_PLATE) || (Block == E_BLOCK_WOODEN_PRESSURE_PLATE)) && (Meta == 0))
+ (((Block == E_BLOCK_STONE_PRESSURE_PLATE) || (Block == E_BLOCK_WOODEN_PRESSURE_PLATE)) && (Meta == 0)) ||
+ (((Block == E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE) || (Block == E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE)) && (Meta == 0))
)
{
LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from powered blocks list due to present/past metadata mismatch", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z);
@@ -313,6 +315,8 @@ void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int
}
case E_BLOCK_WOODEN_PRESSURE_PLATE:
case E_BLOCK_STONE_PRESSURE_PLATE:
+ case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE:
+ case E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE:
{
HandlePressurePlate(a_X, dataitr->y, a_Z, dataitr->Data);
break;
@@ -333,13 +337,13 @@ void cIncrementalRedstoneSimulator::WakeUp(int a_BlockX, int a_BlockY, int a_Blo
((a_BlockX % cChunkDef::Width) >= 14) ||
((a_BlockZ % cChunkDef::Width) <= 1) ||
((a_BlockZ % cChunkDef::Width) >= 14)
- ) // Are we on a chunk boundary? ± 2 because of LinkedPowered blocks
+ ) // Are we on a chunk boundary? +- 2 because of LinkedPowered blocks
{
// On a chunk boundary, alert all four sides (i.e. at least one neighbouring chunk)
AddBlock(a_BlockX, a_BlockY, a_BlockZ, a_Chunk);
// Pass the original coordinates, because when adding things to our simulator lists, we get the chunk that they are in, and therefore any updates need to preseve their position
- // RedstoneAddBlock to pass both the neighbouring chunk and the chunk which the coordiantes are in and ± 2 in GetNeighbour() to accomodate for LinkedPowered blocks being 2 away from chunk boundaries
+ // RedstoneAddBlock to pass both the neighbouring chunk and the chunk which the coordiantes are in and +- 2 in GetNeighbour() to accomodate for LinkedPowered blocks being 2 away from chunk boundaries
RedstoneAddBlock(a_BlockX, a_BlockY, a_BlockZ, a_Chunk->GetNeighborChunk(a_BlockX - 2, a_BlockZ), a_Chunk);
RedstoneAddBlock(a_BlockX, a_BlockY, a_BlockZ, a_Chunk->GetNeighborChunk(a_BlockX + 2, a_BlockZ), a_Chunk);
RedstoneAddBlock(a_BlockX, a_BlockY, a_BlockZ, a_Chunk->GetNeighborChunk(a_BlockX, a_BlockZ - 2), a_Chunk);
@@ -1039,13 +1043,15 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_BlockX, int a_Bloc
}
break;
}
+ case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE:
+ case E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE:
case E_BLOCK_WOODEN_PRESSURE_PLATE:
{
- class cWoodenPressurePlateCallback :
+ class cPressurePlateCallback :
public cEntityCallback
{
public:
- cWoodenPressurePlateCallback(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) :
+ cPressurePlateCallback(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) :
m_Entity(NULL),
m_World(a_World),
m_X(a_BlockX),
@@ -1063,7 +1069,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_BlockX, int a_Bloc
if (Distance <= 0.7)
{
m_Entity = a_Entity;
- return true; // Break out, we only need to know for wooden plates that at least one entity is on top
+ return true; // Break out, we only need to know for plates that at least one entity is on top
}
return false;
}
@@ -1082,16 +1088,25 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_BlockX, int a_Bloc
int m_Z;
} ;
- cWoodenPressurePlateCallback WoodenPressurePlateCallback(a_BlockX, a_BlockY, a_BlockZ, &m_World);
- m_World.ForEachEntity(WoodenPressurePlateCallback);
+ cPressurePlateCallback PressurePlateCallback(a_BlockX, a_BlockY, a_BlockZ, &m_World);
+ m_World.ForEachEntity(PressurePlateCallback);
- if (WoodenPressurePlateCallback.FoundEntity())
+ NIBBLETYPE Meta = m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
+ if (PressurePlateCallback.FoundEntity())
{
+ if (Meta == 0x0)
+ {
+ m_World.BroadcastSoundEffect("random.click", (int) ((a_BlockX + 0.5) * 8.0), (int) ((a_BlockY + 0.1) * 8.0), (int) ((a_BlockZ + 0.5) * 8.0), 0.3F, 0.5F);
+ }
m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, 0x1);
- SetAllDirsAsPowered(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_WOODEN_PRESSURE_PLATE);
+ SetAllDirsAsPowered(a_BlockX, a_BlockY, a_BlockZ, a_MyType);
}
else
{
+ if (Meta == 0x1)
+ {
+ m_World.BroadcastSoundEffect("random.click", (int) ((a_BlockX + 0.5) * 8.0), (int) ((a_BlockY + 0.1) * 8.0), (int) ((a_BlockZ + 0.5) * 8.0), 0.3F, 0.6F);
+ }
m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, 0x0);
m_World.WakeUpSimulators(a_BlockX, a_BlockY, a_BlockZ);
}
diff --git a/src/Simulator/SandSimulator.cpp b/src/Simulator/SandSimulator.cpp
index 87fb83357..f305ba61a 100644
--- a/src/Simulator/SandSimulator.cpp
+++ b/src/Simulator/SandSimulator.cpp
@@ -158,8 +158,10 @@ bool cSandSimulator::CanContinueFallThrough(BLOCKTYPE a_BlockType)
case E_BLOCK_DETECTOR_RAIL:
case E_BLOCK_FIRE:
case E_BLOCK_FLOWER_POT:
+ case E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE:
case E_BLOCK_LAVA:
case E_BLOCK_LEVER:
+ case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE:
case E_BLOCK_MINECART_TRACKS:
case E_BLOCK_MELON_STEM:
case E_BLOCK_POWERED_RAIL:
diff --git a/src/World.cpp b/src/World.cpp
index 4870e7d6e..ffdae2a37 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -1223,10 +1223,12 @@ void cWorld::GrowTreeFromSapling(int a_X, int a_Y, int a_Z, NIBBLETYPE a_Sapling
sSetBlockVector Logs, Other;
switch (a_SaplingMeta & 0x07)
{
- case E_META_SAPLING_APPLE: GetAppleTreeImage (a_X, a_Y, a_Z, Noise, (int)(m_WorldAge & 0xffffffff), Logs, Other); break;
- case E_META_SAPLING_BIRCH: GetBirchTreeImage (a_X, a_Y, a_Z, Noise, (int)(m_WorldAge & 0xffffffff), Logs, Other); break;
- case E_META_SAPLING_CONIFER: GetConiferTreeImage(a_X, a_Y, a_Z, Noise, (int)(m_WorldAge & 0xffffffff), Logs, Other); break;
- case E_META_SAPLING_JUNGLE: GetJungleTreeImage (a_X, a_Y, a_Z, Noise, (int)(m_WorldAge & 0xffffffff), Logs, Other); break;
+ case E_META_SAPLING_APPLE: GetAppleTreeImage (a_X, a_Y, a_Z, Noise, (int)(m_WorldAge & 0xffffffff), Logs, Other); break;
+ case E_META_SAPLING_BIRCH: GetBirchTreeImage (a_X, a_Y, a_Z, Noise, (int)(m_WorldAge & 0xffffffff), Logs, Other); break;
+ case E_META_SAPLING_CONIFER: GetConiferTreeImage(a_X, a_Y, a_Z, Noise, (int)(m_WorldAge & 0xffffffff), Logs, Other); break;
+ case E_META_SAPLING_JUNGLE: GetJungleTreeImage (a_X, a_Y, a_Z, Noise, (int)(m_WorldAge & 0xffffffff), Logs, Other); break;
+ case E_META_SAPLING_ACACIA: GetAcaciaTreeImage (a_X, a_Y, a_Z, Noise, (int)(m_WorldAge & 0xffffffff), Logs, Other); break;
+ case E_META_SAPLING_DARK_OAK: GetDarkoakTreeImage(a_X, a_Y, a_Z, Noise, (int)(m_WorldAge & 0xffffffff), Logs, Other); break;
}
Other.insert(Other.begin(), Logs.begin(), Logs.end());
Logs.clear();
diff --git a/src/main.cpp b/src/main.cpp
index c8cd2d4fe..4d2801926 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -30,7 +30,9 @@ bool g_ShouldLogCommOut;
/// If defined, a thorough leak finder will be used (debug MSVC only); leaks will be output to the Output window
-#define ENABLE_LEAK_FINDER
+// _X 2014_02_20: Disabled for canon repo, it makes the debug version too slow in MSVC2013
+// and we haven't had a memory leak for over a year anyway.
+// #define ENABLE_LEAK_FINDER