1
0
Fork 0

En masse NULL -> nullptr replace

This commit is contained in:
Tiger Wang 2014-10-20 21:55:07 +01:00 committed by archshift
parent 2ac3a807b7
commit a26541a7c3
211 changed files with 1767 additions and 1745 deletions

View File

@ -45,7 +45,7 @@ class cListAllocationPool : public cAllocationPool<T>
for (size_t i = 0; i < NumElementsInReserve; i++) for (size_t i = 0; i < NumElementsInReserve; i++)
{ {
void * space = malloc(sizeof(T)); void * space = malloc(sizeof(T));
if (space == NULL) if (space == nullptr)
{ {
m_Callbacks->OnStartUsingReserve(); m_Callbacks->OnStartUsingReserve();
break; break;
@ -68,7 +68,7 @@ class cListAllocationPool : public cAllocationPool<T>
if (m_FreeList.size() <= NumElementsInReserve) if (m_FreeList.size() <= NumElementsInReserve)
{ {
void * space = malloc(sizeof(T)); void * space = malloc(sizeof(T));
if (space != NULL) if (space != nullptr)
{ {
return new(space) T; return new(space) T;
} }
@ -90,7 +90,7 @@ class cListAllocationPool : public cAllocationPool<T>
} }
virtual void Free(T * a_ptr) override virtual void Free(T * a_ptr) override
{ {
if (a_ptr == NULL) if (a_ptr == nullptr)
{ {
return; return;
} }

View File

@ -29,7 +29,7 @@ static int tolua_get_AllToLua_g_BlockLightValue(lua_State* tolua_S)
BlockType = (int)tolua_tonumber(tolua_S, 2, 0); BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID)) if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
{ {
tolua_error(tolua_S, "array indexing out of range.", NULL); tolua_error(tolua_S, "array indexing out of range.", nullptr);
} }
tolua_pushnumber(tolua_S, (lua_Number)cBlockInfo::GetLightValue((BLOCKTYPE)BlockType)); tolua_pushnumber(tolua_S, (lua_Number)cBlockInfo::GetLightValue((BLOCKTYPE)BlockType));
return 1; return 1;
@ -55,7 +55,7 @@ static int tolua_get_AllToLua_g_BlockSpreadLightFalloff(lua_State* tolua_S)
BlockType = (int)tolua_tonumber(tolua_S, 2, 0); BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID)) if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
{ {
tolua_error(tolua_S, "array indexing out of range.", NULL); tolua_error(tolua_S, "array indexing out of range.", nullptr);
} }
tolua_pushnumber(tolua_S, (lua_Number)cBlockInfo::GetSpreadLightFalloff((BLOCKTYPE)BlockType)); tolua_pushnumber(tolua_S, (lua_Number)cBlockInfo::GetSpreadLightFalloff((BLOCKTYPE)BlockType));
return 1; return 1;
@ -81,7 +81,7 @@ static int tolua_get_AllToLua_g_BlockTransparent(lua_State* tolua_S)
BlockType = (int)tolua_tonumber(tolua_S, 2, 0); BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID)) if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
{ {
tolua_error(tolua_S, "array indexing out of range.", NULL); tolua_error(tolua_S, "array indexing out of range.", nullptr);
} }
tolua_pushboolean(tolua_S, cBlockInfo::IsTransparent((BLOCKTYPE)BlockType)); tolua_pushboolean(tolua_S, cBlockInfo::IsTransparent((BLOCKTYPE)BlockType));
return 1; return 1;
@ -107,7 +107,7 @@ static int tolua_get_AllToLua_g_BlockOneHitDig(lua_State* tolua_S)
BlockType = (int)tolua_tonumber(tolua_S, 2, 0); BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID)) if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
{ {
tolua_error(tolua_S, "array indexing out of range.", NULL); tolua_error(tolua_S, "array indexing out of range.", nullptr);
} }
tolua_pushboolean(tolua_S, cBlockInfo::IsOneHitDig((BLOCKTYPE)BlockType)); tolua_pushboolean(tolua_S, cBlockInfo::IsOneHitDig((BLOCKTYPE)BlockType));
return 1; return 1;
@ -133,7 +133,7 @@ static int tolua_get_AllToLua_g_BlockPistonBreakable(lua_State* tolua_S)
BlockType = (int)tolua_tonumber(tolua_S, 2, 0); BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID)) if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
{ {
tolua_error(tolua_S, "array indexing out of range.", NULL); tolua_error(tolua_S, "array indexing out of range.", nullptr);
} }
tolua_pushboolean(tolua_S, cBlockInfo::IsPistonBreakable((BLOCKTYPE)BlockType)); tolua_pushboolean(tolua_S, cBlockInfo::IsPistonBreakable((BLOCKTYPE)BlockType));
return 1; return 1;
@ -159,7 +159,7 @@ static int tolua_get_AllToLua_g_BlockIsSnowable(lua_State* tolua_S)
BlockType = (int)tolua_tonumber(tolua_S, 2, 0); BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID)) if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
{ {
tolua_error(tolua_S, "array indexing out of range.", NULL); tolua_error(tolua_S, "array indexing out of range.", nullptr);
} }
tolua_pushboolean(tolua_S, cBlockInfo::IsSnowable((BLOCKTYPE)BlockType)); tolua_pushboolean(tolua_S, cBlockInfo::IsSnowable((BLOCKTYPE)BlockType));
return 1; return 1;
@ -185,7 +185,7 @@ static int tolua_get_AllToLua_g_BlockIsSolid(lua_State* tolua_S)
BlockType = (int)tolua_tonumber(tolua_S, 2, 0); BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID)) if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
{ {
tolua_error(tolua_S, "array indexing out of range.", NULL); tolua_error(tolua_S, "array indexing out of range.", nullptr);
} }
tolua_pushboolean(tolua_S, (bool)cBlockInfo::IsSolid((BLOCKTYPE)BlockType)); tolua_pushboolean(tolua_S, (bool)cBlockInfo::IsSolid((BLOCKTYPE)BlockType));
return 1; return 1;
@ -211,7 +211,7 @@ static int tolua_get_AllToLua_g_BlockFullyOccupiesVoxel(lua_State* tolua_S)
BlockType = (int)tolua_tonumber(tolua_S, 2, 0); BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID)) if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
{ {
tolua_error(tolua_S, "array indexing out of range.", NULL); tolua_error(tolua_S, "array indexing out of range.", nullptr);
} }
tolua_pushboolean(tolua_S, (bool)cBlockInfo::FullyOccupiesVoxel((BLOCKTYPE)BlockType)); tolua_pushboolean(tolua_S, (bool)cBlockInfo::FullyOccupiesVoxel((BLOCKTYPE)BlockType));
return 1; return 1;
@ -224,16 +224,16 @@ static int tolua_get_AllToLua_g_BlockFullyOccupiesVoxel(lua_State* tolua_S)
void DeprecatedBindings::Bind(lua_State * tolua_S) void DeprecatedBindings::Bind(lua_State * tolua_S)
{ {
tolua_beginmodule(tolua_S, NULL); tolua_beginmodule(tolua_S, nullptr);
tolua_array(tolua_S, "g_BlockLightValue", tolua_get_AllToLua_g_BlockLightValue, NULL); tolua_array(tolua_S, "g_BlockLightValue", tolua_get_AllToLua_g_BlockLightValue, nullptr);
tolua_array(tolua_S, "g_BlockSpreadLightFalloff", tolua_get_AllToLua_g_BlockSpreadLightFalloff, NULL); tolua_array(tolua_S, "g_BlockSpreadLightFalloff", tolua_get_AllToLua_g_BlockSpreadLightFalloff, nullptr);
tolua_array(tolua_S, "g_BlockTransparent", tolua_get_AllToLua_g_BlockTransparent, NULL); tolua_array(tolua_S, "g_BlockTransparent", tolua_get_AllToLua_g_BlockTransparent, nullptr);
tolua_array(tolua_S, "g_BlockOneHitDig", tolua_get_AllToLua_g_BlockOneHitDig, NULL); tolua_array(tolua_S, "g_BlockOneHitDig", tolua_get_AllToLua_g_BlockOneHitDig, nullptr);
tolua_array(tolua_S, "g_BlockPistonBreakable", tolua_get_AllToLua_g_BlockPistonBreakable, NULL); tolua_array(tolua_S, "g_BlockPistonBreakable", tolua_get_AllToLua_g_BlockPistonBreakable, nullptr);
tolua_array(tolua_S, "g_BlockIsSnowable", tolua_get_AllToLua_g_BlockIsSnowable, NULL); tolua_array(tolua_S, "g_BlockIsSnowable", tolua_get_AllToLua_g_BlockIsSnowable, nullptr);
tolua_array(tolua_S, "g_BlockIsSolid", tolua_get_AllToLua_g_BlockIsSolid, NULL); tolua_array(tolua_S, "g_BlockIsSolid", tolua_get_AllToLua_g_BlockIsSolid, nullptr);
tolua_array(tolua_S, "g_BlockFullyOccupiesVoxel", tolua_get_AllToLua_g_BlockFullyOccupiesVoxel, NULL); tolua_array(tolua_S, "g_BlockFullyOccupiesVoxel", tolua_get_AllToLua_g_BlockFullyOccupiesVoxel, nullptr);
tolua_endmodule(tolua_S); tolua_endmodule(tolua_S);
} }

View File

@ -13,7 +13,7 @@
cLuaChunkStay::cLuaChunkStay(cPluginLua & a_Plugin) : cLuaChunkStay::cLuaChunkStay(cPluginLua & a_Plugin) :
m_Plugin(a_Plugin), m_Plugin(a_Plugin),
m_LuaState(NULL) m_LuaState(nullptr)
{ {
} }

View File

