summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Bindings/BindingsProcessor.lua56
-rw-r--r--src/Bindings/ManualBindings.cpp185
-rw-r--r--src/Bindings/ManualBindings_RankManager.cpp87
-rw-r--r--src/Bindings/PluginLua.cpp1
-rw-r--r--src/Blocks/BlockLeaves.h2
-rw-r--r--src/ClientHandle.cpp12
-rw-r--r--src/CompositeChat.cpp5
-rw-r--r--src/CompositeChat.h26
-rw-r--r--src/Defines.h3
-rw-r--r--src/Entities/Entity.cpp4
-rw-r--r--src/Entities/Player.cpp1
-rw-r--r--src/Generating/FinishGen.cpp4
-rw-r--r--src/Item.h4
-rw-r--r--src/Mobs/Monster.h2
-rw-r--r--src/Protocol/Protocol110x.cpp11
-rw-r--r--src/World.h3
-rw-r--r--src/WorldStorage/MapSerializer.cpp2
-rw-r--r--src/WorldStorage/SchematicFileSerializer.cpp2
18 files changed, 252 insertions, 158 deletions
diff --git a/src/Bindings/BindingsProcessor.lua b/src/Bindings/BindingsProcessor.lua
index df479a634..4bea64435 100644
--- a/src/Bindings/BindingsProcessor.lua
+++ b/src/Bindings/BindingsProcessor.lua
@@ -25,7 +25,7 @@ Placeholders in use (i = internal ToLua++):
- \3 and \4: (i) Embedded C code ("<>")
- \5 and \6: (i) Embedded C code ("{}")
- \17 and \18: DoxyComment for next item ("/** ... */") via an ID lookup
- - \19 and \20: DocyComment for previous item ("///< ... \n") via an ID lookup
+ - \19 and \20: DoxyComment for previous item ("///< ... \n") via an ID lookup
--]]
@@ -121,7 +121,7 @@ function parser_hook(a_Code)
return strsub(a_Code, e) -- normally we would use 'e + 1', but we need to preserve the [^:]
end
end
-
+
-- Process forward DoxyComments:
do
local b, e, comment = a_Code:find("^%s*(%b\17\18)")
@@ -135,7 +135,7 @@ function parser_hook(a_Code)
return strsub(a_Code, e + 1)
end
end
-
+
-- Process backward DoxyComments:
do
local b, e, comment = a_Code:find("^%s*(%b\19\20)")
@@ -200,7 +200,7 @@ local function OutputLuaStateHelpers(a_Package)
f:write("\n\n\n\n\n")
f:close()
end
-
+
-- Output the Push() and GetStackValue() function declarations:
do
local f = assert(io.open("LuaState_Declaration.inc", "w"))
@@ -342,12 +342,12 @@ local function outputClassFunctionDocs(a_File, a_Class, a_Functions)
return (a_Fn1.Name < a_Fn2.Name)
end
)
-
+
-- If there are no functions, bail out:
if not(functions[1]) then
return
end
-
+
-- Output the descriptions:
a_File:write("\t\tFunctions =\n\t\t{\n")
for _, fn in ipairs(functions) do
@@ -401,12 +401,12 @@ local function outputClassVariableDocs(a_File, a_Class, a_Variables)
return (a_Var1.Name < a_Var2.Name)
end
)
-
+
-- If there are no variables, bail out:
if not(variables[1]) then
return
end
-
+
-- Output the descriptions:
a_File:write("\t\tVariables =\n\t\t{\n")
for _, v in ipairs(variables) do
@@ -442,12 +442,12 @@ local function outputClassConstantDocs(a_File, a_Class, a_Constants, a_IgnoredCo
return (a_Var1.Name < a_Var2.Name)
end
)
-
+
-- If there are no constants, bail out:
if not(constants[1]) then
return
end
-
+
-- Output the descriptions:
a_File:write("\t\tConstants =\n\t\t{\n")
for _, con in ipairs(constants) do
@@ -474,14 +474,14 @@ local function outputClassEnumDocs(a_File, a_Class, a_Enums)
if (not(a_Enums) or not(a_Enums[1])) then
return
end
-
+
-- Sort the enums by name:
table.sort(a_Enums,
function (a_Enum1, a_Enum2)
return (a_Enum1.name < a_Enum2.name)
end
)
-
+
-- Output the enums:
a_File:write("\t\tEnums =\n\t\t{\n")
for i, enum in ipairs(a_Enums) do
@@ -540,7 +540,7 @@ local function outputClassDocs(a_Class, a_Functions, a_Variables, a_Constants, a
if (a_Class.DoxyComment) then
f:write("\t\tDesc = ", string.format("%q", a_Class.DoxyComment), ",\n")
end
-
+
-- If the class inherits from anything, output it here:
local ignoredConstants = {}
if (a_Class.base and (a_Class.base ~= "")) then
@@ -559,19 +559,19 @@ local function outputClassDocs(a_Class, a_Functions, a_Variables, a_Constants, a
end
f:write("\t\t},\n")
end
-
+
-- Output the functions:
outputClassFunctionDocs(f, a_Class, a_Functions)
-
+
-- Output the variables:
outputClassVariableDocs(f, a_Class, a_Variables)
-
+
-- Output the constants:
outputClassConstantDocs(f, a_Class, a_Constants, ignoredConstants)
-
+
-- Output the enums:
outputClassEnumDocs(f, a_Class, a_Class.enums)
-
+
-- Output the footer:
f:write("\t},\n}\n")
f:close()
@@ -616,7 +616,7 @@ local function genPackageDocs(a_Self)
f:close()
end
end
-
+
applyNextDoxyComments(a_Self)
-- Generate docs for each member:
@@ -631,7 +631,7 @@ local function genPackageDocs(a_Self)
end
i = i + 1
end
-
+
-- Output the globals' docs:
local functions = {}
local variables = {}
@@ -646,7 +646,7 @@ local function genPackageDocs(a_Self)
a_Self.lname = "Globals"
outputClassDocs(a_Self, functions, variables, constants, filenames)
a_Self.lname = oldName
-
+
-- Output the list of docs files:
table.sort(filenames)
local f = assert(io.open("docs/_files.lua", "w"))
@@ -686,7 +686,7 @@ local function genClassDocs(a_Self, a_Filenames)
end
i = i + 1
end
-
+
-- Output the individual docs
outputClassDocs(a_Self, functions, variables, constants, a_Filenames)
end
@@ -706,7 +706,7 @@ local function parseFunctionParameters(a_Function)
) then
return {}
end
-
+
local res = {}
local idx = 1
for _, param in ipairs(a_Function.args or {}) do
@@ -751,7 +751,7 @@ end
local function genFunctionMemberDocs(a_Self, a_Functions, a_Variables, a_Constants)
assert(a_Self.lname)
-
+
local fn = a_Functions[a_Self.lname] or {}
a_Functions[a_Self.lname] = fn
@@ -776,14 +776,14 @@ end
local function genVariableMemberDocs(a_Self, a_Functions, a_Variables, a_Constants)
assert(a_Self.lname)
-
+
local desc =
{
Name = a_Self.lname,
Type = a_Self.type,
DoxyComment = a_Self.DoxyComment,
}
-
+
if (string.find(a_Self.type,'const%s+') or string.find(a_Self.mod, 'tolua_readonly') or string.find(a_Self.mod, 'tolua_inherits')) then
a_Constants[a_Self.lname] = desc
else
@@ -806,7 +806,7 @@ local function generateDocs(a_Package)
return false, "Cannot access the docs folder: " .. msg
end
f:close()
-
+
-- Generate the docs:
classPackage.genDocs = genPackageDocs
classClass.genDocs = genClassDocs
@@ -858,7 +858,7 @@ end
function preprocess_hook(a_Package)
assert(a_Package)
assert(type(a_Package.code) == "string")
-
+
-- Replace all DoxyComments with placeholders so that they aren't erased later on:
a_Package.code = a_Package.code
:gsub("/%*%*%s*(.-)%s*%*/",
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp
index 038c67995..083a30f2a 100644
--- a/src/Bindings/ManualBindings.cpp
+++ b/src/Bindings/ManualBindings.cpp
@@ -1315,8 +1315,9 @@ static int tolua_cPluginManager_ForEachConsoleCommand(lua_State * tolua_S)
static int tolua_cPluginManager_BindCommand(lua_State * a_LuaState)
{
/* Function signatures:
- cPluginManager:BindCommand(Command, Permission, Function, HelpString)
- cPluginManager.BindCommand(Command, Permission, Function, HelpString) -- without the "self" param
+ cPluginManager:Get():BindCommand(Command, Permission, Function, HelpString) -- regular
+ cPluginManager:BindCommand(Command, Permission, Function, HelpString) -- static
+ cPluginManager.BindCommand(Command, Permission, Function, HelpString) -- without the "self" param
*/
cLuaState L(a_LuaState);
cPluginLua * Plugin = cManualBindings::GetLuaPlugin(L);
@@ -1379,8 +1380,9 @@ static int tolua_cPluginManager_BindCommand(lua_State * a_LuaState)
static int tolua_cPluginManager_BindConsoleCommand(lua_State * a_LuaState)
{
/* Function signatures:
- cPluginManager:BindConsoleCommand(Command, Function, HelpString)
- cPluginManager.BindConsoleCommand(Command, Function, HelpString) -- without the "self" param
+ cPluginManager:Get():BindConsoleCommand(Command, Function, HelpString) -- regular
+ cPluginManager:BindConsoleCommand(Command, Function, HelpString) -- static
+ cPluginManager.BindConsoleCommand(Command, Function, HelpString) -- without the "self" param
*/
// Get the plugin identification out of LuaState:
@@ -1908,20 +1910,17 @@ static int tolua_sha1HexString(lua_State * tolua_S)
-static int tolua_push_StringStringMap(lua_State* tolua_S, std::map< std::string, std::string >& a_StringStringMap)
+static int tolua_get_HTTPRequest_Params(lua_State * a_LuaState)
{
- lua_newtable(tolua_S);
- int top = lua_gettop(tolua_S);
-
- for (std::map<std::string, std::string>::iterator it = a_StringStringMap.begin(); it != a_StringStringMap.end(); ++it)
+ cLuaState L(a_LuaState);
+ HTTPRequest * self;
+ if (!L.GetStackValues(1, self))
{
- const char * key = it->first.c_str();
- const char * value = it->second.c_str();
- lua_pushstring(tolua_S, key);
- lua_pushstring(tolua_S, value);
- lua_settable(tolua_S, top);
+ tolua_Error err;
+ tolua_error(a_LuaState, "Invalid self parameter, expected a HTTPRequest instance", &err);
+ return 0;
}
-
+ L.Push(self->Params);
return 1;
}
@@ -1929,40 +1928,44 @@ static int tolua_push_StringStringMap(lua_State* tolua_S, std::map< std::string,
-static int tolua_get_HTTPRequest_Params(lua_State* tolua_S)
-{
- HTTPRequest * self = reinterpret_cast<HTTPRequest *>(tolua_tousertype(tolua_S, 1, nullptr));
- return tolua_push_StringStringMap(tolua_S, self->Params);
-}
-
-
-
-
-
-static int tolua_get_HTTPRequest_PostParams(lua_State* tolua_S)
+static int tolua_get_HTTPRequest_PostParams(lua_State * a_LuaState)
{
- HTTPRequest * self = reinterpret_cast<HTTPRequest *>(tolua_tousertype(tolua_S, 1, nullptr));
- return tolua_push_StringStringMap(tolua_S, self->PostParams);
+ cLuaState L(a_LuaState);
+ HTTPRequest * self;
+ if (!L.GetStackValues(1, self))
+ {
+ tolua_Error err;
+ tolua_error(a_LuaState, "Invalid self parameter, expected a HTTPRequest instance", &err);
+ return 0;
+ }
+ L.Push(self->PostParams);
+ return 1;
}
-static int tolua_get_HTTPRequest_FormData(lua_State* tolua_S)
+static int tolua_get_HTTPRequest_FormData(lua_State* a_LuaState)
{
- HTTPRequest * self = reinterpret_cast<HTTPRequest *>(tolua_tousertype(tolua_S, 1, nullptr));
- std::map<std::string, HTTPFormData> & FormData = self->FormData;
-
- lua_newtable(tolua_S);
- int top = lua_gettop(tolua_S);
+ cLuaState L(a_LuaState);
+ HTTPRequest * self;
+ if (!L.GetStackValues(1, self))
+ {
+ tolua_Error err;
+ tolua_error(a_LuaState, "Invalid self parameter, expected a HTTPRequest instance", &err);
+ return 0;
+ }
- for (std::map<std::string, HTTPFormData>::iterator it = FormData.begin(); it != FormData.end(); ++it)
+ const auto & FormData = self->FormData;
+ lua_newtable(a_LuaState);
+ int top = lua_gettop(a_LuaState);
+ for (auto itr = FormData.cbegin(); itr != FormData.cend(); ++itr)
{
- lua_pushstring(tolua_S, it->first.c_str());
- tolua_pushusertype(tolua_S, &(it->second), "HTTPFormData");
- // lua_pushlstring(tolua_S, it->second.Value.c_str(), it->second.Value.size()); // Might contain binary data
- lua_settable(tolua_S, top);
+ lua_pushstring(a_LuaState, itr->first.c_str());
+ tolua_pushusertype(a_LuaState, const_cast<void *>(reinterpret_cast<const void *>(&(itr->second))), "HTTPFormData");
+ // lua_pushlstring(a_LuaState, it->second.Value.c_str(), it->second.Value.size()); // Might contain binary data
+ lua_settable(a_LuaState, top);
}
return 1;
@@ -3453,6 +3456,69 @@ static int tolua_cChunkDesc_GetBlockTypeMeta(lua_State * a_LuaState)
+static int tolua_cCompositeChat_new(lua_State * a_LuaState)
+{
+ /* Function signatures:
+ cCompositeChat()
+ cCompositeChat(a_ParseText, a_MessageType)
+ */
+
+ // Check if it's the no-param version:
+ cLuaState L(a_LuaState);
+ if (lua_isnone(a_LuaState, 2))
+ {
+ auto * res = static_cast<cCompositeChat *>(Mtolua_new(cCompositeChat()));
+ L.Push(res);
+ return 1;
+ }
+
+ // Check the second signature:
+ AString parseText;
+ if (!L.GetStackValue(2, parseText))
+ {
+ tolua_Error err;
+ tolua_error(a_LuaState, "Invalid ParseText parameter (1) in cCompositeChat constructor.", &err);
+ return 0;
+ }
+ int messageTypeInt = mtCustom;
+ if (!lua_isnone(a_LuaState, 3))
+ {
+ if (!L.GetStackValue(3, messageTypeInt))
+ {
+ tolua_Error err;
+ tolua_error(a_LuaState, "Invalid type of the MessageType parameter (2) in cCompositeChat constructor.", &err);
+ return 0;
+ }
+ if ((messageTypeInt < 0) || (messageTypeInt >= mtMaxPlusOne))
+ {
+ tolua_Error err;
+ tolua_error(a_LuaState, "Invalid MessageType parameter (2) value in cCompositeChat constructor.", &err);
+ return 0;
+ }
+ }
+ L.Push(static_cast<cCompositeChat *>(Mtolua_new(cCompositeChat(parseText, static_cast<eMessageType>(messageTypeInt)))));
+ return 1;
+}
+
+
+
+
+
+static int tolua_cCompositeChat_new_local(lua_State * a_LuaState)
+{
+ // Use the same constructor as global, just register it for GC:
+ auto res = tolua_cCompositeChat_new(a_LuaState);
+ if (res == 1)
+ {
+ tolua_register_gc(a_LuaState, lua_gettop(a_LuaState));
+ }
+ return res;
+}
+
+
+
+
+
static int tolua_cCompositeChat_AddRunCommandPart(lua_State * tolua_S)
{
// function cCompositeChat:AddRunCommandPart(Message, Command, [Style])
@@ -3475,7 +3541,7 @@ static int tolua_cCompositeChat_AddRunCommandPart(lua_State * tolua_S)
}
// Add the part:
- AString Text, Command, Style;
+ AString Text, Command, Style = "u@a";
L.GetStackValue(2, Text);
L.GetStackValue(3, Command);
L.GetStackValue(4, Style);
@@ -3600,6 +3666,39 @@ static int tolua_cCompositeChat_AddUrlPart(lua_State * tolua_S)
+static int tolua_cCompositeChat_Clear(lua_State * tolua_S)
+{
+ // function cCompositeChat:Clear()
+ // Exported manually to support call-chaining (return *this)
+
+ // Check params:
+ cLuaState L(tolua_S);
+ if (
+ !L.CheckParamUserType(1, "cCompositeChat") ||
+ !L.CheckParamEnd(2)
+ )
+ {
+ return 0;
+ }
+ cCompositeChat * self = reinterpret_cast<cCompositeChat *>(tolua_tousertype(tolua_S, 1, nullptr));
+ if (self == nullptr)
+ {
+ tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:ParseText'", nullptr);
+ return 0;
+ }
+
+ // Clear all the parts:
+ self->Clear();
+
+ // Cut away everything from the stack except for the cCompositeChat instance; return that:
+ lua_settop(L, 1);
+ return 1;
+}
+
+
+
+
+
static int tolua_cCompositeChat_ParseText(lua_State * tolua_S)
{
// function cCompositeChat:ParseText(TextMessage)
@@ -3673,7 +3772,7 @@ static int tolua_cCompositeChat_SetMessageType(lua_State * tolua_S)
static int tolua_cCompositeChat_UnderlineUrls(lua_State * tolua_S)
{
// function cCompositeChat:UnderlineUrls()
- // Exported manually to support call-chaining (return *this)
+ // Exported manually to support call-chaining (return self)
// Check params:
cLuaState L(tolua_S);
@@ -3757,10 +3856,14 @@ void cManualBindings::Bind(lua_State * tolua_S)
tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S, "cCompositeChat");
+ tolua_function(tolua_S, "new", tolua_cCompositeChat_new);
+ tolua_function(tolua_S, "new_local", tolua_cCompositeChat_new_local);
+ tolua_function(tolua_S, ".call", tolua_cCompositeChat_new_local);
tolua_function(tolua_S, "AddRunCommandPart", tolua_cCompositeChat_AddRunCommandPart);
tolua_function(tolua_S, "AddSuggestCommandPart", tolua_cCompositeChat_AddSuggestCommandPart);
tolua_function(tolua_S, "AddTextPart", tolua_cCompositeChat_AddTextPart);
tolua_function(tolua_S, "AddUrlPart", tolua_cCompositeChat_AddUrlPart);
+ tolua_function(tolua_S, "Clear", tolua_cCompositeChat_Clear);
tolua_function(tolua_S, "ParseText", tolua_cCompositeChat_ParseText);
tolua_function(tolua_S, "SetMessageType", tolua_cCompositeChat_SetMessageType);
tolua_function(tolua_S, "UnderlineUrls", tolua_cCompositeChat_UnderlineUrls);
diff --git a/src/Bindings/ManualBindings_RankManager.cpp b/src/Bindings/ManualBindings_RankManager.cpp
index 7871c26ef..84ca67c4e 100644
--- a/src/Bindings/ManualBindings_RankManager.cpp
+++ b/src/Bindings/ManualBindings_RankManager.cpp
@@ -100,58 +100,58 @@ static int tolua_cRankManager_AddPermissionToGroup(lua_State * L)
-/** Binds cRankManager::AddRestrictionToGroup */
-static int tolua_cRankManager_AddRestrictionToGroup(lua_State * L)
+/** Binds cRankManager::AddRank */
+static int tolua_cRankManager_AddRank(lua_State * L)
{
// Function signature:
- // cRankManager:AddRestrictionToGroup(Permission, GroupName) -> bool
+ // cRankManager:AddRank(RankName)
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
- !S.CheckParamString(2, 3) ||
- !S.CheckParamEnd(4)
+ !S.CheckParamString(2, 5) ||
+ !S.CheckParamEnd(6)
)
{
return 0;
}
// Read the params:
- AString GroupName, Permission;
- S.GetStackValues(2, Permission, GroupName);
+ AString RankName, MsgPrefix, MsgSuffix, MsgNameColorCode;
+ S.GetStackValues(2, RankName, MsgPrefix, MsgSuffix, MsgNameColorCode);
- // Add the group to the rank:
- S.Push(cRoot::Get()->GetRankManager()->AddRestrictionToGroup(Permission, GroupName));
- return 1;
+ // Add the rank:
+ cRoot::Get()->GetRankManager()->AddRank(RankName, MsgPrefix, MsgSuffix, MsgNameColorCode);
+ return 0;
}
-/** Binds cRankManager::AddRank */
-static int tolua_cRankManager_AddRank(lua_State * L)
+/** Binds cRankManager::AddRestrictionToGroup */
+static int tolua_cRankManager_AddRestrictionToGroup(lua_State * L)
{
// Function signature:
- // cRankManager:AddRank(RankName)
+ // cRankManager:AddRestrictionToGroup(Restriction, GroupName) -> bool
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
- !S.CheckParamString(2, 5) ||
- !S.CheckParamEnd(6)
+ !S.CheckParamString(2, 3) ||
+ !S.CheckParamEnd(4)
)
{
return 0;
}
// Read the params:
- AString RankName, MsgPrefix, MsgSuffix, MsgNameColorCode;
- S.GetStackValues(2, RankName, MsgPrefix, MsgSuffix, MsgNameColorCode);
+ AString GroupName, Restriction;
+ S.GetStackValues(2, Restriction, GroupName);
- // Add the rank:
- cRoot::Get()->GetRankManager()->AddRank(RankName, MsgPrefix, MsgSuffix, MsgNameColorCode);
- return 0;
+ // Add the group to the rank:
+ S.Push(cRoot::Get()->GetRankManager()->AddRestrictionToGroup(Restriction, GroupName));
+ return 1;
}
@@ -233,11 +233,11 @@ static int tolua_cRankManager_GetAllPermissions(lua_State * L)
-/** Binds cRankManager::GetAllPermissions */
-static int tolua_cRankManager_GetAllRestrictions(lua_State * L)
+/** Binds cRankManager::GetAllPermissionsRestrictions */
+static int tolua_cRankManager_GetAllPermissionsRestrictions(lua_State * L)
{
// Function signature:
- // cRankManager:GetAllRestrictions() -> arraytable of Permissions
+ // cRankManager:GetAllPermissionsRestrictions() -> arraytable of Permissions and Restrictions together
cLuaState S(L);
if (
@@ -248,11 +248,9 @@ static int tolua_cRankManager_GetAllRestrictions(lua_State * L)
return 0;
}
- // Get the permissions:
- AStringVector Permissions = cRoot::Get()->GetRankManager()->GetAllRestrictions();
-
// Push the results:
- S.Push(Permissions);
+ S.Push(cRoot::Get()->GetRankManager()->GetAllPermissionsRestrictions());
+
return 1;
}
@@ -260,11 +258,11 @@ static int tolua_cRankManager_GetAllRestrictions(lua_State * L)
-/** Binds cRankManager::GetAllPermissionsRestrictions */
-static int tolua_cRankManager_GetAllPermissionsRestrictions(lua_State * L)
+/** Binds cRankManager::GetAllPlayerUUIDs */
+static int tolua_cRankManager_GetAllPlayerUUIDs(lua_State * L)
{
// Function signature:
- // cRankManager:GetAllPermissionsRestrictions() -> arraytable of Permissions and Restrictions
+ // cRankManager:GetAllPlayerUUIDs() -> arraytable of Player UUID's
cLuaState S(L);
if (
@@ -275,11 +273,11 @@ static int tolua_cRankManager_GetAllPermissionsRestrictions(lua_State * L)
return 0;
}
- // Get the permissions:
- AStringVector Permissions = cRoot::Get()->GetRankManager()->GetAllPermissionsRestrictions();
+ // Get the player uuid's:
+ AStringVector Players = cRoot::Get()->GetRankManager()->GetAllPlayerUUIDs();
// Push the results:
- S.Push(Permissions);
+ S.Push(Players);
return 1;
}
@@ -287,11 +285,11 @@ static int tolua_cRankManager_GetAllPermissionsRestrictions(lua_State * L)
-/** Binds cRankManager::GetAllPlayerUUIDs */
-static int tolua_cRankManager_GetAllPlayerUUIDs(lua_State * L)
+/** Binds cRankManager::GetAllRanks */
+static int tolua_cRankManager_GetAllRanks(lua_State * L)
{
// Function signature:
- // cRankManager:GetAllPlayerUUIDs() -> arraytable of Player UUID's
+ // cRankManager:GetAllRanks() -> arraytable of RankNames
cLuaState S(L);
if (
@@ -302,11 +300,8 @@ static int tolua_cRankManager_GetAllPlayerUUIDs(lua_State * L)
return 0;
}
- // Get the player uuid's:
- AStringVector Players = cRoot::Get()->GetRankManager()->GetAllPlayerUUIDs();
-
// Push the results:
- S.Push(Players);
+ S.Push(cRoot::Get()->GetRankManager()->GetAllRanks());
return 1;
}
@@ -314,11 +309,11 @@ static int tolua_cRankManager_GetAllPlayerUUIDs(lua_State * L)
-/** Binds cRankManager::GetAllRanks */
-static int tolua_cRankManager_GetAllRanks(lua_State * L)
+/** Binds cRankManager::GetAllRestrictions */
+static int tolua_cRankManager_GetAllRestrictions(lua_State * L)
{
// Function signature:
- // cRankManager:GetAllRanks() -> arraytable of RankNames
+ // cRankManager:GetAllRestrictions() -> arraytable of Restrictions
cLuaState S(L);
if (
@@ -329,11 +324,9 @@ static int tolua_cRankManager_GetAllRanks(lua_State * L)
return 0;
}
- // Get the ranks:
- AStringVector Ranks = cRoot::Get()->GetRankManager()->GetAllRanks();
-
// Push the results:
- S.Push(Ranks);
+ S.Push(cRoot::Get()->GetRankManager()->GetAllRestrictions());
+
return 1;
}
diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp
index d1fc2ae4f..f2896abde 100644
--- a/src/Bindings/PluginLua.cpp
+++ b/src/Bindings/PluginLua.cpp
@@ -150,7 +150,6 @@ bool cPluginLua::Load(void)
if (!m_LuaState.LoadFile(Path))
{
SetLoadError("Failed to load file Info.lua.");
- m_Status = cPluginManager::psError;
Close();
return false;
}
diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h
index 84e186b4c..6c2905171 100644
--- a/src/Blocks/BlockLeaves.h
+++ b/src/Blocks/BlockLeaves.h
@@ -166,7 +166,7 @@ bool HasNearLog(cBlockArea & a_Area, int a_BlockX, int a_BlockY, int a_BlockZ)
a_Area.SetBlockType(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_SPONGE);
for (int i = 0; i < LEAVES_CHECK_DISTANCE; i++)
{
- for (int y = std::max(a_BlockY - i, 0); y <= std::min(a_BlockY + i, 255); y++)
+ for (int y = std::max(a_BlockY - i, 0); y <= std::min(a_BlockY + i, cChunkDef::Height - 1); y++)
{
for (int z = a_BlockZ - i; z <= a_BlockZ + i; z++)
{
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 303583769..8df60ad40 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -77,11 +77,11 @@ cClientHandle::cClientHandle(const AString & a_IPString, int a_ViewDistance) :
m_BlockDigAnimStage(-1),
m_BlockDigAnimSpeed(0),
m_BlockDigAnimX(0),
- m_BlockDigAnimY(256), // Invalid Y, so that the coords don't get picked up
+ m_BlockDigAnimY(cChunkDef::Height + 1), // Invalid Y, so that the coords don't get picked up
m_BlockDigAnimZ(0),
m_HasStartedDigging(false),
m_LastDigBlockX(0),
- m_LastDigBlockY(256), // Invalid Y, so that the coords don't get picked up
+ m_LastDigBlockY(cChunkDef::Height + 1), // Invalid Y, so that the coords don't get picked up
m_LastDigBlockZ(0),
m_State(csConnected),
m_ShouldCheckDownloaded(false),
@@ -213,7 +213,7 @@ AString cClientHandle::FormatChatPrefix(bool ShouldAppendChatPrefixes, AString a
-AString cClientHandle::FormatMessageType(bool ShouldAppendChatPrefixes, eMessageType a_ChatPrefix, const AString &a_AdditionalData)
+AString cClientHandle::FormatMessageType(bool ShouldAppendChatPrefixes, eMessageType a_ChatPrefix, const AString & a_AdditionalData)
{
switch (a_ChatPrefix)
{
@@ -237,11 +237,9 @@ AString cClientHandle::FormatMessageType(bool ShouldAppendChatPrefixes, eMessage
return Printf("%s: %s", a_AdditionalData.c_str(), cChatColor::LightBlue);
}
}
+ case mtMaxPlusOne: break;
}
- ASSERT(!"Unhandled chat prefix type!");
- #ifndef __clang__
- return "";
- #endif
+ return "";
}
diff --git a/src/CompositeChat.cpp b/src/CompositeChat.cpp
index 2a112f810..657d88292 100644
--- a/src/CompositeChat.cpp
+++ b/src/CompositeChat.cpp
@@ -282,11 +282,10 @@ cLogger::eLogLevel cCompositeChat::MessageTypeToLogLevel(eMessageType a_MessageT
case mtPrivateMessage: return cLogger::llRegular;
case mtJoin: return cLogger::llRegular;
case mtLeave: return cLogger::llRegular;
+ case mtMaxPlusOne: break;
}
ASSERT(!"Unhandled MessageType");
- #ifndef __clang__
- return cLogger::llError;
- #endif
+ return cLogger::llError;
}
diff --git a/src/CompositeChat.h b/src/CompositeChat.h
index 2c1ff5fab..ab16e9f72 100644
--- a/src/CompositeChat.h
+++ b/src/CompositeChat.h
@@ -122,25 +122,23 @@ public:
typedef std::vector<cBasePart *> cParts;
- // tolua_begin
-
- /** Creates a new empty chat message */
+ /** Creates a new empty chat message.
+ Exported manually due to the other overload needing a manual export. */
cCompositeChat(void);
/** Creates a new chat message and parses the text into parts.
Recognizes "http:" and "https:" links and @color-codes.
- Uses ParseText() for the actual parsing. */
+ Uses ParseText() for the actual parsing.
+ Exported manually due to ToLua++ generating extra output parameter. */
cCompositeChat(const AString & a_ParseText, eMessageType a_MessageType = mtCustom);
- ~cCompositeChat();
+ ~cCompositeChat(); // tolua_export
+
+ // The following are exported in ManualBindings in order to support chaining - they return "self" in Lua (#755)
/** Removes all parts from the object. */
void Clear(void);
- // tolua_end
-
- // The following are exported in ManualBindings in order to support chaining - they return *this in Lua (#755)
-
/** Adds a plain text part, with optional style.
The default style is plain white text. */
void AddTextPart(const AString & a_Message, const AString & a_Style = "");
@@ -148,8 +146,6 @@ public:
/** Adds a part that is translated client-side, with the formatting parameters and optional style. */
void AddClientTranslatedPart(const AString & a_TranslationID, const AStringVector & a_Parameters, const AString & a_Style = "");
- // tolua_begin
-
/** Adds a part that opens an URL when clicked.
The default style is underlined light blue text. */
void AddUrlPart(const AString & a_Text, const AString & a_Url, const AString & a_Style = "u@c");
@@ -171,14 +167,14 @@ public:
Recognizes "http:" and "https:" URLs and @color-codes. */
void ParseText(const AString & a_ParseText);
+ /** Adds the "underline" style to each part that is an URL. */
+ void UnderlineUrls(void);
+
/** Sets the message type, which is indicated by prefixes added to the message when serializing
Takes optional AdditionalMessageTypeData to set m_AdditionalMessageTypeData. See said variable for more documentation.
- */
+ Exported manually, because ToLua++ would generate extra return values. */
void SetMessageType(eMessageType a_MessageType, const AString & a_AdditionalMessageTypeData = "");
- /** Adds the "underline" style to each part that is an URL. */
- void UnderlineUrls(void);
-
// tolua_begin
/** Returns the message type set previously by SetMessageType(). */
diff --git a/src/Defines.h b/src/Defines.h
index 615beeabd..b9a90cc81 100644
--- a/src/Defines.h
+++ b/src/Defines.h
@@ -557,7 +557,7 @@ inline void AddFaceDirection(int & a_BlockX, unsigned char & a_BlockY, int & a_B
{
int Y = a_BlockY;
AddFaceDirection(a_BlockX, Y, a_BlockZ, a_BlockFace, a_bInverse);
- a_BlockY = Clamp<unsigned char>(static_cast<unsigned char>(Y), 0, 255);
+ a_BlockY = Clamp<unsigned char>(static_cast<unsigned char>(Y), 0, cChunkDef::Height - 1);
}
@@ -641,6 +641,7 @@ enum eMessageType
mtPrivateMessage, // Player to player messaging identifier
mtJoin, // A player has joined the server
mtLeave, // A player has left the server
+ mtMaxPlusOne, // The first invalid type, used for checking on LuaAPI boundaries
// Common aliases:
mtFail = mtFailure,
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index b2fa56143..48d07fbbc 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -1458,7 +1458,7 @@ bool cEntity::DetectPortal()
cWorld * TargetWorld = cRoot::Get()->GetWorld(GetWorld()->GetLinkedOverworldName());
ASSERT(TargetWorld != nullptr); // The linkage checker should have prevented this at startup. See cWorld::start()
LOGD("Jumping %s -> %s", DimensionToString(dimNether).c_str(), DimensionToString(DestionationDim).c_str());
- new cNetherPortalScanner(this, TargetWorld, TargetPos, 256);
+ new cNetherPortalScanner(this, TargetWorld, TargetPos, cChunkDef::Height);
return true;
}
// Nether portal in the overworld
@@ -1490,7 +1490,7 @@ bool cEntity::DetectPortal()
cWorld * TargetWorld = cRoot::Get()->GetWorld(GetWorld()->GetLinkedNetherWorldName());
ASSERT(TargetWorld != nullptr); // The linkage checker should have prevented this at startup. See cWorld::start()
LOGD("Jumping %s -> %s", DimensionToString(dimOverworld).c_str(), DimensionToString(DestionationDim).c_str());
- new cNetherPortalScanner(this, TargetWorld, TargetPos, 128);
+ new cNetherPortalScanner(this, TargetWorld, TargetPos, (cChunkDef::Height / 2));
return true;
}
}
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 889aef778..5ab5e4567 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -84,6 +84,7 @@ cPlayer::cPlayer(cClientHandlePtr a_Client, const AString & a_PlayerName) :
m_BowCharge(0),
m_FloaterID(cEntity::INVALID_ID),
m_Team(nullptr),
+ m_bIsInBed(false),
m_TicksUntilNextSave(PLAYER_INVENTORY_SAVE_INTERVAL),
m_bIsTeleporting(false),
m_UUID((a_Client != nullptr) ? a_Client->GetUUID() : ""),
diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp
index 3f6a1dc7a..4b2cafbca 100644
--- a/src/Generating/FinishGen.cpp
+++ b/src/Generating/FinishGen.cpp
@@ -517,7 +517,7 @@ void cFinishGenTallGrass::GenFinish(cChunkDesc & a_ChunkDesc)
// Get the top block + 1. This is the place where the grass would finaly be placed:
int y = a_ChunkDesc.GetHeight(x, z) + 1;
- if (y >= 255)
+ if (y >= cChunkDef::Height - 1)
{
continue;
}
@@ -1221,7 +1221,7 @@ void cFinishGenPreSimulator::StationarizeFluid(
cFinishGenFluidSprings::cFinishGenFluidSprings(int a_Seed, BLOCKTYPE a_Fluid, cIniFile & a_IniFile, eDimension a_Dimension) :
m_Noise(a_Seed + a_Fluid * 100), // Need to take fluid into account, otherwise water and lava springs generate next to each other
- m_HeightDistribution(255),
+ m_HeightDistribution(cChunkDef::Height - 1),
m_Fluid(a_Fluid)
{
bool IsWater = (a_Fluid == E_BLOCK_WATER);
diff --git a/src/Item.h b/src/Item.h
index fb52c75fa..8d0e9d9a0 100644
--- a/src/Item.h
+++ b/src/Item.h
@@ -197,8 +197,8 @@ public:
/** Returns the enchantability of the item. When the item hasn't a enchantability, it will returns 0 */
int GetEnchantability(); // tolua_export
- /** Enchants the item using the specified number of XP levels.
- Returns true if item enchanted, false if not. */
+ /** Randomly enchants the item using the specified number of XP levels.
+ Returns true if the item was enchanted, false if not (not enchantable / too many enchantments already). */
bool EnchantByXPLevels(int a_NumXPLevels); // tolua_export
// tolua_begin
diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h
index 2155a4a7c..03382e28e 100644
--- a/src/Mobs/Monster.h
+++ b/src/Mobs/Monster.h
@@ -62,7 +62,7 @@ public:
virtual void HandleFalling(void) override;
- /** Engage pathfinder and tell it to calculate a path to a given position, and move the mobile accordingly
+ /** Engage pathfinder and tell it to calculate a path to a given position, and move the mob accordingly
Currently, the mob will only start moving to a new position after the position it is currently going to is reached. */
virtual void MoveToPosition(const Vector3d & a_Position); // tolua_export
diff --git a/src/Protocol/Protocol110x.cpp b/src/Protocol/Protocol110x.cpp
index a117d8750..bf44eb82f 100644
--- a/src/Protocol/Protocol110x.cpp
+++ b/src/Protocol/Protocol110x.cpp
@@ -41,8 +41,10 @@ Implements the 1.10.x protocol classes:
// IMPORTANT: The enum is used to automate the sequential counting of the
// Metadata indexes. Adding a new enum value causes the following values to
// increase their index. Therefore the ordering of the enum values is VERY important!
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wduplicate-enum"
+#ifdef __clang__
+ #pragma clang diagnostic push
+ #pragma clang diagnostic ignored "-Wduplicate-enum"
+#endif
namespace Metadata
{
@@ -272,8 +274,9 @@ namespace Metadata
};
}
-#pragma clang diagnostic pop // Restore ignored clang errors
-
+#ifdef __clang__
+ #pragma clang diagnostic pop // Restore ignored clang errors
+#endif
diff --git a/src/World.h b/src/World.h
index a33831eb9..de34af1d2 100644
--- a/src/World.h
+++ b/src/World.h
@@ -477,7 +477,8 @@ public:
bool DigBlock (int a_X, int a_Y, int a_Z);
virtual void SendBlockTo(int a_X, int a_Y, int a_Z, cPlayer * a_Player) override;
- /** Set default spawn at the given coordinates. */
+ /** Set default spawn at the given coordinates.
+ Returns false if the new spawn couldn't be stored in the INI file. */
bool SetSpawn(double a_X, double a_Y, double a_Z);
double GetSpawnX(void) const { return m_SpawnX; }
diff --git a/src/WorldStorage/MapSerializer.cpp b/src/WorldStorage/MapSerializer.cpp
index 3899ad505..c34efe507 100644
--- a/src/WorldStorage/MapSerializer.cpp
+++ b/src/WorldStorage/MapSerializer.cpp
@@ -163,7 +163,7 @@ bool cMapSerializer::LoadMapFromNBT(const cParsedNBT & a_NBT)
if ((CurrLine >= 0) && (a_NBT.GetType(CurrLine) == TAG_Short))
{
unsigned int Height = static_cast<unsigned int>(a_NBT.GetShort(CurrLine));
- if (Height >= 256)
+ if (Height >= cChunkDef::Height)
{
return false;
}
diff --git a/src/WorldStorage/SchematicFileSerializer.cpp b/src/WorldStorage/SchematicFileSerializer.cpp
index 3fc36e86c..d6bcf840f 100644
--- a/src/WorldStorage/SchematicFileSerializer.cpp
+++ b/src/WorldStorage/SchematicFileSerializer.cpp
@@ -164,7 +164,7 @@ bool cSchematicFileSerializer::LoadFromSchematicNBT(cBlockArea & a_BlockArea, cP
int SizeX = a_NBT.GetShort(TSizeX);
int SizeY = a_NBT.GetShort(TSizeY);
int SizeZ = a_NBT.GetShort(TSizeZ);
- if ((SizeX < 1) || (SizeX > 65535) || (SizeY < 1) || (SizeY > 256) || (SizeZ < 1) || (SizeZ > 65535))
+ if ((SizeX < 1) || (SizeX > 65535) || (SizeY < 1) || (SizeY > cChunkDef::Height) || (SizeZ < 1) || (SizeZ > 65535))
{
LOG("Dimensions are invalid in the schematic file: %d, %d, %d", SizeX, SizeY, SizeZ);
return false;