summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt3
-rw-r--r--MCServer/Plugins/.gitignore2
-rw-r--r--MCServer/Plugins/APIDump/APIDesc.lua5
-rw-r--r--src/Bindings/LuaState.cpp4
-rw-r--r--src/Bindings/ManualBindings.cpp11
-rw-r--r--src/BlockID.cpp3
-rw-r--r--src/Blocks/BlockChest.h6
-rw-r--r--src/Crypto.h2
-rw-r--r--src/Item.h4
-rw-r--r--src/Mobs/Monster.cpp12
-rw-r--r--src/Mobs/Monster.h1
-rw-r--r--src/Protocol/Protocol17x.cpp8
-rw-r--r--src/World.cpp2
-rw-r--r--src/World.h2
14 files changed, 48 insertions, 17 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c40767d20..1fee887e7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -60,6 +60,9 @@ else()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++11")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++11")
endif()
+
+ # We use a signed char (fixes #640 on RasPi)
+ add_flags_cxx("-fsigned-char")
endif()
diff --git a/MCServer/Plugins/.gitignore b/MCServer/Plugins/.gitignore
new file mode 100644
index 000000000..89eab800a
--- /dev/null
+++ b/MCServer/Plugins/.gitignore
@@ -0,0 +1,2 @@
+*.txt
+*.md
diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua
index cbdb7797b..20a97be19 100644
--- a/MCServer/Plugins/APIDump/APIDesc.lua
+++ b/MCServer/Plugins/APIDump/APIDesc.lua
@@ -1103,6 +1103,7 @@ These ItemGrids are available in the API and can be manipulated by the plugins,
GetMaxStackSize = { Params = "", Return = "number", Notes = "Returns the maximum stack size for this item." },
IsDamageable = { Params = "", Return = "bool", Notes = "Returns true if this item does account for its damage" },
IsEmpty = { Params = "", Return = "bool", Notes = "Returns true if this object represents an empty item (zero count or invalid ID)" },
+ IsEnchantable = { Params = "", Return = "bool", Notes = "Returns true if the item is enchantable" },
IsEqual = { Params = "cItem", Return = "bool", Notes = "Returns true if the item in the parameter is the same as the one stored in the object (type, damage and enchantments)" },
IsFullStack = { Params = "", Return = "bool", Notes = "Returns true if the item is stacked up to its maximum stacking" },
IsSameType = { Params = "cItem", Return = "bool", Notes = "Returns true if the item in the parameter is of the same ItemType as the one stored in the object. This is true even if the two items have different enchantments" },
@@ -1479,6 +1480,7 @@ a_Player:OpenWindow(Window);
GetMobType = { Params = "", Return = "{{cMonster#MobType|MobType}}", Notes = "Returns the type of this mob ({{cMonster#MobType|mtXXX}} constant)" },
GetSpawnDelay = { Params = "{{cMonster#MobFamily|MobFamily}}", Return = "number", Notes = "(STATIC) Returns the spawn delay - the number of game ticks between spawn attempts - for the specified mob family." },
MobTypeToString = { Params = "{{cMonster#MobType|MobType}}", Return = "string", Notes = "(STATIC) Returns the string representing the given mob type ({{cMonster#MobType|mtXXX}} constant), or empty string if unknown type." },
+ MoveToPosition = { Params = "Position", Return = "", Notes = "Moves mob to the specified position" },
StringToMobType = { Params = "string", Return = "{{cMonster#MobType|MobType}}", Notes = "(STATIC) Returns the mob type ({{cMonster#MobType|mtXXX}} constant) parsed from the string type (\"creeper\"), or mtInvalidType if unrecognized." },
},
Constants =
@@ -1745,10 +1747,11 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage);
GetCommandPermission = { Params = "Command", Return = "Permission", Notes = "Returns the permission needed for executing the specified command" },
GetCurrentPlugin = { Params = "", Return = "{{cPlugin}}", Notes = "Returns the {{cPlugin}} object for the calling plugin. This is the same object that the Initialize function receives as the argument." },
GetNumPlugins = { Params = "", Return = "number", Notes = "Returns the number of plugins, including the disabled ones" },
- GetPlugin = { Params = "PluginName", Return = "{{cPlugin}}", Notes = "Returns a plugin handle of the specified plugin" },
+ GetPlugin = { Params = "PluginName", Return = "{{cPlugin}}", Notes = "(<b>DEPRECATED, UNSAFE</b>) Returns a plugin handle of the specified plugin, or nil if such plugin is not loaded. Note thatdue to multithreading the handle is not guaranteed to be safe for use when stored - a single-plugin reload may have been triggered in the mean time for the requested plugin." },
IsCommandBound = { Params = "Command", Return = "bool", Notes = "Returns true if in-game Command is already bound (by any plugin)" },
IsConsoleCommandBound = { Params = "Command", Return = "bool", Notes = "Returns true if console Command is already bound (by any plugin)" },
LoadPlugin = { Params = "PluginFolder", Return = "", Notes = "(<b>DEPRECATED</b>) Loads a plugin from the specified folder. NOTE: Loading plugins may be an unsafe operation and may result in a deadlock or a crash. This API is deprecated and might be removed." },
+ LogStackTrace = { Params = "", Return = "", Notes = "(STATIC) Logs a current stack trace of the Lua engine to the server console log. Same format as is used when the plugin fails." },
ReloadPlugins = { Params = "", Return = "", Notes = "Reloads all active plugins" },
},
Constants =
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp
index 8dd17c448..ac5ce47e1 100644
--- a/src/Bindings/LuaState.cpp
+++ b/src/Bindings/LuaState.cpp
@@ -1018,9 +1018,7 @@ void cLuaState::LogStackTrace(lua_State * a_LuaState)
int depth = 0;
while (lua_getstack(a_LuaState, depth, &entry))
{
- int status = lua_getinfo(a_LuaState, "Sln", &entry);
- assert(status);
-
+ lua_getinfo(a_LuaState, "Sln", &entry);
LOGWARNING(" %s(%d): %s", entry.short_src, entry.currentline, entry.name ? entry.name : "(no name)");
depth++;
}
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp
index 9ebdc4b22..d476a3156 100644
--- a/src/Bindings/ManualBindings.cpp
+++ b/src/Bindings/ManualBindings.cpp
@@ -1106,6 +1106,16 @@ static int tolua_cPluginManager_GetCurrentPlugin(lua_State * S)
+static int tolua_cPluginManager_LogStackTrace(lua_State * S)
+{
+ cLuaState::LogStackTrace(S);
+ return 0;
+}
+
+
+
+
+
static int tolua_cPluginManager_AddHook_FnRef(cPluginManager * a_PluginManager, cLuaState & S, int a_ParamIdx)
{
// Helper function for cPluginmanager:AddHook() binding
@@ -2386,6 +2396,7 @@ void ManualBindings::Bind(lua_State * tolua_S)
tolua_function(tolua_S, "ForEachConsoleCommand", tolua_cPluginManager_ForEachConsoleCommand);
tolua_function(tolua_S, "GetAllPlugins", tolua_cPluginManager_GetAllPlugins);
tolua_function(tolua_S, "GetCurrentPlugin", tolua_cPluginManager_GetCurrentPlugin);
+ tolua_function(tolua_S, "LogStackTrace", tolua_cPluginManager_LogStackTrace);
tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S, "cPlayer");
diff --git a/src/BlockID.cpp b/src/BlockID.cpp
index de56d4625..c38db0bfe 100644
--- a/src/BlockID.cpp
+++ b/src/BlockID.cpp
@@ -380,7 +380,7 @@ AString DamageTypeToString(eDamageType a_DamageType)
case dtRangedAttack: return "dtRangedAttack";
case dtStarving: return "dtStarving";
case dtSuffocating: return "dtSuffocation";
-
+ case dtExplosion: return "dtExplosion";
}
// Unknown damage type:
@@ -426,6 +426,7 @@ eDamageType StringToDamageType(const AString & a_DamageTypeString)
{ dtInVoid, "dtInVoid"},
{ dtPotionOfHarming, "dtPotionOfHarming"},
{ dtAdmin, "dtAdmin"},
+ { dtExplosion, "dtExplosion"},
// Common synonyms:
{ dtAttack, "dtPawnAttack"},
diff --git a/src/Blocks/BlockChest.h b/src/Blocks/BlockChest.h
index c2ac8ae27..02ecc4346 100644
--- a/src/Blocks/BlockChest.h
+++ b/src/Blocks/BlockChest.h
@@ -110,9 +110,11 @@ public:
return "step.wood";
}
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, const cChunk & a_Chunk) override
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
- return CanBeAt(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ);
+ int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width;
+ int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
+ return CanBeAt(a_ChunkInterface, BlockX, a_RelY, BlockZ);
}
diff --git a/src/Crypto.h b/src/Crypto.h
index d68f7ec24..a9ec2c6d4 100644
--- a/src/Crypto.h
+++ b/src/Crypto.h
@@ -132,8 +132,6 @@ protected:
class cAESCFBEncryptor
{
public:
- Byte test;
-
cAESCFBEncryptor(void);
~cAESCFBEncryptor();
diff --git a/src/Item.h b/src/Item.h
index 1afb5938a..4782f31c1 100644
--- a/src/Item.h
+++ b/src/Item.h
@@ -167,16 +167,16 @@ public:
void FromJson(const Json::Value & a_Value);
/// Returns true if the specified item type is enchantable (as per 1.2.5 protocol requirements)
- static bool IsEnchantable(short a_ItemType);
+ static bool IsEnchantable(short a_ItemType); // tolua_export
// tolua_begin
short m_ItemType;
char m_ItemCount;
short m_ItemDamage;
+ cEnchantments m_Enchantments;
AString m_CustomName;
AString m_Lore;
- cEnchantments m_Enchantments;
};
// tolua_end
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 1b9bfaa79..be901ac61 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -191,6 +191,18 @@ void cMonster::MoveToPosition(const Vector3f & a_Position)
+
+void cMonster::MoveToPosition(const Vector3d & a_Position)
+{
+ FinishPathFinding();
+
+ m_FinalDestination = a_Position;
+ m_bMovingToDestination = true;
+ TickPathFinding();
+}
+
+
+
bool cMonster::IsCoordinateInTraversedList(Vector3i a_Coords)
{
for (std::vector<Vector3i>::const_iterator itr = m_TraversedCoordinates.begin(); itr != m_TraversedCoordinates.end(); ++itr)
diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h
index 1dd302cdc..714feddb9 100644
--- a/src/Mobs/Monster.h
+++ b/src/Mobs/Monster.h
@@ -91,6 +91,7 @@ public:
virtual void KilledBy(cEntity * a_Killer) override;
virtual void MoveToPosition(const Vector3f & a_Position);
+ virtual void MoveToPosition(const Vector3d & a_Position); // tolua_export
virtual bool ReachedDestination(void);
// tolua_begin
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index 434055fe4..57da48e49 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -99,7 +99,7 @@ void cProtocol172::DataReceived(const char * a_Data, int a_Size)
Byte Decrypted[512];
while (a_Size > 0)
{
- int NumBytes = (a_Size > sizeof(Decrypted)) ? sizeof(Decrypted) : a_Size;
+ size_t NumBytes = (a_Size > sizeof(Decrypted)) ? sizeof(Decrypted) : a_Size;
m_Decryptor.ProcessData(Decrypted, (Byte *)a_Data, NumBytes);
AddReceivedData((const char *)Decrypted, NumBytes);
a_Size -= NumBytes;
@@ -1479,7 +1479,7 @@ void cProtocol172::HandlePacketBlockDig(cByteBuffer & a_ByteBuffer)
HANDLE_READ(a_ByteBuffer, ReadBEInt, int, BlockX);
HANDLE_READ(a_ByteBuffer, ReadByte, Byte, BlockY);
HANDLE_READ(a_ByteBuffer, ReadBEInt, int, BlockZ);
- HANDLE_READ(a_ByteBuffer, ReadByte, Byte, Face);
+ HANDLE_READ(a_ByteBuffer, ReadChar, char, Face);
m_Client->HandleLeftClick(BlockX, BlockY, BlockZ, static_cast<eBlockFace>(Face), Status);
}
@@ -1492,7 +1492,7 @@ void cProtocol172::HandlePacketBlockPlace(cByteBuffer & a_ByteBuffer)
HANDLE_READ(a_ByteBuffer, ReadBEInt, int, BlockX);
HANDLE_READ(a_ByteBuffer, ReadByte, Byte, BlockY);
HANDLE_READ(a_ByteBuffer, ReadBEInt, int, BlockZ);
- HANDLE_READ(a_ByteBuffer, ReadByte, Byte, Face);
+ HANDLE_READ(a_ByteBuffer, ReadChar, char, Face);
cItem Item;
ReadItem(a_ByteBuffer, Item);
@@ -1836,7 +1836,7 @@ void cProtocol172::SendData(const char * a_Data, int a_Size)
Byte Encrypted[8192]; // Larger buffer, we may be sending lots of data (chunks)
while (a_Size > 0)
{
- int NumBytes = (a_Size > sizeof(Encrypted)) ? sizeof(Encrypted) : a_Size;
+ size_t NumBytes = ((size_t)a_Size > sizeof(Encrypted)) ? sizeof(Encrypted) : (size_t)a_Size;
m_Encryptor.ProcessData(Encrypted, (Byte *)a_Data, NumBytes);
m_Client->SendData((const char *)Encrypted, NumBytes);
a_Size -= NumBytes;
diff --git a/src/World.cpp b/src/World.cpp
index 892e04d63..5e08fd599 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -2339,7 +2339,7 @@ bool cWorld::FindAndDoWithPlayer(const AString & a_PlayerNameHint, cPlayerListCa
// TODO: This interface is dangerous!
-cPlayer * cWorld::FindClosestPlayer(const Vector3f & a_Pos, float a_SightLimit, bool a_CheckLineOfSight)
+cPlayer * cWorld::FindClosestPlayer(const Vector3d & a_Pos, float a_SightLimit, bool a_CheckLineOfSight)
{
cTracer LineOfSight(this);
diff --git a/src/World.h b/src/World.h
index afdc09788..8cf860ff5 100644
--- a/src/World.h
+++ b/src/World.h
@@ -248,7 +248,7 @@ public:
bool FindAndDoWithPlayer(const AString & a_PlayerNameHint, cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS <<
// TODO: This interface is dangerous - rewrite to DoWithClosestPlayer(pos, sight, action)
- cPlayer * FindClosestPlayer(const Vector3f & a_Pos, float a_SightLimit, bool a_CheckLineOfSight = true);
+ cPlayer * FindClosestPlayer(const Vector3d & a_Pos, float a_SightLimit, bool a_CheckLineOfSight = true);
void SendPlayerList(cPlayer * a_DestPlayer); // Sends playerlist to the player