summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xCIbuild.sh2
-rw-r--r--MCServer/Plugins/APIDump/main_APIDump.lua110
m---------MCServer/Plugins/Core0
-rw-r--r--src/Bindings/AllToLua.pkg4
-rw-r--r--src/Bindings/LuaWindow.h6
-rw-r--r--src/Bindings/ManualBindings.cpp6
-rw-r--r--src/BlockEntities/BlockEntityWithItems.h2
-rw-r--r--src/Inventory.h2
-rw-r--r--src/Map.h5
-rw-r--r--src/Simulator/FloodyFluidSimulator.cpp3
-rw-r--r--src/WebAdmin.h2
11 files changed, 130 insertions, 12 deletions
diff --git a/CIbuild.sh b/CIbuild.sh
index 755dc7daa..f5a9005da 100755
--- a/CIbuild.sh
+++ b/CIbuild.sh
@@ -11,7 +11,7 @@ cd src
lua CheckBasicStyle.lua
cd ..
make -j 2;
-make -j 2 test;
+make -j 2 test ARGS="-V";
cd MCServer/;
if [ "$TRAVIS_MCSERVER_BUILD_TYPE" != "COVERAGE" ]
then echo stop | $MCSERVER_PATH;
diff --git a/MCServer/Plugins/APIDump/main_APIDump.lua b/MCServer/Plugins/APIDump/main_APIDump.lua
index a25bab9cf..239bec69c 100644
--- a/MCServer/Plugins/APIDump/main_APIDump.lua
+++ b/MCServer/Plugins/APIDump/main_APIDump.lua
@@ -62,7 +62,7 @@ local function CreateAPITables()
Variables = {
},
Descendants = {}, -- Will be filled by ReadDescriptions(), array of class APIs (references to other member in the tree)
- }},
+ },
{
Name = "cBlockArea",
Functions = {
@@ -78,7 +78,9 @@ local function CreateAPITables()
Variables = {
},
...
- }}
+ },
+
+ cCuboid = {} -- Each array item also has the map item by its name
};
local Globals = {
Functions = {
@@ -135,7 +137,9 @@ local function CreateAPITables()
(v ~= g_APIDesc)
) then
if (type(v) == "table") then
- table.insert(API, ParseClass(i, v));
+ local cls = ParseClass(i, v)
+ table.insert(API, cls);
+ API[cls.Name] = cls
else
Add(Globals, i, v);
end
@@ -1449,6 +1453,103 @@ end
+--- Returns true if a_Descendant is declared to be a (possibly indirect) descendant of a_Base
+local function IsDeclaredDescendant(a_DescendantName, a_BaseName, a_API)
+ -- Check params:
+ assert(type(a_DescendantName) == "string")
+ assert(type(a_BaseName) == "string")
+ assert(type(a_API) == "table")
+ if not(a_API[a_BaseName]) then
+ return false
+ end
+ assert(type(a_API[a_BaseName]) == "table", "Not a class name: " .. a_BaseName)
+ assert(type(a_API[a_BaseName].Descendants) == "table")
+
+ -- Check direct inheritance:
+ for _, desc in ipairs(a_API[a_BaseName].Descendants) do
+ if (desc.Name == a_DescendantName) then
+ return true
+ end
+ end -- for desc - a_BaseName's descendants
+
+ -- Check indirect inheritance:
+ for _, desc in ipairs(a_API[a_BaseName].Descendants) do
+ if (IsDeclaredDescendant(a_DescendantName, desc.Name, a_API)) then
+ return true
+ end
+ end -- for desc - a_BaseName's descendants
+
+ return false
+end
+
+
+
+
+
+--- Checks the specified class' inheritance
+-- Reports any problems as new items in the a_Report table
+local function CheckClassInheritance(a_Class, a_API, a_Report)
+ -- Check params:
+ assert(type(a_Class) == "table")
+ assert(type(a_API) == "table")
+ assert(type(a_Report) == "table")
+
+ -- Check that the declared descendants are really descendants:
+ local registry = debug.getregistry()
+ for _, desc in ipairs(a_Class.Descendants or {}) do
+ local isParent = false
+ local parents = registry["tolua_super"][_G[desc.Name]]
+ if not(parents[a_Class.Name]) then
+ table.insert(a_Report, desc.Name .. " is not a descendant of " .. a_Class.Name)
+ end
+ end -- for desc - a_Class.Descendants[]
+
+ -- Check that all inheritance is listed for the class:
+ local parents = registry["tolua_super"][_G[a_Class.Name]] -- map of "classname" -> true for each class that a_Class inherits
+ for clsName, isParent in pairs(parents or {}) do
+ if ((clsName ~= "") and not(clsName:match("const .*"))) then
+ if not(IsDeclaredDescendant(a_Class.Name, clsName, a_API)) then
+ table.insert(a_Report, a_Class.Name .. " inherits from " .. clsName .. " but this isn't documented")
+ end
+ end
+ end
+end
+
+
+
+
+
+--- Checks each class's declared inheritance versus the actual inheritance
+local function CheckAPIDescendants(a_API)
+ -- Check each class:
+ local report = {}
+ for _, cls in ipairs(a_API) do
+ if (cls.Name ~= "Globals") then
+ CheckClassInheritance(cls, a_API, report)
+ end
+ end
+
+ -- If there's anything to report, output it to a file:
+ if (report[1] ~= nil) then
+ LOG("There are inheritance errors in the API description:")
+ for _, msg in ipairs(report) do
+ LOG(" " .. msg)
+ end
+
+ local f, err = io.open("API/_inheritance_errors.txt", "w")
+ if (f == nil) then
+ LOG("Cannot report inheritance problems to a file: " .. tostring(err))
+ return
+ end
+ f:write(table.concat(report, "\n"))
+ f:close()
+ end
+end
+
+
+
+
+
local function DumpApi()
LOG("Dumping the API...")
@@ -1501,6 +1602,9 @@ local function DumpApi()
LOG("Reading descriptions...");
ReadDescriptions(API);
+ -- Check that the API lists the inheritance properly, report any problems to a file:
+ CheckAPIDescendants(API)
+
-- Dump all available API objects in HTML format into a subfolder:
DumpAPIHtml(API);
diff --git a/MCServer/Plugins/Core b/MCServer/Plugins/Core
-Subproject 6e9d612b9eb548d888d2bf986488aad762a99be
+Subproject ee3cd9ba917baa94d6b9bfe7c9205609e0722fa
diff --git a/src/Bindings/AllToLua.pkg b/src/Bindings/AllToLua.pkg
index cea86f432..8f55eba07 100644
--- a/src/Bindings/AllToLua.pkg
+++ b/src/Bindings/AllToLua.pkg
@@ -42,7 +42,6 @@ $cfile "WebPlugin.h"
$cfile "LuaWindow.h"
$cfile "../BlockID.h"
-$cfile "../Mobs/MonsterTypes.h"
$cfile "../BlockInfo.h"
$cfile "../StringUtils.h"
$cfile "../Defines.h"
@@ -63,7 +62,6 @@ $cfile "../BlockArea.h"
$cfile "../Generating/ChunkDesc.h"
$cfile "../CraftingRecipes.h"
$cfile "../UI/Window.h"
-$cfile "../Mobs/Monster.h"
$cfile "../CompositeChat.h"
$cfile "../Map.h"
$cfile "../MapManager.h"
@@ -93,6 +91,8 @@ $cfile "../Entities/ThrownEnderPearlEntity.h"
$cfile "../Entities/ThrownSnowballEntity.h"
$cfile "../Entities/TNTEntity.h"
$cfile "../Entities/WitherSkullEntity.h"
+$cfile "../Mobs/MonsterTypes.h"
+$cfile "../Mobs/Monster.h"
// Block entities:
$cfile "../BlockEntities/BlockEntity.h"
diff --git a/src/Bindings/LuaWindow.h b/src/Bindings/LuaWindow.h
index 76530d99d..d4fc58660 100644
--- a/src/Bindings/LuaWindow.h
+++ b/src/Bindings/LuaWindow.h
@@ -35,8 +35,10 @@ This reference needs to be unreferenced in the Destroy() function.
*/
// tolua_begin
class cLuaWindow :
- public cWindow,
- public cItemGrid::cListener
+ public cWindow
+ // tolua_end
+ , public cItemGrid::cListener
+ // tolua_begin
{
typedef cWindow super;
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp
index e93b11eaa..035be55ae 100644
--- a/src/Bindings/ManualBindings.cpp
+++ b/src/Bindings/ManualBindings.cpp
@@ -638,11 +638,11 @@ static int tolua_DoWithID(lua_State* tolua_S)
private:
virtual bool Item(Ty2 * a_Item) override
{
- lua_rawgeti(LuaState, LUA_REGISTRYINDEX, FuncRef); // Push function to call
- tolua_pushusertype(LuaState, a_Item, Ty2::GetClassStatic()); // Push the item
+ lua_rawgeti(LuaState, LUA_REGISTRYINDEX, FuncRef); // Push function to call
+ tolua_pushusertype(LuaState, a_Item, a_Item->GetClass()); // Push the item
if (TableRef != LUA_REFNIL)
{
- lua_rawgeti(LuaState, LUA_REGISTRYINDEX, TableRef); // Push the optional callbackdata param
+ lua_rawgeti(LuaState, LUA_REGISTRYINDEX, TableRef); // Push the optional callbackdata param
}
int s = lua_pcall(LuaState, (TableRef == LUA_REFNIL ? 1 : 2), 1, 0);
diff --git a/src/BlockEntities/BlockEntityWithItems.h b/src/BlockEntities/BlockEntityWithItems.h
index 2c2ced1cb..740dbca51 100644
--- a/src/BlockEntities/BlockEntityWithItems.h
+++ b/src/BlockEntities/BlockEntityWithItems.h
@@ -21,7 +21,9 @@
// tolua_begin
class cBlockEntityWithItems :
public cBlockEntity,
+ // tolua_end
public cItemGrid::cListener,
+ // tolua_begin
public cBlockEntityWindowOwner
{
typedef cBlockEntity super;
diff --git a/src/Inventory.h b/src/Inventory.h
index 4e76bc0d3..311f64562 100644
--- a/src/Inventory.h
+++ b/src/Inventory.h
@@ -31,7 +31,9 @@ You can use the invArmorOffset, invInventoryOffset and invHotbarOffset constants
*/
class cInventory :
+ // tolua_end
public cItemGrid::cListener
+ // tolua_begin
{
public:
diff --git a/src/Map.h b/src/Map.h
index fe324a5e7..3e775231a 100644
--- a/src/Map.h
+++ b/src/Map.h
@@ -189,6 +189,11 @@ public:
return "cMap";
}
+ const char * GetClass(void) // Needed for ManualBindings' DoWith templates
+ {
+ return "cMap";
+ }
+
protected:
diff --git a/src/Simulator/FloodyFluidSimulator.cpp b/src/Simulator/FloodyFluidSimulator.cpp
index bcd083294..a9481edb0 100644
--- a/src/Simulator/FloodyFluidSimulator.cpp
+++ b/src/Simulator/FloodyFluidSimulator.cpp
@@ -108,8 +108,9 @@ void cFloodyFluidSimulator::SimulateBlock(cChunk * a_Chunk, int a_RelX, int a_Re
{
SpreadXZ(a_Chunk, a_RelX, a_RelY, a_RelZ, NewMeta);
}
+
// If source creation is on, check for it here:
- else if (
+ if (
(m_NumNeighborsForSource > 0) && // Source creation is on
(MyMeta == m_Falloff) && // Only exactly one block away from a source (fast bail-out)
!IsPassableForFluid(Below) && // Only exactly 1 block deep
diff --git a/src/WebAdmin.h b/src/WebAdmin.h
index 86a8a9a4b..1e1a9bfa9 100644
--- a/src/WebAdmin.h
+++ b/src/WebAdmin.h
@@ -95,7 +95,9 @@ struct sWebAdminPage
// tolua_begin
class cWebAdmin :
+ // tolua_end
public cHTTPServer::cCallbacks
+ // tolua_begin
{
public:
// tolua_end