summaryrefslogtreecommitdiffstats
path: root/src/Bindings
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Bindings/LuaChunkStay.cpp22
-rw-r--r--src/Bindings/LuaChunkStay.h20
-rw-r--r--src/Bindings/LuaState.cpp102
-rw-r--r--src/Bindings/LuaState.h98
-rw-r--r--src/Bindings/LuaWindow.cpp18
-rw-r--r--src/Bindings/LuaWindow.h30
-rw-r--r--src/Bindings/ManualBindings.cpp224
-rw-r--r--src/Bindings/ManualBindings.h2
-rw-r--r--src/Bindings/ManualBindings_Network.cpp44
-rw-r--r--src/Bindings/ManualBindings_RankManager.cpp264
-rw-r--r--src/Bindings/ManualBindings_World.cpp22
-rw-r--r--src/Bindings/Plugin.h16
-rw-r--r--src/Bindings/PluginLua.cpp34
-rw-r--r--src/Bindings/PluginLua.h46
-rw-r--r--src/Bindings/PluginManager.cpp6
-rw-r--r--src/Bindings/PluginManager.h56
-rw-r--r--src/Bindings/WebPlugin.h2
17 files changed, 503 insertions, 503 deletions
diff --git a/src/Bindings/LuaChunkStay.cpp b/src/Bindings/LuaChunkStay.cpp
index 1afd09d11..d8d7da5d0 100644
--- a/src/Bindings/LuaChunkStay.cpp
+++ b/src/Bindings/LuaChunkStay.cpp
@@ -25,10 +25,10 @@ bool cLuaChunkStay::AddChunks(int a_ChunkCoordTableStackPos)
{
// This function is expected to be called just once, with all the coords in a table
ASSERT(m_Chunks.empty());
-
+
cPluginLua::cOperation Op(m_Plugin);
cLuaState & L = Op();
-
+
// Check that we got a table:
if (!lua_istable(L, a_ChunkCoordTableStackPos))
{
@@ -38,7 +38,7 @@ bool cLuaChunkStay::AddChunks(int a_ChunkCoordTableStackPos)
L.LogStackTrace();
return false;
}
-
+
// Add each set of coords:
int NumChunks = luaL_getn(L, a_ChunkCoordTableStackPos);
m_Chunks.reserve(static_cast<size_t>(NumChunks));
@@ -58,7 +58,7 @@ bool cLuaChunkStay::AddChunks(int a_ChunkCoordTableStackPos)
AddChunkCoord(L, idx);
lua_pop(L, 1);
}
-
+
// If there are no chunks, log a warning and return failure:
if (m_Chunks.empty())
{
@@ -66,7 +66,7 @@ bool cLuaChunkStay::AddChunks(int a_ChunkCoordTableStackPos)
L.LogStackTrace();
return false;
}
-
+
// All ok
return true;
}
@@ -86,14 +86,14 @@ void cLuaChunkStay::AddChunkCoord(cLuaState & L, int a_Index)
);
return;
}
-
+
// Read the two coords from the element:
lua_rawgeti(L, -1, 1);
lua_rawgeti(L, -2, 2);
int ChunkX = luaL_checkint(L, -2);
int ChunkZ = luaL_checkint(L, -1);
lua_pop(L, 2);
-
+
// Check that a coord is not yet present:
for (cChunkCoordsVector::iterator itr = m_Chunks.begin(), end = m_Chunks.end(); itr != end; ++itr)
{
@@ -105,7 +105,7 @@ void cLuaChunkStay::AddChunkCoord(cLuaState & L, int a_Index)
return;
}
} // for itr - m_Chunks[]
-
+
m_Chunks.push_back(cChunkCoords(ChunkX, ChunkZ));
}
@@ -119,7 +119,7 @@ void cLuaChunkStay::Enable(cChunkMap & a_ChunkMap, int a_OnChunkAvailableStackPo
m_LuaState = &m_Plugin.GetLuaState();
m_OnChunkAvailable.RefStack(*m_LuaState, a_OnChunkAvailableStackPos);
m_OnAllChunksAvailable.RefStack(*m_LuaState, a_OnAllChunksAvailableStackPos);
-
+
// Enable the ChunkStay:
super::Enable(a_ChunkMap);
}
@@ -148,12 +148,12 @@ bool cLuaChunkStay::OnAllChunksAvailable(void)
// Call the callback:
cPluginLua::cOperation Op(m_Plugin);
Op().Call(static_cast<int>(m_OnAllChunksAvailable));
-
+
// Remove the callback references - they won't be needed anymore
m_OnChunkAvailable.UnRef();
m_OnAllChunksAvailable.UnRef();
}
-
+
// Disable the ChunkStay by returning true
return true;
}
diff --git a/src/Bindings/LuaChunkStay.h b/src/Bindings/LuaChunkStay.h
index d76b67de9..a455d2502 100644
--- a/src/Bindings/LuaChunkStay.h
+++ b/src/Bindings/LuaChunkStay.h
@@ -28,38 +28,38 @@ class cLuaChunkStay
: public cChunkStay
{
typedef cChunkStay super;
-
+
public:
cLuaChunkStay(cPluginLua & a_Plugin);
-
+
~cLuaChunkStay() { }
/** Adds chunks in the specified on-stack Lua table.
Returns true if any chunk added, false (plus log warning) if none. */
bool AddChunks(int a_ChunkCoordTableStackPos);
-
+
/** Enables the ChunkStay for the specified chunkmap, with the specified Lua callbacks. */
void Enable(cChunkMap & a_ChunkMap, int a_OnChunkAvailableStackPos, int a_OnAllChunksAvailableStackPos);
-
+
protected:
/** The plugin which has created the ChunkStay, via cWorld:ChunkStay() binding method. */
cPluginLua & m_Plugin;
-
+
/** The Lua state associated with the callbacks. Only valid when enabled. */
cLuaState * m_LuaState;
-
+
/** The Lua function to call in OnChunkAvailable. Only valid when enabled. */
cLuaState::cRef m_OnChunkAvailable;
-
+
/** The Lua function to call in OnAllChunksAvailable. Only valid when enabled. */
cLuaState::cRef m_OnAllChunksAvailable;
-
-
+
+
// cChunkStay overrides:
virtual void OnChunkAvailable(int a_ChunkX, int a_ChunkZ) override;
virtual bool OnAllChunksAvailable(void) override;
virtual void OnDisabled(void) override;
-
+
/** Adds a single chunk coord from the table at the top of the Lua stack.
Expects the top element to be a table, checks that it contains two numbers.
Uses those two numbers as chunk coords appended to m_Chunks.
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp
index b03dccad0..200878cf7 100644
--- a/src/Bindings/LuaState.cpp
+++ b/src/Bindings/LuaState.cpp
@@ -267,12 +267,12 @@ void cLuaState::AddPackagePath(const AString & a_PathVariable, const AString & a
lua_getfield(m_LuaState, -1, a_PathVariable.c_str()); // Stk: <package> <package.path>
size_t len = 0;
const char * PackagePath = lua_tolstring(m_LuaState, -1, &len);
-
+
// Append the new path:
AString NewPackagePath(PackagePath, len);
NewPackagePath.append(LUA_PATHSEP);
NewPackagePath.append(a_Path);
-
+
// Set the new path to the environment:
lua_pop(m_LuaState, 1); // Stk: <package>
lua_pushlstring(m_LuaState, NewPackagePath.c_str(), NewPackagePath.length()); // Stk: <package> <NewPackagePath>
@@ -382,10 +382,10 @@ bool cLuaState::PushFunction(const char * a_FunctionName)
// This happens if cPlugin::Initialize() fails with an error
return false;
}
-
+
// Push the error handler for lua_pcall()
lua_pushcfunction(m_LuaState, &ReportFnCallErrors);
-
+
lua_getglobal(m_LuaState, a_FunctionName);
if (!lua_isfunction(m_LuaState, -1))
{
@@ -406,10 +406,10 @@ bool cLuaState::PushFunction(int a_FnRef)
{
ASSERT(IsValid());
ASSERT(m_NumCurrentFunctionArgs == -1); // If not, there's already something pushed onto the stack
-
+
// Push the error handler for lua_pcall()
lua_pushcfunction(m_LuaState, &ReportFnCallErrors);
-
+
lua_rawgeti(m_LuaState, LUA_REGISTRYINDEX, a_FnRef); // same as lua_getref()
if (!lua_isfunction(m_LuaState, -1))
{
@@ -429,10 +429,10 @@ bool cLuaState::PushFunction(const cTableRef & a_TableRef)
{
ASSERT(IsValid());
ASSERT(m_NumCurrentFunctionArgs == -1); // If not, there's already something pushed onto the stack
-
+
// Push the error handler for lua_pcall()
lua_pushcfunction(m_LuaState, &ReportFnCallErrors);
-
+
lua_rawgeti(m_LuaState, LUA_REGISTRYINDEX, a_TableRef.GetTableRef()); // Get the table ref
if (!lua_istable(m_LuaState, -1))
{
@@ -447,10 +447,10 @@ bool cLuaState::PushFunction(const cTableRef & a_TableRef)
lua_pop(m_LuaState, 3);
return false;
}
-
+
// Pop the table off the stack:
lua_remove(m_LuaState, -2);
-
+
Printf(m_CurrentFunctionName, "<table-callback %s>", a_TableRef.GetFnName());
m_NumCurrentFunctionArgs = 0;
return true;
@@ -1005,13 +1005,13 @@ bool cLuaState::CallFunction(int a_NumResults)
ASSERT (m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
ASSERT(lua_isfunction(m_LuaState, -m_NumCurrentFunctionArgs - 1)); // The function to call
ASSERT(lua_isfunction(m_LuaState, -m_NumCurrentFunctionArgs - 2)); // The error handler
-
+
// Save the current "stack" state and reset, in case the callback calls another function:
AString CurrentFunctionName;
std::swap(m_CurrentFunctionName, CurrentFunctionName);
int NumArgs = m_NumCurrentFunctionArgs;
m_NumCurrentFunctionArgs = -1;
-
+
// Call the function:
int s = lua_pcall(m_LuaState, NumArgs, a_NumResults, -NumArgs - 2);
if (s != 0)
@@ -1020,10 +1020,10 @@ bool cLuaState::CallFunction(int a_NumResults)
LOGWARNING("Error in %s calling function %s()", m_SubsystemName.c_str(), CurrentFunctionName.c_str());
return false;
}
-
+
// Remove the error handler from the stack:
lua_remove(m_LuaState, -a_NumResults - 1);
-
+
return true;
}
@@ -1034,12 +1034,12 @@ bool cLuaState::CallFunction(int a_NumResults)
bool cLuaState::CheckParamUserTable(int a_StartParam, const char * a_UserTable, int a_EndParam)
{
ASSERT(IsValid());
-
+
if (a_EndParam < 0)
{
a_EndParam = a_StartParam;
}
-
+
tolua_Error tolua_err;
for (int i = a_StartParam; i <= a_EndParam; i++)
{
@@ -1055,7 +1055,7 @@ bool cLuaState::CheckParamUserTable(int a_StartParam, const char * a_UserTable,
tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err);
return false;
} // for i - Param
-
+
// All params checked ok
return true;
}
@@ -1067,12 +1067,12 @@ bool cLuaState::CheckParamUserTable(int a_StartParam, const char * a_UserTable,
bool cLuaState::CheckParamUserType(int a_StartParam, const char * a_UserType, int a_EndParam)
{
ASSERT(IsValid());
-
+
if (a_EndParam < 0)
{
a_EndParam = a_StartParam;
}
-
+
tolua_Error tolua_err;
for (int i = a_StartParam; i <= a_EndParam; i++)
{
@@ -1088,7 +1088,7 @@ bool cLuaState::CheckParamUserType(int a_StartParam, const char * a_UserType, in
tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err);
return false;
} // for i - Param
-
+
// All params checked ok
return true;
}
@@ -1100,12 +1100,12 @@ bool cLuaState::CheckParamUserType(int a_StartParam, const char * a_UserType, in
bool cLuaState::CheckParamTable(int a_StartParam, int a_EndParam)
{
ASSERT(IsValid());
-
+
if (a_EndParam < 0)
{
a_EndParam = a_StartParam;
}
-
+
tolua_Error tolua_err;
for (int i = a_StartParam; i <= a_EndParam; i++)
{
@@ -1124,7 +1124,7 @@ bool cLuaState::CheckParamTable(int a_StartParam, int a_EndParam)
tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err);
return false;
} // for i - Param
-
+
// All params checked ok
return true;
}
@@ -1136,12 +1136,12 @@ bool cLuaState::CheckParamTable(int a_StartParam, int a_EndParam)
bool cLuaState::CheckParamNumber(int a_StartParam, int a_EndParam)
{
ASSERT(IsValid());
-
+
if (a_EndParam < 0)
{
a_EndParam = a_StartParam;
}
-
+
tolua_Error tolua_err;
for (int i = a_StartParam; i <= a_EndParam; i++)
{
@@ -1157,7 +1157,7 @@ bool cLuaState::CheckParamNumber(int a_StartParam, int a_EndParam)
tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err);
return false;
} // for i - Param
-
+
// All params checked ok
return true;
}
@@ -1169,12 +1169,12 @@ bool cLuaState::CheckParamNumber(int a_StartParam, int a_EndParam)
bool cLuaState::CheckParamBool(int a_StartParam, int a_EndParam)
{
ASSERT(IsValid());
-
+
if (a_EndParam < 0)
{
a_EndParam = a_StartParam;
}
-
+
tolua_Error tolua_err;
for (int i = a_StartParam; i <= a_EndParam; i++)
{
@@ -1190,7 +1190,7 @@ bool cLuaState::CheckParamBool(int a_StartParam, int a_EndParam)
tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err);
return false;
} // for i - Param
-
+
// All params checked ok
return true;
}
@@ -1202,12 +1202,12 @@ bool cLuaState::CheckParamBool(int a_StartParam, int a_EndParam)
bool cLuaState::CheckParamString(int a_StartParam, int a_EndParam)
{
ASSERT(IsValid());
-
+
if (a_EndParam < 0)
{
a_EndParam = a_StartParam;
}
-
+
tolua_Error tolua_err;
for (int i = a_StartParam; i <= a_EndParam; i++)
{
@@ -1226,7 +1226,7 @@ bool cLuaState::CheckParamString(int a_StartParam, int a_EndParam)
tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err);
return false;
} // for i - Param
-
+
// All params checked ok
return true;
}
@@ -1238,12 +1238,12 @@ bool cLuaState::CheckParamString(int a_StartParam, int a_EndParam)
bool cLuaState::CheckParamFunction(int a_StartParam, int a_EndParam)
{
ASSERT(IsValid());
-
+
if (a_EndParam < 0)
{
a_EndParam = a_StartParam;
}
-
+
for (int i = a_StartParam; i <= a_EndParam; i++)
{
if (lua_isfunction(m_LuaState, i))
@@ -1259,7 +1259,7 @@ bool cLuaState::CheckParamFunction(int a_StartParam, int a_EndParam)
);
return false;
} // for i - Param
-
+
// All params checked ok
return true;
}
@@ -1271,12 +1271,12 @@ bool cLuaState::CheckParamFunction(int a_StartParam, int a_EndParam)
bool cLuaState::CheckParamFunctionOrNil(int a_StartParam, int a_EndParam)
{
ASSERT(IsValid());
-
+
if (a_EndParam < 0)
{
a_EndParam = a_StartParam;
}
-
+
for (int i = a_StartParam; i <= a_EndParam; i++)
{
if (lua_isfunction(m_LuaState, i) || lua_isnil(m_LuaState, i))
@@ -1292,7 +1292,7 @@ bool cLuaState::CheckParamFunctionOrNil(int a_StartParam, int a_EndParam)
);
return false;
} // for i - Param
-
+
// All params checked ok
return true;
}
@@ -1324,7 +1324,7 @@ bool cLuaState::CheckParamEnd(int a_Param)
bool cLuaState::IsParamUserType(int a_Param, AString a_UserType)
{
ASSERT(IsValid());
-
+
tolua_Error tolua_err;
return (tolua_isusertype(m_LuaState, a_Param, a_UserType.c_str(), 0, &tolua_err) == 1);
}
@@ -1336,7 +1336,7 @@ bool cLuaState::IsParamUserType(int a_Param, AString a_UserType)
bool cLuaState::IsParamNumber(int a_Param)
{
ASSERT(IsValid());
-
+
tolua_Error tolua_err;
return (tolua_isnumber(m_LuaState, a_Param, 0, &tolua_err) == 1);
}
@@ -1361,7 +1361,7 @@ bool cLuaState::ReportErrors(lua_State * a_LuaState, int a_Status)
// No error to report
return false;
}
-
+
LOGWARNING("LUA: %d - %s", a_Status, lua_tostring(a_LuaState, -1));
lua_pop(a_LuaState, 1);
return true;
@@ -1416,10 +1416,10 @@ int cLuaState::CallFunctionWithForeignParams(
{
ASSERT(IsValid());
ASSERT(a_SrcLuaState.IsValid());
-
+
// Store the stack position before any changes
int OldTop = lua_gettop(m_LuaState);
-
+
// Push the function to call, including the error handler:
if (!PushFunction(a_FunctionName.c_str()))
{
@@ -1437,7 +1437,7 @@ int cLuaState::CallFunctionWithForeignParams(
m_CurrentFunctionName.clear();
return -1;
}
-
+
// Call the function, with an error handler:
int s = lua_pcall(m_LuaState, a_SrcParamEnd - a_SrcParamStart + 1, LUA_MULTRET, OldTop + 1);
if (ReportErrors(s))
@@ -1445,23 +1445,23 @@ int cLuaState::CallFunctionWithForeignParams(
LOGWARN("Error while calling function '%s' in '%s'", a_FunctionName.c_str(), m_SubsystemName.c_str());
// Reset the stack:
lua_settop(m_LuaState, OldTop);
-
+
// Reset the internal checking mechanisms:
m_NumCurrentFunctionArgs = -1;
m_CurrentFunctionName.clear();
-
+
// Make Lua think everything is okay and return 0 values, so that plugins continue executing.
// The failure is indicated by the zero return values.
return 0;
}
-
+
// Reset the internal checking mechanisms:
m_NumCurrentFunctionArgs = -1;
m_CurrentFunctionName.clear();
-
+
// Remove the error handler from the stack:
lua_remove(m_LuaState, OldTop + 1);
-
+
// Return the number of return values:
return lua_gettop(m_LuaState) - OldTop;
}
@@ -1520,7 +1520,7 @@ int cLuaState::CopyStackFrom(cLuaState & a_SrcLuaState, int a_SrcStart, int a_Sr
lua_rawget(a_SrcLuaState, LUA_REGISTRYINDEX); // Stack +1
type = lua_tostring(a_SrcLuaState, -1);
lua_pop(a_SrcLuaState, 1); // Stack -1
-
+
// Copy the value:
void * ud = tolua_touserdata(a_SrcLuaState, i, nullptr);
tolua_pushusertype(m_LuaState, ud, type);
@@ -1693,7 +1693,7 @@ void cLuaState::cRef::RefStack(cLuaState & a_LuaState, int a_StackPos)
void cLuaState::cRef::UnRef(void)
{
ASSERT(m_LuaState->IsValid()); // The reference should be destroyed before destroying the LuaState
-
+
if (IsValid())
{
luaL_unref(*m_LuaState, LUA_REGISTRYINDEX, m_Ref);
diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h
index f66605332..215980033 100644
--- a/src/Bindings/LuaState.h
+++ b/src/Bindings/LuaState.h
@@ -57,26 +57,26 @@ public:
public:
/** Creates an unbound reference object. */
cRef(void);
-
+
/** Creates a reference in the specified LuaState for object at the specified StackPos */
cRef(cLuaState & a_LuaState, int a_StackPos);
/** Moves the reference from the specified instance into a newly created instance.
The old instance is then "!IsValid()". */
cRef(cRef && a_FromRef);
-
+
~cRef();
-
+
/** Creates a reference to Lua object at the specified stack pos, binds this object to it.
Calls UnRef() first if previously bound to another reference. */
void RefStack(cLuaState & a_LuaState, int a_StackPos);
-
+
/** Removes the bound reference, resets the object to Unbound state. */
void UnRef(void);
-
+
/** Returns true if the reference is valid */
bool IsValid(void) const {return (m_Ref != LUA_REFNIL); }
-
+
/** Allows to use this class wherever an int (i. e. ref) is to be used */
explicit operator int(void) const { return m_Ref; }
@@ -87,8 +87,8 @@ public:
// Remove the copy-constructor:
cRef(const cRef &) = delete;
} ;
-
-
+
+
/** Used for calling functions stored in a reference-stored table */
class cTableRef
{
@@ -100,7 +100,7 @@ public:
m_FnName(a_FnName)
{
}
-
+
cTableRef(const cRef & a_TableRef, const char * a_FnName) :
m_TableRef(static_cast<int>(a_TableRef)),
m_FnName(a_FnName)
@@ -110,13 +110,13 @@ public:
int GetTableRef(void) const { return m_TableRef; }
const char * GetFnName(void) const { return m_FnName; }
} ;
-
-
+
+
/** A dummy class that's used only to delimit function args from return values for cLuaState::Call() */
class cRet
{
} ;
-
+
static const cRet Return; // Use this constant to delimit function args from return values for cLuaState::Call()
@@ -180,31 +180,31 @@ public:
or "LuaScript" for the cLuaScript template
*/
cLuaState(const AString & a_SubsystemName);
-
+
/** Creates a new instance. The a_AttachState is attached.
Subsystem name is set to "<attached>".
*/
explicit cLuaState(lua_State * a_AttachState);
-
+
~cLuaState();
-
+
/** Allows this object to be used in the same way as a lua_State *, for example in the LuaLib functions */
operator lua_State * (void) { return m_LuaState; }
-
+
/** Creates the m_LuaState, if not closed already. This state will be automatically closed in the destructor.
The regular Lua libs are registered, but the MCS API is not registered (so that Lua can be used as
lite-config as well), use RegisterAPILibs() to do that. */
void Create(void);
-
+
/** Registers all the API libraries that MCS provides into m_LuaState. */
void RegisterAPILibs(void);
-
+
/** Closes the m_LuaState, if not closed already */
void Close(void);
-
+
/** Attaches the specified state. Operations will be carried out on this state, but it will not be closed in the destructor */
void Attach(lua_State * a_State);
-
+
/** Detaches a previously attached state. */
void Detach(void);
@@ -260,7 +260,7 @@ public:
void Push(long a_Value);
void Push(const UInt32 a_Value);
void Push(std::chrono::milliseconds a_time);
-
+
// GetStackValue() retrieves the value at a_StackPos, if it is a valid type. If not, a_Value is unchanged.
// Returns whether value was changed
// Enum values are checked for their allowed values and fail if the value is not assigned.
@@ -335,7 +335,7 @@ public:
// Include the auto-generated Push and GetStackValue() functions:
#include "LuaState_Declaration.inc"
-
+
/** Call the specified Lua function.
Returns true if call succeeded, false if there was an error.
A special param of cRet & signifies the end of param list and the start of return values.
@@ -364,50 +364,50 @@ public:
/** Returns true if the specified parameters on the stack are of the specified usertable type; also logs warning if not. Used for static functions */
bool CheckParamUserTable(int a_StartParam, const char * a_UserTable, int a_EndParam = -1);
-
+
/** Returns true if the specified parameters on the stack are of the specified usertype; also logs warning if not. Used for regular functions */
bool CheckParamUserType(int a_StartParam, const char * a_UserType, int a_EndParam = -1);
-
+
/** Returns true if the specified parameters on the stack are tables; also logs warning if not */
bool CheckParamTable(int a_StartParam, int a_EndParam = -1);
-
+
/** Returns true if the specified parameters on the stack are numbers; also logs warning if not */
bool CheckParamNumber(int a_StartParam, int a_EndParam = -1);
-
+
/** Returns true if the specified parameters on the stack are bools; also logs warning if not */
bool CheckParamBool(int a_StartParam, int a_EndParam = -1);
-
+
/** Returns true if the specified parameters on the stack are strings; also logs warning if not */
bool CheckParamString(int a_StartParam, int a_EndParam = -1);
-
+
/** Returns true if the specified parameters on the stack are functions; also logs warning if not */
bool CheckParamFunction(int a_StartParam, int a_EndParam = -1);
-
+
/** Returns true if the specified parameters on the stack are functions or nils; also logs warning if not */
bool CheckParamFunctionOrNil(int a_StartParam, int a_EndParam = -1);
-
+
/** Returns true if the specified parameter on the stack is nil (indicating an end-of-parameters) */
bool CheckParamEnd(int a_Param);
-
+
bool IsParamUserType(int a_Param, AString a_UserType);
bool IsParamNumber(int a_Param);
/** If the status is nonzero, prints the text on the top of Lua stack and returns true */
bool ReportErrors(int status);
-
+
/** If the status is nonzero, prints the text on the top of Lua stack and returns true */
static bool ReportErrors(lua_State * a_LuaState, int status);
-
+
/** Logs all items in the current stack trace to the server console */
void LogStackTrace(int a_StartingDepth = 0);
-
+
/** Logs all items in the current stack trace to the server console */
static void LogStackTrace(lua_State * a_LuaState, int a_StartingDepth = 0);
-
+
/** Returns the type of the item on the specified position in the stack */
AString GetTypeText(int a_StackPos);
-
+
/** Calls the function specified by its name, with arguments copied off the foreign state.
If successful, keeps the return values on the stack and returns their number.
If unsuccessful, returns a negative number and keeps the stack position unchanged. */
@@ -417,37 +417,37 @@ public:
int a_SrcParamStart,
int a_SrcParamEnd
);
-
+
/** Copies objects on the stack from the specified state.
Only numbers, bools, strings and userdatas are copied.
If successful, returns the number of objects copied.
If failed, returns a negative number and rewinds the stack position. */
int CopyStackFrom(cLuaState & a_SrcLuaState, int a_SrcStart, int a_SrcEnd);
-
+
/** Reads the value at the specified stack position as a string and sets it to a_String. */
void ToString(int a_StackPos, AString & a_String);
/** Logs all the elements' types on the API stack, with an optional header for the listing. */
void LogStack(const char * a_Header = nullptr);
-
+
/** Logs all the elements' types on the API stack, with an optional header for the listing. */
static void LogStack(lua_State * a_LuaState, const char * a_Header = nullptr);
-
+
protected:
lua_State * m_LuaState;
-
+
/** If true, the state is owned by this object and will be auto-Closed. False => attached state */
bool m_IsOwned;
-
+
/** The subsystem name is used for reporting errors to the console, it is either "plugin %s" or "LuaScript"
whatever is given to the constructor
*/
AString m_SubsystemName;
-
+
/** Name of the currently pushed function (for the Push / Call chain) */
AString m_CurrentFunctionName;
-
+
/** Number of arguments currently pushed (for the Push / Call chain) */
int m_NumCurrentFunctionArgs;
@@ -499,12 +499,12 @@ protected:
Returns true if successful. Logs a warning on failure (incl. m_SubsystemName)
*/
bool PushFunction(const char * a_FunctionName);
-
+
/** Pushes a function that has been saved into the global registry, identified by a_FnRef.
Returns true if successful. Logs a warning on failure
*/
bool PushFunction(int a_FnRef);
-
+
/** Pushes a function that has been saved as a reference.
Returns true if successful. Logs a warning on failure
*/
@@ -512,12 +512,12 @@ protected:
{
return PushFunction(static_cast<int>(a_FnRef));
}
-
+
/** Pushes a function that is stored in a referenced table by name
Returns true if successful. Logs a warning on failure
*/
bool PushFunction(const cTableRef & a_TableRef);
-
+
/** Pushes a usertype of the specified class type onto the stack */
// void PushUserType(void * a_Object, const char * a_Type);
@@ -527,7 +527,7 @@ protected:
Returns true if successful, logs a warning on failure.
*/
bool CallFunction(int a_NumReturnValues);
-
+
/** Used as the error reporting function for function calls */
static int ReportFnCallErrors(lua_State * a_LuaState);
diff --git a/src/Bindings/LuaWindow.cpp b/src/Bindings/LuaWindow.cpp
index 5f7832ef5..706397a27 100644
--- a/src/Bindings/LuaWindow.cpp
+++ b/src/Bindings/LuaWindow.cpp
@@ -25,7 +25,7 @@ cLuaWindow::cLuaWindow(cWindow::WindowType a_WindowType, int a_SlotsX, int a_Slo
{
m_Contents.AddListener(*this);
m_SlotAreas.push_back(new cSlotAreaItemGrid(m_Contents, *this));
-
+
// If appropriate, add an Armor slot area:
switch (a_WindowType)
{
@@ -93,13 +93,13 @@ void cLuaWindow::SetOnClosing(cPluginLua * a_Plugin, int a_FnRef)
{
// Either m_Plugin is not set or equal to the passed plugin; only one plugin can use one cLuaWindow object
ASSERT((m_Plugin == nullptr) || (m_Plugin == a_Plugin));
-
+
// If there already was a function, unreference it first
if (m_OnClosingFnRef != LUA_REFNIL)
{
m_Plugin->Unreference(m_OnClosingFnRef);
}
-
+
// Store the new reference
m_Plugin = a_Plugin;
m_OnClosingFnRef = a_FnRef;
@@ -113,13 +113,13 @@ void cLuaWindow::SetOnSlotChanged(cPluginLua * a_Plugin, int a_FnRef)
{
// Either m_Plugin is not set or equal to the passed plugin; only one plugin can use one cLuaWindow object
ASSERT((m_Plugin == nullptr) || (m_Plugin == a_Plugin));
-
+
// If there already was a function, unreference it first
if (m_OnSlotChangedFnRef != LUA_REFNIL)
{
m_Plugin->Unreference(m_OnSlotChangedFnRef);
}
-
+
// Store the new reference
m_Plugin = a_Plugin;
m_OnSlotChangedFnRef = a_FnRef;
@@ -141,7 +141,7 @@ bool cLuaWindow::ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse)
return false;
}
}
-
+
return super::ClosedByPlayer(a_Player, a_CanRefuse);
}
@@ -152,13 +152,13 @@ bool cLuaWindow::ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse)
void cLuaWindow::Destroy(void)
{
super::Destroy();
-
+
if ((m_LuaRef != LUA_REFNIL) && (m_Plugin != nullptr))
{
// The object is referenced by Lua, un-reference it
m_Plugin->Unreference(m_LuaRef);
}
-
+
// Lua will take care of this object, it will garbage-collect it, so we must not delete it!
m_IsDestroyed = false;
}
@@ -192,7 +192,7 @@ void cLuaWindow::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
ASSERT(!"Invalid ItemGrid in callback");
return;
}
-
+
// If an OnSlotChanged callback has been registered, call it:
if (m_OnSlotChangedFnRef != LUA_REFNIL)
{
diff --git a/src/Bindings/LuaWindow.h b/src/Bindings/LuaWindow.h
index 60d4f5792..f292a5154 100644
--- a/src/Bindings/LuaWindow.h
+++ b/src/Bindings/LuaWindow.h
@@ -40,52 +40,52 @@ class cLuaWindow :
// tolua_begin
{
typedef cWindow super;
-
+
public:
/** Create a window of the specified type, with a slot grid of a_SlotsX * a_SlotsY size */
cLuaWindow(cWindow::WindowType a_WindowType, int a_SlotsX, int a_SlotsY, const AString & a_Title);
-
+
virtual ~cLuaWindow();
-
+
/** Returns the internal representation of the contents that are manipulated by Lua */
cItemGrid & GetContents(void) { return m_Contents; }
-
+
// tolua_end
-
+
/** Sets the plugin reference and the internal Lua object reference index
used for preventing Lua's GC to collect this class while the window is open. */
void SetLuaRef(cPluginLua * a_Plugin, int a_LuaRef);
-
+
/** Returns true if SetLuaRef() has been called */
bool IsLuaReferenced(void) const;
-
+
/** Sets the callback function (Lua reference) to call when the window is about to close */
void SetOnClosing(cPluginLua * a_Plugin, int a_FnRef);
-
+
/** Sets the callback function (Lua reference) to call when a slot is changed */
void SetOnSlotChanged(cPluginLua * a_Plugin, int a_FnRef);
-
+
protected:
/** Contents of the non-inventory part */
cItemGrid m_Contents;
-
+
/** The plugin that has opened the window and owns the m_LuaRef */
cPluginLua * m_Plugin;
-
+
/** The Lua object reference, used for keeping the object alive as long as any player has the window open */
int m_LuaRef;
-
+
/** The Lua reference for the callback to call when the window is closing for any player */
int m_OnClosingFnRef;
-
+
/** The Lua reference for the callback to call when a slot has changed */
int m_OnSlotChangedFnRef;
-
+
// cWindow overrides:
virtual bool ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse) override;
virtual void Destroy(void) override;
virtual void DistributeStack(cItem & a_ItemStack, int a_Slot, cPlayer & a_Player, cSlotArea * a_ClickedArea, bool a_ShouldApply) override;
-
+
// cItemGrid::cListener overrides:
virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override;
} ; // tolua_export
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp
index 42e7e9bd2..110f22f1c 100644
--- a/src/Bindings/ManualBindings.cpp
+++ b/src/Bindings/ManualBindings.cpp
@@ -356,7 +356,7 @@ static int tolua_LOG(lua_State * tolua_S)
{
LogLevel = cCompositeChat::MessageTypeToLogLevel(reinterpret_cast<cCompositeChat *>(tolua_tousertype(tolua_S, 1, nullptr))->GetMessageType());
}
-
+
// Log the message:
cLogger::GetInstance().LogSimple(GetLogMessage(tolua_S).c_str(), LogLevel);
return 0;
@@ -430,7 +430,7 @@ static int tolua_Base64Encode(lua_State * tolua_S)
{
return 0;
}
-
+
AString Src;
L.GetStackValue(1, Src);
AString res = Base64Encode(Src);
@@ -452,7 +452,7 @@ static int tolua_Base64Decode(lua_State * tolua_S)
{
return 0;
}
-
+
AString Src;
L.GetStackValue(1, Src);
AString res = Base64Decode(Src);
@@ -476,7 +476,7 @@ cPluginLua * cManualBindings::GetLuaPlugin(lua_State * L)
}
cPluginLua * Plugin = reinterpret_cast<cPluginLua *>(const_cast<void*>(lua_topointer(L, -1)));
lua_pop(L, 1);
-
+
return Plugin;
}
@@ -746,7 +746,7 @@ static int tolua_cFile_GetFolderContents(lua_State * tolua_S)
{
return 0;
}
-
+
// Get params:
AString Folder;
ASSERT(LuaState.GetStackValues(2, Folder));
@@ -883,7 +883,7 @@ static int tolua_cFile_ReadWholeFile(lua_State * tolua_S)
{
return 0;
}
-
+
// Get params:
AString FileName;
ASSERT(LuaState.GetStackValues(2, FileName));
@@ -982,7 +982,7 @@ static int tolua_cPluginManager_AddHook_FnRef(cPluginManager * a_PluginManager,
// Helper function for cPluginmanager:AddHook() binding
// Takes care of the new case (#121): args are HOOK_TYPE and CallbackFunction
// The arg types have already been checked
-
+
// Retrieve the cPlugin from the LuaState:
cPluginLua * Plugin = cManualBindings::GetLuaPlugin(S);
if (Plugin == nullptr)
@@ -990,7 +990,7 @@ static int tolua_cPluginManager_AddHook_FnRef(cPluginManager * a_PluginManager,
// An error message has been already printed in GetLuaPlugin()
return 0;
}
-
+
// Retrieve and check the hook type
int HookType = static_cast<int>(tolua_tonumber(S, a_ParamIdx, -1));
if (!a_PluginManager->IsValidHookType(HookType))
@@ -999,7 +999,7 @@ static int tolua_cPluginManager_AddHook_FnRef(cPluginManager * a_PluginManager,
S.LogStackTrace();
return 0;
}
-
+
// Add the hook to the plugin
if (!Plugin->AddHookRef(HookType, a_ParamIdx + 1))
{
@@ -1008,7 +1008,7 @@ static int tolua_cPluginManager_AddHook_FnRef(cPluginManager * a_PluginManager,
return 0;
}
a_PluginManager->AddHook(Plugin, HookType);
-
+
// Success
return 0;
}
@@ -1022,7 +1022,7 @@ static int tolua_cPluginManager_AddHook_DefFn(cPluginManager * a_PluginManager,
// Helper function for cPluginmanager:AddHook() binding
// Takes care of the old case (#121): args are cPluginLua and HOOK_TYPE
// The arg types have already been checked
-
+
// Retrieve and check the cPlugin parameter
cPluginLua * Plugin = reinterpret_cast<cPluginLua *>(tolua_tousertype(S, a_ParamIdx, nullptr));
if (Plugin == nullptr)
@@ -1038,7 +1038,7 @@ static int tolua_cPluginManager_AddHook_DefFn(cPluginManager * a_PluginManager,
S.LogStackTrace();
return 0;
}
-
+
// Retrieve and check the hook type
int HookType = static_cast<int>(tolua_tonumber(S, a_ParamIdx + 1, -1));
if (!a_PluginManager->IsValidHookType(HookType))
@@ -1047,7 +1047,7 @@ static int tolua_cPluginManager_AddHook_DefFn(cPluginManager * a_PluginManager,
S.LogStackTrace();
return 0;
}
-
+
// Get the standard name for the callback function:
const char * FnName = cPluginLua::GetHookFnName(HookType);
if (FnName == nullptr)
@@ -1068,7 +1068,7 @@ static int tolua_cPluginManager_AddHook_DefFn(cPluginManager * a_PluginManager,
return 0;
}
a_PluginManager->AddHook(Plugin, HookType);
-
+
// Success
return 0;
}
@@ -1087,7 +1087,7 @@ static int tolua_cPluginManager_AddHook(lua_State * tolua_S)
cPluginManager:Get():AddHook(Plugin, HOOK_TYPE) -- (4) old style (#121), accepted but complained about in the console
cPluginManager.AddHook(Plugin, HOOK_TYPE) -- (5) old style (#121) mangled, accepted but complained about in the console
*/
-
+
cLuaState S(tolua_S);
cPluginManager * PlgMgr = cPluginManager::Get();
@@ -1111,7 +1111,7 @@ static int tolua_cPluginManager_AddHook(lua_State * tolua_S)
// Style 1, use the global PlgMgr, but increment ParamIdx
ParamIdx++;
}
-
+
if (lua_isnumber(S, ParamIdx) && lua_isfunction(S, ParamIdx + 1))
{
// The next params are a number and a function, assume style 1 or 2
@@ -1124,7 +1124,7 @@ static int tolua_cPluginManager_AddHook(lua_State * tolua_S)
S.LogStackTrace();
return tolua_cPluginManager_AddHook_DefFn(PlgMgr, S, ParamIdx);
}
-
+
AString ParamDesc;
Printf(ParamDesc, "%s, %s, %s", S.GetTypeText(1).c_str(), S.GetTypeText(2).c_str(), S.GetTypeText(3).c_str());
LOGWARNING("cPluginManager:AddHook(): bad parameters. Expected HOOK_TYPE and CallbackFunction, got %s. Hook not added.", ParamDesc.c_str());
@@ -1264,7 +1264,7 @@ static int tolua_cPluginManager_BindCommand(lua_State * L)
{
return 0;
}
-
+
// Read the arguments to this API call:
tolua_Error tolua_err;
int idx = 1;
@@ -1294,7 +1294,7 @@ static int tolua_cPluginManager_BindCommand(lua_State * L)
AString Command (tolua_tocppstring(L, idx, ""));
AString Permission(tolua_tocppstring(L, idx + 1, ""));
AString HelpString(tolua_tocppstring(L, idx + 3, ""));
-
+
// Store the function reference:
lua_pop(L, 1); // Pop the help string off the stack
int FnRef = luaL_ref(L, LUA_REGISTRYINDEX); // Store function reference
@@ -1303,7 +1303,7 @@ static int tolua_cPluginManager_BindCommand(lua_State * L)
LOGERROR("\"BindCommand\": Cannot create a function reference. Command \"%s\" not bound.", Command.c_str());
return 0;
}
-
+
if (!self->BindCommand(Command, Plugin, Permission, HelpString))
{
// Refused. Possibly already bound. Error message has been given, display the callstack:
@@ -1311,7 +1311,7 @@ static int tolua_cPluginManager_BindCommand(lua_State * L)
LS.LogStackTrace();
return 0;
}
-
+
Plugin->BindCommand(Command, FnRef);
lua_pushboolean(L, true);
return 1;
@@ -1327,14 +1327,14 @@ static int tolua_cPluginManager_BindConsoleCommand(lua_State * L)
cPluginManager:BindConsoleCommand(Command, Function, HelpString)
cPluginManager.BindConsoleCommand(Command, Function, HelpString) -- without the "self" param
*/
-
+
// Get the plugin identification out of LuaState:
cPluginLua * Plugin = cManualBindings::GetLuaPlugin(L);
if (Plugin == nullptr)
{
return 0;
}
-
+
// Read the arguments to this API call:
tolua_Error tolua_err;
int idx = 1;
@@ -1362,7 +1362,7 @@ static int tolua_cPluginManager_BindConsoleCommand(lua_State * L)
cPluginManager * self = cPluginManager::Get();
AString Command (tolua_tocppstring(L, idx, ""));
AString HelpString(tolua_tocppstring(L, idx + 2, ""));
-
+
// Store the function reference:
lua_pop(L, 1); // Pop the help string off the stack
int FnRef = luaL_ref(L, LUA_REGISTRYINDEX); // Store function reference
@@ -1371,7 +1371,7 @@ static int tolua_cPluginManager_BindConsoleCommand(lua_State * L)
LOGERROR("\"BindConsoleCommand\": Cannot create a function reference. Console Command \"%s\" not bound.", Command.c_str());
return 0;
}
-
+
if (!self->BindConsoleCommand(Command, Plugin, HelpString))
{
// Refused. Possibly already bound. Error message has been given, display the callstack:
@@ -1379,7 +1379,7 @@ static int tolua_cPluginManager_BindConsoleCommand(lua_State * L)
LS.LogStackTrace();
return 0;
}
-
+
Plugin->BindConsoleCommand(Command, FnRef);
lua_pushboolean(L, true);
return 1;
@@ -1395,7 +1395,7 @@ static int tolua_cPluginManager_CallPlugin(lua_State * tolua_S)
Function signature:
cPluginManager:CallPlugin("PluginName", "FunctionName", args...)
*/
-
+
// Check the parameters:
cLuaState L(tolua_S);
if (
@@ -1404,7 +1404,7 @@ static int tolua_cPluginManager_CallPlugin(lua_State * tolua_S)
{
return 0;
}
-
+
// Retrieve the plugin name and function name
AString PluginName, FunctionName;
L.ToString(2, PluginName);
@@ -1415,7 +1415,7 @@ static int tolua_cPluginManager_CallPlugin(lua_State * tolua_S)
L.LogStackTrace();
return 0;
}
-
+
// If requesting calling the current plugin, refuse:
cPluginLua * ThisPlugin = cManualBindings::GetLuaPlugin(L);
if (ThisPlugin == nullptr)
@@ -1428,7 +1428,7 @@ static int tolua_cPluginManager_CallPlugin(lua_State * tolua_S)
L.LogStackTrace();
return 0;
}
-
+
// Call the destination plugin using a plugin callback:
class cCallback :
public cPluginManager::cPluginCallback
@@ -1445,7 +1445,7 @@ static int tolua_cPluginManager_CallPlugin(lua_State * tolua_S)
protected:
const AString & m_FunctionName;
cLuaState & m_SrcLuaState;
-
+
virtual bool Item(cPlugin * a_Plugin) override
{
if (!a_Plugin->IsLoaded())
@@ -1544,7 +1544,7 @@ static int tolua_cPlayer_GetPermissions(lua_State * tolua_S)
LOGWARNING("%s: invalid self (%p)", __FUNCTION__, static_cast<void *>(self));
return 0;
}
-
+
// Push the permissions:
L.Push(self->GetPermissions());
return 1;
@@ -1575,7 +1575,7 @@ static int tolua_cPlayer_GetRestrictions(lua_State * tolua_S)
LOGWARNING("%s: invalid self (%p)", __FUNCTION__, static_cast<void *>(self));
return 0;
}
-
+
// Push the permissions:
L.Push(self->GetRestrictions());
return 1;
@@ -1604,7 +1604,7 @@ static int tolua_cPlayer_OpenWindow(lua_State * tolua_S)
LOGWARNING("%s: invalid self (%p) or wnd (%p)", __FUNCTION__, static_cast<void *>(self), static_cast<void *>(wnd));
return 0;
}
-
+
// If cLuaWindow, add a reference, so that Lua won't delete the cLuaWindow object mid-processing
tolua_Error err;
if (tolua_isusertype(tolua_S, 2, "cLuaWindow", 0, &err))
@@ -1624,7 +1624,7 @@ static int tolua_cPlayer_OpenWindow(lua_State * tolua_S)
LuaWnd->SetLuaRef(Plugin, LuaRef);
}
}
-
+
// Open the window
self->OpenWindow(wnd);
return 0;
@@ -1652,7 +1652,7 @@ static int tolua_cPlayer_PermissionMatches(lua_State * tolua_S)
// Get the params:
AString Permission, Template;
L.GetStackValues(2, Permission, Template);
-
+
// Push the result of the match:
L.Push(cPlayer::PermissionMatches(StringSplit(Permission, "."), StringSplit(Template, ".")));
return 1;
@@ -1691,7 +1691,7 @@ static int tolua_SetObjectCallback(lua_State * tolua_S)
LOGERROR("%s: Cannot create a function reference. Callback not set.", __FUNCTION__);
return 0;
}
-
+
// Set the callback
(self->*SetCallback)(Plugin, FnRef);
return 0;
@@ -1711,7 +1711,7 @@ static int tolua_cPluginLua_AddWebTab(lua_State * tolua_S)
LOGWARNING("cPluginLua:AddWebTab: invalid self as first argument");
return 0;
}
-
+
tolua_Error tolua_err;
tolua_err.array = 0;
tolua_err.index = 3;
@@ -1752,14 +1752,14 @@ static int tolua_cPluginLua_AddWebTab(lua_State * tolua_S)
static int tolua_cPlugin_GetDirectory(lua_State * tolua_S)
{
cLuaState L(tolua_S);
-
+
// Log the obsoletion warning:
LOGWARNING("cPlugin:GetDirectory() is obsolete, use cPlugin:GetFolderName() instead.");
L.LogStackTrace();
-
+
// Retrieve the params:
cPlugin * Plugin = static_cast<cPluginLua *>(tolua_tousertype(tolua_S, 1, nullptr));
-
+
// Get the folder name:
L.Push(Plugin->GetFolderName());
return 1;
@@ -1772,14 +1772,14 @@ static int tolua_cPlugin_GetDirectory(lua_State * tolua_S)
static int tolua_cPlugin_GetLocalDirectory(lua_State * tolua_S)
{
cLuaState L(tolua_S);
-
+
// Log the obsoletion warning:
LOGWARNING("cPlugin:GetLocalDirectory() is obsolete, use cPlugin:GetLocalFolder() instead.");
L.LogStackTrace();
-
+
// Retrieve the params:
cPlugin * Plugin = static_cast<cPluginLua *>(tolua_tousertype(tolua_S, 1, nullptr));
-
+
// Get the folder:
L.Push(Plugin->GetLocalFolder());
return 1;
@@ -2145,11 +2145,11 @@ static int tolua_AllToLua_cWebAdmin_GetHTMLEscapedString(lua_State * tolua_S)
{
return 0;
}
-
+
// Get the parameters:
AString Input;
S.GetStackValue(2, Input);
-
+
// Convert and return:
S.Push(cWebAdmin::GetHTMLEscapedString(Input));
return 1;
@@ -2173,11 +2173,11 @@ static int tolua_AllToLua_cWebAdmin_GetURLEncodedString(lua_State * tolua_S)
{
return 0;
}
-
+
// Get the parameters:
AString Input;
S.GetStackValue(2, Input);
-
+
// Convert and return:
S.Push(cWebAdmin::GetURLEncodedString(Input));
return 1;
@@ -2249,12 +2249,12 @@ static int tolua_cMojangAPI_AddPlayerNameToUUIDMapping(lua_State * L)
{
return 0;
}
-
+
// Retrieve the parameters:
AString UUID, PlayerName;
S.GetStackValue(2, PlayerName);
S.GetStackValue(3, UUID);
-
+
// Store in the cache:
cRoot::Get()->GetMojangAPI().AddPlayerNameToUUIDMapping(PlayerName, UUID);
return 0;
@@ -2275,10 +2275,10 @@ static int tolua_cMojangAPI_GetPlayerNameFromUUID(lua_State * L)
{
return 0;
}
-
+
AString UUID;
S.GetStackValue(2, UUID);
-
+
// If the UseOnlyCached param was given, read it; default to false
bool ShouldUseCacheOnly = false;
if (lua_gettop(L) == 3)
@@ -2308,10 +2308,10 @@ static int tolua_cMojangAPI_GetUUIDFromPlayerName(lua_State * L)
{
return 0;
}
-
+
AString PlayerName;
S.GetStackValue(2, PlayerName);
-
+
// If the UseOnlyCached param was given, read it; default to false
bool ShouldUseCacheOnly = false;
if (lua_gettop(L) == 3)
@@ -2341,7 +2341,7 @@ static int tolua_cMojangAPI_GetUUIDsFromPlayerNames(lua_State * L)
{
return 0;
}
-
+
// Convert the input table into AStringVector:
AStringVector PlayerNames;
int NumNames = luaL_getn(L, 2);
@@ -2357,7 +2357,7 @@ static int tolua_cMojangAPI_GetUUIDsFromPlayerNames(lua_State * L)
}
lua_pop(L, 1);
}
-
+
// If the UseOnlyCached param was given, read it; default to false
bool ShouldUseCacheOnly = false;
if (lua_gettop(L) == 3)
@@ -2368,7 +2368,7 @@ static int tolua_cMojangAPI_GetUUIDsFromPlayerNames(lua_State * L)
// Push the output table onto the stack:
lua_newtable(L);
-
+
// Get the UUIDs:
AStringVector UUIDs = cRoot::Get()->GetMojangAPI().GetUUIDsFromPlayerNames(PlayerNames, ShouldUseCacheOnly);
if (UUIDs.size() != PlayerNames.size())
@@ -2376,7 +2376,7 @@ static int tolua_cMojangAPI_GetUUIDsFromPlayerNames(lua_State * L)
// A hard error has occured while processing the request, no UUIDs were returned. Return an empty table:
return 1;
}
-
+
// Convert to output table, PlayerName -> UUID:
size_t len = UUIDs.size();
for (size_t i = 0; i < len; i++)
@@ -2410,7 +2410,7 @@ static int tolua_cMojangAPI_MakeUUIDDashed(lua_State * L)
{
return 0;
}
-
+
// Get the params:
AString UUID;
S.GetStackValue(2, UUID);
@@ -2438,7 +2438,7 @@ static int tolua_cMojangAPI_MakeUUIDShort(lua_State * L)
{
return 0;
}
-
+
// Get the params:
AString UUID;
S.GetStackValue(2, UUID);
@@ -2478,7 +2478,7 @@ static int Lua_ItemGrid_GetSlotCoords(lua_State * L)
tolua_pushnumber(L, static_cast<lua_Number>(Y));
return 2;
}
-
+
tolua_lerror:
tolua_error(L, "#ferror in function 'cItemGrid:GetSlotCoords'.", &tolua_err);
return 0;
@@ -2498,7 +2498,7 @@ public:
m_TableRef(a_LuaState, a_ParamNum)
{
}
-
+
virtual bool OnNextBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, char a_EntryFace) override
{
bool res = false;
@@ -2513,7 +2513,7 @@ public:
}
return res;
}
-
+
virtual bool OnNextBlockNoData(int a_BlockX, int a_BlockY, int a_BlockZ, char a_EntryFace) override
{
bool res = false;
@@ -2528,7 +2528,7 @@ public:
}
return res;
}
-
+
virtual bool OnOutOfWorld(double a_BlockX, double a_BlockY, double a_BlockZ) override
{
bool res = false;
@@ -2543,7 +2543,7 @@ public:
}
return res;
}
-
+
virtual bool OnIntoWorld(double a_BlockX, double a_BlockY, double a_BlockZ) override
{
bool res = false;
@@ -2558,12 +2558,12 @@ public:
}
return res;
}
-
+
virtual void OnNoMoreHits(void) override
{
m_LuaState.Call(cLuaState::cTableRef(m_TableRef, "OnNoMoreHits"));
}
-
+
virtual void OnNoChunk(void) override
{
m_LuaState.Call(cLuaState::cTableRef(m_TableRef, "OnNoChunk"));
@@ -2584,7 +2584,7 @@ static int tolua_cLineBlockTracer_Trace(lua_State * tolua_S)
cLineBlockTracer:Trace(World, Callbacks, StartX, StartY, StartZ, EndX, EndY, EndZ) // Canonical
cLineBlockTracer.Trace(World, Callbacks, StartX, StartY, StartZ, EndX, EndY, EndZ)
*/
-
+
// If the first param is the cLineBlockTracer class, shift param index by one:
int idx = 1;
tolua_Error err;
@@ -2592,7 +2592,7 @@ static int tolua_cLineBlockTracer_Trace(lua_State * tolua_S)
{
idx = 2;
}
-
+
// Check params:
cLuaState L(tolua_S);
if (
@@ -2726,7 +2726,7 @@ static int tolua_cRoot_GetFurnaceRecipe(lua_State * tolua_S)
{
return 0;
}
-
+
// Check the input param:
cItem * Input = nullptr;
L.GetStackValue(2, Input);
@@ -2735,7 +2735,7 @@ static int tolua_cRoot_GetFurnaceRecipe(lua_State * tolua_S)
LOGWARNING("cRoot:GetFurnaceRecipe: the Input parameter is nil or missing.");
return 0;
}
-
+
// Get the recipe for the input
cFurnaceRecipe * FR = cRoot::Get()->GetFurnaceRecipe();
const cFurnaceRecipe::cRecipe * Recipe = FR->GetRecipeFrom(*Input);
@@ -2744,7 +2744,7 @@ static int tolua_cRoot_GetFurnaceRecipe(lua_State * tolua_S)
// There is no such furnace recipe for this input, return no value
return 0;
}
-
+
// Push the output, number of ticks and input as the three return values:
L.Push(Recipe->Out);
L.Push(Recipe->CookTime);
@@ -2760,7 +2760,7 @@ static int tolua_cHopperEntity_GetOutputBlockPos(lua_State * tolua_S)
{
// function cHopperEntity::GetOutputBlockPos()
// Exported manually because tolua would require meaningless params
-
+
cLuaState L(tolua_S);
if (
!L.CheckParamUserType(1, "cHopperEntity") ||
@@ -2800,7 +2800,7 @@ static int tolua_cBlockArea_GetBlockTypeMeta(lua_State * tolua_S)
{
// function cBlockArea::GetBlockTypeMeta()
// Exported manually because tolua generates extra input params for the outputs
-
+
cLuaState L(tolua_S);
if (
!L.CheckParamUserType(1, "cBlockArea") ||
@@ -2809,7 +2809,7 @@ static int tolua_cBlockArea_GetBlockTypeMeta(lua_State * tolua_S)
{
return 0;
}
-
+
cBlockArea * self = reinterpret_cast<cBlockArea *>(tolua_tousertype(tolua_S, 1, nullptr));
if (self == nullptr)
{
@@ -2837,20 +2837,20 @@ static int tolua_cBlockArea_GetOrigin(lua_State * tolua_S)
// 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 = reinterpret_cast<cBlockArea *>(tolua_tousertype(tolua_S, 1, nullptr));
if (self == nullptr)
{
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetOrigin'", nullptr);
return 0;
}
-
+
// Push the three origin coords:
lua_pushnumber(tolua_S, self->GetOriginX());
lua_pushnumber(tolua_S, self->GetOriginY());
@@ -2866,13 +2866,13 @@ static int tolua_cBlockArea_GetNonAirCropRelCoords(lua_State * tolua_S)
{
// function cBlockArea::GetNonAirCropRelCoords()
// Exported manually because tolua would generate extra input params for the outputs
-
+
cLuaState L(tolua_S);
if (!L.CheckParamUserType(1, "cBlockArea"))
{
return 0;
}
-
+
cBlockArea * self = nullptr;
BLOCKTYPE IgnoreBlockType = E_BLOCK_AIR;
L.GetStackValues(1, self, IgnoreBlockType);
@@ -2881,7 +2881,7 @@ static int tolua_cBlockArea_GetNonAirCropRelCoords(lua_State * tolua_S)
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetNonAirCropRelCoords'", nullptr);
return 0;
}
-
+
// Calculate the crop coords:
int MinRelX, MinRelY, MinRelZ, MaxRelX, MaxRelY, MaxRelZ;
self->GetNonAirCropRelCoords(MinRelX, MinRelY, MinRelZ, MaxRelX, MaxRelY, MaxRelZ, IgnoreBlockType);
@@ -2904,7 +2904,7 @@ static int tolua_cBlockArea_GetRelBlockTypeMeta(lua_State * tolua_S)
{
// function cBlockArea::GetRelBlockTypeMeta()
// Exported manually because tolua generates extra input params for the outputs
-
+
cLuaState L(tolua_S);
if (
!L.CheckParamUserType(1, "cBlockArea") ||
@@ -2913,7 +2913,7 @@ static int tolua_cBlockArea_GetRelBlockTypeMeta(lua_State * tolua_S)
{
return 0;
}
-
+
cBlockArea * self = reinterpret_cast<cBlockArea *>(tolua_tousertype(tolua_S, 1, nullptr));
if (self == nullptr)
{
@@ -2941,20 +2941,20 @@ static int tolua_cBlockArea_GetSize(lua_State * tolua_S)
// 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 = reinterpret_cast<cBlockArea *>(tolua_tousertype(tolua_S, 1, nullptr));
if (self == nullptr)
{
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetSize'", nullptr);
return 0;
}
-
+
// Push the three origin coords:
lua_pushnumber(tolua_S, self->GetSizeX());
lua_pushnumber(tolua_S, self->GetSizeY());
@@ -2972,20 +2972,20 @@ static int tolua_cBlockArea_GetCoordRange(lua_State * tolua_S)
// Returns all three sizes of the area, miuns one, so that they represent the maximum coord value
// 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 = reinterpret_cast<cBlockArea *>(tolua_tousertype(tolua_S, 1, nullptr));
if (self == nullptr)
{
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetSize'", nullptr);
return 0;
}
-
+
// Push the three origin coords:
lua_pushnumber(tolua_S, self->GetSizeX() - 1);
lua_pushnumber(tolua_S, self->GetSizeY() - 1);
@@ -3105,7 +3105,7 @@ static int tolua_cBlockArea_SaveToSchematicString(lua_State * tolua_S)
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea::SaveToSchematicFile'", nullptr);
return 0;
}
-
+
AString Data;
if (cSchematicFileSerializer::SaveToSchematicString(*self, Data))
{
@@ -3123,7 +3123,7 @@ static int tolua_cCompositeChat_AddRunCommandPart(lua_State * tolua_S)
{
// function cCompositeChat:AddRunCommandPart(Message, Command, [Style])
// Exported manually to support call-chaining (return *this)
-
+
// Check params:
cLuaState L(tolua_S);
if (
@@ -3139,14 +3139,14 @@ static int tolua_cCompositeChat_AddRunCommandPart(lua_State * tolua_S)
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:AddRunCommandPart'", nullptr);
return 0;
}
-
+
// Add the part:
AString Text, Command, Style;
L.GetStackValue(2, Text);
L.GetStackValue(3, Command);
L.GetStackValue(4, Style);
self->AddRunCommandPart(Text, Command, Style);
-
+
// Cut away everything from the stack except for the cCompositeChat instance; return that:
lua_settop(L, 1);
return 1;
@@ -3160,7 +3160,7 @@ static int tolua_cCompositeChat_AddSuggestCommandPart(lua_State * tolua_S)
{
// function cCompositeChat:AddSuggestCommandPart(Message, Command, [Style])
// Exported manually to support call-chaining (return *this)
-
+
// Check params:
cLuaState L(tolua_S);
if (
@@ -3176,14 +3176,14 @@ static int tolua_cCompositeChat_AddSuggestCommandPart(lua_State * tolua_S)
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:AddSuggestCommandPart'", nullptr);
return 0;
}
-
+
// Add the part:
AString Text, Command, Style;
L.GetStackValue(2, Text);
L.GetStackValue(3, Command);
L.GetStackValue(4, Style);
self->AddSuggestCommandPart(Text, Command, Style);
-
+
// Cut away everything from the stack except for the cCompositeChat instance; return that:
lua_settop(L, 1);
return 1;
@@ -3197,7 +3197,7 @@ static int tolua_cCompositeChat_AddTextPart(lua_State * tolua_S)
{
// function cCompositeChat:AddTextPart(Message, [Style])
// Exported manually to support call-chaining (return *this)
-
+
// Check params:
cLuaState L(tolua_S);
if (
@@ -3213,13 +3213,13 @@ static int tolua_cCompositeChat_AddTextPart(lua_State * tolua_S)
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:AddTextPart'", nullptr);
return 0;
}
-
+
// Add the part:
AString Text, Style;
L.GetStackValue(2, Text);
L.GetStackValue(3, Style);
self->AddTextPart(Text, Style);
-
+
// Cut away everything from the stack except for the cCompositeChat instance; return that:
lua_settop(L, 1);
return 1;
@@ -3233,7 +3233,7 @@ static int tolua_cCompositeChat_AddUrlPart(lua_State * tolua_S)
{
// function cCompositeChat:AddTextPart(Message, Url, [Style])
// Exported manually to support call-chaining (return *this)
-
+
// Check params:
cLuaState L(tolua_S);
if (
@@ -3249,14 +3249,14 @@ static int tolua_cCompositeChat_AddUrlPart(lua_State * tolua_S)
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:AddUrlPart'", nullptr);
return 0;
}
-
+
// Add the part:
AString Text, Url, Style;
L.GetStackValue(2, Text);
L.GetStackValue(3, Url);
L.GetStackValue(4, Style);
self->AddUrlPart(Text, Url, Style);
-
+
// Cut away everything from the stack except for the cCompositeChat instance; return that:
lua_settop(L, 1);
return 1;
@@ -3270,7 +3270,7 @@ static int tolua_cCompositeChat_ParseText(lua_State * tolua_S)
{
// function cCompositeChat:ParseText(TextMessage)
// Exported manually to support call-chaining (return *this)
-
+
// Check params:
cLuaState L(tolua_S);
if (
@@ -3286,12 +3286,12 @@ static int tolua_cCompositeChat_ParseText(lua_State * tolua_S)
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:ParseText'", nullptr);
return 0;
}
-
+
// Parse the text:
AString Text;
L.GetStackValue(2, Text);
self->ParseText(Text);
-
+
// Cut away everything from the stack except for the cCompositeChat instance; return that:
lua_settop(L, 1);
return 1;
@@ -3305,7 +3305,7 @@ static int tolua_cCompositeChat_SetMessageType(lua_State * tolua_S)
{
// function cCompositeChat:SetMessageType(MessageType)
// Exported manually to support call-chaining (return *this)
-
+
// Check params:
cLuaState L(tolua_S);
if (
@@ -3321,12 +3321,12 @@ static int tolua_cCompositeChat_SetMessageType(lua_State * tolua_S)
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:SetMessageType'", nullptr);
return 0;
}
-
+
// Set the type:
int MessageType = mtCustom;
L.GetStackValue(2, MessageType);
self->SetMessageType(static_cast<eMessageType>(MessageType));
-
+
// Cut away everything from the stack except for the cCompositeChat instance; return that:
lua_settop(L, 1);
return 1;
@@ -3340,7 +3340,7 @@ static int tolua_cCompositeChat_UnderlineUrls(lua_State * tolua_S)
{
// function cCompositeChat:UnderlineUrls()
// Exported manually to support call-chaining (return *this)
-
+
// Check params:
cLuaState L(tolua_S);
if (!L.CheckParamUserType(1, "cCompositeChat"))
@@ -3353,10 +3353,10 @@ static int tolua_cCompositeChat_UnderlineUrls(lua_State * tolua_S)
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:UnderlineUrls'", nullptr);
return 0;
}
-
+
// Call the processing
self->UnderlineUrls();
-
+
// Cut away everything from the stack except for the cCompositeChat instance; return that:
lua_settop(L, 1);
return 1;
@@ -3494,7 +3494,7 @@ void cManualBindings::Bind(lua_State * tolua_S)
tolua_function(tolua_S, "GetDirectory", tolua_cPlugin_GetDirectory);
tolua_function(tolua_S, "GetLocalDirectory", tolua_cPlugin_GetLocalDirectory);
tolua_endmodule(tolua_S);
-
+
tolua_beginmodule(tolua_S, "cPluginLua");
tolua_function(tolua_S, "AddWebTab", tolua_cPluginLua_AddWebTab);
tolua_endmodule(tolua_S);
diff --git a/src/Bindings/ManualBindings.h b/src/Bindings/ManualBindings.h
index f124084a9..98e3e88ef 100644
--- a/src/Bindings/ManualBindings.h
+++ b/src/Bindings/ManualBindings.h
@@ -27,7 +27,7 @@ class cManualBindings
public:
/** Binds all the manually implemented functions to tolua_S. */
static void Bind(lua_State * tolua_S);
-
+
protected:
/** Binds the manually implemented cNetwork-related API to tolua_S.
Implemented in ManualBindings_Network.cpp. */
diff --git a/src/Bindings/ManualBindings_Network.cpp b/src/Bindings/ManualBindings_Network.cpp
index 1631cdfec..576fe94b7 100644
--- a/src/Bindings/ManualBindings_Network.cpp
+++ b/src/Bindings/ManualBindings_Network.cpp
@@ -37,7 +37,7 @@ static int tolua_cNetwork_Connect(lua_State * L)
{
return 0;
}
-
+
// Get the plugin instance:
cPluginLua * Plugin = cManualBindings::GetLuaPlugin(L);
if (Plugin == nullptr)
@@ -90,7 +90,7 @@ static int tolua_cNetwork_CreateUDPEndpoint(lua_State * L)
{
return 0;
}
-
+
// Get the plugin instance:
cPluginLua * Plugin = cManualBindings::GetLuaPlugin(L);
if (Plugin == nullptr)
@@ -142,7 +142,7 @@ static int tolua_cNetwork_EnumLocalIPAddresses(lua_State * L)
{
return 0;
}
-
+
// Push the enumerated addresses:
S.Push(cNetwork::EnumLocalIPAddresses());
return 1;
@@ -168,7 +168,7 @@ static int tolua_cNetwork_HostnameToIP(lua_State * L)
{
return 0;
}
-
+
// Get the plugin instance:
cPluginLua * Plugin = cManualBindings::GetLuaPlugin(L);
if (Plugin == nullptr)
@@ -209,7 +209,7 @@ static int tolua_cNetwork_IPToHostname(lua_State * L)
{
return 0;
}
-
+
// Get the plugin instance:
cPluginLua * Plugin = cManualBindings::GetLuaPlugin(L);
if (Plugin == nullptr)
@@ -250,7 +250,7 @@ static int tolua_cNetwork_Listen(lua_State * L)
{
return 0;
}
-
+
// Get the plugin instance:
cPluginLua * Plugin = cManualBindings::GetLuaPlugin(L);
if (Plugin == nullptr)
@@ -320,7 +320,7 @@ static int tolua_cServerHandle_Close(lua_State * L)
{
return 0;
}
-
+
// Get the server handle:
cLuaServerHandle * Srv;
if (lua_isnil(L, 1))
@@ -354,7 +354,7 @@ static int tolua_cServerHandle_IsListening(lua_State * L)
{
return 0;
}
-
+
// Get the server handle:
cLuaServerHandle * Srv;
if (lua_isnil(L, 1))
@@ -391,7 +391,7 @@ static int tolua_cTCPLink_Close(lua_State * L)
{
return 0;
}
-
+
// Get the link:
cLuaTCPLink * Link;
if (lua_isnil(L, 1))
@@ -425,7 +425,7 @@ static int tolua_cTCPLink_GetLocalIP(lua_State * L)
{
return 0;
}
-
+
// Get the link:
cLuaTCPLink * Link;
if (lua_isnil(L, 1))
@@ -459,7 +459,7 @@ static int tolua_cTCPLink_GetLocalPort(lua_State * L)
{
return 0;
}
-
+
// Get the link:
cLuaTCPLink * Link;
if (lua_isnil(L, 1))
@@ -493,7 +493,7 @@ static int tolua_cTCPLink_GetRemoteIP(lua_State * L)
{
return 0;
}
-
+
// Get the link:
cLuaTCPLink * Link;
if (lua_isnil(L, 1))
@@ -527,7 +527,7 @@ static int tolua_cTCPLink_GetRemotePort(lua_State * L)
{
return 0;
}
-
+
// Get the link:
cLuaTCPLink * Link;
if (lua_isnil(L, 1))
@@ -562,7 +562,7 @@ static int tolua_cTCPLink_Send(lua_State * L)
{
return 0;
}
-
+
// Get the link:
cLuaTCPLink * Link;
if (lua_isnil(L, 1))
@@ -600,7 +600,7 @@ static int tolua_cTCPLink_Shutdown(lua_State * L)
{
return 0;
}
-
+
// Get the link:
cLuaTCPLink * Link;
if (lua_isnil(L, 1))
@@ -671,7 +671,7 @@ static int tolua_cTCPLink_StartTLSServer(lua_State * L)
{
return 0;
}
-
+
// Get the link:
cLuaTCPLink * Link;
if (lua_isnil(L, 1))
@@ -732,7 +732,7 @@ static int tolua_cUDPEndpoint_Close(lua_State * L)
{
return 0;
}
-
+
// Get the endpoint:
if (lua_isnil(L, 1))
{
@@ -765,7 +765,7 @@ static int tolua_cUDPEndpoint_EnableBroadcasts(lua_State * L)
{
return 0;
}
-
+
// Get the endpoint:
if (lua_isnil(L, 1))
{
@@ -798,7 +798,7 @@ static int tolua_cUDPEndpoint_GetPort(lua_State * L)
{
return 0;
}
-
+
// Get the endpoint:
if (lua_isnil(L, 1))
{
@@ -831,7 +831,7 @@ static int tolua_cUDPEndpoint_IsOpen(lua_State * L)
{
return 0;
}
-
+
// Get the endpoint:
if (lua_isnil(L, 1))
{
@@ -866,7 +866,7 @@ static int tolua_cUDPEndpoint_Send(lua_State * L)
{
return 0;
}
-
+
// Get the link:
if (lua_isnil(L, 1))
{
@@ -913,7 +913,7 @@ void cManualBindings::BindNetwork(lua_State * tolua_S)
tolua_cclass(tolua_S, "cServerHandle", "cServerHandle", "", tolua_collect_cServerHandle);
tolua_cclass(tolua_S, "cTCPLink", "cTCPLink", "", nullptr);
tolua_cclass(tolua_S, "cUDPEndpoint", "cUDPEndpoint", "", tolua_collect_cUDPEndpoint);
-
+
// Fill in the functions (alpha-sorted):
tolua_beginmodule(tolua_S, "cNetwork");
tolua_function(tolua_S, "Connect", tolua_cNetwork_Connect);
diff --git a/src/Bindings/ManualBindings_RankManager.cpp b/src/Bindings/ManualBindings_RankManager.cpp
index 7797d1887..99c0cc63f 100644
--- a/src/Bindings/ManualBindings_RankManager.cpp
+++ b/src/Bindings/ManualBindings_RankManager.cpp
@@ -28,11 +28,11 @@ static int tolua_cRankManager_AddGroup(lua_State * L)
{
return 0;
}
-
+
// Read the params:
AString GroupName;
S.GetStackValue(2, GroupName);
-
+
// Add the group:
cRoot::Get()->GetRankManager()->AddGroup(GroupName);
return 0;
@@ -57,11 +57,11 @@ static int tolua_cRankManager_AddGroupToRank(lua_State * L)
{
return 0;
}
-
+
// Read the params:
AString GroupName, RankName;
S.GetStackValues(2, GroupName, RankName);
-
+
// Add the group to the rank:
S.Push(cRoot::Get()->GetRankManager()->AddGroupToRank(GroupName, RankName));
return 1;
@@ -86,11 +86,11 @@ static int tolua_cRankManager_AddPermissionToGroup(lua_State * L)
{
return 0;
}
-
+
// Read the params:
AString GroupName, Permission;
S.GetStackValues(2, Permission, GroupName);
-
+
// Add the group to the rank:
S.Push(cRoot::Get()->GetRankManager()->AddPermissionToGroup(Permission, GroupName));
return 1;
@@ -115,11 +115,11 @@ static int tolua_cRankManager_AddRestrictionToGroup(lua_State * L)
{
return 0;
}
-
+
// Read the params:
AString GroupName, Permission;
S.GetStackValues(2, Permission, GroupName);
-
+
// Add the group to the rank:
S.Push(cRoot::Get()->GetRankManager()->AddRestrictionToGroup(Permission, GroupName));
return 1;
@@ -134,7 +134,7 @@ static int tolua_cRankManager_AddRank(lua_State * L)
{
// Function signature:
// cRankManager:AddRank(RankName)
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -144,11 +144,11 @@ static int tolua_cRankManager_AddRank(lua_State * L)
{
return 0;
}
-
+
// Read the params:
AString RankName, MsgPrefix, MsgSuffix, MsgNameColorCode;
S.GetStackValues(2, RankName, MsgPrefix, MsgSuffix, MsgNameColorCode);
-
+
// Add the rank:
cRoot::Get()->GetRankManager()->AddRank(RankName, MsgPrefix, MsgSuffix, MsgNameColorCode);
return 0;
@@ -184,7 +184,7 @@ static int tolua_cRankManager_GetAllGroups(lua_State * L)
{
// Function signature:
// cRankManager:GetAllGroups() -> arraytable of GroupNames
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -193,10 +193,10 @@ static int tolua_cRankManager_GetAllGroups(lua_State * L)
{
return 0;
}
-
+
// Get the groups:
AStringVector Groups = cRoot::Get()->GetRankManager()->GetAllGroups();
-
+
// Push the results:
S.Push(Groups);
return 1;
@@ -211,7 +211,7 @@ static int tolua_cRankManager_GetAllPermissions(lua_State * L)
{
// Function signature:
// cRankManager:GetAllPermissions() -> arraytable of Permissions
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -220,10 +220,10 @@ static int tolua_cRankManager_GetAllPermissions(lua_State * L)
{
return 0;
}
-
+
// Get the permissions:
AStringVector Permissions = cRoot::Get()->GetRankManager()->GetAllPermissions();
-
+
// Push the results:
S.Push(Permissions);
return 1;
@@ -238,7 +238,7 @@ static int tolua_cRankManager_GetAllRestrictions(lua_State * L)
{
// Function signature:
// cRankManager:GetAllRestrictions() -> arraytable of Permissions
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -247,10 +247,10 @@ 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);
return 1;
@@ -265,7 +265,7 @@ static int tolua_cRankManager_GetAllPermissionsRestrictions(lua_State * L)
{
// Function signature:
// cRankManager:GetAllPermissionsRestrictions() -> arraytable of Permissions and Restrictions
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -274,10 +274,10 @@ static int tolua_cRankManager_GetAllPermissionsRestrictions(lua_State * L)
{
return 0;
}
-
+
// Get the permissions:
AStringVector Permissions = cRoot::Get()->GetRankManager()->GetAllPermissionsRestrictions();
-
+
// Push the results:
S.Push(Permissions);
return 1;
@@ -319,7 +319,7 @@ static int tolua_cRankManager_GetAllRanks(lua_State * L)
{
// Function signature:
// cRankManager:GetAllRanks() -> arraytable of RankNames
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -328,10 +328,10 @@ 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);
return 1;
@@ -346,7 +346,7 @@ static int tolua_cRankManager_GetDefaultRank(lua_State * L)
{
// Function signature:
// cRankManager:GetDefaultRank() -> string
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -355,7 +355,7 @@ static int tolua_cRankManager_GetDefaultRank(lua_State * L)
{
return 0;
}
-
+
// Return the rank name:
S.Push(cRoot::Get()->GetRankManager()->GetDefaultRank());
return 1;
@@ -370,7 +370,7 @@ static int tolua_cRankManager_GetGroupPermissions(lua_State * L)
{
// Function signature:
// cRankManager:GetGroupPermissions(GroupName) -> arraytable of permissions
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -380,14 +380,14 @@ static int tolua_cRankManager_GetGroupPermissions(lua_State * L)
{
return 0;
}
-
+
// Get the params:
AString GroupName;
S.GetStackValue(2, GroupName);
-
+
// Get the permissions:
AStringVector Permissions = cRoot::Get()->GetRankManager()->GetGroupPermissions(GroupName);
-
+
// Push the results:
S.Push(Permissions);
return 1;
@@ -402,7 +402,7 @@ static int tolua_cRankManager_GetGroupRestrictions(lua_State * L)
{
// Function signature:
// cRankManager:GetGroupRestrictions(GroupName) -> arraytable of restrictions
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -412,14 +412,14 @@ static int tolua_cRankManager_GetGroupRestrictions(lua_State * L)
{
return 0;
}
-
+
// Get the params:
AString GroupName;
S.GetStackValue(2, GroupName);
-
+
// Get the restrictions:
AStringVector Restrictions = cRoot::Get()->GetRankManager()->GetGroupRestrictions(GroupName);
-
+
// Push the results:
S.Push(Restrictions);
return 1;
@@ -434,7 +434,7 @@ static int tolua_cRankManager_GetPlayerGroups(lua_State * L)
{
// Function signature:
// cRankManager:GetPlayerGroups(PlayerUUID) -> arraytable of GroupNames
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -444,14 +444,14 @@ static int tolua_cRankManager_GetPlayerGroups(lua_State * L)
{
return 0;
}
-
+
// Get the params:
AString PlayerUUID;
S.GetStackValue(2, PlayerUUID);
-
+
// Get the groups:
AStringVector Groups = cRoot::Get()->GetRankManager()->GetPlayerGroups(PlayerUUID);
-
+
// Push the results:
S.Push(Groups);
return 1;
@@ -466,7 +466,7 @@ static int tolua_cRankManager_GetPlayerMsgVisuals(lua_State * L)
{
// Function signature:
// cRankManager:GetPlayerMsgVisuals(PlayerUUID) -> string, string, string
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -476,18 +476,18 @@ static int tolua_cRankManager_GetPlayerMsgVisuals(lua_State * L)
{
return 0;
}
-
+
// Get the params:
AString PlayerUUID;
S.GetStackValue(2, PlayerUUID);
-
+
// Get the permissions:
AString MsgPrefix, MsgSuffix, MsgNameColorCode;
if (!cRoot::Get()->GetRankManager()->GetPlayerMsgVisuals(PlayerUUID, MsgPrefix, MsgSuffix, MsgNameColorCode))
{
return 0;
}
-
+
// Push the results:
S.Push(MsgPrefix);
S.Push(MsgSuffix);
@@ -504,7 +504,7 @@ static int tolua_cRankManager_GetPlayerPermissions(lua_State * L)
{
// Function signature:
// cRankManager:GetPlayerPermissions(PlayerUUID) -> arraytable of permissions
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -514,14 +514,14 @@ static int tolua_cRankManager_GetPlayerPermissions(lua_State * L)
{
return 0;
}
-
+
// Get the params:
AString PlayerUUID;
S.GetStackValue(2, PlayerUUID);
-
+
// Get the permissions:
AStringVector Permissions = cRoot::Get()->GetRankManager()->GetPlayerPermissions(PlayerUUID);
-
+
// Push the results:
S.Push(Permissions);
return 1;
@@ -536,7 +536,7 @@ static int tolua_cRankManager_GetPlayerRestrictions(lua_State * L)
{
// Function signature:
// cRankManager:GetPlayerRestrictions(PlayerUUID) -> arraytable of restrictions
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -546,14 +546,14 @@ static int tolua_cRankManager_GetPlayerRestrictions(lua_State * L)
{
return 0;
}
-
+
// Get the params:
AString PlayerUUID;
S.GetStackValue(2, PlayerUUID);
-
+
// Get the permissions:
AStringVector Restrictions = cRoot::Get()->GetRankManager()->GetPlayerRestrictions(PlayerUUID);
-
+
// Push the results:
S.Push(Restrictions);
return 1;
@@ -568,7 +568,7 @@ static int tolua_cRankManager_GetPlayerRankName(lua_State * L)
{
// Function signature:
// cRankManager:GetPlayerRankName(PlayerUUID) -> string
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -578,14 +578,14 @@ static int tolua_cRankManager_GetPlayerRankName(lua_State * L)
{
return 0;
}
-
+
// Get the params:
AString PlayerUUID;
S.GetStackValue(2, PlayerUUID);
-
+
// Get the rank name:
AString RankName = cRoot::Get()->GetRankManager()->GetPlayerRankName(PlayerUUID);
-
+
// Push the result:
S.Push(RankName);
return 1;
@@ -632,7 +632,7 @@ static int tolua_cRankManager_GetRankGroups(lua_State * L)
{
// Function signature:
// cRankManager:GetRankGroups(RankName) -> arraytable of groupnames
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -642,14 +642,14 @@ static int tolua_cRankManager_GetRankGroups(lua_State * L)
{
return 0;
}
-
+
// Get the params:
AString RankName;
S.GetStackValue(2, RankName);
-
+
// Get the groups:
AStringVector Groups = cRoot::Get()->GetRankManager()->GetRankGroups(RankName);
-
+
// Push the results:
S.Push(Groups);
return 1;
@@ -664,7 +664,7 @@ static int tolua_cRankManager_GetRankPermissions(lua_State * L)
{
// Function signature:
// cRankManager:GetRankPermissions(RankName) -> arraytable of permissions
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -674,14 +674,14 @@ static int tolua_cRankManager_GetRankPermissions(lua_State * L)
{
return 0;
}
-
+
// Get the params:
AString RankName;
S.GetStackValue(2, RankName);
-
+
// Get the permissions:
AStringVector Permissions = cRoot::Get()->GetRankManager()->GetRankPermissions(RankName);
-
+
// Push the results:
S.Push(Permissions);
return 1;
@@ -696,7 +696,7 @@ static int tolua_cRankManager_GetRankRestrictions(lua_State * L)
{
// Function signature:
// cRankManager:GetRankRestrictions(RankName) -> arraytable of restrictions
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -706,14 +706,14 @@ static int tolua_cRankManager_GetRankRestrictions(lua_State * L)
{
return 0;
}
-
+
// Get the params:
AString RankName;
S.GetStackValue(2, RankName);
-
+
// Get the permissions:
AStringVector Restrictions = cRoot::Get()->GetRankManager()->GetRankRestrictions(RankName);
-
+
// Push the results:
S.Push(Restrictions);
return 1;
@@ -728,7 +728,7 @@ static int tolua_cRankManager_GetRankVisuals(lua_State * L)
{
// Function signature:
// cRankManager:GetRankVisuals(RankName) -> MsgPrefix, MsgSuffix, MsgNameColorCode
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -738,11 +738,11 @@ static int tolua_cRankManager_GetRankVisuals(lua_State * L)
{
return 0;
}
-
+
// Get the params:
AString RankName;
S.GetStackValue(2, RankName);
-
+
// Get the visuals:
AString MsgPrefix, MsgSuffix, MsgNameColorCode;
if (!cRoot::Get()->GetRankManager()->GetRankVisuals(RankName, MsgPrefix, MsgSuffix, MsgNameColorCode))
@@ -750,7 +750,7 @@ static int tolua_cRankManager_GetRankVisuals(lua_State * L)
// No such rank, return nothing:
return 0;
}
-
+
// Push the results:
S.Push(MsgPrefix);
S.Push(MsgSuffix);
@@ -767,7 +767,7 @@ static int tolua_cRankManager_GroupExists(lua_State * L)
{
// Function signature:
// cRankManager:GroupExists(GroupName) -> bool
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -777,14 +777,14 @@ static int tolua_cRankManager_GroupExists(lua_State * L)
{
return 0;
}
-
+
// Get the params:
AString GroupName;
S.GetStackValue(2, GroupName);
-
+
// Get the response:
bool res = cRoot::Get()->GetRankManager()->GroupExists(GroupName);
-
+
// Push the result:
S.Push(res);
return 1;
@@ -799,7 +799,7 @@ static int tolua_cRankManager_IsGroupInRank(lua_State * L)
{
// Function signature:
// cRankManager:IsGroupInRank(GroupName, RankName) -> bool
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -809,14 +809,14 @@ static int tolua_cRankManager_IsGroupInRank(lua_State * L)
{
return 0;
}
-
+
// Get the params:
AString GroupName, RankName;
S.GetStackValues(2, GroupName, RankName);
-
+
// Get the response:
bool res = cRoot::Get()->GetRankManager()->IsGroupInRank(GroupName, RankName);
-
+
// Push the result:
S.Push(res);
return 1;
@@ -831,7 +831,7 @@ static int tolua_cRankManager_IsPermissionInGroup(lua_State * L)
{
// Function signature:
// cRankManager:IsPermissionInGroup(Permission, GroupName) -> bool
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -841,14 +841,14 @@ static int tolua_cRankManager_IsPermissionInGroup(lua_State * L)
{
return 0;
}
-
+
// Get the params:
AString GroupName, Permission;
S.GetStackValues(2, Permission, GroupName);
-
+
// Get the response:
bool res = cRoot::Get()->GetRankManager()->IsPermissionInGroup(Permission, GroupName);
-
+
// Push the result:
S.Push(res);
return 1;
@@ -863,7 +863,7 @@ static int tolua_cRankManager_IsRestrictionInGroup(lua_State * L)
{
// Function signature:
// cRankManager:IsRestrictionInGroup(Restriction, GroupName) -> bool
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -873,14 +873,14 @@ static int tolua_cRankManager_IsRestrictionInGroup(lua_State * L)
{
return 0;
}
-
+
// Get the params:
AString GroupName, Restriction;
S.GetStackValues(2, Restriction, GroupName);
-
+
// Get the response:
bool res = cRoot::Get()->GetRankManager()->IsRestrictionInGroup(Restriction, GroupName);
-
+
// Push the result:
S.Push(res);
return 1;
@@ -895,7 +895,7 @@ static int tolua_cRankManager_IsPlayerRankSet(lua_State * L)
{
// Function signature:
// cRankManager:IsPlayerRankSet(PlayerUUID) -> bool
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -905,14 +905,14 @@ static int tolua_cRankManager_IsPlayerRankSet(lua_State * L)
{
return 0;
}
-
+
// Get the params:
AString PlayerUUID;
S.GetStackValue(2, PlayerUUID);
-
+
// Get the response:
bool res = cRoot::Get()->GetRankManager()->IsPlayerRankSet(PlayerUUID);
-
+
// Push the result:
S.Push(res);
return 1;
@@ -927,7 +927,7 @@ static int tolua_cRankManager_RankExists(lua_State * L)
{
// Function signature:
// cRankManager:RankExists(RankName) -> bool
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -937,14 +937,14 @@ static int tolua_cRankManager_RankExists(lua_State * L)
{
return 0;
}
-
+
// Get the params:
AString RankName;
S.GetStackValue(2, RankName);
-
+
// Get the response:
bool res = cRoot::Get()->GetRankManager()->RankExists(RankName);
-
+
// Push the result:
S.Push(res);
return 1;
@@ -959,7 +959,7 @@ static int tolua_cRankManager_RemoveGroup(lua_State * L)
{
// Function signature:
// cRankManager:RemoveGroup(GroupName)
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -969,11 +969,11 @@ static int tolua_cRankManager_RemoveGroup(lua_State * L)
{
return 0;
}
-
+
// Get the params:
AString GroupName;
S.GetStackValue(2, GroupName);
-
+
// Remove the group:
cRoot::Get()->GetRankManager()->RemoveGroup(GroupName);
return 0;
@@ -988,7 +988,7 @@ static int tolua_cRankManager_RemoveGroupFromRank(lua_State * L)
{
// Function signature:
// cRankManager:RemoveGroupFromRank(GroupName, RankName)
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -998,11 +998,11 @@ static int tolua_cRankManager_RemoveGroupFromRank(lua_State * L)
{
return 0;
}
-
+
// Get the params:
AString GroupName, RankName;
S.GetStackValues(2, GroupName, RankName);
-
+
// Remove the group:
cRoot::Get()->GetRankManager()->RemoveGroupFromRank(GroupName, RankName);
return 0;
@@ -1017,7 +1017,7 @@ static int tolua_cRankManager_RemovePermissionFromGroup(lua_State * L)
{
// Function signature:
// cRankManager:RemovePermissionFromGroup(Permission, GroupName)
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -1027,11 +1027,11 @@ static int tolua_cRankManager_RemovePermissionFromGroup(lua_State * L)
{
return 0;
}
-
+
// Get the params:
AString GroupName, Permission;
S.GetStackValues(2, Permission, GroupName);
-
+
// Remove the permission:
cRoot::Get()->GetRankManager()->RemovePermissionFromGroup(Permission, GroupName);
return 0;
@@ -1046,7 +1046,7 @@ static int tolua_cRankManager_RemoveRestrictionFromGroup(lua_State * L)
{
// Function signature:
// cRankManager:RemoveRestrictionFromGroup(Restriction, GroupName)
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -1056,11 +1056,11 @@ static int tolua_cRankManager_RemoveRestrictionFromGroup(lua_State * L)
{
return 0;
}
-
+
// Get the params:
AString GroupName, Restriction;
S.GetStackValues(2, Restriction, GroupName);
-
+
// Remove the restriction:
cRoot::Get()->GetRankManager()->RemoveRestrictionFromGroup(Restriction, GroupName);
return 0;
@@ -1075,7 +1075,7 @@ static int tolua_cRankManager_RemovePlayerRank(lua_State * L)
{
// Function signature:
// cRankManager:RemovePlayerRank(PlayerUUID)
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -1085,11 +1085,11 @@ static int tolua_cRankManager_RemovePlayerRank(lua_State * L)
{
return 0;
}
-
+
// Get the params:
AString PlayerUUID;
S.GetStackValue(2, PlayerUUID);
-
+
// Remove the player's rank:
cRoot::Get()->GetRankManager()->RemovePlayerRank(PlayerUUID);
return 0;
@@ -1104,7 +1104,7 @@ static int tolua_cRankManager_RemoveRank(lua_State * L)
{
// Function signature:
// cRankManager:RemoveRank(RankName, [ReplacementRankName])
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -1115,11 +1115,11 @@ static int tolua_cRankManager_RemoveRank(lua_State * L)
{
return 0;
}
-
+
// Get the params:
AString RankName, ReplacementRankName;
S.GetStackValues(2, RankName, ReplacementRankName);
-
+
// Remove the rank:
cRoot::Get()->GetRankManager()->RemoveRank(RankName, ReplacementRankName);
return 0;
@@ -1134,7 +1134,7 @@ static int tolua_cRankManager_RenameGroup(lua_State * L)
{
// Function signature:
// cRankManager:RenameGroup(OldName, NewName)
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -1144,14 +1144,14 @@ static int tolua_cRankManager_RenameGroup(lua_State * L)
{
return 0;
}
-
+
// Get the params:
AString OldName, NewName;
S.GetStackValues(2, OldName, NewName);
-
+
// Remove the group:
bool res = cRoot::Get()->GetRankManager()->RenameGroup(OldName, NewName);
-
+
// Push the result:
S.Push(res);
return 1;
@@ -1166,7 +1166,7 @@ static int tolua_cRankManager_RenameRank(lua_State * L)
{
// Function signature:
// cRankManager:RenameRank(OldName, NewName)
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -1176,14 +1176,14 @@ static int tolua_cRankManager_RenameRank(lua_State * L)
{
return 0;
}
-
+
// Get the params:
AString OldName, NewName;
S.GetStackValues(2, OldName, NewName);
-
+
// Remove the rank:
bool res = cRoot::Get()->GetRankManager()->RenameRank(OldName, NewName);
-
+
// Push the result:
S.Push(res);
return 1;
@@ -1198,7 +1198,7 @@ static int tolua_cRankManager_SetDefaultRank(lua_State * L)
{
// Function signature:
// cRankManager:SetDefaultRank(RankName) -> bool
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -1208,11 +1208,11 @@ static int tolua_cRankManager_SetDefaultRank(lua_State * L)
{
return 0;
}
-
+
// Get the params:
AString RankName;
S.GetStackValue(2, RankName);
-
+
// Set the rank, return the result:
S.Push(cRoot::Get()->GetRankManager()->SetDefaultRank(RankName));
return 1;
@@ -1227,7 +1227,7 @@ static int tolua_cRankManager_SetPlayerRank(lua_State * L)
{
// Function signature:
// cRankManager:SetPlayerRank(PlayerUUID, PlayerName, RankName)
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -1237,11 +1237,11 @@ static int tolua_cRankManager_SetPlayerRank(lua_State * L)
{
return 0;
}
-
+
// Get the params:
AString PlayerUUID, PlayerName, RankName;
S.GetStackValues(2, PlayerUUID, PlayerName, RankName);
-
+
// Set the rank:
cRoot::Get()->GetRankManager()->SetPlayerRank(PlayerUUID, PlayerName, RankName);
return 0;
@@ -1256,7 +1256,7 @@ static int tolua_cRankManager_SetRankVisuals(lua_State * L)
{
// Function signature:
// cRankManager:SetRankVisuals(RankName, MsgPrefix, MsgSuffix, MsgNameColorCode)
-
+
cLuaState S(L);
if (
!S.CheckParamUserTable(1, "cRankManager") ||
@@ -1266,11 +1266,11 @@ static int tolua_cRankManager_SetRankVisuals(lua_State * L)
{
return 0;
}
-
+
// Get the params:
AString RankName, MsgPrefix, MsgSuffix, MsgNameColorCode;
S.GetStackValues(2, RankName, MsgPrefix, MsgSuffix, MsgNameColorCode);
-
+
// Set the visuals:
cRoot::Get()->GetRankManager()->SetRankVisuals(RankName, MsgPrefix, MsgSuffix, MsgNameColorCode);
return 0;
@@ -1285,7 +1285,7 @@ void cManualBindings::BindRankManager(lua_State * tolua_S)
// Create the cRankManager class in the API:
tolua_usertype(tolua_S, "cRankManager");
tolua_cclass(tolua_S, "cRankManager", "cRankManager", "", nullptr);
-
+
// Fill in the functions (alpha-sorted):
tolua_beginmodule(tolua_S, "cRankManager");
tolua_function(tolua_S, "AddGroup", tolua_cRankManager_AddGroup);
diff --git a/src/Bindings/ManualBindings_World.cpp b/src/Bindings/ManualBindings_World.cpp
index f40af9778..00d2169d8 100644
--- a/src/Bindings/ManualBindings_World.cpp
+++ b/src/Bindings/ManualBindings_World.cpp
@@ -30,7 +30,7 @@ static int tolua_cWorld_BroadcastParticleEffect(lua_State * tolua_S)
{
return 0;
}
-
+
// Read the params:
cWorld * World = nullptr;
AString Name;
@@ -68,7 +68,7 @@ static int tolua_cWorld_ChunkStay(lua_State * tolua_S)
World:ChunkStay(ChunkCoordTable, OnChunkAvailable, OnAllChunksAvailable)
ChunkCoordTable == { {Chunk1x, Chunk1z}, {Chunk2x, Chunk2z}, ... }
*/
-
+
cLuaState L(tolua_S);
if (
!L.CheckParamUserType (1, "cWorld") ||
@@ -78,13 +78,13 @@ static int tolua_cWorld_ChunkStay(lua_State * tolua_S)
{
return 0;
}
-
+
cPluginLua * Plugin = cManualBindings::GetLuaPlugin(tolua_S);
if (Plugin == nullptr)
{
return 0;
}
-
+
// Read the params:
cWorld * World = reinterpret_cast<cWorld *>(tolua_tousertype(tolua_S, 1, nullptr));
if (World == nullptr)
@@ -116,7 +116,7 @@ static int tolua_cWorld_DoExplosionAt(lua_State * tolua_S)
/* Function signature:
World:DoExplosionAt(ExplosionSize, BlockX, BlockY, BlockZ, CanCauseFire, SourceType, [SourceData])
*/
-
+
cLuaState L(tolua_S);
if (
!L.CheckParamUserType (1, "cWorld") ||
@@ -128,7 +128,7 @@ static int tolua_cWorld_DoExplosionAt(lua_State * tolua_S)
{
return 0;
}
-
+
// Read the params:
cWorld * World;
double ExplosionSize;
@@ -405,7 +405,7 @@ static int tolua_cWorld_PrepareChunk(lua_State * tolua_S)
/* Function signature:
World:PrepareChunk(ChunkX, ChunkZ, Callback)
*/
-
+
// Check the param types:
cLuaState L(tolua_S);
if (
@@ -416,7 +416,7 @@ static int tolua_cWorld_PrepareChunk(lua_State * tolua_S)
{
return 0;
}
-
+
// Read the params:
cWorld * world = nullptr;
int chunkX = 0;
@@ -497,7 +497,7 @@ static int tolua_cWorld_QueueTask(lua_State * tolua_S)
{
// Binding for cWorld::QueueTask
// Params: function
-
+
// Retrieve the cPlugin from the LuaState:
cPluginLua * Plugin = cManualBindings::GetLuaPlugin(tolua_S);
if (Plugin == nullptr)
@@ -578,7 +578,7 @@ static int tolua_cWorld_ScheduleTask(lua_State * tolua_S)
{
// Binding for cWorld::ScheduleTask
// Params: function, Ticks
-
+
// Retrieve the cPlugin from the LuaState:
cPluginLua * Plugin = cManualBindings::GetLuaPlugin(tolua_S);
if (Plugin == nullptr)
@@ -609,7 +609,7 @@ static int tolua_cWorld_ScheduleTask(lua_State * tolua_S)
{
return cManualBindings::lua_do_error(tolua_S, "Error in function call '#funcname#': Could not get function reference of parameter #1");
}
-
+
auto ResettableTask = std::make_shared<cLuaWorldTask>(*Plugin, FnRef);
Plugin->AddResettable(ResettableTask);
World->ScheduleTask(static_cast<int>(tolua_tonumber(tolua_S, 2, 0)), std::bind(&cLuaWorldTask::Run, ResettableTask, std::placeholders::_1));
diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h
index b8fc97a06..3ee417361 100644
--- a/src/Bindings/Plugin.h
+++ b/src/Bindings/Plugin.h
@@ -20,14 +20,14 @@ class cPlugin
{
public:
// tolua_end
-
+
/** Creates a new instance.
a_FolderName is the name of the folder (in the Plugins folder) from which the plugin is loaded.
The plugin's name defaults to the folder name. */
cPlugin(const AString & a_FolderName);
virtual ~cPlugin();
-
+
/** Called as the last call into the plugin before it is unloaded. */
virtual void OnDisable(void) {}
@@ -109,22 +109,22 @@ public:
virtual bool OnWeatherChanging (cWorld & a_World, eWeather & a_NewWeather) = 0;
virtual bool OnWorldStarted (cWorld & a_World) = 0;
virtual bool OnWorldTick (cWorld & a_World, std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec) = 0;
-
+
/** Handles the command split into a_Split, issued by player a_Player.
Command permissions have already been checked.
Returns true if command handled successfully. */
virtual bool HandleCommand(const AStringVector & a_Split, cPlayer & a_Player, const AString & a_FullCommand) = 0;
-
+
/** Handles the console command split into a_Split.
Returns true if command handled successfully. Output is to be sent to the a_Output callback. */
virtual bool HandleConsoleCommand(const AStringVector & a_Split, cCommandOutputCallback & a_Output, const AString & a_FullCommand) = 0;
-
+
/** All bound commands are to be removed, do any language-dependent cleanup here */
virtual void ClearCommands(void) {}
-
+
/** All bound console commands are to be removed, do any language-dependent cleanup here */
virtual void ClearConsoleCommands(void) {}
-
+
// tolua_begin
const AString & GetName(void) const { return m_Name; }
void SetName(const AString & a_Name) { m_Name = a_Name; }
@@ -145,7 +145,7 @@ public:
bool IsLoaded(void) const { return (m_Status == cPluginManager::psLoaded); }
// tolua_end
-
+
// Needed for ManualBindings' tolua_ForEach<>
static const char * GetClassStatic(void) { return "cPlugin"; }
diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp
index 1b7a18ff1..a266e6223 100644
--- a/src/Bindings/PluginLua.cpp
+++ b/src/Bindings/PluginLua.cpp
@@ -105,13 +105,13 @@ bool cPluginLua::Load(void)
{
m_LuaState.Create();
m_LuaState.RegisterAPILibs();
-
+
// Inject the identification global variables into the state:
lua_pushlightuserdata(m_LuaState, this);
lua_setglobal(m_LuaState, LUA_PLUGIN_INSTANCE_VAR_NAME);
lua_pushstring(m_LuaState, GetName().c_str());
lua_setglobal(m_LuaState, LUA_PLUGIN_NAME_VAR_NAME);
-
+
// Add the plugin's folder to the package.path and package.cpath variables (#693):
m_LuaState.AddPackagePath("path", FILE_IO_PREFIX + GetLocalFolder() + "/?.lua");
#ifdef _WIN32
@@ -119,7 +119,7 @@ bool cPluginLua::Load(void)
#else
m_LuaState.AddPackagePath("cpath", FILE_IO_PREFIX + GetLocalFolder() + "/?.so");
#endif
-
+
tolua_pushusertype(m_LuaState, this, "cPluginLua");
lua_setglobal(m_LuaState, "g_Plugin");
}
@@ -145,7 +145,7 @@ bool cPluginLua::Load(void)
}
}
std::sort(LuaFiles.begin(), LuaFiles.end());
-
+
// Warn if there are no Lua files in the plugin folder:
if (LuaFiles.empty())
{
@@ -1879,7 +1879,7 @@ bool cPluginLua::HandleCommand(const AStringVector & a_Split, cPlayer & a_Player
LOGWARNING("Command handler is registered in cPluginManager but not in cPlugin, wtf? Command \"%s\".", a_Split[0].c_str());
return false;
}
-
+
cCSLock Lock(m_CriticalSection);
bool res = false;
m_LuaState.Call(cmd->second, a_Split, &a_Player, a_FullCommand, cLuaState::Return, res);
@@ -1901,7 +1901,7 @@ bool cPluginLua::HandleConsoleCommand(const AStringVector & a_Split, cCommandOut
);
return false;
}
-
+
cCSLock Lock(m_CriticalSection);
bool res = false;
AString str;
@@ -1967,13 +1967,13 @@ bool cPluginLua::CanAddOldStyleHook(int a_HookType)
m_LuaState.LogStackTrace();
return false;
}
-
+
// Check if the function is available
if (m_LuaState.HasFunction(FnName))
{
return true;
}
-
+
LOGWARNING("Plugin %s wants to add a hook (%d), but it doesn't provide the callback function \"%s\" for it. The plugin need not work properly.",
GetName().c_str(), a_HookType, FnName
);
@@ -2042,7 +2042,7 @@ const char * cPluginLua::GetHookFnName(int a_HookType)
case cPluginManager::HOOK_WEATHER_CHANGED: return "OnWeatherChanged";
case cPluginManager::HOOK_WEATHER_CHANGING: return "OnWeatherChanging";
case cPluginManager::HOOK_WORLD_TICK: return "OnWorldTick";
-
+
case cPluginManager::HOOK_NUM_HOOKS:
{
// Satisfy a warning that all enum values should be used in a switch
@@ -2062,7 +2062,7 @@ const char * cPluginLua::GetHookFnName(int a_HookType)
bool cPluginLua::AddHookRef(int a_HookType, int a_FnRefIdx)
{
ASSERT(m_CriticalSection.IsLockedByCurrentThread()); // It probably has to be, how else would we have a LuaState?
-
+
// Check if the function reference is valid:
cLuaState::cRef * Ref = new cLuaState::cRef(m_LuaState, a_FnRefIdx);
if ((Ref == nullptr) || !Ref->IsValid())
@@ -2073,7 +2073,7 @@ bool cPluginLua::AddHookRef(int a_HookType, int a_FnRefIdx)
Ref = nullptr;
return false;
}
-
+
m_HookMap[a_HookType].push_back(Ref);
return true;
}
@@ -2090,7 +2090,7 @@ int cPluginLua::CallFunctionFromForeignState(
)
{
cCSLock Lock(m_CriticalSection);
-
+
// Call the function:
int NumReturns = m_LuaState.CallFunctionWithForeignParams(a_FunctionName, a_ForeignState, a_ParamStart, a_ParamEnd);
if (NumReturns < 0)
@@ -2098,17 +2098,17 @@ int cPluginLua::CallFunctionFromForeignState(
// The call has failed, an error has already been output to the log, so just silently bail out with the same error
return NumReturns;
}
-
+
// Copy all the return values:
int Top = lua_gettop(m_LuaState);
int res = a_ForeignState.CopyStackFrom(m_LuaState, Top - NumReturns + 1, Top);
-
+
// Remove the return values off this stack:
if (NumReturns > 0)
{
lua_pop(m_LuaState, NumReturns);
}
-
+
return res;
}
@@ -2204,7 +2204,7 @@ void cPluginLua::Unreference(int a_LuaRef)
bool cPluginLua::CallbackWindowClosing(int a_FnRef, cWindow & a_Window, cPlayer & a_Player, bool a_CanRefuse)
{
ASSERT(a_FnRef != LUA_REFNIL);
-
+
cCSLock Lock(m_CriticalSection);
bool res = false;
m_LuaState.Call(a_FnRef, &a_Window, &a_Player, a_CanRefuse, cLuaState::Return, res);
@@ -2218,7 +2218,7 @@ bool cPluginLua::CallbackWindowClosing(int a_FnRef, cWindow & a_Window, cPlayer
void cPluginLua::CallbackWindowSlotChanged(int a_FnRef, cWindow & a_Window, int a_SlotNum)
{
ASSERT(a_FnRef != LUA_REFNIL);
-
+
cCSLock Lock(m_CriticalSection);
m_LuaState.Call(a_FnRef, &a_Window, a_SlotNum);
}
diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h
index 59e56c0e7..db6612671 100644
--- a/src/Bindings/PluginLua.h
+++ b/src/Bindings/PluginLua.h
@@ -36,7 +36,7 @@ class cPluginLua :
public:
// tolua_end
-
+
/** A RAII-style mutex lock for accessing the internal LuaState.
This will be the only way to retrieve the plugin's LuaState;
therefore it directly supports accessing the LuaState of the locked plugin.
@@ -54,10 +54,10 @@ public:
}
cLuaState & operator ()(void) { return m_Plugin.m_LuaState; }
-
+
protected:
cPluginLua & m_Plugin;
-
+
/** RAII lock for m_Plugin.m_CriticalSection */
cCSLock m_Lock;
} ;
@@ -92,8 +92,8 @@ public:
typedef SharedPtr<cResettable> cResettablePtr;
typedef std::vector<cResettablePtr> cResettablePtrs;
-
-
+
+
cPluginLua(const AString & a_PluginDirectory);
~cPluginLua();
@@ -169,18 +169,18 @@ public:
virtual bool OnWeatherChanging (cWorld & a_World, eWeather & a_NewWeather) override;
virtual bool OnWorldStarted (cWorld & a_World) override;
virtual bool OnWorldTick (cWorld & a_World, std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec) override;
-
+
virtual bool HandleCommand(const AStringVector & a_Split, cPlayer & a_Player, const AString & a_FullCommand) override;
-
+
virtual bool HandleConsoleCommand(const AStringVector & a_Split, cCommandOutputCallback & a_Output, const AString & a_FullCommand) override;
virtual void ClearCommands(void) override;
-
+
virtual void ClearConsoleCommands(void) override;
/** Returns true if the plugin contains the function for the specified hook type, using the old-style registration (#121) */
bool CanAddOldStyleHook(int a_HookType);
-
+
// cWebPlugin overrides
virtual const AString GetWebTitle(void) const override {return GetName(); }
virtual AString HandleWebRequest(const HTTPRequest & a_Request) override;
@@ -188,7 +188,7 @@ public:
/** Adds a new web tab to webadmin.
Displaying the tab calls the referenced function. */
bool AddWebTab(const AString & a_Title, lua_State * a_LuaState, int a_FunctionReference); // Exported in ManualBindings.cpp
-
+
/** Binds the command to call the function specified by a Lua function reference. Simply adds to CommandMap. */
void BindCommand(const AString & a_Command, int a_FnRef);
@@ -198,25 +198,25 @@ public:
cLuaState & GetLuaState(void) { return m_LuaState; }
cCriticalSection & GetCriticalSection(void) { return m_CriticalSection; }
-
+
/** Removes a previously referenced object (luaL_unref()) */
void Unreference(int a_LuaRef);
-
+
/** Calls the plugin-specified "cLuaWindow closing" callback. Returns true only if the callback returned true */
bool CallbackWindowClosing(int a_FnRef, cWindow & a_Window, cPlayer & a_Player, bool a_CanRefuse);
-
+
/** Calls the plugin-specified "cLuaWindow slot changed" callback. */
void CallbackWindowSlotChanged(int a_FnRef, cWindow & a_Window, int a_SlotNum);
-
+
/** Returns the name of Lua function that should handle the specified hook type in the older (#121) API */
static const char * GetHookFnName(int a_HookType);
-
+
/** Adds a Lua function to be called for the specified hook.
The function has to be on the Lua stack at the specified index a_FnRefIdx
Returns true if the hook was added successfully.
*/
bool AddHookRef(int a_HookType, int a_FnRefIdx);
-
+
/** Calls a function in this plugin's LuaState with parameters copied over from a_ForeignState.
The values that the function returns are placed onto a_ForeignState.
Returns the number of values returned, if successful, or negative number on failure. */
@@ -226,7 +226,7 @@ public:
int a_ParamStart,
int a_ParamEnd
);
-
+
/** Call a Lua function residing in the plugin. */
template <typename FnT, typename... Args>
bool Call(FnT a_Fn, Args && ... a_Args)
@@ -241,20 +241,20 @@ public:
protected:
/** Maps command name into Lua function reference */
typedef std::map<AString, int> CommandMap;
-
+
/** Provides an array of Lua function references */
typedef std::vector<cLuaState::cRef *> cLuaRefs;
-
+
/** Maps hook types into arrays of Lua function references to call for each hook type */
typedef std::map<int, cLuaRefs> cHookMap;
-
+
/** The mutex protecting m_LuaState and each of the m_Resettables[] against multithreaded use. */
cCriticalSection m_CriticalSection;
/** The plugin's Lua state. */
cLuaState m_LuaState;
-
+
/** Objects that need notification when the plugin is about to be unloaded. */
cResettablePtrs m_Resettables;
@@ -263,10 +263,10 @@ protected:
/** Console commands that the plugin has registered. */
CommandMap m_ConsoleCommands;
-
+
/** Hooks that the plugin has registered. */
cHookMap m_HookMap;
-
+
/** Releases all Lua references, notifies and removes all m_Resettables[] and closes the m_LuaState. */
void Close(void);
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index bf907b31d..5b3ef7803 100644
--- a/src/Bindings/PluginManager.cpp
+++ b/src/Bindings/PluginManager.cpp
@@ -317,21 +317,21 @@ bool cPluginManager::CallHookChat(cPlayer & a_Player, AString & a_Message)
// The command has executed successfully
return true;
}
-
+
case crBlocked:
{
// The command was blocked by a plugin using HOOK_EXECUTE_COMMAND
// The plugin has most likely sent a message to the player already
return true;
}
-
+
case crError:
{
// An error in the plugin has prevented the command from executing. Report the error to the player:
a_Player.SendMessageFailure(Printf("Something went wrong while executing command \"%s\"", a_Message.c_str()));
return true;
}
-
+
case crNoPermission:
{
// The player is not allowed to execute this command
diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h
index 58ec74f53..f3f0b6d0b 100644
--- a/src/Bindings/PluginManager.h
+++ b/src/Bindings/PluginManager.h
@@ -143,10 +143,10 @@ public:
HOOK_WORLD_TICK,
// tolua_end
-
+
// Note that if a hook type is added, it may need processing in cPlugin::CanAddHook() descendants,
// and it definitely needs adding in cPluginLua::GetHookFnName() !
-
+
// Keep these two as the last items, they are used for validity checking and get their values automagically
HOOK_NUM_HOOKS,
HOOK_MAX = HOOK_NUM_HOOKS - 1,
@@ -157,22 +157,22 @@ public:
{
public:
virtual ~cCommandEnumCallback() {}
-
+
/** Called for each command; return true to abort enumeration
For console commands, a_Permission is not used (set to empty string)
*/
virtual bool Command(const AString & a_Command, const cPlugin * a_Plugin, const AString & a_Permission, const AString & a_HelpString) = 0;
} ;
-
+
/** The interface used for enumerating and extern-calling plugins */
typedef cItemCallback<cPlugin> cPluginCallback;
-
+
typedef std::list<cPlugin *> PluginList;
/** Called each tick, calls the plugins' OnTick hook, as well as processes plugin events (addition, removal) */
void Tick(float a_Dt);
-
+
/** Returns the instance of the Plugin Manager (there is only ever one) */
static cPluginManager * Get(void); // tolua_export
@@ -182,7 +182,7 @@ public:
/** Schedules a reload of the plugins to happen within the next call to Tick(). */
void ReloadPlugins(); // tolua_export
-
+
/** Adds the plugin to the list of plugins called for the specified hook type.
If a plugin adds multiple handlers for a single hook, it is added only once (ignore-duplicates). */
void AddHook(cPlugin * a_Plugin, int a_HookType);
@@ -192,7 +192,7 @@ public:
/** Returns the number of plugins that are psLoaded. */
size_t GetNumLoadedPlugins(void) const; // tolua_export
-
+
// Calls for individual hooks. Each returns false if the action is to continue or true if the plugin wants to abort
bool CallHookBlockSpread (cWorld & a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source);
bool CallHookBlockToPickups (cWorld & a_World, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cItems & a_Pickups);
@@ -260,7 +260,7 @@ public:
bool CallHookWeatherChanging (cWorld & a_World, eWeather & a_NewWeather);
bool CallHookWorldStarted (cWorld & a_World);
bool CallHookWorldTick (cWorld & a_World, std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec);
-
+
/** Queues the specified plugin to be unloaded in the next call to Tick().
Note that this function returns before the plugin is unloaded, to avoid deadlocks. */
void UnloadPlugin(const AString & a_PluginFolder); // tolua_export
@@ -271,10 +271,10 @@ public:
/** Removes all hooks the specified plugin has registered */
void RemoveHooks(cPlugin * a_Plugin);
-
+
/** Removes the plugin of the specified name from the internal structures and deletes its object. */
void RemovePlugin(const AString & a_PluginName);
-
+
/** Removes all command bindings that the specified plugin has made */
void RemovePluginCommands(cPlugin * a_Plugin);
@@ -283,47 +283,47 @@ public:
/** Binds a command to the specified plugin. Returns true if successful, false if command already bound. */
bool BindCommand(const AString & a_Command, cPlugin * a_Plugin, const AString & a_Permission, const AString & a_HelpString); // Exported in ManualBindings.cpp, without the a_Plugin param
-
+
/** Calls a_Callback for each bound command, returns true if all commands were enumerated */
bool ForEachCommand(cCommandEnumCallback & a_Callback); // Exported in ManualBindings.cpp
-
+
/** Returns true if the command is in the command map */
bool IsCommandBound(const AString & a_Command); // tolua_export
-
+
/** Returns the permission needed for the specified command; empty string if command not found */
AString GetCommandPermission(const AString & a_Command); // tolua_export
-
+
/** Executes the command, as if it was requested by a_Player. Checks permissions first. Returns crExecuted if executed. */
CommandResult ExecuteCommand(cPlayer & a_Player, const AString & a_Command); // tolua_export
-
+
/** Executes the command, as if it was requested by a_Player. Permisssions are not checked. Returns crExecuted if executed. */
CommandResult ForceExecuteCommand(cPlayer & a_Player, const AString & a_Command); // tolua_export
-
+
/** Removes all console command bindings that the specified plugin has made */
void RemovePluginConsoleCommands(cPlugin * a_Plugin);
-
+
/** Binds a console command to the specified plugin. Returns true if successful, false if command already bound. */
bool BindConsoleCommand(const AString & a_Command, cPlugin * a_Plugin, const AString & a_HelpString); // Exported in ManualBindings.cpp, without the a_Plugin param
-
+
/** Calls a_Callback for each bound console command, returns true if all commands were enumerated */
bool ForEachConsoleCommand(cCommandEnumCallback & a_Callback); // Exported in ManualBindings.cpp
-
+
/** Returns true if the console command is in the command map */
bool IsConsoleCommandBound(const AString & a_Command); // tolua_export
-
+
/** Executes the command split into a_Split, as if it was given on the console.
Returns true if executed. Output is sent to the a_Output callback
Exported in ManualBindings.cpp with a different signature. */
bool ExecuteConsoleCommand(const AStringVector & a_Split, cCommandOutputCallback & a_Output, const AString & a_Command);
-
+
/** Appends all commands beginning with a_Text (case-insensitive) into a_Results.
If a_Player is not nullptr, only commands for which the player has permissions are added.
*/
void TabCompleteCommand(const AString & a_Text, AStringVector & a_Results, cPlayer * a_Player);
-
+
/** Returns true if the specified hook type is within the allowed range */
static bool IsValidHookType(int a_HookType);
-
+
/** Calls the specified callback with the plugin object of the specified plugin.
Returns false if plugin not found, otherwise returns the value that the callback has returned. */
bool DoWithPlugin(const AString & a_PluginName, cPluginCallback & a_Callback);
@@ -331,14 +331,14 @@ public:
/** Calls the specified callback for each plugin in m_Plugins.
Returns true if all plugins have been reported, false if the callback has aborted the enumeration by returning true. */
bool ForEachPlugin(cPluginCallback & a_Callback);
-
+
/** Returns the path where individual plugins' folders are expected.
The path doesn't end in a slash. */
static AString GetPluginsPath(void) { return FILE_IO_PREFIX + AString("Plugins"); } // tolua_export
-
+
private:
friend class cRoot;
-
+
class cCommandReg
{
public:
@@ -346,7 +346,7 @@ private:
AString m_Permission; // Not used for console commands
AString m_HelpString;
} ;
-
+
typedef std::map<int, cPluginManager::PluginList> HookMap;
typedef std::map<AString, cCommandReg> CommandMap;
diff --git a/src/Bindings/WebPlugin.h b/src/Bindings/WebPlugin.h
index ade4f4359..6dc8db801 100644
--- a/src/Bindings/WebPlugin.h
+++ b/src/Bindings/WebPlugin.h
@@ -40,7 +40,7 @@ public:
/** Returns the title of the plugin, as it should be presented in the webadmin's pages tree. */
virtual const AString GetWebTitle(void) const = 0;
-
+
/** Sanitizes the input string, replacing spaces with underscores. */
static AString SafeString(const AString & a_String);