1
0
Fork 0

Bulk clearing of whitespace

This commit is contained in:
LogicParrot 2016-02-05 23:45:45 +02:00
parent 87a31e3a2d
commit ca6ef58b1e
406 changed files with 4497 additions and 4497 deletions

View File

@ -15,23 +15,23 @@ public:
{ {
public: public:
virtual ~cStarvationCallbacks() {} virtual ~cStarvationCallbacks() {}
/** Is called when the reserve buffer starts to be used */ /** Is called when the reserve buffer starts to be used */
virtual void OnStartUsingReserve() = 0; virtual void OnStartUsingReserve() = 0;
/** Is called once the reserve buffer has returned to normal size */ /** Is called once the reserve buffer has returned to normal size */
virtual void OnEndUsingReserve() = 0; virtual void OnEndUsingReserve() = 0;
/** Is called when the allocation pool is unable to allocate memory. Will be repeatedly /** Is called when the allocation pool is unable to allocate memory. Will be repeatedly
called if it does not free sufficient memory */ called if it does not free sufficient memory */
virtual void OnOutOfReserve() = 0; virtual void OnOutOfReserve() = 0;
}; };
virtual ~cAllocationPool() {} virtual ~cAllocationPool() {}
/** Allocates a pointer to T */ /** Allocates a pointer to T */
virtual T * Allocate() = 0; virtual T * Allocate() = 0;
/** Frees the pointer passed in a_ptr, invalidating it */ /** Frees the pointer passed in a_ptr, invalidating it */
virtual void Free(T * a_ptr) = 0; virtual void Free(T * a_ptr) = 0;
}; };
@ -47,7 +47,7 @@ class cListAllocationPool:
public cAllocationPool<T> public cAllocationPool<T>
{ {
public: public:
cListAllocationPool(std::unique_ptr<typename cAllocationPool<T>::cStarvationCallbacks> a_Callbacks): cListAllocationPool(std::unique_ptr<typename cAllocationPool<T>::cStarvationCallbacks> a_Callbacks):
m_Callbacks(std::move(a_Callbacks)) m_Callbacks(std::move(a_Callbacks))
{ {
@ -62,7 +62,7 @@ public:
m_FreeList.push_front(space); m_FreeList.push_front(space);
} }
} }
virtual ~cListAllocationPool() virtual ~cListAllocationPool()
{ {
@ -72,7 +72,7 @@ public:
m_FreeList.pop_front(); m_FreeList.pop_front();
} }
} }
virtual T * Allocate() override virtual T * Allocate() override
{ {
@ -115,7 +115,7 @@ public:
m_Callbacks->OnEndUsingReserve(); m_Callbacks->OnEndUsingReserve();
} }
} }
private: private:
std::list<void *> m_FreeList; std::list<void *> m_FreeList;
std::unique_ptr<typename cAllocationPool<T>::cStarvationCallbacks> m_Callbacks; std::unique_ptr<typename cAllocationPool<T>::cStarvationCallbacks> m_Callbacks;

View File

@ -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 // This function is expected to be called just once, with all the coords in a table
ASSERT(m_Chunks.empty()); ASSERT(m_Chunks.empty());
cPluginLua::cOperation Op(m_Plugin); cPluginLua::cOperation Op(m_Plugin);
cLuaState & L = Op(); cLuaState & L = Op();
// Check that we got a table: // Check that we got a table:
if (!lua_istable(L, a_ChunkCoordTableStackPos)) if (!lua_istable(L, a_ChunkCoordTableStackPos))
{ {
@ -38,7 +38,7 @@ bool cLuaChunkStay::AddChunks(int a_ChunkCoordTableStackPos)
L.LogStackTrace(); L.LogStackTrace();
return false; return false;
} }
// Add each set of coords: // Add each set of coords:
int NumChunks = luaL_getn(L, a_ChunkCoordTableStackPos); int NumChunks = luaL_getn(L, a_ChunkCoordTableStackPos);
m_Chunks.reserve(static_cast<size_t>(NumChunks)); m_Chunks.reserve(static_cast<size_t>(NumChunks));
@ -58,7 +58,7 @@ bool cLuaChunkStay::AddChunks(int a_ChunkCoordTableStackPos)
AddChunkCoord(L, idx); AddChunkCoord(L, idx);
lua_pop(L, 1); lua_pop(L, 1);
} }
// If there are no chunks, log a warning and return failure: // If there are no chunks, log a warning and return failure:
if (m_Chunks.empty()) if (m_Chunks.empty())
{ {
@ -66,7 +66,7 @@ bool cLuaChunkStay::AddChunks(int a_ChunkCoordTableStackPos)
L.LogStackTrace(); L.LogStackTrace();
return false; return false;
} }
// All ok // All ok
return true; return true;
} }
@ -86,14 +86,14 @@ void cLuaChunkStay::AddChunkCoord(cLuaState & L, int a_Index)
); );
return; return;
} }
// Read the two coords from the element: // Read the two coords from the element:
lua_rawgeti(L, -1, 1); lua_rawgeti(L, -1, 1);
lua_rawgeti(L, -2, 2); lua_rawgeti(L, -2, 2);
int ChunkX = luaL_checkint(L, -2); int ChunkX = luaL_checkint(L, -2);
int ChunkZ = luaL_checkint(L, -1); int ChunkZ = luaL_checkint(L, -1);
lua_pop(L, 2); lua_pop(L, 2);
// Check that a coord is not yet present: // Check that a coord is not yet present:
for (cChunkCoordsVector::iterator itr = m_Chunks.begin(), end = m_Chunks.end(); itr != end; ++itr) 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; return;
} }
} // for itr - m_Chunks[] } // for itr - m_Chunks[]
m_Chunks.push_back(cChunkCoords(ChunkX, ChunkZ)); 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_LuaState = &m_Plugin.GetLuaState();
m_OnChunkAvailable.RefStack(*m_LuaState, a_OnChunkAvailableStackPos); m_OnChunkAvailable.RefStack(*m_LuaState, a_OnChunkAvailableStackPos);
m_OnAllChunksAvailable.RefStack(*m_LuaState, a_OnAllChunksAvailableStackPos); m_OnAllChunksAvailable.RefStack(*m_LuaState, a_OnAllChunksAvailableStackPos);
// Enable the ChunkStay: // Enable the ChunkStay:
super::Enable(a_ChunkMap); super::Enable(a_ChunkMap);
} }
@ -148,12 +148,12 @@ bool cLuaChunkStay::OnAllChunksAvailable(void)
// Call the callback: // Call the callback:
cPluginLua::cOperation Op(m_Plugin); cPluginLua::cOperation Op(m_Plugin);
Op().Call(static_cast<int>(m_OnAllChunksAvailable)); Op().Call(static_cast<int>(m_OnAllChunksAvailable));
// Remove the callback references - they won't be needed anymore // Remove the callback references - they won't be needed anymore
m_OnChunkAvailable.UnRef(); m_OnChunkAvailable.UnRef();
m_OnAllChunksAvailable.UnRef(); m_OnAllChunksAvailable.UnRef();
} }
// Disable the ChunkStay by returning true // Disable the ChunkStay by returning true
return true; return true;
} }

View File

@ -28,38 +28,38 @@ class cLuaChunkStay
: public cChunkStay : public cChunkStay
{ {
typedef cChunkStay super; typedef cChunkStay super;
public: public:
cLuaChunkStay(cPluginLua & a_Plugin); cLuaChunkStay(cPluginLua & a_Plugin);
~cLuaChunkStay() { } ~cLuaChunkStay() { }
/** Adds chunks in the specified on-stack Lua table. /** Adds chunks in the specified on-stack Lua table.
Returns true if any chunk added, false (plus log warning) if none. */ Returns true if any chunk added, false (plus log warning) if none. */
bool AddChunks(int a_ChunkCoordTableStackPos); bool AddChunks(int a_ChunkCoordTableStackPos);
/** Enables the ChunkStay for the specified chunkmap, with the specified Lua callbacks. */ /** Enables the ChunkStay for the specified chunkmap, with the specified Lua callbacks. */
void Enable(cChunkMap & a_ChunkMap, int a_OnChunkAvailableStackPos, int a_OnAllChunksAvailableStackPos); void Enable(cChunkMap & a_ChunkMap, int a_OnChunkAvailableStackPos, int a_OnAllChunksAvailableStackPos);
protected: protected:
/** The plugin which has created the ChunkStay, via cWorld:ChunkStay() binding method. */ /** The plugin which has created the ChunkStay, via cWorld:ChunkStay() binding method. */
cPluginLua & m_Plugin; cPluginLua & m_Plugin;
/** The Lua state associated with the callbacks. Only valid when enabled. */ /** The Lua state associated with the callbacks. Only valid when enabled. */
cLuaState * m_LuaState; cLuaState * m_LuaState;
/** The Lua function to call in OnChunkAvailable. Only valid when enabled. */ /** The Lua function to call in OnChunkAvailable. Only valid when enabled. */
cLuaState::cRef m_OnChunkAvailable; cLuaState::cRef m_OnChunkAvailable;
/** The Lua function to call in OnAllChunksAvailable. Only valid when enabled. */ /** The Lua function to call in OnAllChunksAvailable. Only valid when enabled. */
cLuaState::cRef m_OnAllChunksAvailable; cLuaState::cRef m_OnAllChunksAvailable;
// cChunkStay overrides: // cChunkStay overrides:
virtual void OnChunkAvailable(int a_ChunkX, int a_ChunkZ) override; virtual void OnChunkAvailable(int a_ChunkX, int a_ChunkZ) override;
virtual bool OnAllChunksAvailable(void) override; virtual bool OnAllChunksAvailable(void) override;
virtual void OnDisabled(void) override; virtual void OnDisabled(void) override;
/** Adds a single chunk coord from the table at the top of the Lua stack. /** 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. 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. Uses those two numbers as chunk coords appended to m_Chunks.

View File

@ -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> lua_getfield(m_LuaState, -1, a_PathVariable.c_str()); // Stk: <package> <package.path>
size_t len = 0; size_t len = 0;
const char * PackagePath = lua_tolstring(m_LuaState, -1, &len); const char * PackagePath = lua_tolstring(m_LuaState, -1, &len);
// Append the new path: // Append the new path:
AString NewPackagePath(PackagePath, len); AString NewPackagePath(PackagePath, len);
NewPackagePath.append(LUA_PATHSEP); NewPackagePath.append(LUA_PATHSEP);
NewPackagePath.append(a_Path); NewPackagePath.append(a_Path);
// Set the new path to the environment: // Set the new path to the environment:
lua_pop(m_LuaState, 1); // Stk: <package> lua_pop(m_LuaState, 1); // Stk: <package>
lua_pushlstring(m_LuaState, NewPackagePath.c_str(), NewPackagePath.length()); // Stk: <package> <NewPackagePath> 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 // This happens if cPlugin::Initialize() fails with an error
return false; return false;
} }
// Push the error handler for lua_pcall() // Push the error handler for lua_pcall()
lua_pushcfunction(m_LuaState, &ReportFnCallErrors); lua_pushcfunction(m_LuaState, &ReportFnCallErrors);
lua_getglobal(m_LuaState, a_FunctionName); lua_getglobal(m_LuaState, a_FunctionName);
if (!lua_isfunction(m_LuaState, -1)) if (!lua_isfunction(m_LuaState, -1))
{ {
@ -406,10 +406,10 @@ bool cLuaState::PushFunction(int a_FnRef)
{ {
ASSERT(IsValid()); ASSERT(IsValid());
ASSERT(m_NumCurrentFunctionArgs == -1); // If not, there's already something pushed onto the stack ASSERT(m_NumCurrentFunctionArgs == -1); // If not, there's already something pushed onto the stack
// Push the error handler for lua_pcall() // Push the error handler for lua_pcall()
lua_pushcfunction(m_LuaState, &ReportFnCallErrors); lua_pushcfunction(m_LuaState, &ReportFnCallErrors);
lua_rawgeti(m_LuaState, LUA_REGISTRYINDEX, a_FnRef); // same as lua_getref() lua_rawgeti(m_LuaState, LUA_REGISTRYINDEX, a_FnRef); // same as lua_getref()
if (!lua_isfunction(m_LuaState, -1)) if (!lua_isfunction(m_LuaState, -1))
{ {
@ -429,10 +429,10 @@ bool cLuaState::PushFunction(const cTableRef & a_TableRef)
{ {
ASSERT(IsValid()); ASSERT(IsValid());
ASSERT(m_NumCurrentFunctionArgs == -1); // If not, there's already something pushed onto the stack ASSERT(m_NumCurrentFunctionArgs == -1); // If not, there's already something pushed onto the stack
// Push the error handler for lua_pcall() // Push the error handler for lua_pcall()
lua_pushcfunction(m_LuaState, &ReportFnCallErrors); lua_pushcfunction(m_LuaState, &ReportFnCallErrors);
lua_rawgeti(m_LuaState, LUA_REGISTRYINDEX, a_TableRef.GetTableRef()); // Get the table ref lua_rawgeti(m_LuaState, LUA_REGISTRYINDEX, a_TableRef.GetTableRef()); // Get the table ref
if (!lua_istable(m_LuaState, -1)) if (!lua_istable(m_LuaState, -1))
{ {
@ -447,10 +447,10 @@ bool cLuaState::PushFunction(const cTableRef & a_TableRef)
lua_pop(m_LuaState, 3); lua_pop(m_LuaState, 3);
return false; return false;
} }
// Pop the table off the stack: // Pop the table off the stack:
lua_remove(m_LuaState, -2); lua_remove(m_LuaState, -2);
Printf(m_CurrentFunctionName, "<table-callback %s>", a_TableRef.GetFnName()); Printf(m_CurrentFunctionName, "<table-callback %s>", a_TableRef.GetFnName());
m_NumCurrentFunctionArgs = 0; m_NumCurrentFunctionArgs = 0;
return true; 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 (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 - 1)); // The function to call
ASSERT(lua_isfunction(m_LuaState, -m_NumCurrentFunctionArgs - 2)); // The error handler 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: // Save the current "stack" state and reset, in case the callback calls another function:
AString CurrentFunctionName; AString CurrentFunctionName;
std::swap(m_CurrentFunctionName, CurrentFunctionName); std::swap(m_CurrentFunctionName, CurrentFunctionName);
int NumArgs = m_NumCurrentFunctionArgs; int NumArgs = m_NumCurrentFunctionArgs;
m_NumCurrentFunctionArgs = -1; m_NumCurrentFunctionArgs = -1;
// Call the function: // Call the function:
int s = lua_pcall(m_LuaState, NumArgs, a_NumResults, -NumArgs - 2); int s = lua_pcall(m_LuaState, NumArgs, a_NumResults, -NumArgs - 2);
if (s != 0) 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()); LOGWARNING("Error in %s calling function %s()", m_SubsystemName.c_str(), CurrentFunctionName.c_str());
return false; return false;
} }
// Remove the error handler from the stack: // Remove the error handler from the stack:
lua_remove(m_LuaState, -a_NumResults - 1); lua_remove(m_LuaState, -a_NumResults - 1);
return true; 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) bool cLuaState::CheckParamUserTable(int a_StartParam, const char * a_UserTable, int a_EndParam)
{ {
ASSERT(IsValid()); ASSERT(IsValid());
if (a_EndParam < 0) if (a_EndParam < 0)
{ {
a_EndParam = a_StartParam; a_EndParam = a_StartParam;
} }
tolua_Error tolua_err; tolua_Error tolua_err;
for (int i = a_StartParam; i <= a_EndParam; i++) 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); tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err);
return false; return false;
} // for i - Param } // for i - Param
// All params checked ok // All params checked ok
return true; 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) bool cLuaState::CheckParamUserType(int a_StartParam, const char * a_UserType, int a_EndParam)
{ {
ASSERT(IsValid()); ASSERT(IsValid());
if (a_EndParam < 0) if (a_EndParam < 0)
{ {
a_EndParam = a_StartParam; a_EndParam = a_StartParam;
} }
tolua_Error tolua_err; tolua_Error tolua_err;
for (int i = a_StartParam; i <= a_EndParam; i++) 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); tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err);
return false; return false;
} // for i - Param } // for i - Param
// All params checked ok // All params checked ok
return true; 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) bool cLuaState::CheckParamTable(int a_StartParam, int a_EndParam)
{ {
ASSERT(IsValid()); ASSERT(IsValid());
if (a_EndParam < 0) if (a_EndParam < 0)
{ {
a_EndParam = a_StartParam; a_EndParam = a_StartParam;
} }
tolua_Error tolua_err; tolua_Error tolua_err;
for (int i = a_StartParam; i <= a_EndParam; i++) 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); tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err);
return false; return false;
} // for i - Param } // for i - Param
// All params checked ok // All params checked ok
return true; return true;
} }
@ -1136,12 +1136,12 @@ bool cLuaState::CheckParamTable(int a_StartParam, int a_EndParam)
bool cLuaState::CheckParamNumber(int a_StartParam, int a_EndParam) bool cLuaState::CheckParamNumber(int a_StartParam, int a_EndParam)
{ {
ASSERT(IsValid()); ASSERT(IsValid());
if (a_EndParam < 0) if (a_EndParam < 0)
{ {
a_EndParam = a_StartParam; a_EndParam = a_StartParam;
} }
tolua_Error tolua_err; tolua_Error tolua_err;
for (int i = a_StartParam; i <= a_EndParam; i++) 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); tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err);
return false; return false;
} // for i - Param } // for i - Param
// All params checked ok // All params checked ok
return true; return true;
} }
@ -1169,12 +1169,12 @@ bool cLuaState::CheckParamNumber(int a_StartParam, int a_EndParam)
bool cLuaState::CheckParamBool(int a_StartParam, int a_EndParam) bool cLuaState::CheckParamBool(int a_StartParam, int a_EndParam)
{ {
ASSERT(IsValid()); ASSERT(IsValid());
if (a_EndParam < 0) if (a_EndParam < 0)
{ {
a_EndParam = a_StartParam; a_EndParam = a_StartParam;
} }
tolua_Error tolua_err; tolua_Error tolua_err;
for (int i = a_StartParam; i <= a_EndParam; i++) 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); tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err);
return false; return false;
} // for i - Param } // for i - Param
// All params checked ok // All params checked ok
return true; return true;
} }
@ -1202,12 +1202,12 @@ bool cLuaState::CheckParamBool(int a_StartParam, int a_EndParam)
bool cLuaState::CheckParamString(int a_StartParam, int a_EndParam) bool cLuaState::CheckParamString(int a_StartParam, int a_EndParam)
{ {
ASSERT(IsValid()); ASSERT(IsValid());
if (a_EndParam < 0) if (a_EndParam < 0)
{ {
a_EndParam = a_StartParam; a_EndParam = a_StartParam;
} }
tolua_Error tolua_err; tolua_Error tolua_err;
for (int i = a_StartParam; i <= a_EndParam; i++) 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); tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err);
return false; return false;
} // for i - Param } // for i - Param
// All params checked ok // All params checked ok
return true; return true;
} }
@ -1238,12 +1238,12 @@ bool cLuaState::CheckParamString(int a_StartParam, int a_EndParam)
bool cLuaState::CheckParamFunction(int a_StartParam, int a_EndParam) bool cLuaState::CheckParamFunction(int a_StartParam, int a_EndParam)
{ {
ASSERT(IsValid()); ASSERT(IsValid());
if (a_EndParam < 0) if (a_EndParam < 0)
{ {
a_EndParam = a_StartParam; a_EndParam = a_StartParam;
} }
for (int i = a_StartParam; i <= a_EndParam; i++) for (int i = a_StartParam; i <= a_EndParam; i++)
{ {
if (lua_isfunction(m_LuaState, i)) if (lua_isfunction(m_LuaState, i))
@ -1259,7 +1259,7 @@ bool cLuaState::CheckParamFunction(int a_StartParam, int a_EndParam)
); );
return false; return false;
} // for i - Param } // for i - Param
// All params checked ok // All params checked ok
return true; return true;
} }
@ -1271,12 +1271,12 @@ bool cLuaState::CheckParamFunction(int a_StartParam, int a_EndParam)
bool cLuaState::CheckParamFunctionOrNil(int a_StartParam, int a_EndParam) bool cLuaState::CheckParamFunctionOrNil(int a_StartParam, int a_EndParam)
{ {
ASSERT(IsValid()); ASSERT(IsValid());
if (a_EndParam < 0) if (a_EndParam < 0)
{ {
a_EndParam = a_StartParam; a_EndParam = a_StartParam;
} }
for (int i = a_StartParam; i <= a_EndParam; i++) for (int i = a_StartParam; i <= a_EndParam; i++)
{ {
if (lua_isfunction(m_LuaState, i) || lua_isnil(m_LuaState, 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; return false;
} // for i - Param } // for i - Param
// All params checked ok // All params checked ok
return true; return true;
} }
@ -1324,7 +1324,7 @@ bool cLuaState::CheckParamEnd(int a_Param)
bool cLuaState::IsParamUserType(int a_Param, AString a_UserType) bool cLuaState::IsParamUserType(int a_Param, AString a_UserType)
{ {
ASSERT(IsValid()); ASSERT(IsValid());
tolua_Error tolua_err; tolua_Error tolua_err;
return (tolua_isusertype(m_LuaState, a_Param, a_UserType.c_str(), 0, &tolua_err) == 1); 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) bool cLuaState::IsParamNumber(int a_Param)
{ {
ASSERT(IsValid()); ASSERT(IsValid());
tolua_Error tolua_err; tolua_Error tolua_err;
return (tolua_isnumber(m_LuaState, a_Param, 0, &tolua_err) == 1); 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 // No error to report
return false; return false;
} }
LOGWARNING("LUA: %d - %s", a_Status, lua_tostring(a_LuaState, -1)); LOGWARNING("LUA: %d - %s", a_Status, lua_tostring(a_LuaState, -1));
lua_pop(a_LuaState, 1); lua_pop(a_LuaState, 1);
return true; return true;
@ -1416,10 +1416,10 @@ int cLuaState::CallFunctionWithForeignParams(
{ {
ASSERT(IsValid()); ASSERT(IsValid());
ASSERT(a_SrcLuaState.IsValid()); ASSERT(a_SrcLuaState.IsValid());
// Store the stack position before any changes // Store the stack position before any changes
int OldTop = lua_gettop(m_LuaState); int OldTop = lua_gettop(m_LuaState);
// Push the function to call, including the error handler: // Push the function to call, including the error handler:
if (!PushFunction(a_FunctionName.c_str())) if (!PushFunction(a_FunctionName.c_str()))
{ {
@ -1437,7 +1437,7 @@ int cLuaState::CallFunctionWithForeignParams(
m_CurrentFunctionName.clear(); m_CurrentFunctionName.clear();
return -1; return -1;
} }
// Call the function, with an error handler: // Call the function, with an error handler:
int s = lua_pcall(m_LuaState, a_SrcParamEnd - a_SrcParamStart + 1, LUA_MULTRET, OldTop + 1); int s = lua_pcall(m_LuaState, a_SrcParamEnd - a_SrcParamStart + 1, LUA_MULTRET, OldTop + 1);
if (ReportErrors(s)) 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()); LOGWARN("Error while calling function '%s' in '%s'", a_FunctionName.c_str(), m_SubsystemName.c_str());
// Reset the stack: // Reset the stack:
lua_settop(m_LuaState, OldTop); lua_settop(m_LuaState, OldTop);
// Reset the internal checking mechanisms: // Reset the internal checking mechanisms:
m_NumCurrentFunctionArgs = -1; m_NumCurrentFunctionArgs = -1;
m_CurrentFunctionName.clear(); m_CurrentFunctionName.clear();
// Make Lua think everything is okay and return 0 values, so that plugins continue executing. // Make Lua think everything is okay and return 0 values, so that plugins continue executing.
// The failure is indicated by the zero return values. // The failure is indicated by the zero return values.
return 0; return 0;
} }
// Reset the internal checking mechanisms: // Reset the internal checking mechanisms:
m_NumCurrentFunctionArgs = -1; m_NumCurrentFunctionArgs = -1;
m_CurrentFunctionName.clear(); m_CurrentFunctionName.clear();
// Remove the error handler from the stack: // Remove the error handler from the stack:
lua_remove(m_LuaState, OldTop + 1); lua_remove(m_LuaState, OldTop + 1);
// Return the number of return values: // Return the number of return values:
return lua_gettop(m_LuaState) - OldTop; 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 lua_rawget(a_SrcLuaState, LUA_REGISTRYINDEX); // Stack +1
type = lua_tostring(a_SrcLuaState, -1); type = lua_tostring(a_SrcLuaState, -1);
lua_pop(a_SrcLuaState, 1); // Stack -1 lua_pop(a_SrcLuaState, 1); // Stack -1
// Copy the value: // Copy the value:
void * ud = tolua_touserdata(a_SrcLuaState, i, nullptr); void * ud = tolua_touserdata(a_SrcLuaState, i, nullptr);
tolua_pushusertype(m_LuaState, ud, type); 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) void cLuaState::cRef::UnRef(void)
{ {
ASSERT(m_LuaState->IsValid()); // The reference should be destroyed before destroying the LuaState ASSERT(m_LuaState->IsValid()); // The reference should be destroyed before destroying the LuaState
if (IsValid()) if (IsValid())
{ {
luaL_unref(*m_LuaState, LUA_REGISTRYINDEX, m_Ref); luaL_unref(*m_LuaState, LUA_REGISTRYINDEX, m_Ref);

View File

@ -57,26 +57,26 @@ public:
public: public:
/** Creates an unbound reference object. */ /** Creates an unbound reference object. */
cRef(void); cRef(void);
/** Creates a reference in the specified LuaState for object at the specified StackPos */ /** Creates a reference in the specified LuaState for object at the specified StackPos */
cRef(cLuaState & a_LuaState, int a_StackPos); cRef(cLuaState & a_LuaState, int a_StackPos);
/** Moves the reference from the specified instance into a newly created instance. /** Moves the reference from the specified instance into a newly created instance.
The old instance is then "!IsValid()". */ The old instance is then "!IsValid()". */
cRef(cRef && a_FromRef); cRef(cRef && a_FromRef);
~cRef(); ~cRef();
/** Creates a reference to Lua object at the specified stack pos, binds this object to it. /** 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. */ Calls UnRef() first if previously bound to another reference. */
void RefStack(cLuaState & a_LuaState, int a_StackPos); void RefStack(cLuaState & a_LuaState, int a_StackPos);
/** Removes the bound reference, resets the object to Unbound state. */ /** Removes the bound reference, resets the object to Unbound state. */
void UnRef(void); void UnRef(void);
/** Returns true if the reference is valid */ /** Returns true if the reference is valid */
bool IsValid(void) const {return (m_Ref != LUA_REFNIL); } bool IsValid(void) const {return (m_Ref != LUA_REFNIL); }
/** Allows to use this class wherever an int (i. e. ref) is to be used */ /** Allows to use this class wherever an int (i. e. ref) is to be used */
explicit operator int(void) const { return m_Ref; } explicit operator int(void) const { return m_Ref; }
@ -87,8 +87,8 @@ public:
// Remove the copy-constructor: // Remove the copy-constructor:
cRef(const cRef &) = delete; cRef(const cRef &) = delete;
} ; } ;
/** Used for calling functions stored in a reference-stored table */ /** Used for calling functions stored in a reference-stored table */
class cTableRef class cTableRef
{ {
@ -100,7 +100,7 @@ public:
m_FnName(a_FnName) m_FnName(a_FnName)
{ {
} }
cTableRef(const cRef & a_TableRef, const char * a_FnName) : cTableRef(const cRef & a_TableRef, const char * a_FnName) :
m_TableRef(static_cast<int>(a_TableRef)), m_TableRef(static_cast<int>(a_TableRef)),
m_FnName(a_FnName) m_FnName(a_FnName)
@ -110,13 +110,13 @@ public:
int GetTableRef(void) const { return m_TableRef; } int GetTableRef(void) const { return m_TableRef; }
const char * GetFnName(void) const { return m_FnName; } 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() */ /** A dummy class that's used only to delimit function args from return values for cLuaState::Call() */
class cRet class cRet
{ {
} ; } ;
static const cRet Return; // Use this constant to delimit function args from return values for cLuaState::Call() 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 or "LuaScript" for the cLuaScript template
*/ */
cLuaState(const AString & a_SubsystemName); cLuaState(const AString & a_SubsystemName);
/** Creates a new instance. The a_AttachState is attached. /** Creates a new instance. The a_AttachState is attached.
Subsystem name is set to "<attached>". Subsystem name is set to "<attached>".
*/ */
explicit cLuaState(lua_State * a_AttachState); explicit cLuaState(lua_State * a_AttachState);
~cLuaState(); ~cLuaState();
/** Allows this object to be used in the same way as a lua_State *, for example in the LuaLib functions */ /** 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; } operator lua_State * (void) { return m_LuaState; }
/** Creates the m_LuaState, if not closed already. This state will be automatically closed in the destructor. /** 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 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. */ lite-config as well), use RegisterAPILibs() to do that. */
void Create(void); void Create(void);
/** Registers all the API libraries that MCS provides into m_LuaState. */ /** Registers all the API libraries that MCS provides into m_LuaState. */
void RegisterAPILibs(void); void RegisterAPILibs(void);
/** Closes the m_LuaState, if not closed already */ /** Closes the m_LuaState, if not closed already */
void Close(void); void Close(void);
/** Attaches the specified state. Operations will be carried out on this state, but it will not be closed in the destructor */ /** 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); void Attach(lua_State * a_State);
/** Detaches a previously attached state. */ /** Detaches a previously attached state. */
void Detach(void); void Detach(void);
@ -260,7 +260,7 @@ public:
void Push(long a_Value); void Push(long a_Value);
void Push(const UInt32 a_Value); void Push(const UInt32 a_Value);
void Push(std::chrono::milliseconds a_time); 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. // GetStackValue() retrieves the value at a_StackPos, if it is a valid type. If not, a_Value is unchanged.
// Returns whether value was changed // Returns whether value was changed
// Enum values are checked for their allowed values and fail if the value is not assigned. // 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 the auto-generated Push and GetStackValue() functions:
#include "LuaState_Declaration.inc" #include "LuaState_Declaration.inc"
/** Call the specified Lua function. /** Call the specified Lua function.
Returns true if call succeeded, false if there was an error. 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. 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 */ /** 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); 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 */ /** 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); 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 */ /** 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); 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 */ /** 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); 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 */ /** 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); 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 */ /** 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); 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 */ /** 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); 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 */ /** 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); 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) */ /** Returns true if the specified parameter on the stack is nil (indicating an end-of-parameters) */
bool CheckParamEnd(int a_Param); bool CheckParamEnd(int a_Param);
bool IsParamUserType(int a_Param, AString a_UserType); bool IsParamUserType(int a_Param, AString a_UserType);
bool IsParamNumber(int a_Param); bool IsParamNumber(int a_Param);
/** If the status is nonzero, prints the text on the top of Lua stack and returns true */ /** If the status is nonzero, prints the text on the top of Lua stack and returns true */
bool ReportErrors(int status); bool ReportErrors(int status);
/** If the status is nonzero, prints the text on the top of Lua stack and returns true */ /** 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); static bool ReportErrors(lua_State * a_LuaState, int status);
/** Logs all items in the current stack trace to the server console */ /** Logs all items in the current stack trace to the server console */
void LogStackTrace(int a_StartingDepth = 0); void LogStackTrace(int a_StartingDepth = 0);
/** Logs all items in the current stack trace to the server console */ /** Logs all items in the current stack trace to the server console */
static void LogStackTrace(lua_State * a_LuaState, int a_StartingDepth = 0); static void LogStackTrace(lua_State * a_LuaState, int a_StartingDepth = 0);
/** Returns the type of the item on the specified position in the stack */ /** Returns the type of the item on the specified position in the stack */
AString GetTypeText(int a_StackPos); AString GetTypeText(int a_StackPos);
/** Calls the function specified by its name, with arguments copied off the foreign state. /** 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 successful, keeps the return values on the stack and returns their number.
If unsuccessful, returns a negative number and keeps the stack position unchanged. */ If unsuccessful, returns a negative number and keeps the stack position unchanged. */
@ -417,37 +417,37 @@ public:
int a_SrcParamStart, int a_SrcParamStart,
int a_SrcParamEnd int a_SrcParamEnd
); );
/** Copies objects on the stack from the specified state. /** Copies objects on the stack from the specified state.
Only numbers, bools, strings and userdatas are copied. Only numbers, bools, strings and userdatas are copied.
If successful, returns the number of objects copied. If successful, returns the number of objects copied.
If failed, returns a negative number and rewinds the stack position. */ If failed, returns a negative number and rewinds the stack position. */
int CopyStackFrom(cLuaState & a_SrcLuaState, int a_SrcStart, int a_SrcEnd); 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. */ /** 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); void ToString(int a_StackPos, AString & a_String);
/** Logs all the elements' types on the API stack, with an optional header for the listing. */ /** Logs all the elements' types on the API stack, with an optional header for the listing. */
void LogStack(const char * a_Header = nullptr); void LogStack(const char * a_Header = nullptr);
/** Logs all the elements' types on the API stack, with an optional header for the listing. */ /** 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); static void LogStack(lua_State * a_LuaState, const char * a_Header = nullptr);
protected: protected:
lua_State * m_LuaState; lua_State * m_LuaState;
/** If true, the state is owned by this object and will be auto-Closed. False => attached state */ /** If true, the state is owned by this object and will be auto-Closed. False => attached state */
bool m_IsOwned; bool m_IsOwned;
/** The subsystem name is used for reporting errors to the console, it is either "plugin %s" or "LuaScript" /** The subsystem name is used for reporting errors to the console, it is either "plugin %s" or "LuaScript"
whatever is given to the constructor whatever is given to the constructor
*/ */
AString m_SubsystemName; AString m_SubsystemName;
/** Name of the currently pushed function (for the Push / Call chain) */ /** Name of the currently pushed function (for the Push / Call chain) */
AString m_CurrentFunctionName; AString m_CurrentFunctionName;
/** Number of arguments currently pushed (for the Push / Call chain) */ /** Number of arguments currently pushed (for the Push / Call chain) */
int m_NumCurrentFunctionArgs; int m_NumCurrentFunctionArgs;
@ -499,12 +499,12 @@ protected:
Returns true if successful. Logs a warning on failure (incl. m_SubsystemName) Returns true if successful. Logs a warning on failure (incl. m_SubsystemName)
*/ */
bool PushFunction(const char * a_FunctionName); bool PushFunction(const char * a_FunctionName);
/** Pushes a function that has been saved into the global registry, identified by a_FnRef. /** Pushes a function that has been saved into the global registry, identified by a_FnRef.
Returns true if successful. Logs a warning on failure Returns true if successful. Logs a warning on failure
*/ */
bool PushFunction(int a_FnRef); bool PushFunction(int a_FnRef);
/** Pushes a function that has been saved as a reference. /** Pushes a function that has been saved as a reference.
Returns true if successful. Logs a warning on failure Returns true if successful. Logs a warning on failure
*/ */
@ -512,12 +512,12 @@ protected:
{ {
return PushFunction(static_cast<int>(a_FnRef)); return PushFunction(static_cast<int>(a_FnRef));
} }
/** Pushes a function that is stored in a referenced table by name /** Pushes a function that is stored in a referenced table by name
Returns true if successful. Logs a warning on failure Returns true if successful. Logs a warning on failure
*/ */
bool PushFunction(const cTableRef & a_TableRef); bool PushFunction(const cTableRef & a_TableRef);
/** Pushes a usertype of the specified class type onto the stack */ /** Pushes a usertype of the specified class type onto the stack */
// void PushUserType(void * a_Object, const char * a_Type); // void PushUserType(void * a_Object, const char * a_Type);
@ -527,7 +527,7 @@ protected:
Returns true if successful, logs a warning on failure. Returns true if successful, logs a warning on failure.
*/ */
bool CallFunction(int a_NumReturnValues); bool CallFunction(int a_NumReturnValues);
/** Used as the error reporting function for function calls */ /** Used as the error reporting function for function calls */
static int ReportFnCallErrors(lua_State * a_LuaState); static int ReportFnCallErrors(lua_State * a_LuaState);

View File

@ -25,7 +25,7 @@ cLuaWindow::cLuaWindow(cWindow::WindowType a_WindowType, int a_SlotsX, int a_Slo
{ {
m_Contents.AddListener(*this); m_Contents.AddListener(*this);
m_SlotAreas.push_back(new cSlotAreaItemGrid(m_Contents, *this)); m_SlotAreas.push_back(new cSlotAreaItemGrid(m_Contents, *this));
// If appropriate, add an Armor slot area: // If appropriate, add an Armor slot area:
switch (a_WindowType) 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 // 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)); ASSERT((m_Plugin == nullptr) || (m_Plugin == a_Plugin));
// If there already was a function, unreference it first // If there already was a function, unreference it first
if (m_OnClosingFnRef != LUA_REFNIL) if (m_OnClosingFnRef != LUA_REFNIL)
{ {
m_Plugin->Unreference(m_OnClosingFnRef); m_Plugin->Unreference(m_OnClosingFnRef);
} }
// Store the new reference // Store the new reference
m_Plugin = a_Plugin; m_Plugin = a_Plugin;
m_OnClosingFnRef = a_FnRef; 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 // 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)); ASSERT((m_Plugin == nullptr) || (m_Plugin == a_Plugin));
// If there already was a function, unreference it first // If there already was a function, unreference it first
if (m_OnSlotChangedFnRef != LUA_REFNIL) if (m_OnSlotChangedFnRef != LUA_REFNIL)
{ {
m_Plugin->Unreference(m_OnSlotChangedFnRef); m_Plugin->Unreference(m_OnSlotChangedFnRef);
} }
// Store the new reference // Store the new reference
m_Plugin = a_Plugin; m_Plugin = a_Plugin;
m_OnSlotChangedFnRef = a_FnRef; m_OnSlotChangedFnRef = a_FnRef;
@ -141,7 +141,7 @@ bool cLuaWindow::ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse)
return false; return false;
} }
} }
return super::ClosedByPlayer(a_Player, a_CanRefuse); return super::ClosedByPlayer(a_Player, a_CanRefuse);
} }
@ -152,13 +152,13 @@ bool cLuaWindow::ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse)
void cLuaWindow::Destroy(void) void cLuaWindow::Destroy(void)
{ {
super::Destroy(); super::Destroy();
if ((m_LuaRef != LUA_REFNIL) && (m_Plugin != nullptr)) if ((m_LuaRef != LUA_REFNIL) && (m_Plugin != nullptr))
{ {
// The object is referenced by Lua, un-reference it // The object is referenced by Lua, un-reference it
m_Plugin->Unreference(m_LuaRef); m_Plugin->Unreference(m_LuaRef);
} }
// Lua will take care of this object, it will garbage-collect it, so we must not delete it! // Lua will take care of this object, it will garbage-collect it, so we must not delete it!
m_IsDestroyed = false; m_IsDestroyed = false;
} }
@ -192,7 +192,7 @@ void cLuaWindow::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
ASSERT(!"Invalid ItemGrid in callback"); ASSERT(!"Invalid ItemGrid in callback");
return; return;
} }
// If an OnSlotChanged callback has been registered, call it: // If an OnSlotChanged callback has been registered, call it:
if (m_OnSlotChangedFnRef != LUA_REFNIL) if (m_OnSlotChangedFnRef != LUA_REFNIL)
{ {

View File

@ -40,52 +40,52 @@ class cLuaWindow :
// tolua_begin // tolua_begin
{ {
typedef cWindow super; typedef cWindow super;
public: public:
/** Create a window of the specified type, with a slot grid of a_SlotsX * a_SlotsY size */ /** 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); cLuaWindow(cWindow::WindowType a_WindowType, int a_SlotsX, int a_SlotsY, const AString & a_Title);
virtual ~cLuaWindow(); virtual ~cLuaWindow();
/** Returns the internal representation of the contents that are manipulated by Lua */ /** Returns the internal representation of the contents that are manipulated by Lua */
cItemGrid & GetContents(void) { return m_Contents; } cItemGrid & GetContents(void) { return m_Contents; }
// tolua_end // tolua_end
/** Sets the plugin reference and the internal Lua object reference index /** 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. */ used for preventing Lua's GC to collect this class while the window is open. */
void SetLuaRef(cPluginLua * a_Plugin, int a_LuaRef); void SetLuaRef(cPluginLua * a_Plugin, int a_LuaRef);
/** Returns true if SetLuaRef() has been called */ /** Returns true if SetLuaRef() has been called */
bool IsLuaReferenced(void) const; bool IsLuaReferenced(void) const;
/** Sets the callback function (Lua reference) to call when the window is about to close */ /** Sets the callback function (Lua reference) to call when the window is about to close */
void SetOnClosing(cPluginLua * a_Plugin, int a_FnRef); void SetOnClosing(cPluginLua * a_Plugin, int a_FnRef);
/** Sets the callback function (Lua reference) to call when a slot is changed */ /** Sets the callback function (Lua reference) to call when a slot is changed */
void SetOnSlotChanged(cPluginLua * a_Plugin, int a_FnRef); void SetOnSlotChanged(cPluginLua * a_Plugin, int a_FnRef);
protected: protected:
/** Contents of the non-inventory part */ /** Contents of the non-inventory part */
cItemGrid m_Contents; cItemGrid m_Contents;
/** The plugin that has opened the window and owns the m_LuaRef */ /** The plugin that has opened the window and owns the m_LuaRef */
cPluginLua * m_Plugin; cPluginLua * m_Plugin;
/** The Lua object reference, used for keeping the object alive as long as any player has the window open */ /** The Lua object reference, used for keeping the object alive as long as any player has the window open */
int m_LuaRef; int m_LuaRef;
/** The Lua reference for the callback to call when the window is closing for any player */ /** The Lua reference for the callback to call when the window is closing for any player */
int m_OnClosingFnRef; int m_OnClosingFnRef;
/** The Lua reference for the callback to call when a slot has changed */ /** The Lua reference for the callback to call when a slot has changed */
int m_OnSlotChangedFnRef; int m_OnSlotChangedFnRef;
// cWindow overrides: // cWindow overrides:
virtual bool ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse) override; virtual bool ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse) override;
virtual void Destroy(void) 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; virtual void DistributeStack(cItem & a_ItemStack, int a_Slot, cPlayer & a_Player, cSlotArea * a_ClickedArea, bool a_ShouldApply) override;
// cItemGrid::cListener overrides: // cItemGrid::cListener overrides:
virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override; virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override;
} ; // tolua_export } ; // tolua_export

View File

@ -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()); LogLevel = cCompositeChat::MessageTypeToLogLevel(reinterpret_cast<cCompositeChat *>(tolua_tousertype(tolua_S, 1, nullptr))->GetMessageType());
} }
// Log the message: // Log the message:
cLogger::GetInstance().LogSimple(GetLogMessage(tolua_S).c_str(), LogLevel); cLogger::GetInstance().LogSimple(GetLogMessage(tolua_S).c_str(), LogLevel);
return 0; return 0;
@ -430,7 +430,7 @@ static int tolua_Base64Encode(lua_State * tolua_S)
{ {
return 0; return 0;
} }
AString Src; AString Src;
L.GetStackValue(1, Src); L.GetStackValue(1, Src);
AString res = Base64Encode(Src); AString res = Base64Encode(Src);
@ -452,7 +452,7 @@ static int tolua_Base64Decode(lua_State * tolua_S)
{ {
return 0; return 0;
} }
AString Src; AString Src;
L.GetStackValue(1, Src); L.GetStackValue(1, Src);
AString res = Base64Decode(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))); cPluginLua * Plugin = reinterpret_cast<cPluginLua *>(const_cast<void*>(lua_topointer(L, -1)));
lua_pop(L, 1); lua_pop(L, 1);
return Plugin; return Plugin;
} }
@ -746,7 +746,7 @@ static int tolua_cFile_GetFolderContents(lua_State * tolua_S)
{ {
return 0; return 0;
} }
// Get params: // Get params:
AString Folder; AString Folder;
ASSERT(LuaState.GetStackValues(2, Folder)); ASSERT(LuaState.GetStackValues(2, Folder));
@ -883,7 +883,7 @@ static int tolua_cFile_ReadWholeFile(lua_State * tolua_S)
{ {
return 0; return 0;
} }
// Get params: // Get params:
AString FileName; AString FileName;
ASSERT(LuaState.GetStackValues(2, 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 // Helper function for cPluginmanager:AddHook() binding
// Takes care of the new case (#121): args are HOOK_TYPE and CallbackFunction // Takes care of the new case (#121): args are HOOK_TYPE and CallbackFunction
// The arg types have already been checked // The arg types have already been checked
// Retrieve the cPlugin from the LuaState: // Retrieve the cPlugin from the LuaState:
cPluginLua * Plugin = cManualBindings::GetLuaPlugin(S); cPluginLua * Plugin = cManualBindings::GetLuaPlugin(S);
if (Plugin == nullptr) 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() // An error message has been already printed in GetLuaPlugin()
return 0; return 0;
} }
// Retrieve and check the hook type // Retrieve and check the hook type
int HookType = static_cast<int>(tolua_tonumber(S, a_ParamIdx, -1)); int HookType = static_cast<int>(tolua_tonumber(S, a_ParamIdx, -1));
if (!a_PluginManager->IsValidHookType(HookType)) if (!a_PluginManager->IsValidHookType(HookType))
@ -999,7 +999,7 @@ static int tolua_cPluginManager_AddHook_FnRef(cPluginManager * a_PluginManager,
S.LogStackTrace(); S.LogStackTrace();
return 0; return 0;
} }
// Add the hook to the plugin // Add the hook to the plugin
if (!Plugin->AddHookRef(HookType, a_ParamIdx + 1)) if (!Plugin->AddHookRef(HookType, a_ParamIdx + 1))
{ {
@ -1008,7 +1008,7 @@ static int tolua_cPluginManager_AddHook_FnRef(cPluginManager * a_PluginManager,
return 0; return 0;
} }
a_PluginManager->AddHook(Plugin, HookType); a_PluginManager->AddHook(Plugin, HookType);
// Success // Success
return 0; return 0;
} }
@ -1022,7 +1022,7 @@ static int tolua_cPluginManager_AddHook_DefFn(cPluginManager * a_PluginManager,
// Helper function for cPluginmanager:AddHook() binding // Helper function for cPluginmanager:AddHook() binding
// Takes care of the old case (#121): args are cPluginLua and HOOK_TYPE // Takes care of the old case (#121): args are cPluginLua and HOOK_TYPE
// The arg types have already been checked // The arg types have already been checked
// Retrieve and check the cPlugin parameter // Retrieve and check the cPlugin parameter
cPluginLua * Plugin = reinterpret_cast<cPluginLua *>(tolua_tousertype(S, a_ParamIdx, nullptr)); cPluginLua * Plugin = reinterpret_cast<cPluginLua *>(tolua_tousertype(S, a_ParamIdx, nullptr));
if (Plugin == nullptr) if (Plugin == nullptr)
@ -1038,7 +1038,7 @@ static int tolua_cPluginManager_AddHook_DefFn(cPluginManager * a_PluginManager,
S.LogStackTrace(); S.LogStackTrace();
return 0; return 0;
} }
// Retrieve and check the hook type // Retrieve and check the hook type
int HookType = static_cast<int>(tolua_tonumber(S, a_ParamIdx + 1, -1)); int HookType = static_cast<int>(tolua_tonumber(S, a_ParamIdx + 1, -1));
if (!a_PluginManager->IsValidHookType(HookType)) if (!a_PluginManager->IsValidHookType(HookType))
@ -1047,7 +1047,7 @@ static int tolua_cPluginManager_AddHook_DefFn(cPluginManager * a_PluginManager,
S.LogStackTrace(); S.LogStackTrace();
return 0; return 0;
} }
// Get the standard name for the callback function: // Get the standard name for the callback function:
const char * FnName = cPluginLua::GetHookFnName(HookType); const char * FnName = cPluginLua::GetHookFnName(HookType);
if (FnName == nullptr) if (FnName == nullptr)
@ -1068,7 +1068,7 @@ static int tolua_cPluginManager_AddHook_DefFn(cPluginManager * a_PluginManager,
return 0; return 0;
} }
a_PluginManager->AddHook(Plugin, HookType); a_PluginManager->AddHook(Plugin, HookType);
// Success // Success
return 0; 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: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 cPluginManager.AddHook(Plugin, HOOK_TYPE) -- (5) old style (#121) mangled, accepted but complained about in the console
*/ */
cLuaState S(tolua_S); cLuaState S(tolua_S);
cPluginManager * PlgMgr = cPluginManager::Get(); 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 // Style 1, use the global PlgMgr, but increment ParamIdx
ParamIdx++; ParamIdx++;
} }
if (lua_isnumber(S, ParamIdx) && lua_isfunction(S, ParamIdx + 1)) if (lua_isnumber(S, ParamIdx) && lua_isfunction(S, ParamIdx + 1))
{ {
// The next params are a number and a function, assume style 1 or 2 // 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(); S.LogStackTrace();
return tolua_cPluginManager_AddHook_DefFn(PlgMgr, S, ParamIdx); return tolua_cPluginManager_AddHook_DefFn(PlgMgr, S, ParamIdx);
} }
AString ParamDesc; AString ParamDesc;
Printf(ParamDesc, "%s, %s, %s", S.GetTypeText(1).c_str(), S.GetTypeText(2).c_str(), S.GetTypeText(3).c_str()); 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()); 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; return 0;
} }
// Read the arguments to this API call: // Read the arguments to this API call:
tolua_Error tolua_err; tolua_Error tolua_err;
int idx = 1; int idx = 1;
@ -1294,7 +1294,7 @@ static int tolua_cPluginManager_BindCommand(lua_State * L)
AString Command (tolua_tocppstring(L, idx, "")); AString Command (tolua_tocppstring(L, idx, ""));
AString Permission(tolua_tocppstring(L, idx + 1, "")); AString Permission(tolua_tocppstring(L, idx + 1, ""));
AString HelpString(tolua_tocppstring(L, idx + 3, "")); AString HelpString(tolua_tocppstring(L, idx + 3, ""));
// Store the function reference: // Store the function reference:
lua_pop(L, 1); // Pop the help string off the stack lua_pop(L, 1); // Pop the help string off the stack
int FnRef = luaL_ref(L, LUA_REGISTRYINDEX); // Store function reference 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()); LOGERROR("\"BindCommand\": Cannot create a function reference. Command \"%s\" not bound.", Command.c_str());
return 0; return 0;
} }
if (!self->BindCommand(Command, Plugin, Permission, HelpString)) if (!self->BindCommand(Command, Plugin, Permission, HelpString))
{ {
// Refused. Possibly already bound. Error message has been given, display the callstack: // 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(); LS.LogStackTrace();
return 0; return 0;
} }
Plugin->BindCommand(Command, FnRef); Plugin->BindCommand(Command, FnRef);
lua_pushboolean(L, true); lua_pushboolean(L, true);
return 1; return 1;
@ -1327,14 +1327,14 @@ static int tolua_cPluginManager_BindConsoleCommand(lua_State * L)
cPluginManager:BindConsoleCommand(Command, Function, HelpString) cPluginManager:BindConsoleCommand(Command, Function, HelpString)
cPluginManager.BindConsoleCommand(Command, Function, HelpString) -- without the "self" param cPluginManager.BindConsoleCommand(Command, Function, HelpString) -- without the "self" param
*/ */
// Get the plugin identification out of LuaState: // Get the plugin identification out of LuaState:
cPluginLua * Plugin = cManualBindings::GetLuaPlugin(L); cPluginLua * Plugin = cManualBindings::GetLuaPlugin(L);
if (Plugin == nullptr) if (Plugin == nullptr)
{ {
return 0; return 0;
} }
// Read the arguments to this API call: // Read the arguments to this API call:
tolua_Error tolua_err; tolua_Error tolua_err;
int idx = 1; int idx = 1;
@ -1362,7 +1362,7 @@ static int tolua_cPluginManager_BindConsoleCommand(lua_State * L)
cPluginManager * self = cPluginManager::Get(); cPluginManager * self = cPluginManager::Get();
AString Command (tolua_tocppstring(L, idx, "")); AString Command (tolua_tocppstring(L, idx, ""));
AString HelpString(tolua_tocppstring(L, idx + 2, "")); AString HelpString(tolua_tocppstring(L, idx + 2, ""));
// Store the function reference: // Store the function reference:
lua_pop(L, 1); // Pop the help string off the stack lua_pop(L, 1); // Pop the help string off the stack
int FnRef = luaL_ref(L, LUA_REGISTRYINDEX); // Store function reference 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()); LOGERROR("\"BindConsoleCommand\": Cannot create a function reference. Console Command \"%s\" not bound.", Command.c_str());
return 0; return 0;
} }
if (!self->BindConsoleCommand(Command, Plugin, HelpString)) if (!self->BindConsoleCommand(Command, Plugin, HelpString))
{ {
// Refused. Possibly already bound. Error message has been given, display the callstack: // 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(); LS.LogStackTrace();
return 0; return 0;
} }
Plugin->BindConsoleCommand(Command, FnRef); Plugin->BindConsoleCommand(Command, FnRef);
lua_pushboolean(L, true); lua_pushboolean(L, true);
return 1; return 1;
@ -1395,7 +1395,7 @@ static int tolua_cPluginManager_CallPlugin(lua_State * tolua_S)
Function signature: Function signature:
cPluginManager:CallPlugin("PluginName", "FunctionName", args...) cPluginManager:CallPlugin("PluginName", "FunctionName", args...)
*/ */
// Check the parameters: // Check the parameters:
cLuaState L(tolua_S); cLuaState L(tolua_S);
if ( if (
@ -1404,7 +1404,7 @@ static int tolua_cPluginManager_CallPlugin(lua_State * tolua_S)
{ {
return 0; return 0;
} }
// Retrieve the plugin name and function name // Retrieve the plugin name and function name
AString PluginName, FunctionName; AString PluginName, FunctionName;
L.ToString(2, PluginName); L.ToString(2, PluginName);
@ -1415,7 +1415,7 @@ static int tolua_cPluginManager_CallPlugin(lua_State * tolua_S)
L.LogStackTrace(); L.LogStackTrace();
return 0; return 0;
} }
// If requesting calling the current plugin, refuse: // If requesting calling the current plugin, refuse:
cPluginLua * ThisPlugin = cManualBindings::GetLuaPlugin(L); cPluginLua * ThisPlugin = cManualBindings::GetLuaPlugin(L);
if (ThisPlugin == nullptr) if (ThisPlugin == nullptr)
@ -1428,7 +1428,7 @@ static int tolua_cPluginManager_CallPlugin(lua_State * tolua_S)
L.LogStackTrace(); L.LogStackTrace();
return 0; return 0;
} }
// Call the destination plugin using a plugin callback: // Call the destination plugin using a plugin callback:
class cCallback : class cCallback :
public cPluginManager::cPluginCallback public cPluginManager::cPluginCallback
@ -1445,7 +1445,7 @@ static int tolua_cPluginManager_CallPlugin(lua_State * tolua_S)
protected: protected:
const AString & m_FunctionName; const AString & m_FunctionName;
cLuaState & m_SrcLuaState; cLuaState & m_SrcLuaState;
virtual bool Item(cPlugin * a_Plugin) override virtual bool Item(cPlugin * a_Plugin) override
{ {
if (!a_Plugin->IsLoaded()) 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)); LOGWARNING("%s: invalid self (%p)", __FUNCTION__, static_cast<void *>(self));
return 0; return 0;
} }
// Push the permissions: // Push the permissions:
L.Push(self->GetPermissions()); L.Push(self->GetPermissions());
return 1; 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)); LOGWARNING("%s: invalid self (%p)", __FUNCTION__, static_cast<void *>(self));
return 0; return 0;
} }
// Push the permissions: // Push the permissions:
L.Push(self->GetRestrictions()); L.Push(self->GetRestrictions());
return 1; 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)); LOGWARNING("%s: invalid self (%p) or wnd (%p)", __FUNCTION__, static_cast<void *>(self), static_cast<void *>(wnd));
return 0; return 0;
} }
// If cLuaWindow, add a reference, so that Lua won't delete the cLuaWindow object mid-processing // If cLuaWindow, add a reference, so that Lua won't delete the cLuaWindow object mid-processing
tolua_Error err; tolua_Error err;
if (tolua_isusertype(tolua_S, 2, "cLuaWindow", 0, &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); LuaWnd->SetLuaRef(Plugin, LuaRef);
} }
} }
// Open the window // Open the window
self->OpenWindow(wnd); self->OpenWindow(wnd);
return 0; return 0;
@ -1652,7 +1652,7 @@ static int tolua_cPlayer_PermissionMatches(lua_State * tolua_S)
// Get the params: // Get the params:
AString Permission, Template; AString Permission, Template;
L.GetStackValues(2, Permission, Template); L.GetStackValues(2, Permission, Template);
// Push the result of the match: // Push the result of the match:
L.Push(cPlayer::PermissionMatches(StringSplit(Permission, "."), StringSplit(Template, "."))); L.Push(cPlayer::PermissionMatches(StringSplit(Permission, "."), StringSplit(Template, ".")));
return 1; 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__); LOGERROR("%s: Cannot create a function reference. Callback not set.", __FUNCTION__);
return 0; return 0;
} }
// Set the callback // Set the callback
(self->*SetCallback)(Plugin, FnRef); (self->*SetCallback)(Plugin, FnRef);
return 0; return 0;
@ -1711,7 +1711,7 @@ static int tolua_cPluginLua_AddWebTab(lua_State * tolua_S)
LOGWARNING("cPluginLua:AddWebTab: invalid self as first argument"); LOGWARNING("cPluginLua:AddWebTab: invalid self as first argument");
return 0; return 0;
} }
tolua_Error tolua_err; tolua_Error tolua_err;
tolua_err.array = 0; tolua_err.array = 0;
tolua_err.index = 3; 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) static int tolua_cPlugin_GetDirectory(lua_State * tolua_S)
{ {
cLuaState L(tolua_S); cLuaState L(tolua_S);
// Log the obsoletion warning: // Log the obsoletion warning:
LOGWARNING("cPlugin:GetDirectory() is obsolete, use cPlugin:GetFolderName() instead."); LOGWARNING("cPlugin:GetDirectory() is obsolete, use cPlugin:GetFolderName() instead.");
L.LogStackTrace(); L.LogStackTrace();
// Retrieve the params: // Retrieve the params:
cPlugin * Plugin = static_cast<cPluginLua *>(tolua_tousertype(tolua_S, 1, nullptr)); cPlugin * Plugin = static_cast<cPluginLua *>(tolua_tousertype(tolua_S, 1, nullptr));
// Get the folder name: // Get the folder name:
L.Push(Plugin->GetFolderName()); L.Push(Plugin->GetFolderName());
return 1; return 1;
@ -1772,14 +1772,14 @@ static int tolua_cPlugin_GetDirectory(lua_State * tolua_S)
static int tolua_cPlugin_GetLocalDirectory(lua_State * tolua_S) static int tolua_cPlugin_GetLocalDirectory(lua_State * tolua_S)
{ {
cLuaState L(tolua_S); cLuaState L(tolua_S);
// Log the obsoletion warning: // Log the obsoletion warning:
LOGWARNING("cPlugin:GetLocalDirectory() is obsolete, use cPlugin:GetLocalFolder() instead."); LOGWARNING("cPlugin:GetLocalDirectory() is obsolete, use cPlugin:GetLocalFolder() instead.");
L.LogStackTrace(); L.LogStackTrace();
// Retrieve the params: // Retrieve the params:
cPlugin * Plugin = static_cast<cPluginLua *>(tolua_tousertype(tolua_S, 1, nullptr)); cPlugin * Plugin = static_cast<cPluginLua *>(tolua_tousertype(tolua_S, 1, nullptr));
// Get the folder: // Get the folder:
L.Push(Plugin->GetLocalFolder()); L.Push(Plugin->GetLocalFolder());
return 1; return 1;
@ -2145,11 +2145,11 @@ static int tolua_AllToLua_cWebAdmin_GetHTMLEscapedString(lua_State * tolua_S)
{ {
return 0; return 0;
} }
// Get the parameters: // Get the parameters:
AString Input; AString Input;
S.GetStackValue(2, Input); S.GetStackValue(2, Input);
// Convert and return: // Convert and return:
S.Push(cWebAdmin::GetHTMLEscapedString(Input)); S.Push(cWebAdmin::GetHTMLEscapedString(Input));
return 1; return 1;
@ -2173,11 +2173,11 @@ static int tolua_AllToLua_cWebAdmin_GetURLEncodedString(lua_State * tolua_S)
{ {
return 0; return 0;
} }
// Get the parameters: // Get the parameters:
AString Input; AString Input;
S.GetStackValue(2, Input); S.GetStackValue(2, Input);
// Convert and return: // Convert and return:
S.Push(cWebAdmin::GetURLEncodedString(Input)); S.Push(cWebAdmin::GetURLEncodedString(Input));
return 1; return 1;
@ -2249,12 +2249,12 @@ static int tolua_cMojangAPI_AddPlayerNameToUUIDMapping(lua_State * L)
{ {
return 0; return 0;
} }
// Retrieve the parameters: // Retrieve the parameters:
AString UUID, PlayerName; AString UUID, PlayerName;
S.GetStackValue(2, PlayerName); S.GetStackValue(2, PlayerName);
S.GetStackValue(3, UUID); S.GetStackValue(3, UUID);
// Store in the cache: // Store in the cache:
cRoot::Get()->GetMojangAPI().AddPlayerNameToUUIDMapping(PlayerName, UUID); cRoot::Get()->GetMojangAPI().AddPlayerNameToUUIDMapping(PlayerName, UUID);
return 0; return 0;
@ -2275,10 +2275,10 @@ static int tolua_cMojangAPI_GetPlayerNameFromUUID(lua_State * L)
{ {
return 0; return 0;
} }
AString UUID; AString UUID;
S.GetStackValue(2, UUID); S.GetStackValue(2, UUID);
// If the UseOnlyCached param was given, read it; default to false // If the UseOnlyCached param was given, read it; default to false
bool ShouldUseCacheOnly = false; bool ShouldUseCacheOnly = false;
if (lua_gettop(L) == 3) if (lua_gettop(L) == 3)
@ -2308,10 +2308,10 @@ static int tolua_cMojangAPI_GetUUIDFromPlayerName(lua_State * L)
{ {
return 0; return 0;
} }
AString PlayerName; AString PlayerName;
S.GetStackValue(2, PlayerName); S.GetStackValue(2, PlayerName);
// If the UseOnlyCached param was given, read it; default to false // If the UseOnlyCached param was given, read it; default to false
bool ShouldUseCacheOnly = false; bool ShouldUseCacheOnly = false;
if (lua_gettop(L) == 3) if (lua_gettop(L) == 3)
@ -2341,7 +2341,7 @@ static int tolua_cMojangAPI_GetUUIDsFromPlayerNames(lua_State * L)
{ {
return 0; return 0;
} }
// Convert the input table into AStringVector: // Convert the input table into AStringVector:
AStringVector PlayerNames; AStringVector PlayerNames;
int NumNames = luaL_getn(L, 2); int NumNames = luaL_getn(L, 2);
@ -2357,7 +2357,7 @@ static int tolua_cMojangAPI_GetUUIDsFromPlayerNames(lua_State * L)
} }
lua_pop(L, 1); lua_pop(L, 1);
} }
// If the UseOnlyCached param was given, read it; default to false // If the UseOnlyCached param was given, read it; default to false
bool ShouldUseCacheOnly = false; bool ShouldUseCacheOnly = false;
if (lua_gettop(L) == 3) if (lua_gettop(L) == 3)
@ -2368,7 +2368,7 @@ static int tolua_cMojangAPI_GetUUIDsFromPlayerNames(lua_State * L)
// Push the output table onto the stack: // Push the output table onto the stack:
lua_newtable(L); lua_newtable(L);
// Get the UUIDs: // Get the UUIDs:
AStringVector UUIDs = cRoot::Get()->GetMojangAPI().GetUUIDsFromPlayerNames(PlayerNames, ShouldUseCacheOnly); AStringVector UUIDs = cRoot::Get()->GetMojangAPI().GetUUIDsFromPlayerNames(PlayerNames, ShouldUseCacheOnly);
if (UUIDs.size() != PlayerNames.size()) 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: // A hard error has occured while processing the request, no UUIDs were returned. Return an empty table:
return 1; return 1;
} }
// Convert to output table, PlayerName -> UUID: // Convert to output table, PlayerName -> UUID:
size_t len = UUIDs.size(); size_t len = UUIDs.size();
for (size_t i = 0; i < len; i++) for (size_t i = 0; i < len; i++)
@ -2410,7 +2410,7 @@ static int tolua_cMojangAPI_MakeUUIDDashed(lua_State * L)
{ {
return 0; return 0;
} }
// Get the params: // Get the params:
AString UUID; AString UUID;
S.GetStackValue(2, UUID); S.GetStackValue(2, UUID);
@ -2438,7 +2438,7 @@ static int tolua_cMojangAPI_MakeUUIDShort(lua_State * L)
{ {
return 0; return 0;
} }
// Get the params: // Get the params:
AString UUID; AString UUID;
S.GetStackValue(2, 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)); tolua_pushnumber(L, static_cast<lua_Number>(Y));
return 2; return 2;
} }
tolua_lerror: tolua_lerror:
tolua_error(L, "#ferror in function 'cItemGrid:GetSlotCoords'.", &tolua_err); tolua_error(L, "#ferror in function 'cItemGrid:GetSlotCoords'.", &tolua_err);
return 0; return 0;
@ -2498,7 +2498,7 @@ public:
m_TableRef(a_LuaState, a_ParamNum) 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 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; bool res = false;
@ -2513,7 +2513,7 @@ public:
} }
return res; return res;
} }
virtual bool OnNextBlockNoData(int a_BlockX, int a_BlockY, int a_BlockZ, char a_EntryFace) override virtual bool OnNextBlockNoData(int a_BlockX, int a_BlockY, int a_BlockZ, char a_EntryFace) override
{ {
bool res = false; bool res = false;
@ -2528,7 +2528,7 @@ public:
} }
return res; return res;
} }
virtual bool OnOutOfWorld(double a_BlockX, double a_BlockY, double a_BlockZ) override virtual bool OnOutOfWorld(double a_BlockX, double a_BlockY, double a_BlockZ) override
{ {
bool res = false; bool res = false;
@ -2543,7 +2543,7 @@ public:
} }
return res; return res;
} }
virtual bool OnIntoWorld(double a_BlockX, double a_BlockY, double a_BlockZ) override virtual bool OnIntoWorld(double a_BlockX, double a_BlockY, double a_BlockZ) override
{ {
bool res = false; bool res = false;
@ -2558,12 +2558,12 @@ public:
} }
return res; return res;
} }
virtual void OnNoMoreHits(void) override virtual void OnNoMoreHits(void) override
{ {
m_LuaState.Call(cLuaState::cTableRef(m_TableRef, "OnNoMoreHits")); m_LuaState.Call(cLuaState::cTableRef(m_TableRef, "OnNoMoreHits"));
} }
virtual void OnNoChunk(void) override virtual void OnNoChunk(void) override
{ {
m_LuaState.Call(cLuaState::cTableRef(m_TableRef, "OnNoChunk")); 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) // Canonical
cLineBlockTracer.Trace(World, Callbacks, StartX, StartY, StartZ, EndX, EndY, EndZ) cLineBlockTracer.Trace(World, Callbacks, StartX, StartY, StartZ, EndX, EndY, EndZ)
*/ */
// If the first param is the cLineBlockTracer class, shift param index by one: // If the first param is the cLineBlockTracer class, shift param index by one:
int idx = 1; int idx = 1;
tolua_Error err; tolua_Error err;
@ -2592,7 +2592,7 @@ static int tolua_cLineBlockTracer_Trace(lua_State * tolua_S)
{ {
idx = 2; idx = 2;
} }
// Check params: // Check params:
cLuaState L(tolua_S); cLuaState L(tolua_S);
if ( if (
@ -2726,7 +2726,7 @@ static int tolua_cRoot_GetFurnaceRecipe(lua_State * tolua_S)
{ {
return 0; return 0;
} }
// Check the input param: // Check the input param:
cItem * Input = nullptr; cItem * Input = nullptr;
L.GetStackValue(2, Input); 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."); LOGWARNING("cRoot:GetFurnaceRecipe: the Input parameter is nil or missing.");
return 0; return 0;
} }
// Get the recipe for the input // Get the recipe for the input
cFurnaceRecipe * FR = cRoot::Get()->GetFurnaceRecipe(); cFurnaceRecipe * FR = cRoot::Get()->GetFurnaceRecipe();
const cFurnaceRecipe::cRecipe * Recipe = FR->GetRecipeFrom(*Input); 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 // There is no such furnace recipe for this input, return no value
return 0; return 0;
} }
// Push the output, number of ticks and input as the three return values: // Push the output, number of ticks and input as the three return values:
L.Push(Recipe->Out); L.Push(Recipe->Out);
L.Push(Recipe->CookTime); L.Push(Recipe->CookTime);
@ -2760,7 +2760,7 @@ static int tolua_cHopperEntity_GetOutputBlockPos(lua_State * tolua_S)
{ {
// function cHopperEntity::GetOutputBlockPos() // function cHopperEntity::GetOutputBlockPos()
// Exported manually because tolua would require meaningless params // Exported manually because tolua would require meaningless params
cLuaState L(tolua_S); cLuaState L(tolua_S);
if ( if (
!L.CheckParamUserType(1, "cHopperEntity") || !L.CheckParamUserType(1, "cHopperEntity") ||
@ -2800,7 +2800,7 @@ static int tolua_cBlockArea_GetBlockTypeMeta(lua_State * tolua_S)
{ {
// function cBlockArea::GetBlockTypeMeta() // function cBlockArea::GetBlockTypeMeta()
// Exported manually because tolua generates extra input params for the outputs // Exported manually because tolua generates extra input params for the outputs
cLuaState L(tolua_S); cLuaState L(tolua_S);
if ( if (
!L.CheckParamUserType(1, "cBlockArea") || !L.CheckParamUserType(1, "cBlockArea") ||
@ -2809,7 +2809,7 @@ static int tolua_cBlockArea_GetBlockTypeMeta(lua_State * tolua_S)
{ {
return 0; return 0;
} }
cBlockArea * self = reinterpret_cast<cBlockArea *>(tolua_tousertype(tolua_S, 1, nullptr)); cBlockArea * self = reinterpret_cast<cBlockArea *>(tolua_tousertype(tolua_S, 1, nullptr));
if (self == 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 // Returns all three coords of the origin point
// Exported manually because there's no direct C++ equivalent, // Exported manually because there's no direct C++ equivalent,
// plus tolua would generate extra input params for the outputs // plus tolua would generate extra input params for the outputs
cLuaState L(tolua_S); cLuaState L(tolua_S);
if (!L.CheckParamUserType(1, "cBlockArea")) if (!L.CheckParamUserType(1, "cBlockArea"))
{ {
return 0; return 0;
} }
cBlockArea * self = reinterpret_cast<cBlockArea *>(tolua_tousertype(tolua_S, 1, nullptr)); cBlockArea * self = reinterpret_cast<cBlockArea *>(tolua_tousertype(tolua_S, 1, nullptr));
if (self == nullptr) if (self == nullptr)
{ {
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetOrigin'", nullptr); tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetOrigin'", nullptr);
return 0; return 0;
} }
// Push the three origin coords: // Push the three origin coords:
lua_pushnumber(tolua_S, self->GetOriginX()); lua_pushnumber(tolua_S, self->GetOriginX());
lua_pushnumber(tolua_S, self->GetOriginY()); lua_pushnumber(tolua_S, self->GetOriginY());
@ -2866,13 +2866,13 @@ static int tolua_cBlockArea_GetNonAirCropRelCoords(lua_State * tolua_S)
{ {
// function cBlockArea::GetNonAirCropRelCoords() // function cBlockArea::GetNonAirCropRelCoords()
// Exported manually because tolua would generate extra input params for the outputs // Exported manually because tolua would generate extra input params for the outputs
cLuaState L(tolua_S); cLuaState L(tolua_S);
if (!L.CheckParamUserType(1, "cBlockArea")) if (!L.CheckParamUserType(1, "cBlockArea"))
{ {
return 0; return 0;
} }
cBlockArea * self = nullptr; cBlockArea * self = nullptr;
BLOCKTYPE IgnoreBlockType = E_BLOCK_AIR; BLOCKTYPE IgnoreBlockType = E_BLOCK_AIR;
L.GetStackValues(1, self, IgnoreBlockType); 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); tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetNonAirCropRelCoords'", nullptr);
return 0; return 0;
} }
// Calculate the crop coords: // Calculate the crop coords:
int MinRelX, MinRelY, MinRelZ, MaxRelX, MaxRelY, MaxRelZ; int MinRelX, MinRelY, MinRelZ, MaxRelX, MaxRelY, MaxRelZ;
self->GetNonAirCropRelCoords(MinRelX, MinRelY, MinRelZ, MaxRelX, MaxRelY, MaxRelZ, IgnoreBlockType); 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() // function cBlockArea::GetRelBlockTypeMeta()
// Exported manually because tolua generates extra input params for the outputs // Exported manually because tolua generates extra input params for the outputs
cLuaState L(tolua_S); cLuaState L(tolua_S);
if ( if (
!L.CheckParamUserType(1, "cBlockArea") || !L.CheckParamUserType(1, "cBlockArea") ||
@ -2913,7 +2913,7 @@ static int tolua_cBlockArea_GetRelBlockTypeMeta(lua_State * tolua_S)
{ {
return 0; return 0;
} }
cBlockArea * self = reinterpret_cast<cBlockArea *>(tolua_tousertype(tolua_S, 1, nullptr)); cBlockArea * self = reinterpret_cast<cBlockArea *>(tolua_tousertype(tolua_S, 1, nullptr));
if (self == nullptr) if (self == nullptr)
{ {
@ -2941,20 +2941,20 @@ static int tolua_cBlockArea_GetSize(lua_State * tolua_S)
// Returns all three sizes of the area // Returns all three sizes of the area
// Exported manually because there's no direct C++ equivalent, // Exported manually because there's no direct C++ equivalent,
// plus tolua would generate extra input params for the outputs // plus tolua would generate extra input params for the outputs
cLuaState L(tolua_S); cLuaState L(tolua_S);
if (!L.CheckParamUserType(1, "cBlockArea")) if (!L.CheckParamUserType(1, "cBlockArea"))
{ {
return 0; return 0;
} }
cBlockArea * self = reinterpret_cast<cBlockArea *>(tolua_tousertype(tolua_S, 1, nullptr)); cBlockArea * self = reinterpret_cast<cBlockArea *>(tolua_tousertype(tolua_S, 1, nullptr));
if (self == nullptr) if (self == nullptr)
{ {
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetSize'", nullptr); tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetSize'", nullptr);
return 0; return 0;
} }
// Push the three origin coords: // Push the three origin coords:
lua_pushnumber(tolua_S, self->GetSizeX()); lua_pushnumber(tolua_S, self->GetSizeX());
lua_pushnumber(tolua_S, self->GetSizeY()); 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 // 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, // Exported manually because there's no direct C++ equivalent,
// plus tolua would generate extra input params for the outputs // plus tolua would generate extra input params for the outputs
cLuaState L(tolua_S); cLuaState L(tolua_S);
if (!L.CheckParamUserType(1, "cBlockArea")) if (!L.CheckParamUserType(1, "cBlockArea"))
{ {
return 0; return 0;
} }
cBlockArea * self = reinterpret_cast<cBlockArea *>(tolua_tousertype(tolua_S, 1, nullptr)); cBlockArea * self = reinterpret_cast<cBlockArea *>(tolua_tousertype(tolua_S, 1, nullptr));
if (self == nullptr) if (self == nullptr)
{ {
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetSize'", nullptr); tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetSize'", nullptr);
return 0; return 0;
} }
// Push the three origin coords: // Push the three origin coords:
lua_pushnumber(tolua_S, self->GetSizeX() - 1); lua_pushnumber(tolua_S, self->GetSizeX() - 1);
lua_pushnumber(tolua_S, self->GetSizeY() - 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); tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea::SaveToSchematicFile'", nullptr);
return 0; return 0;
} }
AString Data; AString Data;
if (cSchematicFileSerializer::SaveToSchematicString(*self, 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]) // function cCompositeChat:AddRunCommandPart(Message, Command, [Style])
// Exported manually to support call-chaining (return *this) // Exported manually to support call-chaining (return *this)
// Check params: // Check params:
cLuaState L(tolua_S); cLuaState L(tolua_S);
if ( 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); tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:AddRunCommandPart'", nullptr);
return 0; return 0;
} }
// Add the part: // Add the part:
AString Text, Command, Style; AString Text, Command, Style;
L.GetStackValue(2, Text); L.GetStackValue(2, Text);
L.GetStackValue(3, Command); L.GetStackValue(3, Command);
L.GetStackValue(4, Style); L.GetStackValue(4, Style);
self->AddRunCommandPart(Text, Command, Style); self->AddRunCommandPart(Text, Command, Style);
// Cut away everything from the stack except for the cCompositeChat instance; return that: // Cut away everything from the stack except for the cCompositeChat instance; return that:
lua_settop(L, 1); lua_settop(L, 1);
return 1; return 1;
@ -3160,7 +3160,7 @@ static int tolua_cCompositeChat_AddSuggestCommandPart(lua_State * tolua_S)
{ {
// function cCompositeChat:AddSuggestCommandPart(Message, Command, [Style]) // function cCompositeChat:AddSuggestCommandPart(Message, Command, [Style])
// Exported manually to support call-chaining (return *this) // Exported manually to support call-chaining (return *this)
// Check params: // Check params:
cLuaState L(tolua_S); cLuaState L(tolua_S);
if ( 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); tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:AddSuggestCommandPart'", nullptr);
return 0; return 0;
} }
// Add the part: // Add the part:
AString Text, Command, Style; AString Text, Command, Style;
L.GetStackValue(2, Text); L.GetStackValue(2, Text);
L.GetStackValue(3, Command); L.GetStackValue(3, Command);
L.GetStackValue(4, Style); L.GetStackValue(4, Style);
self->AddSuggestCommandPart(Text, Command, Style); self->AddSuggestCommandPart(Text, Command, Style);
// Cut away everything from the stack except for the cCompositeChat instance; return that: // Cut away everything from the stack except for the cCompositeChat instance; return that:
lua_settop(L, 1); lua_settop(L, 1);
return 1; return 1;
@ -3197,7 +3197,7 @@ static int tolua_cCompositeChat_AddTextPart(lua_State * tolua_S)
{ {
// function cCompositeChat:AddTextPart(Message, [Style]) // function cCompositeChat:AddTextPart(Message, [Style])
// Exported manually to support call-chaining (return *this) // Exported manually to support call-chaining (return *this)
// Check params: // Check params:
cLuaState L(tolua_S); cLuaState L(tolua_S);
if ( 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); tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:AddTextPart'", nullptr);
return 0; return 0;
} }
// Add the part: // Add the part:
AString Text, Style; AString Text, Style;
L.GetStackValue(2, Text); L.GetStackValue(2, Text);
L.GetStackValue(3, Style); L.GetStackValue(3, Style);
self->AddTextPart(Text, Style); self->AddTextPart(Text, Style);
// Cut away everything from the stack except for the cCompositeChat instance; return that: // Cut away everything from the stack except for the cCompositeChat instance; return that:
lua_settop(L, 1); lua_settop(L, 1);
return 1; return 1;
@ -3233,7 +3233,7 @@ static int tolua_cCompositeChat_AddUrlPart(lua_State * tolua_S)
{ {
// function cCompositeChat:AddTextPart(Message, Url, [Style]) // function cCompositeChat:AddTextPart(Message, Url, [Style])
// Exported manually to support call-chaining (return *this) // Exported manually to support call-chaining (return *this)
// Check params: // Check params:
cLuaState L(tolua_S); cLuaState L(tolua_S);
if ( 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); tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:AddUrlPart'", nullptr);
return 0; return 0;
} }
// Add the part: // Add the part:
AString Text, Url, Style; AString Text, Url, Style;
L.GetStackValue(2, Text); L.GetStackValue(2, Text);
L.GetStackValue(3, Url); L.GetStackValue(3, Url);
L.GetStackValue(4, Style); L.GetStackValue(4, Style);
self->AddUrlPart(Text, Url, Style); self->AddUrlPart(Text, Url, Style);
// Cut away everything from the stack except for the cCompositeChat instance; return that: // Cut away everything from the stack except for the cCompositeChat instance; return that:
lua_settop(L, 1); lua_settop(L, 1);
return 1; return 1;
@ -3270,7 +3270,7 @@ static int tolua_cCompositeChat_ParseText(lua_State * tolua_S)
{ {
// function cCompositeChat:ParseText(TextMessage) // function cCompositeChat:ParseText(TextMessage)
// Exported manually to support call-chaining (return *this) // Exported manually to support call-chaining (return *this)
// Check params: // Check params:
cLuaState L(tolua_S); cLuaState L(tolua_S);
if ( 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); tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:ParseText'", nullptr);
return 0; return 0;
} }
// Parse the text: // Parse the text:
AString Text; AString Text;
L.GetStackValue(2, Text); L.GetStackValue(2, Text);
self->ParseText(Text); self->ParseText(Text);
// Cut away everything from the stack except for the cCompositeChat instance; return that: // Cut away everything from the stack except for the cCompositeChat instance; return that:
lua_settop(L, 1); lua_settop(L, 1);
return 1; return 1;
@ -3305,7 +3305,7 @@ static int tolua_cCompositeChat_SetMessageType(lua_State * tolua_S)
{ {
// function cCompositeChat:SetMessageType(MessageType) // function cCompositeChat:SetMessageType(MessageType)
// Exported manually to support call-chaining (return *this) // Exported manually to support call-chaining (return *this)
// Check params: // Check params:
cLuaState L(tolua_S); cLuaState L(tolua_S);
if ( 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); tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:SetMessageType'", nullptr);
return 0; return 0;
} }
// Set the type: // Set the type:
int MessageType = mtCustom; int MessageType = mtCustom;
L.GetStackValue(2, MessageType); L.GetStackValue(2, MessageType);
self->SetMessageType(static_cast<eMessageType>(MessageType)); self->SetMessageType(static_cast<eMessageType>(MessageType));
// Cut away everything from the stack except for the cCompositeChat instance; return that: // Cut away everything from the stack except for the cCompositeChat instance; return that:
lua_settop(L, 1); lua_settop(L, 1);
return 1; return 1;
@ -3340,7 +3340,7 @@ static int tolua_cCompositeChat_UnderlineUrls(lua_State * tolua_S)
{ {
// function cCompositeChat:UnderlineUrls() // function cCompositeChat:UnderlineUrls()
// Exported manually to support call-chaining (return *this) // Exported manually to support call-chaining (return *this)
// Check params: // Check params:
cLuaState L(tolua_S); cLuaState L(tolua_S);
if (!L.CheckParamUserType(1, "cCompositeChat")) 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); tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:UnderlineUrls'", nullptr);
return 0; return 0;
} }
// Call the processing // Call the processing
self->UnderlineUrls(); self->UnderlineUrls();
// Cut away everything from the stack except for the cCompositeChat instance; return that: // Cut away everything from the stack except for the cCompositeChat instance; return that:
lua_settop(L, 1); lua_settop(L, 1);
return 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, "GetDirectory", tolua_cPlugin_GetDirectory);
tolua_function(tolua_S, "GetLocalDirectory", tolua_cPlugin_GetLocalDirectory); tolua_function(tolua_S, "GetLocalDirectory", tolua_cPlugin_GetLocalDirectory);
tolua_endmodule(tolua_S); tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S, "cPluginLua"); tolua_beginmodule(tolua_S, "cPluginLua");
tolua_function(tolua_S, "AddWebTab", tolua_cPluginLua_AddWebTab); tolua_function(tolua_S, "AddWebTab", tolua_cPluginLua_AddWebTab);
tolua_endmodule(tolua_S); tolua_endmodule(tolua_S);

View File

@ -27,7 +27,7 @@ class cManualBindings
public: public:
/** Binds all the manually implemented functions to tolua_S. */ /** Binds all the manually implemented functions to tolua_S. */
static void Bind(lua_State * tolua_S); static void Bind(lua_State * tolua_S);
protected: protected:
/** Binds the manually implemented cNetwork-related API to tolua_S. /** Binds the manually implemented cNetwork-related API to tolua_S.
Implemented in ManualBindings_Network.cpp. */ Implemented in ManualBindings_Network.cpp. */

View File

@ -37,7 +37,7 @@ static int tolua_cNetwork_Connect(lua_State * L)
{ {
return 0; return 0;
} }
// Get the plugin instance: // Get the plugin instance:
cPluginLua * Plugin = cManualBindings::GetLuaPlugin(L); cPluginLua * Plugin = cManualBindings::GetLuaPlugin(L);
if (Plugin == nullptr) if (Plugin == nullptr)
@ -90,7 +90,7 @@ static int tolua_cNetwork_CreateUDPEndpoint(lua_State * L)
{ {
return 0; return 0;
} }
// Get the plugin instance: // Get the plugin instance:
cPluginLua * Plugin = cManualBindings::GetLuaPlugin(L); cPluginLua * Plugin = cManualBindings::GetLuaPlugin(L);
if (Plugin == nullptr) if (Plugin == nullptr)
@ -142,7 +142,7 @@ static int tolua_cNetwork_EnumLocalIPAddresses(lua_State * L)
{ {
return 0; return 0;
} }
// Push the enumerated addresses: // Push the enumerated addresses:
S.Push(cNetwork::EnumLocalIPAddresses()); S.Push(cNetwork::EnumLocalIPAddresses());
return 1; return 1;
@ -168,7 +168,7 @@ static int tolua_cNetwork_HostnameToIP(lua_State * L)
{ {
return 0; return 0;
} }
// Get the plugin instance: // Get the plugin instance:
cPluginLua * Plugin = cManualBindings::GetLuaPlugin(L); cPluginLua * Plugin = cManualBindings::GetLuaPlugin(L);
if (Plugin == nullptr) if (Plugin == nullptr)
@ -209,7 +209,7 @@ static int tolua_cNetwork_IPToHostname(lua_State * L)
{ {
return 0; return 0;
} }
// Get the plugin instance: // Get the plugin instance:
cPluginLua * Plugin = cManualBindings::GetLuaPlugin(L); cPluginLua * Plugin = cManualBindings::GetLuaPlugin(L);
if (Plugin == nullptr) if (Plugin == nullptr)
@ -250,7 +250,7 @@ static int tolua_cNetwork_Listen(lua_State * L)
{ {
return 0; return 0;
} }
// Get the plugin instance: // Get the plugin instance:
cPluginLua * Plugin = cManualBindings::GetLuaPlugin(L); cPluginLua * Plugin = cManualBindings::GetLuaPlugin(L);
if (Plugin == nullptr) if (Plugin == nullptr)
@ -320,7 +320,7 @@ static int tolua_cServerHandle_Close(lua_State * L)
{ {
return 0; return 0;
} }
// Get the server handle: // Get the server handle:
cLuaServerHandle * Srv; cLuaServerHandle * Srv;
if (lua_isnil(L, 1)) if (lua_isnil(L, 1))
@ -354,7 +354,7 @@ static int tolua_cServerHandle_IsListening(lua_State * L)
{ {
return 0; return 0;
} }
// Get the server handle: // Get the server handle:
cLuaServerHandle * Srv; cLuaServerHandle * Srv;
if (lua_isnil(L, 1)) if (lua_isnil(L, 1))
@ -391,7 +391,7 @@ static int tolua_cTCPLink_Close(lua_State * L)
{ {
return 0; return 0;
} }
// Get the link: // Get the link:
cLuaTCPLink * Link; cLuaTCPLink * Link;
if (lua_isnil(L, 1)) if (lua_isnil(L, 1))
@ -425,7 +425,7 @@ static int tolua_cTCPLink_GetLocalIP(lua_State * L)
{ {
return 0; return 0;
} }
// Get the link: // Get the link:
cLuaTCPLink * Link; cLuaTCPLink * Link;
if (lua_isnil(L, 1)) if (lua_isnil(L, 1))
@ -459,7 +459,7 @@ static int tolua_cTCPLink_GetLocalPort(lua_State * L)
{ {
return 0; return 0;
} }
// Get the link: // Get the link:
cLuaTCPLink * Link; cLuaTCPLink * Link;
if (lua_isnil(L, 1)) if (lua_isnil(L, 1))
@ -493,7 +493,7 @@ static int tolua_cTCPLink_GetRemoteIP(lua_State * L)
{ {
return 0; return 0;
} }
// Get the link: // Get the link:
cLuaTCPLink * Link; cLuaTCPLink * Link;
if (lua_isnil(L, 1)) if (lua_isnil(L, 1))
@ -527,7 +527,7 @@ static int tolua_cTCPLink_GetRemotePort(lua_State * L)
{ {
return 0; return 0;
} }
// Get the link: // Get the link:
cLuaTCPLink * Link; cLuaTCPLink * Link;
if (lua_isnil(L, 1)) if (lua_isnil(L, 1))
@ -562,7 +562,7 @@ static int tolua_cTCPLink_Send(lua_State * L)
{ {
return 0; return 0;
} }
// Get the link: // Get the link:
cLuaTCPLink * Link; cLuaTCPLink * Link;
if (lua_isnil(L, 1)) if (lua_isnil(L, 1))
@ -600,7 +600,7 @@ static int tolua_cTCPLink_Shutdown(lua_State * L)
{ {
return 0; return 0;
} }
// Get the link: // Get the link:
cLuaTCPLink * Link; cLuaTCPLink * Link;
if (lua_isnil(L, 1)) if (lua_isnil(L, 1))
@ -671,7 +671,7 @@ static int tolua_cTCPLink_StartTLSServer(lua_State * L)
{ {
return 0; return 0;
} }
// Get the link: // Get the link:
cLuaTCPLink * Link; cLuaTCPLink * Link;
if (lua_isnil(L, 1)) if (lua_isnil(L, 1))
@ -732,7 +732,7 @@ static int tolua_cUDPEndpoint_Close(lua_State * L)
{ {
return 0; return 0;
} }
// Get the endpoint: // Get the endpoint:
if (lua_isnil(L, 1)) if (lua_isnil(L, 1))
{ {
@ -765,7 +765,7 @@ static int tolua_cUDPEndpoint_EnableBroadcasts(lua_State * L)
{ {
return 0; return 0;
} }
// Get the endpoint: // Get the endpoint:
if (lua_isnil(L, 1)) if (lua_isnil(L, 1))
{ {
@ -798,7 +798,7 @@ static int tolua_cUDPEndpoint_GetPort(lua_State * L)
{ {
return 0; return 0;
} }
// Get the endpoint: // Get the endpoint:
if (lua_isnil(L, 1)) if (lua_isnil(L, 1))
{ {
@ -831,7 +831,7 @@ static int tolua_cUDPEndpoint_IsOpen(lua_State * L)
{ {
return 0; return 0;
} }
// Get the endpoint: // Get the endpoint:
if (lua_isnil(L, 1)) if (lua_isnil(L, 1))
{ {
@ -866,7 +866,7 @@ static int tolua_cUDPEndpoint_Send(lua_State * L)
{ {
return 0; return 0;
} }
// Get the link: // Get the link:
if (lua_isnil(L, 1)) 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, "cServerHandle", "cServerHandle", "", tolua_collect_cServerHandle);
tolua_cclass(tolua_S, "cTCPLink", "cTCPLink", "", nullptr); tolua_cclass(tolua_S, "cTCPLink", "cTCPLink", "", nullptr);
tolua_cclass(tolua_S, "cUDPEndpoint", "cUDPEndpoint", "", tolua_collect_cUDPEndpoint); tolua_cclass(tolua_S, "cUDPEndpoint", "cUDPEndpoint", "", tolua_collect_cUDPEndpoint);
// Fill in the functions (alpha-sorted): // Fill in the functions (alpha-sorted):
tolua_beginmodule(tolua_S, "cNetwork"); tolua_beginmodule(tolua_S, "cNetwork");
tolua_function(tolua_S, "Connect", tolua_cNetwork_Connect); tolua_function(tolua_S, "Connect", tolua_cNetwork_Connect);

View File

@ -28,11 +28,11 @@ static int tolua_cRankManager_AddGroup(lua_State * L)
{ {
return 0; return 0;
} }
// Read the params: // Read the params:
AString GroupName; AString GroupName;
S.GetStackValue(2, GroupName); S.GetStackValue(2, GroupName);
// Add the group: // Add the group:
cRoot::Get()->GetRankManager()->AddGroup(GroupName); cRoot::Get()->GetRankManager()->AddGroup(GroupName);
return 0; return 0;
@ -57,11 +57,11 @@ static int tolua_cRankManager_AddGroupToRank(lua_State * L)
{ {
return 0; return 0;
} }
// Read the params: // Read the params:
AString GroupName, RankName; AString GroupName, RankName;
S.GetStackValues(2, GroupName, RankName); S.GetStackValues(2, GroupName, RankName);
// Add the group to the rank: // Add the group to the rank:
S.Push(cRoot::Get()->GetRankManager()->AddGroupToRank(GroupName, RankName)); S.Push(cRoot::Get()->GetRankManager()->AddGroupToRank(GroupName, RankName));
return 1; return 1;
@ -86,11 +86,11 @@ static int tolua_cRankManager_AddPermissionToGroup(lua_State * L)
{ {
return 0; return 0;
} }
// Read the params: // Read the params:
AString GroupName, Permission; AString GroupName, Permission;
S.GetStackValues(2, Permission, GroupName); S.GetStackValues(2, Permission, GroupName);
// Add the group to the rank: // Add the group to the rank:
S.Push(cRoot::Get()->GetRankManager()->AddPermissionToGroup(Permission, GroupName)); S.Push(cRoot::Get()->GetRankManager()->AddPermissionToGroup(Permission, GroupName));
return 1; return 1;
@ -115,11 +115,11 @@ static int tolua_cRankManager_AddRestrictionToGroup(lua_State * L)
{ {
return 0; return 0;
} }
// Read the params: // Read the params:
AString GroupName, Permission; AString GroupName, Permission;
S.GetStackValues(2, Permission, GroupName); S.GetStackValues(2, Permission, GroupName);
// Add the group to the rank: // Add the group to the rank:
S.Push(cRoot::Get()->GetRankManager()->AddRestrictionToGroup(Permission, GroupName)); S.Push(cRoot::Get()->GetRankManager()->AddRestrictionToGroup(Permission, GroupName));
return 1; return 1;
@ -134,7 +134,7 @@ static int tolua_cRankManager_AddRank(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:AddRank(RankName) // cRankManager:AddRank(RankName)
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -144,11 +144,11 @@ static int tolua_cRankManager_AddRank(lua_State * L)
{ {
return 0; return 0;
} }
// Read the params: // Read the params:
AString RankName, MsgPrefix, MsgSuffix, MsgNameColorCode; AString RankName, MsgPrefix, MsgSuffix, MsgNameColorCode;
S.GetStackValues(2, RankName, MsgPrefix, MsgSuffix, MsgNameColorCode); S.GetStackValues(2, RankName, MsgPrefix, MsgSuffix, MsgNameColorCode);
// Add the rank: // Add the rank:
cRoot::Get()->GetRankManager()->AddRank(RankName, MsgPrefix, MsgSuffix, MsgNameColorCode); cRoot::Get()->GetRankManager()->AddRank(RankName, MsgPrefix, MsgSuffix, MsgNameColorCode);
return 0; return 0;
@ -184,7 +184,7 @@ static int tolua_cRankManager_GetAllGroups(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:GetAllGroups() -> arraytable of GroupNames // cRankManager:GetAllGroups() -> arraytable of GroupNames
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -193,10 +193,10 @@ static int tolua_cRankManager_GetAllGroups(lua_State * L)
{ {
return 0; return 0;
} }
// Get the groups: // Get the groups:
AStringVector Groups = cRoot::Get()->GetRankManager()->GetAllGroups(); AStringVector Groups = cRoot::Get()->GetRankManager()->GetAllGroups();
// Push the results: // Push the results:
S.Push(Groups); S.Push(Groups);
return 1; return 1;
@ -211,7 +211,7 @@ static int tolua_cRankManager_GetAllPermissions(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:GetAllPermissions() -> arraytable of Permissions // cRankManager:GetAllPermissions() -> arraytable of Permissions
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -220,10 +220,10 @@ static int tolua_cRankManager_GetAllPermissions(lua_State * L)
{ {
return 0; return 0;
} }
// Get the permissions: // Get the permissions:
AStringVector Permissions = cRoot::Get()->GetRankManager()->GetAllPermissions(); AStringVector Permissions = cRoot::Get()->GetRankManager()->GetAllPermissions();
// Push the results: // Push the results:
S.Push(Permissions); S.Push(Permissions);
return 1; return 1;
@ -238,7 +238,7 @@ static int tolua_cRankManager_GetAllRestrictions(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:GetAllRestrictions() -> arraytable of Permissions // cRankManager:GetAllRestrictions() -> arraytable of Permissions
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -247,10 +247,10 @@ static int tolua_cRankManager_GetAllRestrictions(lua_State * L)
{ {
return 0; return 0;
} }
// Get the permissions: // Get the permissions:
AStringVector Permissions = cRoot::Get()->GetRankManager()->GetAllRestrictions(); AStringVector Permissions = cRoot::Get()->GetRankManager()->GetAllRestrictions();
// Push the results: // Push the results:
S.Push(Permissions); S.Push(Permissions);
return 1; return 1;
@ -265,7 +265,7 @@ static int tolua_cRankManager_GetAllPermissionsRestrictions(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:GetAllPermissionsRestrictions() -> arraytable of Permissions and Restrictions // cRankManager:GetAllPermissionsRestrictions() -> arraytable of Permissions and Restrictions
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -274,10 +274,10 @@ static int tolua_cRankManager_GetAllPermissionsRestrictions(lua_State * L)
{ {
return 0; return 0;
} }
// Get the permissions: // Get the permissions:
AStringVector Permissions = cRoot::Get()->GetRankManager()->GetAllPermissionsRestrictions(); AStringVector Permissions = cRoot::Get()->GetRankManager()->GetAllPermissionsRestrictions();
// Push the results: // Push the results:
S.Push(Permissions); S.Push(Permissions);
return 1; return 1;
@ -319,7 +319,7 @@ static int tolua_cRankManager_GetAllRanks(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:GetAllRanks() -> arraytable of RankNames // cRankManager:GetAllRanks() -> arraytable of RankNames
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -328,10 +328,10 @@ static int tolua_cRankManager_GetAllRanks(lua_State * L)
{ {
return 0; return 0;
} }
// Get the ranks: // Get the ranks:
AStringVector Ranks = cRoot::Get()->GetRankManager()->GetAllRanks(); AStringVector Ranks = cRoot::Get()->GetRankManager()->GetAllRanks();
// Push the results: // Push the results:
S.Push(Ranks); S.Push(Ranks);
return 1; return 1;
@ -346,7 +346,7 @@ static int tolua_cRankManager_GetDefaultRank(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:GetDefaultRank() -> string // cRankManager:GetDefaultRank() -> string
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -355,7 +355,7 @@ static int tolua_cRankManager_GetDefaultRank(lua_State * L)
{ {
return 0; return 0;
} }
// Return the rank name: // Return the rank name:
S.Push(cRoot::Get()->GetRankManager()->GetDefaultRank()); S.Push(cRoot::Get()->GetRankManager()->GetDefaultRank());
return 1; return 1;
@ -370,7 +370,7 @@ static int tolua_cRankManager_GetGroupPermissions(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:GetGroupPermissions(GroupName) -> arraytable of permissions // cRankManager:GetGroupPermissions(GroupName) -> arraytable of permissions
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -380,14 +380,14 @@ static int tolua_cRankManager_GetGroupPermissions(lua_State * L)
{ {
return 0; return 0;
} }
// Get the params: // Get the params:
AString GroupName; AString GroupName;
S.GetStackValue(2, GroupName); S.GetStackValue(2, GroupName);
// Get the permissions: // Get the permissions:
AStringVector Permissions = cRoot::Get()->GetRankManager()->GetGroupPermissions(GroupName); AStringVector Permissions = cRoot::Get()->GetRankManager()->GetGroupPermissions(GroupName);
// Push the results: // Push the results:
S.Push(Permissions); S.Push(Permissions);
return 1; return 1;
@ -402,7 +402,7 @@ static int tolua_cRankManager_GetGroupRestrictions(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:GetGroupRestrictions(GroupName) -> arraytable of restrictions // cRankManager:GetGroupRestrictions(GroupName) -> arraytable of restrictions
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -412,14 +412,14 @@ static int tolua_cRankManager_GetGroupRestrictions(lua_State * L)
{ {
return 0; return 0;
} }
// Get the params: // Get the params:
AString GroupName; AString GroupName;
S.GetStackValue(2, GroupName); S.GetStackValue(2, GroupName);
// Get the restrictions: // Get the restrictions:
AStringVector Restrictions = cRoot::Get()->GetRankManager()->GetGroupRestrictions(GroupName); AStringVector Restrictions = cRoot::Get()->GetRankManager()->GetGroupRestrictions(GroupName);
// Push the results: // Push the results:
S.Push(Restrictions); S.Push(Restrictions);
return 1; return 1;
@ -434,7 +434,7 @@ static int tolua_cRankManager_GetPlayerGroups(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:GetPlayerGroups(PlayerUUID) -> arraytable of GroupNames // cRankManager:GetPlayerGroups(PlayerUUID) -> arraytable of GroupNames
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -444,14 +444,14 @@ static int tolua_cRankManager_GetPlayerGroups(lua_State * L)
{ {
return 0; return 0;
} }
// Get the params: // Get the params:
AString PlayerUUID; AString PlayerUUID;
S.GetStackValue(2, PlayerUUID); S.GetStackValue(2, PlayerUUID);
// Get the groups: // Get the groups:
AStringVector Groups = cRoot::Get()->GetRankManager()->GetPlayerGroups(PlayerUUID); AStringVector Groups = cRoot::Get()->GetRankManager()->GetPlayerGroups(PlayerUUID);
// Push the results: // Push the results:
S.Push(Groups); S.Push(Groups);
return 1; return 1;
@ -466,7 +466,7 @@ static int tolua_cRankManager_GetPlayerMsgVisuals(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:GetPlayerMsgVisuals(PlayerUUID) -> string, string, string // cRankManager:GetPlayerMsgVisuals(PlayerUUID) -> string, string, string
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -476,18 +476,18 @@ static int tolua_cRankManager_GetPlayerMsgVisuals(lua_State * L)
{ {
return 0; return 0;
} }
// Get the params: // Get the params:
AString PlayerUUID; AString PlayerUUID;
S.GetStackValue(2, PlayerUUID); S.GetStackValue(2, PlayerUUID);
// Get the permissions: // Get the permissions:
AString MsgPrefix, MsgSuffix, MsgNameColorCode; AString MsgPrefix, MsgSuffix, MsgNameColorCode;
if (!cRoot::Get()->GetRankManager()->GetPlayerMsgVisuals(PlayerUUID, MsgPrefix, MsgSuffix, MsgNameColorCode)) if (!cRoot::Get()->GetRankManager()->GetPlayerMsgVisuals(PlayerUUID, MsgPrefix, MsgSuffix, MsgNameColorCode))
{ {
return 0; return 0;
} }
// Push the results: // Push the results:
S.Push(MsgPrefix); S.Push(MsgPrefix);
S.Push(MsgSuffix); S.Push(MsgSuffix);
@ -504,7 +504,7 @@ static int tolua_cRankManager_GetPlayerPermissions(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:GetPlayerPermissions(PlayerUUID) -> arraytable of permissions // cRankManager:GetPlayerPermissions(PlayerUUID) -> arraytable of permissions
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -514,14 +514,14 @@ static int tolua_cRankManager_GetPlayerPermissions(lua_State * L)
{ {
return 0; return 0;
} }
// Get the params: // Get the params:
AString PlayerUUID; AString PlayerUUID;
S.GetStackValue(2, PlayerUUID); S.GetStackValue(2, PlayerUUID);
// Get the permissions: // Get the permissions:
AStringVector Permissions = cRoot::Get()->GetRankManager()->GetPlayerPermissions(PlayerUUID); AStringVector Permissions = cRoot::Get()->GetRankManager()->GetPlayerPermissions(PlayerUUID);
// Push the results: // Push the results:
S.Push(Permissions); S.Push(Permissions);
return 1; return 1;
@ -536,7 +536,7 @@ static int tolua_cRankManager_GetPlayerRestrictions(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:GetPlayerRestrictions(PlayerUUID) -> arraytable of restrictions // cRankManager:GetPlayerRestrictions(PlayerUUID) -> arraytable of restrictions
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -546,14 +546,14 @@ static int tolua_cRankManager_GetPlayerRestrictions(lua_State * L)
{ {
return 0; return 0;
} }
// Get the params: // Get the params:
AString PlayerUUID; AString PlayerUUID;
S.GetStackValue(2, PlayerUUID); S.GetStackValue(2, PlayerUUID);
// Get the permissions: // Get the permissions:
AStringVector Restrictions = cRoot::Get()->GetRankManager()->GetPlayerRestrictions(PlayerUUID); AStringVector Restrictions = cRoot::Get()->GetRankManager()->GetPlayerRestrictions(PlayerUUID);
// Push the results: // Push the results:
S.Push(Restrictions); S.Push(Restrictions);
return 1; return 1;
@ -568,7 +568,7 @@ static int tolua_cRankManager_GetPlayerRankName(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:GetPlayerRankName(PlayerUUID) -> string // cRankManager:GetPlayerRankName(PlayerUUID) -> string
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -578,14 +578,14 @@ static int tolua_cRankManager_GetPlayerRankName(lua_State * L)
{ {
return 0; return 0;
} }
// Get the params: // Get the params:
AString PlayerUUID; AString PlayerUUID;
S.GetStackValue(2, PlayerUUID); S.GetStackValue(2, PlayerUUID);
// Get the rank name: // Get the rank name:
AString RankName = cRoot::Get()->GetRankManager()->GetPlayerRankName(PlayerUUID); AString RankName = cRoot::Get()->GetRankManager()->GetPlayerRankName(PlayerUUID);
// Push the result: // Push the result:
S.Push(RankName); S.Push(RankName);
return 1; return 1;
@ -632,7 +632,7 @@ static int tolua_cRankManager_GetRankGroups(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:GetRankGroups(RankName) -> arraytable of groupnames // cRankManager:GetRankGroups(RankName) -> arraytable of groupnames
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -642,14 +642,14 @@ static int tolua_cRankManager_GetRankGroups(lua_State * L)
{ {
return 0; return 0;
} }
// Get the params: // Get the params:
AString RankName; AString RankName;
S.GetStackValue(2, RankName); S.GetStackValue(2, RankName);
// Get the groups: // Get the groups:
AStringVector Groups = cRoot::Get()->GetRankManager()->GetRankGroups(RankName); AStringVector Groups = cRoot::Get()->GetRankManager()->GetRankGroups(RankName);
// Push the results: // Push the results:
S.Push(Groups); S.Push(Groups);
return 1; return 1;
@ -664,7 +664,7 @@ static int tolua_cRankManager_GetRankPermissions(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:GetRankPermissions(RankName) -> arraytable of permissions // cRankManager:GetRankPermissions(RankName) -> arraytable of permissions
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -674,14 +674,14 @@ static int tolua_cRankManager_GetRankPermissions(lua_State * L)
{ {
return 0; return 0;
} }
// Get the params: // Get the params:
AString RankName; AString RankName;
S.GetStackValue(2, RankName); S.GetStackValue(2, RankName);
// Get the permissions: // Get the permissions:
AStringVector Permissions = cRoot::Get()->GetRankManager()->GetRankPermissions(RankName); AStringVector Permissions = cRoot::Get()->GetRankManager()->GetRankPermissions(RankName);
// Push the results: // Push the results:
S.Push(Permissions); S.Push(Permissions);
return 1; return 1;
@ -696,7 +696,7 @@ static int tolua_cRankManager_GetRankRestrictions(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:GetRankRestrictions(RankName) -> arraytable of restrictions // cRankManager:GetRankRestrictions(RankName) -> arraytable of restrictions
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -706,14 +706,14 @@ static int tolua_cRankManager_GetRankRestrictions(lua_State * L)
{ {
return 0; return 0;
} }
// Get the params: // Get the params:
AString RankName; AString RankName;
S.GetStackValue(2, RankName); S.GetStackValue(2, RankName);
// Get the permissions: // Get the permissions:
AStringVector Restrictions = cRoot::Get()->GetRankManager()->GetRankRestrictions(RankName); AStringVector Restrictions = cRoot::Get()->GetRankManager()->GetRankRestrictions(RankName);
// Push the results: // Push the results:
S.Push(Restrictions); S.Push(Restrictions);
return 1; return 1;
@ -728,7 +728,7 @@ static int tolua_cRankManager_GetRankVisuals(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:GetRankVisuals(RankName) -> MsgPrefix, MsgSuffix, MsgNameColorCode // cRankManager:GetRankVisuals(RankName) -> MsgPrefix, MsgSuffix, MsgNameColorCode
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -738,11 +738,11 @@ static int tolua_cRankManager_GetRankVisuals(lua_State * L)
{ {
return 0; return 0;
} }
// Get the params: // Get the params:
AString RankName; AString RankName;
S.GetStackValue(2, RankName); S.GetStackValue(2, RankName);
// Get the visuals: // Get the visuals:
AString MsgPrefix, MsgSuffix, MsgNameColorCode; AString MsgPrefix, MsgSuffix, MsgNameColorCode;
if (!cRoot::Get()->GetRankManager()->GetRankVisuals(RankName, 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: // No such rank, return nothing:
return 0; return 0;
} }
// Push the results: // Push the results:
S.Push(MsgPrefix); S.Push(MsgPrefix);
S.Push(MsgSuffix); S.Push(MsgSuffix);
@ -767,7 +767,7 @@ static int tolua_cRankManager_GroupExists(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:GroupExists(GroupName) -> bool // cRankManager:GroupExists(GroupName) -> bool
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -777,14 +777,14 @@ static int tolua_cRankManager_GroupExists(lua_State * L)
{ {
return 0; return 0;
} }
// Get the params: // Get the params:
AString GroupName; AString GroupName;
S.GetStackValue(2, GroupName); S.GetStackValue(2, GroupName);
// Get the response: // Get the response:
bool res = cRoot::Get()->GetRankManager()->GroupExists(GroupName); bool res = cRoot::Get()->GetRankManager()->GroupExists(GroupName);
// Push the result: // Push the result:
S.Push(res); S.Push(res);
return 1; return 1;
@ -799,7 +799,7 @@ static int tolua_cRankManager_IsGroupInRank(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:IsGroupInRank(GroupName, RankName) -> bool // cRankManager:IsGroupInRank(GroupName, RankName) -> bool
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -809,14 +809,14 @@ static int tolua_cRankManager_IsGroupInRank(lua_State * L)
{ {
return 0; return 0;
} }
// Get the params: // Get the params:
AString GroupName, RankName; AString GroupName, RankName;
S.GetStackValues(2, GroupName, RankName); S.GetStackValues(2, GroupName, RankName);
// Get the response: // Get the response:
bool res = cRoot::Get()->GetRankManager()->IsGroupInRank(GroupName, RankName); bool res = cRoot::Get()->GetRankManager()->IsGroupInRank(GroupName, RankName);
// Push the result: // Push the result:
S.Push(res); S.Push(res);
return 1; return 1;
@ -831,7 +831,7 @@ static int tolua_cRankManager_IsPermissionInGroup(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:IsPermissionInGroup(Permission, GroupName) -> bool // cRankManager:IsPermissionInGroup(Permission, GroupName) -> bool
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -841,14 +841,14 @@ static int tolua_cRankManager_IsPermissionInGroup(lua_State * L)
{ {
return 0; return 0;
} }
// Get the params: // Get the params:
AString GroupName, Permission; AString GroupName, Permission;
S.GetStackValues(2, Permission, GroupName); S.GetStackValues(2, Permission, GroupName);
// Get the response: // Get the response:
bool res = cRoot::Get()->GetRankManager()->IsPermissionInGroup(Permission, GroupName); bool res = cRoot::Get()->GetRankManager()->IsPermissionInGroup(Permission, GroupName);
// Push the result: // Push the result:
S.Push(res); S.Push(res);
return 1; return 1;
@ -863,7 +863,7 @@ static int tolua_cRankManager_IsRestrictionInGroup(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:IsRestrictionInGroup(Restriction, GroupName) -> bool // cRankManager:IsRestrictionInGroup(Restriction, GroupName) -> bool
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -873,14 +873,14 @@ static int tolua_cRankManager_IsRestrictionInGroup(lua_State * L)
{ {
return 0; return 0;
} }
// Get the params: // Get the params:
AString GroupName, Restriction; AString GroupName, Restriction;
S.GetStackValues(2, Restriction, GroupName); S.GetStackValues(2, Restriction, GroupName);
// Get the response: // Get the response:
bool res = cRoot::Get()->GetRankManager()->IsRestrictionInGroup(Restriction, GroupName); bool res = cRoot::Get()->GetRankManager()->IsRestrictionInGroup(Restriction, GroupName);
// Push the result: // Push the result:
S.Push(res); S.Push(res);
return 1; return 1;
@ -895,7 +895,7 @@ static int tolua_cRankManager_IsPlayerRankSet(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:IsPlayerRankSet(PlayerUUID) -> bool // cRankManager:IsPlayerRankSet(PlayerUUID) -> bool
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -905,14 +905,14 @@ static int tolua_cRankManager_IsPlayerRankSet(lua_State * L)
{ {
return 0; return 0;
} }
// Get the params: // Get the params:
AString PlayerUUID; AString PlayerUUID;
S.GetStackValue(2, PlayerUUID); S.GetStackValue(2, PlayerUUID);
// Get the response: // Get the response:
bool res = cRoot::Get()->GetRankManager()->IsPlayerRankSet(PlayerUUID); bool res = cRoot::Get()->GetRankManager()->IsPlayerRankSet(PlayerUUID);
// Push the result: // Push the result:
S.Push(res); S.Push(res);
return 1; return 1;
@ -927,7 +927,7 @@ static int tolua_cRankManager_RankExists(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:RankExists(RankName) -> bool // cRankManager:RankExists(RankName) -> bool
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -937,14 +937,14 @@ static int tolua_cRankManager_RankExists(lua_State * L)
{ {
return 0; return 0;
} }
// Get the params: // Get the params:
AString RankName; AString RankName;
S.GetStackValue(2, RankName); S.GetStackValue(2, RankName);
// Get the response: // Get the response:
bool res = cRoot::Get()->GetRankManager()->RankExists(RankName); bool res = cRoot::Get()->GetRankManager()->RankExists(RankName);
// Push the result: // Push the result:
S.Push(res); S.Push(res);
return 1; return 1;
@ -959,7 +959,7 @@ static int tolua_cRankManager_RemoveGroup(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:RemoveGroup(GroupName) // cRankManager:RemoveGroup(GroupName)
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -969,11 +969,11 @@ static int tolua_cRankManager_RemoveGroup(lua_State * L)
{ {
return 0; return 0;
} }
// Get the params: // Get the params:
AString GroupName; AString GroupName;
S.GetStackValue(2, GroupName); S.GetStackValue(2, GroupName);
// Remove the group: // Remove the group:
cRoot::Get()->GetRankManager()->RemoveGroup(GroupName); cRoot::Get()->GetRankManager()->RemoveGroup(GroupName);
return 0; return 0;
@ -988,7 +988,7 @@ static int tolua_cRankManager_RemoveGroupFromRank(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:RemoveGroupFromRank(GroupName, RankName) // cRankManager:RemoveGroupFromRank(GroupName, RankName)
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -998,11 +998,11 @@ static int tolua_cRankManager_RemoveGroupFromRank(lua_State * L)
{ {
return 0; return 0;
} }
// Get the params: // Get the params:
AString GroupName, RankName; AString GroupName, RankName;
S.GetStackValues(2, GroupName, RankName); S.GetStackValues(2, GroupName, RankName);
// Remove the group: // Remove the group:
cRoot::Get()->GetRankManager()->RemoveGroupFromRank(GroupName, RankName); cRoot::Get()->GetRankManager()->RemoveGroupFromRank(GroupName, RankName);
return 0; return 0;
@ -1017,7 +1017,7 @@ static int tolua_cRankManager_RemovePermissionFromGroup(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:RemovePermissionFromGroup(Permission, GroupName) // cRankManager:RemovePermissionFromGroup(Permission, GroupName)
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -1027,11 +1027,11 @@ static int tolua_cRankManager_RemovePermissionFromGroup(lua_State * L)
{ {
return 0; return 0;
} }
// Get the params: // Get the params:
AString GroupName, Permission; AString GroupName, Permission;
S.GetStackValues(2, Permission, GroupName); S.GetStackValues(2, Permission, GroupName);
// Remove the permission: // Remove the permission:
cRoot::Get()->GetRankManager()->RemovePermissionFromGroup(Permission, GroupName); cRoot::Get()->GetRankManager()->RemovePermissionFromGroup(Permission, GroupName);
return 0; return 0;
@ -1046,7 +1046,7 @@ static int tolua_cRankManager_RemoveRestrictionFromGroup(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:RemoveRestrictionFromGroup(Restriction, GroupName) // cRankManager:RemoveRestrictionFromGroup(Restriction, GroupName)
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -1056,11 +1056,11 @@ static int tolua_cRankManager_RemoveRestrictionFromGroup(lua_State * L)
{ {
return 0; return 0;
} }
// Get the params: // Get the params:
AString GroupName, Restriction; AString GroupName, Restriction;
S.GetStackValues(2, Restriction, GroupName); S.GetStackValues(2, Restriction, GroupName);
// Remove the restriction: // Remove the restriction:
cRoot::Get()->GetRankManager()->RemoveRestrictionFromGroup(Restriction, GroupName); cRoot::Get()->GetRankManager()->RemoveRestrictionFromGroup(Restriction, GroupName);
return 0; return 0;
@ -1075,7 +1075,7 @@ static int tolua_cRankManager_RemovePlayerRank(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:RemovePlayerRank(PlayerUUID) // cRankManager:RemovePlayerRank(PlayerUUID)
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -1085,11 +1085,11 @@ static int tolua_cRankManager_RemovePlayerRank(lua_State * L)
{ {
return 0; return 0;
} }
// Get the params: // Get the params:
AString PlayerUUID; AString PlayerUUID;
S.GetStackValue(2, PlayerUUID); S.GetStackValue(2, PlayerUUID);
// Remove the player's rank: // Remove the player's rank:
cRoot::Get()->GetRankManager()->RemovePlayerRank(PlayerUUID); cRoot::Get()->GetRankManager()->RemovePlayerRank(PlayerUUID);
return 0; return 0;
@ -1104,7 +1104,7 @@ static int tolua_cRankManager_RemoveRank(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:RemoveRank(RankName, [ReplacementRankName]) // cRankManager:RemoveRank(RankName, [ReplacementRankName])
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -1115,11 +1115,11 @@ static int tolua_cRankManager_RemoveRank(lua_State * L)
{ {
return 0; return 0;
} }
// Get the params: // Get the params:
AString RankName, ReplacementRankName; AString RankName, ReplacementRankName;
S.GetStackValues(2, RankName, ReplacementRankName); S.GetStackValues(2, RankName, ReplacementRankName);
// Remove the rank: // Remove the rank:
cRoot::Get()->GetRankManager()->RemoveRank(RankName, ReplacementRankName); cRoot::Get()->GetRankManager()->RemoveRank(RankName, ReplacementRankName);
return 0; return 0;
@ -1134,7 +1134,7 @@ static int tolua_cRankManager_RenameGroup(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:RenameGroup(OldName, NewName) // cRankManager:RenameGroup(OldName, NewName)
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -1144,14 +1144,14 @@ static int tolua_cRankManager_RenameGroup(lua_State * L)
{ {
return 0; return 0;
} }
// Get the params: // Get the params:
AString OldName, NewName; AString OldName, NewName;
S.GetStackValues(2, OldName, NewName); S.GetStackValues(2, OldName, NewName);
// Remove the group: // Remove the group:
bool res = cRoot::Get()->GetRankManager()->RenameGroup(OldName, NewName); bool res = cRoot::Get()->GetRankManager()->RenameGroup(OldName, NewName);
// Push the result: // Push the result:
S.Push(res); S.Push(res);
return 1; return 1;
@ -1166,7 +1166,7 @@ static int tolua_cRankManager_RenameRank(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:RenameRank(OldName, NewName) // cRankManager:RenameRank(OldName, NewName)
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -1176,14 +1176,14 @@ static int tolua_cRankManager_RenameRank(lua_State * L)
{ {
return 0; return 0;
} }
// Get the params: // Get the params:
AString OldName, NewName; AString OldName, NewName;
S.GetStackValues(2, OldName, NewName); S.GetStackValues(2, OldName, NewName);
// Remove the rank: // Remove the rank:
bool res = cRoot::Get()->GetRankManager()->RenameRank(OldName, NewName); bool res = cRoot::Get()->GetRankManager()->RenameRank(OldName, NewName);
// Push the result: // Push the result:
S.Push(res); S.Push(res);
return 1; return 1;
@ -1198,7 +1198,7 @@ static int tolua_cRankManager_SetDefaultRank(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:SetDefaultRank(RankName) -> bool // cRankManager:SetDefaultRank(RankName) -> bool
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -1208,11 +1208,11 @@ static int tolua_cRankManager_SetDefaultRank(lua_State * L)
{ {
return 0; return 0;
} }
// Get the params: // Get the params:
AString RankName; AString RankName;
S.GetStackValue(2, RankName); S.GetStackValue(2, RankName);
// Set the rank, return the result: // Set the rank, return the result:
S.Push(cRoot::Get()->GetRankManager()->SetDefaultRank(RankName)); S.Push(cRoot::Get()->GetRankManager()->SetDefaultRank(RankName));
return 1; return 1;
@ -1227,7 +1227,7 @@ static int tolua_cRankManager_SetPlayerRank(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:SetPlayerRank(PlayerUUID, PlayerName, RankName) // cRankManager:SetPlayerRank(PlayerUUID, PlayerName, RankName)
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -1237,11 +1237,11 @@ static int tolua_cRankManager_SetPlayerRank(lua_State * L)
{ {
return 0; return 0;
} }
// Get the params: // Get the params:
AString PlayerUUID, PlayerName, RankName; AString PlayerUUID, PlayerName, RankName;
S.GetStackValues(2, PlayerUUID, PlayerName, RankName); S.GetStackValues(2, PlayerUUID, PlayerName, RankName);
// Set the rank: // Set the rank:
cRoot::Get()->GetRankManager()->SetPlayerRank(PlayerUUID, PlayerName, RankName); cRoot::Get()->GetRankManager()->SetPlayerRank(PlayerUUID, PlayerName, RankName);
return 0; return 0;
@ -1256,7 +1256,7 @@ static int tolua_cRankManager_SetRankVisuals(lua_State * L)
{ {
// Function signature: // Function signature:
// cRankManager:SetRankVisuals(RankName, MsgPrefix, MsgSuffix, MsgNameColorCode) // cRankManager:SetRankVisuals(RankName, MsgPrefix, MsgSuffix, MsgNameColorCode)
cLuaState S(L); cLuaState S(L);
if ( if (
!S.CheckParamUserTable(1, "cRankManager") || !S.CheckParamUserTable(1, "cRankManager") ||
@ -1266,11 +1266,11 @@ static int tolua_cRankManager_SetRankVisuals(lua_State * L)
{ {
return 0; return 0;
} }
// Get the params: // Get the params:
AString RankName, MsgPrefix, MsgSuffix, MsgNameColorCode; AString RankName, MsgPrefix, MsgSuffix, MsgNameColorCode;
S.GetStackValues(2, RankName, MsgPrefix, MsgSuffix, MsgNameColorCode); S.GetStackValues(2, RankName, MsgPrefix, MsgSuffix, MsgNameColorCode);
// Set the visuals: // Set the visuals:
cRoot::Get()->GetRankManager()->SetRankVisuals(RankName, MsgPrefix, MsgSuffix, MsgNameColorCode); cRoot::Get()->GetRankManager()->SetRankVisuals(RankName, MsgPrefix, MsgSuffix, MsgNameColorCode);
return 0; return 0;
@ -1285,7 +1285,7 @@ void cManualBindings::BindRankManager(lua_State * tolua_S)
// Create the cRankManager class in the API: // Create the cRankManager class in the API:
tolua_usertype(tolua_S, "cRankManager"); tolua_usertype(tolua_S, "cRankManager");
tolua_cclass(tolua_S, "cRankManager", "cRankManager", "", nullptr); tolua_cclass(tolua_S, "cRankManager", "cRankManager", "", nullptr);
// Fill in the functions (alpha-sorted): // Fill in the functions (alpha-sorted):
tolua_beginmodule(tolua_S, "cRankManager"); tolua_beginmodule(tolua_S, "cRankManager");
tolua_function(tolua_S, "AddGroup", tolua_cRankManager_AddGroup); tolua_function(tolua_S, "AddGroup", tolua_cRankManager_AddGroup);

View File

@ -30,7 +30,7 @@ static int tolua_cWorld_BroadcastParticleEffect(lua_State * tolua_S)
{ {
return 0; return 0;
} }
// Read the params: // Read the params:
cWorld * World = nullptr; cWorld * World = nullptr;
AString Name; AString Name;
@ -68,7 +68,7 @@ static int tolua_cWorld_ChunkStay(lua_State * tolua_S)
World:ChunkStay(ChunkCoordTable, OnChunkAvailable, OnAllChunksAvailable) World:ChunkStay(ChunkCoordTable, OnChunkAvailable, OnAllChunksAvailable)
ChunkCoordTable == { {Chunk1x, Chunk1z}, {Chunk2x, Chunk2z}, ... } ChunkCoordTable == { {Chunk1x, Chunk1z}, {Chunk2x, Chunk2z}, ... }
*/ */
cLuaState L(tolua_S); cLuaState L(tolua_S);
if ( if (
!L.CheckParamUserType (1, "cWorld") || !L.CheckParamUserType (1, "cWorld") ||
@ -78,13 +78,13 @@ static int tolua_cWorld_ChunkStay(lua_State * tolua_S)
{ {
return 0; return 0;
} }
cPluginLua * Plugin = cManualBindings::GetLuaPlugin(tolua_S); cPluginLua * Plugin = cManualBindings::GetLuaPlugin(tolua_S);
if (Plugin == nullptr) if (Plugin == nullptr)
{ {
return 0; return 0;
} }
// Read the params: // Read the params:
cWorld * World = reinterpret_cast<cWorld *>(tolua_tousertype(tolua_S, 1, nullptr)); cWorld * World = reinterpret_cast<cWorld *>(tolua_tousertype(tolua_S, 1, nullptr));
if (World == nullptr) if (World == nullptr)
@ -116,7 +116,7 @@ static int tolua_cWorld_DoExplosionAt(lua_State * tolua_S)
/* Function signature: /* Function signature:
World:DoExplosionAt(ExplosionSize, BlockX, BlockY, BlockZ, CanCauseFire, SourceType, [SourceData]) World:DoExplosionAt(ExplosionSize, BlockX, BlockY, BlockZ, CanCauseFire, SourceType, [SourceData])
*/ */
cLuaState L(tolua_S); cLuaState L(tolua_S);
if ( if (
!L.CheckParamUserType (1, "cWorld") || !L.CheckParamUserType (1, "cWorld") ||
@ -128,7 +128,7 @@ static int tolua_cWorld_DoExplosionAt(lua_State * tolua_S)
{ {
return 0; return 0;
} }
// Read the params: // Read the params:
cWorld * World; cWorld * World;
double ExplosionSize; double ExplosionSize;
@ -405,7 +405,7 @@ static int tolua_cWorld_PrepareChunk(lua_State * tolua_S)
/* Function signature: /* Function signature:
World:PrepareChunk(ChunkX, ChunkZ, Callback) World:PrepareChunk(ChunkX, ChunkZ, Callback)
*/ */
// Check the param types: // Check the param types:
cLuaState L(tolua_S); cLuaState L(tolua_S);
if ( if (
@ -416,7 +416,7 @@ static int tolua_cWorld_PrepareChunk(lua_State * tolua_S)
{ {
return 0; return 0;
} }
// Read the params: // Read the params:
cWorld * world = nullptr; cWorld * world = nullptr;
int chunkX = 0; int chunkX = 0;
@ -497,7 +497,7 @@ static int tolua_cWorld_QueueTask(lua_State * tolua_S)
{ {
// Binding for cWorld::QueueTask // Binding for cWorld::QueueTask
// Params: function // Params: function
// Retrieve the cPlugin from the LuaState: // Retrieve the cPlugin from the LuaState:
cPluginLua * Plugin = cManualBindings::GetLuaPlugin(tolua_S); cPluginLua * Plugin = cManualBindings::GetLuaPlugin(tolua_S);
if (Plugin == nullptr) if (Plugin == nullptr)
@ -578,7 +578,7 @@ static int tolua_cWorld_ScheduleTask(lua_State * tolua_S)
{ {
// Binding for cWorld::ScheduleTask // Binding for cWorld::ScheduleTask
// Params: function, Ticks // Params: function, Ticks
// Retrieve the cPlugin from the LuaState: // Retrieve the cPlugin from the LuaState:
cPluginLua * Plugin = cManualBindings::GetLuaPlugin(tolua_S); cPluginLua * Plugin = cManualBindings::GetLuaPlugin(tolua_S);
if (Plugin == nullptr) 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"); 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); auto ResettableTask = std::make_shared<cLuaWorldTask>(*Plugin, FnRef);
Plugin->AddResettable(ResettableTask); Plugin->AddResettable(ResettableTask);
World->ScheduleTask(static_cast<int>(tolua_tonumber(tolua_S, 2, 0)), std::bind(&cLuaWorldTask::Run, ResettableTask, std::placeholders::_1)); World->ScheduleTask(static_cast<int>(tolua_tonumber(tolua_S, 2, 0)), std::bind(&cLuaWorldTask::Run, ResettableTask, std::placeholders::_1));

View File

@ -20,14 +20,14 @@ class cPlugin
{ {
public: public:
// tolua_end // tolua_end
/** Creates a new instance. /** Creates a new instance.
a_FolderName is the name of the folder (in the Plugins folder) from which the plugin is loaded. 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. */ The plugin's name defaults to the folder name. */
cPlugin(const AString & a_FolderName); cPlugin(const AString & a_FolderName);
virtual ~cPlugin(); virtual ~cPlugin();
/** Called as the last call into the plugin before it is unloaded. */ /** Called as the last call into the plugin before it is unloaded. */
virtual void OnDisable(void) {} virtual void OnDisable(void) {}
@ -109,22 +109,22 @@ public:
virtual bool OnWeatherChanging (cWorld & a_World, eWeather & a_NewWeather) = 0; virtual bool OnWeatherChanging (cWorld & a_World, eWeather & a_NewWeather) = 0;
virtual bool OnWorldStarted (cWorld & a_World) = 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; 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. /** Handles the command split into a_Split, issued by player a_Player.
Command permissions have already been checked. Command permissions have already been checked.
Returns true if command handled successfully. */ Returns true if command handled successfully. */
virtual bool HandleCommand(const AStringVector & a_Split, cPlayer & a_Player, const AString & a_FullCommand) = 0; virtual bool HandleCommand(const AStringVector & a_Split, cPlayer & a_Player, const AString & a_FullCommand) = 0;
/** Handles the console command split into a_Split. /** Handles the console command split into a_Split.
Returns true if command handled successfully. Output is to be sent to the a_Output callback. */ 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; 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 */ /** All bound commands are to be removed, do any language-dependent cleanup here */
virtual void ClearCommands(void) {} virtual void ClearCommands(void) {}
/** All bound console commands are to be removed, do any language-dependent cleanup here */ /** All bound console commands are to be removed, do any language-dependent cleanup here */
virtual void ClearConsoleCommands(void) {} virtual void ClearConsoleCommands(void) {}
// tolua_begin // tolua_begin
const AString & GetName(void) const { return m_Name; } const AString & GetName(void) const { return m_Name; }
void SetName(const AString & a_Name) { m_Name = a_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); } bool IsLoaded(void) const { return (m_Status == cPluginManager::psLoaded); }
// tolua_end // tolua_end
// Needed for ManualBindings' tolua_ForEach<> // Needed for ManualBindings' tolua_ForEach<>
static const char * GetClassStatic(void) { return "cPlugin"; } static const char * GetClassStatic(void) { return "cPlugin"; }

View File

@ -105,13 +105,13 @@ bool cPluginLua::Load(void)
{ {
m_LuaState.Create(); m_LuaState.Create();
m_LuaState.RegisterAPILibs(); m_LuaState.RegisterAPILibs();
// Inject the identification global variables into the state: // Inject the identification global variables into the state:
lua_pushlightuserdata(m_LuaState, this); lua_pushlightuserdata(m_LuaState, this);
lua_setglobal(m_LuaState, LUA_PLUGIN_INSTANCE_VAR_NAME); lua_setglobal(m_LuaState, LUA_PLUGIN_INSTANCE_VAR_NAME);
lua_pushstring(m_LuaState, GetName().c_str()); lua_pushstring(m_LuaState, GetName().c_str());
lua_setglobal(m_LuaState, LUA_PLUGIN_NAME_VAR_NAME); lua_setglobal(m_LuaState, LUA_PLUGIN_NAME_VAR_NAME);
// Add the plugin's folder to the package.path and package.cpath variables (#693): // Add the plugin's folder to the package.path and package.cpath variables (#693):
m_LuaState.AddPackagePath("path", FILE_IO_PREFIX + GetLocalFolder() + "/?.lua"); m_LuaState.AddPackagePath("path", FILE_IO_PREFIX + GetLocalFolder() + "/?.lua");
#ifdef _WIN32 #ifdef _WIN32
@ -119,7 +119,7 @@ bool cPluginLua::Load(void)
#else #else
m_LuaState.AddPackagePath("cpath", FILE_IO_PREFIX + GetLocalFolder() + "/?.so"); m_LuaState.AddPackagePath("cpath", FILE_IO_PREFIX + GetLocalFolder() + "/?.so");
#endif #endif
tolua_pushusertype(m_LuaState, this, "cPluginLua"); tolua_pushusertype(m_LuaState, this, "cPluginLua");
lua_setglobal(m_LuaState, "g_Plugin"); lua_setglobal(m_LuaState, "g_Plugin");
} }
@ -145,7 +145,7 @@ bool cPluginLua::Load(void)
} }
} }
std::sort(LuaFiles.begin(), LuaFiles.end()); std::sort(LuaFiles.begin(), LuaFiles.end());
// Warn if there are no Lua files in the plugin folder: // Warn if there are no Lua files in the plugin folder:
if (LuaFiles.empty()) 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()); LOGWARNING("Command handler is registered in cPluginManager but not in cPlugin, wtf? Command \"%s\".", a_Split[0].c_str());
return false; return false;
} }
cCSLock Lock(m_CriticalSection); cCSLock Lock(m_CriticalSection);
bool res = false; bool res = false;
m_LuaState.Call(cmd->second, a_Split, &a_Player, a_FullCommand, cLuaState::Return, res); 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; return false;
} }
cCSLock Lock(m_CriticalSection); cCSLock Lock(m_CriticalSection);
bool res = false; bool res = false;
AString str; AString str;
@ -1967,13 +1967,13 @@ bool cPluginLua::CanAddOldStyleHook(int a_HookType)
m_LuaState.LogStackTrace(); m_LuaState.LogStackTrace();
return false; return false;
} }
// Check if the function is available // Check if the function is available
if (m_LuaState.HasFunction(FnName)) if (m_LuaState.HasFunction(FnName))
{ {
return true; 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.", 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 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_CHANGED: return "OnWeatherChanged";
case cPluginManager::HOOK_WEATHER_CHANGING: return "OnWeatherChanging"; case cPluginManager::HOOK_WEATHER_CHANGING: return "OnWeatherChanging";
case cPluginManager::HOOK_WORLD_TICK: return "OnWorldTick"; case cPluginManager::HOOK_WORLD_TICK: return "OnWorldTick";
case cPluginManager::HOOK_NUM_HOOKS: case cPluginManager::HOOK_NUM_HOOKS:
{ {
// Satisfy a warning that all enum values should be used in a switch // 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) 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? ASSERT(m_CriticalSection.IsLockedByCurrentThread()); // It probably has to be, how else would we have a LuaState?
// Check if the function reference is valid: // Check if the function reference is valid:
cLuaState::cRef * Ref = new cLuaState::cRef(m_LuaState, a_FnRefIdx); cLuaState::cRef * Ref = new cLuaState::cRef(m_LuaState, a_FnRefIdx);
if ((Ref == nullptr) || !Ref->IsValid()) if ((Ref == nullptr) || !Ref->IsValid())
@ -2073,7 +2073,7 @@ bool cPluginLua::AddHookRef(int a_HookType, int a_FnRefIdx)
Ref = nullptr; Ref = nullptr;
return false; return false;
} }
m_HookMap[a_HookType].push_back(Ref); m_HookMap[a_HookType].push_back(Ref);
return true; return true;
} }
@ -2090,7 +2090,7 @@ int cPluginLua::CallFunctionFromForeignState(
) )
{ {
cCSLock Lock(m_CriticalSection); cCSLock Lock(m_CriticalSection);
// Call the function: // Call the function:
int NumReturns = m_LuaState.CallFunctionWithForeignParams(a_FunctionName, a_ForeignState, a_ParamStart, a_ParamEnd); int NumReturns = m_LuaState.CallFunctionWithForeignParams(a_FunctionName, a_ForeignState, a_ParamStart, a_ParamEnd);
if (NumReturns < 0) 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 // The call has failed, an error has already been output to the log, so just silently bail out with the same error
return NumReturns; return NumReturns;
} }
// Copy all the return values: // Copy all the return values:
int Top = lua_gettop(m_LuaState); int Top = lua_gettop(m_LuaState);
int res = a_ForeignState.CopyStackFrom(m_LuaState, Top - NumReturns + 1, Top); int res = a_ForeignState.CopyStackFrom(m_LuaState, Top - NumReturns + 1, Top);
// Remove the return values off this stack: // Remove the return values off this stack:
if (NumReturns > 0) if (NumReturns > 0)
{ {
lua_pop(m_LuaState, NumReturns); lua_pop(m_LuaState, NumReturns);
} }
return res; 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) bool cPluginLua::CallbackWindowClosing(int a_FnRef, cWindow & a_Window, cPlayer & a_Player, bool a_CanRefuse)
{ {
ASSERT(a_FnRef != LUA_REFNIL); ASSERT(a_FnRef != LUA_REFNIL);
cCSLock Lock(m_CriticalSection); cCSLock Lock(m_CriticalSection);
bool res = false; bool res = false;
m_LuaState.Call(a_FnRef, &a_Window, &a_Player, a_CanRefuse, cLuaState::Return, res); 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) void cPluginLua::CallbackWindowSlotChanged(int a_FnRef, cWindow & a_Window, int a_SlotNum)
{ {
ASSERT(a_FnRef != LUA_REFNIL); ASSERT(a_FnRef != LUA_REFNIL);
cCSLock Lock(m_CriticalSection); cCSLock Lock(m_CriticalSection);
m_LuaState.Call(a_FnRef, &a_Window, a_SlotNum); m_LuaState.Call(a_FnRef, &a_Window, a_SlotNum);
} }

View File

@ -36,7 +36,7 @@ class cPluginLua :
public: public:
// tolua_end // tolua_end
/** A RAII-style mutex lock for accessing the internal LuaState. /** A RAII-style mutex lock for accessing the internal LuaState.
This will be the only way to retrieve the plugin's LuaState; This will be the only way to retrieve the plugin's LuaState;
therefore it directly supports accessing the LuaState of the locked plugin. therefore it directly supports accessing the LuaState of the locked plugin.
@ -54,10 +54,10 @@ public:
} }
cLuaState & operator ()(void) { return m_Plugin.m_LuaState; } cLuaState & operator ()(void) { return m_Plugin.m_LuaState; }
protected: protected:
cPluginLua & m_Plugin; cPluginLua & m_Plugin;
/** RAII lock for m_Plugin.m_CriticalSection */ /** RAII lock for m_Plugin.m_CriticalSection */
cCSLock m_Lock; cCSLock m_Lock;
} ; } ;
@ -92,8 +92,8 @@ public:
typedef SharedPtr<cResettable> cResettablePtr; typedef SharedPtr<cResettable> cResettablePtr;
typedef std::vector<cResettablePtr> cResettablePtrs; typedef std::vector<cResettablePtr> cResettablePtrs;
cPluginLua(const AString & a_PluginDirectory); cPluginLua(const AString & a_PluginDirectory);
~cPluginLua(); ~cPluginLua();
@ -169,18 +169,18 @@ public:
virtual bool OnWeatherChanging (cWorld & a_World, eWeather & a_NewWeather) override; virtual bool OnWeatherChanging (cWorld & a_World, eWeather & a_NewWeather) override;
virtual bool OnWorldStarted (cWorld & a_World) 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 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 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 bool HandleConsoleCommand(const AStringVector & a_Split, cCommandOutputCallback & a_Output, const AString & a_FullCommand) override;
virtual void ClearCommands(void) override; virtual void ClearCommands(void) override;
virtual void ClearConsoleCommands(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) */ /** Returns true if the plugin contains the function for the specified hook type, using the old-style registration (#121) */
bool CanAddOldStyleHook(int a_HookType); bool CanAddOldStyleHook(int a_HookType);
// cWebPlugin overrides // cWebPlugin overrides
virtual const AString GetWebTitle(void) const override {return GetName(); } virtual const AString GetWebTitle(void) const override {return GetName(); }
virtual AString HandleWebRequest(const HTTPRequest & a_Request) override; virtual AString HandleWebRequest(const HTTPRequest & a_Request) override;
@ -188,7 +188,7 @@ public:
/** Adds a new web tab to webadmin. /** Adds a new web tab to webadmin.
Displaying the tab calls the referenced function. */ Displaying the tab calls the referenced function. */
bool AddWebTab(const AString & a_Title, lua_State * a_LuaState, int a_FunctionReference); // Exported in ManualBindings.cpp 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. */ /** 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); void BindCommand(const AString & a_Command, int a_FnRef);
@ -198,25 +198,25 @@ public:
cLuaState & GetLuaState(void) { return m_LuaState; } cLuaState & GetLuaState(void) { return m_LuaState; }
cCriticalSection & GetCriticalSection(void) { return m_CriticalSection; } cCriticalSection & GetCriticalSection(void) { return m_CriticalSection; }
/** Removes a previously referenced object (luaL_unref()) */ /** Removes a previously referenced object (luaL_unref()) */
void Unreference(int a_LuaRef); void Unreference(int a_LuaRef);
/** Calls the plugin-specified "cLuaWindow closing" callback. Returns true only if the callback returned true */ /** 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); bool CallbackWindowClosing(int a_FnRef, cWindow & a_Window, cPlayer & a_Player, bool a_CanRefuse);
/** Calls the plugin-specified "cLuaWindow slot changed" callback. */ /** Calls the plugin-specified "cLuaWindow slot changed" callback. */
void CallbackWindowSlotChanged(int a_FnRef, cWindow & a_Window, int a_SlotNum); 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 */ /** 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); static const char * GetHookFnName(int a_HookType);
/** Adds a Lua function to be called for the specified hook. /** 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 The function has to be on the Lua stack at the specified index a_FnRefIdx
Returns true if the hook was added successfully. Returns true if the hook was added successfully.
*/ */
bool AddHookRef(int a_HookType, int a_FnRefIdx); bool AddHookRef(int a_HookType, int a_FnRefIdx);
/** Calls a function in this plugin's LuaState with parameters copied over from a_ForeignState. /** 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. The values that the function returns are placed onto a_ForeignState.
Returns the number of values returned, if successful, or negative number on failure. */ Returns the number of values returned, if successful, or negative number on failure. */
@ -226,7 +226,7 @@ public:
int a_ParamStart, int a_ParamStart,
int a_ParamEnd int a_ParamEnd
); );
/** Call a Lua function residing in the plugin. */ /** Call a Lua function residing in the plugin. */
template <typename FnT, typename... Args> template <typename FnT, typename... Args>
bool Call(FnT a_Fn, Args && ... a_Args) bool Call(FnT a_Fn, Args && ... a_Args)
@ -241,20 +241,20 @@ public:
protected: protected:
/** Maps command name into Lua function reference */ /** Maps command name into Lua function reference */
typedef std::map<AString, int> CommandMap; typedef std::map<AString, int> CommandMap;
/** Provides an array of Lua function references */ /** Provides an array of Lua function references */
typedef std::vector<cLuaState::cRef *> cLuaRefs; typedef std::vector<cLuaState::cRef *> cLuaRefs;
/** Maps hook types into arrays of Lua function references to call for each hook type */ /** Maps hook types into arrays of Lua function references to call for each hook type */
typedef std::map<int, cLuaRefs> cHookMap; typedef std::map<int, cLuaRefs> cHookMap;
/** The mutex protecting m_LuaState and each of the m_Resettables[] against multithreaded use. */ /** The mutex protecting m_LuaState and each of the m_Resettables[] against multithreaded use. */
cCriticalSection m_CriticalSection; cCriticalSection m_CriticalSection;
/** The plugin's Lua state. */ /** The plugin's Lua state. */
cLuaState m_LuaState; cLuaState m_LuaState;
/** Objects that need notification when the plugin is about to be unloaded. */ /** Objects that need notification when the plugin is about to be unloaded. */
cResettablePtrs m_Resettables; cResettablePtrs m_Resettables;
@ -263,10 +263,10 @@ protected:
/** Console commands that the plugin has registered. */ /** Console commands that the plugin has registered. */
CommandMap m_ConsoleCommands; CommandMap m_ConsoleCommands;
/** Hooks that the plugin has registered. */ /** Hooks that the plugin has registered. */
cHookMap m_HookMap; cHookMap m_HookMap;
/** Releases all Lua references, notifies and removes all m_Resettables[] and closes the m_LuaState. */ /** Releases all Lua references, notifies and removes all m_Resettables[] and closes the m_LuaState. */
void Close(void); void Close(void);

View File

@ -317,21 +317,21 @@ bool cPluginManager::CallHookChat(cPlayer & a_Player, AString & a_Message)
// The command has executed successfully // The command has executed successfully
return true; return true;
} }
case crBlocked: case crBlocked:
{ {
// The command was blocked by a plugin using HOOK_EXECUTE_COMMAND // The command was blocked by a plugin using HOOK_EXECUTE_COMMAND
// The plugin has most likely sent a message to the player already // The plugin has most likely sent a message to the player already
return true; return true;
} }
case crError: case crError:
{ {
// An error in the plugin has prevented the command from executing. Report the error to the player: // 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())); a_Player.SendMessageFailure(Printf("Something went wrong while executing command \"%s\"", a_Message.c_str()));
return true; return true;
} }
case crNoPermission: case crNoPermission:
{ {
// The player is not allowed to execute this command // The player is not allowed to execute this command

View File

@ -143,10 +143,10 @@ public:
HOOK_WORLD_TICK, HOOK_WORLD_TICK,
// tolua_end // tolua_end
// Note that if a hook type is added, it may need processing in cPlugin::CanAddHook() descendants, // Note that if a hook type is added, it may need processing in cPlugin::CanAddHook() descendants,
// and it definitely needs adding in cPluginLua::GetHookFnName() ! // 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 // Keep these two as the last items, they are used for validity checking and get their values automagically
HOOK_NUM_HOOKS, HOOK_NUM_HOOKS,
HOOK_MAX = HOOK_NUM_HOOKS - 1, HOOK_MAX = HOOK_NUM_HOOKS - 1,
@ -157,22 +157,22 @@ public:
{ {
public: public:
virtual ~cCommandEnumCallback() {} virtual ~cCommandEnumCallback() {}
/** Called for each command; return true to abort enumeration /** Called for each command; return true to abort enumeration
For console commands, a_Permission is not used (set to empty string) 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; 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 */ /** The interface used for enumerating and extern-calling plugins */
typedef cItemCallback<cPlugin> cPluginCallback; typedef cItemCallback<cPlugin> cPluginCallback;
typedef std::list<cPlugin *> PluginList; typedef std::list<cPlugin *> PluginList;
/** Called each tick, calls the plugins' OnTick hook, as well as processes plugin events (addition, removal) */ /** Called each tick, calls the plugins' OnTick hook, as well as processes plugin events (addition, removal) */
void Tick(float a_Dt); void Tick(float a_Dt);
/** Returns the instance of the Plugin Manager (there is only ever one) */ /** Returns the instance of the Plugin Manager (there is only ever one) */
static cPluginManager * Get(void); // tolua_export 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(). */ /** Schedules a reload of the plugins to happen within the next call to Tick(). */
void ReloadPlugins(); // tolua_export void ReloadPlugins(); // tolua_export
/** Adds the plugin to the list of plugins called for the specified hook type. /** 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). */ 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); void AddHook(cPlugin * a_Plugin, int a_HookType);
@ -192,7 +192,7 @@ public:
/** Returns the number of plugins that are psLoaded. */ /** Returns the number of plugins that are psLoaded. */
size_t GetNumLoadedPlugins(void) const; // tolua_export 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 // 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 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); 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 CallHookWeatherChanging (cWorld & a_World, eWeather & a_NewWeather);
bool CallHookWorldStarted (cWorld & a_World); bool CallHookWorldStarted (cWorld & a_World);
bool CallHookWorldTick (cWorld & a_World, std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec); 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(). /** 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. */ Note that this function returns before the plugin is unloaded, to avoid deadlocks. */
void UnloadPlugin(const AString & a_PluginFolder); // tolua_export void UnloadPlugin(const AString & a_PluginFolder); // tolua_export
@ -271,10 +271,10 @@ public:
/** Removes all hooks the specified plugin has registered */ /** Removes all hooks the specified plugin has registered */
void RemoveHooks(cPlugin * a_Plugin); void RemoveHooks(cPlugin * a_Plugin);
/** Removes the plugin of the specified name from the internal structures and deletes its object. */ /** Removes the plugin of the specified name from the internal structures and deletes its object. */
void RemovePlugin(const AString & a_PluginName); void RemovePlugin(const AString & a_PluginName);
/** Removes all command bindings that the specified plugin has made */ /** Removes all command bindings that the specified plugin has made */
void RemovePluginCommands(cPlugin * a_Plugin); 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. */ /** 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 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 */ /** Calls a_Callback for each bound command, returns true if all commands were enumerated */
bool ForEachCommand(cCommandEnumCallback & a_Callback); // Exported in ManualBindings.cpp bool ForEachCommand(cCommandEnumCallback & a_Callback); // Exported in ManualBindings.cpp
/** Returns true if the command is in the command map */ /** Returns true if the command is in the command map */
bool IsCommandBound(const AString & a_Command); // tolua_export bool IsCommandBound(const AString & a_Command); // tolua_export
/** Returns the permission needed for the specified command; empty string if command not found */ /** Returns the permission needed for the specified command; empty string if command not found */
AString GetCommandPermission(const AString & a_Command); // tolua_export 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. */ /** 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 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. */ /** 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 CommandResult ForceExecuteCommand(cPlayer & a_Player, const AString & a_Command); // tolua_export
/** Removes all console command bindings that the specified plugin has made */ /** Removes all console command bindings that the specified plugin has made */
void RemovePluginConsoleCommands(cPlugin * a_Plugin); void RemovePluginConsoleCommands(cPlugin * a_Plugin);
/** Binds a console command to the specified plugin. Returns true if successful, false if command already bound. */ /** 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 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 */ /** Calls a_Callback for each bound console command, returns true if all commands were enumerated */
bool ForEachConsoleCommand(cCommandEnumCallback & a_Callback); // Exported in ManualBindings.cpp bool ForEachConsoleCommand(cCommandEnumCallback & a_Callback); // Exported in ManualBindings.cpp
/** Returns true if the console command is in the command map */ /** Returns true if the console command is in the command map */
bool IsConsoleCommandBound(const AString & a_Command); // tolua_export bool IsConsoleCommandBound(const AString & a_Command); // tolua_export
/** Executes the command split into a_Split, as if it was given on the console. /** 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 Returns true if executed. Output is sent to the a_Output callback
Exported in ManualBindings.cpp with a different signature. */ Exported in ManualBindings.cpp with a different signature. */
bool ExecuteConsoleCommand(const AStringVector & a_Split, cCommandOutputCallback & a_Output, const AString & a_Command); 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. /** 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. 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); void TabCompleteCommand(const AString & a_Text, AStringVector & a_Results, cPlayer * a_Player);
/** Returns true if the specified hook type is within the allowed range */ /** Returns true if the specified hook type is within the allowed range */
static bool IsValidHookType(int a_HookType); static bool IsValidHookType(int a_HookType);
/** Calls the specified callback with the plugin object of the specified plugin. /** 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. */ Returns false if plugin not found, otherwise returns the value that the callback has returned. */
bool DoWithPlugin(const AString & a_PluginName, cPluginCallback & a_Callback); bool DoWithPlugin(const AString & a_PluginName, cPluginCallback & a_Callback);
@ -331,14 +331,14 @@ public:
/** Calls the specified callback for each plugin in m_Plugins. /** 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. */ Returns true if all plugins have been reported, false if the callback has aborted the enumeration by returning true. */
bool ForEachPlugin(cPluginCallback & a_Callback); bool ForEachPlugin(cPluginCallback & a_Callback);
/** Returns the path where individual plugins' folders are expected. /** Returns the path where individual plugins' folders are expected.
The path doesn't end in a slash. */ The path doesn't end in a slash. */
static AString GetPluginsPath(void) { return FILE_IO_PREFIX + AString("Plugins"); } // tolua_export static AString GetPluginsPath(void) { return FILE_IO_PREFIX + AString("Plugins"); } // tolua_export
private: private:
friend class cRoot; friend class cRoot;
class cCommandReg class cCommandReg
{ {
public: public:
@ -346,7 +346,7 @@ private:
AString m_Permission; // Not used for console commands AString m_Permission; // Not used for console commands
AString m_HelpString; AString m_HelpString;
} ; } ;
typedef std::map<int, cPluginManager::PluginList> HookMap; typedef std::map<int, cPluginManager::PluginList> HookMap;
typedef std::map<AString, cCommandReg> CommandMap; typedef std::map<AString, cCommandReg> CommandMap;

View File

@ -40,7 +40,7 @@ public:
/** Returns the title of the plugin, as it should be presented in the webadmin's pages tree. */ /** Returns the title of the plugin, as it should be presented in the webadmin's pages tree. */
virtual const AString GetWebTitle(void) const = 0; virtual const AString GetWebTitle(void) const = 0;
/** Sanitizes the input string, replacing spaces with underscores. */ /** Sanitizes the input string, replacing spaces with underscores. */
static AString SafeString(const AString & a_String); static AString SafeString(const AString & a_String);

View File

@ -42,7 +42,7 @@ static struct
{biExtremeHillsEdge, "ExtremeHillsEdge"}, {biExtremeHillsEdge, "ExtremeHillsEdge"},
{biJungle, "Jungle"}, {biJungle, "Jungle"},
{biJungleHills, "JungleHills"}, {biJungleHills, "JungleHills"},
// Release 1.7 biomes: // Release 1.7 biomes:
{biJungleEdge, "JungleEdge"}, {biJungleEdge, "JungleEdge"},
{biDeepOcean, "DeepOcean"}, {biDeepOcean, "DeepOcean"},
@ -61,7 +61,7 @@ static struct
{biMesa, "Mesa"}, {biMesa, "Mesa"},
{biMesaPlateauF, "MesaPlateauF"}, {biMesaPlateauF, "MesaPlateauF"},
{biMesaPlateau, "MesaPlateau"}, {biMesaPlateau, "MesaPlateau"},
// Release 1.7 variants: // Release 1.7 variants:
{biSunflowerPlains, "SunflowerPlains"}, {biSunflowerPlains, "SunflowerPlains"},
{biDesertM, "DesertM"}, {biDesertM, "DesertM"},
@ -107,7 +107,7 @@ EMCSBiome StringToBiome(const AString & a_BiomeString)
// It was an invalid number // It was an invalid number
return biInvalidBiome; return biInvalidBiome;
} }
for (size_t i = 0; i < ARRAYCOUNT(g_BiomeMap); i++) for (size_t i = 0; i < ARRAYCOUNT(g_BiomeMap); i++)
{ {
if (NoCaseCompare(g_BiomeMap[i].m_String, a_BiomeString) == 0) if (NoCaseCompare(g_BiomeMap[i].m_String, a_BiomeString) == 0)
@ -239,7 +239,7 @@ int GetSnowStartHeight(EMCSBiome a_Biome)
// Always snow // Always snow
return 0; return 0;
} }
case biExtremeHills: case biExtremeHills:
case biExtremeHillsM: case biExtremeHillsM:
case biExtremeHillsPlus: case biExtremeHillsPlus:
@ -338,7 +338,7 @@ int GetSnowStartHeight(EMCSBiome a_Biome)
// These biomes don't actualy have any downfall. // These biomes don't actualy have any downfall.
return 1000; return 1000;
} }
case biNether: case biNether:
case biEnd: case biEnd:
{ {

View File

@ -49,7 +49,7 @@ enum EMCSBiome
biExtremeHillsEdge = 20, biExtremeHillsEdge = 20,
biJungle = 21, biJungle = 21,
biJungleHills = 22, biJungleHills = 22,
// Release 1.7 biomes: // Release 1.7 biomes:
biJungleEdge = 23, biJungleEdge = 23,
biDeepOcean = 24, biDeepOcean = 24,
@ -68,14 +68,14 @@ enum EMCSBiome
biMesa = 37, biMesa = 37,
biMesaPlateauF = 38, biMesaPlateauF = 38,
biMesaPlateau = 39, biMesaPlateau = 39,
// Automatically capture the maximum consecutive biome value into biMaxBiome: // Automatically capture the maximum consecutive biome value into biMaxBiome:
biNumBiomes, // True number of biomes, since they are zero-based biNumBiomes, // True number of biomes, since they are zero-based
biMaxBiome = biNumBiomes - 1, // The maximum biome value biMaxBiome = biNumBiomes - 1, // The maximum biome value
// Add this number to the biomes to get the variant // Add this number to the biomes to get the variant
biVariant = 128, biVariant = 128,
// Release 1.7 biome variants: // Release 1.7 biome variants:
biFirstVariantBiome = 129, biFirstVariantBiome = 129,
biSunflowerPlains = 129, biSunflowerPlains = 129,

View File

@ -146,7 +146,7 @@ void MergeCombinatorLake(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE
} }
return; return;
} }
// Water and lava are never overwritten // Water and lava are never overwritten
switch (a_DstType) switch (a_DstType)
{ {
@ -158,7 +158,7 @@ void MergeCombinatorLake(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE
return; return;
} }
} }
// Water and lava always overwrite // Water and lava always overwrite
switch (a_SrcType) switch (a_SrcType)
{ {
@ -175,7 +175,7 @@ void MergeCombinatorLake(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE
return; return;
} }
} }
if (a_SrcType == E_BLOCK_STONE) if (a_SrcType == E_BLOCK_STONE)
{ {
switch (a_DstType) switch (a_DstType)
@ -342,7 +342,7 @@ void cBlockArea::Create(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes)
{ {
LOGWARNING("Creating a cBlockArea with height larger than world height (%d). Continuing, but the area may misbehave.", a_SizeY); LOGWARNING("Creating a cBlockArea with height larger than world height (%d). Continuing, but the area may misbehave.", a_SizeY);
} }
Clear(); Clear();
int BlockCount = a_SizeX * a_SizeY * a_SizeZ; int BlockCount = a_SizeX * a_SizeY * a_SizeZ;
if ((a_DataTypes & baTypes) != 0) if ((a_DataTypes & baTypes) != 0)
@ -445,12 +445,12 @@ bool cBlockArea::Read(cForEachChunkProvider * a_ForEachChunkProvider, int a_MinB
{ {
std::swap(a_MinBlockZ, a_MaxBlockZ); std::swap(a_MinBlockZ, a_MaxBlockZ);
} }
// Include the Max coords: // Include the Max coords:
a_MaxBlockX += 1; a_MaxBlockX += 1;
a_MaxBlockY += 1; a_MaxBlockY += 1;
a_MaxBlockZ += 1; a_MaxBlockZ += 1;
// Check coords validity: // Check coords validity:
if (a_MinBlockY < 0) if (a_MinBlockY < 0)
{ {
@ -480,7 +480,7 @@ bool cBlockArea::Read(cForEachChunkProvider * a_ForEachChunkProvider, int a_MinB
); );
a_MaxBlockY = cChunkDef::Height; a_MaxBlockY = cChunkDef::Height;
} }
// Allocate the needed memory: // Allocate the needed memory:
Clear(); Clear();
if (!SetSize(a_MaxBlockX - a_MinBlockX, a_MaxBlockY - a_MinBlockY, a_MaxBlockZ - a_MinBlockZ, a_DataTypes)) if (!SetSize(a_MaxBlockX - a_MinBlockX, a_MaxBlockY - a_MinBlockY, a_MaxBlockZ - a_MinBlockZ, a_DataTypes))
@ -489,20 +489,20 @@ bool cBlockArea::Read(cForEachChunkProvider * a_ForEachChunkProvider, int a_MinB
} }
m_Origin.Set(a_MinBlockX, a_MinBlockY, a_MinBlockZ); m_Origin.Set(a_MinBlockX, a_MinBlockY, a_MinBlockZ);
cChunkReader Reader(*this); cChunkReader Reader(*this);
// Convert block coords to chunks coords: // Convert block coords to chunks coords:
int MinChunkX, MaxChunkX; int MinChunkX, MaxChunkX;
int MinChunkZ, MaxChunkZ; int MinChunkZ, MaxChunkZ;
cChunkDef::AbsoluteToRelative(a_MinBlockX, a_MinBlockY, a_MinBlockZ, MinChunkX, MinChunkZ); cChunkDef::AbsoluteToRelative(a_MinBlockX, a_MinBlockY, a_MinBlockZ, MinChunkX, MinChunkZ);
cChunkDef::AbsoluteToRelative(a_MaxBlockX, a_MaxBlockY, a_MaxBlockZ, MaxChunkX, MaxChunkZ); cChunkDef::AbsoluteToRelative(a_MaxBlockX, a_MaxBlockY, a_MaxBlockZ, MaxChunkX, MaxChunkZ);
// Query block data: // Query block data:
if (!a_ForEachChunkProvider->ForEachChunkInRect(MinChunkX, MaxChunkX, MinChunkZ, MaxChunkZ, Reader)) if (!a_ForEachChunkProvider->ForEachChunkInRect(MinChunkX, MaxChunkX, MinChunkZ, MaxChunkZ, Reader))
{ {
Clear(); Clear();
return false; return false;
} }
return true; return true;
} }
@ -584,7 +584,7 @@ void cBlockArea::CopyTo(cBlockArea & a_Into) const
LOGWARNING("Trying to copy a cBlockArea into self, ignoring."); LOGWARNING("Trying to copy a cBlockArea into self, ignoring.");
return; return;
} }
a_Into.Clear(); a_Into.Clear();
a_Into.SetSize(m_Size.x, m_Size.y, m_Size.z, GetDataTypes()); a_Into.SetSize(m_Size.x, m_Size.y, m_Size.z, GetDataTypes());
a_Into.m_Origin = m_Origin; a_Into.m_Origin = m_Origin;
@ -684,7 +684,7 @@ void cBlockArea::Crop(int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY
); );
return; return;
} }
if (HasBlockTypes()) if (HasBlockTypes())
{ {
CropBlockTypes(a_AddMinX, a_SubMaxX, a_AddMinY, a_SubMaxY, a_AddMinZ, a_SubMaxZ); CropBlockTypes(a_AddMinX, a_SubMaxX, a_AddMinY, a_SubMaxY, a_AddMinZ, a_SubMaxZ);
@ -744,9 +744,9 @@ void cBlockArea::Merge(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_R
const NIBBLETYPE * SrcMetas = a_Src.GetBlockMetas(); const NIBBLETYPE * SrcMetas = a_Src.GetBlockMetas();
NIBBLETYPE * DstMetas = m_BlockMetas; NIBBLETYPE * DstMetas = m_BlockMetas;
bool IsDummyMetas = ((SrcMetas == nullptr) || (DstMetas == nullptr)); bool IsDummyMetas = ((SrcMetas == nullptr) || (DstMetas == nullptr));
if (IsDummyMetas) if (IsDummyMetas)
{ {
MergeByStrategy<false>(a_Src, a_RelX, a_RelY, a_RelZ, a_Strategy, SrcMetas, DstMetas); MergeByStrategy<false>(a_Src, a_RelX, a_RelY, a_RelZ, a_Strategy, SrcMetas, DstMetas);
@ -779,7 +779,7 @@ void cBlockArea::Fill(int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_Block
); );
a_DataTypes = a_DataTypes & GetDataTypes(); a_DataTypes = a_DataTypes & GetDataTypes();
} }
size_t BlockCount = GetBlockCount(); size_t BlockCount = GetBlockCount();
if ((a_DataTypes & baTypes) != 0) if ((a_DataTypes & baTypes) != 0)
{ {
@ -827,7 +827,7 @@ void cBlockArea::FillRelCuboid(int a_MinRelX, int a_MaxRelX, int a_MinRelY, int
); );
a_DataTypes = a_DataTypes & GetDataTypes(); a_DataTypes = a_DataTypes & GetDataTypes();
} }
if ((a_DataTypes & baTypes) != 0) if ((a_DataTypes & baTypes) != 0)
{ {
for (int y = a_MinRelY; y <= a_MaxRelY; y++) for (int z = a_MinRelZ; z <= a_MaxRelZ; z++) for (int x = a_MinRelX; x <= a_MaxRelX; x++) for (int y = a_MinRelY; y <= a_MaxRelY; y++) for (int z = a_MinRelZ; z <= a_MaxRelZ; z++) for (int x = a_MinRelX; x <= a_MaxRelX; x++)
@ -983,7 +983,7 @@ void cBlockArea::RelLine(int a_RelX1, int a_RelY1, int a_RelZ1, int a_RelX2, int
a_RelY1 += sy; a_RelY1 += sy;
yd -= dz; yd -= dz;
} }
// move along z // move along z
a_RelZ1 += sz; a_RelZ1 += sz;
xd += dx; xd += dx;
@ -1019,14 +1019,14 @@ void cBlockArea::RotateCCW(void)
LOGWARNING("cBlockArea: Cannot rotate blockmeta without blocktypes!"); LOGWARNING("cBlockArea: Cannot rotate blockmeta without blocktypes!");
return; return;
} }
if (!HasBlockMetas()) if (!HasBlockMetas())
{ {
// There are no blockmetas to rotate, just use the NoMeta function // There are no blockmetas to rotate, just use the NoMeta function
RotateCCWNoMeta(); RotateCCWNoMeta();
return; return;
} }
// We are guaranteed that both blocktypes and blockmetas exist; rotate both at the same time: // We are guaranteed that both blocktypes and blockmetas exist; rotate both at the same time:
BLOCKTYPE * NewTypes = new BLOCKTYPE[GetBlockCount()]; BLOCKTYPE * NewTypes = new BLOCKTYPE[GetBlockCount()];
NIBBLETYPE * NewMetas = new NIBBLETYPE[GetBlockCount()]; NIBBLETYPE * NewMetas = new NIBBLETYPE[GetBlockCount()];
@ -1071,7 +1071,7 @@ void cBlockArea::RotateCW(void)
RotateCWNoMeta(); RotateCWNoMeta();
return; return;
} }
// We are guaranteed that both blocktypes and blockmetas exist; rotate both at the same time: // We are guaranteed that both blocktypes and blockmetas exist; rotate both at the same time:
BLOCKTYPE * NewTypes = new BLOCKTYPE[GetBlockCount()]; BLOCKTYPE * NewTypes = new BLOCKTYPE[GetBlockCount()];
NIBBLETYPE * NewMetas = new NIBBLETYPE[GetBlockCount()]; NIBBLETYPE * NewMetas = new NIBBLETYPE[GetBlockCount()];
@ -1109,7 +1109,7 @@ void cBlockArea::MirrorXY(void)
LOGWARNING("cBlockArea: Cannot mirror meta without blocktypes!"); LOGWARNING("cBlockArea: Cannot mirror meta without blocktypes!");
return; return;
} }
if (!HasBlockMetas()) if (!HasBlockMetas())
{ {
// There are no blockmetas to mirror, just use the NoMeta function // There are no blockmetas to mirror, just use the NoMeta function
@ -1329,7 +1329,7 @@ void cBlockArea::MirrorXYNoMeta(void)
} // for z } // for z
} // for y } // for y
} // if (HasBlockTypes) } // if (HasBlockTypes)
if (HasBlockMetas()) if (HasBlockMetas())
{ {
for (int y = 0; y < m_Size.y; y++) for (int y = 0; y < m_Size.y; y++)
@ -1366,7 +1366,7 @@ void cBlockArea::MirrorXZNoMeta(void)
} // for z } // for z
} // for y } // for y
} // if (HasBlockTypes) } // if (HasBlockTypes)
if (HasBlockMetas()) if (HasBlockMetas())
{ {
for (int y = 0; y < HalfY; y++) for (int y = 0; y < HalfY; y++)
@ -1403,7 +1403,7 @@ void cBlockArea::MirrorYZNoMeta(void)
} // for z } // for z
} // for y } // for y
} // if (HasBlockTypes) } // if (HasBlockTypes)
if (HasBlockMetas()) if (HasBlockMetas())
{ {
for (int y = 0; y < m_Size.y; y++) for (int y = 0; y < m_Size.y; y++)
@ -1632,7 +1632,7 @@ void cBlockArea::GetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTY
{ {
a_BlockType = m_BlockTypes[idx]; a_BlockType = m_BlockTypes[idx];
} }
if (m_BlockMetas == nullptr) if (m_BlockMetas == nullptr)
{ {
LOGWARNING("cBlockArea: BlockMetas have not been read!"); LOGWARNING("cBlockArea: BlockMetas have not been read!");
@ -1834,7 +1834,7 @@ int cBlockArea::GetDataTypes(void) const
bool cBlockArea::SetSize(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes) bool cBlockArea::SetSize(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes)
{ {
ASSERT(m_BlockTypes == nullptr); // Has been cleared ASSERT(m_BlockTypes == nullptr); // Has been cleared
if (a_DataTypes & baTypes) if (a_DataTypes & baTypes)
{ {
m_BlockTypes = new BLOCKTYPE[a_SizeX * a_SizeY * a_SizeZ]; m_BlockTypes = new BLOCKTYPE[a_SizeX * a_SizeY * a_SizeZ];
@ -1895,7 +1895,7 @@ int cBlockArea::MakeIndex(int a_RelX, int a_RelY, int a_RelZ) const
ASSERT(a_RelY < m_Size.y); ASSERT(a_RelY < m_Size.y);
ASSERT(a_RelZ >= 0); ASSERT(a_RelZ >= 0);
ASSERT(a_RelZ < m_Size.z); ASSERT(a_RelZ < m_Size.z);
return a_RelX + a_RelZ * m_Size.x + a_RelY * m_Size.x * m_Size.z; return a_RelX + a_RelZ * m_Size.x + a_RelY * m_Size.x * m_Size.z;
} }
@ -1969,7 +1969,7 @@ void cBlockArea::cChunkReader::CopyNibbles(NIBBLETYPE * a_AreaDst, const NIBBLET
{ {
int SizeY = m_Area.m_Size.y; int SizeY = m_Area.m_Size.y;
int MinY = m_Origin.y; int MinY = m_Origin.y;
// SizeX, SizeZ are the dmensions of the block data to copy from the current chunk (size of the geometric union) // SizeX, SizeZ are the dmensions of the block data to copy from the current chunk (size of the geometric union)
// OffX, OffZ are the offsets of the current chunk data from the area origin // OffX, OffZ are the offsets of the current chunk data from the area origin
// BaseX, BaseZ are the offsets of the area data within the current chunk from the chunk borders // BaseX, BaseZ are the offsets of the area data within the current chunk from the chunk borders
@ -2085,7 +2085,7 @@ void cBlockArea::cChunkReader::ChunkData(const cChunkData & a_BlockBuffer)
{ {
SizeZ -= (m_CurrentChunkZ + 1) * cChunkDef::Width - (m_Origin.z + m_Area.m_Size.z); SizeZ -= (m_CurrentChunkZ + 1) * cChunkDef::Width - (m_Origin.z + m_Area.m_Size.z);
} }
// Copy the blocktypes: // Copy the blocktypes:
if (m_Area.m_BlockTypes != nullptr) if (m_Area.m_BlockTypes != nullptr)
{ {
@ -2323,7 +2323,7 @@ void cBlockArea::MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_Rel
LOGWARNING("%s: cannot merge because one of the areas doesn't have blocktypes.", __FUNCTION__); LOGWARNING("%s: cannot merge because one of the areas doesn't have blocktypes.", __FUNCTION__);
return; return;
} }
// Dst is *this, Src is a_Src // Dst is *this, Src is a_Src
int SrcOffX = std::max(0, -a_RelX); // Offset in Src where to start reading int SrcOffX = std::max(0, -a_RelX); // Offset in Src where to start reading
int DstOffX = std::max(0, a_RelX); // Offset in Dst where to start writing int DstOffX = std::max(0, a_RelX); // Offset in Dst where to start writing
@ -2336,7 +2336,7 @@ void cBlockArea::MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_Rel
int SrcOffZ = std::max(0, -a_RelZ); // Offset in Src where to start reading int SrcOffZ = std::max(0, -a_RelZ); // Offset in Src where to start reading
int DstOffZ = std::max(0, a_RelZ); // Offset in Dst where to start writing int DstOffZ = std::max(0, a_RelZ); // Offset in Dst where to start writing
int SizeZ = std::min(a_Src.GetSizeZ() - SrcOffZ, GetSizeZ() - DstOffZ); // How many blocks to copy int SizeZ = std::min(a_Src.GetSizeZ() - SrcOffZ, GetSizeZ() - DstOffZ); // How many blocks to copy
switch (a_Strategy) switch (a_Strategy)
{ {
case cBlockArea::msOverwrite: case cBlockArea::msOverwrite:
@ -2352,7 +2352,7 @@ void cBlockArea::MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_Rel
); );
return; return;
} // case msOverwrite } // case msOverwrite
case cBlockArea::msFillAir: case cBlockArea::msFillAir:
{ {
InternalMergeBlocks<MetasValid, MergeCombinatorFillAir<MetasValid> >( InternalMergeBlocks<MetasValid, MergeCombinatorFillAir<MetasValid> >(
@ -2366,7 +2366,7 @@ void cBlockArea::MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_Rel
); );
return; return;
} // case msFillAir } // case msFillAir
case cBlockArea::msImprint: case cBlockArea::msImprint:
{ {
InternalMergeBlocks<MetasValid, MergeCombinatorImprint<MetasValid> >( InternalMergeBlocks<MetasValid, MergeCombinatorImprint<MetasValid> >(
@ -2380,7 +2380,7 @@ void cBlockArea::MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_Rel
); );
return; return;
} // case msImprint } // case msImprint
case cBlockArea::msLake: case cBlockArea::msLake:
{ {
InternalMergeBlocks<MetasValid, MergeCombinatorLake<MetasValid> >( InternalMergeBlocks<MetasValid, MergeCombinatorLake<MetasValid> >(
@ -2394,7 +2394,7 @@ void cBlockArea::MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_Rel
); );
return; return;
} // case msLake } // case msLake
case cBlockArea::msSpongePrint: case cBlockArea::msSpongePrint:
{ {
InternalMergeBlocks<MetasValid, MergeCombinatorSpongePrint<MetasValid> >( InternalMergeBlocks<MetasValid, MergeCombinatorSpongePrint<MetasValid> >(
@ -2422,7 +2422,7 @@ void cBlockArea::MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_Rel
); );
return; return;
} // case msDifference } // case msDifference
case cBlockArea::msSimpleCompare: case cBlockArea::msSimpleCompare:
{ {
InternalMergeBlocks<MetasValid, MergeCombinatorSimpleCompare<MetasValid> >( InternalMergeBlocks<MetasValid, MergeCombinatorSimpleCompare<MetasValid> >(
@ -2436,7 +2436,7 @@ void cBlockArea::MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_Rel
); );
return; return;
} // case msSimpleCompare } // case msSimpleCompare
case cBlockArea::msMask: case cBlockArea::msMask:
{ {
InternalMergeBlocks<MetasValid, MergeCombinatorMask<MetasValid> >( InternalMergeBlocks<MetasValid, MergeCombinatorMask<MetasValid> >(
@ -2451,7 +2451,7 @@ void cBlockArea::MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_Rel
return; return;
} // case msMask } // case msMask
} // switch (a_Strategy) } // switch (a_Strategy)
LOGWARNING("Unknown block area merge strategy: %d", a_Strategy); LOGWARNING("Unknown block area merge strategy: %d", a_Strategy);
ASSERT(!"Unknown block area merge strategy"); ASSERT(!"Unknown block area merge strategy");
return; return;

View File

@ -32,7 +32,7 @@ class cBlockArea
// tolua_end // tolua_end
DISALLOW_COPY_AND_ASSIGN(cBlockArea); DISALLOW_COPY_AND_ASSIGN(cBlockArea);
// tolua_begin // tolua_begin
public: public:
/** What data is to be queried (bit-mask) */ /** What data is to be queried (bit-mask) */
@ -43,7 +43,7 @@ public:
baLight = 4, baLight = 4,
baSkyLight = 8, baSkyLight = 8,
} ; } ;
/** The per-block strategy to use when merging another block area into this object. /** The per-block strategy to use when merging another block area into this object.
See the Merge function for the description of these */ See the Merge function for the description of these */
enum eMergeStrategy enum eMergeStrategy
@ -57,64 +57,64 @@ public:
msSimpleCompare, msSimpleCompare,
msMask, msMask,
} ; } ;
cBlockArea(void); cBlockArea(void);
~cBlockArea(); ~cBlockArea();
/** Clears the data stored to reclaim memory */ /** Clears the data stored to reclaim memory */
void Clear(void); void Clear(void);
/** Creates a new area of the specified size and contents. /** Creates a new area of the specified size and contents.
Origin is set to all zeroes. Origin is set to all zeroes.
BlockTypes are set to air, block metas to zero, blocklights to zero and skylights to full light. BlockTypes are set to air, block metas to zero, blocklights to zero and skylights to full light.
*/ */
void Create(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes = baTypes | baMetas); void Create(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes = baTypes | baMetas);
/** Creates a new area of the specified size and contents. /** Creates a new area of the specified size and contents.
Origin is set to all zeroes. Origin is set to all zeroes.
BlockTypes are set to air, block metas to zero, blocklights to zero and skylights to full light. BlockTypes are set to air, block metas to zero, blocklights to zero and skylights to full light.
*/ */
void Create(const Vector3i & a_Size, int a_DataTypes = baTypes | baMetas); void Create(const Vector3i & a_Size, int a_DataTypes = baTypes | baMetas);
/** Resets the origin. No other changes are made, contents are untouched. */ /** Resets the origin. No other changes are made, contents are untouched. */
void SetOrigin(int a_OriginX, int a_OriginY, int a_OriginZ); void SetOrigin(int a_OriginX, int a_OriginY, int a_OriginZ);
/** Resets the origin. No other changes are made, contents are untouched. */ /** Resets the origin. No other changes are made, contents are untouched. */
void SetOrigin(const Vector3i & a_Origin); void SetOrigin(const Vector3i & a_Origin);
/** Reads an area of blocks specified. Returns true if successful. All coords are inclusive. */ /** Reads an area of blocks specified. Returns true if successful. All coords are inclusive. */
bool Read(cForEachChunkProvider * a_ForEachChunkProvider, int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ, int a_DataTypes = baTypes | baMetas); bool Read(cForEachChunkProvider * a_ForEachChunkProvider, int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ, int a_DataTypes = baTypes | baMetas);
/** Reads an area of blocks specified. Returns true if successful. The bounds are included in the read area. */ /** Reads an area of blocks specified. Returns true if successful. The bounds are included in the read area. */
bool Read(cForEachChunkProvider * a_ForEachChunkProvider, const cCuboid & a_Bounds, int a_DataTypes = baTypes | baMetas); bool Read(cForEachChunkProvider * a_ForEachChunkProvider, const cCuboid & a_Bounds, int a_DataTypes = baTypes | baMetas);
/** Reads an area of blocks specified. Returns true if successful. The bounds are included in the read area. */ /** Reads an area of blocks specified. Returns true if successful. The bounds are included in the read area. */
bool Read(cForEachChunkProvider * a_ForEachChunkProvider, const Vector3i & a_Point1, const Vector3i & a_Point2, int a_DataTypes = baTypes | baMetas); bool Read(cForEachChunkProvider * a_ForEachChunkProvider, const Vector3i & a_Point1, const Vector3i & a_Point2, int a_DataTypes = baTypes | baMetas);
// TODO: Write() is not too good an interface: if it fails, there's no way to repeat only for the parts that didn't write // TODO: Write() is not too good an interface: if it fails, there's no way to repeat only for the parts that didn't write
// A better way may be to return a list of cBlockAreas for each part that didn't succeed writing, so that the caller may try again // A better way may be to return a list of cBlockAreas for each part that didn't succeed writing, so that the caller may try again
/** Writes the area back into cWorld at the coords specified. Returns true if successful in all chunks, false if only partially / not at all */ /** Writes the area back into cWorld at the coords specified. Returns true if successful in all chunks, false if only partially / not at all */
bool Write(cForEachChunkProvider * a_ForEachChunkProvider, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes = baTypes | baMetas); bool Write(cForEachChunkProvider * a_ForEachChunkProvider, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes = baTypes | baMetas);
/** Writes the area back into cWorld at the coords specified. Returns true if successful in all chunks, false if only partially / not at all */ /** Writes the area back into cWorld at the coords specified. Returns true if successful in all chunks, false if only partially / not at all */
bool Write(cForEachChunkProvider * a_ForEachChunkProvider, const Vector3i & a_MinCoords, int a_DataTypes = baTypes | baMetas); bool Write(cForEachChunkProvider * a_ForEachChunkProvider, const Vector3i & a_MinCoords, int a_DataTypes = baTypes | baMetas);
/** Copies this object's contents into the specified BlockArea. */ /** Copies this object's contents into the specified BlockArea. */
void CopyTo(cBlockArea & a_Into) const; void CopyTo(cBlockArea & a_Into) const;
/** Copies the contents from the specified BlockArea into this object. */ /** Copies the contents from the specified BlockArea into this object. */
void CopyFrom(const cBlockArea & a_From); void CopyFrom(const cBlockArea & a_From);
/** For testing purposes only, dumps the area into a file. */ /** For testing purposes only, dumps the area into a file. */
void DumpToRawFile(const AString & a_FileName); void DumpToRawFile(const AString & a_FileName);
/** Crops the internal contents by the specified amount of blocks from each border. */ /** Crops the internal contents by the specified amount of blocks from each border. */
void Crop(int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY, int a_AddMinZ, int a_SubMaxZ); void Crop(int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY, int a_AddMinZ, int a_SubMaxZ);
/** Expands the internal contents by the specified amount of blocks from each border */ /** Expands the internal contents by the specified amount of blocks from each border */
void Expand(int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ); void Expand(int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ);
/** Merges another block area into this one, using the specified block combinating strategy /** Merges another block area into this one, using the specified block combinating strategy
This function combines another BlockArea into the current object. This function combines another BlockArea into the current object.
The strategy parameter specifies how individual blocks are combined together, using the table below. The strategy parameter specifies how individual blocks are combined together, using the table below.
@ -126,7 +126,7 @@ public:
| A | air | air | A | A | | A | air | air | A | A |
| air | B | B | B | B | | air | B | B | B | B |
| A | B | B | A | B | | A | B | B | A | B |
So to sum up: So to sum up:
- msOverwrite completely overwrites all blocks with the Src's blocks - msOverwrite completely overwrites all blocks with the Src's blocks
- msFillAir overwrites only those blocks that were air - msFillAir overwrites only those blocks that were air
@ -148,7 +148,7 @@ public:
| mycelium | stone | stone | ... and mycelium | mycelium | stone | stone | ... and mycelium
| A | stone | A | ... but nothing else | A | stone | A | ... but nothing else
| A | * | A | Everything else is left as it is | A | * | A | Everything else is left as it is
msSpongePrint: msSpongePrint:
Used for most generators, it allows carving out air pockets, too, and uses the Sponge as the NOP block Used for most generators, it allows carving out air pockets, too, and uses the Sponge as the NOP block
| area block | | | area block | |
@ -156,7 +156,7 @@ public:
+----------+--------+--------+ +----------+--------+--------+
| A | sponge | A | Sponge is the NOP block | A | sponge | A | Sponge is the NOP block
| * | B | B | Everything else overwrites anything | * | B | B | Everything else overwrites anything
msDifference: msDifference:
Used to determine the differences between two areas. Only the differring blocks are preserved: Used to determine the differences between two areas. Only the differring blocks are preserved:
| area block | | | area block | |
@ -183,68 +183,68 @@ public:
*/ */
void Merge(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_RelZ, eMergeStrategy a_Strategy); void Merge(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_RelZ, eMergeStrategy a_Strategy);
/** Merges another block area into this one, using the specified block combinating strategy. /** Merges another block area into this one, using the specified block combinating strategy.
See Merge() above for details. */ See Merge() above for details. */
void Merge(const cBlockArea & a_Src, const Vector3i & a_RelMinCoords, eMergeStrategy a_Strategy); void Merge(const cBlockArea & a_Src, const Vector3i & a_RelMinCoords, eMergeStrategy a_Strategy);
/** Fills the entire block area with the specified data */ /** Fills the entire block area with the specified data */
void Fill(int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0, NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f); void Fill(int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0, NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f);
/** Fills a cuboid inside the block area with the specified data */ /** Fills a cuboid inside the block area with the specified data */
void FillRelCuboid(int a_MinRelX, int a_MaxRelX, int a_MinRelY, int a_MaxRelY, int a_MinRelZ, int a_MaxRelZ, void FillRelCuboid(int a_MinRelX, int a_MaxRelX, int a_MinRelY, int a_MaxRelY, int a_MinRelZ, int a_MaxRelZ,
int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0, int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0,
NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f
); );
/** Fills a cuboid inside the block area with the specified data. a_Cuboid must be sorted. */ /** Fills a cuboid inside the block area with the specified data. a_Cuboid must be sorted. */
void FillRelCuboid(const cCuboid & a_RelCuboid, void FillRelCuboid(const cCuboid & a_RelCuboid,
int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0, int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0,
NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f
); );
/** Draws a line from between two points with the specified data */ /** Draws a line from between two points with the specified data */
void RelLine(int a_RelX1, int a_RelY1, int a_RelZ1, int a_RelX2, int a_RelY2, int a_RelZ2, void RelLine(int a_RelX1, int a_RelY1, int a_RelZ1, int a_RelX2, int a_RelY2, int a_RelZ2,
int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0, int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0,
NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f
); );
/** Draws a line from between two points with the specified data */ /** Draws a line from between two points with the specified data */
void RelLine(const Vector3i & a_Point1, const Vector3i & a_Point2, void RelLine(const Vector3i & a_Point1, const Vector3i & a_Point2,
int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0, int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0,
NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f
); );
/** Rotates the entire area counter-clockwise around the Y axis */ /** Rotates the entire area counter-clockwise around the Y axis */
void RotateCCW(void); void RotateCCW(void);
/** Rotates the entire area clockwise around the Y axis */ /** Rotates the entire area clockwise around the Y axis */
void RotateCW(void); void RotateCW(void);
/** Mirrors the entire area around the XY plane */ /** Mirrors the entire area around the XY plane */
void MirrorXY(void); void MirrorXY(void);
/** Mirrors the entire area around the XZ plane */ /** Mirrors the entire area around the XZ plane */
void MirrorXZ(void); void MirrorXZ(void);
/** Mirrors the entire area around the YZ plane */ /** Mirrors the entire area around the YZ plane */
void MirrorYZ(void); void MirrorYZ(void);
/** Rotates the entire area counter-clockwise around the Y axis, doesn't use blockhandlers for block meta */ /** Rotates the entire area counter-clockwise around the Y axis, doesn't use blockhandlers for block meta */
void RotateCCWNoMeta(void); void RotateCCWNoMeta(void);
/** Rotates the entire area clockwise around the Y axis, doesn't use blockhandlers for block meta */ /** Rotates the entire area clockwise around the Y axis, doesn't use blockhandlers for block meta */
void RotateCWNoMeta(void); void RotateCWNoMeta(void);
/** Mirrors the entire area around the XY plane, doesn't use blockhandlers for block meta */ /** Mirrors the entire area around the XY plane, doesn't use blockhandlers for block meta */
void MirrorXYNoMeta(void); void MirrorXYNoMeta(void);
/** Mirrors the entire area around the XZ plane, doesn't use blockhandlers for block meta */ /** Mirrors the entire area around the XZ plane, doesn't use blockhandlers for block meta */
void MirrorXZNoMeta(void); void MirrorXZNoMeta(void);
/** Mirrors the entire area around the YZ plane, doesn't use blockhandlers for block meta */ /** Mirrors the entire area around the YZ plane, doesn't use blockhandlers for block meta */
void MirrorYZNoMeta(void); void MirrorYZNoMeta(void);
// Setters: // Setters:
void SetRelBlockType (int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType); void SetRelBlockType (int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType);
void SetBlockType (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType); void SetBlockType (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType);
@ -270,35 +270,35 @@ public:
void SetBlockTypeMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); void SetBlockTypeMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
void SetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); void SetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
// tolua_end // tolua_end
// These need manual exporting, tolua generates the binding as requiring 2 extra input params // These need manual exporting, tolua generates the binding as requiring 2 extra input params
void GetBlockTypeMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const; void GetBlockTypeMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const;
void GetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const; void GetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const;
// GetSize() is already exported manually to return 3 numbers, can't auto-export // GetSize() is already exported manually to return 3 numbers, can't auto-export
const Vector3i & GetSize(void) const { return m_Size; } const Vector3i & GetSize(void) const { return m_Size; }
// GetOrigin() is already exported manually to return 3 numbers, can't auto-export // GetOrigin() is already exported manually to return 3 numbers, can't auto-export
const Vector3i & GetOrigin(void) const { return m_Origin; } const Vector3i & GetOrigin(void) const { return m_Origin; }
// tolua_begin // tolua_begin
int GetSizeX(void) const { return m_Size.x; } int GetSizeX(void) const { return m_Size.x; }
int GetSizeY(void) const { return m_Size.y; } int GetSizeY(void) const { return m_Size.y; }
int GetSizeZ(void) const { return m_Size.z; } int GetSizeZ(void) const { return m_Size.z; }
/** Returns the volume of the area, as number of blocks */ /** Returns the volume of the area, as number of blocks */
int GetVolume(void) const { return m_Size.x * m_Size.y * m_Size.z; } int GetVolume(void) const { return m_Size.x * m_Size.y * m_Size.z; }
int GetOriginX(void) const { return m_Origin.x; } int GetOriginX(void) const { return m_Origin.x; }
int GetOriginY(void) const { return m_Origin.y; } int GetOriginY(void) const { return m_Origin.y; }
int GetOriginZ(void) const { return m_Origin.z; } int GetOriginZ(void) const { return m_Origin.z; }
/** Returns the datatypes that are stored in the object (bitmask of baXXX values) */ /** Returns the datatypes that are stored in the object (bitmask of baXXX values) */
int GetDataTypes(void) const; int GetDataTypes(void) const;
bool HasBlockTypes (void) const { return (m_BlockTypes != nullptr); } bool HasBlockTypes (void) const { return (m_BlockTypes != nullptr); }
bool HasBlockMetas (void) const { return (m_BlockMetas != nullptr); } bool HasBlockMetas (void) const { return (m_BlockMetas != nullptr); }
bool HasBlockLights (void) const { return (m_BlockLight != nullptr); } bool HasBlockLights (void) const { return (m_BlockLight != nullptr); }
@ -323,7 +323,7 @@ public:
If there are no non-ignored blocks within the area, or blocktypes are not present, the returned values are reverse-ranges (MinX <- m_RangeX, MaxX <- 0 etc.) If there are no non-ignored blocks within the area, or blocktypes are not present, the returned values are reverse-ranges (MinX <- m_RangeX, MaxX <- 0 etc.)
Exported to Lua in ManualBindings.cpp. */ Exported to Lua in ManualBindings.cpp. */
void GetNonAirCropRelCoords(int & a_MinRelX, int & a_MinRelY, int & a_MinRelZ, int & a_MaxRelX, int & a_MaxRelY, int & a_MaxRelZ, BLOCKTYPE a_IgnoreBlockType = E_BLOCK_AIR); void GetNonAirCropRelCoords(int & a_MinRelX, int & a_MinRelY, int & a_MinRelZ, int & a_MaxRelX, int & a_MaxRelY, int & a_MaxRelZ, BLOCKTYPE a_IgnoreBlockType = E_BLOCK_AIR);
// Clients can use these for faster access to all blocktypes. Be careful though! // Clients can use these for faster access to all blocktypes. Be careful though!
/** Returns the internal pointer to the block types */ /** Returns the internal pointer to the block types */
BLOCKTYPE * GetBlockTypes (void) const { return m_BlockTypes; } BLOCKTYPE * GetBlockTypes (void) const { return m_BlockTypes; }
@ -336,32 +336,32 @@ public:
protected: protected:
friend class cChunkDesc; friend class cChunkDesc;
friend class cSchematicFileSerializer; friend class cSchematicFileSerializer;
class cChunkReader : class cChunkReader :
public cChunkDataCallback public cChunkDataCallback
{ {
public: public:
cChunkReader(cBlockArea & a_Area); cChunkReader(cBlockArea & a_Area);
protected: protected:
cBlockArea & m_Area; cBlockArea & m_Area;
Vector3i m_Origin; Vector3i m_Origin;
int m_CurrentChunkX; int m_CurrentChunkX;
int m_CurrentChunkZ; int m_CurrentChunkZ;
void CopyNibbles(NIBBLETYPE * a_AreaDst, const NIBBLETYPE * a_ChunkSrc); void CopyNibbles(NIBBLETYPE * a_AreaDst, const NIBBLETYPE * a_ChunkSrc);
// cChunkDataCallback overrides: // cChunkDataCallback overrides:
virtual bool Coords(int a_ChunkX, int a_ChunkZ) override; virtual bool Coords(int a_ChunkX, int a_ChunkZ) override;
virtual void ChunkData(const cChunkData & a_BlockTypes) override; virtual void ChunkData(const cChunkData & a_BlockTypes) override;
} ; } ;
typedef NIBBLETYPE * NIBBLEARRAY; typedef NIBBLETYPE * NIBBLEARRAY;
Vector3i m_Origin; Vector3i m_Origin;
Vector3i m_Size; Vector3i m_Size;
/** An extra data value sometimes stored in the .schematic file. Used mainly by the WorldEdit plugin. /** An extra data value sometimes stored in the .schematic file. Used mainly by the WorldEdit plugin.
cBlockArea doesn't use this value in any way. */ cBlockArea doesn't use this value in any way. */
Vector3i m_WEOffset; Vector3i m_WEOffset;
@ -370,10 +370,10 @@ protected:
NIBBLETYPE * m_BlockMetas; // Each meta is stored as a separate byte for faster access NIBBLETYPE * m_BlockMetas; // Each meta is stored as a separate byte for faster access
NIBBLETYPE * m_BlockLight; // Each light value is stored as a separate byte for faster access NIBBLETYPE * m_BlockLight; // Each light value is stored as a separate byte for faster access
NIBBLETYPE * m_BlockSkyLight; // Each light value is stored as a separate byte for faster access NIBBLETYPE * m_BlockSkyLight; // Each light value is stored as a separate byte for faster access
/** Clears the data stored and prepares a fresh new block area with the specified dimensions */ /** Clears the data stored and prepares a fresh new block area with the specified dimensions */
bool SetSize(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes); bool SetSize(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes);
// Basic Setters: // Basic Setters:
void SetRelNibble(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Value, NIBBLETYPE * a_Array); void SetRelNibble(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Value, NIBBLETYPE * a_Array);
void SetNibble (int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_Value, NIBBLETYPE * a_Array); void SetNibble (int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_Value, NIBBLETYPE * a_Array);
@ -381,11 +381,11 @@ protected:
// Basic Getters: // Basic Getters:
NIBBLETYPE GetRelNibble(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE * a_Array) const; NIBBLETYPE GetRelNibble(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE * a_Array) const;
NIBBLETYPE GetNibble (int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE * a_Array) const; NIBBLETYPE GetNibble (int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE * a_Array) const;
// Crop helpers: // Crop helpers:
void CropBlockTypes(int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY, int a_AddMinZ, int a_SubMaxZ); void CropBlockTypes(int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY, int a_AddMinZ, int a_SubMaxZ);
void CropNibbles (NIBBLEARRAY & a_Array, int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY, int a_AddMinZ, int a_SubMaxZ); void CropNibbles (NIBBLEARRAY & a_Array, int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY, int a_AddMinZ, int a_SubMaxZ);
// Expand helpers: // Expand helpers:
void ExpandBlockTypes(int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ); void ExpandBlockTypes(int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ);
void ExpandNibbles (NIBBLEARRAY & a_Array, int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ); void ExpandNibbles (NIBBLEARRAY & a_Array, int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ);
@ -396,7 +396,7 @@ protected:
int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta,
NIBBLETYPE a_BlockLight, NIBBLETYPE a_BlockSkyLight NIBBLETYPE a_BlockLight, NIBBLETYPE a_BlockSkyLight
); );
template <bool MetasValid> template <bool MetasValid>
void MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_RelZ, eMergeStrategy a_Strategy, const NIBBLETYPE * SrcMetas, NIBBLETYPE * DstMetas); void MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_RelZ, eMergeStrategy a_Strategy, const NIBBLETYPE * SrcMetas, NIBBLETYPE * DstMetas);
// tolua_begin // tolua_begin

View File

@ -53,21 +53,21 @@ protected:
public: public:
// tolua_end // tolua_end
virtual ~cBlockEntity() {} // force a virtual destructor in all descendants virtual ~cBlockEntity() {} // force a virtual destructor in all descendants
virtual void Destroy(void) {} virtual void Destroy(void) {}
void SetWorld(cWorld * a_World) void SetWorld(cWorld * a_World)
{ {
m_World = a_World; m_World = a_World;
} }
/** Creates a new block entity for the specified block type /** Creates a new block entity for the specified block type
If a_World is valid, then the entity is created bound to that world If a_World is valid, then the entity is created bound to that world
Returns nullptr for unknown block types. */ Returns nullptr for unknown block types. */
static cBlockEntity * CreateByBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World = nullptr); static cBlockEntity * CreateByBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World = nullptr);
static const char * GetClassStatic(void) // Needed for ManualBindings's ForEach templates static const char * GetClassStatic(void) // Needed for ManualBindings's ForEach templates
{ {
return "cBlockEntity"; return "cBlockEntity";
@ -81,9 +81,9 @@ public:
/** Returns the name of the parent class, or empty string if no parent class. */ /** Returns the name of the parent class, or empty string if no parent class. */
virtual const char * GetParentClass(void) const { return ""; } virtual const char * GetParentClass(void) const { return ""; }
// tolua_begin // tolua_begin
// Position, in absolute block coordinates: // Position, in absolute block coordinates:
Vector3i GetPos(void) const { return Vector3i{m_PosX, m_PosY, m_PosZ}; } Vector3i GetPos(void) const { return Vector3i{m_PosX, m_PosY, m_PosZ}; }
int GetPosX(void) const { return m_PosX; } int GetPosX(void) const { return m_PosX; }
@ -91,25 +91,25 @@ public:
int GetPosZ(void) const { return m_PosZ; } int GetPosZ(void) const { return m_PosZ; }
BLOCKTYPE GetBlockType(void) const { return m_BlockType; } BLOCKTYPE GetBlockType(void) const { return m_BlockType; }
cWorld * GetWorld(void) const { return m_World; } cWorld * GetWorld(void) const { return m_World; }
int GetChunkX(void) const { return FAST_FLOOR_DIV(m_PosX, cChunkDef::Width); } int GetChunkX(void) const { return FAST_FLOOR_DIV(m_PosX, cChunkDef::Width); }
int GetChunkZ(void) const { return FAST_FLOOR_DIV(m_PosZ, cChunkDef::Width); } int GetChunkZ(void) const { return FAST_FLOOR_DIV(m_PosZ, cChunkDef::Width); }
int GetRelX(void) const { return m_RelX; } int GetRelX(void) const { return m_RelX; }
int GetRelZ(void) const { return m_RelZ; } int GetRelZ(void) const { return m_RelZ; }
// tolua_end // tolua_end
/** Called when a player uses this entity; should open the UI window. /** Called when a player uses this entity; should open the UI window.
returns true if the use was successful, return false to use the block as a "normal" block */ returns true if the use was successful, return false to use the block as a "normal" block */
virtual bool UsedBy( cPlayer * a_Player) = 0; virtual bool UsedBy( cPlayer * a_Player) = 0;
/** Sends the packet defining the block entity to the client specified. /** Sends the packet defining the block entity to the client specified.
To send to all eligible clients, use cWorld::BroadcastBlockEntity() */ To send to all eligible clients, use cWorld::BroadcastBlockEntity() */
virtual void SendTo(cClientHandle & a_Client) = 0; virtual void SendTo(cClientHandle & a_Client) = 0;
/** Ticks the entity; returns true if the chunk should be marked as dirty as a result of this ticking. By default does nothing. */ /** Ticks the entity; returns true if the chunk should be marked as dirty as a result of this ticking. By default does nothing. */
virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{ {
@ -120,12 +120,12 @@ public:
protected: protected:
/** Position in absolute block coordinates */ /** Position in absolute block coordinates */
int m_PosX, m_PosY, m_PosZ; int m_PosX, m_PosY, m_PosZ;
/** Position relative to the chunk, used to speed up ticking */ /** Position relative to the chunk, used to speed up ticking */
int m_RelX, m_RelZ; int m_RelX, m_RelZ;
BLOCKTYPE m_BlockType; BLOCKTYPE m_BlockType;
cWorld * m_World; cWorld * m_World;
} ; // tolua_export } ; // tolua_export

View File

@ -30,9 +30,9 @@ class cBlockEntityWithItems :
public: public:
// tolua_end // tolua_end
BLOCKENTITY_PROTODEF(cBlockEntityWithItems) BLOCKENTITY_PROTODEF(cBlockEntityWithItems)
cBlockEntityWithItems( cBlockEntityWithItems(
BLOCKTYPE a_BlockType, // Type of the block that the entity represents BLOCKTYPE a_BlockType, // Type of the block that the entity represents
int a_BlockX, int a_BlockY, int a_BlockZ, // Position of the block entity int a_BlockX, int a_BlockY, int a_BlockZ, // Position of the block entity
@ -45,7 +45,7 @@ public:
{ {
m_Contents.AddListener(*this); m_Contents.AddListener(*this);
} }
virtual void Destroy(void) override virtual void Destroy(void) override
{ {
// Drop the contents as pickups: // Drop the contents as pickups:
@ -55,12 +55,12 @@ public:
m_Contents.Clear(); m_Contents.Clear();
m_World->SpawnItemPickups(Pickups, m_PosX + 0.5, m_PosY + 0.5, m_PosZ + 0.5); // Spawn in centre of block m_World->SpawnItemPickups(Pickups, m_PosX + 0.5, m_PosY + 0.5, m_PosZ + 0.5); // Spawn in centre of block
} }
// tolua_begin // tolua_begin
const cItem & GetSlot(int a_SlotNum) const { return m_Contents.GetSlot(a_SlotNum); } const cItem & GetSlot(int a_SlotNum) const { return m_Contents.GetSlot(a_SlotNum); }
const cItem & GetSlot(int a_X, int a_Y) const { return m_Contents.GetSlot(a_X, a_Y); } const cItem & GetSlot(int a_X, int a_Y) const { return m_Contents.GetSlot(a_X, a_Y); }
void SetSlot(int a_SlotNum, const cItem & a_Item) { m_Contents.SetSlot(a_SlotNum, a_Item); } void SetSlot(int a_SlotNum, const cItem & a_Item) { m_Contents.SetSlot(a_SlotNum, a_Item); }
void SetSlot(int a_X, int a_Y, const cItem & a_Item) { m_Contents.SetSlot(a_X, a_Y, a_Item); } void SetSlot(int a_X, int a_Y, const cItem & a_Item) { m_Contents.SetSlot(a_X, a_Y, a_Item); }
@ -68,13 +68,13 @@ public:
cItemGrid & GetContents(void) { return m_Contents; } cItemGrid & GetContents(void) { return m_Contents; }
// tolua_end // tolua_end
/** Const version of the GetContents() function for C++ type-safety */ /** Const version of the GetContents() function for C++ type-safety */
const cItemGrid & GetContents(void) const { return m_Contents; } const cItemGrid & GetContents(void) const { return m_Contents; }
protected: protected:
cItemGrid m_Contents; cItemGrid m_Contents;
// cItemGrid::cListener overrides: // cItemGrid::cListener overrides:
virtual void OnSlotChanged(cItemGrid * a_Grid, int a_SlotNum) override virtual void OnSlotChanged(cItemGrid * a_Grid, int a_SlotNum) override
{ {

View File

@ -18,27 +18,27 @@ class cChestEntity :
public cBlockEntityWithItems public cBlockEntityWithItems
{ {
typedef cBlockEntityWithItems super; typedef cBlockEntityWithItems super;
public: public:
enum enum
{ {
ContentsHeight = 3, ContentsHeight = 3,
ContentsWidth = 9, ContentsWidth = 9,
} ; } ;
// tolua_end // tolua_end
BLOCKENTITY_PROTODEF(cChestEntity) BLOCKENTITY_PROTODEF(cChestEntity)
/** Constructor used for normal operation */ /** Constructor used for normal operation */
cChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World, BLOCKTYPE a_Type); cChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World, BLOCKTYPE a_Type);
virtual ~cChestEntity(); virtual ~cChestEntity();
// cBlockEntity overrides: // cBlockEntity overrides:
virtual void SendTo(cClientHandle & a_Client) override; virtual void SendTo(cClientHandle & a_Client) override;
virtual bool UsedBy(cPlayer * a_Player) override; virtual bool UsedBy(cPlayer * a_Player) override;
/** Opens a new chest window for this chest. /** Opens a new chest window for this chest.
Scans for neighbors to open a double chest window, if appropriate. */ Scans for neighbors to open a double chest window, if appropriate. */
void OpenNewWindow(void); void OpenNewWindow(void);

View File

@ -120,7 +120,7 @@ bool cCommandBlockEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{ {
return false; return false;
} }
m_ShouldExecute = false; m_ShouldExecute = false;
Execute(); Execute();
return true; return true;
@ -142,7 +142,7 @@ void cCommandBlockEntity::SendTo(cClientHandle & a_Client)
void cCommandBlockEntity::Execute() void cCommandBlockEntity::Execute()
{ {
ASSERT(m_World != nullptr); // Execute should not be called before the command block is attached to a world ASSERT(m_World != nullptr); // Execute should not be called before the command block is attached to a world
if (!m_World->AreCommandBlocksEnabled()) if (!m_World->AreCommandBlocksEnabled())
{ {
return; return;

View File

@ -21,13 +21,13 @@ class cCommandBlockEntity :
public cBlockEntity public cBlockEntity
{ {
typedef cBlockEntity super; typedef cBlockEntity super;
public: public:
// tolua_end // tolua_end
BLOCKENTITY_PROTODEF(cCommandBlockEntity) BLOCKENTITY_PROTODEF(cCommandBlockEntity)
/** Creates a new empty command block entity */ /** Creates a new empty command block entity */
cCommandBlockEntity(int a_X, int a_Y, int a_Z, cWorld * a_World); cCommandBlockEntity(int a_X, int a_Y, int a_Z, cWorld * a_World);
@ -43,7 +43,7 @@ public:
/** Sets the command block to execute a command in the next tick */ /** Sets the command block to execute a command in the next tick */
void Activate(void); void Activate(void);
/** Sets the command */ /** Sets the command */
void SetCommand(const AString & a_Cmd); void SetCommand(const AString & a_Cmd);
@ -55,9 +55,9 @@ public:
/** Retrieves the result (signal strength) of the last operation */ /** Retrieves the result (signal strength) of the last operation */
NIBBLETYPE GetResult(void) const; NIBBLETYPE GetResult(void) const;
// tolua_end // tolua_end
private: private:
/** Executes the associated command */ /** Executes the associated command */

View File

@ -18,19 +18,19 @@ public:
// tolua_end // tolua_end
BLOCKENTITY_PROTODEF(cDispenserEntity) BLOCKENTITY_PROTODEF(cDispenserEntity)
/** Constructor used for normal operation */ /** Constructor used for normal operation */
cDispenserEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); cDispenserEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
// tolua_begin // tolua_begin
/** Spawns a projectile of the given kind in front of the dispenser with the specified speed. /** Spawns a projectile of the given kind in front of the dispenser with the specified speed.
Returns the UniqueID of the spawned projectile, or 0 on failure. */ Returns the UniqueID of the spawned projectile, or 0 on failure. */
UInt32 SpawnProjectileFromDispenser(int a_BlockX, int a_BlockY, int a_BlockZ, cProjectileEntity::eKind a_Kind, const Vector3d & a_Speed); UInt32 SpawnProjectileFromDispenser(int a_BlockX, int a_BlockY, int a_BlockZ, cProjectileEntity::eKind a_Kind, const Vector3d & a_Speed);
/** Returns a unit vector in the cardinal direction of where the dispenser is facing. */ /** Returns a unit vector in the cardinal direction of where the dispenser is facing. */
Vector3d GetShootVector(NIBBLETYPE a_Meta); Vector3d GetShootVector(NIBBLETYPE a_Meta);
// tolua_end // tolua_end
private: private:

View File

@ -71,19 +71,19 @@ void cDropSpenserEntity::DropSpense(cChunk & a_Chunk)
SlotsCnt++; SlotsCnt++;
} }
} // for i - m_Contents[] } // for i - m_Contents[]
if (SlotsCnt == 0) if (SlotsCnt == 0)
{ {
// Nothing in the dropspenser, play the click sound // Nothing in the dropspenser, play the click sound
m_World->BroadcastSoundEffect("random.click", static_cast<double>(m_PosX), static_cast<double>(m_PosY), static_cast<double>(m_PosZ), 1.0f, 1.2f); m_World->BroadcastSoundEffect("random.click", static_cast<double>(m_PosX), static_cast<double>(m_PosY), static_cast<double>(m_PosZ), 1.0f, 1.2f);
return; return;
} }
int RandomSlot = m_World->GetTickRandomNumber(SlotsCnt - 1); int RandomSlot = m_World->GetTickRandomNumber(SlotsCnt - 1);
// DropSpense the item, using the specialized behavior in the subclasses: // DropSpense the item, using the specialized behavior in the subclasses:
DropSpenseFromSlot(a_Chunk, OccupiedSlots[RandomSlot]); DropSpenseFromSlot(a_Chunk, OccupiedSlots[RandomSlot]);
// Broadcast a smoke and click effects: // Broadcast a smoke and click effects:
NIBBLETYPE Meta = a_Chunk.GetMeta(m_RelX, m_PosY, m_RelZ); NIBBLETYPE Meta = a_Chunk.GetMeta(m_RelX, m_PosY, m_RelZ);
int SmokeDir = 0; int SmokeDir = 0;
@ -120,7 +120,7 @@ bool cDropSpenserEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{ {
return false; return false;
} }
m_ShouldDropSpense = false; m_ShouldDropSpense = false;
DropSpense(a_Chunk); DropSpense(a_Chunk);
return true; return true;
@ -148,7 +148,7 @@ bool cDropSpenserEntity::UsedBy(cPlayer * a_Player)
OpenWindow(new cDropSpenserWindow(m_PosX, m_PosY, m_PosZ, this)); OpenWindow(new cDropSpenserWindow(m_PosX, m_PosY, m_PosZ, this));
Window = GetWindow(); Window = GetWindow();
} }
if (Window != nullptr) if (Window != nullptr)
{ {
if (a_Player->GetWindow() != Window) if (a_Player->GetWindow() != Window)

View File

@ -34,38 +34,38 @@ public:
ContentsHeight = 3, ContentsHeight = 3,
ContentsWidth = 3, ContentsWidth = 3,
} ; } ;
// tolua_end // tolua_end
BLOCKENTITY_PROTODEF(cDropSpenserEntity) BLOCKENTITY_PROTODEF(cDropSpenserEntity)
cDropSpenserEntity(BLOCKTYPE a_BlockType, int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); cDropSpenserEntity(BLOCKTYPE a_BlockType, int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
virtual ~cDropSpenserEntity(); virtual ~cDropSpenserEntity();
// cBlockEntity overrides: // cBlockEntity overrides:
virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void SendTo(cClientHandle & a_Client) override; virtual void SendTo(cClientHandle & a_Client) override;
virtual bool UsedBy(cPlayer * a_Player) override; virtual bool UsedBy(cPlayer * a_Player) override;
// tolua_begin // tolua_begin
/** Modifies the block coords to match the dropspenser direction given (where the dropspensed pickups should materialize) */ /** Modifies the block coords to match the dropspenser direction given (where the dropspensed pickups should materialize) */
void AddDropSpenserDir(int & a_BlockX, int & a_BlockY, int & a_BlockZ, NIBBLETYPE a_Direction); void AddDropSpenserDir(int & a_BlockX, int & a_BlockY, int & a_BlockZ, NIBBLETYPE a_Direction);
/** Sets the dropspenser to dropspense an item in the next tick */ /** Sets the dropspenser to dropspense an item in the next tick */
void Activate(void); void Activate(void);
// tolua_end // tolua_end
protected: protected:
bool m_ShouldDropSpense; ///< If true, the dropspenser will dropspense an item in the next tick bool m_ShouldDropSpense; ///< If true, the dropspenser will dropspense an item in the next tick
/** Does the actual work on dropspensing an item. Chooses the slot, calls DropSpenseFromSlot() and handles smoke / sound effects */ /** Does the actual work on dropspensing an item. Chooses the slot, calls DropSpenseFromSlot() and handles smoke / sound effects */
void DropSpense(cChunk & a_Chunk); void DropSpense(cChunk & a_Chunk);
/** Override this function to provide the specific behavior for item dropspensing (drop / shoot / pour / ...) */ /** Override this function to provide the specific behavior for item dropspensing (drop / shoot / pour / ...) */
virtual void DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) = 0; virtual void DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) = 0;
/** Helper function, drops one item from the specified slot (like a dropper) */ /** Helper function, drops one item from the specified slot (like a dropper) */
void DropFromSlot(cChunk & a_Chunk, int a_SlotNum); void DropFromSlot(cChunk & a_Chunk, int a_SlotNum);
} ; // tolua_export } ; // tolua_export

View File

@ -20,20 +20,20 @@ class cDropperEntity :
public cDropSpenserEntity public cDropSpenserEntity
{ {
typedef cDropSpenserEntity super; typedef cDropSpenserEntity super;
public: public:
// tolua_end // tolua_end
BLOCKENTITY_PROTODEF(cDropperEntity) BLOCKENTITY_PROTODEF(cDropperEntity)
/** Constructor used for normal operation */ /** Constructor used for normal operation */
cDropperEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); cDropperEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
protected: protected:
// cDropSpenserEntity overrides: // cDropSpenserEntity overrides:
virtual void DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) override; virtual void DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) override;
/** Takes an item from slot a_SlotNum and puts it into the container in front of the dropper. /** Takes an item from slot a_SlotNum and puts it into the container in front of the dropper.
Called when there's a container directly in front of the dropper, Called when there's a container directly in front of the dropper,
so the dropper should store items there, rather than dropping. */ so the dropper should store items there, rather than dropping. */

View File

@ -14,12 +14,12 @@ class cEnderChestEntity :
public cBlockEntityWindowOwner public cBlockEntityWindowOwner
{ {
typedef cBlockEntity super; typedef cBlockEntity super;
public: public:
// tolua_end // tolua_end
BLOCKENTITY_PROTODEF(cEnderChestEntity) BLOCKENTITY_PROTODEF(cEnderChestEntity)
cEnderChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); cEnderChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
virtual ~cEnderChestEntity(); virtual ~cEnderChestEntity();
@ -29,7 +29,7 @@ public:
static void LoadFromJson(const Json::Value & a_Value, cItemGrid & a_Grid); static void LoadFromJson(const Json::Value & a_Value, cItemGrid & a_Grid);
static void SaveToJson(Json::Value & a_Value, const cItemGrid & a_Grid); static void SaveToJson(Json::Value & a_Value, const cItemGrid & a_Grid);
/** Opens a new enderchest window for this enderchest */ /** Opens a new enderchest window for this enderchest */
void OpenNewWindow(void); void OpenNewWindow(void);
} ; // tolua_export } ; // tolua_export

View File

@ -21,31 +21,31 @@ class cFlowerPotEntity :
public cBlockEntity public cBlockEntity
{ {
typedef cBlockEntity super; typedef cBlockEntity super;
public: public:
// tolua_end // tolua_end
BLOCKENTITY_PROTODEF(cFlowerPotEntity) BLOCKENTITY_PROTODEF(cFlowerPotEntity)
/** Creates a new flowerpot entity at the specified block coords. a_World may be nullptr */ /** Creates a new flowerpot entity at the specified block coords. a_World may be nullptr */
cFlowerPotEntity(int a_BlocX, int a_BlockY, int a_BlockZ, cWorld * a_World); cFlowerPotEntity(int a_BlocX, int a_BlockY, int a_BlockZ, cWorld * a_World);
virtual void Destroy(void) override; virtual void Destroy(void) override;
// tolua_begin // tolua_begin
/** Is a flower in the pot? */ /** Is a flower in the pot? */
bool IsItemInPot(void) { return !m_Item.IsEmpty(); } bool IsItemInPot(void) { return !m_Item.IsEmpty(); }
/** Get the item in the flower pot */ /** Get the item in the flower pot */
cItem GetItem(void) const { return m_Item; } cItem GetItem(void) const { return m_Item; }
/** Set the item in the flower pot */ /** Set the item in the flower pot */
void SetItem(const cItem & a_Item) { m_Item = a_Item; } void SetItem(const cItem & a_Item) { m_Item = a_Item; }
// tolua_end // tolua_end
/** Called when the player is using the entity; returns true if it was a successful use, return false if it should be treated as a normal block */ /** Called when the player is using the entity; returns true if it was a successful use, return false if it should be treated as a normal block */
virtual bool UsedBy(cPlayer * a_Player) override; virtual bool UsedBy(cPlayer * a_Player) override;
virtual void SendTo(cClientHandle & a_Client) override; virtual void SendTo(cClientHandle & a_Client) override;

View File

@ -365,7 +365,7 @@ void cFurnaceEntity::UpdateProgressBars(bool a_ForceUpdate)
int CurFuel = (m_FuelBurnTime > 0) ? 200 - (200 * m_TimeBurned / m_FuelBurnTime) : 0; int CurFuel = (m_FuelBurnTime > 0) ? 200 - (200 * m_TimeBurned / m_FuelBurnTime) : 0;
BroadcastProgress(PROGRESSBAR_FUEL, static_cast<short>(CurFuel)); BroadcastProgress(PROGRESSBAR_FUEL, static_cast<short>(CurFuel));
int CurCook = (m_NeedCookTime > 0) ? (200 * m_TimeCooked / m_NeedCookTime) : 0; int CurCook = (m_NeedCookTime > 0) ? (200 * m_TimeCooked / m_NeedCookTime) : 0;
BroadcastProgress(PROGRESSBAR_SMELTING_CONFIRM, 200); // Post 1.8, Mojang requires a random packet with an ID of three and value of 200. Wat. Wat. Wat. BroadcastProgress(PROGRESSBAR_SMELTING_CONFIRM, 200); // Post 1.8, Mojang requires a random packet with an ID of three and value of 200. Wat. Wat. Wat.
BroadcastProgress(PROGRESSBAR_SMELTING, static_cast<short>(CurCook)); BroadcastProgress(PROGRESSBAR_SMELTING, static_cast<short>(CurCook));

View File

@ -19,25 +19,25 @@ class cFurnaceEntity :
public cBlockEntityWithItems public cBlockEntityWithItems
{ {
typedef cBlockEntityWithItems super; typedef cBlockEntityWithItems super;
public: public:
enum enum
{ {
fsInput = 0, // Input slot number fsInput = 0, // Input slot number
fsFuel = 1, // Fuel slot number fsFuel = 1, // Fuel slot number
fsOutput = 2, // Output slot number fsOutput = 2, // Output slot number
ContentsWidth = 3, ContentsWidth = 3,
ContentsHeight = 1, ContentsHeight = 1,
}; };
// tolua_end // tolua_end
BLOCKENTITY_PROTODEF(cFurnaceEntity) BLOCKENTITY_PROTODEF(cFurnaceEntity)
/** Constructor used for normal operation */ /** Constructor used for normal operation */
cFurnaceEntity(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cWorld * a_World); cFurnaceEntity(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cWorld * a_World);
virtual ~cFurnaceEntity(); virtual ~cFurnaceEntity();
// cBlockEntity overrides: // cBlockEntity overrides:
@ -54,41 +54,41 @@ public:
Used after the furnace is loaded from storage to set up the internal variables so that cooking continues, if it was active Used after the furnace is loaded from storage to set up the internal variables so that cooking continues, if it was active
Returns true if cooking */ Returns true if cooking */
bool ContinueCooking(void); bool ContinueCooking(void);
// tolua_begin // tolua_begin
/** Returns the item in the input slot */ /** Returns the item in the input slot */
const cItem & GetInputSlot(void) const { return GetSlot(fsInput); } const cItem & GetInputSlot(void) const { return GetSlot(fsInput); }
/** Returns the item in the fuel slot */ /** Returns the item in the fuel slot */
const cItem & GetFuelSlot(void) const { return GetSlot(fsFuel); } const cItem & GetFuelSlot(void) const { return GetSlot(fsFuel); }
/** Returns the item in the output slot */ /** Returns the item in the output slot */
const cItem & GetOutputSlot(void) const { return GetSlot(fsOutput); } const cItem & GetOutputSlot(void) const { return GetSlot(fsOutput); }
/** Sets the item in the input slot */ /** Sets the item in the input slot */
void SetInputSlot(const cItem & a_Item) { SetSlot(fsInput, a_Item); } void SetInputSlot(const cItem & a_Item) { SetSlot(fsInput, a_Item); }
/** Sets the item in the fuel slot */ /** Sets the item in the fuel slot */
void SetFuelSlot(const cItem & a_Item) { SetSlot(fsFuel, a_Item); } void SetFuelSlot(const cItem & a_Item) { SetSlot(fsFuel, a_Item); }
/** Sets the item in the output slot */ /** Sets the item in the output slot */
void SetOutputSlot(const cItem & a_Item) { SetSlot(fsOutput, a_Item); } void SetOutputSlot(const cItem & a_Item) { SetSlot(fsOutput, a_Item); }
/** Returns the time that the current item has been cooking, in ticks */ /** Returns the time that the current item has been cooking, in ticks */
int GetTimeCooked(void) const { return m_TimeCooked; } int GetTimeCooked(void) const { return m_TimeCooked; }
/** Returns the time until the current item finishes cooking, in ticks */ /** Returns the time until the current item finishes cooking, in ticks */
int GetCookTimeLeft(void) const { return m_NeedCookTime - m_TimeCooked; } int GetCookTimeLeft(void) const { return m_NeedCookTime - m_TimeCooked; }
/** Returns the time until the current fuel is depleted, in ticks */ /** Returns the time until the current fuel is depleted, in ticks */
int GetFuelBurnTimeLeft(void) const { return m_FuelBurnTime - m_TimeBurned; } int GetFuelBurnTimeLeft(void) const { return m_FuelBurnTime - m_TimeBurned; }
/** Returns true if there's time left before the current fuel is depleted */ /** Returns true if there's time left before the current fuel is depleted */
bool HasFuelTimeLeft(void) const { return (GetFuelBurnTimeLeft() > 0); } bool HasFuelTimeLeft(void) const { return (GetFuelBurnTimeLeft() > 0); }
// tolua_end // tolua_end
void SetBurnTimes(int a_FuelBurnTime, int a_TimeBurned) void SetBurnTimes(int a_FuelBurnTime, int a_TimeBurned)
{ {
m_FuelBurnTime = a_FuelBurnTime; m_FuelBurnTime = a_FuelBurnTime;
@ -100,29 +100,29 @@ public:
m_NeedCookTime = a_NeedCookTime; m_NeedCookTime = a_NeedCookTime;
m_TimeCooked = a_TimeCooked; m_TimeCooked = a_TimeCooked;
} }
void SetLoading(bool a_IsLoading) void SetLoading(bool a_IsLoading)
{ {
m_IsLoading = a_IsLoading; m_IsLoading = a_IsLoading;
} }
protected: protected:
/** Block meta of the block currently represented by this entity */ /** Block meta of the block currently represented by this entity */
NIBBLETYPE m_BlockMeta; NIBBLETYPE m_BlockMeta;
/** The recipe for the current input slot */ /** The recipe for the current input slot */
const cFurnaceRecipe::cRecipe * m_CurrentRecipe; const cFurnaceRecipe::cRecipe * m_CurrentRecipe;
/** The item that is being smelted */ /** The item that is being smelted */
cItem m_LastInput; cItem m_LastInput;
/** Set to true when the furnace entity has been destroyed to prevent the block being set again */ /** Set to true when the furnace entity has been destroyed to prevent the block being set again */
bool m_IsDestroyed; bool m_IsDestroyed;
/** Set to true if the furnace is cooking an item */ /** Set to true if the furnace is cooking an item */
bool m_IsCooking; bool m_IsCooking;
/** Amount of ticks needed to fully cook current item */ /** Amount of ticks needed to fully cook current item */
int m_NeedCookTime; int m_NeedCookTime;
@ -137,37 +137,37 @@ protected:
/** Is the block currently being loaded into the world? */ /** Is the block currently being loaded into the world? */
bool m_IsLoading; bool m_IsLoading;
/** Sends the specified progressbar value to all clients of the window */ /** Sends the specified progressbar value to all clients of the window */
void BroadcastProgress(short a_ProgressbarID, short a_Value); void BroadcastProgress(short a_ProgressbarID, short a_Value);
/** One item finished cooking */ /** One item finished cooking */
void FinishOne(); void FinishOne();
/** Starts burning a new fuel, if possible */ /** Starts burning a new fuel, if possible */
void BurnNewFuel(void); void BurnNewFuel(void);
/** Updates the recipe, based on the current input */ /** Updates the recipe, based on the current input */
void UpdateInput(void); void UpdateInput(void);
/** Called when the fuel slot changes or when the fuel is spent, burns another piece of fuel if appropriate */ /** Called when the fuel slot changes or when the fuel is spent, burns another piece of fuel if appropriate */
void UpdateFuel(void); void UpdateFuel(void);
/** Called when the output slot changes */ /** Called when the output slot changes */
void UpdateOutput(void); void UpdateOutput(void);
/** Returns true if the input can be cooked into output and the item counts allow for another cooking operation */ /** Returns true if the input can be cooked into output and the item counts allow for another cooking operation */
bool CanCookInputToOutput(void) const; bool CanCookInputToOutput(void) const;
/** Broadcasts progressbar updates, if needed */ /** Broadcasts progressbar updates, if needed */
void UpdateProgressBars(bool a_ForceUpdate = false); void UpdateProgressBars(bool a_ForceUpdate = false);
/** Sets the m_IsCooking variable, updates the furnace block type based on the value */ /** Sets the m_IsCooking variable, updates the furnace block type based on the value */
void SetIsCooking(bool a_IsCooking); void SetIsCooking(bool a_IsCooking);
// cItemGrid::cListener overrides: // cItemGrid::cListener overrides:
virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override; virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override;
} ; // tolua_export } ; // tolua_export

View File

@ -30,17 +30,17 @@ public:
} ; } ;
// tolua_end // tolua_end
BLOCKENTITY_PROTODEF(cHopperEntity) BLOCKENTITY_PROTODEF(cHopperEntity)
/** Constructor used for normal operation */ /** Constructor used for normal operation */
cHopperEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); cHopperEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
/** Returns the block coords of the block receiving the output items, based on the meta /** Returns the block coords of the block receiving the output items, based on the meta
Returns false if unattached. Returns false if unattached.
Exported in ManualBindings.cpp. */ Exported in ManualBindings.cpp. */
bool GetOutputBlockPos(NIBBLETYPE a_BlockMeta, int & a_OutputX, int & a_OutputY, int & a_OutputZ); bool GetOutputBlockPos(NIBBLETYPE a_BlockMeta, int & a_OutputX, int & a_OutputY, int & a_OutputZ);
protected: protected:
Int64 m_LastMoveItemsInTick; Int64 m_LastMoveItemsInTick;
@ -50,37 +50,37 @@ protected:
virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void SendTo(cClientHandle & a_Client) override; virtual void SendTo(cClientHandle & a_Client) override;
virtual bool UsedBy(cPlayer * a_Player) override; virtual bool UsedBy(cPlayer * a_Player) override;
/** Opens a new chest window for this chest. Scans for neighbors to open a double chest window, if appropriate. */ /** Opens a new chest window for this chest. Scans for neighbors to open a double chest window, if appropriate. */
void OpenNewWindow(void); void OpenNewWindow(void);
/** Moves items from the container above it into this hopper. Returns true if the contents have changed. */ /** Moves items from the container above it into this hopper. Returns true if the contents have changed. */
bool MoveItemsIn(cChunk & a_Chunk, Int64 a_CurrentTick); bool MoveItemsIn(cChunk & a_Chunk, Int64 a_CurrentTick);
/** Moves pickups from above this hopper into it. Returns true if the contents have changed. */ /** Moves pickups from above this hopper into it. Returns true if the contents have changed. */
bool MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick); bool MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick);
/** Moves items out from this hopper into the destination. Returns true if the contents have changed. */ /** Moves items out from this hopper into the destination. Returns true if the contents have changed. */
bool MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick); bool MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick);
/** Moves items from a chest (dblchest) above the hopper into this hopper. Returns true if contents have changed. */ /** Moves items from a chest (dblchest) above the hopper into this hopper. Returns true if contents have changed. */
bool MoveItemsFromChest(cChunk & a_Chunk); bool MoveItemsFromChest(cChunk & a_Chunk);
/** Moves items from a furnace above the hopper into this hopper. Returns true if contents have changed. */ /** Moves items from a furnace above the hopper into this hopper. Returns true if contents have changed. */
bool MoveItemsFromFurnace(cChunk & a_Chunk); bool MoveItemsFromFurnace(cChunk & a_Chunk);
/** Moves items from the specified a_Entity's Contents into this hopper. Returns true if contents have changed. */ /** Moves items from the specified a_Entity's Contents into this hopper. Returns true if contents have changed. */
bool MoveItemsFromGrid(cBlockEntityWithItems & a_Entity); bool MoveItemsFromGrid(cBlockEntityWithItems & a_Entity);
/** Moves one piece from the specified itemstack into this hopper. Returns true if contents have changed. Doesn't change the itemstack. */ /** Moves one piece from the specified itemstack into this hopper. Returns true if contents have changed. Doesn't change the itemstack. */
bool MoveItemsFromSlot(cBlockEntityWithItems & a_Entity, int a_SrcSlotNum); bool MoveItemsFromSlot(cBlockEntityWithItems & a_Entity, int a_SrcSlotNum);
/** Moves items to the chest at the specified coords. Returns true if contents have changed */ /** Moves items to the chest at the specified coords. Returns true if contents have changed */
bool MoveItemsToChest(cChunk & a_Chunk, int a_BlockX, int a_BlockY, int a_BlockZ); bool MoveItemsToChest(cChunk & a_Chunk, int a_BlockX, int a_BlockY, int a_BlockZ);
/** Moves items to the furnace at the specified coords. Returns true if contents have changed */ /** Moves items to the furnace at the specified coords. Returns true if contents have changed */
bool MoveItemsToFurnace(cChunk & a_Chunk, int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_HopperMeta); bool MoveItemsToFurnace(cChunk & a_Chunk, int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_HopperMeta);
/** Moves items to the specified ItemGrid. Returns true if contents have changed */ /** Moves items to the specified ItemGrid. Returns true if contents have changed */
bool MoveItemsToGrid(cBlockEntityWithItems & a_Entity); bool MoveItemsToGrid(cBlockEntityWithItems & a_Entity);

View File

@ -16,32 +16,32 @@ class cJukeboxEntity :
public: public:
// tolua_end // tolua_end
BLOCKENTITY_PROTODEF(cJukeboxEntity) BLOCKENTITY_PROTODEF(cJukeboxEntity)
cJukeboxEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); cJukeboxEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
virtual ~cJukeboxEntity(); virtual ~cJukeboxEntity();
// tolua_begin // tolua_begin
int GetRecord(void); int GetRecord(void);
void SetRecord(int a_Record); void SetRecord(int a_Record);
/** Plays the specified Record. Return false if a_Record isn't a playable Record (E_ITEM_XXX_DISC). /** Plays the specified Record. Return false if a_Record isn't a playable Record (E_ITEM_XXX_DISC).
If there is a record already playing, ejects it first. */ If there is a record already playing, ejects it first. */
bool PlayRecord(int a_Record); bool PlayRecord(int a_Record);
/** Ejects the currently held record as a pickup. Return false when no record had been inserted. */ /** Ejects the currently held record as a pickup. Return false when no record had been inserted. */
bool EjectRecord(void); bool EjectRecord(void);
/** Is in the Jukebox a Record? */ /** Is in the Jukebox a Record? */
bool IsPlayingRecord(void); bool IsPlayingRecord(void);
static bool IsRecordItem(int a_Item) static bool IsRecordItem(int a_Item)
{ {
return ((a_Item >= E_ITEM_FIRST_DISC) && (a_Item <= E_ITEM_LAST_DISC)); return ((a_Item >= E_ITEM_FIRST_DISC) && (a_Item <= E_ITEM_LAST_DISC));
} }
// tolua_end // tolua_end
virtual bool UsedBy(cPlayer * a_Player) override; virtual bool UsedBy(cPlayer * a_Player) override;

View File

@ -21,36 +21,36 @@ class cMobHeadEntity :
public cBlockEntity public cBlockEntity
{ {
typedef cBlockEntity super; typedef cBlockEntity super;
public: public:
// tolua_end // tolua_end
BLOCKENTITY_PROTODEF(cMobHeadEntity) BLOCKENTITY_PROTODEF(cMobHeadEntity)
/** Creates a new mob head entity at the specified block coords. a_World may be nullptr */ /** Creates a new mob head entity at the specified block coords. a_World may be nullptr */
cMobHeadEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); cMobHeadEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
// tolua_begin // tolua_begin
/** Set the type of the mob head */ /** Set the type of the mob head */
void SetType(const eMobHeadType & a_SkullType); void SetType(const eMobHeadType & a_SkullType);
/** Set the rotation of the mob head */ /** Set the rotation of the mob head */
void SetRotation(eMobHeadRotation a_Rotation); void SetRotation(eMobHeadRotation a_Rotation);
/** Set the player for mob heads with player type */ /** Set the player for mob heads with player type */
void SetOwner(const cPlayer & a_Owner); void SetOwner(const cPlayer & a_Owner);
/** Sets the player components for the mob heads with player type */ /** Sets the player components for the mob heads with player type */
void SetOwner(const AString & a_OwnerUUID, const AString & a_OwnerName, const AString & a_OwnerTexture, const AString & a_OwnerTextureSignature); void SetOwner(const AString & a_OwnerUUID, const AString & a_OwnerName, const AString & a_OwnerTexture, const AString & a_OwnerTextureSignature);
/** Returns the type of the mob head */ /** Returns the type of the mob head */
eMobHeadType GetType(void) const { return m_Type; } eMobHeadType GetType(void) const { return m_Type; }
/** Returns the rotation of the mob head */ /** Returns the rotation of the mob head */
eMobHeadRotation GetRotation(void) const { return m_Rotation; } eMobHeadRotation GetRotation(void) const { return m_Rotation; }
/** Returns the player name of the mob head */ /** Returns the player name of the mob head */
AString GetOwnerName(void) const { return m_OwnerName; } AString GetOwnerName(void) const { return m_OwnerName; }
@ -62,9 +62,9 @@ public:
/** Returns the texture signature of the mob head */ /** Returns the texture signature of the mob head */
AString GetOwnerTextureSignature(void) const { return m_OwnerTextureSignature; } AString GetOwnerTextureSignature(void) const { return m_OwnerTextureSignature; }
// tolua_end // tolua_end
virtual bool UsedBy(cPlayer * a_Player) override; virtual bool UsedBy(cPlayer * a_Player) override;
virtual void SendTo(cClientHandle & a_Client) override; virtual void SendTo(cClientHandle & a_Client) override;

View File

@ -24,7 +24,7 @@ class cMobSpawnerEntity :
public: public:
// tolua_end // tolua_end
cMobSpawnerEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); cMobSpawnerEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
virtual void SendTo(cClientHandle & a_Client) override; virtual void SendTo(cClientHandle & a_Client) override;

View File

@ -35,7 +35,7 @@ void cNoteEntity::MakeSound(void)
{ {
char instrument; char instrument;
AString sampleName; AString sampleName;
switch (m_World->GetBlock(m_PosX, m_PosY - 1, m_PosZ)) switch (m_World->GetBlock(m_PosX, m_PosY - 1, m_PosZ))
{ {
case E_BLOCK_PLANKS: case E_BLOCK_PLANKS:
@ -47,7 +47,7 @@ void cNoteEntity::MakeSound(void)
sampleName = "note.bassattack"; sampleName = "note.bassattack";
break; break;
} }
case E_BLOCK_SAND: case E_BLOCK_SAND:
case E_BLOCK_GRAVEL: case E_BLOCK_GRAVEL:
case E_BLOCK_SOULSAND: case E_BLOCK_SOULSAND:
@ -56,7 +56,7 @@ void cNoteEntity::MakeSound(void)
sampleName = "note.snare"; sampleName = "note.snare";
break; break;
} }
case E_BLOCK_GLASS: case E_BLOCK_GLASS:
case E_BLOCK_GLASS_PANE: case E_BLOCK_GLASS_PANE:
case E_BLOCK_GLOWSTONE: case E_BLOCK_GLOWSTONE:
@ -89,7 +89,7 @@ void cNoteEntity::MakeSound(void)
} }
m_World->BroadcastBlockAction(m_PosX, m_PosY, m_PosZ, static_cast<Byte>(instrument), static_cast<Byte>(m_Pitch), E_BLOCK_NOTE_BLOCK); m_World->BroadcastBlockAction(m_PosX, m_PosY, m_PosZ, static_cast<Byte>(instrument), static_cast<Byte>(m_Pitch), E_BLOCK_NOTE_BLOCK);
// TODO: instead of calculating the power function over and over, make a precalculated table - there's only 24 pitches after all // TODO: instead of calculating the power function over and over, make a precalculated table - there's only 24 pitches after all
float calcPitch = static_cast<float>(pow(2.0f, static_cast<float>(m_Pitch - 12.0f) / 12.0f)); float calcPitch = static_cast<float>(pow(2.0f, static_cast<float>(m_Pitch - 12.0f) / 12.0f));
m_World->BroadcastSoundEffect( m_World->BroadcastSoundEffect(

View File

@ -31,20 +31,20 @@ public:
// tolua_end // tolua_end
BLOCKENTITY_PROTODEF(cNoteEntity) BLOCKENTITY_PROTODEF(cNoteEntity)
/** Creates a new note entity. a_World may be nullptr */ /** Creates a new note entity. a_World may be nullptr */
cNoteEntity(int a_X, int a_Y, int a_Z, cWorld * a_World); cNoteEntity(int a_X, int a_Y, int a_Z, cWorld * a_World);
virtual ~cNoteEntity() {} virtual ~cNoteEntity() {}
// tolua_begin // tolua_begin
char GetPitch(void); char GetPitch(void);
void SetPitch(char a_Pitch); void SetPitch(char a_Pitch);
void IncrementPitch(void); void IncrementPitch(void);
void MakeSound(void); void MakeSound(void);
// tolua_end // tolua_end
virtual bool UsedBy(cPlayer * a_Player) override; virtual bool UsedBy(cPlayer * a_Player) override;
virtual void SendTo(cClientHandle &) override {} virtual void SendTo(cClientHandle &) override {}

View File

@ -20,29 +20,29 @@ class cSignEntity :
public cBlockEntity public cBlockEntity
{ {
typedef cBlockEntity super; typedef cBlockEntity super;
public: public:
// tolua_end // tolua_end
BLOCKENTITY_PROTODEF(cSignEntity) BLOCKENTITY_PROTODEF(cSignEntity)
/** Creates a new empty sign entity at the specified block coords and block type (wall or standing). a_World may be nullptr */ /** Creates a new empty sign entity at the specified block coords and block type (wall or standing). a_World may be nullptr */
cSignEntity(BLOCKTYPE a_BlockType, int a_X, int a_Y, int a_Z, cWorld * a_World); cSignEntity(BLOCKTYPE a_BlockType, int a_X, int a_Y, int a_Z, cWorld * a_World);
// tolua_begin // tolua_begin
/** Sets all the sign's lines */ /** Sets all the sign's lines */
void SetLines(const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4); void SetLines(const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4);
/** Sets individual line (zero-based index) */ /** Sets individual line (zero-based index) */
void SetLine(int a_Index, const AString & a_Line); void SetLine(int a_Index, const AString & a_Line);
/** Retrieves individual line (zero-based index) */ /** Retrieves individual line (zero-based index) */
AString GetLine(int a_Index) const; AString GetLine(int a_Index) const;
// tolua_end // tolua_end
virtual bool UsedBy(cPlayer * a_Player) override; virtual bool UsedBy(cPlayer * a_Player) override;
virtual void SendTo(cClientHandle & a_Client) override; virtual void SendTo(cClientHandle & a_Client) override;

View File

@ -22,9 +22,9 @@ class cBlockIDMap
return (NoCaseCompare(a_Item1, a_Item2) > 0); return (NoCaseCompare(a_Item1, a_Item2) > 0);
} }
} ; } ;
typedef std::map<AString, std::pair<short, short>, Comparator> ItemMap; typedef std::map<AString, std::pair<short, short>, Comparator> ItemMap;
public: public:
static bool m_bHasRunInit; static bool m_bHasRunInit;
@ -60,8 +60,8 @@ public:
AddToMap(Name, Value); AddToMap(Name, Value);
} // for i - Ini.Values[] } // for i - Ini.Values[]
} }
int Resolve(const AString & a_ItemName) int Resolve(const AString & a_ItemName)
{ {
ItemMap::iterator itr = m_Map.find(a_ItemName); ItemMap::iterator itr = m_Map.find(a_ItemName);
@ -71,8 +71,8 @@ public:
} }
return itr->second.first; return itr->second.first;
} }
bool ResolveItem(const AString & a_ItemName, cItem & a_Item) bool ResolveItem(const AString & a_ItemName, cItem & a_Item)
{ {
// Split into parts divided by either ':' or '^' // Split into parts divided by either ':' or '^'
@ -102,7 +102,7 @@ public:
return false; return false;
} }
} }
// Parse the damage, if present: // Parse the damage, if present:
if (Split.size() < 2) if (Split.size() < 2)
{ {
@ -119,8 +119,8 @@ public:
a_Item.m_ItemCount = 1; a_Item.m_ItemCount = 1;
return true; return true;
} }
AString Desolve(short a_ItemType, short a_ItemDamage) AString Desolve(short a_ItemType, short a_ItemDamage)
{ {
// First try an exact match, both ItemType and ItemDamage ("birchplanks=5:2"): // First try an exact match, both ItemType and ItemDamage ("birchplanks=5:2"):
@ -131,7 +131,7 @@ public:
return itr->first; return itr->first;
} }
} // for itr - m_Map[] } // for itr - m_Map[]
// There is no exact match, try matching ItemType only ("planks=5"): // There is no exact match, try matching ItemType only ("planks=5"):
if (a_ItemDamage == 0) if (a_ItemDamage == 0)
{ {
@ -156,12 +156,12 @@ public:
} }
return res; return res;
} }
protected: protected:
ItemMap m_Map; ItemMap m_Map;
void AddToMap(const AString & a_Name, const AString & a_Value) void AddToMap(const AString & a_Name, const AString & a_Value)
{ {
AStringVector Split = StringSplit(a_Value, ":"); AStringVector Split = StringSplit(a_Value, ":");
@ -224,7 +224,7 @@ int BlockStringToType(const AString & a_BlockTypeString)
// It was a valid number, return that // It was a valid number, return that
return res; return res;
} }
if (!gsBlockIDMap.m_bHasRunInit) if (!gsBlockIDMap.m_bHasRunInit)
{ {
gsBlockIDMap.init(); gsBlockIDMap.init();
@ -300,7 +300,7 @@ eDimension StringToDimension(const AString & a_DimensionString)
// It was a valid number // It was a valid number
return static_cast<eDimension>(res); return static_cast<eDimension>(res);
} }
// Decode using a built-in map: // Decode using a built-in map:
static struct static struct
{ {
@ -323,7 +323,7 @@ eDimension StringToDimension(const AString & a_DimensionString)
return DimensionMap[i].m_Dimension; return DimensionMap[i].m_Dimension;
} }
} // for i - DimensionMap[] } // for i - DimensionMap[]
// Not found // Not found
LOGWARNING("Unknown dimension: \"%s\". Setting to Overworld", a_DimensionString.c_str()); LOGWARNING("Unknown dimension: \"%s\". Setting to Overworld", a_DimensionString.c_str());
return dimOverworld; return dimOverworld;
@ -389,7 +389,7 @@ AString DamageTypeToString(eDamageType a_DamageType)
case dtSuffocating: return "dtSuffocation"; case dtSuffocating: return "dtSuffocation";
case dtExplosion: return "dtExplosion"; case dtExplosion: return "dtExplosion";
} }
// Unknown damage type: // Unknown damage type:
ASSERT(!"Unknown DamageType"); ASSERT(!"Unknown DamageType");
return Printf("dtUnknown_%d", static_cast<int>(a_DamageType)); return Printf("dtUnknown_%d", static_cast<int>(a_DamageType));
@ -410,7 +410,7 @@ eDamageType StringToDamageType(const AString & a_DamageTypeString)
// It was a valid number // It was a valid number
return static_cast<eDamageType>(res); return static_cast<eDamageType>(res);
} }
// Decode using a built-in map: // Decode using a built-in map:
static struct static struct
{ {
@ -467,7 +467,7 @@ eDamageType StringToDamageType(const AString & a_DamageTypeString)
return DamageTypeMap[i].m_DamageType; return DamageTypeMap[i].m_DamageType;
} }
} // for i - DamageTypeMap[] } // for i - DamageTypeMap[]
// Not found: // Not found:
return static_cast<eDamageType>(-1); return static_cast<eDamageType>(-1);
} }

View File

@ -163,7 +163,7 @@ enum BLOCKTYPE
E_BLOCK_TRAPPED_CHEST = 146, E_BLOCK_TRAPPED_CHEST = 146,
E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE = 147, E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE = 147,
E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE = 148, E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE = 148,
E_BLOCK_INACTIVE_COMPARATOR = 149, E_BLOCK_INACTIVE_COMPARATOR = 149,
E_BLOCK_ACTIVE_COMPARATOR = 150, E_BLOCK_ACTIVE_COMPARATOR = 150,
E_BLOCK_DAYLIGHT_SENSOR = 151, E_BLOCK_DAYLIGHT_SENSOR = 151,
@ -174,7 +174,7 @@ enum BLOCKTYPE
E_BLOCK_QUARTZ_BLOCK = 155, E_BLOCK_QUARTZ_BLOCK = 155,
E_BLOCK_QUARTZ_STAIRS = 156, E_BLOCK_QUARTZ_STAIRS = 156,
E_BLOCK_ACTIVATOR_RAIL = 157, E_BLOCK_ACTIVATOR_RAIL = 157,
E_BLOCK_DROPPER = 158, E_BLOCK_DROPPER = 158,
E_BLOCK_STAINED_CLAY = 159, E_BLOCK_STAINED_CLAY = 159,
E_BLOCK_STAINED_GLASS_PANE = 160, E_BLOCK_STAINED_GLASS_PANE = 160,
@ -215,12 +215,12 @@ enum BLOCKTYPE
E_BLOCK_JUNGLE_DOOR = 195, E_BLOCK_JUNGLE_DOOR = 195,
E_BLOCK_ACACIA_DOOR = 196, E_BLOCK_ACACIA_DOOR = 196,
E_BLOCK_DARK_OAK_DOOR = 197, E_BLOCK_DARK_OAK_DOOR = 197,
// Keep these two as the last values. Update the last block value when adding another block // Keep these two as the last values. Update the last block value when adding another block
// IsValidBlock() depends on this // IsValidBlock() depends on this
E_BLOCK_NUMBER_OF_TYPES = E_BLOCK_DARK_OAK_DOOR + 1, ///< Number of individual (different) blocktypes E_BLOCK_NUMBER_OF_TYPES = E_BLOCK_DARK_OAK_DOOR + 1, ///< Number of individual (different) blocktypes
E_BLOCK_MAX_TYPE_ID = E_BLOCK_NUMBER_OF_TYPES - 1, ///< Maximum BlockType number used E_BLOCK_MAX_TYPE_ID = E_BLOCK_NUMBER_OF_TYPES - 1, ///< Maximum BlockType number used
// Synonym or ID compatibility // Synonym or ID compatibility
E_BLOCK_YELLOW_FLOWER = E_BLOCK_DANDELION, E_BLOCK_YELLOW_FLOWER = E_BLOCK_DANDELION,
E_BLOCK_RED_ROSE = E_BLOCK_FLOWER, E_BLOCK_RED_ROSE = E_BLOCK_FLOWER,
@ -244,7 +244,7 @@ enum ENUM_ITEM_ID
E_ITEM_EMPTY = -1, E_ITEM_EMPTY = -1,
E_ITEM_FIRST = 256, // First true item type E_ITEM_FIRST = 256, // First true item type
E_ITEM_IRON_SHOVEL = 256, E_ITEM_IRON_SHOVEL = 256,
E_ITEM_IRON_PICKAXE = 257, E_ITEM_IRON_PICKAXE = 257,
E_ITEM_IRON_AXE = 258, E_ITEM_IRON_AXE = 258,
@ -422,7 +422,7 @@ enum ENUM_ITEM_ID
E_ITEM_JUNGLE_DOOR = 429, E_ITEM_JUNGLE_DOOR = 429,
E_ITEM_ACACIA_DOOR = 430, E_ITEM_ACACIA_DOOR = 430,
E_ITEM_DARK_OAK_DOOR = 431, E_ITEM_DARK_OAK_DOOR = 431,
// Keep these two as the last values of the consecutive list, without a number - they will get their correct number assigned automagically by C++ // Keep these two as the last values of the consecutive list, without a number - they will get their correct number assigned automagically by C++
// IsValidItem() depends on this! // IsValidItem() depends on this!
E_ITEM_NUMBER_OF_CONSECUTIVE_TYPES, ///< Number of individual (different) consecutive itemtypes E_ITEM_NUMBER_OF_CONSECUTIVE_TYPES, ///< Number of individual (different) consecutive itemtypes
@ -441,12 +441,12 @@ enum ENUM_ITEM_ID
E_ITEM_WARD_DISC = 2265, E_ITEM_WARD_DISC = 2265,
E_ITEM_11_DISC = 2266, E_ITEM_11_DISC = 2266,
E_ITEM_WAIT_DISC = 2267, E_ITEM_WAIT_DISC = 2267,
// Keep these two as the last values of the disc list, without a number - they will get their correct number assigned automagically by C++ // Keep these two as the last values of the disc list, without a number - they will get their correct number assigned automagically by C++
// IsValidItem() depends on this! // IsValidItem() depends on this!
E_ITEM_LAST_DISC_PLUS_ONE, ///< Useless, really, but needs to be present for the following value E_ITEM_LAST_DISC_PLUS_ONE, ///< Useless, really, but needs to be present for the following value
E_ITEM_LAST_DISC = E_ITEM_LAST_DISC_PLUS_ONE - 1, ///< Maximum disc itemtype number used E_ITEM_LAST_DISC = E_ITEM_LAST_DISC_PLUS_ONE - 1, ///< Maximum disc itemtype number used
E_ITEM_LAST = E_ITEM_LAST_DISC, ///< Maximum valid ItemType E_ITEM_LAST = E_ITEM_LAST_DISC, ///< Maximum valid ItemType
}; };
@ -458,7 +458,7 @@ enum
{ {
// Please keep this list alpha-sorted by the blocktype / itemtype part // Please keep this list alpha-sorted by the blocktype / itemtype part
// then number-sorted for the same block / item // then number-sorted for the same block / item
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Block metas: // Block metas:
@ -516,19 +516,19 @@ enum
E_META_CARPET_GREEN = 13, E_META_CARPET_GREEN = 13,
E_META_CARPET_RED = 14, E_META_CARPET_RED = 14,
E_META_CARPET_BLACK = 15, E_META_CARPET_BLACK = 15,
// E_BLOCK_CHEST metas: // E_BLOCK_CHEST metas:
E_META_CHEST_FACING_ZM = 2, E_META_CHEST_FACING_ZM = 2,
E_META_CHEST_FACING_ZP = 3, E_META_CHEST_FACING_ZP = 3,
E_META_CHEST_FACING_XM = 4, E_META_CHEST_FACING_XM = 4,
E_META_CHEST_FACING_XP = 5, E_META_CHEST_FACING_XP = 5,
// E_BLOCK_DIRT metas: // E_BLOCK_DIRT metas:
E_META_DIRT_NORMAL = 0, E_META_DIRT_NORMAL = 0,
E_META_DIRT_GRASSLESS = 1, E_META_DIRT_GRASSLESS = 1,
E_META_DIRT_COARSE = 1, E_META_DIRT_COARSE = 1,
E_META_DIRT_PODZOL = 2, E_META_DIRT_PODZOL = 2,
// E_BLOCK_DISPENSER / E_BLOCK_DROPPER metas: // E_BLOCK_DISPENSER / E_BLOCK_DROPPER metas:
E_META_DROPSPENSER_FACING_YM = 0, E_META_DROPSPENSER_FACING_YM = 0,
E_META_DROPSPENSER_FACING_YP = 1, E_META_DROPSPENSER_FACING_YP = 1,
@ -549,7 +549,7 @@ enum
E_META_DOUBLE_STONE_SLAB_SMOOTH_STONE = 8, E_META_DOUBLE_STONE_SLAB_SMOOTH_STONE = 8,
E_META_DOUBLE_STONE_SLAB_SMOOTH_SANDSTONE = 9, E_META_DOUBLE_STONE_SLAB_SMOOTH_SANDSTONE = 9,
E_META_DOUBLE_STONE_SLAB_TILE_QUARTZ = 10, E_META_DOUBLE_STONE_SLAB_TILE_QUARTZ = 10,
// E_BLOCK_FLOWER metas: // E_BLOCK_FLOWER metas:
E_META_FLOWER_POPPY = 0, E_META_FLOWER_POPPY = 0,
E_META_FLOWER_BLUE_ORCHID = 1, E_META_FLOWER_BLUE_ORCHID = 1,
@ -559,11 +559,11 @@ enum
E_META_FLOWER_WHITE_TULIP = 6, E_META_FLOWER_WHITE_TULIP = 6,
E_META_FLOWER_PINK_TULIP = 7, E_META_FLOWER_PINK_TULIP = 7,
E_META_FLOWER_OXEYE_DAISY = 8, E_META_FLOWER_OXEYE_DAISY = 8,
// E_BLOCK_JUKEBOX metas: // E_BLOCK_JUKEBOX metas:
E_META_JUKEBOX_OFF = 0, E_META_JUKEBOX_OFF = 0,
E_META_JUKEBOX_ON = 1, E_META_JUKEBOX_ON = 1,
// E_BLOCK_HOPPER metas: // E_BLOCK_HOPPER metas:
E_META_HOPPER_FACING_YM = 0, E_META_HOPPER_FACING_YM = 0,
E_META_HOPPER_UNATTACHED = 1, // Hopper doesn't move items up, there's no YP E_META_HOPPER_UNATTACHED = 1, // Hopper doesn't move items up, there's no YP
@ -593,21 +593,21 @@ enum
E_META_NEWLEAVES_DARK_OAK_NO_DECAY = 5, E_META_NEWLEAVES_DARK_OAK_NO_DECAY = 5,
E_META_NEWLEAVES_ACACIA_CHECK_DECAY = 8, E_META_NEWLEAVES_ACACIA_CHECK_DECAY = 8,
E_META_NEWLEAVES_DARK_OAK_CHECK_DECAY = 9, E_META_NEWLEAVES_DARK_OAK_CHECK_DECAY = 9,
// E_BLOCK_LOG metas: // E_BLOCK_LOG metas:
E_META_LOG_APPLE = 0, E_META_LOG_APPLE = 0,
E_META_LOG_CONIFER = 1, E_META_LOG_CONIFER = 1,
E_META_LOG_BIRCH = 2, E_META_LOG_BIRCH = 2,
E_META_LOG_JUNGLE = 3, E_META_LOG_JUNGLE = 3,
// E_BLOCK_NEW_LEAVES metas: // E_BLOCK_NEW_LEAVES metas:
E_META_NEW_LEAVES_ACACIA_WOOD = 0, E_META_NEW_LEAVES_ACACIA_WOOD = 0,
E_META_NEW_LEAVES_DARK_OAK_WOOD = 1, E_META_NEW_LEAVES_DARK_OAK_WOOD = 1,
// E_BLOCK_NEW_LOG metas: // E_BLOCK_NEW_LOG metas:
E_META_NEW_LOG_ACACIA_WOOD = 0, E_META_NEW_LOG_ACACIA_WOOD = 0,
E_META_NEW_LOG_DARK_OAK_WOOD = 1, E_META_NEW_LOG_DARK_OAK_WOOD = 1,
// E_BLOCK_PISTON metas: // E_BLOCK_PISTON metas:
E_META_PISTON_DOWN = 0, E_META_PISTON_DOWN = 0,
E_META_PISTON_U = 1, E_META_PISTON_U = 1,
@ -629,12 +629,12 @@ enum
// E_BLOCK_(XXX_WEIGHTED)_PRESSURE_PLATE metas: // E_BLOCK_(XXX_WEIGHTED)_PRESSURE_PLATE metas:
E_META_PRESSURE_PLATE_RAISED = 0, E_META_PRESSURE_PLATE_RAISED = 0,
E_META_PRESSURE_PLATE_DEPRESSED = 1, E_META_PRESSURE_PLATE_DEPRESSED = 1,
// E_BLOCK_PRISMARINE_BLOCK metas: // E_BLOCK_PRISMARINE_BLOCK metas:
E_META_PRISMARINE_BLOCK_ROUGH = 0, E_META_PRISMARINE_BLOCK_ROUGH = 0,
E_META_PRISMARINE_BLOCK_BRICKS = 1, E_META_PRISMARINE_BLOCK_BRICKS = 1,
E_META_PRISMARINE_BLOCK_DARK = 2, E_META_PRISMARINE_BLOCK_DARK = 2,
// E_BLOCK_QUARTZ_BLOCK metas: // E_BLOCK_QUARTZ_BLOCK metas:
E_META_QUARTZ_NORMAL = 0, E_META_QUARTZ_NORMAL = 0,
E_META_QUARTZ_CHISELLED = 1, E_META_QUARTZ_CHISELLED = 1,
@ -651,21 +651,21 @@ enum
E_META_RAIL_CURVED_ZP_XM = 7, E_META_RAIL_CURVED_ZP_XM = 7,
E_META_RAIL_CURVED_ZM_XM = 8, E_META_RAIL_CURVED_ZM_XM = 8,
E_META_RAIL_CURVED_ZM_XP = 9, E_META_RAIL_CURVED_ZM_XP = 9,
// E_BLOCK_RED_SANDSTONE metas: // E_BLOCK_RED_SANDSTONE metas:
E_META_RED_SANDSTONE_NORMAL = 0, E_META_RED_SANDSTONE_NORMAL = 0,
E_META_RED_SANDSTONE_ORNAMENT = 1, E_META_RED_SANDSTONE_ORNAMENT = 1,
E_META_RED_SANDSTONE_SMOOTH = 2, E_META_RED_SANDSTONE_SMOOTH = 2,
// E_BLOCK_SAND metas: // E_BLOCK_SAND metas:
E_META_SAND_NORMAL = 0, E_META_SAND_NORMAL = 0,
E_META_SAND_RED = 1, E_META_SAND_RED = 1,
// E_BLOCK_SANDSTONE metas: // E_BLOCK_SANDSTONE metas:
E_META_SANDSTONE_NORMAL = 0, E_META_SANDSTONE_NORMAL = 0,
E_META_SANDSTONE_ORNAMENT = 1, E_META_SANDSTONE_ORNAMENT = 1,
E_META_SANDSTONE_SMOOTH = 2, E_META_SANDSTONE_SMOOTH = 2,
// E_BLOCK_SAPLING metas (lowest 3 bits): // E_BLOCK_SAPLING metas (lowest 3 bits):
E_META_SAPLING_APPLE = 0, E_META_SAPLING_APPLE = 0,
E_META_SAPLING_CONIFER = 1, E_META_SAPLING_CONIFER = 1,
@ -673,12 +673,12 @@ enum
E_META_SAPLING_JUNGLE = 3, E_META_SAPLING_JUNGLE = 3,
E_META_SAPLING_ACACIA = 4, E_META_SAPLING_ACACIA = 4,
E_META_SAPLING_DARK_OAK = 5, E_META_SAPLING_DARK_OAK = 5,
// E_BLOCK_SILVERFISH_EGG metas: // E_BLOCK_SILVERFISH_EGG metas:
E_META_SILVERFISH_EGG_STONE = 0, E_META_SILVERFISH_EGG_STONE = 0,
E_META_SILVERFISH_EGG_COBBLESTONE = 1, E_META_SILVERFISH_EGG_COBBLESTONE = 1,
E_META_SILVERFISH_EGG_STONE_BRICK = 2, E_META_SILVERFISH_EGG_STONE_BRICK = 2,
// E_BLOCK_SNOW metas: // E_BLOCK_SNOW metas:
E_META_SNOW_LAYER_ONE = 0, E_META_SNOW_LAYER_ONE = 0,
E_META_SNOW_LAYER_TWO = 1, E_META_SNOW_LAYER_TWO = 1,
@ -706,7 +706,7 @@ enum
E_META_STAINED_CLAY_GREEN = 13, E_META_STAINED_CLAY_GREEN = 13,
E_META_STAINED_CLAY_RED = 14, E_META_STAINED_CLAY_RED = 14,
E_META_STAINED_CLAY_BLACK = 15, E_META_STAINED_CLAY_BLACK = 15,
// E_BLOCK_STAINED_GLASS metas: // E_BLOCK_STAINED_GLASS metas:
E_META_STAINED_GLASS_WHITE = 0, E_META_STAINED_GLASS_WHITE = 0,
E_META_STAINED_GLASS_ORANGE = 1, E_META_STAINED_GLASS_ORANGE = 1,
@ -724,7 +724,7 @@ enum
E_META_STAINED_GLASS_GREEN = 13, E_META_STAINED_GLASS_GREEN = 13,
E_META_STAINED_GLASS_RED = 14, E_META_STAINED_GLASS_RED = 14,
E_META_STAINED_GLASS_BLACK = 15, E_META_STAINED_GLASS_BLACK = 15,
// E_BLOCK_STAINED_GLASS_PANE metas: // E_BLOCK_STAINED_GLASS_PANE metas:
E_META_STAINED_GLASS_PANE_WHITE = 0, E_META_STAINED_GLASS_PANE_WHITE = 0,
E_META_STAINED_GLASS_PANE_ORANGE = 1, E_META_STAINED_GLASS_PANE_ORANGE = 1,
@ -768,19 +768,19 @@ enum
E_META_STONE_SLAB_STONE_BRICK = 5, E_META_STONE_SLAB_STONE_BRICK = 5,
E_META_STONE_SLAB_NETHER_BRICK = 6, E_META_STONE_SLAB_NETHER_BRICK = 6,
E_META_STONE_SLAB_QUARTZ = 7, E_META_STONE_SLAB_QUARTZ = 7,
// E_BLOCK_STONE_BRICKS metas: // E_BLOCK_STONE_BRICKS metas:
E_META_STONE_BRICK_NORMAL = 0, E_META_STONE_BRICK_NORMAL = 0,
E_META_STONE_BRICK_MOSSY = 1, E_META_STONE_BRICK_MOSSY = 1,
E_META_STONE_BRICK_CRACKED = 2, E_META_STONE_BRICK_CRACKED = 2,
E_META_STONE_BRICK_ORNAMENT = 3, E_META_STONE_BRICK_ORNAMENT = 3,
// E_BLOCK_TALL_GRASS metas: // E_BLOCK_TALL_GRASS metas:
E_META_TALL_GRASS_DEAD_SHRUB = 0, E_META_TALL_GRASS_DEAD_SHRUB = 0,
E_META_TALL_GRASS_GRASS = 1, E_META_TALL_GRASS_GRASS = 1,
E_META_TALL_GRASS_FERN = 2, E_META_TALL_GRASS_FERN = 2,
E_META_TALL_GRASS_BIOME = 3, E_META_TALL_GRASS_BIOME = 3,
// E_BLOCK_TORCH, E_BLOCK_REDSTONE_TORCH_OFF, E_BLOCK_REDSTONE_TORCH_ON metas: // E_BLOCK_TORCH, E_BLOCK_REDSTONE_TORCH_OFF, E_BLOCK_REDSTONE_TORCH_ON metas:
E_META_TORCH_EAST = 1, // east face of the block, pointing east E_META_TORCH_EAST = 1, // east face of the block, pointing east
E_META_TORCH_WEST = 2, E_META_TORCH_WEST = 2,
@ -827,7 +827,7 @@ enum
E_META_WOODEN_DOUBLE_SLAB_JUNGLE = 3, E_META_WOODEN_DOUBLE_SLAB_JUNGLE = 3,
E_META_WOODEN_DOUBLE_SLAB_ACACIA = 4, E_META_WOODEN_DOUBLE_SLAB_ACACIA = 4,
E_META_WOODEN_DOUBLE_SLAB_DARK_OAK = 5, E_META_WOODEN_DOUBLE_SLAB_DARK_OAK = 5,
// E_BLOCK_WOODEN_SLAB metas: // E_BLOCK_WOODEN_SLAB metas:
E_META_WOODEN_SLAB_OAK = 0, E_META_WOODEN_SLAB_OAK = 0,
E_META_WOODEN_SLAB_SPRUCE = 1, E_META_WOODEN_SLAB_SPRUCE = 1,
@ -854,10 +854,10 @@ enum
E_META_WOOL_GREEN = 13, E_META_WOOL_GREEN = 13,
E_META_WOOL_RED = 14, E_META_WOOL_RED = 14,
E_META_WOOL_BLACK = 15, E_META_WOOL_BLACK = 15,
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Item metas: // Item metas:
// E_ITEM_BANNER metas: // E_ITEM_BANNER metas:
E_META_BANNER_BLACK = 0, E_META_BANNER_BLACK = 0,
E_META_BANNER_RED = 1, E_META_BANNER_RED = 1,
@ -875,11 +875,11 @@ enum
E_META_BANNER_MAGENTA = 13, E_META_BANNER_MAGENTA = 13,
E_META_BANNER_ORANGE = 14, E_META_BANNER_ORANGE = 14,
E_META_BANNER_WHITE = 15, E_META_BANNER_WHITE = 15,
// E_ITEM_COAL metas: // E_ITEM_COAL metas:
E_META_COAL_NORMAL = 0, E_META_COAL_NORMAL = 0,
E_META_COAL_CHARCOAL = 1, E_META_COAL_CHARCOAL = 1,
// E_ITEM_DYE metas: // E_ITEM_DYE metas:
E_META_DYE_BLACK = 0, E_META_DYE_BLACK = 0,
E_META_DYE_RED = 1, E_META_DYE_RED = 1,
@ -901,20 +901,20 @@ enum
// E_ITEM_GOLDEN_APPLE metas: // E_ITEM_GOLDEN_APPLE metas:
E_META_GOLDEN_APPLE_NORMAL = 0, E_META_GOLDEN_APPLE_NORMAL = 0,
E_META_GOLDEN_APPLE_ENCHANTED = 1, E_META_GOLDEN_APPLE_ENCHANTED = 1,
// E_ITEM_HEAD metas: // E_ITEM_HEAD metas:
E_META_HEAD_SKELETON = 0, E_META_HEAD_SKELETON = 0,
E_META_HEAD_WITHER = 1, E_META_HEAD_WITHER = 1,
E_META_HEAD_ZOMBIE = 2, E_META_HEAD_ZOMBIE = 2,
E_META_HEAD_PLAYER = 3, E_META_HEAD_PLAYER = 3,
E_META_HEAD_CREEPER = 4, E_META_HEAD_CREEPER = 4,
// E_ITEM_RAW_FISH metas: // E_ITEM_RAW_FISH metas:
E_META_RAW_FISH_FISH = 0, E_META_RAW_FISH_FISH = 0,
E_META_RAW_FISH_SALMON = 1, E_META_RAW_FISH_SALMON = 1,
E_META_RAW_FISH_CLOWNFISH = 2, E_META_RAW_FISH_CLOWNFISH = 2,
E_META_RAW_FISH_PUFFERFISH = 3, E_META_RAW_FISH_PUFFERFISH = 3,
// E_ITEM_COOKED_FISH metas: // E_ITEM_COOKED_FISH metas:
E_META_COOKED_FISH_FISH = 0, E_META_COOKED_FISH_FISH = 0,
E_META_COOKED_FISH_SALMON = 1, E_META_COOKED_FISH_SALMON = 1,
@ -922,7 +922,7 @@ enum
// E_ITEM_MINECART_TRACKS metas: // E_ITEM_MINECART_TRACKS metas:
E_META_TRACKS_X = 1, E_META_TRACKS_X = 1,
E_META_TRACKS_Z = 0, E_META_TRACKS_Z = 0,
// E_ITEM_SPAWN_EGG metas: // E_ITEM_SPAWN_EGG metas:
// See also cMonster::eType, since monster type and spawn egg meta are the same // See also cMonster::eType, since monster type and spawn egg meta are the same
E_META_SPAWN_EGG_PICKUP = 1, E_META_SPAWN_EGG_PICKUP = 1,
@ -1022,7 +1022,7 @@ enum eDamageType
dtEnderPearl, // Thrown an ender pearl, teleported by it dtEnderPearl, // Thrown an ender pearl, teleported by it
dtAdmin, // Damage applied by an admin command dtAdmin, // Damage applied by an admin command
dtExplosion, // Damage applied by an explosion dtExplosion, // Damage applied by an explosion
// Some common synonyms: // Some common synonyms:
dtPawnAttack = dtAttack, dtPawnAttack = dtAttack,
dtEntityAttack = dtAttack, dtEntityAttack = dtAttack,

View File

@ -17,7 +17,7 @@ class cBlockInfo
public: public:
/** Returns the associated BlockInfo structure for the specified block type. */ /** Returns the associated BlockInfo structure for the specified block type. */
/** This accessor makes sure that the cBlockInfo structures are properly initialized exactly once. /** This accessor makes sure that the cBlockInfo structures are properly initialized exactly once.
It does so by using the C++ singleton approximation - storing the actual singleton as the function's static variable. It does so by using the C++ singleton approximation - storing the actual singleton as the function's static variable.
It works only if it is called for the first time before the app spawns other threads. */ It works only if it is called for the first time before the app spawns other threads. */

View File

@ -30,12 +30,12 @@ public:
public: public:
// Force a virtual destructor in descendants: // Force a virtual destructor in descendants:
virtual ~cCallbacks() {} virtual ~cCallbacks() {}
/** Called on each block encountered along the path, including the first block (path start) /** Called on each block encountered along the path, including the first block (path start)
When this callback returns true, the tracing is aborted. When this callback returns true, the tracing is aborted.
*/ */
virtual bool OnNextBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, char a_EntryFace) = 0; virtual bool OnNextBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, char a_EntryFace) = 0;
/** Called on each block encountered along the path, including the first block (path start), if chunk data is not loaded /** Called on each block encountered along the path, including the first block (path start), if chunk data is not loaded
When this callback returns true, the tracing is aborted. When this callback returns true, the tracing is aborted.
*/ */
@ -47,7 +47,7 @@ public:
UNUSED(a_EntryFace); UNUSED(a_EntryFace);
return false; return false;
} }
/** Called when the path goes out of world, either below (a_BlockY < 0) or above (a_BlockY >= cChunkDef::Height) /** Called when the path goes out of world, either below (a_BlockY < 0) or above (a_BlockY >= cChunkDef::Height)
The coords specify the exact point at which the path exited the world. The coords specify the exact point at which the path exited the world.
If this callback returns true, the tracing is aborted. If this callback returns true, the tracing is aborted.
@ -61,7 +61,7 @@ public:
UNUSED(a_BlockZ); UNUSED(a_BlockZ);
return false; return false;
} }
/** Called when the path goes into the world, from either below (a_BlockY < 0) or above (a_BlockY >= cChunkDef::Height) /** Called when the path goes into the world, from either below (a_BlockY < 0) or above (a_BlockY >= cChunkDef::Height)
The coords specify the exact point at which the path entered the world. The coords specify the exact point at which the path entered the world.
If this callback returns true, the tracing is aborted. If this callback returns true, the tracing is aborted.
@ -75,27 +75,27 @@ public:
UNUSED(a_BlockZ); UNUSED(a_BlockZ);
return false; return false;
} }
/** Called when the path is sure not to hit any more blocks. /** Called when the path is sure not to hit any more blocks.
Note that for some shapes this might never happen (line with constant Y) Note that for some shapes this might never happen (line with constant Y)
*/ */
virtual void OnNoMoreHits(void) {} virtual void OnNoMoreHits(void) {}
/** Called when the block tracing walks into a chunk that is not allocated. /** Called when the block tracing walks into a chunk that is not allocated.
This usually means that the tracing is aborted. This usually means that the tracing is aborted.
*/ */
virtual void OnNoChunk(void) {} virtual void OnNoChunk(void) {}
} ; } ;
/** Creates the BlockTracer parent with the specified callbacks */ /** Creates the BlockTracer parent with the specified callbacks */
cBlockTracer(cWorld & a_World, cCallbacks & a_Callbacks) : cBlockTracer(cWorld & a_World, cCallbacks & a_Callbacks) :
m_World(&a_World), m_World(&a_World),
m_Callbacks(&a_Callbacks) m_Callbacks(&a_Callbacks)
{ {
} }
/** Sets new world, returns the old one. Note that both need to be valid */ /** Sets new world, returns the old one. Note that both need to be valid */
cWorld & SetWorld(cWorld & a_World) cWorld & SetWorld(cWorld & a_World)
{ {
@ -103,8 +103,8 @@ public:
m_World = &a_World; m_World = &a_World;
return Old; return Old;
} }
/** Sets new callbacks, returns the old ones. Note that both need to be valid */ /** Sets new callbacks, returns the old ones. Note that both need to be valid */
cCallbacks & SetCallbacks(cCallbacks & a_NewCallbacks) cCallbacks & SetCallbacks(cCallbacks & a_NewCallbacks)
{ {
@ -112,11 +112,11 @@ public:
m_Callbacks = &a_NewCallbacks; m_Callbacks = &a_NewCallbacks;
return Old; return Old;
} }
protected: protected:
/** The world upon which to operate */ /** The world upon which to operate */
cWorld * m_World; cWorld * m_World;
/** The callback to use for reporting */ /** The callback to use for reporting */
cCallbacks * m_Callbacks; cCallbacks * m_Callbacks;
} ; } ;

View File

@ -18,7 +18,7 @@ public:
: cBlockHandler(a_BlockType) : cBlockHandler(a_BlockType)
{ {
} }
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{ {
a_Pickups.push_back(cItem(E_BLOCK_ANVIL, 1, a_BlockMeta >> 2)); a_Pickups.push_back(cItem(E_BLOCK_ANVIL, 1, a_BlockMeta >> 2));
@ -30,7 +30,7 @@ public:
a_Player->OpenWindow(Window); a_Player->OpenWindow(Window);
return true; return true;
} }
virtual bool GetPlacementBlockTypeMeta( virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player, cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,

View File

@ -21,7 +21,7 @@ public:
: cMetaRotator<cBlockHandler, 0x3, 0x02, 0x03, 0x00, 0x01, true>(a_BlockType) : cMetaRotator<cBlockHandler, 0x3, 0x02, 0x03, 0x00, 0x01, true>(a_BlockType)
{ {
} }
virtual void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ) override; virtual void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ) override;
virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override; virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override;
@ -29,7 +29,7 @@ public:
{ {
return true; return true;
} }
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{ {
// Reset meta to zero // Reset meta to zero

View File

@ -34,12 +34,12 @@ public:
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{ {
NIBBLETYPE Meta = a_BlockMeta & 0x7; NIBBLETYPE Meta = a_BlockMeta & 0x7;
if ((Meta == E_META_BIG_FLOWER_DOUBLE_TALL_GRASS) || (Meta == E_META_BIG_FLOWER_LARGE_FERN)) if ((Meta == E_META_BIG_FLOWER_DOUBLE_TALL_GRASS) || (Meta == E_META_BIG_FLOWER_LARGE_FERN))
{ {
return; return;
} }
a_Pickups.push_back(cItem(E_BLOCK_BIG_FLOWER, 1, Meta)); a_Pickups.push_back(cItem(E_BLOCK_BIG_FLOWER, 1, Meta));
} }
@ -50,7 +50,7 @@ public:
{ {
Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY - 1, a_BlockZ); Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY - 1, a_BlockZ);
} }
NIBBLETYPE FlowerMeta = Meta & 0x7; NIBBLETYPE FlowerMeta = Meta & 0x7;
if (!a_Player->IsGameModeCreative()) if (!a_Player->IsGameModeCreative())
{ {

View File

@ -15,11 +15,11 @@ public:
: cMetaRotator<cBlockHandler, 0x07, 0x04, 0x01, 0x03, 0x02, true>(a_BlockType) : cMetaRotator<cBlockHandler, 0x07, 0x04, 0x01, 0x03, 0x02, true>(a_BlockType)
{ {
} }
virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
{ {
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
double x(a_BlockX); double x(a_BlockX);
double y(a_BlockY); double y(a_BlockY);
double z(a_BlockZ); double z(a_BlockZ);
@ -53,7 +53,7 @@ public:
return true; return true;
} }
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{ {
// Reset meta to 0 // Reset meta to 0
@ -64,7 +64,7 @@ public:
{ {
return true; return true;
} }
virtual bool GetPlacementBlockTypeMeta( virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player, cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,

View File

@ -14,7 +14,7 @@ public:
: cBlockHandler(a_BlockType) : cBlockHandler(a_BlockType)
{ {
} }
virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
{ {
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
@ -23,7 +23,7 @@ public:
{ {
return false; return false;
} }
if (Meta >= 5) if (Meta >= 5)
{ {
a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0); a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);

View File

@ -22,7 +22,7 @@ public:
cBlockHandler(a_BlockType) cBlockHandler(a_BlockType)
{ {
} }
virtual bool GetPlacementBlockTypeMeta( virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player, cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
@ -34,7 +34,7 @@ public:
a_BlockMeta = a_Player->GetEquippedItem().m_ItemDamage & 0x0f; a_BlockMeta = a_Player->GetEquippedItem().m_ItemDamage & 0x0f;
return true; return true;
} }
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{ {
a_Pickups.push_back(cItem(E_BLOCK_CARPET, 1, a_BlockMeta)); a_Pickups.push_back(cItem(E_BLOCK_CARPET, 1, a_BlockMeta));

View File

@ -18,7 +18,7 @@ public:
: cMetaRotator<cBlockEntityHandler, 0x07, 0x02, 0x05, 0x03, 0x04>(a_BlockType) : cMetaRotator<cBlockEntityHandler, 0x07, 0x02, 0x05, 0x03, 0x04>(a_BlockType)
{ {
} }
virtual bool GetPlacementBlockTypeMeta( virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player, cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
@ -27,14 +27,14 @@ public:
) override ) override
{ {
a_BlockType = m_BlockType; a_BlockType = m_BlockType;
// Is there a doublechest already next to this block? // Is there a doublechest already next to this block?
if (!CanBeAt(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ)) if (!CanBeAt(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ))
{ {
// Yup, cannot form a triple-chest, refuse: // Yup, cannot form a triple-chest, refuse:
return false; return false;
} }
// Check if this forms a doublechest, if so, need to adjust the meta: // Check if this forms a doublechest, if so, need to adjust the meta:
cBlockArea Area; cBlockArea Area;
if (!Area.Read(&a_ChunkInterface, a_BlockX - 1, a_BlockX + 1, a_BlockY, a_BlockY, a_BlockZ - 1, a_BlockZ + 1)) if (!Area.Read(&a_ChunkInterface, a_BlockX - 1, a_BlockX + 1, a_BlockY, a_BlockY, a_BlockZ - 1, a_BlockZ + 1))
@ -59,7 +59,7 @@ public:
a_BlockMeta = (yaw < 0) ? 4 : 5; a_BlockMeta = (yaw < 0) ? 4 : 5;
return true; return true;
} }
// Single chest, get meta from rotation only // Single chest, get meta from rotation only
a_BlockMeta = PlayerYawToMetaData(yaw); a_BlockMeta = PlayerYawToMetaData(yaw);
return true; return true;
@ -71,7 +71,7 @@ public:
int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width; int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
return CanBeAt(a_ChunkInterface, BlockX, a_RelY, BlockZ); return CanBeAt(a_ChunkInterface, BlockX, a_RelY, BlockZ);
} }
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ)
{ {
cBlockArea Area; cBlockArea Area;
@ -80,7 +80,7 @@ public:
// Cannot read the surroundings, probably at the edge of loaded chunks. Disallow. // Cannot read the surroundings, probably at the edge of loaded chunks. Disallow.
return false; return false;
} }
int NumChestNeighbors = 0; int NumChestNeighbors = 0;
if (Area.GetRelBlockType(1, 0, 2) == m_BlockType) if (Area.GetRelBlockType(1, 0, 2) == m_BlockType)
{ {
@ -136,7 +136,7 @@ public:
} }
return (NumChestNeighbors < 2); return (NumChestNeighbors < 2);
} }
/** Translates player yaw when placing a chest into the chest block metadata. Valid for single chests only */ /** Translates player yaw when placing a chest into the chest block metadata. Valid for single chests only */
static NIBBLETYPE PlayerYawToMetaData(double a_Yaw) static NIBBLETYPE PlayerYawToMetaData(double a_Yaw)
{ {
@ -163,7 +163,7 @@ public:
return 0x03; return 0x03;
} }
} }
/** If there's a chest in the a_Area in the specified coords, modifies its meta to a_NewMeta and returns true. */ /** If there's a chest in the a_Area in the specified coords, modifies its meta to a_NewMeta and returns true. */
bool CheckAndAdjustNeighbor(cChunkInterface & a_ChunkInterface, const cBlockArea & a_Area, int a_RelX, int a_RelZ, NIBBLETYPE a_NewMeta) bool CheckAndAdjustNeighbor(cChunkInterface & a_ChunkInterface, const cBlockArea & a_Area, int a_RelX, int a_RelZ, NIBBLETYPE a_NewMeta)
{ {

View File

@ -17,7 +17,7 @@ public:
: cMetaRotator<cBlockHandler, 0x03, 0x00, 0x01, 0x02, 0x03, true>(a_BlockType) : cMetaRotator<cBlockHandler, 0x03, 0x00, 0x01, 0x02, 0x03, true>(a_BlockType)
{ {
} }
virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
{ {
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
@ -42,7 +42,7 @@ public:
{ {
return true; return true;
} }
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{ {
return ((a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) != E_BLOCK_AIR)); return ((a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) != E_BLOCK_AIR));

View File

@ -72,7 +72,7 @@ public:
} }
} }
} }
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
{ {
NIBBLETYPE Meta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ); NIBBLETYPE Meta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ);

View File

@ -20,7 +20,7 @@ public:
: cBlockHandler(a_BlockType) : cBlockHandler(a_BlockType)
{ {
} }
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{ {
if (a_BlockMeta == E_META_DIRT_COARSE) if (a_BlockMeta == E_META_DIRT_COARSE)
@ -33,7 +33,7 @@ public:
a_Pickups.Add(E_BLOCK_DIRT, 1, E_META_DIRT_NORMAL); a_Pickups.Add(E_BLOCK_DIRT, 1, E_META_DIRT_NORMAL);
} }
} }
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
{ {
if (m_BlockType != E_BLOCK_GRASS) if (m_BlockType != E_BLOCK_GRASS)
@ -50,21 +50,21 @@ public:
else if ((a_RelY < cChunkDef::Height - 1)) else if ((a_RelY < cChunkDef::Height - 1))
{ {
BLOCKTYPE above = a_Chunk.GetBlock(a_RelX, a_RelY + 1, a_RelZ); BLOCKTYPE above = a_Chunk.GetBlock(a_RelX, a_RelY + 1, a_RelZ);
// Grass turns back to dirt when the block above is not transparent // Grass turns back to dirt when the block above is not transparent
if (!cBlockInfo::IsTransparent(above)) if (!cBlockInfo::IsTransparent(above))
{ {
a_Chunk.FastSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_DIRT, E_META_DIRT_NORMAL); a_Chunk.FastSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_DIRT, E_META_DIRT_NORMAL);
return; return;
} }
NIBBLETYPE light = std::max(a_Chunk.GetBlockLight(a_RelX, a_RelY + 1, a_RelZ), a_Chunk.GetTimeAlteredLight(a_Chunk.GetSkyLight(a_RelX, a_RelY + 1, a_RelZ))); NIBBLETYPE light = std::max(a_Chunk.GetBlockLight(a_RelX, a_RelY + 1, a_RelZ), a_Chunk.GetTimeAlteredLight(a_Chunk.GetSkyLight(a_RelX, a_RelY + 1, a_RelZ)));
// Source block is not bright enough to spread // Source block is not bright enough to spread
if (light < 9) if (light < 9)
{ {
return; return;
} }
} }
// Grass spreads to adjacent dirt blocks: // Grass spreads to adjacent dirt blocks:
@ -74,7 +74,7 @@ public:
int OfsX = rand.NextInt(3) - 1; // [-1 .. 1] int OfsX = rand.NextInt(3) - 1; // [-1 .. 1]
int OfsY = rand.NextInt(5) - 3; // [-3 .. 1] int OfsY = rand.NextInt(5) - 3; // [-3 .. 1]
int OfsZ = rand.NextInt(3) - 1; // [-1 .. 1] int OfsZ = rand.NextInt(3) - 1; // [-1 .. 1]
BLOCKTYPE DestBlock; BLOCKTYPE DestBlock;
NIBBLETYPE DestMeta; NIBBLETYPE DestMeta;
if (!cChunkDef::IsValidHeight(a_RelY + OfsY)) if (!cChunkDef::IsValidHeight(a_RelY + OfsY))

View File

@ -86,10 +86,10 @@ bool cBlockDoorHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterfac
void cBlockDoorHandler::OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) void cBlockDoorHandler::OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace)
{ {
UNUSED(a_ChunkInterface); UNUSED(a_ChunkInterface);
a_WorldInterface.SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, a_Player); a_WorldInterface.SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, a_Player);
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
if (Meta & 0x8) if (Meta & 0x8)
{ {
// Current block is top of the door // Current block is top of the door

View File

@ -46,7 +46,7 @@ public:
{ {
return false; return false;
} }
a_BlockType = m_BlockType; a_BlockType = m_BlockType;
a_BlockMeta = PlayerYawToMetaData(a_Player->GetYaw()); a_BlockMeta = PlayerYawToMetaData(a_Player->GetYaw());
return true; return true;
@ -118,7 +118,7 @@ public:
{ {
// Vanilla refuses to place doors on transparent blocks, except top-half slabs and other doors // Vanilla refuses to place doors on transparent blocks, except top-half slabs and other doors
// We need to keep the door compatible with itself, otherwise the top half drops while the bottom half stays // We need to keep the door compatible with itself, otherwise the top half drops while the bottom half stays
// Doors can be placed on upside-down slabs // Doors can be placed on upside-down slabs
if (cBlockSlabHandler::IsAnySlabType(a_BlockType) && ((a_BlockMeta & 0x08) != 0)) if (cBlockSlabHandler::IsAnySlabType(a_BlockType) && ((a_BlockMeta & 0x08) != 0))
{ {
@ -159,7 +159,7 @@ public:
inline static NIBBLETYPE PlayerYawToMetaData(double a_Yaw) inline static NIBBLETYPE PlayerYawToMetaData(double a_Yaw)
{ {
ASSERT((a_Yaw >= -180) && (a_Yaw < 180)); ASSERT((a_Yaw >= -180) && (a_Yaw < 180));
a_Yaw += 90 + 45; a_Yaw += 90 + 45;
if (a_Yaw > 360) if (a_Yaw > 360)
{ {

View File

@ -29,12 +29,12 @@ public:
) override ) override
{ {
a_BlockType = m_BlockType; a_BlockType = m_BlockType;
// FIXME: Do not use cPiston class for dispenser placement! // FIXME: Do not use cPiston class for dispenser placement!
a_BlockMeta = cBlockPistonHandler::RotationPitchToMetaData(a_Player->GetYaw(), a_Player->GetPitch()); a_BlockMeta = cBlockPistonHandler::RotationPitchToMetaData(a_Player->GetYaw(), a_Player->GetPitch());
return true; return true;
} }
virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) override virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) override
{ {
// Bit 0x08 is a flag. Lowest three bits are position. 0x08 == 1000 // Bit 0x08 is a flag. Lowest three bits are position. 0x08 == 1000

View File

@ -33,7 +33,7 @@ public:
a_BlockMeta = RotationToMetaData(a_Player->GetYaw()); a_BlockMeta = RotationToMetaData(a_Player->GetYaw());
return true; return true;
} }
static NIBBLETYPE RotationToMetaData(double a_Rotation) static NIBBLETYPE RotationToMetaData(double a_Rotation)
{ {
a_Rotation += 90 + 45; // So its not aligned with axis a_Rotation += 90 + 45; // So its not aligned with axis

View File

@ -14,12 +14,12 @@ public:
: cBlockHandler(a_BlockType) : cBlockHandler(a_BlockType)
{ {
} }
virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
{ {
return a_ChunkInterface.UseBlockEntity(a_Player, a_BlockX, a_BlockY, a_BlockZ); return a_ChunkInterface.UseBlockEntity(a_Player, a_BlockX, a_BlockY, a_BlockZ);
} }
virtual bool IsUseable() override virtual bool IsUseable() override
{ {
return true; return true;

View File

@ -68,7 +68,7 @@ public:
inline static NIBBLETYPE PlayerYawToMetaData(double a_Yaw) inline static NIBBLETYPE PlayerYawToMetaData(double a_Yaw)
{ {
ASSERT((a_Yaw >= -180) && (a_Yaw < 180)); ASSERT((a_Yaw >= -180) && (a_Yaw < 180));
a_Yaw += 360 + 45; a_Yaw += 360 + 45;
if (a_Yaw > 360) if (a_Yaw > 360)
{ {

View File

@ -59,7 +59,7 @@ public:
{ {
return 0; return 0;
} }
for (int newY = Y + 1; newY < cChunkDef::Height; newY++) for (int newY = Y + 1; newY < cChunkDef::Height; newY++)
{ {
BLOCKTYPE Block = a_ChunkInterface.GetBlock(X, newY, Z); BLOCKTYPE Block = a_ChunkInterface.GetBlock(X, newY, Z);

View File

@ -11,24 +11,24 @@ class cBlockFluidHandler :
public cBlockHandler public cBlockHandler
{ {
typedef cBlockHandler super; typedef cBlockHandler super;
public: public:
cBlockFluidHandler(BLOCKTYPE a_BlockType) cBlockFluidHandler(BLOCKTYPE a_BlockType)
: cBlockHandler(a_BlockType) : cBlockHandler(a_BlockType)
{ {
} }
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{ {
// No pickups // No pickups
} }
virtual bool DoesIgnoreBuildCollision(void) override virtual bool DoesIgnoreBuildCollision(void) override
{ {
return true; return true;
} }
virtual void Check(cChunkInterface & a_ChunkInterface, cBlockPluginInterface & a_PluginInterface, int a_RelX, int a_RelY, int a_RelZ, cChunk & a_Chunk) override virtual void Check(cChunkInterface & a_ChunkInterface, cBlockPluginInterface & a_PluginInterface, int a_RelX, int a_RelY, int a_RelZ, cChunk & a_Chunk) override
{ {
switch (m_BlockType) switch (m_BlockType)
@ -84,7 +84,7 @@ public:
super(a_BlockType) super(a_BlockType)
{ {
} }
/** Called to tick the block */ /** Called to tick the block */
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
{ {
@ -97,7 +97,7 @@ public:
} }
} }
} }
/** Tries to start a fire near the lava at given coords. Returns true if fire started. */ /** Tries to start a fire near the lava at given coords. Returns true if fire started. */
static bool TryStartFireNear(int a_RelX, int a_RelY, int a_RelZ, cChunk & a_Chunk) static bool TryStartFireNear(int a_RelX, int a_RelY, int a_RelZ, cChunk & a_Chunk)
{ {
@ -106,7 +106,7 @@ public:
int x = (rnd % 3) - 1; // -1 .. 1 int x = (rnd % 3) - 1; // -1 .. 1
int y = ((rnd / 4) % 4) - 1; // -1 .. 2 int y = ((rnd / 4) % 4) - 1; // -1 .. 2
int z = ((rnd / 16) % 3) - 1; // -1 .. 1 int z = ((rnd / 16) % 3) - 1; // -1 .. 1
// Check if it's fuel: // Check if it's fuel:
BLOCKTYPE BlockType; BLOCKTYPE BlockType;
if ( if (
@ -117,7 +117,7 @@ public:
{ {
return false; return false;
} }
// Try to set it on fire: // Try to set it on fire:
static struct static struct
{ {

View File

@ -22,7 +22,7 @@ public:
{ {
a_Pickups.push_back(cItem(E_BLOCK_FURNACE, 1, 0)); a_Pickups.push_back(cItem(E_BLOCK_FURNACE, 1, 0));
} }
virtual bool GetPlacementBlockTypeMeta( virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player, cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
@ -31,10 +31,10 @@ public:
) override ) override
{ {
a_BlockType = m_BlockType; a_BlockType = m_BlockType;
// FIXME: Do not use cPiston class for furnace placement! // FIXME: Do not use cPiston class for furnace placement!
a_BlockMeta = cBlockPistonHandler::RotationPitchToMetaData(a_Player->GetYaw(), 0); a_BlockMeta = cBlockPistonHandler::RotationPitchToMetaData(a_Player->GetYaw(), 0);
return true; return true;
} }

View File

@ -136,7 +136,7 @@ public:
// CW rotation of a CCW rotation should produce no change in the meta // CW rotation of a CCW rotation should produce no change in the meta
printf("Handler for blocktype %d (%s) fails CW(CCW) rotation test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta); printf("Handler for blocktype %d (%s) fails CW(CCW) rotation test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta);
} }
// Test the mirroring: // Test the mirroring:
TestMeta = Handler->MetaMirrorXY(Handler->MetaMirrorXY(Meta)); TestMeta = Handler->MetaMirrorXY(Handler->MetaMirrorXY(Meta));
if (TestMeta != Meta) if (TestMeta != Meta)
@ -156,7 +156,7 @@ public:
// Double-mirroring should produce the same meta: // Double-mirroring should produce the same meta:
printf("Handler for blocktype %d (%s) fails YZ mirror test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta); printf("Handler for blocktype %d (%s) fails YZ mirror test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta);
} }
// Test mirror-rotating: // Test mirror-rotating:
TestMeta = Handler->MetaRotateCW(Handler->MetaRotateCW(Handler->MetaMirrorXY(Handler->MetaMirrorYZ(Meta)))); TestMeta = Handler->MetaRotateCW(Handler->MetaRotateCW(Handler->MetaMirrorXY(Handler->MetaMirrorYZ(Meta))));
if (TestMeta != Meta) if (TestMeta != Meta)
@ -331,7 +331,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_WOOL: return new cBlockClothHandler (a_BlockType); case E_BLOCK_WOOL: return new cBlockClothHandler (a_BlockType);
case E_BLOCK_WORKBENCH: return new cBlockWorkbenchHandler (a_BlockType); case E_BLOCK_WORKBENCH: return new cBlockWorkbenchHandler (a_BlockType);
case E_BLOCK_YELLOW_FLOWER: return new cBlockFlowerHandler (a_BlockType); case E_BLOCK_YELLOW_FLOWER: return new cBlockFlowerHandler (a_BlockType);
default: return new cBlockHandler(a_BlockType); default: return new cBlockHandler(a_BlockType);
} }
} }
@ -512,7 +512,7 @@ void cBlockHandler::DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterfac
// Allow plugins to modify the pickups: // Allow plugins to modify the pickups:
a_BlockPluginInterface.CallHookBlockToPickups(a_Digger, a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta, Pickups); a_BlockPluginInterface.CallHookBlockToPickups(a_Digger, a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta, Pickups);
if (!Pickups.empty()) if (!Pickups.empty())
{ {
MTRand r1; MTRand r1;
@ -600,7 +600,7 @@ void cBlockHandler::Check(cChunkInterface & a_ChunkInterface, cBlockPluginInterf
int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width; int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
DropBlock(a_ChunkInterface, *a_Chunk.GetWorld(), a_PluginInterface, nullptr, BlockX, a_RelY, BlockZ); DropBlock(a_ChunkInterface, *a_Chunk.GetWorld(), a_PluginInterface, nullptr, BlockX, a_RelY, BlockZ);
} }
a_Chunk.SetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_AIR, 0); a_Chunk.SetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_AIR, 0);
} }
else else

View File

@ -23,7 +23,7 @@ class cBlockHandler
{ {
public: public:
cBlockHandler(BLOCKTYPE a_BlockType); cBlockHandler(BLOCKTYPE a_BlockType);
virtual ~cBlockHandler() {} virtual ~cBlockHandler() {}
/** Called when the block gets ticked either by a random tick or by a queued tick. /** Called when the block gets ticked either by a random tick or by a queued tick.
@ -43,71 +43,71 @@ public:
/** Called by cWorld::SetBlock() after the block has been set */ /** Called by cWorld::SetBlock() after the block has been set */
virtual void OnPlaced(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); virtual void OnPlaced(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
/** Called by cPlayer::PlaceBlocks() for each block after it has been set to the world. Called after OnPlaced(). */ /** Called by cPlayer::PlaceBlocks() for each block after it has been set to the world. Called after OnPlaced(). */
virtual void OnPlacedByPlayer( virtual void OnPlacedByPlayer(
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, const sSetBlock & a_BlockChange cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, const sSetBlock & a_BlockChange
); );
/** Called before the player has destroyed a block */ /** Called before the player has destroyed a block */
virtual void OnDestroyedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ); virtual void OnDestroyedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ);
/** Called before a block gets destroyed / replaced with air */ /** Called before a block gets destroyed / replaced with air */
virtual void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ); virtual void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ);
/** Called when a direct neighbor of this block has been changed (The position is the block's own position, not the changing neighbor's position) /** Called when a direct neighbor of this block has been changed (The position is the block's own position, not the changing neighbor's position)
a_WhichNeighbor indicates which neighbor has changed. For example, BLOCK_FACE_YP meant the neighbor above has changed. a_WhichNeighbor indicates which neighbor has changed. For example, BLOCK_FACE_YP meant the neighbor above has changed.
BLOCK_FACE_NONE means that it is a neighbor not directly adjacent (diagonal, etc.) */ BLOCK_FACE_NONE means that it is a neighbor not directly adjacent (diagonal, etc.) */
virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_WhichNeighbor) {} virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_WhichNeighbor) {}
/** Notifies the specified neighbor that the current block has changed. /** Notifies the specified neighbor that the current block has changed.
a_NeighborXYZ coords are the coords of the neighbor a_NeighborXYZ coords are the coords of the neighbor
a_WhichNeighbor specifies which neighbor (relative to a_NeighborXYZ) has changed. a_WhichNeighbor specifies which neighbor (relative to a_NeighborXYZ) has changed.
For example BLOCK_FACE_YP means that the block at {a_NeighborX, a_NeighborY + 1, a_NeighborZ} has changed. For example BLOCK_FACE_YP means that the block at {a_NeighborX, a_NeighborY + 1, a_NeighborZ} has changed.
BLOCK_FACE_NONE means that it is a neighbor not directly adjacent (diagonal, etc.) */ BLOCK_FACE_NONE means that it is a neighbor not directly adjacent (diagonal, etc.) */
static void NeighborChanged(cChunkInterface & a_ChunkInterface, int a_NeighborX, int a_NeighborY, int a_NeighborZ, eBlockFace a_WhichNeighbor); static void NeighborChanged(cChunkInterface & a_ChunkInterface, int a_NeighborX, int a_NeighborY, int a_NeighborZ, eBlockFace a_WhichNeighbor);
/** Called when the player starts digging the block. */ /** Called when the player starts digging the block. */
virtual void OnDigging(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) {} virtual void OnDigging(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) {}
/** Called if the user right clicks the block and the block is useable /** Called if the user right clicks the block and the block is useable
returns true if the use was successful, return false to use the block as a "normal" block */ returns true if the use was successful, return false to use the block as a "normal" block */
virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) { return false; } virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) { return false; }
/** Called when a right click to this block is cancelled */ /** Called when a right click to this block is cancelled */
virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) {} virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) {}
/** Called when the item is mined to convert it into pickups. Pickups may specify multiple items. Appends items to a_Pickups, preserves its original contents */ /** Called when the item is mined to convert it into pickups. Pickups may specify multiple items. Appends items to a_Pickups, preserves its original contents */
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta); virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta);
/** Handles the dropping, but not destruction, of a block based on what ConvertTo(Verbatim)Pickups() returns, including the spawning of pickups and alertion of plugins /** Handles the dropping, but not destruction, of a block based on what ConvertTo(Verbatim)Pickups() returns, including the spawning of pickups and alertion of plugins
@param a_Digger The entity causing the drop; it may be nullptr @param a_Digger The entity causing the drop; it may be nullptr
@param a_CanDrop Informs the handler whether the block should be dropped at all. One example when this is false is when stone is destroyed by hand @param a_CanDrop Informs the handler whether the block should be dropped at all. One example when this is false is when stone is destroyed by hand
@param a_DropVerbatim Calls ConvertToVerbatimPickups() instead of its counterpart, meaning the block itself is dropped by default (due to a speical tool or enchantment) @param a_DropVerbatim Calls ConvertToVerbatimPickups() instead of its counterpart, meaning the block itself is dropped by default (due to a speical tool or enchantment)
*/ */
virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_CanDrop = true); virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_CanDrop = true);
/** Checks if the block can stay at the specified relative coords in the chunk */ /** Checks if the block can stay at the specified relative coords in the chunk */
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk); virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk);
/** Checks whether the block has an effect on growing the plant */ /** Checks whether the block has an effect on growing the plant */
virtual bool CanSustainPlant(BLOCKTYPE a_Plant) { return false; } virtual bool CanSustainPlant(BLOCKTYPE a_Plant) { return false; }
/** Checks if the block can be placed at this point. /** Checks if the block can be placed at this point.
Default: CanBeAt(...) Default: CanBeAt(...)
NOTE: This call doesn't actually place the block NOTE: This call doesn't actually place the block
*/ */
// virtual bool CanBePlacedAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir); // virtual bool CanBePlacedAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir);
/** Called to check whether this block supports a rclk action. /** Called to check whether this block supports a rclk action.
If it returns true, OnUse() is called */ If it returns true, OnUse() is called */
virtual bool IsUseable(void); virtual bool IsUseable(void);
/** Indicates whether the client will click through this block. /** Indicates whether the client will click through this block.
For example digging a fire will hit the block below the fire so fire is clicked through For example digging a fire will hit the block below the fire so fire is clicked through
*/ */
virtual bool IsClickedThrough(void); virtual bool IsClickedThrough(void);
/** Checks if the player can build "inside" this block. /** Checks if the player can build "inside" this block.
For example blocks placed "on" snow will be placed at the same position. So: Snow ignores Build collision For example blocks placed "on" snow will be placed at the same position. So: Snow ignores Build collision
*/ */
@ -136,15 +136,15 @@ public:
/** Returns the base colour ID of the block, as will be represented on a map, as per documentation: http://minecraft.gamepedia.com/Map_item_format */ /** Returns the base colour ID of the block, as will be represented on a map, as per documentation: http://minecraft.gamepedia.com/Map_item_format */
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta); virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta);
/** Rotates a given block meta counter-clockwise. Default: no change /** Rotates a given block meta counter-clockwise. Default: no change
Returns block meta following rotation */ Returns block meta following rotation */
virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) { return a_Meta; } virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) { return a_Meta; }
/** Rotates a given block meta clockwise. Default: no change /** Rotates a given block meta clockwise. Default: no change
Returns block meta following rotation */ Returns block meta following rotation */
virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) { return a_Meta; } virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) { return a_Meta; }
/** Mirrors a given block meta around the XY plane. Default: no change /** Mirrors a given block meta around the XY plane. Default: no change
Returns block meta following rotation */ Returns block meta following rotation */
virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) { return a_Meta; } virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) { return a_Meta; }
@ -156,10 +156,10 @@ public:
/** Mirros a given block meta around the YZ plane. Default: no change /** Mirros a given block meta around the YZ plane. Default: no change
Returns block meta following rotation */ Returns block meta following rotation */
virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) { return a_Meta; } virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) { return a_Meta; }
protected: protected:
BLOCKTYPE m_BlockType; BLOCKTYPE m_BlockType;
// Creates a new blockhandler for the given block type. For internal use only, use ::GetBlockHandler() instead. // Creates a new blockhandler for the given block type. For internal use only, use ::GetBlockHandler() instead.
static cBlockHandler * CreateBlockHandler(BLOCKTYPE a_BlockType); static cBlockHandler * CreateBlockHandler(BLOCKTYPE a_BlockType);

View File

@ -24,7 +24,7 @@ public:
) override ) override
{ {
a_BlockType = m_BlockType; a_BlockType = m_BlockType;
// Convert the blockface into meta: // Convert the blockface into meta:
switch (a_BlockFace) switch (a_BlockFace)
{ {

View File

@ -21,14 +21,14 @@ public:
{ {
// No pickups // No pickups
} }
virtual void OnDestroyedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override virtual void OnDestroyedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override
{ {
if (a_Player->IsGameModeCreative() || (a_BlockY <= 0)) if (a_Player->IsGameModeCreative() || (a_BlockY <= 0))
{ {
return; return;
} }
cEnchantments Enchantments = a_Player->GetInventory().GetEquippedItem().m_Enchantments; cEnchantments Enchantments = a_Player->GetInventory().GetEquippedItem().m_Enchantments;
if (Enchantments.GetLevel(cEnchantments::enchSilkTouch) == 0) if (Enchantments.GetLevel(cEnchantments::enchSilkTouch) == 0)
{ {

View File

@ -29,7 +29,7 @@ public:
if (!LadderCanBePlacedAt(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace)) if (!LadderCanBePlacedAt(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace))
{ {
a_BlockFace = FindSuitableBlockFace(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); a_BlockFace = FindSuitableBlockFace(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ);
if (a_BlockFace == BLOCK_FACE_BOTTOM) if (a_BlockFace == BLOCK_FACE_BOTTOM)
{ {
return false; return false;

View File

@ -82,7 +82,7 @@ public:
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta & 0x7); a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta & 0x7);
} }
} }
virtual void OnUpdate(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override virtual void OnUpdate(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
{ {
NIBBLETYPE Meta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ); NIBBLETYPE Meta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ);
@ -159,7 +159,7 @@ bool HasNearLog(cBlockArea & a_Area, int a_BlockX, int a_BlockY, int a_BlockZ)
} }
} }
} // for i - Types[] } // for i - Types[]
// Perform a breadth-first search to see if there's a log connected within 4 blocks of the leaves block: // Perform a breadth-first search to see if there's a log connected within 4 blocks of the leaves block:
// Simply replace all reachable leaves blocks with a sponge block plus iteration (in the Area) and see if we can reach a log in 4 iterations // Simply replace all reachable leaves blocks with a sponge block plus iteration (in the Area) and see if we can reach a log in 4 iterations
a_Area.SetBlockType(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_SPONGE); a_Area.SetBlockType(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_SPONGE);

View File

@ -10,13 +10,13 @@ class cBlockLeverHandler :
public cMetaRotator<cBlockHandler, 0x07, 0x04, 0x01, 0x03, 0x02, false> public cMetaRotator<cBlockHandler, 0x07, 0x04, 0x01, 0x03, 0x02, false>
{ {
typedef cMetaRotator<cBlockHandler, 0x07, 0x04, 0x01, 0x03, 0x02, false> super; typedef cMetaRotator<cBlockHandler, 0x07, 0x04, 0x01, 0x03, 0x02, false> super;
public: public:
cBlockLeverHandler(BLOCKTYPE a_BlockType) : cBlockLeverHandler(BLOCKTYPE a_BlockType) :
super(a_BlockType) super(a_BlockType)
{ {
} }
virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
{ {
// Flip the ON bit on / off using the XOR bitwise operation // Flip the ON bit on / off using the XOR bitwise operation
@ -38,7 +38,7 @@ public:
{ {
return true; return true;
} }
virtual bool GetPlacementBlockTypeMeta( virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player, cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
@ -93,7 +93,7 @@ public:
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{ {
NIBBLETYPE Meta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ); NIBBLETYPE Meta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ);
eBlockFace Face = BlockMetaDataToBlockFace(Meta); eBlockFace Face = BlockMetaDataToBlockFace(Meta);
AddFaceDirection(a_RelX, a_RelY, a_RelZ, Face, true); AddFaceDirection(a_RelX, a_RelY, a_RelZ, Face, true);

View File

@ -15,7 +15,7 @@ public:
: cBlockHandler(a_BlockType) : cBlockHandler(a_BlockType)
{ {
} }
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{ {
cFastRandom Random; cFastRandom Random;

View File

@ -39,7 +39,7 @@ public:
return false; return false;
} }
cMobHeadEntity * MobHeadEntity = static_cast<cMobHeadEntity*>(a_BlockEntity); cMobHeadEntity * MobHeadEntity = static_cast<cMobHeadEntity*>(a_BlockEntity);
cItems Pickups; cItems Pickups;
Pickups.Add(E_ITEM_HEAD, 1, static_cast<short>(MobHeadEntity->GetType())); Pickups.Add(E_ITEM_HEAD, 1, static_cast<short>(MobHeadEntity->GetType()));
MTRand r1; MTRand r1;
@ -58,7 +58,7 @@ public:
return false; return false;
} }
} Callback; } Callback;
a_WorldInterface.DoWithBlockEntityAt(a_BlockX, a_BlockY, a_BlockZ, Callback); a_WorldInterface.DoWithBlockEntityAt(a_BlockX, a_BlockY, a_BlockZ, Callback);
} }

View File

@ -35,8 +35,8 @@ public:
{ {
// No pickups // No pickups
} }
virtual void OnDestroyedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override virtual void OnDestroyedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override
{ {
cItemHandler * Handler = a_Player->GetEquippedItem().GetHandler(); cItemHandler * Handler = a_Player->GetEquippedItem().GetHandler();

View File

@ -30,9 +30,9 @@ public:
{ {
return false; return false;
} }
// TODO: Cannot be at too much daylight // TODO: Cannot be at too much daylight
switch (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ)) switch (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ))
{ {
case E_BLOCK_GLASS: case E_BLOCK_GLASS:

View File

@ -14,7 +14,7 @@ class cBlockPistonHandler :
{ {
public: public:
cBlockPistonHandler(BLOCKTYPE a_BlockType); cBlockPistonHandler(BLOCKTYPE a_BlockType);
virtual void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ) override; virtual void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ) override;
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override; virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override;
@ -94,7 +94,7 @@ public:
} }
private: private:
typedef std::unordered_set<Vector3i, VectorHasher<int>> Vector3iSet; typedef std::unordered_set<Vector3i, VectorHasher<int>> Vector3iSet;
/** Returns true if the piston (specified by blocktype) is a sticky piston */ /** Returns true if the piston (specified by blocktype) is a sticky piston */
@ -153,7 +153,7 @@ private:
const Vector3i & a_BlockPos, cWorld * a_World, bool a_RequirePushable, const Vector3i & a_BlockPos, cWorld * a_World, bool a_RequirePushable,
Vector3iSet & a_BlocksPushed, const Vector3i & a_PushDir Vector3iSet & a_BlocksPushed, const Vector3i & a_PushDir
); );
/** Moves a list of blocks in a specific direction */ /** Moves a list of blocks in a specific direction */
static void PushBlocks(const Vector3iSet & a_BlocksToPush, static void PushBlocks(const Vector3iSet & a_BlocksToPush,
cWorld * a_World, const Vector3i & a_PushDir cWorld * a_World, const Vector3i & a_PushDir
@ -168,10 +168,10 @@ class cBlockPistonHeadHandler :
public cBlockHandler public cBlockHandler
{ {
typedef cBlockHandler super; typedef cBlockHandler super;
public: public:
cBlockPistonHeadHandler(void); cBlockPistonHeadHandler(void);
virtual void OnDestroyedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override; virtual void OnDestroyedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override;
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override

View File

@ -14,7 +14,7 @@ public:
: cBlockHandler(a_BlockType) : cBlockHandler(a_BlockType)
{ {
} }
virtual bool GetPlacementBlockTypeMeta( virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player, cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,

View File

@ -28,7 +28,7 @@ class cBlockPluginInterface
{ {
public: public:
virtual ~cBlockPluginInterface() {} virtual ~cBlockPluginInterface() {}
virtual bool CallHookBlockSpread(int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source) = 0; virtual bool CallHookBlockSpread(int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source) = 0;
virtual bool CallHookBlockToPickups(cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cItems & a_Pickups) = 0; virtual bool CallHookBlockToPickups(cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cItems & a_Pickups) = 0;
virtual bool CallHookPlayerBreakingBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0; virtual bool CallHookPlayerBreakingBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0;

View File

@ -112,7 +112,7 @@ public:
} }
return true; return true;
} }
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{ {
UNUSED(a_Meta); UNUSED(a_Meta);

View File

@ -15,7 +15,7 @@ public:
super(a_BlockType) super(a_BlockType)
{ {
} }
virtual bool GetPlacementBlockTypeMeta( virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player, cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
@ -31,7 +31,7 @@ public:
inline static NIBBLETYPE PlayerYawToMetaData(double a_Yaw) inline static NIBBLETYPE PlayerYawToMetaData(double a_Yaw)
{ {
ASSERT((a_Yaw >= -180) && (a_Yaw < 180)); ASSERT((a_Yaw >= -180) && (a_Yaw < 180));
a_Yaw += 180 + 45; a_Yaw += 180 + 45;
if (a_Yaw > 360) if (a_Yaw > 360)
{ {

View File

@ -22,13 +22,13 @@ class cBlockRailHandler :
public cBlockHandler public cBlockHandler
{ {
typedef cBlockHandler super; typedef cBlockHandler super;
public: public:
cBlockRailHandler(BLOCKTYPE a_BlockType) cBlockRailHandler(BLOCKTYPE a_BlockType)
: cBlockHandler(a_BlockType) : cBlockHandler(a_BlockType)
{ {
} }
virtual bool GetPlacementBlockTypeMeta( virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player, cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
@ -85,7 +85,7 @@ public:
{ {
super::ConvertToPickups(a_Pickups, 0); super::ConvertToPickups(a_Pickups, 0);
} }
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{ {
if (a_RelY <= 0) if (a_RelY <= 0)
@ -279,7 +279,7 @@ public:
} }
break; break;
} }
case E_META_RAIL_XM_XP: case E_META_RAIL_XM_XP:
{ {
if ( if (
@ -291,7 +291,7 @@ public:
} }
break; break;
} }
case E_META_RAIL_ASCEND_XP: case E_META_RAIL_ASCEND_XP:
{ {
if ( if (
@ -303,7 +303,7 @@ public:
} }
break; break;
} }
case E_META_RAIL_ASCEND_XM: case E_META_RAIL_ASCEND_XM:
{ {
if ( if (
@ -315,7 +315,7 @@ public:
} }
break; break;
} }
case E_META_RAIL_ASCEND_ZM: case E_META_RAIL_ASCEND_ZM:
{ {
if ( if (
@ -327,7 +327,7 @@ public:
} }
break; break;
} }
case E_META_RAIL_ASCEND_ZP: case E_META_RAIL_ASCEND_ZP:
{ {
if ( if (
@ -339,7 +339,7 @@ public:
} }
break; break;
} }
case E_META_RAIL_CURVED_ZP_XP: case E_META_RAIL_CURVED_ZP_XP:
{ {
if ( if (
@ -351,7 +351,7 @@ public:
} }
break; break;
} }
case E_META_RAIL_CURVED_ZP_XM: case E_META_RAIL_CURVED_ZP_XM:
{ {
if ( if (
@ -363,7 +363,7 @@ public:
} }
break; break;
} }
case E_META_RAIL_CURVED_ZM_XM: case E_META_RAIL_CURVED_ZM_XM:
{ {
if ( if (
@ -375,7 +375,7 @@ public:
} }
break; break;
} }
case E_META_RAIL_CURVED_ZM_XP: case E_META_RAIL_CURVED_ZM_XP:
{ {
if ( if (
@ -417,7 +417,7 @@ public:
{ {
Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
} }
switch (a_BlockFace) switch (a_BlockFace)
{ {
case BLOCK_FACE_NORTH: case BLOCK_FACE_NORTH:
@ -434,7 +434,7 @@ public:
} }
break; break;
} }
case BLOCK_FACE_SOUTH: case BLOCK_FACE_SOUTH:
{ {
if ( if (
@ -449,7 +449,7 @@ public:
} }
break; break;
} }
case BLOCK_FACE_EAST: case BLOCK_FACE_EAST:
{ {
if ( if (

View File

@ -43,7 +43,7 @@ public:
} }
return false; return false;
} }
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{ {
// Reset meta to zero // Reset meta to zero

View File

@ -15,7 +15,7 @@ public:
: cBlockHandler(a_BlockType) : cBlockHandler(a_BlockType)
{ {
} }
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{ {
a_Pickups.push_back(cItem(E_BLOCK_REDSTONE_LAMP_OFF, 1, 0)); a_Pickups.push_back(cItem(E_BLOCK_REDSTONE_LAMP_OFF, 1, 0));

View File

@ -52,7 +52,7 @@ public:
{ {
return true; return true;
} }
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{ {
if (a_RelY <= 0) if (a_RelY <= 0)

View File

@ -17,18 +17,18 @@ public:
: cBlockHandler(a_BlockType) : cBlockHandler(a_BlockType)
{ {
} }
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{ {
// Only the first 2 bits contain the display information and the 4th bit is for the growth indicator, but, we use 0x07 for forward compatibility // Only the first 2 bits contain the display information and the 4th bit is for the growth indicator, but, we use 0x07 for forward compatibility
a_Pickups.push_back(cItem(E_BLOCK_SAPLING, 1, a_BlockMeta & 0x07)); a_Pickups.push_back(cItem(E_BLOCK_SAPLING, 1, a_BlockMeta & 0x07));
} }
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{ {
return (a_RelY > 0) && IsBlockTypeOfDirt(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ)); return (a_RelY > 0) && IsBlockTypeOfDirt(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ));
} }
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
{ {
NIBBLETYPE Meta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ); NIBBLETYPE Meta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ);

View File

@ -15,7 +15,7 @@ public:
{ {
} }
virtual bool GetPlacementBlockTypeMeta( virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player, cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,

View File

@ -13,7 +13,7 @@ class cBlockSignPostHandler :
public cBlockHandler public cBlockHandler
{ {
typedef cBlockHandler super; typedef cBlockHandler super;
public: public:
cBlockSignPostHandler(BLOCKTYPE a_BlockType) : cBlockSignPostHandler(BLOCKTYPE a_BlockType) :
super(a_BlockType) super(a_BlockType)
@ -43,9 +43,9 @@ public:
{ {
a_Rotation -= 360; a_Rotation -= 360;
} }
a_Rotation = (a_Rotation / 360) * 16; a_Rotation = (a_Rotation / 360) * 16;
return (static_cast<char>(a_Rotation)) % 16; return (static_cast<char>(a_Rotation)) % 16;
} }

View File

@ -39,7 +39,7 @@ public:
{ {
a_BlockType = m_BlockType; a_BlockType = m_BlockType;
NIBBLETYPE Meta = static_cast<NIBBLETYPE>(a_Player->GetEquippedItem().m_ItemDamage); NIBBLETYPE Meta = static_cast<NIBBLETYPE>(a_Player->GetEquippedItem().m_ItemDamage);
// Set the correct metadata based on player equipped item (i.e. a_BlockMeta not initialised yet) // Set the correct metadata based on player equipped item (i.e. a_BlockMeta not initialised yet)
switch (a_BlockFace) switch (a_BlockFace)
{ {
@ -84,7 +84,7 @@ public:
return true; return true;
} }
/** Returns true if the specified blocktype is one of the slabs handled by this handler */ /** Returns true if the specified blocktype is one of the slabs handled by this handler */
static bool IsAnySlabType(BLOCKTYPE a_BlockType) static bool IsAnySlabType(BLOCKTYPE a_BlockType)
{ {
@ -101,7 +101,7 @@ public:
// Sends the slab back to the client. It's to refuse a doubleslab placement. */ // Sends the slab back to the client. It's to refuse a doubleslab placement. */
a_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, a_Player); a_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, a_Player);
} }
/** Converts the single-slab blocktype to its equivalent double-slab blocktype */ /** Converts the single-slab blocktype to its equivalent double-slab blocktype */
static BLOCKTYPE GetDoubleSlabType(BLOCKTYPE a_SingleSlabBlockType) static BLOCKTYPE GetDoubleSlabType(BLOCKTYPE a_SingleSlabBlockType)
{ {
@ -114,7 +114,7 @@ public:
ASSERT(!"Unhandled slab type!"); ASSERT(!"Unhandled slab type!");
return E_BLOCK_AIR; return E_BLOCK_AIR;
} }
virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) override virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) override
{ {
// Toggle the 4th bit - up / down: // Toggle the 4th bit - up / down:
@ -203,7 +203,7 @@ public:
BLOCKTYPE Block = GetSingleSlabType(m_BlockType); BLOCKTYPE Block = GetSingleSlabType(m_BlockType);
a_Pickups.push_back(cItem(Block, 2, a_BlockMeta & 0x7)); a_Pickups.push_back(cItem(Block, 2, a_BlockMeta & 0x7));
} }
inline static BLOCKTYPE GetSingleSlabType(BLOCKTYPE a_BlockType) inline static BLOCKTYPE GetSingleSlabType(BLOCKTYPE a_BlockType)
{ {
switch (a_BlockType) switch (a_BlockType)

View File

@ -14,7 +14,7 @@ public:
: cBlockHandler(a_BlockType) : cBlockHandler(a_BlockType)
{ {
} }
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{ {
a_Pickups.push_back(cItem(m_BlockType, 1, 0)); a_Pickups.push_back(cItem(m_BlockType, 1, 0));

View File

@ -36,7 +36,7 @@ public:
// - Height is smaller than 7, the maximum possible height // - Height is smaller than 7, the maximum possible height
MetaBeforePlacement++; MetaBeforePlacement++;
} }
a_BlockMeta = MetaBeforePlacement; a_BlockMeta = MetaBeforePlacement;
return true; return true;
} }
@ -67,17 +67,17 @@ public:
{ {
BLOCKTYPE BlockBelow = a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ); BLOCKTYPE BlockBelow = a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ);
NIBBLETYPE MetaBelow = a_Chunk.GetMeta(a_RelX, a_RelY - 1, a_RelZ); NIBBLETYPE MetaBelow = a_Chunk.GetMeta(a_RelX, a_RelY - 1, a_RelZ);
if (cBlockInfo::IsSnowable(BlockBelow) || ((BlockBelow == E_BLOCK_SNOW) && (MetaBelow == 7))) if (cBlockInfo::IsSnowable(BlockBelow) || ((BlockBelow == E_BLOCK_SNOW) && (MetaBelow == 7)))
{ {
// If block below is snowable, or it is a thin slow block and has a meta of 7 (full thin snow block), say yay // If block below is snowable, or it is a thin slow block and has a meta of 7 (full thin snow block), say yay
return true; return true;
} }
} }
return false; return false;
} }
virtual bool DoesDropOnUnsuitable(void) override virtual bool DoesDropOnUnsuitable(void) override
{ {
return false; return false;

View File

@ -23,7 +23,7 @@ public:
short ItemType = (m_BlockType == E_BLOCK_MELON_STEM) ? E_ITEM_MELON_SEEDS : E_ITEM_PUMPKIN_SEEDS; short ItemType = (m_BlockType == E_BLOCK_MELON_STEM) ? E_ITEM_MELON_SEEDS : E_ITEM_PUMPKIN_SEEDS;
a_Pickups.push_back(cItem(ItemType, 1, 0)); a_Pickups.push_back(cItem(ItemType, 1, 0));
} }
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
{ {
auto Action = CanGrow(a_Chunk, a_RelX, a_RelY, a_RelZ); auto Action = CanGrow(a_Chunk, a_RelX, a_RelY, a_RelZ);

View File

@ -71,7 +71,7 @@ public:
} }
return false; return false;
} }
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
{ {
if (CanGrow(a_Chunk, a_RelX, a_RelY, a_RelZ) == paGrowth) if (CanGrow(a_Chunk, a_RelX, a_RelY, a_RelZ) == paGrowth)

View File

@ -16,7 +16,7 @@ public:
: cMetaRotator<cBlockHandler, 0x7, 0x4, 0x1, 0x3, 0x2>(a_BlockType) : cMetaRotator<cBlockHandler, 0x7, 0x4, 0x1, 0x3, 0x2>(a_BlockType)
{ {
} }
virtual bool GetPlacementBlockTypeMeta( virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player, cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
@ -142,7 +142,7 @@ public:
} }
} }
} }
/** Finds a suitable face to place the torch, returning BLOCK_FACE_NONE on failure */ /** Finds a suitable face to place the torch, returning BLOCK_FACE_NONE on failure */
static eBlockFace FindSuitableFace(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) static eBlockFace FindSuitableFace(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ)
{ {

View File

@ -39,7 +39,7 @@ public:
// Flip the ON bit on / off using the XOR bitwise operation // Flip the ON bit on / off using the XOR bitwise operation
NIBBLETYPE Meta = (a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) ^ 0x04); NIBBLETYPE Meta = (a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) ^ 0x04);
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta); a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
cWorld * World = static_cast<cWorld *>(&a_WorldInterface); cWorld * World = static_cast<cWorld *>(&a_WorldInterface);
World->BroadcastSoundParticleEffect(EffectID::SFX_RANDOM_DOOR_OPEN_CLOSE, a_BlockX, a_BlockY, a_BlockZ, 0, a_Player->GetClientHandle()); World->BroadcastSoundParticleEffect(EffectID::SFX_RANDOM_DOOR_OPEN_CLOSE, a_BlockX, a_BlockY, a_BlockZ, 0, a_Player->GetClientHandle());

View File

@ -14,7 +14,7 @@ public:
: cBlockHandler(a_BlockType) : cBlockHandler(a_BlockType)
{ {
} }
virtual bool GetPlacementBlockTypeMeta( virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player, cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
@ -117,18 +117,18 @@ public:
} }
return res; return res;
} }
void Check(cChunkInterface & a_ChunkInterface, cBlockPluginInterface & a_PluginInterface, int a_RelX, int a_RelY, int a_RelZ, cChunk & a_Chunk) override void Check(cChunkInterface & a_ChunkInterface, cBlockPluginInterface & a_PluginInterface, int a_RelX, int a_RelY, int a_RelZ, cChunk & a_Chunk) override
{ {
NIBBLETYPE CurMeta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ); NIBBLETYPE CurMeta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ);
NIBBLETYPE MaxMeta = GetMaxMeta(a_Chunk, a_RelX, a_RelY, a_RelZ); NIBBLETYPE MaxMeta = GetMaxMeta(a_Chunk, a_RelX, a_RelY, a_RelZ);
// Check if vine above us, add its meta to MaxMeta // Check if vine above us, add its meta to MaxMeta
if ((a_RelY < cChunkDef::Height - 1) && (a_Chunk.GetBlock(a_RelX, a_RelY + 1, a_RelZ) == m_BlockType)) if ((a_RelY < cChunkDef::Height - 1) && (a_Chunk.GetBlock(a_RelX, a_RelY + 1, a_RelZ) == m_BlockType))
{ {
MaxMeta |= a_Chunk.GetMeta(a_RelX, a_RelY + 1, a_RelZ); MaxMeta |= a_Chunk.GetMeta(a_RelX, a_RelY + 1, a_RelZ);
} }
NIBBLETYPE Common = CurMeta & MaxMeta; // Neighbors that we have and are legal NIBBLETYPE Common = CurMeta & MaxMeta; // Neighbors that we have and are legal
if (Common != CurMeta) if (Common != CurMeta)
{ {

View File

@ -17,7 +17,7 @@ public:
: cBlockHandler(a_BlockType) : cBlockHandler(a_BlockType)
{ {
} }
virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
{ {
cWindow * Window = new cCraftingWindow(a_BlockX, a_BlockY, a_BlockZ); cWindow * Window = new cCraftingWindow(a_BlockX, a_BlockY, a_BlockZ);

View File

@ -5,7 +5,7 @@ class cBroadcastInterface
{ {
public: public:
virtual ~cBroadcastInterface() {} virtual ~cBroadcastInterface() {}
virtual void BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) = 0; virtual void BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) = 0;
virtual void BroadcastSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = nullptr) = 0; virtual void BroadcastSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = nullptr) = 0;
virtual void BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = nullptr) = 0; virtual void BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = nullptr) = 0;

View File

@ -21,32 +21,32 @@ public:
NIBBLETYPE GetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ); NIBBLETYPE GetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ);
bool GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta); bool GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta);
/** Sets the block at the specified coords to the specified value. /** Sets the block at the specified coords to the specified value.
Full processing, incl. updating neighbors, is performed. Full processing, incl. updating neighbors, is performed.
*/ */
void SetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); void SetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
void SetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_MetaData); void SetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_MetaData);
/** Sets the block at the specified coords to the specified value. /** Sets the block at the specified coords to the specified value.
The replacement doesn't trigger block updates. The replacement doesn't trigger block updates.
The replaced blocks aren't checked for block entities (block entity is leaked if it exists at this block) The replaced blocks aren't checked for block entities (block entity is leaked if it exists at this block)
*/ */
void FastSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); void FastSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
void FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); void FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
/** Use block entity on coordinate. /** Use block entity on coordinate.
returns true if the use was successful, return false to use the block as a "normal" block */ returns true if the use was successful, return false to use the block as a "normal" block */
bool UseBlockEntity(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ); bool UseBlockEntity(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ);
virtual bool ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ, cChunkDataCallback & a_Callback) override; virtual bool ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ, cChunkDataCallback & a_Callback) override;
virtual bool WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes) override; virtual bool WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes) override;
bool DigBlock(cWorldInterface & a_WorldInterface, int a_X, int a_Y, int a_Z); bool DigBlock(cWorldInterface & a_WorldInterface, int a_X, int a_Y, int a_Z);
private: private:
cChunkMap * m_ChunkMap; cChunkMap * m_ChunkMap;
}; };

View File

@ -15,7 +15,7 @@ public:
cClearMetaOnDrop(BLOCKTYPE a_BlockType) : cClearMetaOnDrop(BLOCKTYPE a_BlockType) :
Base(a_BlockType) Base(a_BlockType)
{} {}
virtual ~cClearMetaOnDrop() {} virtual ~cClearMetaOnDrop() {}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{ {

Some files were not shown because too many files have changed in this diff Show More