@ -46,7 +46,7 @@ const cLuaState::cRet cLuaState::Return = {};
// cLuaState: // cLuaState:
cLuaState::cLuaState(const AString & a_SubsystemName) : cLuaState::cLuaState(const AString & a_SubsystemName) :
m_LuaState(NULL), m_LuaState(nullptr),
m_IsOwned(false), m_IsOwned(false),
m_SubsystemName(a_SubsystemName), m_SubsystemName(a_SubsystemName),
m_NumCurrentFunctionArgs(-1) m_NumCurrentFunctionArgs(-1)
@ -90,7 +90,7 @@ cLuaState::~cLuaState()
void cLuaState::Create(void) void cLuaState::Create(void)
{ {
if (m_LuaState != NULL) if (m_LuaState != nullptr)
{ {
LOGWARNING("%s: Trying to create an already-existing LuaState, ignoring.", __FUNCTION__); LOGWARNING("%s: Trying to create an already-existing LuaState, ignoring.", __FUNCTION__);
return; return;
@ -119,7 +119,7 @@ void cLuaState::RegisterAPILibs(void)
void cLuaState::Close(void) void cLuaState::Close(void)
{ {
if (m_LuaState == NULL) if (m_LuaState == nullptr)
{ {
LOGWARNING("%s: Trying to close an invalid LuaState, ignoring.", __FUNCTION__); LOGWARNING("%s: Trying to close an invalid LuaState, ignoring.", __FUNCTION__);
return; return;
@ -134,7 +134,7 @@ void cLuaState::Close(void)
return; return;
} }
lua_close(m_LuaState); lua_close(m_LuaState);
m_LuaState = NULL; m_LuaState = nullptr;
m_IsOwned = false; m_IsOwned = false;
} }
@ -144,7 +144,7 @@ void cLuaState::Close(void)
void cLuaState::Attach(lua_State * a_State) void cLuaState::Attach(lua_State * a_State)
{ {
if (m_LuaState != NULL) if (m_LuaState != nullptr)
{ {
LOGINFO("%s: Already contains a LuaState (0x%p), will be closed / detached.", __FUNCTION__, m_LuaState); LOGINFO("%s: Already contains a LuaState (0x%p), will be closed / detached.", __FUNCTION__, m_LuaState);
if (m_IsOwned) if (m_IsOwned)
@ -166,7 +166,7 @@ void cLuaState::Attach(lua_State * a_State)
void cLuaState::Detach(void) void cLuaState::Detach(void)
{ {
if (m_LuaState == NULL) if (m_LuaState == nullptr)
{ {
return; return;
} }
@ -179,7 +179,7 @@ void cLuaState::Detach(void)
Close(); Close();
return; return;
} }
m_LuaState = NULL; m_LuaState = nullptr;
} }
@ -869,7 +869,7 @@ void cLuaState::GetStackValue(int a_StackPos, AString & a_Value)
{ {
size_t len = 0; size_t len = 0;
const char * data = lua_tolstring(m_LuaState, a_StackPos, &len); const char * data = lua_tolstring(m_LuaState, a_StackPos, &len);
if (data != NULL) if (data != nullptr)
{ {
a_Value.assign(data, len); a_Value.assign(data, len);
} }
@ -919,7 +919,7 @@ void cLuaState::GetStackValue(int a_StackPos, pBoundingBox & a_ReturnedVal)
{ {
if (lua_isnil(m_LuaState, a_StackPos)) if (lua_isnil(m_LuaState, a_StackPos))
{ {
a_ReturnedVal = NULL; a_ReturnedVal = nullptr;
return; return;
} }
tolua_Error err; tolua_Error err;
@ -937,7 +937,7 @@ void cLuaState::GetStackValue(int a_StackPos, pWorld & a_ReturnedVal)
{ {
if (lua_isnil(m_LuaState, a_StackPos)) if (lua_isnil(m_LuaState, a_StackPos))
{ {
a_ReturnedVal = NULL; a_ReturnedVal = nullptr;
return; return;
} }
tolua_Error err; tolua_Error err;
@ -1002,7 +1002,7 @@ bool cLuaState::CheckParamUserTable(int a_StartParam, const char * a_UserTable,
lua_Debug entry; lua_Debug entry;
VERIFY(lua_getstack(m_LuaState, 0, &entry)); VERIFY(lua_getstack(m_LuaState, 0, &entry));
VERIFY(lua_getinfo (m_LuaState, "n", &entry)); VERIFY(lua_getinfo (m_LuaState, "n", &entry));
AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != NULL) ? entry.name : "?"); AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != nullptr) ? entry.name : "?");
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
@ -1035,7 +1035,7 @@ bool cLuaState::CheckParamUserType(int a_StartParam, const char * a_UserType, in
lua_Debug entry; lua_Debug entry;
VERIFY(lua_getstack(m_LuaState, 0, &entry)); VERIFY(lua_getstack(m_LuaState, 0, &entry));
VERIFY(lua_getinfo (m_LuaState, "n", &entry)); VERIFY(lua_getinfo (m_LuaState, "n", &entry));
AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != NULL) ? entry.name : "?"); AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != nullptr) ? entry.name : "?");
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
@ -1068,7 +1068,7 @@ bool cLuaState::CheckParamTable(int a_StartParam, int a_EndParam)
lua_Debug entry; lua_Debug entry;
VERIFY(lua_getstack(m_LuaState, 0, &entry)); VERIFY(lua_getstack(m_LuaState, 0, &entry));
VERIFY(lua_getinfo (m_LuaState, "n", &entry)); VERIFY(lua_getinfo (m_LuaState, "n", &entry));
AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != NULL) ? entry.name : "?"); AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != nullptr) ? entry.name : "?");
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
@ -1101,7 +1101,7 @@ bool cLuaState::CheckParamNumber(int a_StartParam, int a_EndParam)
lua_Debug entry; lua_Debug entry;
VERIFY(lua_getstack(m_LuaState, 0, &entry)); VERIFY(lua_getstack(m_LuaState, 0, &entry));
VERIFY(lua_getinfo (m_LuaState, "n", &entry)); VERIFY(lua_getinfo (m_LuaState, "n", &entry));
AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != NULL) ? entry.name : "?"); AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != nullptr) ? entry.name : "?");
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
@ -1134,7 +1134,7 @@ bool cLuaState::CheckParamString(int a_StartParam, int a_EndParam)
lua_Debug entry; lua_Debug entry;
VERIFY(lua_getstack(m_LuaState, 0, &entry)); VERIFY(lua_getstack(m_LuaState, 0, &entry));
VERIFY(lua_getinfo (m_LuaState, "n", &entry)); VERIFY(lua_getinfo (m_LuaState, "n", &entry));
AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != NULL) ? entry.name : "?"); AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != nullptr) ? entry.name : "?");
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
@ -1167,7 +1167,7 @@ bool cLuaState::CheckParamFunction(int a_StartParam, int a_EndParam)
VERIFY(lua_getstack(m_LuaState, 0, &entry)); VERIFY(lua_getstack(m_LuaState, 0, &entry));
VERIFY(lua_getinfo (m_LuaState, "n", &entry)); VERIFY(lua_getinfo (m_LuaState, "n", &entry));
luaL_error(m_LuaState, "Error in function '%s' parameter #%d. Function expected, got %s", luaL_error(m_LuaState, "Error in function '%s' parameter #%d. Function expected, got %s",
(entry.name != NULL) ? entry.name : "?", i, GetTypeText(i).c_str() (entry.name != nullptr) ? entry.name : "?", i, GetTypeText(i).c_str()
); );
return false; return false;
} // for i - Param } // for i - Param
@ -1200,7 +1200,7 @@ bool cLuaState::CheckParamFunctionOrNil(int a_StartParam, int a_EndParam)
VERIFY(lua_getstack(m_LuaState, 0, &entry)); VERIFY(lua_getstack(m_LuaState, 0, &entry));
VERIFY(lua_getinfo (m_LuaState, "n", &entry)); VERIFY(lua_getinfo (m_LuaState, "n", &entry));
luaL_error(m_LuaState, "Error in function '%s' parameter #%d. Function expected, got %s", luaL_error(m_LuaState, "Error in function '%s' parameter #%d. Function expected, got %s",
(entry.name != NULL) ? entry.name : "?", i, GetTypeText(i).c_str() (entry.name != nullptr) ? entry.name : "?", i, GetTypeText(i).c_str()
); );
return false; return false;
} // for i - Param } // for i - Param
@ -1224,7 +1224,7 @@ bool cLuaState::CheckParamEnd(int a_Param)
lua_Debug entry; lua_Debug entry;
VERIFY(lua_getstack(m_LuaState, 0, &entry)); VERIFY(lua_getstack(m_LuaState, 0, &entry));
VERIFY(lua_getinfo (m_LuaState, "n", &entry)); VERIFY(lua_getinfo (m_LuaState, "n", &entry));
AString ErrMsg = Printf("#ferror in function '%s': Too many arguments.", (entry.name != NULL) ? entry.name : "?"); AString ErrMsg = Printf("#ferror in function '%s': Too many arguments.", (entry.name != nullptr) ? entry.name : "?");
tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err); tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err);
return false; return false;
} }
@ -1403,7 +1403,7 @@ int cLuaState::CopyStackFrom(cLuaState & a_SrcLuaState, int a_SrcStart, int a_Sr
case LUA_TUSERDATA: case LUA_TUSERDATA:
{ {
// Get the class name: // Get the class name:
const char * type = NULL; const char * type = nullptr;
if (lua_getmetatable(a_SrcLuaState, i) == 0) if (lua_getmetatable(a_SrcLuaState, i) == 0)
{ {
LOGWARNING("%s: Unknown class in pos %d, cannot copy.", __FUNCTION__, i); LOGWARNING("%s: Unknown class in pos %d, cannot copy.", __FUNCTION__, i);
@ -1415,7 +1415,7 @@ int cLuaState::CopyStackFrom(cLuaState & a_SrcLuaState, int a_SrcStart, int a_Sr
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, NULL); void * ud = tolua_touserdata(a_SrcLuaState, i, nullptr);
tolua_pushusertype(m_LuaState, ud, type); tolua_pushusertype(m_LuaState, ud, type);
break; break;
} }
@ -1441,7 +1441,7 @@ void cLuaState::ToString(int a_StackPos, AString & a_String)
{ {
size_t len; size_t len;
const char * s = lua_tolstring(m_LuaState, a_StackPos, &len); const char * s = lua_tolstring(m_LuaState, a_StackPos, &len);
if (s != NULL) if (s != nullptr)
{ {
a_String.assign(s, len); a_String.assign(s, len);
} }
@ -1463,7 +1463,7 @@ void cLuaState::LogStack(const char * a_Header)
void cLuaState::LogStack(lua_State * a_LuaState, const char * a_Header) void cLuaState::LogStack(lua_State * a_LuaState, const char * a_Header)
{ {
// Format string consisting only of %s is used to appease the compiler // Format string consisting only of %s is used to appease the compiler
LOG("%s", (a_Header != NULL) ? a_Header : "Lua C API Stack contents:"); LOG("%s", (a_Header != nullptr) ? a_Header : "Lua C API Stack contents:");
for (int i = lua_gettop(a_LuaState); i > 0; i--) for (int i = lua_gettop(a_LuaState); i > 0; i--)
{ {
AString Value; AString Value;
@ -1500,7 +1500,7 @@ int cLuaState::ReportFnCallErrors(lua_State * a_LuaState)
// cLuaState::cRef: // cLuaState::cRef:
cLuaState::cRef::cRef(void) : cLuaState::cRef::cRef(void) :
m_LuaState(NULL), m_LuaState(nullptr),
m_Ref(LUA_REFNIL) m_Ref(LUA_REFNIL)
{ {
} }
@ -1510,7 +1510,7 @@ cLuaState::cRef::cRef(void) :
cLuaState::cRef::cRef(cLuaState & a_LuaState, int a_StackPos) : cLuaState::cRef::cRef(cLuaState & a_LuaState, int a_StackPos) :
m_LuaState(NULL), m_LuaState(nullptr),
m_Ref(LUA_REFNIL) m_Ref(LUA_REFNIL)
{ {
RefStack(a_LuaState, a_StackPos); RefStack(a_LuaState, a_StackPos);
@ -1522,7 +1522,7 @@ cLuaState::cRef::cRef(cLuaState & a_LuaState, int a_StackPos) :
cLuaState::cRef::~cRef() cLuaState::cRef::~cRef()
{ {
if (m_LuaState != NULL) if (m_LuaState != nullptr)
{ {
UnRef(); UnRef();
} }
@ -1535,7 +1535,7 @@ cLuaState::cRef::~cRef()
void cLuaState::cRef::RefStack(cLuaState & a_LuaState, int a_StackPos) void cLuaState::cRef::RefStack(cLuaState & a_LuaState, int a_StackPos)
{ {
ASSERT(a_LuaState.IsValid()); ASSERT(a_LuaState.IsValid());
if (m_LuaState != NULL) if (m_LuaState != nullptr)
{ {
UnRef(); UnRef();
} }
@ -1556,7 +1556,7 @@ void cLuaState::cRef::UnRef(void)
{ {
luaL_unref(*m_LuaState, LUA_REGISTRYINDEX, m_Ref); luaL_unref(*m_LuaState, LUA_REGISTRYINDEX, m_Ref);
} }
m_LuaState = NULL; m_LuaState = nullptr;
m_Ref = LUA_REFNIL; m_Ref = LUA_REFNIL;
} }

View File

@ -164,7 +164,7 @@ public:
void Detach(void); void Detach(void);
/** Returns true if the m_LuaState is valid */ /** Returns true if the m_LuaState is valid */
bool IsValid(void) const { return (m_LuaState != NULL); } bool IsValid(void) const { return (m_LuaState != nullptr); }
/** Adds the specified path to package.<a_PathVariable> */ /** Adds the specified path to package.<a_PathVariable> */
void AddPackagePath(const AString & a_PathVariable, const AString & a_Path); void AddPackagePath(const AString & a_PathVariable, const AString & a_Path);
@ -318,10 +318,10 @@ public:
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 = NULL); 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 = NULL); static void LogStack(lua_State * a_LuaState, const char * a_Header = nullptr);
protected: protected:

View File

@ -18,7 +18,7 @@
cLuaWindow::cLuaWindow(cWindow::WindowType a_WindowType, int a_SlotsX, int a_SlotsY, const AString & a_Title) : cLuaWindow::cLuaWindow(cWindow::WindowType a_WindowType, int a_SlotsX, int a_SlotsY, const AString & a_Title) :
super(a_WindowType, a_Title), super(a_WindowType, a_Title),
m_Contents(a_SlotsX, a_SlotsY), m_Contents(a_SlotsX, a_SlotsY),
m_Plugin(NULL), m_Plugin(nullptr),
m_LuaRef(LUA_REFNIL), m_LuaRef(LUA_REFNIL),
m_OnClosingFnRef(LUA_REFNIL), m_OnClosingFnRef(LUA_REFNIL),
m_OnSlotChangedFnRef(LUA_REFNIL) m_OnSlotChangedFnRef(LUA_REFNIL)
@ -70,7 +70,7 @@ cLuaWindow::~cLuaWindow()
void cLuaWindow::SetLuaRef(cPluginLua * a_Plugin, int a_LuaRef) void cLuaWindow::SetLuaRef(cPluginLua * a_Plugin, int a_LuaRef)
{ {
// 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 == NULL) || (m_Plugin == a_Plugin)); ASSERT((m_Plugin == nullptr) || (m_Plugin == a_Plugin));
ASSERT(m_LuaRef == LUA_REFNIL); ASSERT(m_LuaRef == LUA_REFNIL);
m_Plugin = a_Plugin; m_Plugin = a_Plugin;
m_LuaRef = a_LuaRef; m_LuaRef = a_LuaRef;
@ -82,7 +82,7 @@ void cLuaWindow::SetLuaRef(cPluginLua * a_Plugin, int a_LuaRef)
bool cLuaWindow::IsLuaReferenced(void) const bool cLuaWindow::IsLuaReferenced(void) const
{ {
return ((m_Plugin != NULL) && (m_LuaRef != LUA_REFNIL)); return ((m_Plugin != nullptr) && (m_LuaRef != LUA_REFNIL));
} }
@ -92,7 +92,7 @@ bool cLuaWindow::IsLuaReferenced(void) const
void cLuaWindow::SetOnClosing(cPluginLua * a_Plugin, int a_FnRef) 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 == NULL) || (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)
@ -112,7 +112,7 @@ void cLuaWindow::SetOnClosing(cPluginLua * a_Plugin, int a_FnRef)
void cLuaWindow::SetOnSlotChanged(cPluginLua * a_Plugin, int a_FnRef) 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 == NULL) || (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)
@ -134,7 +134,7 @@ bool cLuaWindow::ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse)
// First notify the plugin through the registered callback: // First notify the plugin through the registered callback:
if (m_OnClosingFnRef != LUA_REFNIL) if (m_OnClosingFnRef != LUA_REFNIL)
{ {
ASSERT(m_Plugin != NULL); ASSERT(m_Plugin != nullptr);
if (m_Plugin->CallbackWindowClosing(m_OnClosingFnRef, *this, a_Player, a_CanRefuse)) if (m_Plugin->CallbackWindowClosing(m_OnClosingFnRef, *this, a_Player, a_CanRefuse))
{ {
// The callback disagrees (the higher levels check the CanRefuse flag compliance) // The callback disagrees (the higher levels check the CanRefuse flag compliance)
@ -153,7 +153,7 @@ void cLuaWindow::Destroy(void)
{ {
super::Destroy(); super::Destroy();
if ((m_LuaRef != LUA_REFNIL) && (m_Plugin != NULL)) 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);

View File

@ -145,13 +145,13 @@ static AString GetLogMessage(lua_State * tolua_S)
tolua_Error err; tolua_Error err;
if (tolua_isusertype(tolua_S, 1, "cCompositeChat", false, &err)) if (tolua_isusertype(tolua_S, 1, "cCompositeChat", false, &err))
{ {
return ((cCompositeChat *)tolua_tousertype(tolua_S, 1, NULL))->ExtractText(); return ((cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr))->ExtractText();
} }
else else
{ {
size_t len = 0; size_t len = 0;
const char * str = lua_tolstring(tolua_S, 1, &len); const char * str = lua_tolstring(tolua_S, 1, &len);
if (str != NULL) if (str != nullptr)
{ {
return AString(str, len); return AString(str, len);
} }
@ -170,7 +170,7 @@ static int tolua_LOG(lua_State * tolua_S)
tolua_Error err; tolua_Error err;
if (tolua_isusertype(tolua_S, 1, "cCompositeChat", false, &err)) if (tolua_isusertype(tolua_S, 1, "cCompositeChat", false, &err))
{ {
LogLevel = cCompositeChat::MessageTypeToLogLevel(((cCompositeChat *)tolua_tousertype(tolua_S, 1, NULL))->GetMessageType()); LogLevel = cCompositeChat::MessageTypeToLogLevel(((cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr))->GetMessageType());
} }
// Log the message: // Log the message:
@ -264,7 +264,7 @@ static cPluginLua * GetLuaPlugin(lua_State * L)
{ {
LOGWARNING("%s: cannot get plugin instance, what have you done to my Lua state?", __FUNCTION__); LOGWARNING("%s: cannot get plugin instance, what have you done to my Lua state?", __FUNCTION__);
lua_pop(L, 1); lua_pop(L, 1);
return NULL; return nullptr;
} }
cPluginLua * Plugin = (cPluginLua *)lua_topointer(L, -1); cPluginLua * Plugin = (cPluginLua *)lua_topointer(L, -1);
lua_pop(L, 1); lua_pop(L, 1);
@ -312,10 +312,10 @@ static int tolua_DoWith(lua_State* tolua_S)
return lua_do_error(tolua_S, "Error in function call '#funcname#': Requires 2 or 3 arguments, got %i", NumArgs); return lua_do_error(tolua_S, "Error in function call '#funcname#': Requires 2 or 3 arguments, got %i", NumArgs);
} }
Ty1 * self = (Ty1 *) tolua_tousertype(tolua_S, 1, NULL); Ty1 * self = (Ty1 *) tolua_tousertype(tolua_S, 1, nullptr);
const char * ItemName = tolua_tocppstring(tolua_S, 2, ""); const char * ItemName = tolua_tocppstring(tolua_S, 2, "");
if ((ItemName == NULL) || (ItemName[0] == 0)) if ((ItemName == nullptr) || (ItemName[0] == 0))
{ {
return lua_do_error(tolua_S, "Error in function call '#funcname#': Expected a non-empty string for parameter #1", NumArgs); return lua_do_error(tolua_S, "Error in function call '#funcname#': Expected a non-empty string for parameter #1", NumArgs);
} }
@ -406,7 +406,7 @@ static int tolua_DoWithID(lua_State* tolua_S)
return lua_do_error(tolua_S, "Error in function call '#funcname#': Requires 2 or 3 arguments, got %i", NumArgs); return lua_do_error(tolua_S, "Error in function call '#funcname#': Requires 2 or 3 arguments, got %i", NumArgs);
} }
Ty1 * self = (Ty1 *)tolua_tousertype(tolua_S, 1, NULL); Ty1 * self = (Ty1 *)tolua_tousertype(tolua_S, 1, nullptr);
int ItemID = (int)tolua_tonumber(tolua_S, 2, 0); int ItemID = (int)tolua_tonumber(tolua_S, 2, 0);
if (!lua_isfunction(tolua_S, 3)) if (!lua_isfunction(tolua_S, 3))
@ -496,7 +496,7 @@ static int tolua_DoWithXYZ(lua_State* tolua_S)
return lua_do_error(tolua_S, "Error in function call '#funcname#': Requires 4 or 5 arguments, got %i", NumArgs); return lua_do_error(tolua_S, "Error in function call '#funcname#': Requires 4 or 5 arguments, got %i", NumArgs);
} }
Ty1 * self = (Ty1 *) tolua_tousertype(tolua_S, 1, NULL); Ty1 * self = (Ty1 *) tolua_tousertype(tolua_S, 1, nullptr);
if (!lua_isnumber(tolua_S, 2) || !lua_isnumber(tolua_S, 3) || !lua_isnumber(tolua_S, 4)) if (!lua_isnumber(tolua_S, 2) || !lua_isnumber(tolua_S, 3) || !lua_isnumber(tolua_S, 4))
{ {
return lua_do_error(tolua_S, "Error in function call '#funcname#': Expected a number for parameters #1, #2 and #3"); return lua_do_error(tolua_S, "Error in function call '#funcname#': Expected a number for parameters #1, #2 and #3");
@ -591,7 +591,7 @@ static int tolua_ForEachInChunk(lua_State * tolua_S)
return lua_do_error(tolua_S, "Error in function call '#funcname#': Requires 3 or 4 arguments, got %i", NumArgs); return lua_do_error(tolua_S, "Error in function call '#funcname#': Requires 3 or 4 arguments, got %i", NumArgs);
} }
Ty1 * self = (Ty1 *) tolua_tousertype(tolua_S, 1, NULL); Ty1 * self = (Ty1 *) tolua_tousertype(tolua_S, 1, nullptr);
if (!lua_isnumber(tolua_S, 2) || !lua_isnumber(tolua_S, 3)) if (!lua_isnumber(tolua_S, 2) || !lua_isnumber(tolua_S, 3))
{ {
return lua_do_error(tolua_S, "Error in function call '#funcname#': Expected a number for parameters #1 and #2"); return lua_do_error(tolua_S, "Error in function call '#funcname#': Expected a number for parameters #1 and #2");
@ -694,10 +694,10 @@ static int tolua_ForEachInBox(lua_State * tolua_S)
} }
// Get the params: // Get the params:
Ty1 * Self = NULL; Ty1 * Self = nullptr;
cBoundingBox * Box = NULL; cBoundingBox * Box = nullptr;
L.GetStackValues(1, Self, Box); L.GetStackValues(1, Self, Box);
if ((Self == NULL) || (Box == NULL)) if ((Self == nullptr) || (Box == nullptr))
{ {
LOGWARNING("Invalid world (%p) or boundingbox (%p)", Self, Box); LOGWARNING("Invalid world (%p) or boundingbox (%p)", Self, Box);
L.LogStackTrace(); L.LogStackTrace();
@ -760,8 +760,8 @@ static int tolua_ForEach(lua_State * tolua_S)
return lua_do_error(tolua_S, "Error in function call '#funcname#': Requires 1 or 2 arguments, got %i", NumArgs); return lua_do_error(tolua_S, "Error in function call '#funcname#': Requires 1 or 2 arguments, got %i", NumArgs);
} }
Ty1 * self = (Ty1 *)tolua_tousertype(tolua_S, 1, NULL); Ty1 * self = (Ty1 *)tolua_tousertype(tolua_S, 1, nullptr);
if (self == NULL) if (self == nullptr)
{ {
return lua_do_error(tolua_S, "Error in function call '#funcname#': Not called on an object instance"); return lua_do_error(tolua_S, "Error in function call '#funcname#': Not called on an object instance");
} }
@ -857,14 +857,14 @@ static int tolua_cWorld_GetBlockInfo(lua_State * tolua_S)
else else
#endif #endif
{ {
cWorld * self = (cWorld *) tolua_tousertype (tolua_S, 1, NULL); cWorld * self = (cWorld *) tolua_tousertype (tolua_S, 1, nullptr);
int BlockX = (int) tolua_tonumber (tolua_S, 2, 0); int BlockX = (int) tolua_tonumber (tolua_S, 2, 0);
int BlockY = (int) tolua_tonumber (tolua_S, 3, 0); int BlockY = (int) tolua_tonumber (tolua_S, 3, 0);
int BlockZ = (int) tolua_tonumber (tolua_S, 4, 0); int BlockZ = (int) tolua_tonumber (tolua_S, 4, 0);
#ifndef TOLUA_RELEASE #ifndef TOLUA_RELEASE
if (self == NULL) if (self == nullptr)
{ {
tolua_error(tolua_S, "invalid 'self' in function 'GetBlockInfo'", NULL); tolua_error(tolua_S, "invalid 'self' in function 'GetBlockInfo'", nullptr);
} }
#endif #endif
{ {
@ -912,14 +912,14 @@ static int tolua_cWorld_GetBlockTypeMeta(lua_State * tolua_S)
else else
#endif #endif
{ {
cWorld * self = (cWorld *) tolua_tousertype (tolua_S, 1, NULL); cWorld * self = (cWorld *) tolua_tousertype (tolua_S, 1, nullptr);
int BlockX = (int) tolua_tonumber (tolua_S, 2, 0); int BlockX = (int) tolua_tonumber (tolua_S, 2, 0);
int BlockY = (int) tolua_tonumber (tolua_S, 3, 0); int BlockY = (int) tolua_tonumber (tolua_S, 3, 0);
int BlockZ = (int) tolua_tonumber (tolua_S, 4, 0); int BlockZ = (int) tolua_tonumber (tolua_S, 4, 0);
#ifndef TOLUA_RELEASE #ifndef TOLUA_RELEASE
if (self == NULL) if (self == nullptr)
{ {
tolua_error(tolua_S, "invalid 'self' in function 'GetBlockTypeMeta'", NULL); tolua_error(tolua_S, "invalid 'self' in function 'GetBlockTypeMeta'", nullptr);
} }
#endif #endif
{ {
@ -964,14 +964,14 @@ static int tolua_cWorld_GetSignLines(lua_State * tolua_S)
else else
#endif #endif
{ {
cWorld * self = (cWorld *) tolua_tousertype (tolua_S, 1, NULL); cWorld * self = (cWorld *) tolua_tousertype (tolua_S, 1, nullptr);
int BlockX = (int) tolua_tonumber (tolua_S, 2, 0); int BlockX = (int) tolua_tonumber (tolua_S, 2, 0);
int BlockY = (int) tolua_tonumber (tolua_S, 3, 0); int BlockY = (int) tolua_tonumber (tolua_S, 3, 0);
int BlockZ = (int) tolua_tonumber (tolua_S, 4, 0); int BlockZ = (int) tolua_tonumber (tolua_S, 4, 0);
#ifndef TOLUA_RELEASE #ifndef TOLUA_RELEASE
if (self == NULL) if (self == nullptr)
{ {
tolua_error(tolua_S, "invalid 'self' in function 'GetSignLines'", NULL); tolua_error(tolua_S, "invalid 'self' in function 'GetSignLines'", nullptr);
} }
#endif #endif
{ {
@ -1022,7 +1022,7 @@ static int tolua_cWorld_SetSignLines(lua_State * tolua_S)
else else
#endif #endif
{ {
cWorld * self = (cWorld *) tolua_tousertype (tolua_S, 1, NULL); cWorld * self = (cWorld *) tolua_tousertype (tolua_S, 1, nullptr);
int BlockX = (int) tolua_tonumber (tolua_S, 2, 0); int BlockX = (int) tolua_tonumber (tolua_S, 2, 0);
int BlockY = (int) tolua_tonumber (tolua_S, 3, 0); int BlockY = (int) tolua_tonumber (tolua_S, 3, 0);
int BlockZ = (int) tolua_tonumber (tolua_S, 4, 0); int BlockZ = (int) tolua_tonumber (tolua_S, 4, 0);
@ -1030,11 +1030,11 @@ static int tolua_cWorld_SetSignLines(lua_State * tolua_S)
const AString Line2 = tolua_tocppstring(tolua_S, 6, 0); const AString Line2 = tolua_tocppstring(tolua_S, 6, 0);
const AString Line3 = tolua_tocppstring(tolua_S, 7, 0); const AString Line3 = tolua_tocppstring(tolua_S, 7, 0);
const AString Line4 = tolua_tocppstring(tolua_S, 8, 0); const AString Line4 = tolua_tocppstring(tolua_S, 8, 0);
cPlayer * Player = (cPlayer *)tolua_tousertype (tolua_S, 9, NULL); cPlayer * Player = (cPlayer *)tolua_tousertype (tolua_S, 9, nullptr);
#ifndef TOLUA_RELEASE #ifndef TOLUA_RELEASE
if (self == NULL) if (self == nullptr)
{ {
tolua_error(tolua_S, "invalid 'self' in function 'SetSignLines' / 'UpdateSign'", NULL); tolua_error(tolua_S, "invalid 'self' in function 'SetSignLines' / 'UpdateSign'", nullptr);
} }
#endif #endif
{ {
@ -1071,13 +1071,13 @@ static int tolua_cWorld_TryGetHeight(lua_State * tolua_S)
else else
#endif #endif
{ {
cWorld * self = (cWorld *) tolua_tousertype (tolua_S, 1, NULL); cWorld * self = (cWorld *) tolua_tousertype (tolua_S, 1, nullptr);
int BlockX = (int) tolua_tonumber (tolua_S, 2, 0); int BlockX = (int) tolua_tonumber (tolua_S, 2, 0);
int BlockZ = (int) tolua_tonumber (tolua_S, 3, 0); int BlockZ = (int) tolua_tonumber (tolua_S, 3, 0);
#ifndef TOLUA_RELEASE #ifndef TOLUA_RELEASE
if (self == NULL) if (self == nullptr)
{ {
tolua_error(tolua_S, "Invalid 'self' in function 'TryGetHeight'", NULL); tolua_error(tolua_S, "Invalid 'self' in function 'TryGetHeight'", nullptr);
} }
#endif #endif
{ {
@ -1136,15 +1136,15 @@ static int tolua_cWorld_QueueTask(lua_State * tolua_S)
// Retrieve the cPlugin from the LuaState: // Retrieve the cPlugin from the LuaState:
cPluginLua * Plugin = GetLuaPlugin(tolua_S); cPluginLua * Plugin = GetLuaPlugin(tolua_S);
if (Plugin == NULL) if (Plugin == nullptr)
{ {
// An error message has been already printed in GetLuaPlugin() // An error message has been already printed in GetLuaPlugin()
return 0; return 0;
} }
// Retrieve the args: // Retrieve the args:
cWorld * self = (cWorld *)tolua_tousertype(tolua_S, 1, NULL); cWorld * self = (cWorld *)tolua_tousertype(tolua_S, 1, nullptr);
if (self == NULL) if (self == nullptr)
{ {
return lua_do_error(tolua_S, "Error in function call '#funcname#': Not called on an object instance"); return lua_do_error(tolua_S, "Error in function call '#funcname#': Not called on an object instance");
} }
@ -1200,7 +1200,7 @@ static int tolua_cWorld_ScheduleTask(lua_State * tolua_S)
// Retrieve the cPlugin from the LuaState: // Retrieve the cPlugin from the LuaState:
cPluginLua * Plugin = GetLuaPlugin(tolua_S); cPluginLua * Plugin = GetLuaPlugin(tolua_S);
if (Plugin == NULL) if (Plugin == nullptr)
{ {
// An error message has been already printed in GetLuaPlugin() // An error message has been already printed in GetLuaPlugin()
return 0; return 0;
@ -1216,8 +1216,8 @@ static int tolua_cWorld_ScheduleTask(lua_State * tolua_S)
{ {
return 0; return 0;
} }
cWorld * World = (cWorld *)tolua_tousertype(tolua_S, 1, NULL); cWorld * World = (cWorld *)tolua_tousertype(tolua_S, 1, nullptr);
if (World == NULL) if (World == nullptr)
{ {
return lua_do_error(tolua_S, "Error in function call '#funcname#': Not called on an object instance"); return lua_do_error(tolua_S, "Error in function call '#funcname#': Not called on an object instance");
} }
@ -1241,7 +1241,7 @@ static int tolua_cWorld_ScheduleTask(lua_State * tolua_S)
static int tolua_cPluginManager_GetAllPlugins(lua_State * tolua_S) static int tolua_cPluginManager_GetAllPlugins(lua_State * tolua_S)
{ {
cPluginManager * self = (cPluginManager *)tolua_tousertype(tolua_S, 1, NULL); cPluginManager * self = (cPluginManager *)tolua_tousertype(tolua_S, 1, nullptr);
const cPluginManager::PluginMap & AllPlugins = self->GetAllPlugins(); const cPluginManager::PluginMap & AllPlugins = self->GetAllPlugins();
@ -1252,7 +1252,7 @@ static int tolua_cPluginManager_GetAllPlugins(lua_State * tolua_S)
{ {
const cPlugin* Plugin = iter->second; const cPlugin* Plugin = iter->second;
tolua_pushstring(tolua_S, iter->first.c_str()); tolua_pushstring(tolua_S, iter->first.c_str());
if (Plugin != NULL) if (Plugin != nullptr)
{ {
tolua_pushusertype(tolua_S, (void *)Plugin, "const cPlugin"); tolua_pushusertype(tolua_S, (void *)Plugin, "const cPlugin");
} }
@ -1274,7 +1274,7 @@ static int tolua_cPluginManager_GetAllPlugins(lua_State * tolua_S)
static int tolua_cPluginManager_GetCurrentPlugin(lua_State * S) static int tolua_cPluginManager_GetCurrentPlugin(lua_State * S)
{ {
cPluginLua * Plugin = GetLuaPlugin(S); cPluginLua * Plugin = GetLuaPlugin(S);
if (Plugin == NULL) if (Plugin == nullptr)
{ {
// An error message has already been printed in GetLuaPlugin() // An error message has already been printed in GetLuaPlugin()
return 0; return 0;
@ -1305,7 +1305,7 @@ static int tolua_cPluginManager_AddHook_FnRef(cPluginManager * a_PluginManager,
// Retrieve the cPlugin from the LuaState: // Retrieve the cPlugin from the LuaState:
cPluginLua * Plugin = GetLuaPlugin(S); cPluginLua * Plugin = GetLuaPlugin(S);
if (Plugin == NULL) if (Plugin == nullptr)
{ {
// An error message has been already printed in GetLuaPlugin() // An error message has been already printed in GetLuaPlugin()
return 0; return 0;
@ -1344,8 +1344,8 @@ static int tolua_cPluginManager_AddHook_DefFn(cPluginManager * a_PluginManager,
// 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 = (cPluginLua *)tolua_tousertype(S, a_ParamIdx, NULL); cPluginLua * Plugin = (cPluginLua *)tolua_tousertype(S, a_ParamIdx, nullptr);
if (Plugin == NULL) if (Plugin == nullptr)
{ {
LOGWARNING("cPluginManager.AddHook(): Invalid Plugin parameter, expected a valid cPlugin object. Hook not added"); LOGWARNING("cPluginManager.AddHook(): Invalid Plugin parameter, expected a valid cPlugin object. Hook not added");
S.LogStackTrace(); S.LogStackTrace();
@ -1370,7 +1370,7 @@ static int tolua_cPluginManager_AddHook_DefFn(cPluginManager * a_PluginManager,
// 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 == NULL) if (FnName == nullptr)
{ {
LOGWARNING("cPluginManager.AddHook(): Unknown hook type (%d). Hook not added.", HookType); LOGWARNING("cPluginManager.AddHook(): Unknown hook type (%d). Hook not added.", HookType);
S.LogStackTrace(); S.LogStackTrace();
@ -1417,8 +1417,8 @@ static int tolua_cPluginManager_AddHook(lua_State * tolua_S)
if (tolua_isusertype(S, 1, "cPluginManager", 0, &err)) if (tolua_isusertype(S, 1, "cPluginManager", 0, &err))
{ {
// Style 2 or 3, retrieve the PlgMgr instance // Style 2 or 3, retrieve the PlgMgr instance
PlgMgr = (cPluginManager *)tolua_tousertype(S, 1, NULL); PlgMgr = (cPluginManager *)tolua_tousertype(S, 1, nullptr);
if (PlgMgr == NULL) if (PlgMgr == nullptr)
{ {
LOGWARNING("Malformed plugin, use cPluginManager.AddHook(HOOK_TYPE, CallbackFunction). Fixing the call for you."); LOGWARNING("Malformed plugin, use cPluginManager.AddHook(HOOK_TYPE, CallbackFunction). Fixing the call for you.");
S.LogStackTrace(); S.LogStackTrace();
@ -1465,8 +1465,8 @@ static int tolua_cPluginManager_ForEachCommand(lua_State * tolua_S)
return 0; return 0;
} }
cPluginManager * self = (cPluginManager *)tolua_tousertype(tolua_S, 1, NULL); cPluginManager * self = (cPluginManager *)tolua_tousertype(tolua_S, 1, nullptr);
if (self == NULL) if (self == nullptr)
{ {
LOGWARN("Error in function call 'ForEachCommand': Not called on an object instance"); LOGWARN("Error in function call 'ForEachCommand': Not called on an object instance");
return 0; return 0;
@ -1542,8 +1542,8 @@ static int tolua_cPluginManager_ForEachConsoleCommand(lua_State * tolua_S)
return 0; return 0;
} }
cPluginManager * self = (cPluginManager *)tolua_tousertype(tolua_S, 1, NULL); cPluginManager * self = (cPluginManager *)tolua_tousertype(tolua_S, 1, nullptr);
if (self == NULL) if (self == nullptr)
{ {
LOGWARN("Error in function call 'ForEachConsoleCommand': Not called on an object instance"); LOGWARN("Error in function call 'ForEachConsoleCommand': Not called on an object instance");
return 0; return 0;
@ -1617,7 +1617,7 @@ static int tolua_cPluginManager_BindCommand(lua_State * L)
cPluginManager.BindCommand(Command, Permission, Function, HelpString) -- without the "self" param cPluginManager.BindCommand(Command, Permission, Function, HelpString) -- without the "self" param
*/ */
cPluginLua * Plugin = GetLuaPlugin(L); cPluginLua * Plugin = GetLuaPlugin(L);
if (Plugin == NULL) if (Plugin == nullptr)
{ {
return 0; return 0;
} }
@ -1687,7 +1687,7 @@ static int tolua_cPluginManager_BindConsoleCommand(lua_State * L)
// Get the plugin identification out of LuaState: // Get the plugin identification out of LuaState:
cPluginLua * Plugin = GetLuaPlugin(L); cPluginLua * Plugin = GetLuaPlugin(L);
if (Plugin == NULL) if (Plugin == nullptr)
{ {
return 0; return 0;
} }
@ -1775,7 +1775,7 @@ static int tolua_cPluginManager_CallPlugin(lua_State * tolua_S)
// If requesting calling the current plugin, refuse: // If requesting calling the current plugin, refuse:
cPluginLua * ThisPlugin = GetLuaPlugin(L); cPluginLua * ThisPlugin = GetLuaPlugin(L);
if (ThisPlugin == NULL) if (ThisPlugin == nullptr)
{ {
return 0; return 0;
} }
@ -1843,14 +1843,14 @@ static int tolua_cWorld_ChunkStay(lua_State * tolua_S)
} }
cPluginLua * Plugin = GetLuaPlugin(tolua_S); cPluginLua * Plugin = GetLuaPlugin(tolua_S);
if (Plugin == NULL) if (Plugin == nullptr)
{ {
return 0; return 0;
} }
// Read the params: // Read the params:
cWorld * World = (cWorld *)tolua_tousertype(tolua_S, 1, NULL); cWorld * World = (cWorld *)tolua_tousertype(tolua_S, 1, nullptr);
if (World == NULL) if (World == nullptr)
{ {
LOGWARNING("World:ChunkStay(): invalid world parameter"); LOGWARNING("World:ChunkStay(): invalid world parameter");
L.LogStackTrace(); L.LogStackTrace();
@ -1862,7 +1862,7 @@ static int tolua_cWorld_ChunkStay(lua_State * tolua_S)
if (!ChunkStay->AddChunks(2)) if (!ChunkStay->AddChunks(2))
{ {
delete ChunkStay; delete ChunkStay;
ChunkStay = NULL; ChunkStay = nullptr;
return 0; return 0;
} }
@ -1889,8 +1889,8 @@ static int tolua_cPlayer_GetPermissions(lua_State * tolua_S)
} }
// Get the params: // Get the params:
cPlayer * self = (cPlayer *)tolua_tousertype(tolua_S, 1, NULL); cPlayer * self = (cPlayer *)tolua_tousertype(tolua_S, 1, nullptr);
if (self == NULL) if (self == nullptr)
{ {
LOGWARNING("%s: invalid self (%p)", __FUNCTION__, self); LOGWARNING("%s: invalid self (%p)", __FUNCTION__, self);
return 0; return 0;
@ -1911,15 +1911,15 @@ static int tolua_cPlayer_OpenWindow(lua_State * tolua_S)
// Retrieve the plugin instance from the Lua state // Retrieve the plugin instance from the Lua state
cPluginLua * Plugin = GetLuaPlugin(tolua_S); cPluginLua * Plugin = GetLuaPlugin(tolua_S);
if (Plugin == NULL) if (Plugin == nullptr)
{ {
return 0; return 0;
} }
// Get the parameters: // Get the parameters:
cPlayer * self = (cPlayer *)tolua_tousertype(tolua_S, 1, NULL); cPlayer * self = (cPlayer *)tolua_tousertype(tolua_S, 1, nullptr);
cWindow * wnd = (cWindow *)tolua_tousertype(tolua_S, 2, NULL); cWindow * wnd = (cWindow *)tolua_tousertype(tolua_S, 2, nullptr);
if ((self == NULL) || (wnd == NULL)) if ((self == nullptr) || (wnd == nullptr))
{ {
LOGWARNING("%s: invalid self (%p) or wnd (%p)", __FUNCTION__, self, wnd); LOGWARNING("%s: invalid self (%p) or wnd (%p)", __FUNCTION__, self, wnd);
return 0; return 0;
@ -1992,15 +1992,15 @@ static int tolua_SetObjectCallback(lua_State * tolua_S)
// Retrieve the plugin instance from the Lua state // Retrieve the plugin instance from the Lua state
cPluginLua * Plugin = GetLuaPlugin(tolua_S); cPluginLua * Plugin = GetLuaPlugin(tolua_S);
if (Plugin == NULL) if (Plugin == nullptr)
{ {
// Warning message has already been printed by GetLuaPlugin(), bail out silently // Warning message has already been printed by GetLuaPlugin(), bail out silently
return 0; return 0;
} }
// Get the parameters - self and the function reference: // Get the parameters - self and the function reference:
OBJTYPE * self = (OBJTYPE *)tolua_tousertype(tolua_S, 1, NULL); OBJTYPE * self = (OBJTYPE *)tolua_tousertype(tolua_S, 1, nullptr);
if (self == NULL) if (self == nullptr)
{ {
LOGWARNING("%s: invalid self (%p)", __FUNCTION__, self); LOGWARNING("%s: invalid self (%p)", __FUNCTION__, self);
return 0; return 0;
@ -2023,7 +2023,7 @@ static int tolua_SetObjectCallback(lua_State * tolua_S)
static int tolua_cPluginLua_AddWebTab(lua_State * tolua_S) static int tolua_cPluginLua_AddWebTab(lua_State * tolua_S)
{ {
cPluginLua * self = (cPluginLua *)tolua_tousertype(tolua_S, 1, NULL); cPluginLua * self = (cPluginLua *)tolua_tousertype(tolua_S, 1, nullptr);
tolua_Error tolua_err; tolua_Error tolua_err;
tolua_err.array = 0; tolua_err.array = 0;
@ -2067,7 +2067,7 @@ static int tolua_cPluginLua_AddWebTab(lua_State * tolua_S)
static int tolua_cPluginLua_AddTab(lua_State* tolua_S) static int tolua_cPluginLua_AddTab(lua_State* tolua_S)
{ {
cPluginLua * self = (cPluginLua *) tolua_tousertype(tolua_S, 1, NULL); cPluginLua * self = (cPluginLua *) tolua_tousertype(tolua_S, 1, nullptr);
LOGWARN("WARNING: Using deprecated function AddTab()! Use AddWebTab() instead. (plugin \"%s\" in folder \"%s\")", LOGWARN("WARNING: Using deprecated function AddTab()! Use AddWebTab() instead. (plugin \"%s\" in folder \"%s\")",
self->GetName().c_str(), self->GetDirectory().c_str() self->GetName().c_str(), self->GetDirectory().c_str()
); );
@ -2087,7 +2087,7 @@ static int tolua_cPlugin_Call(lua_State * tolua_S)
L.LogStackTrace(); L.LogStackTrace();
// Retrieve the params: plugin and the function name to call // Retrieve the params: plugin and the function name to call
cPluginLua * TargetPlugin = (cPluginLua *) tolua_tousertype(tolua_S, 1, NULL); cPluginLua * TargetPlugin = (cPluginLua *) tolua_tousertype(tolua_S, 1, nullptr);
AString FunctionName = tolua_tostring(tolua_S, 2, ""); AString FunctionName = tolua_tostring(tolua_S, 2, "");
// Call the function: // Call the function:
@ -2142,7 +2142,7 @@ static int tolua_push_StringStringMap(lua_State* tolua_S, std::map< std::string,
static int tolua_get_HTTPRequest_Params(lua_State* tolua_S) static int tolua_get_HTTPRequest_Params(lua_State* tolua_S)
{ {
HTTPRequest* self = (HTTPRequest*) tolua_tousertype(tolua_S, 1, NULL); HTTPRequest* self = (HTTPRequest*) tolua_tousertype(tolua_S, 1, nullptr);
return tolua_push_StringStringMap(tolua_S, self->Params); return tolua_push_StringStringMap(tolua_S, self->Params);
} }
@ -2152,7 +2152,7 @@ static int tolua_get_HTTPRequest_Params(lua_State* tolua_S)
static int tolua_get_HTTPRequest_PostParams(lua_State* tolua_S) static int tolua_get_HTTPRequest_PostParams(lua_State* tolua_S)
{ {
HTTPRequest* self = (HTTPRequest*) tolua_tousertype(tolua_S, 1, NULL); HTTPRequest* self = (HTTPRequest*) tolua_tousertype(tolua_S, 1, nullptr);
return tolua_push_StringStringMap(tolua_S, self->PostParams); return tolua_push_StringStringMap(tolua_S, self->PostParams);
} }
@ -2162,7 +2162,7 @@ static int tolua_get_HTTPRequest_PostParams(lua_State* tolua_S)
static int tolua_get_HTTPRequest_FormData(lua_State* tolua_S) static int tolua_get_HTTPRequest_FormData(lua_State* tolua_S)
{ {
HTTPRequest* self = (HTTPRequest*) tolua_tousertype(tolua_S, 1, NULL); HTTPRequest* self = (HTTPRequest*) tolua_tousertype(tolua_S, 1, nullptr);
std::map< std::string, HTTPFormData >& FormData = self->FormData; std::map< std::string, HTTPFormData >& FormData = self->FormData;
lua_newtable(tolua_S); lua_newtable(tolua_S);
@ -2185,7 +2185,7 @@ static int tolua_get_HTTPRequest_FormData(lua_State* tolua_S)
static int tolua_cWebAdmin_GetPlugins(lua_State * tolua_S) static int tolua_cWebAdmin_GetPlugins(lua_State * tolua_S)
{ {
cWebAdmin * self = (cWebAdmin *)tolua_tousertype(tolua_S, 1, NULL); cWebAdmin * self = (cWebAdmin *)tolua_tousertype(tolua_S, 1, nullptr);
const cWebAdmin::PluginList & AllPlugins = self->GetPlugins(); const cWebAdmin::PluginList & AllPlugins = self->GetPlugins();
@ -2266,7 +2266,7 @@ static int tolua_AllToLua_cWebAdmin_GetURLEncodedString(lua_State * tolua_S)
static int tolua_cWebPlugin_GetTabNames(lua_State * tolua_S) static int tolua_cWebPlugin_GetTabNames(lua_State * tolua_S)
{ {
cWebPlugin* self = (cWebPlugin*) tolua_tousertype(tolua_S, 1, NULL); cWebPlugin* self = (cWebPlugin*) tolua_tousertype(tolua_S, 1, nullptr);
const cWebPlugin::TabNameList & TabNames = self->GetTabNames(); const cWebPlugin::TabNameList & TabNames = self->GetTabNames();
@ -2302,8 +2302,8 @@ static int tolua_cClientHandle_SendPluginMessage(lua_State * L)
{ {
return 0; return 0;
} }
cClientHandle * Client = (cClientHandle *)tolua_tousertype(L, 1, NULL); cClientHandle * Client = (cClientHandle *)tolua_tousertype(L, 1, nullptr);
if (Client == NULL) if (Client == nullptr)
{ {
LOGWARNING("ClientHandle is nil in cClientHandle:SendPluginMessage()"); LOGWARNING("ClientHandle is nil in cClientHandle:SendPluginMessage()");
S.LogStackTrace(); S.LogStackTrace();
@ -2548,11 +2548,11 @@ static int Lua_ItemGrid_GetSlotCoords(lua_State * L)
} }
{ {
const cItemGrid * self = (const cItemGrid *)tolua_tousertype(L, 1, NULL); const cItemGrid * self = (const cItemGrid *)tolua_tousertype(L, 1, nullptr);
int SlotNum = (int)tolua_tonumber(L, 2, 0); int SlotNum = (int)tolua_tonumber(L, 2, 0);
if (self == NULL) if (self == nullptr)
{ {
tolua_error(L, "invalid 'self' in function 'cItemGrid:GetSlotCoords'", NULL); tolua_error(L, "invalid 'self' in function 'cItemGrid:GetSlotCoords'", nullptr);
return 0; return 0;
} }
int X, Y; int X, Y;
@ -2689,7 +2689,7 @@ static int tolua_cLineBlockTracer_Trace(lua_State * tolua_S)
} }
// Trace: // Trace:
cWorld * World = (cWorld *)tolua_tousertype(L, idx, NULL); cWorld * World = (cWorld *)tolua_tousertype(L, idx, nullptr);
cLuaBlockTracerCallbacks Callbacks(L, idx + 1); cLuaBlockTracerCallbacks Callbacks(L, idx + 1);
double StartX = tolua_tonumber(L, idx + 2, 0); double StartX = tolua_tonumber(L, idx + 2, 0);
double StartY = tolua_tonumber(L, idx + 3, 0); double StartY = tolua_tonumber(L, idx + 3, 0);
@ -2719,8 +2719,8 @@ static int tolua_cRoot_GetFurnaceRecipe(lua_State * tolua_S)
} }
// Check the input param: // Check the input param:
cItem * Input = (cItem *)tolua_tousertype(L, 2, NULL); cItem * Input = (cItem *)tolua_tousertype(L, 2, nullptr);
if (Input == NULL) if (Input == nullptr)
{ {
LOGWARNING("cRoot:GetFurnaceRecipe: the Input parameter is nil or missing."); LOGWARNING("cRoot:GetFurnaceRecipe: the Input parameter is nil or missing.");
return 0; return 0;
@ -2729,7 +2729,7 @@ static int tolua_cRoot_GetFurnaceRecipe(lua_State * tolua_S)
// 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);
if (Recipe == NULL) if (Recipe == nullptr)
{ {
// 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;
@ -2760,10 +2760,10 @@ static int tolua_cHopperEntity_GetOutputBlockPos(lua_State * tolua_S)
{ {
return 0; return 0;
} }
cHopperEntity * self = (cHopperEntity *)tolua_tousertype(tolua_S, 1, NULL); cHopperEntity * self = (cHopperEntity *)tolua_tousertype(tolua_S, 1, nullptr);
if (self == NULL) if (self == nullptr)
{ {
tolua_error(tolua_S, "invalid 'self' in function 'cHopperEntity::GetOutputBlockPos()'", NULL); tolua_error(tolua_S, "invalid 'self' in function 'cHopperEntity::GetOutputBlockPos()'", nullptr);
return 0; return 0;
} }
@ -2800,10 +2800,10 @@ static int tolua_cBlockArea_GetBlockTypeMeta(lua_State * tolua_S)
return 0; return 0;
} }
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL); cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
if (self == NULL) if (self == nullptr)
{ {
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetRelBlockTypeMeta'", NULL); tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetRelBlockTypeMeta'", nullptr);
return 0; return 0;
} }
int BlockX = (int)tolua_tonumber(tolua_S, 2, 0); int BlockX = (int)tolua_tonumber(tolua_S, 2, 0);
@ -2834,10 +2834,10 @@ static int tolua_cBlockArea_GetOrigin(lua_State * tolua_S)
return 0; return 0;
} }
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL); cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
if (self == NULL) if (self == nullptr)
{ {
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetOrigin'", NULL); tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetOrigin'", nullptr);
return 0; return 0;
} }
@ -2866,10 +2866,10 @@ static int tolua_cBlockArea_GetRelBlockTypeMeta(lua_State * tolua_S)
return 0; return 0;
} }
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL); cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
if (self == NULL) if (self == nullptr)
{ {
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetRelBlockTypeMeta'", NULL); tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetRelBlockTypeMeta'", nullptr);
return 0; return 0;
} }
int BlockX = (int)tolua_tonumber(tolua_S, 2, 0); int BlockX = (int)tolua_tonumber(tolua_S, 2, 0);
@ -2900,10 +2900,10 @@ static int tolua_cBlockArea_GetSize(lua_State * tolua_S)
return 0; return 0;
} }
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL); cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
if (self == NULL) if (self == nullptr)
{ {
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetSize'", NULL); tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetSize'", nullptr);
return 0; return 0;
} }
@ -2931,10 +2931,10 @@ static int tolua_cBlockArea_GetCoordRange(lua_State * tolua_S)
return 0; return 0;
} }
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL); cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
if (self == NULL) if (self == nullptr)
{ {
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetSize'", NULL); tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetSize'", nullptr);
return 0; return 0;
} }
@ -2962,10 +2962,10 @@ static int tolua_cBlockArea_LoadFromSchematicFile(lua_State * tolua_S)
{ {
return 0; return 0;
} }
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL); cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
if (self == NULL) if (self == nullptr)
{ {
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea::LoadFromSchematicFile'", NULL); tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea::LoadFromSchematicFile'", nullptr);
return 0; return 0;
} }
@ -2992,10 +2992,10 @@ static int tolua_cBlockArea_LoadFromSchematicString(lua_State * tolua_S)
{ {
return 0; return 0;
} }
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL); cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
if (self == NULL) if (self == nullptr)
{ {
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea::LoadFromSchematicFile'", NULL); tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea::LoadFromSchematicFile'", nullptr);
return 0; return 0;
} }
@ -3023,10 +3023,10 @@ static int tolua_cBlockArea_SaveToSchematicFile(lua_State * tolua_S)
{ {
return 0; return 0;
} }
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL); cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
if (self == NULL) if (self == nullptr)
{ {
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea::SaveToSchematicFile'", NULL); tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea::SaveToSchematicFile'", nullptr);
return 0; return 0;
} }
AString Filename = tolua_tostring(tolua_S, 2, 0); AString Filename = tolua_tostring(tolua_S, 2, 0);
@ -3051,10 +3051,10 @@ static int tolua_cBlockArea_SaveToSchematicString(lua_State * tolua_S)
{ {
return 0; return 0;
} }
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL); cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
if (self == NULL) if (self == nullptr)
{ {
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea::SaveToSchematicFile'", NULL); tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea::SaveToSchematicFile'", nullptr);
return 0; return 0;
} }
@ -3085,10 +3085,10 @@ static int tolua_cCompositeChat_AddRunCommandPart(lua_State * tolua_S)
{ {
return 0; return 0;
} }
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, NULL); cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr);
if (self == NULL) if (self == nullptr)
{ {
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:AddRunCommandPart'", NULL); tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:AddRunCommandPart'", nullptr);
return 0; return 0;
} }
@ -3122,10 +3122,10 @@ static int tolua_cCompositeChat_AddSuggestCommandPart(lua_State * tolua_S)
{ {
return 0; return 0;
} }
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, NULL); cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr);
if (self == NULL) if (self == nullptr)
{ {
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:AddSuggestCommandPart'", NULL); tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:AddSuggestCommandPart'", nullptr);
return 0; return 0;
} }
@ -3159,10 +3159,10 @@ static int tolua_cCompositeChat_AddTextPart(lua_State * tolua_S)
{ {
return 0; return 0;
} }
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, NULL); cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr);
if (self == NULL) if (self == nullptr)
{ {
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:AddTextPart'", NULL); tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:AddTextPart'", nullptr);
return 0; return 0;
} }
@ -3195,10 +3195,10 @@ static int tolua_cCompositeChat_AddUrlPart(lua_State * tolua_S)
{ {
return 0; return 0;
} }
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, NULL); cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr);
if (self == NULL) if (self == nullptr)
{ {
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:AddUrlPart'", NULL); tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:AddUrlPart'", nullptr);
return 0; return 0;
} }
@ -3232,10 +3232,10 @@ static int tolua_cCompositeChat_ParseText(lua_State * tolua_S)
{ {
return 0; return 0;
} }
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, NULL); cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr);
if (self == NULL) if (self == nullptr)
{ {
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:ParseText'", NULL); tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:ParseText'", nullptr);
return 0; return 0;
} }
@ -3267,10 +3267,10 @@ static int tolua_cCompositeChat_SetMessageType(lua_State * tolua_S)
{ {
return 0; return 0;
} }
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, NULL); cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr);
if (self == NULL) if (self == nullptr)
{ {
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:SetMessageType'", NULL); tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:SetMessageType'", nullptr);
return 0; return 0;
} }
@ -3299,10 +3299,10 @@ static int tolua_cCompositeChat_UnderlineUrls(lua_State * tolua_S)
{ {
return 0; return 0;
} }
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, NULL); cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr);
if (self == NULL) if (self == nullptr)
{ {
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:UnderlineUrls'", NULL); tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:UnderlineUrls'", nullptr);
return 0; return 0;
} }
@ -3320,7 +3320,7 @@ static int tolua_cCompositeChat_UnderlineUrls(lua_State * tolua_S)
void ManualBindings::Bind(lua_State * tolua_S) void ManualBindings::Bind(lua_State * tolua_S)
{ {
tolua_beginmodule(tolua_S, NULL); tolua_beginmodule(tolua_S, nullptr);
tolua_function(tolua_S, "Clamp", tolua_Clamp); tolua_function(tolua_S, "Clamp", tolua_Clamp);
tolua_function(tolua_S, "StringSplit", tolua_StringSplit); tolua_function(tolua_S, "StringSplit", tolua_StringSplit);
tolua_function(tolua_S, "StringSplitAndTrim", tolua_StringSplitAndTrim); tolua_function(tolua_S, "StringSplitAndTrim", tolua_StringSplitAndTrim);
@ -3447,7 +3447,7 @@ void ManualBindings::Bind(lua_State * tolua_S)
tolua_function(tolua_S, "AddWebTab", tolua_cPluginLua_AddWebTab); tolua_function(tolua_S, "AddWebTab", tolua_cPluginLua_AddWebTab);
tolua_endmodule(tolua_S); tolua_endmodule(tolua_S);
tolua_cclass(tolua_S, "HTTPRequest", "HTTPRequest", "", NULL); tolua_cclass(tolua_S, "HTTPRequest", "HTTPRequest", "", nullptr);
tolua_beginmodule(tolua_S, "HTTPRequest"); tolua_beginmodule(tolua_S, "HTTPRequest");
// tolua_variable(tolua_S, "Method", tolua_get_HTTPRequest_Method, tolua_set_HTTPRequest_Method); // tolua_variable(tolua_S, "Method", tolua_get_HTTPRequest_Method, tolua_set_HTTPRequest_Method);
// tolua_variable(tolua_S, "Path", tolua_get_HTTPRequest_Path, tolua_set_HTTPRequest_Path); // tolua_variable(tolua_S, "Path", tolua_get_HTTPRequest_Path, tolua_set_HTTPRequest_Path);

View File

@ -1044,7 +1044,7 @@ void ManualBindings::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", "", NULL); 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");

View File

@ -1487,7 +1487,7 @@ void cPluginLua::ClearCommands(void)
cCSLock Lock(m_CriticalSection); cCSLock Lock(m_CriticalSection);
// Unreference the bound functions so that Lua can GC them // Unreference the bound functions so that Lua can GC them
if (m_LuaState != NULL) if (m_LuaState != nullptr)
{ {
for (CommandMap::iterator itr = m_Commands.begin(), end = m_Commands.end(); itr != end; ++itr) for (CommandMap::iterator itr = m_Commands.begin(), end = m_Commands.end(); itr != end; ++itr)
{ {
@ -1506,7 +1506,7 @@ void cPluginLua::ClearConsoleCommands(void)
cCSLock Lock(m_CriticalSection); cCSLock Lock(m_CriticalSection);
// Unreference the bound functions so that Lua can GC them // Unreference the bound functions so that Lua can GC them
if (m_LuaState != NULL) if (m_LuaState != nullptr)
{ {
for (CommandMap::iterator itr = m_ConsoleCommands.begin(), end = m_ConsoleCommands.end(); itr != end; ++itr) for (CommandMap::iterator itr = m_ConsoleCommands.begin(), end = m_ConsoleCommands.end(); itr != end; ++itr)
{ {
@ -1523,7 +1523,7 @@ void cPluginLua::ClearConsoleCommands(void)
bool cPluginLua::CanAddOldStyleHook(int a_HookType) bool cPluginLua::CanAddOldStyleHook(int a_HookType)
{ {
const char * FnName = GetHookFnName(a_HookType); const char * FnName = GetHookFnName(a_HookType);
if (FnName == NULL) if (FnName == nullptr)
{ {
// Unknown hook ID // Unknown hook ID
LOGWARNING("Plugin %s wants to add an unknown hook ID (%d). The plugin need not work properly.", LOGWARNING("Plugin %s wants to add an unknown hook ID (%d). The plugin need not work properly.",
@ -1614,7 +1614,7 @@ const char * cPluginLua::GetHookFnName(int a_HookType)
} // switch (a_Hook) } // switch (a_Hook)
LOGWARNING("Requested name of an unknown hook type function: %d (max is %d)", a_HookType, cPluginManager::HOOK_MAX); LOGWARNING("Requested name of an unknown hook type function: %d (max is %d)", a_HookType, cPluginManager::HOOK_MAX);
ASSERT(!"Unknown hook requested!"); ASSERT(!"Unknown hook requested!");
return NULL; return nullptr;
} }
@ -1627,12 +1627,12 @@ bool cPluginLua::AddHookRef(int a_HookType, int a_FnRefIdx)
// 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 == NULL) || !Ref->IsValid()) if ((Ref == nullptr) || !Ref->IsValid())
{ {
LOGWARNING("Plugin %s tried to add a hook %d with bad handler function.", GetName().c_str(), a_HookType); LOGWARNING("Plugin %s tried to add a hook %d with bad handler function.", GetName().c_str(), a_HookType);
m_LuaState.LogStackTrace(); m_LuaState.LogStackTrace();
delete Ref; delete Ref;
Ref = NULL; Ref = nullptr;
return false; return false;
} }
@ -1700,7 +1700,7 @@ AString cPluginLua::HandleWebRequest(const HTTPRequest * a_Request)
} }
} }
if (Tab != NULL) if (Tab != nullptr)
{ {
AString Contents = Printf("WARNING: WebPlugin tab '%s' did not return a string!", Tab->Title.c_str()); AString Contents = Printf("WARNING: WebPlugin tab '%s' did not return a string!", Tab->Title.c_str());
if (!m_LuaState.Call(Tab->UserData, a_Request, cLuaState::Return, Contents)) if (!m_LuaState.Call(Tab->UserData, a_Request, cLuaState::Return, Contents))

View File

@ -66,7 +66,7 @@ void cPluginManager::FindPlugins(void)
// First get a clean list of only the currently running plugins, we don't want to mess those up // First get a clean list of only the currently running plugins, we don't want to mess those up
for (PluginMap::iterator itr = m_Plugins.begin(); itr != m_Plugins.end();) for (PluginMap::iterator itr = m_Plugins.begin(); itr != m_Plugins.end();)
{ {
if (itr->second == NULL) if (itr->second == nullptr)
{ {
PluginMap::iterator thiz = itr; PluginMap::iterator thiz = itr;
++thiz; ++thiz;
@ -89,7 +89,7 @@ void cPluginManager::FindPlugins(void)
// Add plugin name/directory to the list // Add plugin name/directory to the list
if (m_Plugins.find(*itr) == m_Plugins.end()) if (m_Plugins.find(*itr) == m_Plugins.end())
{ {
m_Plugins[*itr] = NULL; m_Plugins[*itr] = nullptr;
} }
} }
} }
@ -151,7 +151,7 @@ void cPluginManager::ReloadPluginsNow(cIniFile & a_SettingsIni)
// Remove invalid plugins from the PluginMap. // Remove invalid plugins from the PluginMap.
for (PluginMap::iterator itr = m_Plugins.begin(); itr != m_Plugins.end();) for (PluginMap::iterator itr = m_Plugins.begin(); itr != m_Plugins.end();)
{ {
if (itr->second == NULL) if (itr->second == nullptr)
{ {
PluginMap::iterator thiz = itr; PluginMap::iterator thiz = itr;
++thiz; ++thiz;
@ -1445,7 +1445,7 @@ cPluginManager::CommandResult cPluginManager::HandleCommand(cPlayer & a_Player,
return crNoPermission; return crNoPermission;
} }
ASSERT(cmd->second.m_Plugin != NULL); ASSERT(cmd->second.m_Plugin != nullptr);
if (!cmd->second.m_Plugin->HandleCommand(Split, a_Player)) if (!cmd->second.m_Plugin->HandleCommand(Split, a_Player))
{ {
@ -1463,7 +1463,7 @@ cPlugin * cPluginManager::GetPlugin( const AString & a_Plugin) const
{ {
for (PluginMap::const_iterator itr = m_Plugins.begin(); itr != m_Plugins.end(); ++itr) for (PluginMap::const_iterator itr = m_Plugins.begin(); itr != m_Plugins.end(); ++itr)
{ {
if (itr->second == NULL) continue; if (itr->second == nullptr) continue;
if (itr->second->GetName().compare(a_Plugin) == 0) if (itr->second->GetName().compare(a_Plugin) == 0)
{ {
return itr->second; return itr->second;
@ -1513,7 +1513,7 @@ bool cPluginManager::DisablePlugin(const AString & a_PluginName)
if (itr->first.compare(a_PluginName) == 0) // _X 2013_02_01: wtf? Isn't this supposed to be what find() does? if (itr->first.compare(a_PluginName) == 0) // _X 2013_02_01: wtf? Isn't this supposed to be what find() does?
{ {
m_DisablePluginList.push_back(itr->second); m_DisablePluginList.push_back(itr->second);
itr->second = NULL; // Get rid of this thing right away itr->second = nullptr; // Get rid of this thing right away
return true; return true;
} }
return false; return false;
@ -1558,12 +1558,12 @@ void cPluginManager::RemovePlugin(cPlugin * a_Plugin)
RemovePluginCommands(a_Plugin); RemovePluginCommands(a_Plugin);
RemovePluginConsoleCommands(a_Plugin); RemovePluginConsoleCommands(a_Plugin);
RemoveHooks(a_Plugin); RemoveHooks(a_Plugin);
if (a_Plugin != NULL) if (a_Plugin != nullptr)
{ {
a_Plugin->OnDisable(); a_Plugin->OnDisable();
} }
delete a_Plugin; delete a_Plugin;
a_Plugin = NULL; a_Plugin = nullptr;
} }
@ -1572,7 +1572,7 @@ void cPluginManager::RemovePlugin(cPlugin * a_Plugin)
void cPluginManager::RemovePluginCommands(cPlugin * a_Plugin) void cPluginManager::RemovePluginCommands(cPlugin * a_Plugin)
{ {
if (a_Plugin != NULL) if (a_Plugin != nullptr)
{ {
a_Plugin->ClearCommands(); a_Plugin->ClearCommands();
} }
@ -1670,7 +1670,7 @@ cPluginManager::CommandResult cPluginManager::ForceExecuteCommand(cPlayer & a_Pl
void cPluginManager::RemovePluginConsoleCommands(cPlugin * a_Plugin) void cPluginManager::RemovePluginConsoleCommands(cPlugin * a_Plugin)
{ {
if (a_Plugin != NULL) if (a_Plugin != nullptr)
{ {
a_Plugin->ClearConsoleCommands(); a_Plugin->ClearConsoleCommands();
} }
@ -1699,7 +1699,7 @@ bool cPluginManager::BindConsoleCommand(const AString & a_Command, cPlugin * a_P
CommandMap::iterator cmd = m_ConsoleCommands.find(a_Command); CommandMap::iterator cmd = m_ConsoleCommands.find(a_Command);
if (cmd != m_ConsoleCommands.end()) if (cmd != m_ConsoleCommands.end())
{ {
if (cmd->second.m_Plugin == NULL) if (cmd->second.m_Plugin == nullptr)
{ {
LOGWARNING("Console command \"%s\" is already bound internally by MCServer, cannot bind in plugin \"%s\".", a_Command.c_str(), a_Plugin->GetName().c_str()); LOGWARNING("Console command \"%s\" is already bound internally by MCServer, cannot bind in plugin \"%s\".", a_Command.c_str(), a_Plugin->GetName().c_str());
} }
@ -1759,14 +1759,14 @@ bool cPluginManager::ExecuteConsoleCommand(const AStringVector & a_Split, cComma
return false; return false;
} }
if (cmd->second.m_Plugin == NULL) if (cmd->second.m_Plugin == nullptr)
{ {
// This is a built-in command // This is a built-in command
return false; return false;
} }
// Ask plugins first if a command is okay to execute the console command: // Ask plugins first if a command is okay to execute the console command:
if (CallHookExecuteCommand(NULL, a_Split)) if (CallHookExecuteCommand(nullptr, a_Split))
{ {
a_Output.Out("Command \"%s\" was stopped by the HOOK_EXECUTE_COMMAND hook", a_Split[0].c_str()); a_Output.Out("Command \"%s\" was stopped by the HOOK_EXECUTE_COMMAND hook", a_Split[0].c_str());
return false; return false;
@ -1788,7 +1788,7 @@ void cPluginManager::TabCompleteCommand(const AString & a_Text, AStringVector &
// Command name doesn't match // Command name doesn't match
continue; continue;
} }
if ((a_Player != NULL) && !a_Player->HasPermission(itr->second.m_Permission)) if ((a_Player != nullptr) && !a_Player->HasPermission(itr->second.m_Permission))
{ {
// Player doesn't have permission for the command // Player doesn't have permission for the command
continue; continue;
@ -1814,7 +1814,7 @@ bool cPluginManager::DoWithPlugin(const AString & a_PluginName, cPluginCallback
{ {
// TODO: Implement locking for plugins // TODO: Implement locking for plugins
PluginMap::iterator itr = m_Plugins.find(a_PluginName); PluginMap::iterator itr = m_Plugins.find(a_PluginName);
if ((itr == m_Plugins.end()) || (itr->second == NULL)) if ((itr == m_Plugins.end()) || (itr->second == nullptr))
{ {
return false; return false;
} }
@ -1848,7 +1848,7 @@ void cPluginManager::AddHook(cPlugin * a_Plugin, int a_Hook)
{ {
if (!a_Plugin) if (!a_Plugin)
{ {
LOGWARN("Called cPluginManager::AddHook() with a_Plugin == NULL"); LOGWARN("Called cPluginManager::AddHook() with a_Plugin == nullptr");
return; return;
} }
PluginList & Plugins = m_Hooks[a_Hook]; PluginList & Plugins = m_Hooks[a_Hook];

View File

@ -190,7 +190,7 @@ public:
bool CallHookCraftingNoRecipe (cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe * a_Recipe); bool CallHookCraftingNoRecipe (cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe * a_Recipe);
bool CallHookDisconnect (cClientHandle & a_Client, const AString & a_Reason); bool CallHookDisconnect (cClientHandle & a_Client, const AString & a_Reason);
bool CallHookEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier); bool CallHookEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier);
bool CallHookExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split); // If a_Player == NULL, it is a console cmd bool CallHookExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split); // If a_Player == nullptr, it is a console cmd
bool CallHookExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData); bool CallHookExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData);
bool CallHookExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData); bool CallHookExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData);
bool CallHookHandshake (cClientHandle & a_ClientHandle, const AString & a_Username); bool CallHookHandshake (cClientHandle & a_ClientHandle, const AString & a_Username);
@ -285,7 +285,7 @@ public:
bool ExecuteConsoleCommand(const AStringVector & a_Split, cCommandOutputCallback & a_Output); bool ExecuteConsoleCommand(const AStringVector & a_Split, cCommandOutputCallback & a_Output);
/** 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 NULL, 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);

View File

@ -12,7 +12,7 @@
cWebPlugin::cWebPlugin() cWebPlugin::cWebPlugin()
{ {
cWebAdmin * WebAdmin = cRoot::Get()->GetWebAdmin(); cWebAdmin * WebAdmin = cRoot::Get()->GetWebAdmin();
if (WebAdmin != NULL) if (WebAdmin != nullptr)
{ {
WebAdmin->AddPlugin(this); WebAdmin->AddPlugin(this);
} }
@ -25,7 +25,7 @@ cWebPlugin::cWebPlugin()
cWebPlugin::~cWebPlugin() cWebPlugin::~cWebPlugin()
{ {
cWebAdmin * WebAdmin = cRoot::Get()->GetWebAdmin(); cWebAdmin * WebAdmin = cRoot::Get()->GetWebAdmin();
if (WebAdmin != NULL) if (WebAdmin != nullptr)
{ {
WebAdmin->RemovePlugin(this); WebAdmin->RemovePlugin(this);
} }
@ -65,7 +65,7 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest
if (Split.size() > 1) if (Split.size() > 1)
{ {
sWebPluginTab * Tab = NULL; sWebPluginTab * Tab = nullptr;
if (Split.size() > 2) // If we got the tab name, show that page if (Split.size() > 2) // If we got the tab name, show that page
{ {
for (TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr) for (TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr)
@ -85,7 +85,7 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest
} }
} }
if (Tab != NULL) if (Tab != nullptr)
{ {
Names.first = Tab->Title; Names.first = Tab->Title;
Names.second = Tab->SafeTitle; Names.second = Tab->SafeTitle;

View File

@ -273,10 +273,10 @@ void MergeCombinatorMask(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE
// cBlockArea: // cBlockArea:
cBlockArea::cBlockArea(void) : cBlockArea::cBlockArea(void) :
m_BlockTypes(NULL), m_BlockTypes(nullptr),
m_BlockMetas(NULL), m_BlockMetas(nullptr),
m_BlockLight(NULL), m_BlockLight(nullptr),
m_BlockSkyLight(NULL) m_BlockSkyLight(nullptr)
{ {
} }
@ -295,10 +295,10 @@ cBlockArea::~cBlockArea()
void cBlockArea::Clear(void) void cBlockArea::Clear(void)
{ {
delete[] m_BlockTypes; m_BlockTypes = NULL; delete[] m_BlockTypes; m_BlockTypes = nullptr;
delete[] m_BlockMetas; m_BlockMetas = NULL; delete[] m_BlockMetas; m_BlockMetas = nullptr;
delete[] m_BlockLight; m_BlockLight = NULL; delete[] m_BlockLight; m_BlockLight = nullptr;
delete[] m_BlockSkyLight; m_BlockSkyLight = NULL; delete[] m_BlockSkyLight; m_BlockSkyLight = nullptr;
m_Origin.Set(0, 0, 0); m_Origin.Set(0, 0, 0);
m_Size.Set(0, 0, 0); m_Size.Set(0, 0, 0);
} }
@ -711,7 +711,7 @@ 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 == NULL) || (DstMetas == NULL)); bool IsDummyMetas = ((SrcMetas == nullptr) || (DstMetas == nullptr));
if (IsDummyMetas) if (IsDummyMetas)
{ {
@ -1013,8 +1013,8 @@ void cBlockArea::RotateCCW(void)
} // for x } // for x
std::swap(m_BlockTypes, NewTypes); std::swap(m_BlockTypes, NewTypes);
std::swap(m_BlockMetas, NewMetas); std::swap(m_BlockMetas, NewMetas);
delete[] NewTypes; NewTypes = NULL; delete[] NewTypes; NewTypes = nullptr;
delete[] NewMetas; NewMetas = NULL; delete[] NewMetas; NewMetas = nullptr;
std::swap(m_Size.x, m_Size.z); std::swap(m_Size.x, m_Size.z);
} }
@ -1058,8 +1058,8 @@ void cBlockArea::RotateCW(void)
} // for x } // for x
std::swap(m_BlockTypes, NewTypes); std::swap(m_BlockTypes, NewTypes);
std::swap(m_BlockMetas, NewMetas); std::swap(m_BlockMetas, NewMetas);
delete[] NewTypes; NewTypes = NULL; delete[] NewTypes; NewTypes = nullptr;
delete[] NewMetas; NewMetas = NULL; delete[] NewMetas; NewMetas = nullptr;
std::swap(m_Size.x, m_Size.z); std::swap(m_Size.x, m_Size.z);
} }
@ -1206,7 +1206,7 @@ void cBlockArea::RotateCCWNoMeta(void)
} // for z } // for z
} // for x } // for x
std::swap(m_BlockTypes, NewTypes); std::swap(m_BlockTypes, NewTypes);
delete[] NewTypes; NewTypes = NULL; delete[] NewTypes; NewTypes = nullptr;
} }
if (HasBlockMetas()) if (HasBlockMetas())
{ {
@ -1224,7 +1224,7 @@ void cBlockArea::RotateCCWNoMeta(void)
} // for z } // for z
} // for x } // for x
std::swap(m_BlockMetas, NewMetas); std::swap(m_BlockMetas, NewMetas);
delete[] NewMetas; NewMetas = NULL; delete[] NewMetas; NewMetas = nullptr;
} }
std::swap(m_Size.x, m_Size.z); std::swap(m_Size.x, m_Size.z);
} }
@ -1251,7 +1251,7 @@ void cBlockArea::RotateCWNoMeta(void)
} // for x } // for x
} // for z } // for z
std::swap(m_BlockTypes, NewTypes); std::swap(m_BlockTypes, NewTypes);
delete[] NewTypes; NewTypes = NULL; delete[] NewTypes; NewTypes = nullptr;
} }
if (HasBlockMetas()) if (HasBlockMetas())
{ {
@ -1269,7 +1269,7 @@ void cBlockArea::RotateCWNoMeta(void)
} // for x } // for x
} // for z } // for z
std::swap(m_BlockMetas, NewMetas); std::swap(m_BlockMetas, NewMetas);
delete[] NewMetas; NewMetas = NULL; delete[] NewMetas; NewMetas = nullptr;
} }
std::swap(m_Size.x, m_Size.z); std::swap(m_Size.x, m_Size.z);
} }
@ -1391,7 +1391,7 @@ void cBlockArea::MirrorYZNoMeta(void)
void cBlockArea::SetRelBlockType(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType) void cBlockArea::SetRelBlockType(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType)
{ {
if (m_BlockTypes == NULL) if (m_BlockTypes == nullptr)
{ {
LOGWARNING("cBlockArea: BlockTypes have not been read!"); LOGWARNING("cBlockArea: BlockTypes have not been read!");
return; return;
@ -1468,7 +1468,7 @@ void cBlockArea::SetBlockSkyLight(int a_BlockX, int a_BlockY, int a_BlockZ, NIBB
BLOCKTYPE cBlockArea::GetRelBlockType(int a_RelX, int a_RelY, int a_RelZ) const BLOCKTYPE cBlockArea::GetRelBlockType(int a_RelX, int a_RelY, int a_RelZ) const
{ {
if (m_BlockTypes == NULL) if (m_BlockTypes == nullptr)
{ {
LOGWARNING("cBlockArea: BlockTypes have not been read!"); LOGWARNING("cBlockArea: BlockTypes have not been read!");
return E_BLOCK_AIR; return E_BLOCK_AIR;
@ -1555,7 +1555,7 @@ void cBlockArea::SetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOC
void cBlockArea::SetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) void cBlockArea::SetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{ {
int idx = MakeIndex(a_RelX, a_RelY, a_RelZ); int idx = MakeIndex(a_RelX, a_RelY, a_RelZ);
if (m_BlockTypes == NULL) if (m_BlockTypes == nullptr)
{ {
LOGWARNING("%s: BlockTypes not available but requested to be written to.", __FUNCTION__); LOGWARNING("%s: BlockTypes not available but requested to be written to.", __FUNCTION__);
} }
@ -1563,7 +1563,7 @@ void cBlockArea::SetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, B
{ {
m_BlockTypes[idx] = a_BlockType; m_BlockTypes[idx] = a_BlockType;
} }
if (m_BlockMetas == NULL) if (m_BlockMetas == nullptr)
{ {
LOGWARNING("%s: BlockMetas not available but requested to be written to.", __FUNCTION__); LOGWARNING("%s: BlockMetas not available but requested to be written to.", __FUNCTION__);
} }
@ -1589,7 +1589,7 @@ void cBlockArea::GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOC
void cBlockArea::GetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const void cBlockArea::GetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const
{ {
int idx = MakeIndex(a_RelX, a_RelY, a_RelZ); int idx = MakeIndex(a_RelX, a_RelY, a_RelZ);
if (m_BlockTypes == NULL) if (m_BlockTypes == nullptr)
{ {
LOGWARNING("cBlockArea: BlockTypes have not been read!"); LOGWARNING("cBlockArea: BlockTypes have not been read!");
a_BlockType = E_BLOCK_AIR; a_BlockType = E_BLOCK_AIR;
@ -1599,7 +1599,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 == NULL) if (m_BlockMetas == nullptr)
{ {
LOGWARNING("cBlockArea: BlockMetas have not been read!"); LOGWARNING("cBlockArea: BlockMetas have not been read!");
a_BlockMeta = 0; a_BlockMeta = 0;
@ -1617,19 +1617,19 @@ void cBlockArea::GetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTY
int cBlockArea::GetDataTypes(void) const int cBlockArea::GetDataTypes(void) const
{ {
int res = 0; int res = 0;
if (m_BlockTypes != NULL) if (m_BlockTypes != nullptr)
{ {
res |= baTypes; res |= baTypes;
} }
if (m_BlockMetas != NULL) if (m_BlockMetas != nullptr)
{ {
res |= baMetas; res |= baMetas;
} }
if (m_BlockLight != NULL) if (m_BlockLight != nullptr)
{ {
res |= baLight; res |= baLight;
} }
if (m_BlockSkyLight != NULL) if (m_BlockSkyLight != nullptr)
{ {
res |= baSkyLight; res |= baSkyLight;
} }
@ -1642,12 +1642,12 @@ 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 == NULL); // 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];
if (m_BlockTypes == NULL) if (m_BlockTypes == nullptr)
{ {
return false; return false;
} }
@ -1655,36 +1655,36 @@ bool cBlockArea::SetSize(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes)
if (a_DataTypes & baMetas) if (a_DataTypes & baMetas)
{ {
m_BlockMetas = new NIBBLETYPE[a_SizeX * a_SizeY * a_SizeZ]; m_BlockMetas = new NIBBLETYPE[a_SizeX * a_SizeY * a_SizeZ];
if (m_BlockMetas == NULL) if (m_BlockMetas == nullptr)
{ {
delete[] m_BlockTypes; delete[] m_BlockTypes;
m_BlockTypes = NULL; m_BlockTypes = nullptr;
return false; return false;
} }
} }
if (a_DataTypes & baLight) if (a_DataTypes & baLight)
{ {
m_BlockLight = new NIBBLETYPE[a_SizeX * a_SizeY * a_SizeZ]; m_BlockLight = new NIBBLETYPE[a_SizeX * a_SizeY * a_SizeZ];
if (m_BlockLight == NULL) if (m_BlockLight == nullptr)
{ {
delete[] m_BlockMetas; delete[] m_BlockMetas;
m_BlockMetas = NULL; m_BlockMetas = nullptr;
delete[] m_BlockTypes; delete[] m_BlockTypes;
m_BlockTypes = NULL; m_BlockTypes = nullptr;
return false; return false;
} }
} }
if (a_DataTypes & baSkyLight) if (a_DataTypes & baSkyLight)
{ {
m_BlockSkyLight = new NIBBLETYPE[a_SizeX * a_SizeY * a_SizeZ]; m_BlockSkyLight = new NIBBLETYPE[a_SizeX * a_SizeY * a_SizeZ];
if (m_BlockSkyLight == NULL) if (m_BlockSkyLight == nullptr)
{ {
delete[] m_BlockLight; delete[] m_BlockLight;
m_BlockLight = NULL; m_BlockLight = nullptr;
delete[] m_BlockMetas; delete[] m_BlockMetas;
m_BlockMetas = NULL; m_BlockMetas = nullptr;
delete[] m_BlockTypes; delete[] m_BlockTypes;
m_BlockTypes = NULL; m_BlockTypes = nullptr;
return false; return false;
} }
} }
@ -1714,7 +1714,7 @@ int cBlockArea::MakeIndex(int a_RelX, int a_RelY, int a_RelZ) const
void cBlockArea::SetRelNibble(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Value, NIBBLETYPE * a_Array) void cBlockArea::SetRelNibble(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Value, NIBBLETYPE * a_Array)
{ {
if (a_Array == NULL) if (a_Array == nullptr)
{ {
LOGWARNING("cBlockArea: datatype has not been read!"); LOGWARNING("cBlockArea: datatype has not been read!");
return; return;
@ -1737,7 +1737,7 @@ void cBlockArea::SetNibble(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE
NIBBLETYPE cBlockArea::GetRelNibble(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE * a_Array) const NIBBLETYPE cBlockArea::GetRelNibble(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE * a_Array) const
{ {
if (a_Array == NULL) if (a_Array == nullptr)
{ {
LOGWARNING("cBlockArea: datatype has not been read!"); LOGWARNING("cBlockArea: datatype has not been read!");
return 16; return 16;
@ -1896,7 +1896,7 @@ void cBlockArea::cChunkReader::ChunkData(const cChunkData & a_BlockBuffer)
} }
// Copy the blocktypes: // Copy the blocktypes:
if (m_Area.m_BlockTypes != NULL) if (m_Area.m_BlockTypes != nullptr)
{ {
for (int y = 0; y < SizeY; y++) for (int y = 0; y < SizeY; y++)
{ {
@ -1917,7 +1917,7 @@ void cBlockArea::cChunkReader::ChunkData(const cChunkData & a_BlockBuffer)
} }
// Copy the block metas: // Copy the block metas:
if (m_Area.m_BlockMetas != NULL) if (m_Area.m_BlockMetas != nullptr)
{ {
for (int y = 0; y < SizeY; y++) for (int y = 0; y < SizeY; y++)
{ {
@ -1938,7 +1938,7 @@ void cBlockArea::cChunkReader::ChunkData(const cChunkData & a_BlockBuffer)
} }
// Copy the blocklight: // Copy the blocklight:
if (m_Area.m_BlockLight != NULL) if (m_Area.m_BlockLight != nullptr)
{ {
for (int y = 0; y < SizeY; y++) for (int y = 0; y < SizeY; y++)
{ {
@ -1959,7 +1959,7 @@ void cBlockArea::cChunkReader::ChunkData(const cChunkData & a_BlockBuffer)
} }
// Copy the skylight: // Copy the skylight:
if (m_Area.m_BlockSkyLight != NULL) if (m_Area.m_BlockSkyLight != nullptr)
{ {
for (int y = 0; y < SizeY; y++) for (int y = 0; y < SizeY; y++)
{ {

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
@ -56,64 +56,64 @@ public:
msDifference, msDifference,
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.
@ -125,7 +125,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
@ -147,7 +147,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 | |
@ -155,7 +155,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
msMask: msMask:
Combines two areas, the blocks that are the same are kept, differing ones are reset to air Combines two areas, the blocks that are the same are kept, differing ones are reset to air
| area block | | | area block | |
@ -166,68 +166,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);
@ -253,80 +253,80 @@ 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 != NULL); } bool HasBlockTypes (void) const { return (m_BlockTypes != nullptr); }
bool HasBlockMetas (void) const { return (m_BlockMetas != NULL); } bool HasBlockMetas (void) const { return (m_BlockMetas != nullptr); }
bool HasBlockLights (void) const { return (m_BlockLight != NULL); } bool HasBlockLights (void) const { return (m_BlockLight != nullptr); }
bool HasBlockSkyLights(void) const { return (m_BlockSkyLight != NULL); } bool HasBlockSkyLights(void) const { return (m_BlockSkyLight != nullptr); }
// tolua_end // tolua_end
// 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; }
NIBBLETYPE * GetBlockMetas (void) const { return m_BlockMetas; } // NOTE: one byte per block! NIBBLETYPE * GetBlockMetas (void) const { return m_BlockMetas; } // NOTE: one byte per block!
NIBBLETYPE * GetBlockLight (void) const { return m_BlockLight; } // NOTE: one byte per block! NIBBLETYPE * GetBlockLight (void) const { return m_BlockLight; } // NOTE: one byte per block!
NIBBLETYPE * GetBlockSkyLight(void) const { return m_BlockSkyLight; } // NOTE: one byte per block! NIBBLETYPE * GetBlockSkyLight(void) const { return m_BlockSkyLight; } // NOTE: one byte per block!
size_t GetBlockCount(void) const { return static_cast<size_t>(m_Size.x * m_Size.y * m_Size.z); } size_t GetBlockCount(void) const { return (size_t)(m_Size.x * m_Size.y * m_Size.z); }
int MakeIndex(int a_RelX, int a_RelY, int a_RelZ) const; int MakeIndex(int a_RelX, int a_RelY, int a_RelZ) const;
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;
@ -335,10 +335,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);
@ -346,11 +346,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);
@ -361,9 +361,13 @@ 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
} ; } ;
// tolua_end // tolua_end

View File

@ -2,7 +2,6 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "BeaconEntity.h" #include "BeaconEntity.h"
#include <algorithm>
#include "../BlockArea.h" #include "../BlockArea.h"
#include "../Entities/Player.h" #include "../Entities/Player.h"
@ -98,7 +97,7 @@ bool cBeaconEntity::SetPrimaryEffect(cEntityEffect::eType a_Effect)
m_PrimaryEffect = a_Effect; m_PrimaryEffect = a_Effect;
// Send window update: // Send window update:
if (GetWindow() != NULL) if (GetWindow() != nullptr)
{ {
GetWindow()->SetProperty(1, m_PrimaryEffect); GetWindow()->SetProperty(1, m_PrimaryEffect);
} }
@ -120,7 +119,7 @@ bool cBeaconEntity::SetSecondaryEffect(cEntityEffect::eType a_Effect)
m_SecondaryEffect = a_Effect; m_SecondaryEffect = a_Effect;
// Send window update: // Send window update:
if (GetWindow() != NULL) if (GetWindow() != nullptr)
{ {
GetWindow()->SetProperty(2, m_SecondaryEffect); GetWindow()->SetProperty(2, m_SecondaryEffect);
} }
@ -185,7 +184,7 @@ void cBeaconEntity::UpdateBeacon(void)
if (m_BeaconLevel != OldBeaconLevel) if (m_BeaconLevel != OldBeaconLevel)
{ {
// Send window update: // Send window update:
if (GetWindow() != NULL) if (GetWindow() != nullptr)
{ {
GetWindow()->SetProperty(0, m_BeaconLevel); GetWindow()->SetProperty(0, m_BeaconLevel);
} }
@ -228,7 +227,10 @@ void cBeaconEntity::GiveEffects(void)
virtual bool Item(cPlayer * a_Player) virtual bool Item(cPlayer * a_Player)
{ {
Vector3d PlayerPosition = Vector3d(a_Player->GetPosition()); Vector3d PlayerPosition = Vector3d(a_Player->GetPosition());
PlayerPosition.y = std::min(static_cast<double>(m_PosY), PlayerPosition.y); if (PlayerPosition.y > (double)m_PosY)
{
PlayerPosition.y = (double)m_PosY;
}
// TODO: Vanilla minecraft uses an AABB check instead of a radius one // TODO: Vanilla minecraft uses an AABB check instead of a radius one
Vector3d BeaconPosition = Vector3d(m_PosX, m_PosY, m_PosZ); Vector3d BeaconPosition = Vector3d(m_PosX, m_PosY, m_PosZ);
@ -253,7 +255,7 @@ void cBeaconEntity::GiveEffects(void)
, m_PrimaryEffect(a_PrimaryEffect) , m_PrimaryEffect(a_PrimaryEffect)
, m_SecondaryEffect(a_SecondaryEffect) , m_SecondaryEffect(a_SecondaryEffect)
, m_EffectLevel(a_EffectLevel) , m_EffectLevel(a_EffectLevel)
{} {};
} PlayerCallback(Radius, m_PosX, m_PosY, m_PosZ, m_PrimaryEffect, SecondaryEffect, EffectLevel); } PlayerCallback(Radius, m_PosX, m_PosY, m_PosZ, m_PrimaryEffect, SecondaryEffect, EffectLevel);
GetWorld()->ForEachPlayer(PlayerCallback); GetWorld()->ForEachPlayer(PlayerCallback);
@ -281,13 +283,13 @@ bool cBeaconEntity::Tick(float a_Dt, cChunk & a_Chunk)
void cBeaconEntity::UsedBy(cPlayer * a_Player) void cBeaconEntity::UsedBy(cPlayer * a_Player)
{ {
cWindow * Window = GetWindow(); cWindow * Window = GetWindow();
if (Window == NULL) if (Window == nullptr)
{ {
OpenWindow(new cBeaconWindow(m_PosX, m_PosY, m_PosZ, this)); OpenWindow(new cBeaconWindow(m_PosX, m_PosY, m_PosZ, this));
Window = GetWindow(); Window = GetWindow();
} }
if (Window != NULL) if (Window != nullptr)
{ {
// if (a_Player->GetWindow() != Window) // if (a_Player->GetWindow() != Window)
// -> Because mojang doesn't send a 'close window' packet when you click the cancel button in the beacon inventory ... // -> Because mojang doesn't send a 'close window' packet when you click the cancel button in the beacon inventory ...
@ -305,3 +307,7 @@ void cBeaconEntity::SendTo(cClientHandle & a_Client)
{ {
a_Client.SendUpdateBlockEntity(*this); a_Client.SendUpdateBlockEntity(*this);
} }

View File

@ -48,7 +48,7 @@ cBlockEntity * cBlockEntity::CreateByBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE
__FUNCTION__, a_BlockType, ItemTypeToString(a_BlockType).c_str() __FUNCTION__, a_BlockType, ItemTypeToString(a_BlockType).c_str()
); );
ASSERT(!"Requesting creation of an unknown block entity"); ASSERT(!"Requesting creation of an unknown block entity");
return NULL; return nullptr;
} }

View File

@ -70,8 +70,8 @@ public:
/// 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 NULL 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 = NULL); 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
{ {

View File

@ -47,7 +47,7 @@ public:
virtual void Destroy(void) override virtual void Destroy(void) override
{ {
// Drop the contents as pickups: // Drop the contents as pickups:
ASSERT(m_World != NULL); ASSERT(m_World != nullptr);
cItems Pickups; cItems Pickups;
m_Contents.CopyToItems(Pickups); m_Contents.CopyToItems(Pickups);
m_Contents.Clear(); m_Contents.Clear();
@ -78,9 +78,9 @@ protected:
{ {
UNUSED(a_SlotNum); UNUSED(a_SlotNum);
ASSERT(a_Grid == &m_Contents); ASSERT(a_Grid == &m_Contents);
if (m_World != NULL) if (m_World != nullptr)
{ {
if (GetWindow() != NULL) if (GetWindow() != nullptr)
{ {
GetWindow()->BroadcastWholeWindow(); GetWindow()->BroadcastWholeWindow();
} }

View File

@ -23,7 +23,7 @@ cChestEntity::cChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_
cChestEntity::~cChestEntity() cChestEntity::~cChestEntity()
{ {
cWindow * Window = GetWindow(); cWindow * Window = GetWindow();
if (Window != NULL) if (Window != nullptr)
{ {
Window->OwnerDestroyed(); Window->OwnerDestroyed();
} }
@ -49,14 +49,14 @@ void cChestEntity::UsedBy(cPlayer * a_Player)
{ {
// If the window is not created, open it anew: // If the window is not created, open it anew:
cWindow * Window = GetWindow(); cWindow * Window = GetWindow();
if (Window == NULL) if (Window == nullptr)
{ {
OpenNewWindow(); OpenNewWindow();
Window = GetWindow(); Window = GetWindow();
} }
// Open the window for the player: // Open the window for the player:
if (Window != NULL) if (Window != nullptr)
{ {
if (a_Player->GetWindow() != Window) if (a_Player->GetWindow() != Window)
{ {

View File

@ -154,7 +154,7 @@ void cCommandBlockEntity::SendTo(cClientHandle & a_Client)
void cCommandBlockEntity::Execute() void cCommandBlockEntity::Execute()
{ {
ASSERT(m_World != NULL); // 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())
{ {

View File

@ -28,7 +28,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum)
NIBBLETYPE Meta = a_Chunk.GetMeta(m_RelX, m_PosY, m_RelZ); NIBBLETYPE Meta = a_Chunk.GetMeta(m_RelX, m_PosY, m_RelZ);
AddDropSpenserDir(DispX, DispY, DispZ, Meta); AddDropSpenserDir(DispX, DispY, DispZ, Meta);
cChunk * DispChunk = a_Chunk.GetRelNeighborChunkAdjustCoords(DispX, DispZ); cChunk * DispChunk = a_Chunk.GetRelNeighborChunkAdjustCoords(DispX, DispZ);
if (DispChunk == NULL) if (DispChunk == nullptr)
{ {
// Would dispense into / interact with a non-loaded chunk, ignore the tick // Would dispense into / interact with a non-loaded chunk, ignore the tick
return; return;
@ -190,7 +190,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum)
void cDispenserEntity::SpawnProjectileFromDispenser(int a_BlockX, int a_BlockY, int a_BlockZ, cProjectileEntity::eKind a_Kind, const Vector3d & a_ShootVector) void cDispenserEntity::SpawnProjectileFromDispenser(int a_BlockX, int a_BlockY, int a_BlockZ, cProjectileEntity::eKind a_Kind, const Vector3d & a_ShootVector)
{ {
m_World->CreateProjectile(static_cast<double>(a_BlockX + 0.5), static_cast<double>(a_BlockY + 0.5), static_cast<double>(a_BlockZ + 0.5), a_Kind, NULL, NULL, &a_ShootVector); m_World->CreateProjectile(static_cast<double>(a_BlockX + 0.5), static_cast<double>(a_BlockY + 0.5), static_cast<double>(a_BlockZ + 0.5), a_Kind, nullptr, nullptr, &a_ShootVector);
} }

View File

@ -28,7 +28,7 @@ cDropSpenserEntity::~cDropSpenserEntity()
{ {
// Tell window its owner is destroyed // Tell window its owner is destroyed
cWindow * Window = GetWindow(); cWindow * Window = GetWindow();
if (Window != NULL) if (Window != nullptr)
{ {
Window->OwnerDestroyed(); Window->OwnerDestroyed();
} }
@ -70,19 +70,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", m_PosX * 8, m_PosY * 8, m_PosZ * 8, 1.0f, 1.2f); m_World->BroadcastSoundEffect("random.click", m_PosX * 8, m_PosY * 8, m_PosZ * 8, 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;
@ -132,7 +132,7 @@ bool cDropSpenserEntity::Tick(float 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;
@ -155,13 +155,13 @@ void cDropSpenserEntity::SendTo(cClientHandle & a_Client)
void cDropSpenserEntity::UsedBy(cPlayer * a_Player) void cDropSpenserEntity::UsedBy(cPlayer * a_Player)
{ {
cWindow * Window = GetWindow(); cWindow * Window = GetWindow();
if (Window == NULL) if (Window == nullptr)
{ {
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 != NULL) if (Window != nullptr)
{ {
if (a_Player->GetWindow() != Window) if (a_Player->GetWindow() != Window)
{ {
@ -205,3 +205,7 @@ void cDropSpenserEntity::DropFromSlot(cChunk & a_Chunk, int a_SlotNum)
m_World->SpawnItemPickups(Pickups, MicroX, MicroY, MicroZ, PickupSpeedX, PickupSpeedY, PickupSpeedZ); m_World->SpawnItemPickups(Pickups, MicroX, MicroY, MicroZ, PickupSpeedX, PickupSpeedY, PickupSpeedZ);
} }

View File

@ -23,7 +23,7 @@ cEnderChestEntity::cEnderChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, c
cEnderChestEntity::~cEnderChestEntity() cEnderChestEntity::~cEnderChestEntity()
{ {
cWindow * Window = GetWindow(); cWindow * Window = GetWindow();
if (Window != NULL) if (Window != nullptr)
{ {
Window->OwnerDestroyed(); Window->OwnerDestroyed();
} }
@ -37,14 +37,14 @@ void cEnderChestEntity::UsedBy(cPlayer * a_Player)
{ {
// If the window is not created, open it anew: // If the window is not created, open it anew:
cWindow * Window = GetWindow(); cWindow * Window = GetWindow();
if (Window == NULL) if (Window == nullptr)
{ {
OpenNewWindow(); OpenNewWindow();
Window = GetWindow(); Window = GetWindow();
} }
// Open the window for the player: // Open the window for the player:
if (Window != NULL) if (Window != nullptr)
{ {
if (a_Player->GetWindow() != Window) if (a_Player->GetWindow() != Window)
{ {

View File

@ -59,7 +59,7 @@ void cFlowerPotEntity::Destroy(void)
// Drop the contents as pickups: // Drop the contents as pickups:
if (!m_Item.IsEmpty()) if (!m_Item.IsEmpty())
{ {
ASSERT(m_World != NULL); ASSERT(m_World != nullptr);
cItems Pickups; cItems Pickups;
Pickups.Add(m_Item); Pickups.Add(m_Item);
m_World->SpawnItemPickups(Pickups, m_PosX + 0.5, m_PosY + 0.5, m_PosZ + 0.5); m_World->SpawnItemPickups(Pickups, m_PosX + 0.5, m_PosY + 0.5, m_PosZ + 0.5);

View File

@ -38,7 +38,7 @@ public:
BLOCKENTITY_PROTODEF(cFlowerPotEntity); BLOCKENTITY_PROTODEF(cFlowerPotEntity);
/** Creates a new flowerpot entity at the specified block coords. a_World may be NULL */ /** 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;

View File

@ -26,7 +26,7 @@ enum
cFurnaceEntity::cFurnaceEntity(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cWorld * a_World) : cFurnaceEntity::cFurnaceEntity(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cWorld * a_World) :
super(a_BlockType, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, a_World), super(a_BlockType, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, a_World),
m_BlockMeta(a_BlockMeta), m_BlockMeta(a_BlockMeta),
m_CurrentRecipe(NULL), m_CurrentRecipe(nullptr),
m_IsDestroyed(false), m_IsDestroyed(false),
m_IsCooking(a_BlockType == E_BLOCK_LIT_FURNACE), m_IsCooking(a_BlockType == E_BLOCK_LIT_FURNACE),
m_NeedCookTime(0), m_NeedCookTime(0),
@ -45,7 +45,7 @@ cFurnaceEntity::~cFurnaceEntity()
{ {
// Tell window its owner is destroyed // Tell window its owner is destroyed
cWindow * Window = GetWindow(); cWindow * Window = GetWindow();
if (Window != NULL) if (Window != nullptr)
{ {
Window->OwnerDestroyed(); Window->OwnerDestroyed();
} }
@ -145,7 +145,7 @@ void cFurnaceEntity::SendTo(cClientHandle & a_Client)
void cFurnaceEntity::BroadcastProgress(short a_ProgressbarID, short a_Value) void cFurnaceEntity::BroadcastProgress(short a_ProgressbarID, short a_Value)
{ {
cWindow * Window = GetWindow(); cWindow * Window = GetWindow();
if (Window != NULL) if (Window != nullptr)
{ {
Window->SetProperty(a_ProgressbarID, a_Value); Window->SetProperty(a_ProgressbarID, a_Value);
} }
@ -306,7 +306,7 @@ void cFurnaceEntity::UpdateOutput(void)
bool cFurnaceEntity::CanCookInputToOutput(void) const bool cFurnaceEntity::CanCookInputToOutput(void) const
{ {
if (m_CurrentRecipe == NULL) if (m_CurrentRecipe == nullptr)
{ {
// This input cannot be cooked // This input cannot be cooked
return false; return false;

View File

@ -86,14 +86,14 @@ void cHopperEntity::UsedBy(cPlayer * a_Player)
{ {
// If the window is not created, open it anew: // If the window is not created, open it anew:
cWindow * Window = GetWindow(); cWindow * Window = GetWindow();
if (Window == NULL) if (Window == nullptr)
{ {
OpenNewWindow(); OpenNewWindow();
Window = GetWindow(); Window = GetWindow();
} }
// Open the window for the player: // Open the window for the player:
if (Window != NULL) if (Window != nullptr)
{ {
if (a_Player->GetWindow() != Window) if (a_Player->GetWindow() != Window)
{ {
@ -197,7 +197,7 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
virtual bool Item(cEntity * a_Entity) override virtual bool Item(cEntity * a_Entity) override
{ {
ASSERT(a_Entity != NULL); ASSERT(a_Entity != nullptr);
if (!a_Entity->IsPickup() || a_Entity->IsDestroyed()) if (!a_Entity->IsPickup() || a_Entity->IsDestroyed())
{ {
@ -299,7 +299,7 @@ bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick)
int OutRelX = OutX - a_Chunk.GetPosX() * cChunkDef::Width; int OutRelX = OutX - a_Chunk.GetPosX() * cChunkDef::Width;
int OutRelZ = OutZ - a_Chunk.GetPosZ() * cChunkDef::Width; int OutRelZ = OutZ - a_Chunk.GetPosZ() * cChunkDef::Width;
cChunk * DestChunk = a_Chunk.GetRelNeighborChunkAdjustCoords(OutRelX, OutRelZ); cChunk * DestChunk = a_Chunk.GetRelNeighborChunkAdjustCoords(OutRelX, OutRelZ);
if (DestChunk == NULL) if (DestChunk == nullptr)
{ {
// The destination chunk has been unloaded, don't tick // The destination chunk has been unloaded, don't tick
return false; return false;
@ -328,7 +328,7 @@ bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick)
case E_BLOCK_HOPPER: case E_BLOCK_HOPPER:
{ {
cBlockEntityWithItems * BlockEntity = static_cast<cBlockEntityWithItems *>(DestChunk->GetBlockEntity(OutX, OutY, OutZ)); cBlockEntityWithItems * BlockEntity = static_cast<cBlockEntityWithItems *>(DestChunk->GetBlockEntity(OutX, OutY, OutZ));
if (BlockEntity == NULL) if (BlockEntity == nullptr)
{ {
LOGWARNING("%s: A block entity was not found where expected at {%d, %d, %d}", __FUNCTION__, OutX, OutY, OutZ); LOGWARNING("%s: A block entity was not found where expected at {%d, %d, %d}", __FUNCTION__, OutX, OutY, OutZ);
return false; return false;
@ -355,7 +355,7 @@ bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick)
bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk) bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk)
{ {
cChestEntity * MainChest = static_cast<cChestEntity *>(a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ)); cChestEntity * MainChest = static_cast<cChestEntity *>(a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ));
if (MainChest == NULL) if (MainChest == nullptr)
{ {
LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, m_PosX, m_PosY + 1, m_PosZ); LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, m_PosX, m_PosY + 1, m_PosZ);
return false; return false;
@ -383,7 +383,7 @@ bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk)
int x = m_RelX + Coords[i].x; int x = m_RelX + Coords[i].x;
int z = m_RelZ + Coords[i].z; int z = m_RelZ + Coords[i].z;
cChunk * Neighbor = a_Chunk.GetRelNeighborChunkAdjustCoords(x, z); cChunk * Neighbor = a_Chunk.GetRelNeighborChunkAdjustCoords(x, z);
if (Neighbor == NULL) if (Neighbor == nullptr)
{ {
continue; continue;
} }
@ -396,7 +396,7 @@ bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk)
} }
cChestEntity * SideChest = static_cast<cChestEntity *>(Neighbor->GetBlockEntity(m_PosX + Coords[i].x, m_PosY + 1, m_PosZ + Coords[i].z)); cChestEntity * SideChest = static_cast<cChestEntity *>(Neighbor->GetBlockEntity(m_PosX + Coords[i].x, m_PosY + 1, m_PosZ + Coords[i].z));
if (SideChest == NULL) if (SideChest == nullptr)
{ {
LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, m_PosX + Coords[i].x, m_PosY + 1, m_PosZ + Coords[i].z); LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, m_PosX + Coords[i].x, m_PosY + 1, m_PosZ + Coords[i].z);
} }
@ -422,7 +422,7 @@ bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk)
bool cHopperEntity::MoveItemsFromFurnace(cChunk & a_Chunk) bool cHopperEntity::MoveItemsFromFurnace(cChunk & a_Chunk)
{ {
cFurnaceEntity * Furnace = static_cast<cFurnaceEntity *>(a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ)); cFurnaceEntity * Furnace = static_cast<cFurnaceEntity *>(a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ));
if (Furnace == NULL) if (Furnace == nullptr)
{ {
LOGWARNING("%s: A furnace entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, m_PosX, m_PosY + 1, m_PosZ); LOGWARNING("%s: A furnace entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, m_PosX, m_PosY + 1, m_PosZ);
return false; return false;
@ -536,7 +536,7 @@ bool cHopperEntity::MoveItemsToChest(cChunk & a_Chunk, int a_BlockX, int a_Block
{ {
// Try the chest directly connected to the hopper: // Try the chest directly connected to the hopper:
cChestEntity * ConnectedChest = static_cast<cChestEntity *>(a_Chunk.GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ)); cChestEntity * ConnectedChest = static_cast<cChestEntity *>(a_Chunk.GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ));
if (ConnectedChest == NULL) if (ConnectedChest == nullptr)
{ {
LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, a_BlockX, a_BlockY, a_BlockZ); LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, a_BlockX, a_BlockY, a_BlockZ);
return false; return false;
@ -566,7 +566,7 @@ bool cHopperEntity::MoveItemsToChest(cChunk & a_Chunk, int a_BlockX, int a_Block
int x = RelX + Coords[i].x; int x = RelX + Coords[i].x;
int z = RelZ + Coords[i].z; int z = RelZ + Coords[i].z;
cChunk * Neighbor = a_Chunk.GetRelNeighborChunkAdjustCoords(x, z); cChunk * Neighbor = a_Chunk.GetRelNeighborChunkAdjustCoords(x, z);
if (Neighbor == NULL) if (Neighbor == nullptr)
{ {
continue; continue;
} }
@ -579,7 +579,7 @@ bool cHopperEntity::MoveItemsToChest(cChunk & a_Chunk, int a_BlockX, int a_Block
} }
cChestEntity * Chest = static_cast<cChestEntity *>(Neighbor->GetBlockEntity(a_BlockX + Coords[i].x, a_BlockY, a_BlockZ + Coords[i].z)); cChestEntity * Chest = static_cast<cChestEntity *>(Neighbor->GetBlockEntity(a_BlockX + Coords[i].x, a_BlockY, a_BlockZ + Coords[i].z));
if (Chest == NULL) if (Chest == nullptr)
{ {
LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d} (%d, %d)", __FUNCTION__, a_BlockX + Coords[i].x, a_BlockY, a_BlockZ + Coords[i].z, x, z); LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d} (%d, %d)", __FUNCTION__, a_BlockX + Coords[i].x, a_BlockY, a_BlockZ + Coords[i].z, x, z);
continue; continue;

View File

@ -36,7 +36,7 @@ public:
BLOCKENTITY_PROTODEF(cMobHeadEntity); BLOCKENTITY_PROTODEF(cMobHeadEntity);
/** Creates a new mob head entity at the specified block coords. a_World may be NULL */ /** 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

View File

@ -42,7 +42,7 @@ public:
BLOCKENTITY_PROTODEF(cNoteEntity); BLOCKENTITY_PROTODEF(cNoteEntity);
/// Creates a new note entity. a_World may be NULL /// 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() {}

View File

@ -36,7 +36,7 @@ public:
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 NULL /// 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

View File

@ -9,7 +9,7 @@
cBlockInfo::~cBlockInfo() cBlockInfo::~cBlockInfo()
{ {
delete m_Handler; delete m_Handler;
m_Handler = NULL; m_Handler = nullptr;
} }
@ -17,7 +17,7 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
{ {
for (unsigned int i = 0; i < 256; ++i) for (unsigned int i = 0; i < 256; ++i)
{ {
if (a_Info[i].m_Handler == NULL) if (a_Info[i].m_Handler == nullptr)
{ {
a_Info[i].m_Handler = cBlockHandler::CreateBlockHandler((BLOCKTYPE) i); a_Info[i].m_Handler = cBlockHandler::CreateBlockHandler((BLOCKTYPE) i);
} }

View File

@ -102,7 +102,7 @@ protected:
, m_FullyOccupiesVoxel(false) , m_FullyOccupiesVoxel(false)
, m_CanBeTerraformed(false) , m_CanBeTerraformed(false)
, m_PlaceSound("") , m_PlaceSound("")
, m_Handler(NULL) , m_Handler(nullptr)
{} {}
/** Cleans up the stored values */ /** Cleans up the stored values */

View File

@ -72,7 +72,7 @@ public:
int BlockY = a_RelY + OfsY; int BlockY = a_RelY + OfsY;
int BlockZ = a_RelZ + OfsZ; int BlockZ = a_RelZ + OfsZ;
cChunk * Chunk = a_Chunk.GetRelNeighborChunkAdjustCoords(BlockX, BlockZ); cChunk * Chunk = a_Chunk.GetRelNeighborChunkAdjustCoords(BlockX, BlockZ);
if (Chunk == NULL) if (Chunk == nullptr)
{ {
// Unloaded chunk // Unloaded chunk
continue; continue;

View File

@ -99,9 +99,9 @@ public:
for (BLOCKTYPE Type = 0; Type < E_BLOCK_MAX_TYPE_ID; Type++) for (BLOCKTYPE Type = 0; Type < E_BLOCK_MAX_TYPE_ID; Type++)
{ {
cBlockHandler * Handler = cBlockInfo::GetHandler(Type); cBlockHandler * Handler = cBlockInfo::GetHandler(Type);
if (Handler == NULL) if (Handler == nullptr)
{ {
printf("NULL handler for block type %d!\n", Type); printf("nullptr handler for block type %d!\n", Type);
continue; continue;
} }
AString BlockName = ItemTypeToString(Type); AString BlockName = ItemTypeToString(Type);
@ -441,7 +441,7 @@ void cBlockHandler::DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterfac
if (a_CanDrop) if (a_CanDrop)
{ {
if ((a_Digger != NULL) && (a_Digger->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchSilkTouch) > 0)) if ((a_Digger != nullptr) && (a_Digger->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchSilkTouch) > 0))
{ {
switch (m_BlockType) switch (m_BlockType)
{ {
@ -562,7 +562,7 @@ void cBlockHandler::Check(cChunkInterface & a_ChunkInterface, cBlockPluginInterf
{ {
int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width; int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width;
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, NULL, 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);

View File

@ -78,7 +78,7 @@ public:
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 NULL @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)
*/ */

View File

@ -109,7 +109,7 @@ public:
} }
// Decay the leaves: // Decay the leaves:
DropBlock(a_ChunkInterface, a_WorldInterface, a_PluginInterface, NULL, BlockX, a_RelY, BlockZ); DropBlock(a_ChunkInterface, a_WorldInterface, a_PluginInterface, nullptr, BlockX, a_RelY, BlockZ);
a_ChunkInterface.DigBlock(a_WorldInterface, BlockX, a_RelY, BlockZ); a_ChunkInterface.DigBlock(a_WorldInterface, BlockX, a_RelY, BlockZ);
} }
} ; } ;

View File

@ -139,7 +139,7 @@ void cBlockPistonHandler::ExtendPiston(int a_BlockX, int a_BlockY, int a_BlockZ,
{ {
cChunkInterface ChunkInterface(a_World->GetChunkMap()); cChunkInterface ChunkInterface(a_World->GetChunkMap());
cBlockInServerPluginInterface PluginInterface(*a_World); cBlockInServerPluginInterface PluginInterface(*a_World);
Handler->DropBlock(ChunkInterface, *a_World, PluginInterface, NULL, a_BlockX, a_BlockY, a_BlockZ); Handler->DropBlock(ChunkInterface, *a_World, PluginInterface, nullptr, a_BlockX, a_BlockY, a_BlockZ);
} }
} }

View File

@ -148,7 +148,7 @@ public:
{ {
int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width; int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width;
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, NULL, 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);
return; return;

View File

@ -7,6 +7,6 @@ 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 = NULL) = 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 = NULL) = 0; virtual void BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = nullptr) = 0;
}; };

View File

@ -165,7 +165,7 @@ cByteBuffer::~cByteBuffer()
{ {
CheckValid(); CheckValid();
delete[] m_Buffer; delete[] m_Buffer;
m_Buffer = NULL; m_Buffer = nullptr;
} }

View File

@ -95,19 +95,19 @@ cChunk::cChunk(
m_RedstoneSimulatorData(a_World->GetRedstoneSimulator()->CreateChunkData()), m_RedstoneSimulatorData(a_World->GetRedstoneSimulator()->CreateChunkData()),
m_AlwaysTicked(0) m_AlwaysTicked(0)
{ {
if (a_NeighborXM != NULL) if (a_NeighborXM != nullptr)
{ {
a_NeighborXM->m_NeighborXP = this; a_NeighborXM->m_NeighborXP = this;
} }
if (a_NeighborXP != NULL) if (a_NeighborXP != nullptr)
{ {
a_NeighborXP->m_NeighborXM = this; a_NeighborXP->m_NeighborXM = this;
} }
if (a_NeighborZM != NULL) if (a_NeighborZM != nullptr)
{ {
a_NeighborZM->m_NeighborZP = this; a_NeighborZM->m_NeighborZP = this;
} }
if (a_NeighborZP != NULL) if (a_NeighborZP != nullptr)
{ {
a_NeighborZP->m_NeighborZM = this; a_NeighborZP->m_NeighborZM = this;
} }
@ -141,28 +141,28 @@ cChunk::~cChunk()
} }
} }
if (m_NeighborXM != NULL) if (m_NeighborXM != nullptr)
{ {
m_NeighborXM->m_NeighborXP = NULL; m_NeighborXM->m_NeighborXP = nullptr;
} }
if (m_NeighborXP != NULL) if (m_NeighborXP != nullptr)
{ {
m_NeighborXP->m_NeighborXM = NULL; m_NeighborXP->m_NeighborXM = nullptr;
} }
if (m_NeighborZM != NULL) if (m_NeighborZM != nullptr)
{ {
m_NeighborZM->m_NeighborZP = NULL; m_NeighborZM->m_NeighborZP = nullptr;
} }
if (m_NeighborZP != NULL) if (m_NeighborZP != nullptr)
{ {
m_NeighborZP->m_NeighborZM = NULL; m_NeighborZP->m_NeighborZM = nullptr;
} }
delete m_WaterSimulatorData; delete m_WaterSimulatorData;
m_WaterSimulatorData = NULL; m_WaterSimulatorData = nullptr;
delete m_LavaSimulatorData; delete m_LavaSimulatorData;
m_LavaSimulatorData = NULL; m_LavaSimulatorData = nullptr;
delete m_RedstoneSimulatorData; delete m_RedstoneSimulatorData;
m_RedstoneSimulatorData = NULL; m_RedstoneSimulatorData = nullptr;
} }
@ -581,7 +581,7 @@ void cChunk::SpawnMobs(cMobSpawner& a_MobSpawner)
} }
cEntity * newMob = a_MobSpawner.TryToSpawnHere(this, TryX, TryY, TryZ, Biome, MaxNbOfSuccess); cEntity * newMob = a_MobSpawner.TryToSpawnHere(this, TryX, TryY, TryZ, Biome, MaxNbOfSuccess);
if (newMob == NULL) if (newMob == nullptr)
{ {
continue; continue;
} }
@ -639,7 +639,7 @@ void cChunk::Tick(float a_Dt)
{ {
// Remove all entities that are travelling to another world // Remove all entities that are travelling to another world
MarkDirty(); MarkDirty();
(*itr)->SetWorldTravellingFrom(NULL); (*itr)->SetWorldTravellingFrom(nullptr);
itr = m_Entities.erase(itr); itr = m_Entities.erase(itr);
} }
else if ( else if (
@ -668,7 +668,7 @@ void cChunk::Tick(float a_Dt)
void cChunk::TickBlock(int a_RelX, int a_RelY, int a_RelZ) void cChunk::TickBlock(int a_RelX, int a_RelY, int a_RelZ)
{ {
cBlockHandler * Handler = BlockHandler(GetBlock(a_RelX, a_RelY, a_RelZ)); cBlockHandler * Handler = BlockHandler(GetBlock(a_RelX, a_RelY, a_RelZ));
ASSERT(Handler != NULL); // Happenned on server restart, FS #243 ASSERT(Handler != nullptr); // Happenned on server restart, FS #243
cChunkInterface ChunkInterface(this->GetWorld()->GetChunkMap()); cChunkInterface ChunkInterface(this->GetWorld()->GetChunkMap());
cBlockInServerPluginInterface PluginInterface(*this->GetWorld()); cBlockInServerPluginInterface PluginInterface(*this->GetWorld());
Handler->OnUpdate(ChunkInterface, *this->GetWorld(), PluginInterface, *this, a_RelX, a_RelY, a_RelZ); Handler->OnUpdate(ChunkInterface, *this->GetWorld(), PluginInterface, *this, a_RelX, a_RelY, a_RelZ);
@ -681,10 +681,10 @@ void cChunk::TickBlock(int a_RelX, int a_RelY, int a_RelZ)
void cChunk::MoveEntityToNewChunk(cEntity * a_Entity) void cChunk::MoveEntityToNewChunk(cEntity * a_Entity)
{ {
cChunk * Neighbor = GetNeighborChunk(a_Entity->GetChunkX() * cChunkDef::Width, a_Entity->GetChunkZ() * cChunkDef::Width); cChunk * Neighbor = GetNeighborChunk(a_Entity->GetChunkX() * cChunkDef::Width, a_Entity->GetChunkZ() * cChunkDef::Width);
if (Neighbor == NULL) if (Neighbor == nullptr)
{ {
Neighbor = m_ChunkMap->GetChunkNoLoad(a_Entity->GetChunkX(), a_Entity->GetChunkZ()); Neighbor = m_ChunkMap->GetChunkNoLoad(a_Entity->GetChunkX(), a_Entity->GetChunkZ());
if (Neighbor == NULL) if (Neighbor == nullptr)
{ {
// TODO: What to do with this? // TODO: What to do with this?
LOGWARNING("%s: Failed to move entity, destination chunk unreachable. Entity lost", __FUNCTION__); LOGWARNING("%s: Failed to move entity, destination chunk unreachable. Entity lost", __FUNCTION__);
@ -847,7 +847,7 @@ void cChunk::TickBlocks(void)
} }
cBlockHandler * Handler = BlockHandler(GetBlock(m_BlockTickX, m_BlockTickY, m_BlockTickZ)); cBlockHandler * Handler = BlockHandler(GetBlock(m_BlockTickX, m_BlockTickY, m_BlockTickZ));
ASSERT(Handler != NULL); // Happenned on server restart, FS #243 ASSERT(Handler != nullptr); // Happenned on server restart, FS #243
Handler->OnUpdate(ChunkInterface, *this->GetWorld(), PluginInterface, *this, m_BlockTickX, m_BlockTickY, m_BlockTickZ); Handler->OnUpdate(ChunkInterface, *this->GetWorld(), PluginInterface, *this, m_BlockTickX, m_BlockTickY, m_BlockTickZ);
} // for i - tickblocks } // for i - tickblocks
} }
@ -1127,7 +1127,7 @@ bool cChunk::UnboundedRelGetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE
return false; return false;
} }
cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ); cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ);
if ((Chunk == NULL) || !Chunk->IsValid()) if ((Chunk == nullptr) || !Chunk->IsValid())
{ {
// The chunk is not available, bail out // The chunk is not available, bail out
return false; return false;
@ -1148,7 +1148,7 @@ bool cChunk::UnboundedRelGetBlockType(int a_RelX, int a_RelY, int a_RelZ, BLOCKT
return false; return false;
} }
cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ); cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ);
if ((Chunk == NULL) || !Chunk->IsValid()) if ((Chunk == nullptr) || !Chunk->IsValid())
{ {
// The chunk is not available, bail out // The chunk is not available, bail out
return false; return false;
@ -1169,7 +1169,7 @@ bool cChunk::UnboundedRelGetBlockMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLE
return false; return false;
} }
cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ); cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ);
if ((Chunk == NULL) || !Chunk->IsValid()) if ((Chunk == nullptr) || !Chunk->IsValid())
{ {
// The chunk is not available, bail out // The chunk is not available, bail out
return false; return false;
@ -1190,7 +1190,7 @@ bool cChunk::UnboundedRelGetBlockBlockLight(int a_RelX, int a_RelY, int a_RelZ,
return false; return false;
} }
cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ); cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ);
if ((Chunk == NULL) || !Chunk->IsValid()) if ((Chunk == nullptr) || !Chunk->IsValid())
{ {
// The chunk is not available, bail out // The chunk is not available, bail out
return false; return false;
@ -1211,7 +1211,7 @@ bool cChunk::UnboundedRelGetBlockSkyLight(int a_RelX, int a_RelY, int a_RelZ, NI
return false; return false;
} }
cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ); cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ);
if ((Chunk == NULL) || !Chunk->IsValid()) if ((Chunk == nullptr) || !Chunk->IsValid())
{ {
// The chunk is not available, bail out // The chunk is not available, bail out
return false; return false;
@ -1232,7 +1232,7 @@ bool cChunk::UnboundedRelGetBlockLights(int a_RelX, int a_RelY, int a_RelZ, NIBB
return false; return false;
} }
cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ); cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ);
if ((Chunk == NULL) || !Chunk->IsValid()) if ((Chunk == nullptr) || !Chunk->IsValid())
{ {
// The chunk is not available, bail out // The chunk is not available, bail out
return false; return false;
@ -1254,7 +1254,7 @@ bool cChunk::UnboundedRelSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE
return false; return false;
} }
cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ); cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ);
if ((Chunk == NULL) || !Chunk->IsValid()) if ((Chunk == nullptr) || !Chunk->IsValid())
{ {
// The chunk is not available, bail out // The chunk is not available, bail out
return false; return false;
@ -1275,7 +1275,7 @@ bool cChunk::UnboundedRelFastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKT
return false; return false;
} }
cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ); cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ);
if ((Chunk == NULL) || !Chunk->IsValid()) if ((Chunk == nullptr) || !Chunk->IsValid())
{ {
// The chunk is not available, bail out // The chunk is not available, bail out
return false; return false;
@ -1296,7 +1296,7 @@ void cChunk::UnboundedQueueTickBlock(int a_RelX, int a_RelY, int a_RelZ)
return; return;
} }
cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ); cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ);
if ((Chunk != NULL) && Chunk->IsValid()) if ((Chunk != nullptr) && Chunk->IsValid())
{ {
Chunk->QueueTickBlock(a_RelX, a_RelY, a_RelZ); Chunk->QueueTickBlock(a_RelX, a_RelY, a_RelZ);
} }
@ -1452,12 +1452,12 @@ void cChunk::SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType,
// If there was a block entity, remove it: // If there was a block entity, remove it:
Vector3i WorldPos = PositionToWorldPosition(a_RelX, a_RelY, a_RelZ); Vector3i WorldPos = PositionToWorldPosition(a_RelX, a_RelY, a_RelZ);
cBlockEntity * BlockEntity = GetBlockEntity(WorldPos); cBlockEntity * BlockEntity = GetBlockEntity(WorldPos);
if (BlockEntity != NULL) if (BlockEntity != nullptr)
{ {
BlockEntity->Destroy(); BlockEntity->Destroy();
RemoveBlockEntity(BlockEntity); RemoveBlockEntity(BlockEntity);
delete BlockEntity; delete BlockEntity;
BlockEntity = NULL; BlockEntity = nullptr;
} }
// If the new block is a block entity, create the entity object: // If the new block is a block entity, create the entity object:
@ -1619,7 +1619,7 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT
void cChunk::SendBlockTo(int a_RelX, int a_RelY, int a_RelZ, cClientHandle * a_Client) void cChunk::SendBlockTo(int a_RelX, int a_RelY, int a_RelZ, cClientHandle * a_Client)
{ {
if (a_Client == NULL) if (a_Client == nullptr)
{ {
// Queue the block for all clients in the chunk (will be sent in Tick()) // Queue the block for all clients in the chunk (will be sent in Tick())
m_PendingSendBlocks.push_back(sSetBlock(m_PosX, m_PosZ, a_RelX, a_RelY, a_RelZ, GetBlock(a_RelX, a_RelY, a_RelZ), GetMeta(a_RelX, a_RelY, a_RelZ))); m_PendingSendBlocks.push_back(sSetBlock(m_PosX, m_PosZ, a_RelX, a_RelY, a_RelZ, GetBlock(a_RelX, a_RelY, a_RelZ), GetMeta(a_RelX, a_RelY, a_RelZ)));
@ -1673,7 +1673,7 @@ cBlockEntity * cChunk::GetBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ)
} }
} // for itr - m_BlockEntities[] } // for itr - m_BlockEntities[]
return NULL; return nullptr;
} }
@ -1708,7 +1708,7 @@ void cChunk::SetAlwaysTicked(bool a_AlwaysTicked)
void cChunk::UseBlockEntity(cPlayer * a_Player, int a_X, int a_Y, int a_Z) void cChunk::UseBlockEntity(cPlayer * a_Player, int a_X, int a_Y, int a_Z)
{ {
cBlockEntity * be = GetBlockEntity(a_X, a_Y, a_Z); cBlockEntity * be = GetBlockEntity(a_X, a_Y, a_Z);
if (be != NULL) if (be != nullptr)
{ {
be->UsedBy(a_Player); be->UsedBy(a_Player);
} }
@ -2664,10 +2664,10 @@ cChunk * cChunk::GetRelNeighborChunk(int a_RelX, int a_RelZ)
bool ReturnThis = true; bool ReturnThis = true;
if (a_RelX < 0) if (a_RelX < 0)
{ {
if (m_NeighborXM != NULL) if (m_NeighborXM != nullptr)
{ {
cChunk * Candidate = m_NeighborXM->GetRelNeighborChunk(a_RelX + cChunkDef::Width, a_RelZ); cChunk * Candidate = m_NeighborXM->GetRelNeighborChunk(a_RelX + cChunkDef::Width, a_RelZ);
if (Candidate != NULL) if (Candidate != nullptr)
{ {
return Candidate; return Candidate;
} }
@ -2677,10 +2677,10 @@ cChunk * cChunk::GetRelNeighborChunk(int a_RelX, int a_RelZ)
} }
else if (a_RelX >= cChunkDef::Width) else if (a_RelX >= cChunkDef::Width)
{ {
if (m_NeighborXP != NULL) if (m_NeighborXP != nullptr)
{ {
cChunk * Candidate = m_NeighborXP->GetRelNeighborChunk(a_RelX - cChunkDef::Width, a_RelZ); cChunk * Candidate = m_NeighborXP->GetRelNeighborChunk(a_RelX - cChunkDef::Width, a_RelZ);
if (Candidate != NULL) if (Candidate != nullptr)
{ {
return Candidate; return Candidate;
} }
@ -2691,24 +2691,24 @@ cChunk * cChunk::GetRelNeighborChunk(int a_RelX, int a_RelZ)
if (a_RelZ < 0) if (a_RelZ < 0)
{ {
if (m_NeighborZM != NULL) if (m_NeighborZM != nullptr)
{ {
return m_NeighborZM->GetRelNeighborChunk(a_RelX, a_RelZ + cChunkDef::Width); return m_NeighborZM->GetRelNeighborChunk(a_RelX, a_RelZ + cChunkDef::Width);
// For requests crossing both X and Z, the X-first way has been already tried // For requests crossing both X and Z, the X-first way has been already tried
} }
return NULL; return nullptr;
} }
else if (a_RelZ >= cChunkDef::Width) else if (a_RelZ >= cChunkDef::Width)
{ {
if (m_NeighborZP != NULL) if (m_NeighborZP != nullptr)
{ {
return m_NeighborZP->GetRelNeighborChunk(a_RelX, a_RelZ - cChunkDef::Width); return m_NeighborZP->GetRelNeighborChunk(a_RelX, a_RelZ - cChunkDef::Width);
// For requests crossing both X and Z, the X-first way has been already tried // For requests crossing both X and Z, the X-first way has been already tried
} }
return NULL; return nullptr;
} }
return (ReturnThis ? this : NULL); return (ReturnThis ? this : nullptr);
} }
@ -2731,27 +2731,27 @@ cChunk * cChunk::GetRelNeighborChunkAdjustCoords(int & a_RelX, int & a_RelZ) con
// Request for a different chunk, calculate chunk offset: // Request for a different chunk, calculate chunk offset:
int RelX = a_RelX; // Make a local copy of the coords (faster access) int RelX = a_RelX; // Make a local copy of the coords (faster access)
int RelZ = a_RelZ; int RelZ = a_RelZ;
while ((RelX >= Width) && (ToReturn != NULL)) while ((RelX >= Width) && (ToReturn != nullptr))
{ {
RelX -= Width; RelX -= Width;
ToReturn = ToReturn->m_NeighborXP; ToReturn = ToReturn->m_NeighborXP;
} }
while ((RelX < 0) && (ToReturn != NULL)) while ((RelX < 0) && (ToReturn != nullptr))
{ {
RelX += Width; RelX += Width;
ToReturn = ToReturn->m_NeighborXM; ToReturn = ToReturn->m_NeighborXM;
} }
while ((RelZ >= Width) && (ToReturn != NULL)) while ((RelZ >= Width) && (ToReturn != nullptr))
{ {
RelZ -= Width; RelZ -= Width;
ToReturn = ToReturn->m_NeighborZP; ToReturn = ToReturn->m_NeighborZP;
} }
while ((RelZ < 0) && (ToReturn != NULL)) while ((RelZ < 0) && (ToReturn != nullptr))
{ {
RelZ += Width; RelZ += Width;
ToReturn = ToReturn->m_NeighborZM; ToReturn = ToReturn->m_NeighborZM;
} }
if (ToReturn != NULL) if (ToReturn != nullptr)
{ {
a_RelX = RelX; a_RelX = RelX;
a_RelZ = RelZ; a_RelZ = RelZ;
@ -2821,7 +2821,7 @@ void cChunk::BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cons
{ {
// We can operate on entity pointers, we're inside the ChunkMap's CS lock which guards the list // We can operate on entity pointers, we're inside the ChunkMap's CS lock which guards the list
cBlockEntity * Entity = GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ); cBlockEntity * Entity = GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ);
if (Entity == NULL) if (Entity == nullptr)
{ {
return; return;
} }
@ -3158,7 +3158,7 @@ void cChunk::BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_Block
void cChunk::SendBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client) void cChunk::SendBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client)
{ {
cBlockEntity * Entity = GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ); cBlockEntity * Entity = GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ);
if (Entity == NULL) if (Entity == nullptr)
{ {
return; return;
} }

View File

@ -190,13 +190,13 @@ public:
void GetBlockInfo (int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_Meta, NIBBLETYPE & a_SkyLight, NIBBLETYPE & a_BlockLight); void GetBlockInfo (int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_Meta, NIBBLETYPE & a_SkyLight, NIBBLETYPE & a_BlockLight);
/** Returns the chunk into which the specified block belongs, by walking the neighbors. /** Returns the chunk into which the specified block belongs, by walking the neighbors.
Will return self if appropriate. Returns NULL if not reachable through neighbors. Will return self if appropriate. Returns nullptr if not reachable through neighbors.
*/ */
cChunk * GetNeighborChunk(int a_BlockX, int a_BlockZ); cChunk * GetNeighborChunk(int a_BlockX, int a_BlockZ);
/** /**
Returns the chunk into which the relatively-specified block belongs, by walking the neighbors. Returns the chunk into which the relatively-specified block belongs, by walking the neighbors.
Will return self if appropriate. Returns NULL if not reachable through neighbors. Will return self if appropriate. Returns nullptr if not reachable through neighbors.
*/ */
cChunk * GetRelNeighborChunk(int a_RelX, int a_RelZ); cChunk * GetRelNeighborChunk(int a_RelX, int a_RelZ);
@ -316,28 +316,28 @@ public:
// Broadcast various packets to all clients of this chunk: // Broadcast various packets to all clients of this chunk:
// (Please keep these alpha-sorted) // (Please keep these alpha-sorted)
void BroadcastAttachEntity (const cEntity & a_Entity, const cEntity * a_Vehicle); void BroadcastAttachEntity (const cEntity & a_Entity, const cEntity * a_Vehicle);
void BroadcastBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = NULL); void BroadcastBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = nullptr);
void BroadcastBlockBreakAnimation(int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude = NULL); void BroadcastBlockBreakAnimation(int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude = nullptr);
void BroadcastBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL); void BroadcastBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = nullptr);
void BroadcastChunkData (cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = NULL); void BroadcastChunkData (cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = nullptr);
void BroadcastCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL); void BroadcastCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr);
void BroadcastDestroyEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); void BroadcastDestroyEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr);
void BroadcastEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude = NULL); void BroadcastEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude = nullptr);
void BroadcastEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude = NULL); void BroadcastEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude = nullptr);
void BroadcastEntityHeadLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); void BroadcastEntityHeadLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr);
void BroadcastEntityLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); void BroadcastEntityLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr);
void BroadcastEntityMetadata (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); void BroadcastEntityMetadata (const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr);
void BroadcastEntityRelMove (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = NULL); void BroadcastEntityRelMove (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = nullptr);
void BroadcastEntityRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = NULL); void BroadcastEntityRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = nullptr);
void BroadcastEntityStatus (const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude = NULL); void BroadcastEntityStatus (const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude = nullptr);
void BroadcastEntityVelocity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); void BroadcastEntityVelocity (const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr);
void BroadcastEntityAnimation (const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = NULL); void BroadcastEntityAnimation (const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = nullptr);
void BroadcastParticleEffect (const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmount, cClientHandle * a_Exclude = NULL); void BroadcastParticleEffect (const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmount, cClientHandle * a_Exclude = nullptr);
void BroadcastRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude = NULL); void BroadcastRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude = nullptr);
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 = NULL); 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);
void BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = NULL); void BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = nullptr);
void BroadcastSpawnEntity (cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); void BroadcastSpawnEntity (cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr);
void BroadcastThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL); void BroadcastThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = nullptr);
void BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ); void BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ);
void SendBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client); void SendBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client);

View File

@ -36,7 +36,7 @@ cChunkData::cChunkData(cAllocationPool<cChunkData::sChunkSection> & a_Pool) :
{ {
for (size_t i = 0; i < NumSections; i++) for (size_t i = 0; i < NumSections; i++)
{ {
m_Sections[i] = NULL; m_Sections[i] = nullptr;
} }
} }
@ -56,7 +56,7 @@ cChunkData::~cChunkData()
for (size_t i = 0; i < NumSections; i++) for (size_t i = 0; i < NumSections; i++)
{ {
Free(m_Sections[i]); Free(m_Sections[i]);
m_Sections[i] = NULL; m_Sections[i] = nullptr;
} }
} }
@ -96,7 +96,7 @@ cChunkData::~cChunkData()
for (size_t i = 0; i < NumSections; i++) for (size_t i = 0; i < NumSections; i++)
{ {
Free(m_Sections[i]); Free(m_Sections[i]);
m_Sections[i] = NULL; m_Sections[i] = nullptr;
} }
} }
@ -120,7 +120,7 @@ cChunkData::~cChunkData()
for (size_t i = 0; i < NumSections; i++) for (size_t i = 0; i < NumSections; i++)
{ {
m_Sections[i] = other.m_Sections[i]; m_Sections[i] = other.m_Sections[i];
other.m_Sections[i] = NULL; other.m_Sections[i] = nullptr;
} }
} }
@ -137,7 +137,7 @@ cChunkData::~cChunkData()
{ {
Free(m_Sections[i]); Free(m_Sections[i]);
m_Sections[i] = other.m_Sections[i]; m_Sections[i] = other.m_Sections[i];
other.m_Sections[i] = NULL; other.m_Sections[i] = nullptr;
} }
} }
return *this; return *this;
@ -154,7 +154,7 @@ BLOCKTYPE cChunkData::GetBlock(int a_X, int a_Y, int a_Z) const
ASSERT((a_Y >= 0) && (a_Y < cChunkDef::Height)); ASSERT((a_Y >= 0) && (a_Y < cChunkDef::Height));
ASSERT((a_Z >= 0) && (a_Z < cChunkDef::Width)); ASSERT((a_Z >= 0) && (a_Z < cChunkDef::Width));
int Section = a_Y / SectionHeight; int Section = a_Y / SectionHeight;
if (m_Sections[Section] != NULL) if (m_Sections[Section] != nullptr)
{ {
int Index = cChunkDef::MakeIndexNoCheck(a_X, a_Y - (Section * SectionHeight), a_Z); int Index = cChunkDef::MakeIndexNoCheck(a_X, a_Y - (Section * SectionHeight), a_Z);
return m_Sections[Section]->m_BlockTypes[Index]; return m_Sections[Section]->m_BlockTypes[Index];
@ -182,14 +182,14 @@ void cChunkData::SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_Block)
} }
int Section = a_RelY / SectionHeight; int Section = a_RelY / SectionHeight;
if (m_Sections[Section] == NULL) if (m_Sections[Section] == nullptr)
{ {
if (a_Block == 0x00) if (a_Block == 0x00)
{ {
return; return;
} }
m_Sections[Section] = Allocate(); m_Sections[Section] = Allocate();
if (m_Sections[Section] == NULL) if (m_Sections[Section] == nullptr)
{ {
ASSERT(!"Failed to allocate a new section in Chunkbuffer"); ASSERT(!"Failed to allocate a new section in Chunkbuffer");
return; return;
@ -212,7 +212,7 @@ NIBBLETYPE cChunkData::GetMeta(int a_RelX, int a_RelY, int a_RelZ) const
(a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) (a_RelZ < cChunkDef::Width) && (a_RelZ > -1))
{ {
int Section = a_RelY / SectionHeight; int Section = a_RelY / SectionHeight;
if (m_Sections[Section] != NULL) if (m_Sections[Section] != nullptr)
{ {
int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * SectionHeight), a_RelZ); int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * SectionHeight), a_RelZ);
return (m_Sections[Section]->m_BlockMetas[Index / 2] >> ((Index & 1) * 4)) & 0x0f; return (m_Sections[Section]->m_BlockMetas[Index / 2] >> ((Index & 1) * 4)) & 0x0f;
@ -243,14 +243,14 @@ bool cChunkData::SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Nibble
} }
int Section = a_RelY / SectionHeight; int Section = a_RelY / SectionHeight;
if (m_Sections[Section] == NULL) if (m_Sections[Section] == nullptr)
{ {
if ((a_Nibble & 0xf) == 0x00) if ((a_Nibble & 0xf) == 0x00)
{ {
return false; return false;
} }
m_Sections[Section] = Allocate(); m_Sections[Section] = Allocate();
if (m_Sections[Section] == NULL) if (m_Sections[Section] == nullptr)
{ {
ASSERT(!"Failed to allocate a new section in Chunkbuffer"); ASSERT(!"Failed to allocate a new section in Chunkbuffer");
return false; return false;
@ -279,7 +279,7 @@ NIBBLETYPE cChunkData::GetBlockLight(int a_RelX, int a_RelY, int a_RelZ) const
) )
{ {
int Section = a_RelY / SectionHeight; int Section = a_RelY / SectionHeight;
if (m_Sections[Section] != NULL) if (m_Sections[Section] != nullptr)
{ {
int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * SectionHeight), a_RelZ); int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * SectionHeight), a_RelZ);
return (m_Sections[Section]->m_BlockLight[Index / 2] >> ((Index & 1) * 4)) & 0x0f; return (m_Sections[Section]->m_BlockLight[Index / 2] >> ((Index & 1) * 4)) & 0x0f;
@ -302,7 +302,7 @@ NIBBLETYPE cChunkData::GetSkyLight(int a_RelX, int a_RelY, int a_RelZ) const
if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1))
{ {
int Section = a_RelY / SectionHeight; int Section = a_RelY / SectionHeight;
if (m_Sections[Section] != NULL) if (m_Sections[Section] != nullptr)
{ {
int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * SectionHeight), a_RelZ); int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * SectionHeight), a_RelZ);
return (m_Sections[Section]->m_BlockSkyLight[Index / 2] >> ((Index & 1) * 4)) & 0x0f; return (m_Sections[Section]->m_BlockSkyLight[Index / 2] >> ((Index & 1) * 4)) & 0x0f;
@ -325,7 +325,7 @@ cChunkData cChunkData::Copy(void) const
cChunkData copy(m_Pool); cChunkData copy(m_Pool);
for (size_t i = 0; i < NumSections; i++) for (size_t i = 0; i < NumSections; i++)
{ {
if (m_Sections[i] != NULL) if (m_Sections[i] != nullptr)
{ {
copy.m_Sections[i] = copy.Allocate(); copy.m_Sections[i] = copy.Allocate();
*copy.m_Sections[i] = *m_Sections[i]; *copy.m_Sections[i] = *m_Sections[i];
@ -354,7 +354,7 @@ void cChunkData::CopyBlockTypes(BLOCKTYPE * a_Dest, size_t a_Idx, size_t a_Lengt
{ {
size_t ToCopy = std::min(+SectionBlockCount - StartPos, a_Length); size_t ToCopy = std::min(+SectionBlockCount - StartPos, a_Length);
a_Length -= ToCopy; a_Length -= ToCopy;
if (m_Sections[i] != NULL) if (m_Sections[i] != nullptr)
{ {
BLOCKTYPE * blockbuffer = m_Sections[i]->m_BlockTypes; BLOCKTYPE * blockbuffer = m_Sections[i]->m_BlockTypes;
memcpy(&a_Dest[(i * SectionBlockCount) + StartPos - a_Idx], blockbuffer + StartPos, sizeof(BLOCKTYPE) * ToCopy); memcpy(&a_Dest[(i * SectionBlockCount) + StartPos - a_Idx], blockbuffer + StartPos, sizeof(BLOCKTYPE) * ToCopy);
@ -375,7 +375,7 @@ void cChunkData::CopyMetas(NIBBLETYPE * a_Dest) const
{ {
for (size_t i = 0; i < NumSections; i++) for (size_t i = 0; i < NumSections; i++)
{ {
if (m_Sections[i] != NULL) if (m_Sections[i] != nullptr)
{ {
memcpy(&a_Dest[i * SectionBlockCount / 2], &m_Sections[i]->m_BlockMetas, sizeof(m_Sections[i]->m_BlockMetas)); memcpy(&a_Dest[i * SectionBlockCount / 2], &m_Sections[i]->m_BlockMetas, sizeof(m_Sections[i]->m_BlockMetas));
} }
@ -394,7 +394,7 @@ void cChunkData::CopyBlockLight(NIBBLETYPE * a_Dest) const
{ {
for (size_t i = 0; i < NumSections; i++) for (size_t i = 0; i < NumSections; i++)
{ {
if (m_Sections[i] != NULL) if (m_Sections[i] != nullptr)
{ {
memcpy(&a_Dest[i * SectionBlockCount / 2], &m_Sections[i]->m_BlockLight, sizeof(m_Sections[i]->m_BlockLight)); memcpy(&a_Dest[i * SectionBlockCount / 2], &m_Sections[i]->m_BlockLight, sizeof(m_Sections[i]->m_BlockLight));
} }
@ -413,7 +413,7 @@ void cChunkData::CopySkyLight(NIBBLETYPE * a_Dest) const
{ {
for (size_t i = 0; i < NumSections; i++) for (size_t i = 0; i < NumSections; i++)
{ {
if (m_Sections[i] != NULL) if (m_Sections[i] != nullptr)
{ {
memcpy(&a_Dest[i * SectionBlockCount / 2], &m_Sections[i]->m_BlockSkyLight, sizeof(m_Sections[i]->m_BlockSkyLight)); memcpy(&a_Dest[i * SectionBlockCount / 2], &m_Sections[i]->m_BlockSkyLight, sizeof(m_Sections[i]->m_BlockSkyLight));
} }
@ -430,12 +430,12 @@ void cChunkData::CopySkyLight(NIBBLETYPE * a_Dest) const
void cChunkData::SetBlockTypes(const BLOCKTYPE * a_Src) void cChunkData::SetBlockTypes(const BLOCKTYPE * a_Src)
{ {
ASSERT(a_Src != NULL); ASSERT(a_Src != nullptr);
for (size_t i = 0; i < NumSections; i++) for (size_t i = 0; i < NumSections; i++)
{ {
// If the section is already allocated, copy the data into it: // If the section is already allocated, copy the data into it:
if (m_Sections[i] != NULL) if (m_Sections[i] != nullptr)
{ {
memcpy(m_Sections[i]->m_BlockTypes, &a_Src[i * SectionBlockCount], sizeof(m_Sections[i]->m_BlockTypes)); memcpy(m_Sections[i]->m_BlockTypes, &a_Src[i * SectionBlockCount], sizeof(m_Sections[i]->m_BlockTypes));
continue; continue;
@ -462,12 +462,12 @@ void cChunkData::SetBlockTypes(const BLOCKTYPE * a_Src)
void cChunkData::SetMetas(const NIBBLETYPE * a_Src) void cChunkData::SetMetas(const NIBBLETYPE * a_Src)
{ {
ASSERT(a_Src != NULL); ASSERT(a_Src != nullptr);
for (size_t i = 0; i < NumSections; i++) for (size_t i = 0; i < NumSections; i++)
{ {
// If the section is already allocated, copy the data into it: // If the section is already allocated, copy the data into it:
if (m_Sections[i] != NULL) if (m_Sections[i] != nullptr)
{ {
memcpy(m_Sections[i]->m_BlockMetas, &a_Src[i * SectionBlockCount / 2], sizeof(m_Sections[i]->m_BlockMetas)); memcpy(m_Sections[i]->m_BlockMetas, &a_Src[i * SectionBlockCount / 2], sizeof(m_Sections[i]->m_BlockMetas));
continue; continue;
@ -495,7 +495,7 @@ void cChunkData::SetMetas(const NIBBLETYPE * a_Src)
void cChunkData::SetBlockLight(const NIBBLETYPE * a_Src) void cChunkData::SetBlockLight(const NIBBLETYPE * a_Src)
{ {
if (a_Src == NULL) if (a_Src == nullptr)
{ {
return; return;
} }
@ -503,7 +503,7 @@ void cChunkData::SetBlockLight(const NIBBLETYPE * a_Src)
for (size_t i = 0; i < NumSections; i++) for (size_t i = 0; i < NumSections; i++)
{ {
// If the section is already allocated, copy the data into it: // If the section is already allocated, copy the data into it:
if (m_Sections[i] != NULL) if (m_Sections[i] != nullptr)
{ {
memcpy(m_Sections[i]->m_BlockLight, &a_Src[i * SectionBlockCount / 2], sizeof(m_Sections[i]->m_BlockLight)); memcpy(m_Sections[i]->m_BlockLight, &a_Src[i * SectionBlockCount / 2], sizeof(m_Sections[i]->m_BlockLight));
continue; continue;
@ -530,7 +530,7 @@ void cChunkData::SetBlockLight(const NIBBLETYPE * a_Src)
void cChunkData::SetSkyLight(const NIBBLETYPE * a_Src) void cChunkData::SetSkyLight(const NIBBLETYPE * a_Src)
{ {
if (a_Src == NULL) if (a_Src == nullptr)
{ {
return; return;
} }
@ -538,7 +538,7 @@ void cChunkData::SetSkyLight(const NIBBLETYPE * a_Src)
for (size_t i = 0; i < NumSections; i++) for (size_t i = 0; i < NumSections; i++)
{ {
// If the section is already allocated, copy the data into it: // If the section is already allocated, copy the data into it:
if (m_Sections[i] != NULL) if (m_Sections[i] != nullptr)
{ {
memcpy(m_Sections[i]->m_BlockSkyLight, &a_Src[i * SectionBlockCount / 2], sizeof(m_Sections[i]->m_BlockSkyLight)); memcpy(m_Sections[i]->m_BlockSkyLight, &a_Src[i * SectionBlockCount / 2], sizeof(m_Sections[i]->m_BlockSkyLight));
continue; continue;

View File

@ -88,12 +88,12 @@ public:
/** Copies the blocklight data from the specified flat array into the internal representation. /** Copies the blocklight data from the specified flat array into the internal representation.
Allocates sectios that are needed for the operation. Allocates sectios that are needed for the operation.
Allows a_Src to be NULL, in which case it doesn't do anything. */ Allows a_Src to be nullptr, in which case it doesn't do anything. */
void SetBlockLight(const NIBBLETYPE * a_Src); void SetBlockLight(const NIBBLETYPE * a_Src);
/** Copies the skylight data from the specified flat array into the internal representation. /** Copies the skylight data from the specified flat array into the internal representation.
Allocates sectios that are needed for the operation. Allocates sectios that are needed for the operation.
Allows a_Src to be NULL, in which case it doesn't do anything. */ Allows a_Src to be nullptr, in which case it doesn't do anything. */
void SetSkyLight(const NIBBLETYPE * a_Src); void SetSkyLight(const NIBBLETYPE * a_Src);
struct sChunkSection struct sChunkSection
@ -118,7 +118,7 @@ private:
sChunkSection * Allocate(void); sChunkSection * Allocate(void);
/** Frees the specified section, previously allocated using Allocate(). /** Frees the specified section, previously allocated using Allocate().
Note that a_Section may be NULL. */ Note that a_Section may be nullptr. */
void Free(sChunkSection * a_Section); void Free(sChunkSection * a_Section);
/** Sets the data in the specified section to their default values. */ /** Sets the data in the specified section to their default values. */

File diff suppressed because it is too large Load Diff

View File

@ -70,29 +70,29 @@ public:
// Broadcast respective packets to all clients of the chunk where the event is taking place // Broadcast respective packets to all clients of the chunk where the event is taking place
// (Please keep these alpha-sorted) // (Please keep these alpha-sorted)
void BroadcastAttachEntity(const cEntity & a_Entity, const cEntity * a_Vehicle); void BroadcastAttachEntity(const cEntity & a_Entity, const cEntity * a_Vehicle);
void BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = NULL); void BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = nullptr);
void BroadcastBlockBreakAnimation(int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage, const cClientHandle * a_Exclude = NULL); void BroadcastBlockBreakAnimation(int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage, const cClientHandle * a_Exclude = nullptr);
void BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude); void BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude);
void BroadcastChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = NULL); void BroadcastChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = nullptr);
void BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL); void BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr);
void BroadcastCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL); void BroadcastCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr);
void BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); void BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr);
void BroadcastEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude = NULL); void BroadcastEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude = nullptr);
void BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude = NULL); void BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude = nullptr);
void BroadcastEntityHeadLook(const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); void BroadcastEntityHeadLook(const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr);
void BroadcastEntityLook(const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); void BroadcastEntityLook(const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr);
void BroadcastEntityMetadata(const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); void BroadcastEntityMetadata(const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr);
void BroadcastEntityRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = NULL); void BroadcastEntityRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = nullptr);
void BroadcastEntityRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = NULL); void BroadcastEntityRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = nullptr);
void BroadcastEntityStatus(const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude = NULL); void BroadcastEntityStatus(const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude = nullptr);
void BroadcastEntityVelocity(const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); void BroadcastEntityVelocity(const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr);
void BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = NULL); void BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = nullptr);
void BroadcastParticleEffect(const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmount, cClientHandle * a_Exclude = NULL); void BroadcastParticleEffect(const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmount, cClientHandle * a_Exclude = nullptr);
void BroadcastRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude = NULL); void BroadcastRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude = nullptr);
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 = NULL); 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);
void BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = NULL); void BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = nullptr);
void BroadcastSpawnEntity(cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); void BroadcastSpawnEntity(cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr);
void BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL); void BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = nullptr);
void BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ); void BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ);
/** Sends the block entity, if it is at the coords specified, to a_Client */ /** Sends the block entity, if it is at the coords specified, to a_Client */
@ -368,7 +368,7 @@ private:
/** Always returns an assigned chunkptr, but the chunk needn't be valid (loaded / generated) - callers must check */ /** Always returns an assigned chunkptr, but the chunk needn't be valid (loaded / generated) - callers must check */
cChunkPtr GetChunk( int a_ChunkX, int a_ChunkZ); cChunkPtr GetChunk( int a_ChunkX, int a_ChunkZ);
/** Returns the specified chunk, or NULL if not created yet */ /** Returns the specified chunk, or nullptr if not created yet */
cChunk * FindChunk(int a_ChunkX, int a_ChunkZ); cChunk * FindChunk(int a_ChunkX, int a_ChunkZ);
int GetX(void) const {return m_LayerX; } int GetX(void) const {return m_LayerX; }
@ -431,10 +431,10 @@ private:
typedef std::list<cChunkStay *> cChunkStays; typedef std::list<cChunkStay *> cChunkStays;
/** Finds the cChunkLayer object responsible for the specified chunk; returns NULL if not found. Assumes m_CSLayers is locked. */ /** Finds the cChunkLayer object responsible for the specified chunk; returns nullptr if not found. Assumes m_CSLayers is locked. */
cChunkLayer * FindLayerForChunk(int a_ChunkX, int a_ChunkZ); cChunkLayer * FindLayerForChunk(int a_ChunkX, int a_ChunkZ);
/** Returns the specified cChunkLayer object; returns NULL if not found. Assumes m_CSLayers is locked. */ /** Returns the specified cChunkLayer object; returns nullptr if not found. Assumes m_CSLayers is locked. */
cChunkLayer * FindLayer(int a_LayerX, int a_LayerZ); cChunkLayer * FindLayer(int a_LayerX, int a_LayerZ);
/** Returns the cChunkLayer object responsible for the specified chunk; creates it if not found. */ /** Returns the cChunkLayer object responsible for the specified chunk; creates it if not found. */

View File

@ -35,9 +35,9 @@ void cNotifyChunkSender::Call(int a_ChunkX, int a_ChunkZ)
cChunkSender::cChunkSender(void) : cChunkSender::cChunkSender(void) :
super("ChunkSender"), super("ChunkSender"),
m_World(NULL), m_World(nullptr),
m_RemoveCount(0), m_RemoveCount(0),
m_Notify(NULL) m_Notify(nullptr)
{ {
m_Notify.SetChunkSender(this); m_Notify.SetChunkSender(this);
} }
@ -93,7 +93,7 @@ void cChunkSender::ChunkReady(int a_ChunkX, int a_ChunkZ)
void cChunkSender::QueueSendChunkTo(int a_ChunkX, int a_ChunkZ, cClientHandle * a_Client) void cChunkSender::QueueSendChunkTo(int a_ChunkX, int a_ChunkZ, cClientHandle * a_Client)
{ {
ASSERT(a_Client != NULL); ASSERT(a_Client != nullptr);
{ {
cCSLock Lock(m_CS); cCSLock Lock(m_CS);
if (std::find(m_SendChunks.begin(), m_SendChunks.end(), sSendChunk(a_ChunkX, a_ChunkZ, a_Client)) != m_SendChunks.end()) if (std::find(m_SendChunks.begin(), m_SendChunks.end(), sSendChunk(a_ChunkX, a_ChunkZ, a_Client)) != m_SendChunks.end())
@ -161,7 +161,7 @@ void cChunkSender::Execute(void)
m_ChunksReady.pop_front(); m_ChunksReady.pop_front();
Lock.Unlock(); Lock.Unlock();
SendChunk(Coords.m_ChunkX, Coords.m_ChunkZ, NULL); SendChunk(Coords.m_ChunkX, Coords.m_ChunkZ, nullptr);
} }
else else
{ {
@ -189,10 +189,10 @@ void cChunkSender::Execute(void)
void cChunkSender::SendChunk(int a_ChunkX, int a_ChunkZ, cClientHandle * a_Client) void cChunkSender::SendChunk(int a_ChunkX, int a_ChunkZ, cClientHandle * a_Client)
{ {
ASSERT(m_World != NULL); ASSERT(m_World != nullptr);
// Ask the client if it still wants the chunk: // Ask the client if it still wants the chunk:
if (a_Client != NULL) if (a_Client != nullptr)
{ {
if (!a_Client->WantsSendChunk(a_ChunkX, a_ChunkZ)) if (!a_Client->WantsSendChunk(a_ChunkX, a_ChunkZ))
{ {
@ -227,7 +227,7 @@ void cChunkSender::SendChunk(int a_ChunkX, int a_ChunkZ, cClientHandle * a_Clien
cChunkDataSerializer Data(m_BlockTypes, m_BlockMetas, m_BlockLight, m_BlockSkyLight, m_BiomeMap); cChunkDataSerializer Data(m_BlockTypes, m_BlockMetas, m_BlockLight, m_BlockSkyLight, m_BiomeMap);
// Send: // Send:
if (a_Client == NULL) if (a_Client == nullptr)
{ {
m_World->BroadcastChunkData(a_ChunkX, a_ChunkZ, Data); m_World->BroadcastChunkData(a_ChunkX, a_ChunkZ, Data);
} }
@ -239,7 +239,7 @@ void cChunkSender::SendChunk(int a_ChunkX, int a_ChunkZ, cClientHandle * a_Clien
// Send block-entity packets: // Send block-entity packets:
for (sBlockCoords::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end(); ++itr) for (sBlockCoords::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end(); ++itr)
{ {
if (a_Client == NULL) if (a_Client == nullptr)
{ {
m_World->BroadcastBlockEntity(itr->m_BlockX, itr->m_BlockY, itr->m_BlockZ); m_World->BroadcastBlockEntity(itr->m_BlockX, itr->m_BlockY, itr->m_BlockZ);
} }

View File

@ -158,7 +158,7 @@ protected:
virtual void Entity (cEntity * a_Entity) override; virtual void Entity (cEntity * a_Entity) override;
virtual void BlockEntity (cBlockEntity * a_Entity) override; virtual void BlockEntity (cBlockEntity * a_Entity) override;
/// Sends the specified chunk to a_Client, or to all chunk clients if a_Client == NULL /// Sends the specified chunk to a_Client, or to all chunk clients if a_Client == nullptr
void SendChunk(int a_ChunkX, int a_ChunkZ, cClientHandle * a_Client); void SendChunk(int a_ChunkX, int a_ChunkZ, cClientHandle * a_Client);
} ; } ;

View File

@ -12,7 +12,7 @@
cChunkStay::cChunkStay(void) : cChunkStay::cChunkStay(void) :
m_ChunkMap(NULL) m_ChunkMap(nullptr)
{ {
} }
@ -31,7 +31,7 @@ cChunkStay::~cChunkStay()
void cChunkStay::Clear(void) void cChunkStay::Clear(void)
{ {
ASSERT(m_ChunkMap == NULL); ASSERT(m_ChunkMap == nullptr);
m_Chunks.clear(); m_Chunks.clear();
} }
@ -41,7 +41,7 @@ void cChunkStay::Clear(void)
void cChunkStay::Add(int a_ChunkX, int a_ChunkZ) void cChunkStay::Add(int a_ChunkX, int a_ChunkZ)
{ {
ASSERT(m_ChunkMap == NULL); ASSERT(m_ChunkMap == nullptr);
for (cChunkCoordsVector::const_iterator itr = m_Chunks.begin(); itr != m_Chunks.end(); ++itr) for (cChunkCoordsVector::const_iterator itr = m_Chunks.begin(); itr != m_Chunks.end(); ++itr)
{ {
@ -60,7 +60,7 @@ void cChunkStay::Add(int a_ChunkX, int a_ChunkZ)
void cChunkStay::Remove(int a_ChunkX, int a_ChunkZ) void cChunkStay::Remove(int a_ChunkX, int a_ChunkZ)
{ {
ASSERT(m_ChunkMap == NULL); ASSERT(m_ChunkMap == nullptr);
for (cChunkCoordsVector::iterator itr = m_Chunks.begin(); itr != m_Chunks.end(); ++itr) for (cChunkCoordsVector::iterator itr = m_Chunks.begin(); itr != m_Chunks.end(); ++itr)
{ {
@ -79,7 +79,7 @@ void cChunkStay::Remove(int a_ChunkX, int a_ChunkZ)
void cChunkStay::Enable(cChunkMap & a_ChunkMap) void cChunkStay::Enable(cChunkMap & a_ChunkMap)
{ {
ASSERT(m_ChunkMap == NULL); ASSERT(m_ChunkMap == nullptr);
m_OutstandingChunks = m_Chunks; m_OutstandingChunks = m_Chunks;
m_ChunkMap = &a_ChunkMap; m_ChunkMap = &a_ChunkMap;
@ -92,10 +92,10 @@ void cChunkStay::Enable(cChunkMap & a_ChunkMap)
void cChunkStay::Disable(void) void cChunkStay::Disable(void)
{ {
ASSERT(m_ChunkMap != NULL); ASSERT(m_ChunkMap != nullptr);
cChunkMap * ChunkMap = m_ChunkMap; cChunkMap * ChunkMap = m_ChunkMap;
m_ChunkMap = NULL; m_ChunkMap = nullptr;
ChunkMap->DelChunkStay(*this); ChunkMap->DelChunkStay(*this);
} }

View File

@ -68,7 +68,7 @@ cClientHandle::cClientHandle(const cSocket * a_Socket, int a_ViewDistance) :
m_ViewDistance(a_ViewDistance), m_ViewDistance(a_ViewDistance),
m_IPString(a_Socket->GetIPString()), m_IPString(a_Socket->GetIPString()),
m_OutgoingData(64 KiB), m_OutgoingData(64 KiB),
m_Player(NULL), m_Player(nullptr),
m_HasSentDC(false), m_HasSentDC(false),
m_LastStreamedChunkX(0x7fffffff), // bogus chunk coords to force streaming upon login m_LastStreamedChunkX(0x7fffffff), // bogus chunk coords to force streaming upon login
m_LastStreamedChunkZ(0x7fffffff), m_LastStreamedChunkZ(0x7fffffff),
@ -122,10 +122,10 @@ cClientHandle::~cClientHandle()
m_ChunksToSend.clear(); m_ChunksToSend.clear();
} }
if (m_Player != NULL) if (m_Player != nullptr)
{ {
cWorld * World = m_Player->GetWorld(); cWorld * World = m_Player->GetWorld();
if (World != NULL) if (World != nullptr)
{ {
if (!m_Username.empty()) if (!m_Username.empty())
{ {
@ -137,7 +137,7 @@ cClientHandle::~cClientHandle()
m_Player->Destroy(); m_Player->Destroy();
} }
delete m_Player; delete m_Player;
m_Player = NULL; m_Player = nullptr;
} }
if (!m_HasSentDC) if (!m_HasSentDC)
@ -149,7 +149,7 @@ cClientHandle::~cClientHandle()
cRoot::Get()->GetServer()->RemoveClient(this); cRoot::Get()->GetServer()->RemoveClient(this);
delete m_Protocol; delete m_Protocol;
m_Protocol = NULL; m_Protocol = nullptr;
LOGD("ClientHandle at %p deleted", this); LOGD("ClientHandle at %p deleted", this);
} }
@ -173,7 +173,7 @@ void cClientHandle::Destroy(void)
// DEBUG: // DEBUG:
LOGD("%s: client %p, \"%s\"", __FUNCTION__, this, m_Username.c_str()); LOGD("%s: client %p, \"%s\"", __FUNCTION__, this, m_Username.c_str());
if ((m_Player != NULL) && (m_Player->GetWorld() != NULL)) if ((m_Player != nullptr) && (m_Player->GetWorld() != nullptr))
{ {
RemoveFromAllChunks(); RemoveFromAllChunks();
m_Player->GetWorld()->RemoveClientFromChunkSender(this); m_Player->GetWorld()->RemoveClientFromChunkSender(this);
@ -314,7 +314,7 @@ void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID,
return; return;
} }
ASSERT(m_Player == NULL); ASSERT(m_Player == nullptr);
m_Username = a_Name; m_Username = a_Name;
@ -335,7 +335,7 @@ void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID,
m_Player = new cPlayer(this, GetUsername()); m_Player = new cPlayer(this, GetUsername());
cWorld * World = cRoot::Get()->GetWorld(m_Player->GetLoadedWorldName()); cWorld * World = cRoot::Get()->GetWorld(m_Player->GetLoadedWorldName());
if (World == NULL) if (World == nullptr)
{ {
World = cRoot::Get()->GetDefaultWorld(); World = cRoot::Get()->GetDefaultWorld();
} }
@ -412,7 +412,7 @@ void cClientHandle::StreamChunks(void)
return; return;
} }
ASSERT(m_Player != NULL); ASSERT(m_Player != nullptr);
int ChunkPosX = FAST_FLOOR_DIV((int)m_Player->GetPosX(), cChunkDef::Width); int ChunkPosX = FAST_FLOOR_DIV((int)m_Player->GetPosX(), cChunkDef::Width);
int ChunkPosZ = FAST_FLOOR_DIV((int)m_Player->GetPosZ(), cChunkDef::Width); int ChunkPosZ = FAST_FLOOR_DIV((int)m_Player->GetPosZ(), cChunkDef::Width);
@ -427,7 +427,7 @@ void cClientHandle::StreamChunks(void)
LOGD("Streaming chunks centered on [%d, %d], view distance %d", ChunkPosX, ChunkPosZ, m_ViewDistance); LOGD("Streaming chunks centered on [%d, %d], view distance %d", ChunkPosX, ChunkPosZ, m_ViewDistance);
cWorld * World = m_Player->GetWorld(); cWorld * World = m_Player->GetWorld();
ASSERT(World != NULL); ASSERT(World != nullptr);
// Remove all loaded chunks that are no longer in range; deferred to out-of-CS: // Remove all loaded chunks that are no longer in range; deferred to out-of-CS:
cChunkCoordsList RemoveChunks; cChunkCoordsList RemoveChunks;
@ -513,7 +513,7 @@ void cClientHandle::StreamChunk(int a_ChunkX, int a_ChunkZ)
} }
cWorld * World = m_Player->GetWorld(); cWorld * World = m_Player->GetWorld();
ASSERT(World != NULL); ASSERT(World != nullptr);
if (World->AddChunkClient(a_ChunkX, a_ChunkZ, this)) if (World->AddChunkClient(a_ChunkX, a_ChunkZ, this))
{ {
@ -534,7 +534,7 @@ void cClientHandle::StreamChunk(int a_ChunkX, int a_ChunkZ)
void cClientHandle::RemoveFromAllChunks() void cClientHandle::RemoveFromAllChunks()
{ {
cWorld * World = m_Player->GetWorld(); cWorld * World = m_Player->GetWorld();
if (World != NULL) if (World != nullptr)
{ {
World->RemoveClientFromChunks(this); World->RemoveClientFromChunks(this);
} }
@ -650,7 +650,7 @@ void cClientHandle::HandlePlayerAbilities(bool a_CanFly, bool a_IsFlying, float
void cClientHandle::HandlePlayerPos(double a_PosX, double a_PosY, double a_PosZ, double a_Stance, bool a_IsOnGround) void cClientHandle::HandlePlayerPos(double a_PosX, double a_PosY, double a_PosZ, double a_Stance, bool a_IsOnGround)
{ {
if ((m_Player == NULL) || (m_State != csPlaying)) if ((m_Player == nullptr) || (m_State != csPlaying))
{ {
// The client hasn't been spawned yet and sends nonsense, we know better // The client hasn't been spawned yet and sends nonsense, we know better
return; return;
@ -784,7 +784,7 @@ void cClientHandle::UnregisterPluginChannels(const AStringVector & a_ChannelList
void cClientHandle::HandleBeaconSelection(int a_PrimaryEffect, int a_SecondaryEffect) void cClientHandle::HandleBeaconSelection(int a_PrimaryEffect, int a_SecondaryEffect)
{ {
cWindow * Window = m_Player->GetWindow(); cWindow * Window = m_Player->GetWindow();
if ((Window == NULL) || (Window->GetWindowType() != cWindow::wtBeacon)) if ((Window == nullptr) || (Window->GetWindowType() != cWindow::wtBeacon))
{ {
return; return;
} }
@ -860,7 +860,7 @@ void cClientHandle::HandleCommandBlockEntityChange(int a_EntityID, const AString
void cClientHandle::HandleAnvilItemName(const AString & a_ItemName) void cClientHandle::HandleAnvilItemName(const AString & a_ItemName)
{ {
if ((m_Player->GetWindow() == NULL) || (m_Player->GetWindow()->GetWindowType() != cWindow::wtAnvil)) if ((m_Player->GetWindow() == nullptr) || (m_Player->GetWindow()->GetWindowType() != cWindow::wtAnvil))
{ {
return; return;
} }
@ -1497,7 +1497,7 @@ void cClientHandle::HandleChat(const AString & a_Message)
void cClientHandle::HandlePlayerLook(float a_Rotation, float a_Pitch, bool a_IsOnGround) void cClientHandle::HandlePlayerLook(float a_Rotation, float a_Pitch, bool a_IsOnGround)
{ {
if ((m_Player == NULL) || (m_State != csPlaying)) if ((m_Player == nullptr) || (m_State != csPlaying))
{ {
return; return;
} }
@ -1597,7 +1597,7 @@ void cClientHandle::HandleWindowClick(char a_WindowID, short a_SlotNum, eClickAc
); );
cWindow * Window = m_Player->GetWindow(); cWindow * Window = m_Player->GetWindow();
if (Window == NULL) if (Window == nullptr)
{ {
LOGWARNING("Player \"%s\" clicked in a non-existent window. Ignoring", m_Username.c_str()); LOGWARNING("Player \"%s\" clicked in a non-existent window. Ignoring", m_Username.c_str());
return; return;
@ -1689,7 +1689,7 @@ void cClientHandle::HandleUseEntity(int a_TargetEntityID, bool a_IsLeftClick)
void cClientHandle::HandleRespawn(void) void cClientHandle::HandleRespawn(void)
{ {
if (m_Player == NULL) if (m_Player == nullptr)
{ {
Destroy(); Destroy();
return; return;
@ -1779,7 +1779,7 @@ void cClientHandle::HandleEntitySprinting(int a_EntityID, bool a_IsSprinting)
void cClientHandle::HandleUnmount(void) void cClientHandle::HandleUnmount(void)
{ {
if (m_Player == NULL) if (m_Player == nullptr)
{ {
return; return;
} }
@ -1884,8 +1884,8 @@ void cClientHandle::RemoveFromWorld(void)
bool cClientHandle::CheckBlockInteractionsRate(void) bool cClientHandle::CheckBlockInteractionsRate(void)
{ {
ASSERT(m_Player != NULL); ASSERT(m_Player != nullptr);
ASSERT(m_Player->GetWorld() != NULL); ASSERT(m_Player->GetWorld() != nullptr);
if (m_NumBlockChangeInteractionsThisTick > MAX_BLOCK_CHANGE_INTERACTIONS) if (m_NumBlockChangeInteractionsThisTick > MAX_BLOCK_CHANGE_INTERACTIONS)
{ {
@ -1916,7 +1916,7 @@ void cClientHandle::Tick(float a_Dt)
Destroy(); Destroy();
} }
if (m_Player == NULL) if (m_Player == nullptr)
{ {
return; return;
} }
@ -2067,10 +2067,10 @@ void cClientHandle::SendBlockChanges(int a_ChunkX, int a_ChunkZ, const sSetBlock
void cClientHandle::SendChat(const AString & a_Message, eMessageType a_ChatPrefix, const AString & a_AdditionalData) void cClientHandle::SendChat(const AString & a_Message, eMessageType a_ChatPrefix, const AString & a_AdditionalData)
{ {
cWorld * World = GetPlayer()->GetWorld(); cWorld * World = GetPlayer()->GetWorld();
if (World == NULL) if (World == nullptr)
{ {
World = cRoot::Get()->GetWorld(GetPlayer()->GetLoadedWorldName()); World = cRoot::Get()->GetWorld(GetPlayer()->GetLoadedWorldName());
if (World == NULL) if (World == nullptr)
{ {
World = cRoot::Get()->GetDefaultWorld(); World = cRoot::Get()->GetDefaultWorld();
} }
@ -2095,7 +2095,7 @@ void cClientHandle::SendChat(const cCompositeChat & a_Message)
void cClientHandle::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) void cClientHandle::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer)
{ {
ASSERT(m_Player != NULL); ASSERT(m_Player != nullptr);
// Check chunks being sent, erase them from m_ChunksToSend: // Check chunks being sent, erase them from m_ChunksToSend:
bool Found = false; bool Found = false;
@ -2926,7 +2926,7 @@ void cClientHandle::HandleEnchantItem(Byte & a_WindowID, Byte & a_Enchantment)
} }
if ( if (
(m_Player->GetWindow() == NULL) || (m_Player->GetWindow() == nullptr) ||
(m_Player->GetWindow()->GetWindowID() != a_WindowID) || (m_Player->GetWindow()->GetWindowID() != a_WindowID) ||
(m_Player->GetWindow()->GetWindowType() != cWindow::wtEnchantment) (m_Player->GetWindow()->GetWindowType() != cWindow::wtEnchantment)
) )

View File

@ -59,7 +59,7 @@ cCraftingGrid::cCraftingGrid(const cCraftingGrid & a_Original) :
cCraftingGrid::~cCraftingGrid() cCraftingGrid::~cCraftingGrid()
{ {
delete[] m_Items; delete[] m_Items;
m_Items = NULL; m_Items = nullptr;
} }
@ -291,7 +291,7 @@ void cCraftingRecipes::GetRecipe(cPlayer & a_Player, cCraftingGrid & a_CraftingG
// Built-in recipes: // Built-in recipes:
std::auto_ptr<cRecipe> Recipe(FindRecipe(a_CraftingGrid.GetItems(), a_CraftingGrid.GetWidth(), a_CraftingGrid.GetHeight())); std::auto_ptr<cRecipe> Recipe(FindRecipe(a_CraftingGrid.GetItems(), a_CraftingGrid.GetWidth(), a_CraftingGrid.GetHeight()));
a_Recipe.Clear(); a_Recipe.Clear();
if (Recipe.get() == NULL) if (Recipe.get() == nullptr)
{ {
// Allow plugins to intercept a no-recipe-found situation: // Allow plugins to intercept a no-recipe-found situation:
cRoot::Get()->GetPluginManager()->CallHookCraftingNoRecipe(a_Player, a_CraftingGrid, &a_Recipe); cRoot::Get()->GetPluginManager()->CallHookCraftingNoRecipe(a_Player, a_CraftingGrid, &a_Recipe);
@ -603,9 +603,9 @@ cCraftingRecipes::cRecipe * cCraftingRecipes::FindRecipe(const cItem * a_Craftin
// Search in the possibly minimized grid, but keep the stride: // Search in the possibly minimized grid, but keep the stride:
const cItem * Grid = a_CraftingGrid + GridLeft + (a_GridWidth * GridTop); const cItem * Grid = a_CraftingGrid + GridLeft + (a_GridWidth * GridTop);
cRecipe * Recipe = FindRecipeCropped(Grid, GridWidth, GridHeight, a_GridWidth); cRecipe * Recipe = FindRecipeCropped(Grid, GridWidth, GridHeight, a_GridWidth);
if (Recipe == NULL) if (Recipe == nullptr)
{ {
return NULL; return nullptr;
} }
// A recipe has been found, move it to correspond to the original crafting grid: // A recipe has been found, move it to correspond to the original crafting grid:
@ -637,7 +637,7 @@ cCraftingRecipes::cRecipe * cCraftingRecipes::FindRecipeCropped(const cItem * a_
for (int x = 0; x <= MaxOfsX; x++) for (int y = 0; y <= MaxOfsY; y++) for (int x = 0; x <= MaxOfsX; x++) for (int y = 0; y <= MaxOfsY; y++)
{ {
cRecipe * Recipe = MatchRecipe(a_CraftingGrid, a_GridWidth, a_GridHeight, a_GridStride, *itr, x, y); cRecipe * Recipe = MatchRecipe(a_CraftingGrid, a_GridWidth, a_GridHeight, a_GridStride, *itr, x, y);
if (Recipe != NULL) if (Recipe != nullptr)
{ {
return Recipe; return Recipe;
} }
@ -645,7 +645,7 @@ cCraftingRecipes::cRecipe * cCraftingRecipes::FindRecipeCropped(const cItem * a_
} // for itr - m_Recipes[] } // for itr - m_Recipes[]
// No matching recipe found // No matching recipe found
return NULL; return nullptr;
} }
@ -681,7 +681,7 @@ cCraftingRecipes::cRecipe * cCraftingRecipes::MatchRecipe(const cItem * a_Crafti
) )
{ {
// Doesn't match // Doesn't match
return NULL; return nullptr;
} }
HasMatched[itrS->x + a_OffsetX][itrS->y + a_OffsetY] = true; HasMatched[itrS->x + a_OffsetX][itrS->y + a_OffsetY] = true;
} // for itrS - Recipe->m_Ingredients[] } // for itrS - Recipe->m_Ingredients[]
@ -743,7 +743,7 @@ cCraftingRecipes::cRecipe * cCraftingRecipes::MatchRecipe(const cItem * a_Crafti
} // for x } // for x
if (!Found) if (!Found)
{ {
return NULL; return nullptr;
} }
} // for itrS - a_Recipe->m_Ingredients[] } // for itrS - a_Recipe->m_Ingredients[]
@ -753,7 +753,7 @@ cCraftingRecipes::cRecipe * cCraftingRecipes::MatchRecipe(const cItem * a_Crafti
if (!HasMatched[x][y] && !a_CraftingGrid[x + a_GridStride * y].IsEmpty()) if (!HasMatched[x][y] && !a_CraftingGrid[x + a_GridStride * y].IsEmpty())
{ {
// There's an unmatched item in the grid // There's an unmatched item in the grid
return NULL; return nullptr;
} }
} // for y, for x } // for y, for x

View File

@ -157,13 +157,13 @@ protected:
/// Moves the recipe to top-left corner, sets its MinWidth / MinHeight /// Moves the recipe to top-left corner, sets its MinWidth / MinHeight
void NormalizeIngredients(cRecipe * a_Recipe); void NormalizeIngredients(cRecipe * a_Recipe);
/// Finds a recipe matching the crafting grid. Returns a newly allocated recipe (with all its coords set) or NULL if not found. Caller must delete return value! /// Finds a recipe matching the crafting grid. Returns a newly allocated recipe (with all its coords set) or nullptr if not found. Caller must delete return value!
cRecipe * FindRecipe(const cItem * a_CraftingGrid, int a_GridWidth, int a_GridHeight); cRecipe * FindRecipe(const cItem * a_CraftingGrid, int a_GridWidth, int a_GridHeight);
/// Same as FindRecipe, but the grid is guaranteed to be of minimal dimensions needed /// Same as FindRecipe, but the grid is guaranteed to be of minimal dimensions needed
cRecipe * FindRecipeCropped(const cItem * a_CraftingGrid, int a_GridWidth, int a_GridHeight, int a_GridStride); cRecipe * FindRecipeCropped(const cItem * a_CraftingGrid, int a_GridWidth, int a_GridHeight, int a_GridStride);
/// Checks if the grid matches the specified recipe, offset by the specified offsets. Returns a matched cRecipe * if so, or NULL if not matching. Caller must delete the return value! /// Checks if the grid matches the specified recipe, offset by the specified offsets. Returns a matched cRecipe * if so, or nullptr if not matching. Caller must delete the return value!
cRecipe * MatchRecipe(const cItem * a_CraftingGrid, int a_GridWidth, int a_GridHeight, int a_GridStride, const cRecipe * a_Recipe, int a_OffsetX, int a_OffsetY); cRecipe * MatchRecipe(const cItem * a_CraftingGrid, int a_GridWidth, int a_GridHeight, int a_GridStride, const cRecipe * a_Recipe, int a_OffsetX, int a_OffsetY);
/** Searches for anything firework related, and does the data setting if appropriate */ /** Searches for anything firework related, and does the data setting if appropriate */

View File

@ -477,16 +477,16 @@ inline void AddFaceDirection(int & a_BlockX, unsigned char & a_BlockY, int & a_B
#define PI 3.14159265358979323846264338327950288419716939937510582097494459072381640628620899862803482534211706798f
inline void EulerToVector(double a_Pan, double a_Pitch, double & a_X, double & a_Y, double & a_Z) inline void EulerToVector(double a_Pan, double a_Pitch, double & a_X, double & a_Y, double & a_Z)
{ {
// a_X = sinf ( a_Pan / 180 * PI) * cosf ( a_Pitch / 180 * PI); // a_X = sinf ( a_Pan / 180 * PI) * cosf ( a_Pitch / 180 * PI);
// a_Y = -sinf ( a_Pitch / 180 * PI); // a_Y = -sinf ( a_Pitch / 180 * PI);
// a_Z = -cosf ( a_Pan / 180 * PI) * cosf ( a_Pitch / 180 * PI); // a_Z = -cosf ( a_Pan / 180 * PI) * cosf ( a_Pitch / 180 * PI);
a_X = cos(a_Pan / 180 * PI) * cos(a_Pitch / 180 * PI); a_X = cos(a_Pan / 180 * M_PI) * cos(a_Pitch / 180 * M_PI);
a_Y = sin(a_Pan / 180 * PI) * cos(a_Pitch / 180 * PI); a_Y = sin(a_Pan / 180 * M_PI) * cos(a_Pitch / 180 * M_PI);
a_Z = sin(a_Pitch / 180 * PI); a_Z = sin(a_Pitch / 180 * M_PI);
} }
@ -502,10 +502,10 @@ inline void VectorToEuler(double a_X, double a_Y, double a_Z, double & a_Pan, do
} }
else else
{ {
a_Pan = atan2(a_Z, a_X) * 180 / PI - 90; a_Pan = atan2(a_Z, a_X) * 180 / M_PI - 90;
} }
a_Pitch = atan2(a_Y, r) * 180 / PI; a_Pitch = atan2(a_Y, r) * 180 / M_PI;
} }

View File

@ -217,7 +217,7 @@ void cArrowEntity::Tick(float a_Dt, cChunk & a_Chunk)
int RelPosZ = m_HitBlockPos.z - a_Chunk.GetPosZ() * cChunkDef::Width; int RelPosZ = m_HitBlockPos.z - a_Chunk.GetPosZ() * cChunkDef::Width;
cChunk * Chunk = a_Chunk.GetRelNeighborChunkAdjustCoords(RelPosX, RelPosZ); cChunk * Chunk = a_Chunk.GetRelNeighborChunkAdjustCoords(RelPosX, RelPosZ);
if (Chunk == NULL) if (Chunk == nullptr)
{ {
// Inside an unloaded chunk, abort // Inside an unloaded chunk, abort
return; return;

View File

@ -42,7 +42,7 @@ bool cBoat::DoTakeDamage(TakeDamageInfo & TDI)
if (GetHealth() == 0) if (GetHealth() == 0)
{ {
if (TDI.Attacker != NULL) if (TDI.Attacker != nullptr)
{ {
if (TDI.Attacker->IsPlayer()) if (TDI.Attacker->IsPlayer())
{ {
@ -64,7 +64,7 @@ void cBoat::OnRightClicked(cPlayer & a_Player)
{ {
super::OnRightClicked(a_Player); super::OnRightClicked(a_Player);
if (m_Attachee != NULL) if (m_Attachee != nullptr)
{ {
if (m_Attachee->GetUniqueID() == a_Player.GetUniqueID()) if (m_Attachee->GetUniqueID() == a_Player.GetUniqueID())
{ {

View File

@ -29,8 +29,8 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d
: m_UniqueID(0) : m_UniqueID(0)
, m_Health(1) , m_Health(1)
, m_MaxHealth(1) , m_MaxHealth(1)
, m_AttachedTo(NULL) , m_AttachedTo(nullptr)
, m_Attachee(NULL) , m_Attachee(nullptr)
, m_bDirtyHead(true) , m_bDirtyHead(true)
, m_bDirtyOrientation(true) , m_bDirtyOrientation(true)
, m_bHasSentNoSpeed(true) , m_bHasSentNoSpeed(true)
@ -38,9 +38,9 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d
, m_Gravity(-9.81f) , m_Gravity(-9.81f)
, m_LastPos(a_X, a_Y, a_Z) , m_LastPos(a_X, a_Y, a_Z)
, m_IsInitialized(false) , m_IsInitialized(false)
, m_WorldTravellingFrom(NULL) , m_WorldTravellingFrom(nullptr)
, m_EntityType(a_EntityType) , m_EntityType(a_EntityType)
, m_World(NULL) , m_World(nullptr)
, m_IsFireproof(false) , m_IsFireproof(false)
, m_TicksSinceLastBurnDamage(0) , m_TicksSinceLastBurnDamage(0)
, m_TicksSinceLastLavaDamage(0) , m_TicksSinceLastLavaDamage(0)
@ -73,7 +73,7 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d
cEntity::~cEntity() cEntity::~cEntity()
{ {
// Before deleting, the entity needs to have been removed from the world, if ever added // Before deleting, the entity needs to have been removed from the world, if ever added
ASSERT((m_World == NULL) || !m_World->HasEntity(m_UniqueID)); ASSERT((m_World == nullptr) || !m_World->HasEntity(m_UniqueID));
/* /*
// DEBUG: // DEBUG:
@ -85,11 +85,11 @@ cEntity::~cEntity()
); );
*/ */
if (m_AttachedTo != NULL) if (m_AttachedTo != nullptr)
{ {
Detach(); Detach();
} }
if (m_Attachee != NULL) if (m_Attachee != nullptr)
{ {
m_Attachee->Detach(); m_Attachee->Detach();
} }
@ -242,7 +242,7 @@ void cEntity::TakeDamage(eDamageType a_DamageType, cEntity * a_Attacker, int a_R
TDI.FinalDamage = a_FinalDamage; TDI.FinalDamage = a_FinalDamage;
Vector3d Heading(0, 0, 0); Vector3d Heading(0, 0, 0);
if (a_Attacker != NULL) if (a_Attacker != nullptr)
{ {
Heading = a_Attacker->GetLookVector() * (a_Attacker->IsSprinting() ? 16 : 11); Heading = a_Attacker->GetLookVector() * (a_Attacker->IsSprinting() ? 16 : 11);
Heading.y = 1.6; Heading.y = 1.6;
@ -265,7 +265,7 @@ void cEntity::SetYawFromSpeed(void)
SetYaw(0); SetYaw(0);
return; return;
} }
SetYaw(atan2(m_Speed.x, m_Speed.z) * 180 / PI); SetYaw(atan2(m_Speed.x, m_Speed.z) * 180 / M_PI);
} }
@ -282,7 +282,7 @@ void cEntity::SetPitchFromSpeed(void)
SetPitch(0); SetPitch(0);
return; return;
} }
SetPitch(atan2(m_Speed.y, xz) * 180 / PI); SetPitch(atan2(m_Speed.y, xz) * 180 / M_PI);
} }
@ -308,7 +308,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
return false; return false;
} }
if ((a_TDI.Attacker != NULL) && (a_TDI.Attacker->IsPlayer())) if ((a_TDI.Attacker != nullptr) && (a_TDI.Attacker->IsPlayer()))
{ {
cPlayer * Player = (cPlayer *)a_TDI.Attacker; cPlayer * Player = (cPlayer *)a_TDI.Attacker;
@ -544,7 +544,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
m_Health = std::max(m_Health, 0); m_Health = std::max(m_Health, 0);
// Add knockback: // Add knockback:
if ((IsMob() || IsPlayer()) && (a_TDI.Attacker != NULL)) if ((IsMob() || IsPlayer()) && (a_TDI.Attacker != nullptr))
{ {
int KnockbackLevel = a_TDI.Attacker->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchKnockback); // More common enchantment int KnockbackLevel = a_TDI.Attacker->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchKnockback); // More common enchantment
if (KnockbackLevel < 1) if (KnockbackLevel < 1)
@ -571,7 +571,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
{ {
KilledBy(a_TDI); KilledBy(a_TDI);
if (a_TDI.Attacker != NULL) if (a_TDI.Attacker != nullptr)
{ {
a_TDI.Attacker->Killed(this); a_TDI.Attacker->Killed(this);
} }
@ -778,7 +778,7 @@ void cEntity::Tick(float a_Dt, cChunk & a_Chunk)
m_InvulnerableTicks--; m_InvulnerableTicks--;
} }
if (m_AttachedTo != NULL) if (m_AttachedTo != nullptr)
{ {
Vector3d DeltaPos = m_Pos - m_AttachedTo->GetPosition(); Vector3d DeltaPos = m_Pos - m_AttachedTo->GetPosition();
if (DeltaPos.Length() > 0.5) if (DeltaPos.Length() > 0.5)
@ -1092,7 +1092,7 @@ void cEntity::TickBurning(cChunk & a_Chunk)
{ {
if (!m_IsFireproof) if (!m_IsFireproof)
{ {
TakeDamage(dtOnFire, NULL, BURN_DAMAGE, 0); TakeDamage(dtOnFire, nullptr, BURN_DAMAGE, 0);
} }
m_TicksSinceLastBurnDamage = 0; m_TicksSinceLastBurnDamage = 0;
} }
@ -1163,7 +1163,7 @@ void cEntity::TickBurning(cChunk & a_Chunk)
{ {
if (!m_IsFireproof) if (!m_IsFireproof)
{ {
TakeDamage(dtLavaContact, NULL, LAVA_DAMAGE, 0); TakeDamage(dtLavaContact, nullptr, LAVA_DAMAGE, 0);
} }
m_TicksSinceLastLavaDamage = 0; m_TicksSinceLastLavaDamage = 0;
} }
@ -1184,7 +1184,7 @@ void cEntity::TickBurning(cChunk & a_Chunk)
{ {
if (!m_IsFireproof) if (!m_IsFireproof)
{ {
TakeDamage(dtFireContact, NULL, FIRE_DAMAGE, 0); TakeDamage(dtFireContact, nullptr, FIRE_DAMAGE, 0);
} }
m_TicksSinceLastFireDamage = 0; m_TicksSinceLastFireDamage = 0;
} }
@ -1213,7 +1213,7 @@ void cEntity::TickInVoid(cChunk & a_Chunk)
{ {
if (m_TicksSinceLastVoidDamage == 20) if (m_TicksSinceLastVoidDamage == 20)
{ {
TakeDamage(dtInVoid, NULL, 2, 0); TakeDamage(dtInVoid, nullptr, 2, 0);
m_TicksSinceLastVoidDamage = 0; m_TicksSinceLastVoidDamage = 0;
} }
else else
@ -1239,7 +1239,7 @@ void cEntity::DetectCacti(void)
(((GetPosY() - Y < 1) && (GetWorld()->GetBlock(X, Y, Z) == E_BLOCK_CACTUS)))) (((GetPosY() - Y < 1) && (GetWorld()->GetBlock(X, Y, Z) == E_BLOCK_CACTUS))))
) )
{ {
TakeDamage(dtCactusContact, NULL, 1, 0); TakeDamage(dtCactusContact, nullptr, 1, 0);
} }
} }
@ -1380,7 +1380,7 @@ bool cEntity::DetectPortal()
bool cEntity::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn) bool cEntity::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn)
{ {
UNUSED(a_ShouldSendRespawn); UNUSED(a_ShouldSendRespawn);
ASSERT(a_World != NULL); ASSERT(a_World != nullptr);
if (GetWorld() == a_World) if (GetWorld() == a_World)
{ {
@ -1406,7 +1406,7 @@ bool cEntity::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn)
bool cEntity::MoveToWorld(const AString & a_WorldName, bool a_ShouldSendRespawn) bool cEntity::MoveToWorld(const AString & a_WorldName, bool a_ShouldSendRespawn)
{ {
cWorld * World = cRoot::Get()->GetWorld(a_WorldName); cWorld * World = cRoot::Get()->GetWorld(a_WorldName);
if (World == NULL) if (World == nullptr)
{ {
LOG("%s: Couldn't find world \"%s\".", __FUNCTION__, a_WorldName.c_str()); LOG("%s: Couldn't find world \"%s\".", __FUNCTION__, a_WorldName.c_str());
return false; return false;
@ -1493,7 +1493,7 @@ void cEntity::HandleAir(void)
if (m_AirTickTimer <= 0) if (m_AirTickTimer <= 0)
{ {
// Damage player // Damage player
TakeDamage(dtDrowning, NULL, 1, 1, 0); TakeDamage(dtDrowning, nullptr, 1, 1, 0);
// Reset timer // Reset timer
m_AirTickTimer = DROWNING_TICKS; m_AirTickTimer = DROWNING_TICKS;
} }
@ -1708,7 +1708,7 @@ void cEntity::AttachTo(cEntity * a_AttachTo)
// Already attached to that entity, nothing to do here // Already attached to that entity, nothing to do here
return; return;
} }
if (m_AttachedTo != NULL) if (m_AttachedTo != nullptr)
{ {
// Detach from any previous entity: // Detach from any previous entity:
Detach(); Detach();
@ -1726,14 +1726,14 @@ void cEntity::AttachTo(cEntity * a_AttachTo)
void cEntity::Detach(void) void cEntity::Detach(void)
{ {
if (m_AttachedTo == NULL) if (m_AttachedTo == nullptr)
{ {
// Attached to no entity, our work is done // Attached to no entity, our work is done
return; return;
} }
m_AttachedTo->m_Attachee = NULL; m_AttachedTo->m_Attachee = nullptr;
m_AttachedTo = NULL; m_AttachedTo = nullptr;
m_World->BroadcastAttachEntity(*this, NULL); m_World->BroadcastAttachEntity(*this, nullptr);
} }
@ -1956,7 +1956,7 @@ void cEntity::HandleSpeedFromAttachee(float a_Forward, float a_Sideways)
void cEntity::SteerVehicle(float a_Forward, float a_Sideways) void cEntity::SteerVehicle(float a_Forward, float a_Sideways)
{ {
if (m_AttachedTo == NULL) if (m_AttachedTo == nullptr)
{ {
return; return;
} }

View File

@ -32,7 +32,7 @@
#define POSZ_TOINT FloorC(GetPosZ()) #define POSZ_TOINT FloorC(GetPosZ())
#define POS_TOINT Vector3i(POSXTOINT, POSYTOINT, POSZTOINT) #define POS_TOINT Vector3i(POSXTOINT, POSYTOINT, POSZTOINT)
#define GET_AND_VERIFY_CURRENT_CHUNK(ChunkVarName, X, Z) cChunk * ChunkVarName = a_Chunk.GetNeighborChunk(X, Z); if ((ChunkVarName == NULL) || !ChunkVarName->IsValid()) { return; } #define GET_AND_VERIFY_CURRENT_CHUNK(ChunkVarName, X, Z) cChunk * ChunkVarName = a_Chunk.GetNeighborChunk(X, Z); if ((ChunkVarName == nullptr) || !ChunkVarName->IsValid()) { return; }
@ -84,13 +84,13 @@ public:
etFloater, etFloater,
etItemFrame, etItemFrame,
etPainting, etPainting,
// Common variations // Common variations
etMob = etMonster, // DEPRECATED, use etMonster instead! etMob = etMonster, // DEPRECATED, use etMonster instead!
} ; } ;
// tolua_end // tolua_end
enum eEntityStatus enum eEntityStatus
{ {
// TODO: Investiagate 0, 1, and 5 as Wiki.vg is not certain // TODO: Investiagate 0, 1, and 5 as Wiki.vg is not certain
@ -127,22 +127,22 @@ public:
// Informs client to explode a firework based on its metadata // Informs client to explode a firework based on its metadata
esFireworkExploding = 17, esFireworkExploding = 17,
} ; } ;
static const int FIRE_TICKS_PER_DAMAGE = 10; ///< Ticks to wait between damaging an entity when it stands in fire static const int FIRE_TICKS_PER_DAMAGE = 10; ///< Ticks to wait between damaging an entity when it stands in fire
static const int FIRE_DAMAGE = 1; ///< Damage to deal when standing in fire static const int FIRE_DAMAGE = 1; ///< Damage to deal when standing in fire
static const int LAVA_TICKS_PER_DAMAGE = 10; ///< Ticks to wait between damaging an entity when it stands in lava static const int LAVA_TICKS_PER_DAMAGE = 10; ///< Ticks to wait between damaging an entity when it stands in lava
static const int LAVA_DAMAGE = 5; ///< Damage to deal when standing in lava static const int LAVA_DAMAGE = 5; ///< Damage to deal when standing in lava
static const int BURN_TICKS_PER_DAMAGE = 20; ///< Ticks to wait between damaging an entity when it is burning static const int BURN_TICKS_PER_DAMAGE = 20; ///< Ticks to wait between damaging an entity when it is burning
static const int BURN_DAMAGE = 1; ///< Damage to deal when the entity is burning static const int BURN_DAMAGE = 1; ///< Damage to deal when the entity is burning
static const int BURN_TICKS = 200; ///< Ticks to keep an entity burning after it has stood in lava / fire static const int BURN_TICKS = 200; ///< Ticks to keep an entity burning after it has stood in lava / fire
static const int MAX_AIR_LEVEL = 300; ///< Maximum air an entity can have static const int MAX_AIR_LEVEL = 300; ///< Maximum air an entity can have
static const int DROWNING_TICKS = 20; ///< Number of ticks per heart of damage static const int DROWNING_TICKS = 20; ///< Number of ticks per heart of damage
static const int VOID_BOUNDARY = -46; ///< Y position to begin applying void damage static const int VOID_BOUNDARY = -46; ///< Y position to begin applying void damage
static const int FALL_DAMAGE_HEIGHT = 4; ///< Y difference after which fall damage is applied static const int FALL_DAMAGE_HEIGHT = 4; ///< Y difference after which fall damage is applied
cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, double a_Width, double a_Height); cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, double a_Width, double a_Height);
virtual ~cEntity(); virtual ~cEntity();
@ -151,9 +151,9 @@ public:
virtual bool Initialize(cWorld & a_World); virtual bool Initialize(cWorld & a_World);
// tolua_begin // tolua_begin
eEntityType GetEntityType(void) const { return m_EntityType; } eEntityType GetEntityType(void) const { return m_EntityType; }
bool IsEnderCrystal(void) const { return (m_EntityType == etEnderCrystal); } bool IsEnderCrystal(void) const { return (m_EntityType == etEnderCrystal); }
bool IsPlayer (void) const { return (m_EntityType == etPlayer); } bool IsPlayer (void) const { return (m_EntityType == etPlayer); }
bool IsPickup (void) const { return (m_EntityType == etPickup); } bool IsPickup (void) const { return (m_EntityType == etPickup); }
@ -168,16 +168,16 @@ public:
bool IsFloater (void) const { return (m_EntityType == etFloater); } bool IsFloater (void) const { return (m_EntityType == etFloater); }
bool IsItemFrame (void) const { return (m_EntityType == etItemFrame); } bool IsItemFrame (void) const { return (m_EntityType == etItemFrame); }
bool IsPainting (void) const { return (m_EntityType == etPainting); } bool IsPainting (void) const { return (m_EntityType == etPainting); }
/// Returns true if the entity is of the specified class or a subclass (cPawn's IsA("cEntity") returns true) /// Returns true if the entity is of the specified class or a subclass (cPawn's IsA("cEntity") returns true)
virtual bool IsA(const char * a_ClassName) const; virtual bool IsA(const char * a_ClassName) const;
/** Returns the class name of this class */ /** Returns the class name of this class */
static const char * GetClassStatic(void); static const char * GetClassStatic(void);
/** Returns the topmost class name for the object */ /** Returns the topmost class name for the object */
virtual const char * GetClass(void) const; virtual const char * GetClass(void) const;
/** Returns the topmost class's parent class name for the object. cEntity returns an empty string (no parent). */ /** Returns the topmost class's parent class name for the object. cEntity returns an empty string (no parent). */
virtual const char * GetParentClass(void) const; virtual const char * GetParentClass(void) const;
@ -200,9 +200,9 @@ public:
double GetSpeedY (void) const { return m_Speed.y; } double GetSpeedY (void) const { return m_Speed.y; }
double GetSpeedZ (void) const { return m_Speed.z; } double GetSpeedZ (void) const { return m_Speed.z; }
double GetWidth (void) const { return m_Width; } double GetWidth (void) const { return m_Width; }
int GetChunkX(void) const {return static_cast<int>(floor(m_Pos.x / cChunkDef::Width)); } int GetChunkX(void) const {return (int)floor(m_Pos.x / cChunkDef::Width); }
int GetChunkZ(void) const {return static_cast<int>(floor(m_Pos.z / cChunkDef::Width)); } int GetChunkZ(void) const {return (int)floor(m_Pos.z / cChunkDef::Width); }
void SetHeadYaw (double a_HeadYaw); void SetHeadYaw (double a_HeadYaw);
void SetHeight (double a_Height); void SetHeight (double a_Height);
@ -219,21 +219,21 @@ public:
/** Sets the speed of the entity, measured in m / sec */ /** Sets the speed of the entity, measured in m / sec */
void SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ); void SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ);
/** Sets the speed of the entity, measured in m / sec */ /** Sets the speed of the entity, measured in m / sec */
void SetSpeed(const Vector3d & a_Speed) { SetSpeed(a_Speed.x, a_Speed.y, a_Speed.z); } void SetSpeed(const Vector3d & a_Speed) { SetSpeed(a_Speed.x, a_Speed.y, a_Speed.z); }
/** Sets the speed in the X axis, leaving the other speed components intact. Measured in m / sec. */ /** Sets the speed in the X axis, leaving the other speed components intact. Measured in m / sec. */
void SetSpeedX(double a_SpeedX); void SetSpeedX(double a_SpeedX);
/** Sets the speed in the Y axis, leaving the other speed components intact. Measured in m / sec. */ /** Sets the speed in the Y axis, leaving the other speed components intact. Measured in m / sec. */
void SetSpeedY(double a_SpeedY); void SetSpeedY(double a_SpeedY);
/** Sets the speed in the Z axis, leaving the other speed components intact. Measured in m / sec. */ /** Sets the speed in the Z axis, leaving the other speed components intact. Measured in m / sec. */
void SetSpeedZ(double a_SpeedZ); void SetSpeedZ(double a_SpeedZ);
void SetWidth (double a_Width); void SetWidth (double a_Width);
void AddPosX (double a_AddPosX); void AddPosX (double a_AddPosX);
void AddPosY (double a_AddPosY); void AddPosY (double a_AddPosY);
void AddPosZ (double a_AddPosZ); void AddPosZ (double a_AddPosZ);
@ -244,7 +244,7 @@ public:
void AddSpeedX (double a_AddSpeedX); void AddSpeedX (double a_AddSpeedX);
void AddSpeedY (double a_AddSpeedY); void AddSpeedY (double a_AddSpeedY);
void AddSpeedZ (double a_AddSpeedZ); void AddSpeedZ (double a_AddSpeedZ);
virtual void HandleSpeedFromAttachee(float a_Forward, float a_Sideways); virtual void HandleSpeedFromAttachee(float a_Forward, float a_Sideways);
void SteerVehicle(float a_Forward, float a_Sideways); void SteerVehicle(float a_Forward, float a_Sideways);
@ -256,60 +256,60 @@ public:
/// Makes this pawn take damage from an attack by a_Attacker. Damage values are calculated automatically and DoTakeDamage() called /// Makes this pawn take damage from an attack by a_Attacker. Damage values are calculated automatically and DoTakeDamage() called
void TakeDamage(cEntity & a_Attacker); void TakeDamage(cEntity & a_Attacker);
/// Makes this entity take the specified damage. The final damage is calculated using current armor, then DoTakeDamage() called /// Makes this entity take the specified damage. The final damage is calculated using current armor, then DoTakeDamage() called
void TakeDamage(eDamageType a_DamageType, cEntity * a_Attacker, int a_RawDamage, double a_KnockbackAmount); void TakeDamage(eDamageType a_DamageType, cEntity * a_Attacker, int a_RawDamage, double a_KnockbackAmount);
/// Makes this entity take the specified damage. The values are packed into a TDI, knockback calculated, then sent through DoTakeDamage() /// Makes this entity take the specified damage. The values are packed into a TDI, knockback calculated, then sent through DoTakeDamage()
void TakeDamage(eDamageType a_DamageType, cEntity * a_Attacker, int a_RawDamage, int a_FinalDamage, double a_KnockbackAmount); void TakeDamage(eDamageType a_DamageType, cEntity * a_Attacker, int a_RawDamage, int a_FinalDamage, double a_KnockbackAmount);
float GetGravity(void) const { return m_Gravity; } float GetGravity(void) const { return m_Gravity; }
void SetGravity(float a_Gravity) { m_Gravity = a_Gravity; } void SetGravity(float a_Gravity) { m_Gravity = a_Gravity; }
/// Sets the rotation to match the speed vector (entity goes "face-forward") /// Sets the rotation to match the speed vector (entity goes "face-forward")
void SetYawFromSpeed(void); void SetYawFromSpeed(void);
/// Sets the pitch to match the speed vector (entity gies "face-forward") /// Sets the pitch to match the speed vector (entity gies "face-forward")
void SetPitchFromSpeed(void); void SetPitchFromSpeed(void);
// tolua_end // tolua_end
/** Makes this entity take damage specified in the a_TDI. /** Makes this entity take damage specified in the a_TDI.
The TDI is sent through plugins first, then applied. The TDI is sent through plugins first, then applied.
If it returns false, the entity hasn't receive any damage. */ If it returns false, the entity hasn't receive any damage. */
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI); virtual bool DoTakeDamage(TakeDamageInfo & a_TDI);
// tolua_begin // tolua_begin
/// Returns the hitpoints that this pawn can deal to a_Receiver using its equipped items /// Returns the hitpoints that this pawn can deal to a_Receiver using its equipped items
virtual int GetRawDamageAgainst(const cEntity & a_Receiver); virtual int GetRawDamageAgainst(const cEntity & a_Receiver);
/** Returns whether armor will protect against the passed damage type **/ /** Returns whether armor will protect against the passed damage type **/
virtual bool ArmorCoversAgainst(eDamageType a_DamageType); virtual bool ArmorCoversAgainst(eDamageType a_DamageType);
/// Returns the hitpoints out of a_RawDamage that the currently equipped armor would cover /// Returns the hitpoints out of a_RawDamage that the currently equipped armor would cover
virtual int GetArmorCoverAgainst(const cEntity * a_Attacker, eDamageType a_DamageType, int a_RawDamage); virtual int GetArmorCoverAgainst(const cEntity * a_Attacker, eDamageType a_DamageType, int a_RawDamage);
/// Returns the knockback amount that the currently equipped items would cause to a_Receiver on a hit /// Returns the knockback amount that the currently equipped items would cause to a_Receiver on a hit
virtual double GetKnockbackAmountAgainst(const cEntity & a_Receiver); virtual double GetKnockbackAmountAgainst(const cEntity & a_Receiver);
/// Returns the curently equipped weapon; empty item if none /// Returns the curently equipped weapon; empty item if none
virtual cItem GetEquippedWeapon(void) const { return cItem(); } virtual cItem GetEquippedWeapon(void) const { return cItem(); }
/// Returns the currently equipped helmet; empty item if none /// Returns the currently equipped helmet; empty item if none
virtual cItem GetEquippedHelmet(void) const { return cItem(); } virtual cItem GetEquippedHelmet(void) const { return cItem(); }
/// Returns the currently equipped chestplate; empty item if none /// Returns the currently equipped chestplate; empty item if none
virtual cItem GetEquippedChestplate(void) const { return cItem(); } virtual cItem GetEquippedChestplate(void) const { return cItem(); }
/// Returns the currently equipped leggings; empty item if none /// Returns the currently equipped leggings; empty item if none
virtual cItem GetEquippedLeggings(void) const { return cItem(); } virtual cItem GetEquippedLeggings(void) const { return cItem(); }
/// Returns the currently equipped boots; empty item if none /// Returns the currently equipped boots; empty item if none
virtual cItem GetEquippedBoots(void) const { return cItem(); } virtual cItem GetEquippedBoots(void) const { return cItem(); }
/// Called when the health drops below zero. a_Killer may be NULL (environmental damage) /// Called when the health drops below zero. a_Killer may be nullptr (environmental damage)
virtual void KilledBy(TakeDamageInfo & a_TDI); virtual void KilledBy(TakeDamageInfo & a_TDI);
/// Called when the entity kills another entity /// Called when the entity kills another entity
@ -317,20 +317,20 @@ public:
/// Heals the specified amount of HPs /// Heals the specified amount of HPs
virtual void Heal(int a_HitPoints); virtual void Heal(int a_HitPoints);
/// Returns the health of this entity /// Returns the health of this entity
int GetHealth(void) const { return m_Health; } int GetHealth(void) const { return m_Health; }
/// Sets the health of this entity; doesn't broadcast any hurt animation /// Sets the health of this entity; doesn't broadcast any hurt animation
void SetHealth(int a_Health); void SetHealth(int a_Health);
// tolua_end // tolua_end
virtual void Tick(float a_Dt, cChunk & a_Chunk); virtual void Tick(float a_Dt, cChunk & a_Chunk);
/// Handles the physics of the entity - updates position based on speed, updates speed based on environment /// Handles the physics of the entity - updates position based on speed, updates speed based on environment
virtual void HandlePhysics(float a_Dt, cChunk & a_Chunk); virtual void HandlePhysics(float a_Dt, cChunk & a_Chunk);
/// Updates the state related to this entity being on fire /// Updates the state related to this entity being on fire
virtual void TickBurning(cChunk & a_Chunk); virtual void TickBurning(cChunk & a_Chunk);
@ -341,34 +341,34 @@ public:
Returns true if MoveToWorld() was called, false if not Returns true if MoveToWorld() was called, false if not
*/ */
virtual bool DetectPortal(void); virtual bool DetectPortal(void);
/// Handles when the entity is in the void /// Handles when the entity is in the void
virtual void TickInVoid(cChunk & a_Chunk); virtual void TickInVoid(cChunk & a_Chunk);
/// Called when the entity starts burning /// Called when the entity starts burning
virtual void OnStartedBurning(void); virtual void OnStartedBurning(void);
/// Called when the entity finishes burning /// Called when the entity finishes burning
virtual void OnFinishedBurning(void); virtual void OnFinishedBurning(void);
// tolua_begin // tolua_begin
/// Sets the maximum value for the health /// Sets the maximum value for the health
void SetMaxHealth(int a_MaxHealth); void SetMaxHealth(int a_MaxHealth);
int GetMaxHealth(void) const { return m_MaxHealth; } int GetMaxHealth(void) const { return m_MaxHealth; }
/// Sets whether the entity is fireproof /// Sets whether the entity is fireproof
void SetIsFireproof(bool a_IsFireproof); void SetIsFireproof(bool a_IsFireproof);
bool IsFireproof(void) const { return m_IsFireproof; } bool IsFireproof(void) const { return m_IsFireproof; }
/// Puts the entity on fire for the specified amount of ticks /// Puts the entity on fire for the specified amount of ticks
void StartBurning(int a_TicksLeftBurning); void StartBurning(int a_TicksLeftBurning);
/// Stops the entity from burning, resets all burning timers /// Stops the entity from burning, resets all burning timers
void StopBurning(void); void StopBurning(void);
// tolua_end // tolua_end
/** Descendants override this function to send a command to the specified client to spawn the entity on the client. /** Descendants override this function to send a command to the specified client to spawn the entity on the client.
@ -377,10 +377,10 @@ public:
virtual void SpawnOn(cClientHandle & a_Client) = 0; virtual void SpawnOn(cClientHandle & a_Client) = 0;
// tolua_begin // tolua_begin
/// Teleports to the entity specified /// Teleports to the entity specified
virtual void TeleportToEntity(cEntity & a_Entity); virtual void TeleportToEntity(cEntity & a_Entity);
/// Teleports to the coordinates specified /// Teleports to the coordinates specified
virtual void TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ); virtual void TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ);
@ -389,7 +389,7 @@ public:
/** Moves entity to specified world, taking a world name */ /** Moves entity to specified world, taking a world name */
bool MoveToWorld(const AString & a_WorldName, bool a_ShouldSendRespawn = true); bool MoveToWorld(const AString & a_WorldName, bool a_ShouldSendRespawn = true);
// tolua_end // tolua_end
virtual bool DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn); virtual bool DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn);
@ -399,16 +399,16 @@ public:
/** Sets the world the entity will be leaving */ /** Sets the world the entity will be leaving */
void SetWorldTravellingFrom(cWorld * a_World) { m_WorldTravellingFrom = a_World; } void SetWorldTravellingFrom(cWorld * a_World) { m_WorldTravellingFrom = a_World; }
/// Updates clients of changes in the entity. /// Updates clients of changes in the entity.
virtual void BroadcastMovementUpdate(const cClientHandle * a_Exclude = NULL); virtual void BroadcastMovementUpdate(const cClientHandle * a_Exclude = nullptr);
/// Attaches to the specified entity; detaches from any previous one first /// Attaches to the specified entity; detaches from any previous one first
void AttachTo(cEntity * a_AttachTo); void AttachTo(cEntity * a_AttachTo);
/// Detaches from the currently attached entity, if any /// Detaches from the currently attached entity, if any
virtual void Detach(void); virtual void Detach(void);
/// Makes sure head yaw is not over the specified range. /// Makes sure head yaw is not over the specified range.
void WrapHeadYaw(); void WrapHeadYaw();
@ -417,9 +417,9 @@ public:
/// Makes speed is not over 20. Max speed is 20 blocks / second /// Makes speed is not over 20. Max speed is 20 blocks / second
void WrapSpeed(); void WrapSpeed();
// tolua_begin // tolua_begin
// COMMON metadata flags; descendants may override the defaults: // COMMON metadata flags; descendants may override the defaults:
virtual bool IsOnFire (void) const {return (m_TicksLeftBurning > 0); } virtual bool IsOnFire (void) const {return (m_TicksLeftBurning > 0); }
virtual bool IsCrouched (void) const {return false; } virtual bool IsCrouched (void) const {return false; }
@ -437,20 +437,20 @@ public:
/** Gets number of ticks this entity has existed for */ /** Gets number of ticks this entity has existed for */
long int GetTicksAlive(void) const { return m_TicksAlive; } long int GetTicksAlive(void) const { return m_TicksAlive; }
/** Gets the invulnerable ticks from the entity */ /** Gets the invulnerable ticks from the entity */
int GetInvulnerableTicks(void) const { return m_InvulnerableTicks; } int GetInvulnerableTicks(void) const { return m_InvulnerableTicks; }
/** Set the invulnerable ticks from the entity */ /** Set the invulnerable ticks from the entity */
void SetInvulnerableTicks(int a_InvulnerableTicks) { m_InvulnerableTicks = a_InvulnerableTicks; } void SetInvulnerableTicks(int a_InvulnerableTicks) { m_InvulnerableTicks = a_InvulnerableTicks; }
// tolua_end // tolua_end
/// Called when the specified player right-clicks this entity /// Called when the specified player right-clicks this entity
virtual void OnRightClicked(cPlayer & a_Player) {} virtual void OnRightClicked(cPlayer & a_Player) {}
/// Returns the list of drops for this pawn when it is killed. May check a_Killer for special handling (sword of looting etc.). Called from KilledBy(). /// Returns the list of drops for this pawn when it is killed. May check a_Killer for special handling (sword of looting etc.). Called from KilledBy().
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr)
{ {
UNUSED(a_Drops); UNUSED(a_Drops);
UNUSED(a_Killer); UNUSED(a_Killer);
@ -462,38 +462,38 @@ public:
protected: protected:
static cCriticalSection m_CSCount; static cCriticalSection m_CSCount;
static int m_EntityCount; static int m_EntityCount;
/** Measured in meter/second (m/s) */ /** Measured in meter/second (m/s) */
Vector3d m_Speed; Vector3d m_Speed;
int m_UniqueID; int m_UniqueID;
int m_Health; int m_Health;
int m_MaxHealth; int m_MaxHealth;
/// The entity to which this entity is attached (vehicle), NULL if none /// The entity to which this entity is attached (vehicle), nullptr if none
cEntity * m_AttachedTo; cEntity * m_AttachedTo;
/// The entity which is attached to this entity (rider), NULL if none /// The entity which is attached to this entity (rider), nullptr if none
cEntity * m_Attachee; cEntity * m_Attachee;
/** Stores whether head yaw has been set manually */ /** Stores whether head yaw has been set manually */
bool m_bDirtyHead; bool m_bDirtyHead;
/** Stores whether our yaw/pitch/roll (body orientation) has been set manually */ /** Stores whether our yaw/pitch/roll (body orientation) has been set manually */
bool m_bDirtyOrientation; bool m_bDirtyOrientation;
/** Stores whether we have sent a Velocity packet with a speed of zero (no speed) to the client /** Stores whether we have sent a Velocity packet with a speed of zero (no speed) to the client
Ensures that said packet is sent only once */ Ensures that said packet is sent only once */
bool m_bHasSentNoSpeed; bool m_bHasSentNoSpeed;
/** Stores if the entity is on the ground */ /** Stores if the entity is on the ground */
bool m_bOnGround; bool m_bOnGround;
/** Stores gravity that is applied to an entity every tick /** Stores gravity that is applied to an entity every tick
For realistic effects, this should be negative. For spaaaaaaace, this can be zero or even positive */ For realistic effects, this should be negative. For spaaaaaaace, this can be zero or even positive */
float m_Gravity; float m_Gravity;
/** Last position sent to client via the Relative Move or Teleport packets (not Velocity) /** Last position sent to client via the Relative Move or Teleport packets (not Velocity)
Only updated if cEntity::BroadcastMovementUpdate() is called! */ Only updated if cEntity::BroadcastMovementUpdate() is called! */
Vector3d m_LastPos; Vector3d m_LastPos;
@ -502,37 +502,37 @@ protected:
bool m_IsInitialized; bool m_IsInitialized;
/** World entity is travelling from /** World entity is travelling from
Set to a valid world pointer by MoveToWorld; reset to NULL when the entity is removed from the old world Set to a valid world pointer by MoveToWorld; reset to nullptr when the entity is removed from the old world
Can't be a simple boolean as context switches between worlds may leave the new chunk processing (and therefore immediately removing) the entity before the old chunk could remove it Can't be a simple boolean as context switches between worlds may leave the new chunk processing (and therefore immediately removing) the entity before the old chunk could remove it
*/ */
cWorld * m_WorldTravellingFrom; cWorld * m_WorldTravellingFrom;
eEntityType m_EntityType; eEntityType m_EntityType;
cWorld * m_World; cWorld * m_World;
/// Whether the entity is capable of taking fire or lava damage. /// Whether the entity is capable of taking fire or lava damage.
bool m_IsFireproof; bool m_IsFireproof;
/// Time, in ticks, since the last damage dealt by being on fire. Valid only if on fire (IsOnFire()) /// Time, in ticks, since the last damage dealt by being on fire. Valid only if on fire (IsOnFire())
int m_TicksSinceLastBurnDamage; int m_TicksSinceLastBurnDamage;
/// Time, in ticks, since the last damage dealt by standing in lava. Reset to zero when moving out of lava. /// Time, in ticks, since the last damage dealt by standing in lava. Reset to zero when moving out of lava.
int m_TicksSinceLastLavaDamage; int m_TicksSinceLastLavaDamage;
/// Time, in ticks, since the last damage dealt by standing in fire. Reset to zero when moving out of fire. /// Time, in ticks, since the last damage dealt by standing in fire. Reset to zero when moving out of fire.
int m_TicksSinceLastFireDamage; int m_TicksSinceLastFireDamage;
/// Time, in ticks, until the entity extinguishes its fire /// Time, in ticks, until the entity extinguishes its fire
int m_TicksLeftBurning; int m_TicksLeftBurning;
/// Time, in ticks, since the last damage dealt by the void. Reset to zero when moving out of the void. /// Time, in ticks, since the last damage dealt by the void. Reset to zero when moving out of the void.
int m_TicksSinceLastVoidDamage; int m_TicksSinceLastVoidDamage;
/** Does the actual speed-setting. The default implementation just sets the member variable value; /** Does the actual speed-setting. The default implementation just sets the member variable value;
overrides can provide further processing, such as forcing players to move at the given speed. */ overrides can provide further processing, such as forcing players to move at the given speed. */
virtual void DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ); virtual void DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ);
virtual void Destroyed(void) {} // Called after the entity has been destroyed virtual void Destroyed(void) {} // Called after the entity has been destroyed
/** Applies friction to an entity /** Applies friction to an entity
@ -543,7 +543,7 @@ protected:
/** Called in each tick to handle air-related processing i.e. drowning */ /** Called in each tick to handle air-related processing i.e. drowning */
virtual void HandleAir(void); virtual void HandleAir(void);
/** Called once per tick to set IsSwimming and IsSubmerged */ /** Called once per tick to set IsSwimming and IsSubmerged */
virtual void SetSwimState(cChunk & a_Chunk); virtual void SetSwimState(cChunk & a_Chunk);
@ -568,29 +568,29 @@ protected:
/** Portal delay timer and cooldown boolean data */ /** Portal delay timer and cooldown boolean data */
sPortalCooldownData m_PortalCooldownData; sPortalCooldownData m_PortalCooldownData;
/** The number of ticks this entity has been alive for */ /** The number of ticks this entity has been alive for */
long int m_TicksAlive; long int m_TicksAlive;
private: private:
/** Measured in degrees, [-180, +180) */ /** Measured in degrees, [-180, +180) */
double m_HeadYaw; double m_HeadYaw;
/** Measured in degrees, [-180, +180) */ /** Measured in degrees, [-180, +180) */
Vector3d m_Rot; Vector3d m_Rot;
/** Position of the entity's XZ center and Y bottom */ /** Position of the entity's XZ center and Y bottom */
Vector3d m_Pos; Vector3d m_Pos;
/** Measured in meter / second */ /** Measured in meter / second */
Vector3d m_WaterSpeed; Vector3d m_WaterSpeed;
/** Measured in Kilograms (Kg) */ /** Measured in Kilograms (Kg) */
double m_Mass; double m_Mass;
/** Width of the entity, in the XZ plane. Since entities are represented as cylinders, this is more of a diameter. */ /** Width of the entity, in the XZ plane. Since entities are represented as cylinders, this is more of a diameter. */
double m_Width; double m_Width;
/** Height of the entity (Y axis) */ /** Height of the entity (Y axis) */
double m_Height; double m_Height;
@ -600,3 +600,7 @@ private:
} ; // tolua_export } ; // tolua_export
typedef std::list<cEntity *> cEntityList; typedef std::list<cEntity *> cEntityList;

View File

@ -216,7 +216,7 @@ cEntityEffect * cEntityEffect::CreateEntityEffect(cEntityEffect::eType a_EffectT
} }
ASSERT(!"Unhandled entity effect type!"); ASSERT(!"Unhandled entity effect type!");
return NULL; return nullptr;
} }
@ -329,7 +329,7 @@ void cEntityEffectInstantHealth::OnActivate(cPawn & a_Target)
if (a_Target.IsMob() && ((cMonster &) a_Target).IsUndead()) if (a_Target.IsMob() && ((cMonster &) a_Target).IsUndead())
{ {
a_Target.TakeDamage(dtPotionOfHarming, NULL, amount, 0); // TODO: Store attacker in a pointer-safe way, pass to TakeDamage a_Target.TakeDamage(dtPotionOfHarming, nullptr, amount, 0); // TODO: Store attacker in a pointer-safe way, pass to TakeDamage
return; return;
} }
a_Target.Heal(amount); a_Target.Heal(amount);
@ -352,7 +352,7 @@ void cEntityEffectInstantDamage::OnActivate(cPawn & a_Target)
a_Target.Heal(amount); a_Target.Heal(amount);
return; return;
} }
a_Target.TakeDamage(dtPotionOfHarming, NULL, amount, 0); // TODO: Store attacker in a pointer-safe way, pass to TakeDamage a_Target.TakeDamage(dtPotionOfHarming, nullptr, amount, 0); // TODO: Store attacker in a pointer-safe way, pass to TakeDamage
} }
@ -452,7 +452,7 @@ void cEntityEffectPoison::OnTick(cPawn & a_Target)
// Cannot take poison damage when health is at 1 // Cannot take poison damage when health is at 1
if (a_Target.GetHealth() > 1) if (a_Target.GetHealth() > 1)
{ {
a_Target.TakeDamage(dtPoisoning, NULL, 1, 0); a_Target.TakeDamage(dtPoisoning, nullptr, 1, 0);
} }
} }
} }
@ -473,7 +473,7 @@ void cEntityEffectWither::OnTick(cPawn & a_Target)
if ((m_Ticks % frequency) == 0) if ((m_Ticks % frequency) == 0)
{ {
a_Target.TakeDamage(dtWither, NULL, 1, 0); a_Target.TakeDamage(dtWither, nullptr, 1, 0);
} }
} }

View File

@ -45,7 +45,7 @@ void cExpOrb::SpawnOn(cClientHandle & a_Client)
void cExpOrb::Tick(float a_Dt, cChunk & a_Chunk) void cExpOrb::Tick(float a_Dt, cChunk & a_Chunk)
{ {
cPlayer * a_ClosestPlayer(m_World->FindClosestPlayer(Vector3f(GetPosition()), 5)); cPlayer * a_ClosestPlayer(m_World->FindClosestPlayer(Vector3f(GetPosition()), 5));
if (a_ClosestPlayer != NULL) if (a_ClosestPlayer != nullptr)
{ {
Vector3f a_PlayerPos(a_ClosestPlayer->GetPosition()); Vector3f a_PlayerPos(a_ClosestPlayer->GetPosition());
a_PlayerPos.y++; a_PlayerPos.y++;

View File

@ -22,7 +22,7 @@ public:
m_Pos(a_Pos), m_Pos(a_Pos),
m_NextPos(a_NextPos), m_NextPos(a_NextPos),
m_MinCoeff(1), m_MinCoeff(1),
m_HitEntity(NULL) m_HitEntity(nullptr)
{ {
} }
virtual bool Item(cEntity * a_Entity) override virtual bool Item(cEntity * a_Entity) override

View File

@ -62,7 +62,7 @@ void cItemFrame::KilledBy(TakeDamageInfo & a_TDI)
return; return;
} }
if ((a_TDI.Attacker != NULL) && a_TDI.Attacker->IsPlayer() && !((cPlayer *)a_TDI.Attacker)->IsGameModeCreative()) if ((a_TDI.Attacker != nullptr) && a_TDI.Attacker->IsPlayer() && !((cPlayer *)a_TDI.Attacker)->IsGameModeCreative())
{ {
cItems Item; cItems Item;
Item.push_back(m_Item); Item.push_back(m_Item);
@ -83,7 +83,7 @@ void cItemFrame::KilledBy(TakeDamageInfo & a_TDI)
void cItemFrame::GetDrops(cItems & a_Items, cEntity * a_Killer) void cItemFrame::GetDrops(cItems & a_Items, cEntity * a_Killer)
{ {
if ((a_Killer != NULL) && a_Killer->IsPlayer() && !((cPlayer *)a_Killer)->IsGameModeCreative()) if ((a_Killer != nullptr) && a_Killer->IsPlayer() && !((cPlayer *)a_Killer)->IsGameModeCreative())
{ {
a_Items.push_back(cItem(E_ITEM_ITEM_FRAME)); a_Items.push_back(cItem(E_ITEM_ITEM_FRAME));
} }

View File

@ -36,7 +36,7 @@ public:
virtual bool Item(cEntity * a_Entity) override virtual bool Item(cEntity * a_Entity) override
{ {
ASSERT(a_Entity != NULL); ASSERT(a_Entity != nullptr);
if (!a_Entity->IsPlayer() && !a_Entity->IsMob() && !a_Entity->IsMinecart() && !a_Entity->IsBoat()) if (!a_Entity->IsPlayer() && !a_Entity->IsMob() && !a_Entity->IsMinecart() && !a_Entity->IsBoat())
{ {
@ -130,7 +130,7 @@ void cMinecart::HandlePhysics(float a_Dt, cChunk & a_Chunk)
int RelPosX = POSX_TOINT - a_Chunk.GetPosX() * cChunkDef::Width; int RelPosX = POSX_TOINT - a_Chunk.GetPosX() * cChunkDef::Width;
int RelPosZ = POSZ_TOINT - a_Chunk.GetPosZ() * cChunkDef::Width; int RelPosZ = POSZ_TOINT - a_Chunk.GetPosZ() * cChunkDef::Width;
cChunk * Chunk = a_Chunk.GetRelNeighborChunkAdjustCoords(RelPosX, RelPosZ); cChunk * Chunk = a_Chunk.GetRelNeighborChunkAdjustCoords(RelPosX, RelPosZ);
if (Chunk == NULL) if (Chunk == nullptr)
{ {
// Inside an unloaded chunk, bail out all processing // Inside an unloaded chunk, bail out all processing
return; return;
@ -806,7 +806,7 @@ bool cMinecart::TestBlockCollision(NIBBLETYPE a_RailMeta)
bool cMinecart::TestEntityCollision(NIBBLETYPE a_RailMeta) bool cMinecart::TestEntityCollision(NIBBLETYPE a_RailMeta)
{ {
cMinecartCollisionCallback MinecartCollisionCallback(GetPosition(), GetHeight(), GetWidth(), GetUniqueID(), ((m_Attachee == NULL) ? -1 : m_Attachee->GetUniqueID())); cMinecartCollisionCallback MinecartCollisionCallback(GetPosition(), GetHeight(), GetWidth(), GetUniqueID(), ((m_Attachee == nullptr) ? -1 : m_Attachee->GetUniqueID()));
int ChunkX, ChunkZ; int ChunkX, ChunkZ;
cChunkDef::BlockToChunk(POSX_TOINT, POSZ_TOINT, ChunkX, ChunkZ); cChunkDef::BlockToChunk(POSX_TOINT, POSZ_TOINT, ChunkX, ChunkZ);
m_World->ForEachEntityInChunk(ChunkX, ChunkZ, MinecartCollisionCallback); m_World->ForEachEntityInChunk(ChunkX, ChunkZ, MinecartCollisionCallback);
@ -980,7 +980,7 @@ bool cMinecart::TestEntityCollision(NIBBLETYPE a_RailMeta)
bool cMinecart::DoTakeDamage(TakeDamageInfo & TDI) bool cMinecart::DoTakeDamage(TakeDamageInfo & TDI)
{ {
if ((TDI.Attacker != NULL) && TDI.Attacker->IsPlayer() && ((cPlayer *)TDI.Attacker)->IsGameModeCreative()) if ((TDI.Attacker != nullptr) && TDI.Attacker->IsPlayer() && ((cPlayer *)TDI.Attacker)->IsGameModeCreative())
{ {
Destroy(); Destroy();
TDI.FinalDamage = GetMaxHealth(); // Instant hit for creative TDI.FinalDamage = GetMaxHealth(); // Instant hit for creative
@ -1074,7 +1074,7 @@ void cRideableMinecart::OnRightClicked(cPlayer & a_Player)
{ {
super::OnRightClicked(a_Player); super::OnRightClicked(a_Player);
if (m_Attachee != NULL) if (m_Attachee != nullptr)
{ {
if (m_Attachee->GetUniqueID() == a_Player.GetUniqueID()) if (m_Attachee->GetUniqueID() == a_Player.GetUniqueID())
{ {
@ -1120,14 +1120,14 @@ void cMinecartWithChest::OnRightClicked(cPlayer & a_Player)
{ {
// If the window is not created, open it anew: // If the window is not created, open it anew:
cWindow * Window = GetWindow(); cWindow * Window = GetWindow();
if (Window == NULL) if (Window == nullptr)
{ {
OpenNewWindow(); OpenNewWindow();
Window = GetWindow(); Window = GetWindow();
} }
// Open the window for the player: // Open the window for the player:
if (Window != NULL) if (Window != nullptr)
{ {
if (a_Player.GetWindow() != Window) if (a_Player.GetWindow() != Window)
{ {

View File

@ -140,9 +140,9 @@ protected:
{ {
UNUSED(a_SlotNum); UNUSED(a_SlotNum);
ASSERT(a_Grid == &m_Contents); ASSERT(a_Grid == &m_Contents);
if (m_World != NULL) if (m_World != nullptr)
{ {
if (GetWindow() != NULL) if (GetWindow() != nullptr)
{ {
GetWindow()->BroadcastWholeWindow(); GetWindow()->BroadcastWholeWindow();
} }

View File

@ -43,7 +43,7 @@ void cPainting::Tick(float a_Dt, cChunk & a_Chunk)
void cPainting::GetDrops(cItems & a_Items, cEntity * a_Killer) void cPainting::GetDrops(cItems & a_Items, cEntity * a_Killer)
{ {
if ((a_Killer != NULL) && a_Killer->IsPlayer() && !((cPlayer *)a_Killer)->IsGameModeCreative()) if ((a_Killer != nullptr) && a_Killer->IsPlayer() && !((cPlayer *)a_Killer)->IsGameModeCreative())
{ {
a_Items.push_back(cItem(E_ITEM_PAINTING)); a_Items.push_back(cItem(E_ITEM_PAINTING));
} }

View File

@ -56,8 +56,8 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) :
m_Stance(0.0), m_Stance(0.0),
m_Inventory(*this), m_Inventory(*this),
m_EnderChestContents(9, 3), m_EnderChestContents(9, 3),
m_CurrentWindow(NULL), m_CurrentWindow(nullptr),
m_InventoryWindow(NULL), m_InventoryWindow(nullptr),
m_GameMode(eGameMode_NotSet), m_GameMode(eGameMode_NotSet),
m_IP(""), m_IP(""),
m_ClientHandle(a_Client), m_ClientHandle(a_Client),
@ -78,10 +78,10 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) :
m_IsChargingBow(false), m_IsChargingBow(false),
m_BowCharge(0), m_BowCharge(0),
m_FloaterID(-1), m_FloaterID(-1),
m_Team(NULL), m_Team(nullptr),
m_TicksUntilNextSave(PLAYER_INVENTORY_SAVE_INTERVAL), m_TicksUntilNextSave(PLAYER_INVENTORY_SAVE_INTERVAL),
m_bIsTeleporting(false), m_bIsTeleporting(false),
m_UUID((a_Client != NULL) ? a_Client->GetUUID() : ""), m_UUID((a_Client != nullptr) ? a_Client->GetUUID() : ""),
m_CustomName("") m_CustomName("")
{ {
m_InventoryWindow = new cInventoryWindow(*this); m_InventoryWindow = new cInventoryWindow(*this);
@ -96,7 +96,7 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) :
m_PlayerName = a_PlayerName; m_PlayerName = a_PlayerName;
cWorld * World = NULL; cWorld * World = nullptr;
if (!LoadFromDisk(World)) if (!LoadFromDisk(World))
{ {
m_Inventory.Clear(); m_Inventory.Clear();
@ -144,10 +144,10 @@ cPlayer::~cPlayer(void)
SaveToDisk(); SaveToDisk();
m_ClientHandle = NULL; m_ClientHandle = nullptr;
delete m_InventoryWindow; delete m_InventoryWindow;
m_InventoryWindow = NULL; m_InventoryWindow = nullptr;
LOGD("Player %p deleted", this); LOGD("Player %p deleted", this);
} }
@ -186,12 +186,12 @@ void cPlayer::SpawnOn(cClientHandle & a_Client)
void cPlayer::Tick(float a_Dt, cChunk & a_Chunk) void cPlayer::Tick(float a_Dt, cChunk & a_Chunk)
{ {
if (m_ClientHandle != NULL) if (m_ClientHandle != nullptr)
{ {
if (m_ClientHandle->IsDestroyed()) if (m_ClientHandle->IsDestroyed())
{ {
// This should not happen, because destroying a client will remove it from the world, but just in case // This should not happen, because destroying a client will remove it from the world, but just in case
m_ClientHandle = NULL; m_ClientHandle = nullptr;
return; return;
} }
@ -504,7 +504,7 @@ void cPlayer::SetTouchGround(bool a_bTouchGround)
if (Damage > 0) if (Damage > 0)
{ {
// cPlayer makes sure damage isn't applied in creative, no need to check here // cPlayer makes sure damage isn't applied in creative, no need to check here
TakeDamage(dtFalling, NULL, Damage, Damage, 0); TakeDamage(dtFalling, nullptr, Damage, Damage, 0);
// Fall particles // Fall particles
GetWorld()->BroadcastSoundParticleEffect(2006, POSX_TOINT, (int)GetPosY() - 1, POSZ_TOINT, Damage /* Used as particle effect speed modifier */); GetWorld()->BroadcastSoundParticleEffect(2006, POSX_TOINT, (int)GetPosY() - 1, POSZ_TOINT, Damage /* Used as particle effect speed modifier */);
@ -651,7 +651,7 @@ void cPlayer::AbortEating(void)
void cPlayer::SendHealth(void) void cPlayer::SendHealth(void)
{ {
if (m_ClientHandle != NULL) if (m_ClientHandle != nullptr)
{ {
m_ClientHandle->SendHealth(); m_ClientHandle->SendHealth();
} }
@ -663,7 +663,7 @@ void cPlayer::SendHealth(void)
void cPlayer::SendExperience(void) void cPlayer::SendExperience(void)
{ {
if (m_ClientHandle != NULL) if (m_ClientHandle != nullptr)
{ {
m_ClientHandle->SendExperience(); m_ClientHandle->SendExperience();
m_bDirtyExperience = false; m_bDirtyExperience = false;
@ -859,11 +859,11 @@ bool cPlayer::DoTakeDamage(TakeDamageInfo & a_TDI)
} }
} }
if ((a_TDI.Attacker != NULL) && (a_TDI.Attacker->IsPlayer())) if ((a_TDI.Attacker != nullptr) && (a_TDI.Attacker->IsPlayer()))
{ {
cPlayer * Attacker = (cPlayer *)a_TDI.Attacker; cPlayer * Attacker = (cPlayer *)a_TDI.Attacker;
if ((m_Team != NULL) && (m_Team == Attacker->m_Team)) if ((m_Team != nullptr) && (m_Team == Attacker->m_Team))
{ {
if (!m_Team->AllowsFriendlyFire()) if (!m_Team->AllowsFriendlyFire())
{ {
@ -915,7 +915,7 @@ void cPlayer::KilledBy(TakeDamageInfo & a_TDI)
m_World->SpawnItemPickups(Pickups, GetPosX(), GetPosY(), GetPosZ(), 10); m_World->SpawnItemPickups(Pickups, GetPosX(), GetPosY(), GetPosZ(), 10);
SaveToDisk(); // Save it, yeah the world is a tough place ! SaveToDisk(); // Save it, yeah the world is a tough place !
if ((a_TDI.Attacker == NULL) && m_World->ShouldBroadcastDeathMessages()) if ((a_TDI.Attacker == nullptr) && m_World->ShouldBroadcastDeathMessages())
{ {
AString DamageText; AString DamageText;
switch (a_TDI.DamageType) switch (a_TDI.DamageType)
@ -941,7 +941,7 @@ void cPlayer::KilledBy(TakeDamageInfo & a_TDI)
} }
GetWorld()->BroadcastChatDeath(Printf("%s %s", GetName().c_str(), DamageText.c_str())); GetWorld()->BroadcastChatDeath(Printf("%s %s", GetName().c_str(), DamageText.c_str()));
} }
else if (a_TDI.Attacker == NULL) // && !m_World->ShouldBroadcastDeathMessages() by fallthrough else if (a_TDI.Attacker == nullptr) // && !m_World->ShouldBroadcastDeathMessages() by fallthrough
{ {
// no-op // no-op
} }
@ -997,7 +997,7 @@ void cPlayer::Killed(cEntity * a_Victim)
void cPlayer::Respawn(void) void cPlayer::Respawn(void)
{ {
ASSERT(m_World != NULL); ASSERT(m_World != nullptr);
m_Health = GetMaxHealth(); m_Health = GetMaxHealth();
SetInvulnerableTicks(20); SetInvulnerableTicks(20);
@ -1107,9 +1107,9 @@ void cPlayer::SetTeam(cTeam * a_Team)
cTeam * cPlayer::UpdateTeam(void) cTeam * cPlayer::UpdateTeam(void)
{ {
if (m_World == NULL) if (m_World == nullptr)
{ {
SetTeam(NULL); SetTeam(nullptr);
} }
else else
{ {
@ -1142,7 +1142,7 @@ void cPlayer::OpenWindow(cWindow * a_Window)
void cPlayer::CloseWindow(bool a_CanRefuse) void cPlayer::CloseWindow(bool a_CanRefuse)
{ {
if (m_CurrentWindow == NULL) if (m_CurrentWindow == nullptr)
{ {
m_CurrentWindow = m_InventoryWindow; m_CurrentWindow = m_InventoryWindow;
return; return;
@ -1167,7 +1167,7 @@ void cPlayer::CloseWindow(bool a_CanRefuse)
void cPlayer::CloseWindowIfID(char a_WindowID, bool a_CanRefuse) void cPlayer::CloseWindowIfID(char a_WindowID, bool a_CanRefuse)
{ {
if ((m_CurrentWindow == NULL) || (m_CurrentWindow->GetWindowID() != a_WindowID)) if ((m_CurrentWindow == nullptr) || (m_CurrentWindow->GetWindowID() != a_WindowID))
{ {
return; return;
} }
@ -1354,7 +1354,7 @@ void cPlayer::MoveTo( const Vector3d & a_NewPos)
// Y = -999 and X, Z = attempting to create speed, usually up to 0.03 // Y = -999 and X, Z = attempting to create speed, usually up to 0.03
// We cannot test m_AttachedTo, because when deattaching, the server thinks the client is already deattached while // We cannot test m_AttachedTo, because when deattaching, the server thinks the client is already deattached while
// the client may still send more of these nonsensical packets. // the client may still send more of these nonsensical packets.
if (m_AttachedTo != NULL) if (m_AttachedTo != nullptr)
{ {
Vector3d AddSpeed(a_NewPos); Vector3d AddSpeed(a_NewPos);
AddSpeed.y = 0; AddSpeed.y = 0;
@ -1581,7 +1581,7 @@ void cPlayer::TossItems(const cItems & a_Items)
bool cPlayer::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn) bool cPlayer::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn)
{ {
ASSERT(a_World != NULL); ASSERT(a_World != nullptr);
if (GetWorld() == a_World) if (GetWorld() == a_World)
{ {
@ -1590,7 +1590,7 @@ bool cPlayer::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn)
} }
// Send the respawn packet: // Send the respawn packet:
if (a_ShouldSendRespawn && (m_ClientHandle != NULL)) if (a_ShouldSendRespawn && (m_ClientHandle != nullptr))
{ {
m_ClientHandle->SendRespawn(a_World->GetDimension()); m_ClientHandle->SendRespawn(a_World->GetDimension());
} }
@ -1652,7 +1652,7 @@ bool cPlayer::LoadFromDisk(cWorldPtr & a_World)
GetName().c_str(), m_UUID.c_str(), OfflineUUID.c_str(), OfflineUsage GetName().c_str(), m_UUID.c_str(), OfflineUUID.c_str(), OfflineUsage
); );
if (a_World == NULL) if (a_World == nullptr)
{ {
a_World = cRoot::Get()->GetDefaultWorld(); a_World = cRoot::Get()->GetDefaultWorld();
} }
@ -1729,7 +1729,7 @@ bool cPlayer::LoadFromFile(const AString & a_FileName, cWorldPtr & a_World)
m_LoadedWorldName = root.get("world", "world").asString(); m_LoadedWorldName = root.get("world", "world").asString();
a_World = cRoot::Get()->GetWorld(GetLoadedWorldName(), false); a_World = cRoot::Get()->GetWorld(GetLoadedWorldName(), false);
if (a_World == NULL) if (a_World == nullptr)
{ {
a_World = cRoot::Get()->GetDefaultWorld(); a_World = cRoot::Get()->GetDefaultWorld();
} }
@ -1795,7 +1795,7 @@ bool cPlayer::SaveToDisk()
root["SpawnY"] = GetLastBedPos().y; root["SpawnY"] = GetLastBedPos().y;
root["SpawnZ"] = GetLastBedPos().z; root["SpawnZ"] = GetLastBedPos().z;
if (m_World != NULL) if (m_World != nullptr)
{ {
root["world"] = m_World->GetName(); root["world"] = m_World->GetName();
if (m_GameMode == m_World->GetGameMode()) if (m_GameMode == m_World->GetGameMode())
@ -1949,7 +1949,7 @@ void cPlayer::HandleFood(void)
else if ((m_FoodLevel <= 0) && (m_Health > 1)) else if ((m_FoodLevel <= 0) && (m_Health > 1))
{ {
// Damage from starving // Damage from starving
TakeDamage(dtStarving, NULL, 1, 1, 0); TakeDamage(dtStarving, nullptr, 1, 1, 0);
} }
} }
} }
@ -2018,7 +2018,7 @@ void cPlayer::UpdateMovementStats(const Vector3d & a_DeltaPos)
{ {
StatValue Value = (StatValue)floor(a_DeltaPos.Length() * 100 + 0.5); StatValue Value = (StatValue)floor(a_DeltaPos.Length() * 100 + 0.5);
if (m_AttachedTo == NULL) if (m_AttachedTo == nullptr)
{ {
if (IsClimbing()) if (IsClimbing())
{ {
@ -2091,7 +2091,7 @@ void cPlayer::ApplyFoodExhaustionFromMovement()
} }
// If riding anything, apply no food exhaustion // If riding anything, apply no food exhaustion
if (m_AttachedTo != NULL) if (m_AttachedTo != nullptr)
{ {
return; return;
} }

View File

@ -176,10 +176,10 @@ public:
AString GetIP(void) const { return m_IP; } // tolua_export AString GetIP(void) const { return m_IP; } // tolua_export
/** Returns the associated team, NULL if none */ /** Returns the associated team, nullptr if none */
cTeam * GetTeam(void) { return m_Team; } // tolua_export cTeam * GetTeam(void) { return m_Team; } // tolua_export
/** Sets the player team, NULL if none */ /** Sets the player team, nullptr if none */
void SetTeam(cTeam * a_Team); void SetTeam(cTeam * a_Team);
// tolua_end // tolua_end

View File

@ -135,7 +135,7 @@ public:
m_Pos(a_Pos), m_Pos(a_Pos),
m_NextPos(a_NextPos), m_NextPos(a_NextPos),
m_MinCoeff(1), m_MinCoeff(1),
m_HitEntity(NULL) m_HitEntity(nullptr)
{ {
} }
@ -221,9 +221,9 @@ cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a
super(etProjectile, a_X, a_Y, a_Z, a_Width, a_Height), super(etProjectile, a_X, a_Y, a_Z, a_Width, a_Height),
m_ProjectileKind(a_Kind), m_ProjectileKind(a_Kind),
m_CreatorData( m_CreatorData(
((a_Creator != NULL) ? a_Creator->GetUniqueID() : -1), ((a_Creator != nullptr) ? a_Creator->GetUniqueID() : -1),
((a_Creator != NULL) ? (a_Creator->IsPlayer() ? ((cPlayer *)a_Creator)->GetName() : "") : ""), ((a_Creator != nullptr) ? (a_Creator->IsPlayer() ? ((cPlayer *)a_Creator)->GetName() : "") : ""),
((a_Creator != NULL) ? a_Creator->GetEquippedWeapon().m_Enchantments : cEnchantments()) ((a_Creator != nullptr) ? a_Creator->GetEquippedWeapon().m_Enchantments : cEnchantments())
), ),
m_IsInGround(false) m_IsInGround(false)
{ {
@ -251,7 +251,7 @@ cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, const Ve
cProjectileEntity * cProjectileEntity::Create(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem * a_Item, const Vector3d * a_Speed) cProjectileEntity * cProjectileEntity::Create(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem * a_Item, const Vector3d * a_Speed)
{ {
Vector3d Speed; Vector3d Speed;
if (a_Speed != NULL) if (a_Speed != nullptr)
{ {
Speed = *a_Speed; Speed = *a_Speed;
} }
@ -269,10 +269,10 @@ cProjectileEntity * cProjectileEntity::Create(eKind a_Kind, cEntity * a_Creator,
case pkWitherSkull: return new cWitherSkullEntity (a_Creator, a_X, a_Y, a_Z, Speed); case pkWitherSkull: return new cWitherSkullEntity (a_Creator, a_X, a_Y, a_Z, Speed);
case pkFirework: case pkFirework:
{ {
ASSERT(a_Item != NULL); ASSERT(a_Item != nullptr);
if (a_Item->m_FireworkItem.m_Colours.empty()) if (a_Item->m_FireworkItem.m_Colours.empty())
{ {
return NULL; return nullptr;
} }
return new cFireworkEntity(a_Creator, a_X, a_Y, a_Z, *a_Item); return new cFireworkEntity(a_Creator, a_X, a_Y, a_Z, *a_Item);
@ -280,7 +280,7 @@ cProjectileEntity * cProjectileEntity::Create(eKind a_Kind, cEntity * a_Creator,
} }
LOGWARNING("%s: Unknown projectile kind: %d", __FUNCTION__, a_Kind); LOGWARNING("%s: Unknown projectile kind: %d", __FUNCTION__, a_Kind);
return NULL; return nullptr;
} }

View File

@ -46,7 +46,7 @@ public:
cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, double a_Width, double a_Height); cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, double a_Width, double a_Height);
cProjectileEntity(eKind a_Kind, cEntity * a_Creator, const Vector3d & a_Pos, const Vector3d & a_Speed, double a_Width, double a_Height); cProjectileEntity(eKind a_Kind, cEntity * a_Creator, const Vector3d & a_Pos, const Vector3d & a_Speed, double a_Width, double a_Height);
static cProjectileEntity * Create(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem * a_Item, const Vector3d * a_Speed = NULL); static cProjectileEntity * Create(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem * a_Item, const Vector3d * a_Speed = nullptr);
/** Called by the physics blocktracer when the entity hits a solid block, the hit position and the face hit (BLOCK_FACE_) is given */ /** Called by the physics blocktracer when the entity hits a solid block, the hit position and the face hit (BLOCK_FACE_) is given */
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace); virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace);
@ -110,7 +110,7 @@ protected:
eKind m_ProjectileKind; eKind m_ProjectileKind;
/** The structure for containing the entity ID and name who has created this projectile /** The structure for containing the entity ID and name who has created this projectile
The ID and/or name may be NULL (e.g. for dispensers/mobs) The ID and/or name may be nullptr (e.g. for dispensers/mobs)
*/ */
CreatorData m_CreatorData; CreatorData m_CreatorData;

View File

@ -43,7 +43,7 @@ cFurnaceRecipe::~cFurnaceRecipe()
{ {
ClearRecipes(); ClearRecipes();
delete m_pState; delete m_pState;
m_pState = NULL; m_pState = nullptr;
} }
@ -247,9 +247,9 @@ void cFurnaceRecipe::ClearRecipes(void)
{ {
cRecipe Recipe = *itr; cRecipe Recipe = *itr;
delete Recipe.In; delete Recipe.In;
Recipe.In = NULL; Recipe.In = nullptr;
delete Recipe.Out; delete Recipe.Out;
Recipe.Out = NULL; Recipe.Out = nullptr;
} }
m_pState->Recipes.clear(); m_pState->Recipes.clear();
@ -257,7 +257,7 @@ void cFurnaceRecipe::ClearRecipes(void)
{ {
cFuel Fuel = *itr; cFuel Fuel = *itr;
delete Fuel.In; delete Fuel.In;
Fuel.In = NULL; Fuel.In = nullptr;
} }
m_pState->Fuel.clear(); m_pState->Fuel.clear();
} }

View File

@ -32,7 +32,7 @@ public:
int CookTime; ///< How long this recipe takes to smelt, in ticks int CookTime; ///< How long this recipe takes to smelt, in ticks
}; };
/** Returns a recipe for the specified input, NULL if no recipe found */ /** Returns a recipe for the specified input, nullptr if no recipe found */
const cRecipe * GetRecipeFrom(const cItem & a_Ingredient) const; const cRecipe * GetRecipeFrom(const cItem & a_Ingredient) const;
/** Returns the amount of time that the specified fuel burns, in ticks */ /** Returns the amount of time that the specified fuel burns, in ticks */

View File

@ -69,9 +69,9 @@ cBioGenCache::cBioGenCache(cBiomeGenPtr a_BioGenToCache, int a_CacheSize) :
cBioGenCache::~cBioGenCache() cBioGenCache::~cBioGenCache()
{ {
delete[] m_CacheData; delete[] m_CacheData;
m_CacheData = NULL; m_CacheData = nullptr;
delete[] m_CacheOrder; delete[] m_CacheOrder;
m_CacheOrder = NULL; m_CacheOrder = nullptr;
} }
@ -928,7 +928,7 @@ cBiomeGenPtr cBiomeGen::CreateBiomeGen(cIniFile & a_IniFile, int a_Seed, bool &
BiomeGenName = "MultiStepMap"; BiomeGenName = "MultiStepMap";
} }
cBiomeGen * res = NULL; cBiomeGen * res = nullptr;
a_CacheOffByDefault = false; a_CacheOffByDefault = false;
if (NoCaseCompare(BiomeGenName, "constant") == 0) if (NoCaseCompare(BiomeGenName, "constant") == 0)
{ {

View File

@ -530,10 +530,10 @@ cBlockEntity * cChunkDesc::GetBlockEntity(int a_RelX, int a_RelY, int a_RelZ)
// The block entity is not created yet, try to create it and add to list: // The block entity is not created yet, try to create it and add to list:
cBlockEntity * be = cBlockEntity::CreateByBlockType(GetBlockType(a_RelX, a_RelY, a_RelZ), GetBlockMeta(a_RelX, a_RelY, a_RelZ), AbsX, a_RelY, AbsZ); cBlockEntity * be = cBlockEntity::CreateByBlockType(GetBlockType(a_RelX, a_RelY, a_RelZ), GetBlockMeta(a_RelX, a_RelY, a_RelZ), AbsX, a_RelY, AbsZ);
if (be == NULL) if (be == nullptr)
{ {
// No block entity for this block type // No block entity for this block type
return NULL; return nullptr;
} }
m_BlockEntities.push_back(be); m_BlockEntities.push_back(be);
return be; return be;

View File

@ -172,7 +172,7 @@ public:
/** Returns the block entity at the specified coords. /** Returns the block entity at the specified coords.
If there is no block entity at those coords, tries to create one, based on the block type If there is no block entity at those coords, tries to create one, based on the block type
If the blocktype doesn't support a block entity, returns NULL. */ If the blocktype doesn't support a block entity, returns nullptr. */
cBlockEntity * GetBlockEntity(int a_RelX, int a_RelY, int a_RelZ); cBlockEntity * GetBlockEntity(int a_RelX, int a_RelY, int a_RelZ);
/** Updates the heightmap to match the current contents. /** Updates the heightmap to match the current contents.

View File

@ -28,9 +28,9 @@ const unsigned int QUEUE_SKIP_LIMIT = 500;
cChunkGenerator::cChunkGenerator(void) : cChunkGenerator::cChunkGenerator(void) :
super("cChunkGenerator"), super("cChunkGenerator"),
m_Seed(0), // Will be overwritten by the actual generator m_Seed(0), // Will be overwritten by the actual generator
m_Generator(NULL), m_Generator(nullptr),
m_PluginInterface(NULL), m_PluginInterface(nullptr),
m_ChunkSink(NULL) m_ChunkSink(nullptr)
{ {
} }
@ -80,7 +80,7 @@ bool cChunkGenerator::Start(cPluginInterface & a_PluginInterface, cChunkSink & a
m_Generator = new cComposableGenerator(*this); m_Generator = new cComposableGenerator(*this);
} }
if (m_Generator == NULL) if (m_Generator == nullptr)
{ {
LOGERROR("Generator could not start, aborting the server"); LOGERROR("Generator could not start, aborting the server");
return false; return false;
@ -103,7 +103,7 @@ void cChunkGenerator::Stop(void)
Wait(); Wait();
delete m_Generator; delete m_Generator;
m_Generator = NULL; m_Generator = nullptr;
} }
@ -144,7 +144,7 @@ void cChunkGenerator::QueueGenerateChunk(int a_ChunkX, int a_ChunkZ, bool a_Forc
void cChunkGenerator::GenerateBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) void cChunkGenerator::GenerateBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap)
{ {
if (m_Generator != NULL) if (m_Generator != nullptr)
{ {
m_Generator->GenerateBiomes(a_ChunkX, a_ChunkZ, a_BiomeMap); m_Generator->GenerateBiomes(a_ChunkX, a_ChunkZ, a_BiomeMap);
} }
@ -180,7 +180,7 @@ int cChunkGenerator::GetQueueLength(void)
EMCSBiome cChunkGenerator::GetBiomeAt(int a_BlockX, int a_BlockZ) EMCSBiome cChunkGenerator::GetBiomeAt(int a_BlockX, int a_BlockZ)
{ {
ASSERT(m_Generator != NULL); ASSERT(m_Generator != nullptr);
return m_Generator->GetBiomeAt(a_BlockX, a_BlockZ); return m_Generator->GetBiomeAt(a_BlockX, a_BlockZ);
} }
@ -283,8 +283,8 @@ void cChunkGenerator::Execute(void)
void cChunkGenerator::DoGenerate(int a_ChunkX, int a_ChunkZ) void cChunkGenerator::DoGenerate(int a_ChunkX, int a_ChunkZ)
{ {
ASSERT(m_PluginInterface != NULL); ASSERT(m_PluginInterface != nullptr);
ASSERT(m_ChunkSink != NULL); ASSERT(m_ChunkSink != nullptr);
ASSERT(m_ChunkSink->IsChunkQueued(a_ChunkX, a_ChunkZ)); ASSERT(m_ChunkSink->IsChunkQueued(a_ChunkX, a_ChunkZ));
cChunkDesc ChunkDesc(a_ChunkX, a_ChunkZ); cChunkDesc ChunkDesc(a_ChunkX, a_ChunkZ);

View File

@ -687,9 +687,9 @@ cCompoGenCache::cCompoGenCache(cTerrainCompositionGenPtr a_Underlying, int a_Cac
cCompoGenCache::~cCompoGenCache() cCompoGenCache::~cCompoGenCache()
{ {
delete[] m_CacheData; delete[] m_CacheData;
m_CacheData = NULL; m_CacheData = nullptr;
delete[] m_CacheOrder; delete[] m_CacheOrder;
m_CacheOrder = NULL; m_CacheOrder = nullptr;
} }

View File

@ -48,7 +48,7 @@ cTerrainCompositionGenPtr cTerrainCompositionGen::CreateCompositionGen(cIniFile
CompoGenName = "Biomal"; CompoGenName = "Biomal";
} }
cTerrainCompositionGen * res = NULL; cTerrainCompositionGen * res = nullptr;
if (NoCaseCompare(CompoGenName, "sameblock") == 0) if (NoCaseCompare(CompoGenName, "sameblock") == 0)
{ {
res = new cCompoGenSameBlock; res = new cCompoGenSameBlock;
@ -102,7 +102,7 @@ cTerrainCompositionGenPtr cTerrainCompositionGen::CreateCompositionGen(cIniFile
a_IniFile.SetValue("Generator", "CompositionGen", "Biomal"); a_IniFile.SetValue("Generator", "CompositionGen", "Biomal");
return CreateCompositionGen(a_IniFile, a_BiomeGen, a_HeightGen, a_Seed); return CreateCompositionGen(a_IniFile, a_BiomeGen, a_HeightGen, a_Seed);
} }
ASSERT(res != NULL); ASSERT(res != nullptr);
// Read the settings from the ini file: // Read the settings from the ini file:
res->InitializeCompoGen(a_IniFile); res->InitializeCompoGen(a_IniFile);
@ -145,7 +145,7 @@ void cComposableGenerator::Initialize(cIniFile & a_IniFile)
void cComposableGenerator::GenerateBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) void cComposableGenerator::GenerateBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap)
{ {
if (m_BiomeGen != NULL) // Quick fix for generator deinitializing before the world storage finishes loading if (m_BiomeGen != nullptr) // Quick fix for generator deinitializing before the world storage finishes loading
{ {
m_BiomeGen->GenBiomes(a_ChunkX, a_ChunkZ, a_BiomeMap); m_BiomeGen->GenBiomes(a_ChunkX, a_ChunkZ, a_BiomeMap);
} }

View File

@ -198,7 +198,7 @@ protected:
} ; } ;
cChestEntity * ChestEntity = (cChestEntity *)a_ChunkDesc.GetBlockEntity(RelX, m_FloorHeight + 1, RelZ); cChestEntity * ChestEntity = (cChestEntity *)a_ChunkDesc.GetBlockEntity(RelX, m_FloorHeight + 1, RelZ);
ASSERT((ChestEntity != NULL) && (ChestEntity->GetBlockType() == E_BLOCK_CHEST)); ASSERT((ChestEntity != nullptr) && (ChestEntity->GetBlockType() == E_BLOCK_CHEST));
cNoise Noise(a_ChunkDesc.GetChunkX() ^ a_ChunkDesc.GetChunkZ()); cNoise Noise(a_ChunkDesc.GetChunkX() ^ a_ChunkDesc.GetChunkZ());
int NumSlots = 3 + ((Noise.IntNoise3DInt(a_Chest.x, a_Chest.y, a_Chest.z) / 11) % 4); int NumSlots = 3 + ((Noise.IntNoise3DInt(a_Chest.x, a_Chest.y, a_Chest.z) / 11) % 4);
int Seed = Noise.IntNoise2DInt(RelX, RelZ); int Seed = Noise.IntNoise2DInt(RelX, RelZ);

View File

@ -135,7 +135,7 @@ void cGridStructGen::GetStructuresForChunk(int a_ChunkX, int a_ChunkZ, cStructur
int OriginX = GridX + ((m_Noise.IntNoise2DInt(GridX + 3, GridZ + 5) / 7) % (m_MaxOffsetX * 2)) - m_MaxOffsetX; int OriginX = GridX + ((m_Noise.IntNoise2DInt(GridX + 3, GridZ + 5) / 7) % (m_MaxOffsetX * 2)) - m_MaxOffsetX;
int OriginZ = GridZ + ((m_Noise.IntNoise2DInt(GridX + 5, GridZ + 3) / 7) % (m_MaxOffsetZ * 2)) - m_MaxOffsetZ; int OriginZ = GridZ + ((m_Noise.IntNoise2DInt(GridX + 5, GridZ + 3) / 7) % (m_MaxOffsetZ * 2)) - m_MaxOffsetZ;
cStructurePtr Structure = CreateStructure(GridX, GridZ, OriginX, OriginZ); cStructurePtr Structure = CreateStructure(GridX, GridZ, OriginX, OriginZ);
if (Structure.get() == NULL) if (Structure.get() == nullptr)
{ {
Structure.reset(new cEmptyStructure(GridX, GridZ, OriginX, OriginZ)); Structure.reset(new cEmptyStructure(GridX, GridZ, OriginX, OriginZ));
} }

View File

@ -29,7 +29,7 @@ cTerrainHeightGenPtr cTerrainHeightGen::CreateHeightGen(cIniFile & a_IniFile, cB
} }
a_CacheOffByDefault = false; a_CacheOffByDefault = false;
cTerrainHeightGen * res = NULL; cTerrainHeightGen * res = nullptr;
if (NoCaseCompare(HeightGenName, "flat") == 0) if (NoCaseCompare(HeightGenName, "flat") == 0)
{ {
res = new cHeiGenFlat; res = new cHeiGenFlat;
@ -142,9 +142,9 @@ cHeiGenCache::cHeiGenCache(cTerrainHeightGenPtr a_HeiGenToCache, int a_CacheSize
cHeiGenCache::~cHeiGenCache() cHeiGenCache::~cHeiGenCache()
{ {
delete[] m_CacheData; delete[] m_CacheData;
m_CacheData = NULL; m_CacheData = nullptr;
delete[] m_CacheOrder; delete[] m_CacheOrder;
m_CacheOrder = NULL; m_CacheOrder = nullptr;
} }

View File

@ -112,7 +112,7 @@ class cMineShaftCorridor :
public: public:
/** Creates a new Corridor attached to the specified pivot point and direction. /** Creates a new Corridor attached to the specified pivot point and direction.
Checks all ParentSystem's objects and disallows intersecting. Initializes the new object to fit. Checks all ParentSystem's objects and disallows intersecting. Initializes the new object to fit.
May return NULL if cannot fit. May return nullptr if cannot fit.
*/ */
static cMineShaft * CreateAndFit( static cMineShaft * CreateAndFit(
cStructGenMineShafts::cMineShaftSystem & a_ParentSystem, cStructGenMineShafts::cMineShaftSystem & a_ParentSystem,
@ -165,7 +165,7 @@ class cMineShaftCrossing :
public: public:
/** Creates a new Crossing attached to the specified pivot point and direction. /** Creates a new Crossing attached to the specified pivot point and direction.
Checks all ParentSystem's objects and disallows intersecting. Initializes the new object to fit. Checks all ParentSystem's objects and disallows intersecting. Initializes the new object to fit.
May return NULL if cannot fit. May return nullptr if cannot fit.
*/ */
static cMineShaft * CreateAndFit( static cMineShaft * CreateAndFit(
cStructGenMineShafts::cMineShaftSystem & a_ParentSystem, cStructGenMineShafts::cMineShaftSystem & a_ParentSystem,
@ -199,7 +199,7 @@ public:
/** Creates a new Staircase attached to the specified pivot point and direction. /** Creates a new Staircase attached to the specified pivot point and direction.
Checks all ParentSystem's objects and disallows intersecting. Initializes the new object to fit. Checks all ParentSystem's objects and disallows intersecting. Initializes the new object to fit.
May return NULL if cannot fit. May return nullptr if cannot fit.
*/ */
static cMineShaft * CreateAndFit( static cMineShaft * CreateAndFit(
cStructGenMineShafts::cMineShaftSystem & a_ParentSystem, cStructGenMineShafts::cMineShaftSystem & a_ParentSystem,
@ -351,7 +351,7 @@ void cStructGenMineShafts::cMineShaftSystem::AppendBranch(
return; return;
} }
cMineShaft * Next = NULL; cMineShaft * Next = nullptr;
int rnd = (a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + a_RecursionLevel * 16, a_PivotZ) / 13) % m_ProbLevelStaircase; int rnd = (a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + a_RecursionLevel * 16, a_PivotZ) / 13) % m_ProbLevelStaircase;
if (rnd < m_ProbLevelCorridor) if (rnd < m_ProbLevelCorridor)
{ {
@ -365,7 +365,7 @@ void cStructGenMineShafts::cMineShaftSystem::AppendBranch(
{ {
Next = cMineShaftStaircase::CreateAndFit(*this, a_PivotX, a_PivotY, a_PivotZ, a_Direction, a_Noise); Next = cMineShaftStaircase::CreateAndFit(*this, a_PivotX, a_PivotY, a_PivotZ, a_Direction, a_Noise);
} }
if (Next == NULL) if (Next == nullptr)
{ {
return; return;
} }
@ -552,7 +552,7 @@ cMineShaft * cMineShaftCorridor::CreateAndFit(
} }
if (!a_ParentSystem.CanAppend(BoundingBox)) if (!a_ParentSystem.CanAppend(BoundingBox))
{ {
return NULL; return nullptr;
} }
return new cMineShaftCorridor(a_ParentSystem, BoundingBox, NumSegments, a_Direction, a_Noise); return new cMineShaftCorridor(a_ParentSystem, BoundingBox, NumSegments, a_Direction, a_Noise);
} }
@ -796,7 +796,7 @@ void cMineShaftCorridor::PlaceChest(cChunkDesc & a_ChunkDesc)
{ {
a_ChunkDesc.SetBlockTypeMeta(x, m_BoundingBox.p1.y + 1, z, E_BLOCK_CHEST, Meta); a_ChunkDesc.SetBlockTypeMeta(x, m_BoundingBox.p1.y + 1, z, E_BLOCK_CHEST, Meta);
cChestEntity * ChestEntity = (cChestEntity *)a_ChunkDesc.GetBlockEntity(x, m_BoundingBox.p1.y + 1, z); cChestEntity * ChestEntity = (cChestEntity *)a_ChunkDesc.GetBlockEntity(x, m_BoundingBox.p1.y + 1, z);
ASSERT((ChestEntity != NULL) && (ChestEntity->GetBlockType() == E_BLOCK_CHEST)); ASSERT((ChestEntity != nullptr) && (ChestEntity->GetBlockType() == E_BLOCK_CHEST));
cNoise Noise(a_ChunkDesc.GetChunkX() ^ a_ChunkDesc.GetChunkZ()); cNoise Noise(a_ChunkDesc.GetChunkX() ^ a_ChunkDesc.GetChunkZ());
int NumSlots = 3 + ((Noise.IntNoise3DInt(x, m_BoundingBox.p1.y, z) / 11) % 4); int NumSlots = 3 + ((Noise.IntNoise3DInt(x, m_BoundingBox.p1.y, z) / 11) % 4);
int Seed = Noise.IntNoise2DInt(x, z); int Seed = Noise.IntNoise2DInt(x, z);
@ -1006,7 +1006,7 @@ cMineShaft * cMineShaftCrossing::CreateAndFit(
} }
if (!a_ParentSystem.CanAppend(BoundingBox)) if (!a_ParentSystem.CanAppend(BoundingBox))
{ {
return NULL; return nullptr;
} }
return new cMineShaftCrossing(a_ParentSystem, BoundingBox); return new cMineShaftCrossing(a_ParentSystem, BoundingBox);
} }
@ -1157,7 +1157,7 @@ cMineShaft * cMineShaftStaircase::CreateAndFit(
} }
if (!a_ParentSystem.CanAppend(Box)) if (!a_ParentSystem.CanAppend(Box))
{ {
return NULL; return nullptr;
} }
return new cMineShaftStaircase(a_ParentSystem, Box, a_Direction, Slope); return new cMineShaftStaircase(a_ParentSystem, Box, a_Direction, Slope);
} }

View File

@ -289,7 +289,7 @@ cPlacedPiece::cPlacedPiece(const cPlacedPiece * a_Parent, const cPiece & a_Piece
m_NumCCWRotations(a_NumCCWRotations), m_NumCCWRotations(a_NumCCWRotations),
m_HasBeenMovedToGround(false) m_HasBeenMovedToGround(false)
{ {
m_Depth = (m_Parent == NULL) ? 0 : (m_Parent->GetDepth() + 1); m_Depth = (m_Parent == nullptr) ? 0 : (m_Parent->GetDepth() + 1);
m_HitBox = a_Piece.RotateMoveHitBox(a_NumCCWRotations, a_Coords.x, a_Coords.y, a_Coords.z); m_HitBox = a_Piece.RotateMoveHitBox(a_NumCCWRotations, a_Coords.x, a_Coords.y, a_Coords.z);
m_HitBox.Sort(); m_HitBox.Sort();
} }
@ -402,7 +402,7 @@ cPlacedPiece * cPieceGenerator::PlaceStartingPiece(int a_BlockX, int a_BlockY, i
} }
int Rotation = Rotations[rnd % NumRotations]; int Rotation = Rotations[rnd % NumRotations];
cPlacedPiece * res = new cPlacedPiece(NULL, *StartingPiece, Vector3i(a_BlockX, a_BlockY, a_BlockZ), Rotation); cPlacedPiece * res = new cPlacedPiece(nullptr, *StartingPiece, Vector3i(a_BlockX, a_BlockY, a_BlockZ), Rotation);
// Place the piece's connectors into a_OutConnectors: // Place the piece's connectors into a_OutConnectors:
const cPiece::cConnectors & Conn = StartingPiece->GetConnectors(); const cPiece::cConnectors & Conn = StartingPiece->GetConnectors();

View File

@ -328,7 +328,7 @@ void cPrefab::AddConnector(int a_RelX, int a_RelY, int a_RelZ, eBlockFace a_Dire
void cPrefab::ParseCharMap(CharMap & a_CharMapOut, const char * a_CharMapDef) void cPrefab::ParseCharMap(CharMap & a_CharMapOut, const char * a_CharMapDef)
{ {
ASSERT(a_CharMapDef != NULL); ASSERT(a_CharMapDef != nullptr);
// Initialize the charmap to all-invalid values: // Initialize the charmap to all-invalid values:
for (size_t i = 0; i < ARRAYCOUNT(a_CharMapOut); i++) for (size_t i = 0; i < ARRAYCOUNT(a_CharMapOut); i++)
@ -389,7 +389,7 @@ void cPrefab::ParseBlockImage(const CharMap & a_CharMap, const char * a_BlockIma
void cPrefab::ParseConnectors(const char * a_ConnectorsDef) void cPrefab::ParseConnectors(const char * a_ConnectorsDef)
{ {
ASSERT(a_ConnectorsDef != NULL); ASSERT(a_ConnectorsDef != nullptr);
AStringVector Lines = StringSplitAndTrim(a_ConnectorsDef, "\n"); AStringVector Lines = StringSplitAndTrim(a_ConnectorsDef, "\n");
for (AStringVector::const_iterator itr = Lines.begin(), end = Lines.end(); itr != end; ++itr) for (AStringVector::const_iterator itr = Lines.begin(), end = Lines.end(); itr != end; ++itr)
@ -436,7 +436,7 @@ void cPrefab::ParseConnectors(const char * a_ConnectorsDef)
void cPrefab::ParseDepthWeight(const char * a_DepthWeightDef) void cPrefab::ParseDepthWeight(const char * a_DepthWeightDef)
{ {
// The member needn't be defined at all, if so, skip: // The member needn't be defined at all, if so, skip:
if (a_DepthWeightDef == NULL) if (a_DepthWeightDef == nullptr)
{ {
return; return;
} }

View File

@ -16,7 +16,7 @@ cPrefabPiecePool::cPrefabPiecePool(
) )
{ {
AddPieceDefs(a_PieceDefs, a_NumPieceDefs); AddPieceDefs(a_PieceDefs, a_NumPieceDefs);
if (a_StartingPieceDefs != NULL) if (a_StartingPieceDefs != nullptr)
{ {
AddStartingPieceDefs(a_StartingPieceDefs, a_NumStartingPieceDefs); AddStartingPieceDefs(a_StartingPieceDefs, a_NumStartingPieceDefs);
} }
@ -56,7 +56,7 @@ void cPrefabPiecePool::Clear(void)
void cPrefabPiecePool::AddPieceDefs(const cPrefab::sDef * a_PieceDefs, size_t a_NumPieceDefs) void cPrefabPiecePool::AddPieceDefs(const cPrefab::sDef * a_PieceDefs, size_t a_NumPieceDefs)
{ {
ASSERT(a_PieceDefs != NULL); ASSERT(a_PieceDefs != nullptr);
for (size_t i = 0; i < a_NumPieceDefs; i++) for (size_t i = 0; i < a_NumPieceDefs; i++)
{ {
cPrefab * Prefab = new cPrefab(a_PieceDefs[i]); cPrefab * Prefab = new cPrefab(a_PieceDefs[i]);
@ -71,7 +71,7 @@ void cPrefabPiecePool::AddPieceDefs(const cPrefab::sDef * a_PieceDefs, size_t a_
void cPrefabPiecePool::AddStartingPieceDefs(const cPrefab::sDef * a_StartingPieceDefs, size_t a_NumStartingPieceDefs) void cPrefabPiecePool::AddStartingPieceDefs(const cPrefab::sDef * a_StartingPieceDefs, size_t a_NumStartingPieceDefs)
{ {
ASSERT(a_StartingPieceDefs != NULL); ASSERT(a_StartingPieceDefs != nullptr);
for (size_t i = 0; i < a_NumStartingPieceDefs; i++) for (size_t i = 0; i < a_NumStartingPieceDefs; i++)
{ {
cPrefab * Prefab = new cPrefab(a_StartingPieceDefs[i]); cPrefab * Prefab = new cPrefab(a_StartingPieceDefs[i]);

View File

@ -385,7 +385,7 @@ cGridStructGen::cStructurePtr cVillageGen::CreateStructure(int a_GridX, int a_Gr
// Check if all the biomes are village-friendly: // Check if all the biomes are village-friendly:
// If just one is not, no village is created, because it's likely that an unfriendly biome is too close // If just one is not, no village is created, because it's likely that an unfriendly biome is too close
cVillagePiecePool * VillagePrefabs = NULL; cVillagePiecePool * VillagePrefabs = nullptr;
BLOCKTYPE RoadBlock = E_BLOCK_GRAVEL; BLOCKTYPE RoadBlock = E_BLOCK_GRAVEL;
BLOCKTYPE WaterRoadBlock = E_BLOCK_PLANKS; BLOCKTYPE WaterRoadBlock = E_BLOCK_PLANKS;
int rnd = m_Noise.IntNoise2DInt(a_OriginX, a_OriginZ) / 11; int rnd = m_Noise.IntNoise2DInt(a_OriginX, a_OriginZ) / 11;
@ -432,7 +432,7 @@ cGridStructGen::cStructurePtr cVillageGen::CreateStructure(int a_GridX, int a_Gr
} }
// Create a village based on the chosen prefabs: // Create a village based on the chosen prefabs:
if (VillagePrefabs == NULL) if (VillagePrefabs == nullptr)
{ {
return cStructurePtr(); return cStructurePtr();
} }

View File

@ -15,7 +15,7 @@
cHTTPConnection::cHTTPConnection(cHTTPServer & a_HTTPServer) : cHTTPConnection::cHTTPConnection(cHTTPServer & a_HTTPServer) :
m_HTTPServer(a_HTTPServer), m_HTTPServer(a_HTTPServer),
m_State(wcsRecvHeaders), m_State(wcsRecvHeaders),
m_CurrentRequest(NULL), m_CurrentRequest(nullptr),
m_CurrentRequestBodyRemaining(0) m_CurrentRequestBodyRemaining(0)
{ {
// LOGD("HTTP: New connection at %p", this); // LOGD("HTTP: New connection at %p", this);
@ -29,7 +29,7 @@ cHTTPConnection::~cHTTPConnection()
{ {
// LOGD("HTTP: Connection deleting: %p", this); // LOGD("HTTP: Connection deleting: %p", this);
delete m_CurrentRequest; delete m_CurrentRequest;
m_CurrentRequest = NULL; m_CurrentRequest = nullptr;
} }
@ -136,7 +136,7 @@ void cHTTPConnection::AwaitNextRequest(void)
void cHTTPConnection::Terminate(void) void cHTTPConnection::Terminate(void)
{ {
if (m_CurrentRequest != NULL) if (m_CurrentRequest != nullptr)
{ {
m_HTTPServer.RequestFinished(*this, *m_CurrentRequest); m_HTTPServer.RequestFinished(*this, *m_CurrentRequest);
} }
@ -153,7 +153,7 @@ bool cHTTPConnection::DataReceived(const char * a_Data, size_t a_Size)
{ {
case wcsRecvHeaders: case wcsRecvHeaders:
{ {
if (m_CurrentRequest == NULL) if (m_CurrentRequest == nullptr)
{ {
m_CurrentRequest = new cHTTPRequest; m_CurrentRequest = new cHTTPRequest;
} }
@ -162,7 +162,7 @@ bool cHTTPConnection::DataReceived(const char * a_Data, size_t a_Size)
if (BytesConsumed == AString::npos) if (BytesConsumed == AString::npos)
{ {
delete m_CurrentRequest; delete m_CurrentRequest;
m_CurrentRequest = NULL; m_CurrentRequest = nullptr;
m_State = wcsInvalid; m_State = wcsInvalid;
m_HTTPServer.CloseConnection(*this); m_HTTPServer.CloseConnection(*this);
return true; return true;
@ -196,7 +196,7 @@ bool cHTTPConnection::DataReceived(const char * a_Data, size_t a_Size)
case wcsRecvBody: case wcsRecvBody:
{ {
ASSERT(m_CurrentRequest != NULL); ASSERT(m_CurrentRequest != nullptr);
if (m_CurrentRequestBodyRemaining > 0) if (m_CurrentRequestBodyRemaining > 0)
{ {
size_t BytesToConsume = std::min(m_CurrentRequestBodyRemaining, (size_t)a_Size); size_t BytesToConsume = std::min(m_CurrentRequestBodyRemaining, (size_t)a_Size);
@ -214,7 +214,7 @@ bool cHTTPConnection::DataReceived(const char * a_Data, size_t a_Size)
return true; return true;
} }
delete m_CurrentRequest; delete m_CurrentRequest;
m_CurrentRequest = NULL; m_CurrentRequest = nullptr;
} }
break; break;
} }
@ -243,7 +243,7 @@ void cHTTPConnection::GetOutgoingData(AString & a_Data)
void cHTTPConnection::SocketClosed(void) void cHTTPConnection::SocketClosed(void)
{ {
if (m_CurrentRequest != NULL) if (m_CurrentRequest != nullptr)
{ {
m_HTTPServer.RequestFinished(*this, *m_CurrentRequest); m_HTTPServer.RequestFinished(*this, *m_CurrentRequest);
} }

View File

@ -31,10 +31,10 @@ public:
enum eState enum eState
{ {
wcsRecvHeaders, ///< Receiving request headers (m_CurrentRequest is created if NULL) wcsRecvHeaders, ///< Receiving request headers (m_CurrentRequest is created if nullptr)
wcsRecvBody, ///< Receiving request body (m_CurrentRequest is valid) wcsRecvBody, ///< Receiving request body (m_CurrentRequest is valid)
wcsRecvIdle, ///< Has received the entire body, waiting to send the response (m_CurrentRequest == NULL) wcsRecvIdle, ///< Has received the entire body, waiting to send the response (m_CurrentRequest == nullptr)
wcsSendingResp, ///< Sending response body (m_CurrentRequest == NULL) wcsSendingResp, ///< Sending response body (m_CurrentRequest == nullptr)
wcsInvalid, ///< The request was malformed, the connection is closing wcsInvalid, ///< The request was malformed, the connection is closing
} ; } ;

View File

@ -86,7 +86,7 @@ void cHTTPFormParser::Parse(const char * a_Data, size_t a_Size)
} }
case fpkMultipart: case fpkMultipart:
{ {
ASSERT(m_MultipartParser.get() != NULL); ASSERT(m_MultipartParser.get() != nullptr);
m_MultipartParser->Parse(a_Data, a_Size); m_MultipartParser->Parse(a_Data, a_Size);
break; break;
} }
@ -145,7 +145,7 @@ bool cHTTPFormParser::HasFormData(const cHTTPRequest & a_Request)
void cHTTPFormParser::BeginMultipart(const cHTTPRequest & a_Request) void cHTTPFormParser::BeginMultipart(const cHTTPRequest & a_Request)
{ {
ASSERT(m_MultipartParser.get() == NULL); ASSERT(m_MultipartParser.get() == nullptr);
m_MultipartParser.reset(new cMultipartParser(a_Request.GetContentType(), *this)); m_MultipartParser.reset(new cMultipartParser(a_Request.GetContentType(), *this));
} }

View File

@ -70,7 +70,7 @@ cHTTPRequest::cHTTPRequest(void) :
super(mkRequest), super(mkRequest),
m_EnvelopeParser(*this), m_EnvelopeParser(*this),
m_IsValid(true), m_IsValid(true),
m_UserData(NULL), m_UserData(nullptr),
m_HasAuth(false), m_HasAuth(false),
m_AllowKeepAlive(false) m_AllowKeepAlive(false)
{ {

View File

@ -44,7 +44,7 @@ class cDebugCallbacks :
UNUSED(a_Connection); UNUSED(a_Connection);
cHTTPFormParser * FormParser = (cHTTPFormParser *)(a_Request.GetUserData()); cHTTPFormParser * FormParser = (cHTTPFormParser *)(a_Request.GetUserData());
if (FormParser != NULL) if (FormParser != nullptr)
{ {
FormParser->Parse(a_Data, a_Size); FormParser->Parse(a_Data, a_Size);
} }
@ -54,7 +54,7 @@ class cDebugCallbacks :
virtual void OnRequestFinished(cHTTPConnection & a_Connection, cHTTPRequest & a_Request) override virtual void OnRequestFinished(cHTTPConnection & a_Connection, cHTTPRequest & a_Request) override
{ {
cHTTPFormParser * FormParser = (cHTTPFormParser *)(a_Request.GetUserData()); cHTTPFormParser * FormParser = (cHTTPFormParser *)(a_Request.GetUserData());
if (FormParser != NULL) if (FormParser != nullptr)
{ {
if (FormParser->Finish()) if (FormParser->Finish())
{ {
@ -124,7 +124,7 @@ class cDebugCallbacks :
cHTTPServer::cHTTPServer(void) : cHTTPServer::cHTTPServer(void) :
m_ListenThreadIPv4(*this, cSocket::IPv4, "WebServer"), m_ListenThreadIPv4(*this, cSocket::IPv4, "WebServer"),
m_ListenThreadIPv6(*this, cSocket::IPv6, "WebServer"), m_ListenThreadIPv6(*this, cSocket::IPv6, "WebServer"),
m_Callbacks(NULL) m_Callbacks(nullptr)
{ {
} }
@ -168,7 +168,7 @@ bool cHTTPServer::Initialize(const AString & a_PortsIPv4, const AString & a_Port
} }
// Notify the admin about the HTTPS / HTTP status // Notify the admin about the HTTPS / HTTP status
if (m_Cert.get() == NULL) if (m_Cert.get() == nullptr)
{ {
LOGWARNING("WebServer: The server is running in unsecured HTTP mode."); LOGWARNING("WebServer: The server is running in unsecured HTTP mode.");
LOGINFO("Put a valid HTTPS certificate in file 'webadmin/httpscert.crt' and its corresponding private key to 'webadmin/httpskey.pem' (without any password) to enable HTTPS support"); LOGINFO("Put a valid HTTPS certificate in file 'webadmin/httpscert.crt' and its corresponding private key to 'webadmin/httpskey.pem' (without any password) to enable HTTPS support");
@ -235,7 +235,7 @@ void cHTTPServer::Stop(void)
void cHTTPServer::OnConnectionAccepted(cSocket & a_Socket) void cHTTPServer::OnConnectionAccepted(cSocket & a_Socket)
{ {
cHTTPConnection * Connection; cHTTPConnection * Connection;
if (m_Cert.get() != NULL) if (m_Cert.get() != nullptr)
{ {
Connection = new cSslHTTPConnection(*this, m_Cert, m_CertPrivKey); Connection = new cSslHTTPConnection(*this, m_Cert, m_CertPrivKey);
} }

View File

@ -220,7 +220,7 @@ void cInventory::SetSlot(int a_SlotNum, const cItem & a_Item)
int GridSlotNum = 0; int GridSlotNum = 0;
cItemGrid * Grid = GetGridForSlotNum(a_SlotNum, GridSlotNum); cItemGrid * Grid = GetGridForSlotNum(a_SlotNum, GridSlotNum);
if (Grid == NULL) if (Grid == nullptr)
{ {
LOGWARNING("%s(%d): requesting an invalid itemgrid. Ignoring.", __FUNCTION__, a_SlotNum); LOGWARNING("%s(%d): requesting an invalid itemgrid. Ignoring.", __FUNCTION__, a_SlotNum);
return; return;
@ -278,7 +278,7 @@ const cItem & cInventory::GetSlot(int a_SlotNum) const
} }
int GridSlotNum = 0; int GridSlotNum = 0;
const cItemGrid * Grid = GetGridForSlotNum(a_SlotNum, GridSlotNum); const cItemGrid * Grid = GetGridForSlotNum(a_SlotNum, GridSlotNum);
if (Grid == NULL) if (Grid == nullptr)
{ {
// Something went wrong, but we don't know what. We must return a value, so return the first inventory slot // Something went wrong, but we don't know what. We must return a value, so return the first inventory slot
LOGWARNING("%s(%d): requesting an invalid ItemGrid, returning the first inventory slot instead.", __FUNCTION__, a_SlotNum); LOGWARNING("%s(%d): requesting an invalid ItemGrid, returning the first inventory slot instead.", __FUNCTION__, a_SlotNum);
@ -372,7 +372,7 @@ int cInventory::ChangeSlotCount(int a_SlotNum, int a_AddToCount)
{ {
int GridSlotNum = 0; int GridSlotNum = 0;
cItemGrid * Grid = GetGridForSlotNum(a_SlotNum, GridSlotNum); cItemGrid * Grid = GetGridForSlotNum(a_SlotNum, GridSlotNum);
if (Grid == NULL) if (Grid == nullptr)
{ {
LOGWARNING("%s: invalid slot number, expected 0 .. %d, got %d; ignoring", __FUNCTION__, invNumSlots, a_SlotNum); LOGWARNING("%s: invalid slot number, expected 0 .. %d, got %d; ignoring", __FUNCTION__, invNumSlots, a_SlotNum);
return -1; return -1;
@ -398,7 +398,7 @@ bool cInventory::DamageItem(int a_SlotNum, short a_Amount)
int GridSlotNum = 0; int GridSlotNum = 0;
cItemGrid * Grid = GetGridForSlotNum(a_SlotNum, GridSlotNum); cItemGrid * Grid = GetGridForSlotNum(a_SlotNum, GridSlotNum);
if (Grid == NULL) if (Grid == nullptr)
{ {
LOGWARNING("%s(%d, %d): requesting an invalid grid, ignoring.", __FUNCTION__, a_SlotNum, a_Amount); LOGWARNING("%s(%d, %d): requesting an invalid grid, ignoring.", __FUNCTION__, a_SlotNum, a_Amount);
return false; return false;
@ -640,7 +640,7 @@ bool cInventory::LoadFromJson(Json::Value & a_Value)
int GridSlotNum = 0; int GridSlotNum = 0;
cItemGrid * Grid = GetGridForSlotNum(SlotIdx - 5, GridSlotNum); cItemGrid * Grid = GetGridForSlotNum(SlotIdx - 5, GridSlotNum);
ASSERT(Grid != NULL); ASSERT(Grid != nullptr);
Grid->SetSlot(GridSlotNum, Item); Grid->SetSlot(GridSlotNum, Item);
} // for itr - a_Value[] } // for itr - a_Value[]
return true; return true;
@ -708,7 +708,7 @@ void cInventory::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
// Armor update needs broadcast to other players: // Armor update needs broadcast to other players:
cWorld * World = m_Owner.GetWorld(); cWorld * World = m_Owner.GetWorld();
if ((a_ItemGrid == &m_ArmorSlots) && (World != NULL)) if ((a_ItemGrid == &m_ArmorSlots) && (World != nullptr))
{ {
World->BroadcastEntityEquipment( World->BroadcastEntityEquipment(
m_Owner, ArmorSlotNumToEntityEquipmentID(a_SlotNum), m_Owner, ArmorSlotNumToEntityEquipmentID(a_SlotNum),

View File

@ -179,10 +179,10 @@ protected:
cPlayer & m_Owner; cPlayer & m_Owner;
/** Returns the ItemGrid and the (grid-local) slot number for a (global) slot number; return NULL for invalid SlotNum */ /** Returns the ItemGrid and the (grid-local) slot number for a (global) slot number; return nullptr for invalid SlotNum */
const cItemGrid * GetGridForSlotNum(int a_SlotNum, int & a_GridSlotNum) const; const cItemGrid * GetGridForSlotNum(int a_SlotNum, int & a_GridSlotNum) const;
/** Returns the ItemGrid and the (grid-local) slot number for a (global) slot number; return NULL for invalid SlotNum */ /** Returns the ItemGrid and the (grid-local) slot number for a (global) slot number; return nullptr for invalid SlotNum */
cItemGrid * GetGridForSlotNum(int a_SlotNum, int & a_GridSlotNum); cItemGrid * GetGridForSlotNum(int a_SlotNum, int & a_GridSlotNum);
// cItemGrid::cListener override: // cItemGrid::cListener override:

View File

@ -391,7 +391,7 @@ cItem * cItems::Get(int a_Idx)
if ((a_Idx < 0) || (a_Idx >= (int)size())) if ((a_Idx < 0) || (a_Idx >= (int)size()))
{ {
LOGWARNING("cItems: Attempt to get an out-of-bounds item at index %d; there are currently " SIZE_T_FMT " items. Returning a nil.", a_Idx, size()); LOGWARNING("cItems: Attempt to get an out-of-bounds item at index %d; there are currently " SIZE_T_FMT " items. Returning a nil.", a_Idx, size());
return NULL; return nullptr;
} }
return &at(a_Idx); return &at(a_Idx);
} }

View File

@ -28,7 +28,7 @@ cItemGrid::cItemGrid(int a_Width, int a_Height) :
cItemGrid::~cItemGrid() cItemGrid::~cItemGrid()
{ {
delete[] m_Slots; delete[] m_Slots;
m_Slots = NULL; m_Slots = nullptr;
} }

View File

@ -29,7 +29,7 @@ public:
virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override
{ {
ASSERT(a_Player != NULL); ASSERT(a_Player != nullptr);
// Check if the player has an arrow in the inventory, or is in Creative: // Check if the player has an arrow in the inventory, or is in Creative:
if (!(a_Player->IsGameModeCreative() || a_Player->GetInventory().HasItems(cItem(E_ITEM_ARROW)))) if (!(a_Player->IsGameModeCreative() || a_Player->GetInventory().HasItems(cItem(E_ITEM_ARROW))))
@ -45,7 +45,7 @@ public:
virtual void OnItemShoot(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override virtual void OnItemShoot(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override
{ {
// Actual shot - produce the arrow with speed based on the ticks that the bow was charged // Actual shot - produce the arrow with speed based on the ticks that the bow was charged
ASSERT(a_Player != NULL); ASSERT(a_Player != nullptr);
int BowCharge = a_Player->FinishChargingBow(); int BowCharge = a_Player->FinishChargingBow();
double Force = (double)BowCharge / 20.0; double Force = (double)BowCharge / 20.0;
@ -65,14 +65,14 @@ public:
// Create the arrow entity: // Create the arrow entity:
cArrowEntity * Arrow = new cArrowEntity(*a_Player, Force * 2); cArrowEntity * Arrow = new cArrowEntity(*a_Player, Force * 2);
if (Arrow == NULL) if (Arrow == nullptr)
{ {
return; return;
} }
if (!Arrow->Initialize(*a_Player->GetWorld())) if (!Arrow->Initialize(*a_Player->GetWorld()))
{ {
delete Arrow; delete Arrow;
Arrow = NULL; Arrow = nullptr;
return; return;
} }
a_Player->GetWorld()->BroadcastSoundEffect("random.bow", a_Player->GetPosX(), a_Player->GetPosY(), a_Player->GetPosZ(), 0.5, (float)Force); a_Player->GetWorld()->BroadcastSoundEffect("random.bow", a_Player->GetPosX(), a_Player->GetPosY(), a_Player->GetPosZ(), 0.5, (float)Force);

View File

@ -50,7 +50,7 @@ public:
return true; return true;
} }
if (NewMap == NULL) if (NewMap == nullptr)
{ {
return true; return true;
} }

View File

@ -83,7 +83,7 @@ cItemHandler * cItemHandler::GetItemHandler(int a_ItemType)
memset(m_ItemHandler, 0, sizeof(m_ItemHandler)); memset(m_ItemHandler, 0, sizeof(m_ItemHandler));
m_HandlerInitialized = true; m_HandlerInitialized = true;
} }
if (m_ItemHandler[a_ItemType] == NULL) if (m_ItemHandler[a_ItemType] == nullptr)
{ {
m_ItemHandler[a_ItemType] = CreateItemHandler(a_ItemType); m_ItemHandler[a_ItemType] = CreateItemHandler(a_ItemType);
} }
@ -278,7 +278,7 @@ void cItemHandler::Deinit()
for (int i = 0; i < 2267; i++) for (int i = 0; i < 2267; i++)
{ {
delete m_ItemHandler[i]; delete m_ItemHandler[i];
m_ItemHandler[i] = NULL; m_ItemHandler[i] = nullptr;
} }
memset(m_ItemHandler, 0, sizeof(m_ItemHandler)); // Don't leave any dangling pointers around, just in case memset(m_ItemHandler, 0, sizeof(m_ItemHandler)); // Don't leave any dangling pointers around, just in case
m_HandlerInitialized = false; m_HandlerInitialized = false;

View File

@ -37,7 +37,7 @@ public:
if (!ItemFrame->Initialize(*a_World)) if (!ItemFrame->Initialize(*a_World))
{ {
delete ItemFrame; delete ItemFrame;
ItemFrame = NULL; ItemFrame = nullptr;
return false; return false;
} }

View File

@ -31,7 +31,7 @@ public:
{ {
cMap * Map = a_World->GetMapManager().GetMapData((unsigned)a_Item.m_ItemDamage); cMap * Map = a_World->GetMapManager().GetMapData((unsigned)a_Item.m_ItemDamage);
if (Map == NULL) if (Map == nullptr)
{ {
return; return;
} }

View File

@ -56,7 +56,7 @@ public:
double x = (double)a_BlockX + 0.5; double x = (double)a_BlockX + 0.5;
double y = (double)a_BlockY + 0.5; double y = (double)a_BlockY + 0.5;
double z = (double)a_BlockZ + 0.5; double z = (double)a_BlockZ + 0.5;
cMinecart * Minecart = NULL; cMinecart * Minecart = nullptr;
switch (m_ItemType) switch (m_ItemType)
{ {
case E_ITEM_MINECART: Minecart = new cRideableMinecart (x, y, z, cItem(), 1); break; case E_ITEM_MINECART: Minecart = new cRideableMinecart (x, y, z, cItem(), 1); break;

View File

@ -68,7 +68,7 @@ public:
LeakFinderShowCompleteCallstack = 0x1000 LeakFinderShowCompleteCallstack = 0x1000
} LeakFinderOptions; } LeakFinderOptions;
LeakFinderOutput(int options = OptionsAll, LPCSTR szSymPath = NULL); LeakFinderOutput(int options = OptionsAll, LPCSTR szSymPath = nullptr);
virtual void OnLeakSearchStart(LPCSTR sszLeakFinderName); virtual void OnLeakSearchStart(LPCSTR sszLeakFinderName);
virtual void OnLeakStartEntry(LPCSTR szKeyName, SIZE_T nDataSize); virtual void OnLeakStartEntry(LPCSTR szKeyName, SIZE_T nDataSize);
protected: protected:
@ -110,7 +110,7 @@ class ZZZ_LeakFinder
public: public:
ZZZ_LeakFinder() ZZZ_LeakFinder()
{ {
m_pXml = NULL; m_pXml = nullptr;
#ifdef XML_LEAK_FINDER #ifdef XML_LEAK_FINDER
m_pXml = new LeakFinderXmlOutput(); m_pXml = new LeakFinderXmlOutput();
#endif #endif
@ -119,7 +119,7 @@ public:
~ZZZ_LeakFinder() ~ZZZ_LeakFinder()
{ {
DeinitLeakFinder(m_pXml); DeinitLeakFinder(m_pXml);
if (m_pXml != NULL) delete m_pXml; if (m_pXml != nullptr) delete m_pXml;
} }
protected: protected:
LeakFinderXmlOutput *m_pXml; LeakFinderXmlOutput *m_pXml;
@ -148,7 +148,7 @@ ZZZ_LeakFinder zzz_LeakFinder;
extern void DumpUsedMemory(LeakFinderOutput * output = NULL); extern void DumpUsedMemory(LeakFinderOutput * output = nullptr);

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