1
0

Merge branch 'master' into ChunkLoader

Conflicts:
	src/ChunkSender.cpp
	src/ClientHandle.cpp
	src/World.h
This commit is contained in:
Howaner 2014-10-23 14:59:42 +02:00
commit 72bb299a4a
240 changed files with 2398 additions and 2084 deletions

View File

@ -35,12 +35,49 @@ return
Inherits = "cProjectileEntity",
}, -- cArrowEntity
cExpBottleEntity =
{
Desc = [[
Represents a thrown ExpBottle. A subclass of the {{cProjectileEntity}}.
]],
Functions =
{
},
Inherits = "cProjectileEntity",
}, -- cExpBottleEntity
cFireChargeEntity =
{
Desc = [[
Represents a fire charge that has been shot by a Blaze or a {{cDispenserEntity|Dispenser}}. A subclass
of the {{cProjectileEntity}}.
]],
Functions = {},
Inherits = "cProjectileEntity",
}, -- cFireChargeEntity
cFireworkEntity =
{
Desc = [[
Represents a firework rocket.
]],
Functions =
{
GetItem = { Params = "", Return = "{{cItem}}", Notes = "Returns the item that has been used to create the firework rocket. The item's m_FireworkItem member contains all the firework-related data." },
GetTicksToExplosion = { Params = "", Return = "number", Notes = "Returns the number of ticks left until the firework explodes." },
SetItem = { Params = "{{cItem}}", Return = "", Notes = "Sets a new item to be used for the firework." },
SetTicksToExplosion = { Params = "NumTicks", Return = "", Notes = "Sets the number of ticks left until the firework explodes." },
},
Inherits = "cProjectileEntity",
}, -- cFireworkEntity
cFloater =
{
Desc = "",
Functions = {},
Inherits = "cProjectileEntity",
}, -- cFireChargeEntity
}, -- cFloater
cGhastFireballEntity =
{
@ -64,14 +101,14 @@ return
pkArrow = { Notes = "The projectile is an {{cArrowEntity|arrow}}" },
pkEgg = { Notes = "The projectile is a {{cThrownEggEntity|thrown egg}}" },
pkEnderPearl = { Notes = "The projectile is a {{cThrownEnderPearlEntity|thrown enderpearl}}" },
pkExpBottle = { Notes = "The projectile is a thrown exp bottle (NYI)" },
pkExpBottle = { Notes = "The projectile is a {{cExpBottleEntity|thrown exp bottle}}" },
pkFireCharge = { Notes = "The projectile is a {{cFireChargeEntity|fire charge}}" },
pkFirework = { Notes = "The projectile is a (flying) firework (NYI)" },
pkFishingFloat = { Notes = "The projectile is a fishing float (NYI)" },
pkFirework = { Notes = "The projectile is a (flying) {{cFireworkEntity|firework}}" },
pkFishingFloat = { Notes = "The projectile is a {{cFloater|fishing float}}" },
pkGhastFireball = { Notes = "The projectile is a {{cGhastFireballEntity|ghast fireball}}" },
pkSnowball = { Notes = "The projectile is a {{cThrownSnowballEntity|thrown snowball}}" },
pkSplashPotion = { Notes = "The projectile is a thrown splash potion (NYI)" },
pkWitherSkull = { Notes = "The projectile is a wither skull (NYI)" },
pkSplashPotion = { Notes = "The projectile is a {{cSplashPotionEntity|thrown splash potion}}" },
pkWitherSkull = { Notes = "The projectile is a {{cWitherSkullEntity|wither skull}}" },
},
ConstantGroups =
{
@ -84,6 +121,13 @@ return
Inherits = "cEntity",
}, -- cProjectileEntity
cSplashPotionEntity =
{
Desc = "",
Functions = {},
Inherits = "cProjectileEntity",
}, -- cSplashPotionEntity
cThrownEggEntity =
{
Desc = "",
@ -97,13 +141,20 @@ return
Functions = {},
Inherits = "cProjectileEntity",
}, -- cThrownEnderPearlEntity
cThrownSnowballEntity =
{
Desc = "",
Functions = {},
Inherits = "cProjectileEntity",
}, -- cThrownSnowballEntity
cWitherSkullEntity =
{
Desc = "",
Functions = {},
Inherits = "cProjectileEntity",
}, -- cWitherSkullEntity
}

View File

@ -33,7 +33,7 @@ function GetDefaultPage()
local AllPlugins = PM:GetAllPlugins()
for key,value in pairs(AllPlugins) do
if( value ~= nil and value ~= false ) then
Content = Content .. "<li>" .. key .. " V." .. value:GetVersion() .. "</li>"
Content = Content .. "<li>" .. key .. " (version " .. value:GetVersion() .. ")</li>"
end
end

View File

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

View File

@ -33,15 +33,27 @@ $cfile "../StringUtils.h"
$cfile "../Defines.h"
$cfile "../ChatColor.h"
$cfile "../ClientHandle.h"
$cfile "../Entities/ArrowEntity.h"
$cfile "../Entities/Entity.h"
$cfile "../Entities/EntityEffect.h"
$cfile "../Entities/ExpBottleEntity.h"
$cfile "../Entities/FireChargeEntity.h"
$cfile "../Entities/FireworkEntity.h"
$cfile "../Entities/Floater.h"
$cfile "../Entities/GhastFireballEntity.h"
$cfile "../Entities/HangingEntity.h"
$cfile "../Entities/ItemFrame.h"
$cfile "../Entities/Pawn.h"
$cfile "../Entities/Player.h"
$cfile "../Entities/Painting.h"
$cfile "../Entities/Pickup.h"
$cfile "../Entities/ProjectileEntity.h"
$cfile "../Entities/SplashPotionEntity.h"
$cfile "../Entities/ThrownEggEntity.h"
$cfile "../Entities/ThrownEnderPearlEntity.h"
$cfile "../Entities/ThrownSnowballEntity.h"
$cfile "../Entities/TNTEntity.h"
$cfile "../Entities/EntityEffect.h"
$cfile "../Entities/WitherSkullEntity.h"
$cfile "../Server.h"
$cfile "../World.h"
$cfile "../Inventory.h"

View File

@ -5,131 +5,133 @@ include_directories ("${PROJECT_SOURCE_DIR}/../")
include_directories (".")
SET (SRCS
Bindings.cpp
DeprecatedBindings.cpp
LuaChunkStay.cpp
LuaState.cpp
LuaWindow.cpp
ManualBindings.cpp
ManualBindings_RankManager.cpp
Plugin.cpp
PluginLua.cpp
PluginManager.cpp
WebPlugin.cpp
Bindings.cpp
DeprecatedBindings.cpp
LuaChunkStay.cpp
LuaState.cpp
LuaWindow.cpp
ManualBindings.cpp
ManualBindings_RankManager.cpp
Plugin.cpp
PluginLua.cpp
PluginManager.cpp
WebPlugin.cpp
)
SET (HDRS
Bindings.h
DeprecatedBindings.h
LuaChunkStay.h
LuaFunctions.h
LuaState.h
LuaWindow.h
ManualBindings.h
Plugin.h
PluginLua.h
PluginManager.h
WebPlugin.h
tolua++.h
Bindings.h
DeprecatedBindings.h
LuaChunkStay.h
LuaFunctions.h
LuaState.h
LuaWindow.h
ManualBindings.h
Plugin.h
PluginLua.h
PluginManager.h
WebPlugin.h
tolua++.h
)
# List all the files that are generated as part of the Bindings build process
set (BINDING_OUTPUTS
${CMAKE_CURRENT_SOURCE_DIR}/Bindings.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Bindings.h
${CMAKE_CURRENT_SOURCE_DIR}/Bindings.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Bindings.h
)
set(BINDING_DEPENDENCIES
tolua
../Bindings/virtual_method_hooks.lua
../Bindings/AllToLua.pkg
../Bindings/LuaFunctions.h
../Bindings/LuaWindow.h
../Bindings/Plugin.h
../Bindings/PluginLua.h
../Bindings/PluginManager.h
../Bindings/WebPlugin.h
../BiomeDef.h
../BlockArea.h
tolua
../Bindings/virtual_method_hooks.lua
../Bindings/AllToLua.pkg
../Bindings/LuaFunctions.h
../Bindings/LuaWindow.h
../Bindings/Plugin.h
../Bindings/PluginLua.h
../Bindings/PluginManager.h
../Bindings/WebPlugin.h
../BiomeDef.h
../BlockArea.h
../BlockEntities/BeaconEntity.h
../BlockEntities/BlockEntity.h
../BlockEntities/BlockEntityWithItems.h
../BlockEntities/ChestEntity.h
../BlockEntities/DispenserEntity.h
../BlockEntities/DropSpenserEntity.h
../BlockEntities/DropperEntity.h
../BlockEntities/FurnaceEntity.h
../BlockEntities/HopperEntity.h
../BlockEntities/JukeboxEntity.h
../BlockEntities/NoteEntity.h
../BlockEntities/SignEntity.h
../BlockEntities/MobHeadEntity.h
../BlockEntities/FlowerPotEntity.h
../BlockID.h
../BoundingBox.h
../ChatColor.h
../ChunkDef.h
../ClientHandle.h
../CraftingRecipes.h
../Cuboid.h
../Defines.h
../Enchantments.h
../Entities/EntityEffect.h
../Entities/Entity.h
../Entities/Floater.h
../Entities/Pawn.h
../Entities/Painting.h
../Entities/Pickup.h
../Entities/Player.h
../Entities/ProjectileEntity.h
../Entities/ArrowEntity.h
../Entities/ThrownEggEntity.h
../Entities/ThrownEnderPearlEntity.h
../Entities/ExpBottleEntity.h
../Entities/ThrownSnowballEntity.h
../Entities/FireChargeEntity.h
../Entities/FireworkEntity.h
../Entities/GhastFireballEntity.h
../Entities/TNTEntity.h
../Entities/ExpOrb.h
../Entities/HangingEntity.h
../Entities/ItemFrame.h
../Generating/ChunkDesc.h
../Inventory.h
../Item.h
../ItemGrid.h
../Mobs/Monster.h
../OSSupport/File.h
../Root.h
../Server.h
../StringUtils.h
../Tracer.h
../UI/Window.h
../Vector3.h
../WebAdmin.h
../World.h
../BlockEntities/BlockEntity.h
../BlockEntities/BlockEntityWithItems.h
../BlockEntities/ChestEntity.h
../BlockEntities/DispenserEntity.h
../BlockEntities/DropSpenserEntity.h
../BlockEntities/DropperEntity.h
../BlockEntities/FurnaceEntity.h
../BlockEntities/HopperEntity.h
../BlockEntities/JukeboxEntity.h
../BlockEntities/NoteEntity.h
../BlockEntities/SignEntity.h
../BlockEntities/MobHeadEntity.h
../BlockEntities/FlowerPotEntity.h
../BlockID.h
../BoundingBox.h
../ChatColor.h
../ChunkDef.h
../ClientHandle.h
../CraftingRecipes.h
../Cuboid.h
../Defines.h
../Enchantments.h
../Entities/ArrowEntity.h
../Entities/Entity.h
../Entities/EntityEffect.h
../Entities/ExpBottleEntity.h
../Entities/FireChargeEntity.h
../Entities/FireworkEntity.h
../Entities/Floater.h
../Entities/GhastFireballEntity.h
../Entities/HangingEntity.h
../Entities/ItemFrame.h
../Entities/Pawn.h
../Entities/Player.h
../Entities/Painting.h
../Entities/Pickup.h
../Entities/ProjectileEntity.h
../Entities/SplashPotionEntity.h
../Entities/ThrownEggEntity.h
../Entities/ThrownEnderPearlEntity.h
../Entities/ThrownSnowballEntity.h
../Entities/TNTEntity.h
../Entities/WitherSkullEntity.h
../Generating/ChunkDesc.h
../Inventory.h
../Item.h
../ItemGrid.h
../Mobs/Monster.h
../OSSupport/File.h
../Root.h
../Server.h
../StringUtils.h
../Tracer.h
../UI/Window.h
../Vector3.h
../WebAdmin.h
../World.h
)
if (NOT MSVC)
ADD_CUSTOM_COMMAND(
# add any new generated bindings here
OUTPUT ${BINDING_OUTPUTS}
ADD_CUSTOM_COMMAND(
# add any new generated bindings here
OUTPUT ${BINDING_OUTPUTS}
# Regenerate bindings:
COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
# Regenerate bindings:
COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
# add any new generation dependencies here
DEPENDS ${BINDING_DEPENDENCIES}
)
# add any new generation dependencies here
DEPENDS ${BINDING_DEPENDENCIES}
)
endif ()
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.cpp PROPERTIES GENERATED TRUE)
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.h PROPERTIES GENERATED TRUE)
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.cpp PROPERTIES COMPILE_FLAGS -Wno-error)
if(NOT MSVC)
add_library(Bindings ${SRCS} ${HDRS})
add_library(Bindings ${SRCS} ${HDRS})
target_link_libraries(Bindings lua sqlite tolualib polarssl)
target_link_libraries(Bindings lua sqlite tolualib polarssl)
endif()

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);
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));
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);
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));
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);
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));
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);
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));
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);
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));
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);
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));
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);
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));
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);
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));
return 1;
@ -224,16 +224,16 @@ static int tolua_get_AllToLua_g_BlockFullyOccupiesVoxel(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_BlockSpreadLightFalloff", tolua_get_AllToLua_g_BlockSpreadLightFalloff, NULL);
tolua_array(tolua_S, "g_BlockTransparent", tolua_get_AllToLua_g_BlockTransparent, NULL);
tolua_array(tolua_S, "g_BlockOneHitDig", tolua_get_AllToLua_g_BlockOneHitDig, NULL);
tolua_array(tolua_S, "g_BlockPistonBreakable", tolua_get_AllToLua_g_BlockPistonBreakable, NULL);
tolua_array(tolua_S, "g_BlockIsSnowable", tolua_get_AllToLua_g_BlockIsSnowable, NULL);
tolua_array(tolua_S, "g_BlockIsSolid", tolua_get_AllToLua_g_BlockIsSolid, NULL);
tolua_array(tolua_S, "g_BlockFullyOccupiesVoxel", tolua_get_AllToLua_g_BlockFullyOccupiesVoxel, NULL);
tolua_array(tolua_S, "g_BlockLightValue", tolua_get_AllToLua_g_BlockLightValue, nullptr);
tolua_array(tolua_S, "g_BlockSpreadLightFalloff", tolua_get_AllToLua_g_BlockSpreadLightFalloff, nullptr);
tolua_array(tolua_S, "g_BlockTransparent", tolua_get_AllToLua_g_BlockTransparent, nullptr);
tolua_array(tolua_S, "g_BlockOneHitDig", tolua_get_AllToLua_g_BlockOneHitDig, nullptr);
tolua_array(tolua_S, "g_BlockPistonBreakable", tolua_get_AllToLua_g_BlockPistonBreakable, nullptr);
tolua_array(tolua_S, "g_BlockIsSnowable", tolua_get_AllToLua_g_BlockIsSnowable, nullptr);
tolua_array(tolua_S, "g_BlockIsSolid", tolua_get_AllToLua_g_BlockIsSolid, nullptr);
tolua_array(tolua_S, "g_BlockFullyOccupiesVoxel", tolua_get_AllToLua_g_BlockFullyOccupiesVoxel, nullptr);
tolua_endmodule(tolua_S);
}

View File

@ -13,7 +13,7 @@
cLuaChunkStay::cLuaChunkStay(cPluginLua & 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(const AString & a_SubsystemName) :
m_LuaState(NULL),
m_LuaState(nullptr),
m_IsOwned(false),
m_SubsystemName(a_SubsystemName),
m_NumCurrentFunctionArgs(-1)
@ -90,7 +90,7 @@ cLuaState::~cLuaState()
void cLuaState::Create(void)
{
if (m_LuaState != NULL)
if (m_LuaState != nullptr)
{
LOGWARNING("%s: Trying to create an already-existing LuaState, ignoring.", __FUNCTION__);
return;
@ -119,7 +119,7 @@ void cLuaState::RegisterAPILibs(void)
void cLuaState::Close(void)
{
if (m_LuaState == NULL)
if (m_LuaState == nullptr)
{
LOGWARNING("%s: Trying to close an invalid LuaState, ignoring.", __FUNCTION__);
return;
@ -134,7 +134,7 @@ void cLuaState::Close(void)
return;
}
lua_close(m_LuaState);
m_LuaState = NULL;
m_LuaState = nullptr;
m_IsOwned = false;
}
@ -144,7 +144,7 @@ void cLuaState::Close(void)
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);
if (m_IsOwned)
@ -166,7 +166,7 @@ void cLuaState::Attach(lua_State * a_State)
void cLuaState::Detach(void)
{
if (m_LuaState == NULL)
if (m_LuaState == nullptr)
{
return;
}
@ -179,7 +179,7 @@ void cLuaState::Detach(void)
Close();
return;
}
m_LuaState = NULL;
m_LuaState = nullptr;
}
@ -589,7 +589,7 @@ void cLuaState::Push(cEntity * a_Entity)
}
case cEntity::etProjectile:
{
tolua_pushusertype(m_LuaState, a_Entity, "cProjectileEntity");
tolua_pushusertype(m_LuaState, a_Entity, a_Entity->GetClass());
break;
}
case cEntity::etFloater:
@ -869,7 +869,7 @@ void cLuaState::GetStackValue(int a_StackPos, AString & a_Value)
{
size_t len = 0;
const char * data = lua_tolstring(m_LuaState, a_StackPos, &len);
if (data != NULL)
if (data != nullptr)
{
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))
{
a_ReturnedVal = NULL;
a_ReturnedVal = nullptr;
return;
}
tolua_Error err;
@ -937,7 +937,7 @@ void cLuaState::GetStackValue(int a_StackPos, pWorld & a_ReturnedVal)
{
if (lua_isnil(m_LuaState, a_StackPos))
{
a_ReturnedVal = NULL;
a_ReturnedVal = nullptr;
return;
}
tolua_Error err;
@ -1002,7 +1002,7 @@ bool cLuaState::CheckParamUserTable(int a_StartParam, const char * a_UserTable,
lua_Debug entry;
VERIFY(lua_getstack(m_LuaState, 0, &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);
return false;
} // for i - Param
@ -1035,7 +1035,7 @@ bool cLuaState::CheckParamUserType(int a_StartParam, const char * a_UserType, in
lua_Debug entry;
VERIFY(lua_getstack(m_LuaState, 0, &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);
return false;
} // for i - Param
@ -1068,7 +1068,7 @@ bool cLuaState::CheckParamTable(int a_StartParam, int a_EndParam)
lua_Debug entry;
VERIFY(lua_getstack(m_LuaState, 0, &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);
return false;
} // for i - Param
@ -1101,7 +1101,7 @@ bool cLuaState::CheckParamNumber(int a_StartParam, int a_EndParam)
lua_Debug entry;
VERIFY(lua_getstack(m_LuaState, 0, &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);
return false;
} // for i - Param
@ -1134,7 +1134,7 @@ bool cLuaState::CheckParamString(int a_StartParam, int a_EndParam)
lua_Debug entry;
VERIFY(lua_getstack(m_LuaState, 0, &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);
return false;
} // 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_getinfo (m_LuaState, "n", &entry));
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;
} // 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_getinfo (m_LuaState, "n", &entry));
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;
} // for i - Param
@ -1224,7 +1224,7 @@ bool cLuaState::CheckParamEnd(int a_Param)
lua_Debug entry;
VERIFY(lua_getstack(m_LuaState, 0, &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);
return false;
}
@ -1403,7 +1403,7 @@ int cLuaState::CopyStackFrom(cLuaState & a_SrcLuaState, int a_SrcStart, int a_Sr
case LUA_TUSERDATA:
{
// Get the class name:
const char * type = NULL;
const char * type = nullptr;
if (lua_getmetatable(a_SrcLuaState, i) == 0)
{
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
// 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);
break;
}
@ -1441,7 +1441,7 @@ void cLuaState::ToString(int a_StackPos, AString & a_String)
{
size_t len;
const char * s = lua_tolstring(m_LuaState, a_StackPos, &len);
if (s != NULL)
if (s != nullptr)
{
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)
{
// 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--)
{
AString Value;
@ -1500,7 +1500,7 @@ int cLuaState::ReportFnCallErrors(lua_State * a_LuaState)
// cLuaState::cRef:
cLuaState::cRef::cRef(void) :
m_LuaState(NULL),
m_LuaState(nullptr),
m_Ref(LUA_REFNIL)
{
}
@ -1510,7 +1510,7 @@ cLuaState::cRef::cRef(void) :
cLuaState::cRef::cRef(cLuaState & a_LuaState, int a_StackPos) :
m_LuaState(NULL),
m_LuaState(nullptr),
m_Ref(LUA_REFNIL)
{
RefStack(a_LuaState, a_StackPos);
@ -1522,7 +1522,7 @@ cLuaState::cRef::cRef(cLuaState & a_LuaState, int a_StackPos) :
cLuaState::cRef::~cRef()
{
if (m_LuaState != NULL)
if (m_LuaState != nullptr)
{
UnRef();
}
@ -1535,7 +1535,7 @@ cLuaState::cRef::~cRef()
void cLuaState::cRef::RefStack(cLuaState & a_LuaState, int a_StackPos)
{
ASSERT(a_LuaState.IsValid());
if (m_LuaState != NULL)
if (m_LuaState != nullptr)
{
UnRef();
}
@ -1556,7 +1556,7 @@ void cLuaState::cRef::UnRef(void)
{
luaL_unref(*m_LuaState, LUA_REGISTRYINDEX, m_Ref);
}
m_LuaState = NULL;
m_LuaState = nullptr;
m_Ref = LUA_REFNIL;
}

View File

@ -164,7 +164,7 @@ public:
void Detach(void);
/** 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> */
void AddPackagePath(const AString & a_PathVariable, const AString & a_Path);
@ -318,10 +318,10 @@ public:
void ToString(int a_StackPos, AString & a_String);
/** Logs all the elements' types on the API stack, with an optional header for the listing. */
void LogStack(const char * a_Header = NULL);
void LogStack(const char * a_Header = nullptr);
/** Logs all the elements' types on the API stack, with an optional header for the listing. */
static void LogStack(lua_State * a_LuaState, const char * a_Header = NULL);
static void LogStack(lua_State * a_LuaState, const char * a_Header = nullptr);
protected:

View File

@ -18,7 +18,7 @@
cLuaWindow::cLuaWindow(cWindow::WindowType a_WindowType, int a_SlotsX, int a_SlotsY, const AString & a_Title) :
super(a_WindowType, a_Title),
m_Contents(a_SlotsX, a_SlotsY),
m_Plugin(NULL),
m_Plugin(nullptr),
m_LuaRef(LUA_REFNIL),
m_OnClosingFnRef(LUA_REFNIL),
m_OnSlotChangedFnRef(LUA_REFNIL)
@ -70,7 +70,7 @@ cLuaWindow::~cLuaWindow()
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
ASSERT((m_Plugin == NULL) || (m_Plugin == a_Plugin));
ASSERT((m_Plugin == nullptr) || (m_Plugin == a_Plugin));
ASSERT(m_LuaRef == LUA_REFNIL);
m_Plugin = a_Plugin;
m_LuaRef = a_LuaRef;
@ -82,7 +82,7 @@ void cLuaWindow::SetLuaRef(cPluginLua * a_Plugin, int a_LuaRef)
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)
{
// 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 (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)
{
// 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 (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:
if (m_OnClosingFnRef != LUA_REFNIL)
{
ASSERT(m_Plugin != NULL);
ASSERT(m_Plugin != nullptr);
if (m_Plugin->CallbackWindowClosing(m_OnClosingFnRef, *this, a_Player, a_CanRefuse))
{
// The callback disagrees (the higher levels check the CanRefuse flag compliance)
@ -153,7 +153,7 @@ void cLuaWindow::Destroy(void)
{
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
m_Plugin->Unreference(m_LuaRef);

View File

@ -145,13 +145,13 @@ static AString GetLogMessage(lua_State * tolua_S)
tolua_Error 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
{
size_t len = 0;
const char * str = lua_tolstring(tolua_S, 1, &len);
if (str != NULL)
if (str != nullptr)
{
return AString(str, len);
}
@ -170,7 +170,7 @@ static int tolua_LOG(lua_State * tolua_S)
tolua_Error 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:
@ -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__);
lua_pop(L, 1);
return NULL;
return nullptr;
}
cPluginLua * Plugin = (cPluginLua *)lua_topointer(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);
}
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, "");
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);
}
@ -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);
}
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);
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);
}
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))
{
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);
}
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))
{
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:
Ty1 * Self = NULL;
cBoundingBox * Box = NULL;
Ty1 * Self = nullptr;
cBoundingBox * Box = nullptr;
L.GetStackValues(1, Self, Box);
if ((Self == NULL) || (Box == NULL))
if ((Self == nullptr) || (Box == nullptr))
{
LOGWARNING("Invalid world (%p) or boundingbox (%p)", Self, Box);
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);
}
Ty1 * self = (Ty1 *)tolua_tousertype(tolua_S, 1, NULL);
if (self == NULL)
Ty1 * self = (Ty1 *)tolua_tousertype(tolua_S, 1, nullptr);
if (self == nullptr)
{
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
#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 BlockY = (int) tolua_tonumber (tolua_S, 3, 0);
int BlockZ = (int) tolua_tonumber (tolua_S, 4, 0);
#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
{
@ -912,14 +912,14 @@ static int tolua_cWorld_GetBlockTypeMeta(lua_State * tolua_S)
else
#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 BlockY = (int) tolua_tonumber (tolua_S, 3, 0);
int BlockZ = (int) tolua_tonumber (tolua_S, 4, 0);
#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
{
@ -964,14 +964,14 @@ static int tolua_cWorld_GetSignLines(lua_State * tolua_S)
else
#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 BlockY = (int) tolua_tonumber (tolua_S, 3, 0);
int BlockZ = (int) tolua_tonumber (tolua_S, 4, 0);
#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
{
@ -1022,7 +1022,7 @@ static int tolua_cWorld_SetSignLines(lua_State * tolua_S)
else
#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 BlockY = (int) tolua_tonumber (tolua_S, 3, 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 Line3 = tolua_tocppstring(tolua_S, 7, 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
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
{
@ -1071,13 +1071,13 @@ static int tolua_cWorld_TryGetHeight(lua_State * tolua_S)
else
#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 BlockZ = (int) tolua_tonumber (tolua_S, 3, 0);
#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
{
@ -1136,15 +1136,15 @@ static int tolua_cWorld_QueueTask(lua_State * tolua_S)
// Retrieve the cPlugin from the LuaState:
cPluginLua * Plugin = GetLuaPlugin(tolua_S);
if (Plugin == NULL)
if (Plugin == nullptr)
{
// An error message has been already printed in GetLuaPlugin()
return 0;
}
// Retrieve the args:
cWorld * self = (cWorld *)tolua_tousertype(tolua_S, 1, NULL);
if (self == NULL)
cWorld * self = (cWorld *)tolua_tousertype(tolua_S, 1, nullptr);
if (self == nullptr)
{
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:
cPluginLua * Plugin = GetLuaPlugin(tolua_S);
if (Plugin == NULL)
if (Plugin == nullptr)
{
// An error message has been already printed in GetLuaPlugin()
return 0;
@ -1216,8 +1216,8 @@ static int tolua_cWorld_ScheduleTask(lua_State * tolua_S)
{
return 0;
}
cWorld * World = (cWorld *)tolua_tousertype(tolua_S, 1, NULL);
if (World == NULL)
cWorld * World = (cWorld *)tolua_tousertype(tolua_S, 1, nullptr);
if (World == nullptr)
{
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)
{
cPluginManager * self = (cPluginManager *)tolua_tousertype(tolua_S, 1, NULL);
cPluginManager * self = (cPluginManager *)tolua_tousertype(tolua_S, 1, nullptr);
const cPluginManager::PluginMap & AllPlugins = self->GetAllPlugins();
@ -1252,7 +1252,7 @@ static int tolua_cPluginManager_GetAllPlugins(lua_State * tolua_S)
{
const cPlugin* Plugin = iter->second;
tolua_pushstring(tolua_S, iter->first.c_str());
if (Plugin != NULL)
if (Plugin != nullptr)
{
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)
{
cPluginLua * Plugin = GetLuaPlugin(S);
if (Plugin == NULL)
if (Plugin == nullptr)
{
// An error message has already been printed in GetLuaPlugin()
return 0;
@ -1305,7 +1305,7 @@ static int tolua_cPluginManager_AddHook_FnRef(cPluginManager * a_PluginManager,
// Retrieve the cPlugin from the LuaState:
cPluginLua * Plugin = GetLuaPlugin(S);
if (Plugin == NULL)
if (Plugin == nullptr)
{
// An error message has been already printed in GetLuaPlugin()
return 0;
@ -1344,8 +1344,8 @@ static int tolua_cPluginManager_AddHook_DefFn(cPluginManager * a_PluginManager,
// The arg types have already been checked
// Retrieve and check the cPlugin parameter
cPluginLua * Plugin = (cPluginLua *)tolua_tousertype(S, a_ParamIdx, NULL);
if (Plugin == NULL)
cPluginLua * Plugin = (cPluginLua *)tolua_tousertype(S, a_ParamIdx, nullptr);
if (Plugin == nullptr)
{
LOGWARNING("cPluginManager.AddHook(): Invalid Plugin parameter, expected a valid cPlugin object. Hook not added");
S.LogStackTrace();
@ -1370,7 +1370,7 @@ static int tolua_cPluginManager_AddHook_DefFn(cPluginManager * a_PluginManager,
// Get the standard name for the callback function:
const char * FnName = cPluginLua::GetHookFnName(HookType);
if (FnName == NULL)
if (FnName == nullptr)
{
LOGWARNING("cPluginManager.AddHook(): Unknown hook type (%d). Hook not added.", HookType);
S.LogStackTrace();
@ -1417,8 +1417,8 @@ static int tolua_cPluginManager_AddHook(lua_State * tolua_S)
if (tolua_isusertype(S, 1, "cPluginManager", 0, &err))
{
// Style 2 or 3, retrieve the PlgMgr instance
PlgMgr = (cPluginManager *)tolua_tousertype(S, 1, NULL);
if (PlgMgr == NULL)
PlgMgr = (cPluginManager *)tolua_tousertype(S, 1, nullptr);
if (PlgMgr == nullptr)
{
LOGWARNING("Malformed plugin, use cPluginManager.AddHook(HOOK_TYPE, CallbackFunction). Fixing the call for you.");
S.LogStackTrace();
@ -1465,8 +1465,8 @@ static int tolua_cPluginManager_ForEachCommand(lua_State * tolua_S)
return 0;
}
cPluginManager * self = (cPluginManager *)tolua_tousertype(tolua_S, 1, NULL);
if (self == NULL)
cPluginManager * self = (cPluginManager *)tolua_tousertype(tolua_S, 1, nullptr);
if (self == nullptr)
{
LOGWARN("Error in function call 'ForEachCommand': Not called on an object instance");
return 0;
@ -1542,8 +1542,8 @@ static int tolua_cPluginManager_ForEachConsoleCommand(lua_State * tolua_S)
return 0;
}
cPluginManager * self = (cPluginManager *)tolua_tousertype(tolua_S, 1, NULL);
if (self == NULL)
cPluginManager * self = (cPluginManager *)tolua_tousertype(tolua_S, 1, nullptr);
if (self == nullptr)
{
LOGWARN("Error in function call 'ForEachConsoleCommand': Not called on an object instance");
return 0;
@ -1617,7 +1617,7 @@ static int tolua_cPluginManager_BindCommand(lua_State * L)
cPluginManager.BindCommand(Command, Permission, Function, HelpString) -- without the "self" param
*/
cPluginLua * Plugin = GetLuaPlugin(L);
if (Plugin == NULL)
if (Plugin == nullptr)
{
return 0;
}
@ -1687,7 +1687,7 @@ static int tolua_cPluginManager_BindConsoleCommand(lua_State * L)
// Get the plugin identification out of LuaState:
cPluginLua * Plugin = GetLuaPlugin(L);
if (Plugin == NULL)
if (Plugin == nullptr)
{
return 0;
}
@ -1775,7 +1775,7 @@ static int tolua_cPluginManager_CallPlugin(lua_State * tolua_S)
// If requesting calling the current plugin, refuse:
cPluginLua * ThisPlugin = GetLuaPlugin(L);
if (ThisPlugin == NULL)
if (ThisPlugin == nullptr)
{
return 0;
}
@ -1843,14 +1843,14 @@ static int tolua_cWorld_ChunkStay(lua_State * tolua_S)
}
cPluginLua * Plugin = GetLuaPlugin(tolua_S);
if (Plugin == NULL)
if (Plugin == nullptr)
{
return 0;
}
// Read the params:
cWorld * World = (cWorld *)tolua_tousertype(tolua_S, 1, NULL);
if (World == NULL)
cWorld * World = (cWorld *)tolua_tousertype(tolua_S, 1, nullptr);
if (World == nullptr)
{
LOGWARNING("World:ChunkStay(): invalid world parameter");
L.LogStackTrace();
@ -1862,7 +1862,7 @@ static int tolua_cWorld_ChunkStay(lua_State * tolua_S)
if (!ChunkStay->AddChunks(2))
{
delete ChunkStay;
ChunkStay = NULL;
ChunkStay = nullptr;
return 0;
}
@ -1889,8 +1889,8 @@ static int tolua_cPlayer_GetPermissions(lua_State * tolua_S)
}
// Get the params:
cPlayer * self = (cPlayer *)tolua_tousertype(tolua_S, 1, NULL);
if (self == NULL)
cPlayer * self = (cPlayer *)tolua_tousertype(tolua_S, 1, nullptr);
if (self == nullptr)
{
LOGWARNING("%s: invalid self (%p)", __FUNCTION__, self);
return 0;
@ -1911,15 +1911,15 @@ static int tolua_cPlayer_OpenWindow(lua_State * tolua_S)
// Retrieve the plugin instance from the Lua state
cPluginLua * Plugin = GetLuaPlugin(tolua_S);
if (Plugin == NULL)
if (Plugin == nullptr)
{
return 0;
}
// Get the parameters:
cPlayer * self = (cPlayer *)tolua_tousertype(tolua_S, 1, NULL);
cWindow * wnd = (cWindow *)tolua_tousertype(tolua_S, 2, NULL);
if ((self == NULL) || (wnd == NULL))
cPlayer * self = (cPlayer *)tolua_tousertype(tolua_S, 1, nullptr);
cWindow * wnd = (cWindow *)tolua_tousertype(tolua_S, 2, nullptr);
if ((self == nullptr) || (wnd == nullptr))
{
LOGWARNING("%s: invalid self (%p) or wnd (%p)", __FUNCTION__, self, wnd);
return 0;
@ -1992,15 +1992,15 @@ static int tolua_SetObjectCallback(lua_State * tolua_S)
// Retrieve the plugin instance from the Lua state
cPluginLua * Plugin = GetLuaPlugin(tolua_S);
if (Plugin == NULL)
if (Plugin == nullptr)
{
// Warning message has already been printed by GetLuaPlugin(), bail out silently
return 0;
}
// Get the parameters - self and the function reference:
OBJTYPE * self = (OBJTYPE *)tolua_tousertype(tolua_S, 1, NULL);
if (self == NULL)
OBJTYPE * self = (OBJTYPE *)tolua_tousertype(tolua_S, 1, nullptr);
if (self == nullptr)
{
LOGWARNING("%s: invalid self (%p)", __FUNCTION__, self);
return 0;
@ -2023,7 +2023,7 @@ static int tolua_SetObjectCallback(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_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)
{
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\")",
self->GetName().c_str(), self->GetDirectory().c_str()
);
@ -2087,7 +2087,7 @@ static int tolua_cPlugin_Call(lua_State * tolua_S)
L.LogStackTrace();
// 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, "");
// 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)
{
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);
}
@ -2152,7 +2152,7 @@ static int tolua_get_HTTPRequest_Params(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);
}
@ -2162,7 +2162,7 @@ static int tolua_get_HTTPRequest_PostParams(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;
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)
{
cWebAdmin * self = (cWebAdmin *)tolua_tousertype(tolua_S, 1, NULL);
cWebAdmin * self = (cWebAdmin *)tolua_tousertype(tolua_S, 1, nullptr);
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)
{
cWebPlugin* self = (cWebPlugin*) tolua_tousertype(tolua_S, 1, NULL);
cWebPlugin* self = (cWebPlugin*) tolua_tousertype(tolua_S, 1, nullptr);
const cWebPlugin::TabNameList & TabNames = self->GetTabNames();
@ -2302,8 +2302,8 @@ static int tolua_cClientHandle_SendPluginMessage(lua_State * L)
{
return 0;
}
cClientHandle * Client = (cClientHandle *)tolua_tousertype(L, 1, NULL);
if (Client == NULL)
cClientHandle * Client = (cClientHandle *)tolua_tousertype(L, 1, nullptr);
if (Client == nullptr)
{
LOGWARNING("ClientHandle is nil in cClientHandle:SendPluginMessage()");
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);
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;
}
int X, Y;
@ -2689,7 +2689,7 @@ static int tolua_cLineBlockTracer_Trace(lua_State * tolua_S)
}
// Trace:
cWorld * World = (cWorld *)tolua_tousertype(L, idx, NULL);
cWorld * World = (cWorld *)tolua_tousertype(L, idx, nullptr);
cLuaBlockTracerCallbacks Callbacks(L, idx + 1);
double StartX = tolua_tonumber(L, idx + 2, 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:
cItem * Input = (cItem *)tolua_tousertype(L, 2, NULL);
if (Input == NULL)
cItem * Input = (cItem *)tolua_tousertype(L, 2, nullptr);
if (Input == nullptr)
{
LOGWARNING("cRoot:GetFurnaceRecipe: the Input parameter is nil or missing.");
return 0;
@ -2729,7 +2729,7 @@ static int tolua_cRoot_GetFurnaceRecipe(lua_State * tolua_S)
// Get the recipe for the input
cFurnaceRecipe * FR = cRoot::Get()->GetFurnaceRecipe();
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
return 0;
@ -2760,10 +2760,10 @@ static int tolua_cHopperEntity_GetOutputBlockPos(lua_State * tolua_S)
{
return 0;
}
cHopperEntity * self = (cHopperEntity *)tolua_tousertype(tolua_S, 1, NULL);
if (self == NULL)
cHopperEntity * self = (cHopperEntity *)tolua_tousertype(tolua_S, 1, nullptr);
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;
}
@ -2800,10 +2800,10 @@ static int tolua_cBlockArea_GetBlockTypeMeta(lua_State * tolua_S)
return 0;
}
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL);
if (self == NULL)
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
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;
}
int BlockX = (int)tolua_tonumber(tolua_S, 2, 0);
@ -2834,10 +2834,10 @@ static int tolua_cBlockArea_GetOrigin(lua_State * tolua_S)
return 0;
}
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL);
if (self == NULL)
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
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;
}
@ -2866,10 +2866,10 @@ static int tolua_cBlockArea_GetRelBlockTypeMeta(lua_State * tolua_S)
return 0;
}
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL);
if (self == NULL)
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
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;
}
int BlockX = (int)tolua_tonumber(tolua_S, 2, 0);
@ -2900,10 +2900,10 @@ static int tolua_cBlockArea_GetSize(lua_State * tolua_S)
return 0;
}
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL);
if (self == NULL)
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
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;
}
@ -2931,10 +2931,10 @@ static int tolua_cBlockArea_GetCoordRange(lua_State * tolua_S)
return 0;
}
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL);
if (self == NULL)
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
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;
}
@ -2962,10 +2962,10 @@ static int tolua_cBlockArea_LoadFromSchematicFile(lua_State * tolua_S)
{
return 0;
}
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL);
if (self == NULL)
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
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;
}
@ -2992,10 +2992,10 @@ static int tolua_cBlockArea_LoadFromSchematicString(lua_State * tolua_S)
{
return 0;
}
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL);
if (self == NULL)
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
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;
}
@ -3023,10 +3023,10 @@ static int tolua_cBlockArea_SaveToSchematicFile(lua_State * tolua_S)
{
return 0;
}
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL);
if (self == NULL)
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
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;
}
AString Filename = tolua_tostring(tolua_S, 2, 0);
@ -3051,10 +3051,10 @@ static int tolua_cBlockArea_SaveToSchematicString(lua_State * tolua_S)
{
return 0;
}
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL);
if (self == NULL)
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
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;
}
@ -3085,10 +3085,10 @@ static int tolua_cCompositeChat_AddRunCommandPart(lua_State * tolua_S)
{
return 0;
}
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, NULL);
if (self == NULL)
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr);
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;
}
@ -3122,10 +3122,10 @@ static int tolua_cCompositeChat_AddSuggestCommandPart(lua_State * tolua_S)
{
return 0;
}
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, NULL);
if (self == NULL)
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr);
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;
}
@ -3159,10 +3159,10 @@ static int tolua_cCompositeChat_AddTextPart(lua_State * tolua_S)
{
return 0;
}
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, NULL);
if (self == NULL)
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr);
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;
}
@ -3195,10 +3195,10 @@ static int tolua_cCompositeChat_AddUrlPart(lua_State * tolua_S)
{
return 0;
}
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, NULL);
if (self == NULL)
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr);
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;
}
@ -3232,10 +3232,10 @@ static int tolua_cCompositeChat_ParseText(lua_State * tolua_S)
{
return 0;
}
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, NULL);
if (self == NULL)
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr);
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;
}
@ -3267,10 +3267,10 @@ static int tolua_cCompositeChat_SetMessageType(lua_State * tolua_S)
{
return 0;
}
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, NULL);
if (self == NULL)
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr);
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;
}
@ -3299,10 +3299,10 @@ static int tolua_cCompositeChat_UnderlineUrls(lua_State * tolua_S)
{
return 0;
}
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, NULL);
if (self == NULL)
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr);
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;
}
@ -3320,7 +3320,7 @@ static int tolua_cCompositeChat_UnderlineUrls(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, "StringSplit", tolua_StringSplit);
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_endmodule(tolua_S);
tolua_cclass(tolua_S, "HTTPRequest", "HTTPRequest", "", NULL);
tolua_cclass(tolua_S, "HTTPRequest", "HTTPRequest", "", nullptr);
tolua_beginmodule(tolua_S, "HTTPRequest");
// 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);

View File

@ -1044,7 +1044,7 @@ void ManualBindings::BindRankManager(lua_State * tolua_S)
{
// Create the cRankManager class in the API:
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):
tolua_beginmodule(tolua_S, "cRankManager");

View File

@ -1487,7 +1487,7 @@ void cPluginLua::ClearCommands(void)
cCSLock Lock(m_CriticalSection);
// 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)
{
@ -1506,7 +1506,7 @@ void cPluginLua::ClearConsoleCommands(void)
cCSLock Lock(m_CriticalSection);
// 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)
{
@ -1523,7 +1523,7 @@ void cPluginLua::ClearConsoleCommands(void)
bool cPluginLua::CanAddOldStyleHook(int a_HookType)
{
const char * FnName = GetHookFnName(a_HookType);
if (FnName == NULL)
if (FnName == nullptr)
{
// Unknown hook ID
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)
LOGWARNING("Requested name of an unknown hook type function: %d (max is %d)", a_HookType, cPluginManager::HOOK_MAX);
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:
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);
m_LuaState.LogStackTrace();
delete Ref;
Ref = NULL;
Ref = nullptr;
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());
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
for (PluginMap::iterator itr = m_Plugins.begin(); itr != m_Plugins.end();)
{
if (itr->second == NULL)
if (itr->second == nullptr)
{
PluginMap::iterator thiz = itr;
++thiz;
@ -89,7 +89,7 @@ void cPluginManager::FindPlugins(void)
// Add plugin name/directory to the list
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.
for (PluginMap::iterator itr = m_Plugins.begin(); itr != m_Plugins.end();)
{
if (itr->second == NULL)
if (itr->second == nullptr)
{
PluginMap::iterator thiz = itr;
++thiz;
@ -1445,7 +1445,7 @@ cPluginManager::CommandResult cPluginManager::HandleCommand(cPlayer & a_Player,
return crNoPermission;
}
ASSERT(cmd->second.m_Plugin != NULL);
ASSERT(cmd->second.m_Plugin != nullptr);
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)
{
if (itr->second == NULL) continue;
if (itr->second == nullptr) continue;
if (itr->second->GetName().compare(a_Plugin) == 0)
{
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?
{
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 false;
@ -1558,12 +1558,12 @@ void cPluginManager::RemovePlugin(cPlugin * a_Plugin)
RemovePluginCommands(a_Plugin);
RemovePluginConsoleCommands(a_Plugin);
RemoveHooks(a_Plugin);
if (a_Plugin != NULL)
if (a_Plugin != nullptr)
{
a_Plugin->OnDisable();
}
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)
{
if (a_Plugin != NULL)
if (a_Plugin != nullptr)
{
a_Plugin->ClearCommands();
}
@ -1670,7 +1670,7 @@ cPluginManager::CommandResult cPluginManager::ForceExecuteCommand(cPlayer & a_Pl
void cPluginManager::RemovePluginConsoleCommands(cPlugin * a_Plugin)
{
if (a_Plugin != NULL)
if (a_Plugin != nullptr)
{
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);
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());
}
@ -1759,14 +1759,14 @@ bool cPluginManager::ExecuteConsoleCommand(const AStringVector & a_Split, cComma
return false;
}
if (cmd->second.m_Plugin == NULL)
if (cmd->second.m_Plugin == nullptr)
{
// This is a built-in command
return false;
}
// 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());
return false;
@ -1788,7 +1788,7 @@ void cPluginManager::TabCompleteCommand(const AString & a_Text, AStringVector &
// Command name doesn't match
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
continue;
@ -1814,7 +1814,7 @@ bool cPluginManager::DoWithPlugin(const AString & a_PluginName, cPluginCallback
{
// TODO: Implement locking for plugins
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;
}
@ -1848,7 +1848,7 @@ void cPluginManager::AddHook(cPlugin * a_Plugin, int a_Hook)
{
if (!a_Plugin)
{
LOGWARN("Called cPluginManager::AddHook() with a_Plugin == NULL");
LOGWARN("Called cPluginManager::AddHook() with a_Plugin == nullptr");
return;
}
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 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 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 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);
@ -285,7 +285,7 @@ public:
bool ExecuteConsoleCommand(const AStringVector & a_Split, cCommandOutputCallback & a_Output);
/** 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);

View File

@ -12,7 +12,7 @@
cWebPlugin::cWebPlugin()
{
cWebAdmin * WebAdmin = cRoot::Get()->GetWebAdmin();
if (WebAdmin != NULL)
if (WebAdmin != nullptr)
{
WebAdmin->AddPlugin(this);
}
@ -25,7 +25,7 @@ cWebPlugin::cWebPlugin()
cWebPlugin::~cWebPlugin()
{
cWebAdmin * WebAdmin = cRoot::Get()->GetWebAdmin();
if (WebAdmin != NULL)
if (WebAdmin != nullptr)
{
WebAdmin->RemovePlugin(this);
}
@ -65,7 +65,7 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest
if (Split.size() > 1)
{
sWebPluginTab * Tab = NULL;
sWebPluginTab * Tab = nullptr;
if (Split.size() > 2) // If we got the tab name, show that page
{
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.second = Tab->SafeTitle;

View File

@ -273,10 +273,10 @@ void MergeCombinatorMask(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE
// cBlockArea:
cBlockArea::cBlockArea(void) :
m_BlockTypes(NULL),
m_BlockMetas(NULL),
m_BlockLight(NULL),
m_BlockSkyLight(NULL)
m_BlockTypes(nullptr),
m_BlockMetas(nullptr),
m_BlockLight(nullptr),
m_BlockSkyLight(nullptr)
{
}
@ -295,10 +295,10 @@ cBlockArea::~cBlockArea()
void cBlockArea::Clear(void)
{
delete[] m_BlockTypes; m_BlockTypes = NULL;
delete[] m_BlockMetas; m_BlockMetas = NULL;
delete[] m_BlockLight; m_BlockLight = NULL;
delete[] m_BlockSkyLight; m_BlockSkyLight = NULL;
delete[] m_BlockTypes; m_BlockTypes = nullptr;
delete[] m_BlockMetas; m_BlockMetas = nullptr;
delete[] m_BlockLight; m_BlockLight = nullptr;
delete[] m_BlockSkyLight; m_BlockSkyLight = nullptr;
m_Origin.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();
NIBBLETYPE * DstMetas = m_BlockMetas;
bool IsDummyMetas = ((SrcMetas == NULL) || (DstMetas == NULL));
bool IsDummyMetas = ((SrcMetas == nullptr) || (DstMetas == nullptr));
if (IsDummyMetas)
{
@ -1013,8 +1013,8 @@ void cBlockArea::RotateCCW(void)
} // for x
std::swap(m_BlockTypes, NewTypes);
std::swap(m_BlockMetas, NewMetas);
delete[] NewTypes; NewTypes = NULL;
delete[] NewMetas; NewMetas = NULL;
delete[] NewTypes; NewTypes = nullptr;
delete[] NewMetas; NewMetas = nullptr;
std::swap(m_Size.x, m_Size.z);
}
@ -1058,8 +1058,8 @@ void cBlockArea::RotateCW(void)
} // for x
std::swap(m_BlockTypes, NewTypes);
std::swap(m_BlockMetas, NewMetas);
delete[] NewTypes; NewTypes = NULL;
delete[] NewMetas; NewMetas = NULL;
delete[] NewTypes; NewTypes = nullptr;
delete[] NewMetas; NewMetas = nullptr;
std::swap(m_Size.x, m_Size.z);
}
@ -1206,7 +1206,7 @@ void cBlockArea::RotateCCWNoMeta(void)
} // for z
} // for x
std::swap(m_BlockTypes, NewTypes);
delete[] NewTypes; NewTypes = NULL;
delete[] NewTypes; NewTypes = nullptr;
}
if (HasBlockMetas())
{
@ -1224,7 +1224,7 @@ void cBlockArea::RotateCCWNoMeta(void)
} // for z
} // for x
std::swap(m_BlockMetas, NewMetas);
delete[] NewMetas; NewMetas = NULL;
delete[] NewMetas; NewMetas = nullptr;
}
std::swap(m_Size.x, m_Size.z);
}
@ -1251,7 +1251,7 @@ void cBlockArea::RotateCWNoMeta(void)
} // for x
} // for z
std::swap(m_BlockTypes, NewTypes);
delete[] NewTypes; NewTypes = NULL;
delete[] NewTypes; NewTypes = nullptr;
}
if (HasBlockMetas())
{
@ -1269,7 +1269,7 @@ void cBlockArea::RotateCWNoMeta(void)
} // for x
} // for z
std::swap(m_BlockMetas, NewMetas);
delete[] NewMetas; NewMetas = NULL;
delete[] NewMetas; NewMetas = nullptr;
}
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)
{
if (m_BlockTypes == NULL)
if (m_BlockTypes == nullptr)
{
LOGWARNING("cBlockArea: BlockTypes have not been read!");
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
{
if (m_BlockTypes == NULL)
if (m_BlockTypes == nullptr)
{
LOGWARNING("cBlockArea: BlockTypes have not been read!");
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)
{
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__);
}
@ -1563,7 +1563,7 @@ void cBlockArea::SetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, B
{
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__);
}
@ -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
{
int idx = MakeIndex(a_RelX, a_RelY, a_RelZ);
if (m_BlockTypes == NULL)
if (m_BlockTypes == nullptr)
{
LOGWARNING("cBlockArea: BlockTypes have not been read!");
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];
}
if (m_BlockMetas == NULL)
if (m_BlockMetas == nullptr)
{
LOGWARNING("cBlockArea: BlockMetas have not been read!");
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 res = 0;
if (m_BlockTypes != NULL)
if (m_BlockTypes != nullptr)
{
res |= baTypes;
}
if (m_BlockMetas != NULL)
if (m_BlockMetas != nullptr)
{
res |= baMetas;
}
if (m_BlockLight != NULL)
if (m_BlockLight != nullptr)
{
res |= baLight;
}
if (m_BlockSkyLight != NULL)
if (m_BlockSkyLight != nullptr)
{
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)
{
ASSERT(m_BlockTypes == NULL); // Has been cleared
ASSERT(m_BlockTypes == nullptr); // Has been cleared
if (a_DataTypes & baTypes)
{
m_BlockTypes = new BLOCKTYPE[a_SizeX * a_SizeY * a_SizeZ];
if (m_BlockTypes == NULL)
if (m_BlockTypes == nullptr)
{
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)
{
m_BlockMetas = new NIBBLETYPE[a_SizeX * a_SizeY * a_SizeZ];
if (m_BlockMetas == NULL)
if (m_BlockMetas == nullptr)
{
delete[] m_BlockTypes;
m_BlockTypes = NULL;
m_BlockTypes = nullptr;
return false;
}
}
if (a_DataTypes & baLight)
{
m_BlockLight = new NIBBLETYPE[a_SizeX * a_SizeY * a_SizeZ];
if (m_BlockLight == NULL)
if (m_BlockLight == nullptr)
{
delete[] m_BlockMetas;
m_BlockMetas = NULL;
m_BlockMetas = nullptr;
delete[] m_BlockTypes;
m_BlockTypes = NULL;
m_BlockTypes = nullptr;
return false;
}
}
if (a_DataTypes & baSkyLight)
{
m_BlockSkyLight = new NIBBLETYPE[a_SizeX * a_SizeY * a_SizeZ];
if (m_BlockSkyLight == NULL)
if (m_BlockSkyLight == nullptr)
{
delete[] m_BlockLight;
m_BlockLight = NULL;
m_BlockLight = nullptr;
delete[] m_BlockMetas;
m_BlockMetas = NULL;
m_BlockMetas = nullptr;
delete[] m_BlockTypes;
m_BlockTypes = NULL;
m_BlockTypes = nullptr;
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)
{
if (a_Array == NULL)
if (a_Array == nullptr)
{
LOGWARNING("cBlockArea: datatype has not been read!");
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
{
if (a_Array == NULL)
if (a_Array == nullptr)
{
LOGWARNING("cBlockArea: datatype has not been read!");
return 16;
@ -1896,7 +1896,7 @@ void cBlockArea::cChunkReader::ChunkData(const cChunkData & a_BlockBuffer)
}
// Copy the blocktypes:
if (m_Area.m_BlockTypes != NULL)
if (m_Area.m_BlockTypes != nullptr)
{
for (int y = 0; y < SizeY; y++)
{
@ -1917,7 +1917,7 @@ void cBlockArea::cChunkReader::ChunkData(const cChunkData & a_BlockBuffer)
}
// Copy the block metas:
if (m_Area.m_BlockMetas != NULL)
if (m_Area.m_BlockMetas != nullptr)
{
for (int y = 0; y < SizeY; y++)
{
@ -1938,7 +1938,7 @@ void cBlockArea::cChunkReader::ChunkData(const cChunkData & a_BlockBuffer)
}
// Copy the blocklight:
if (m_Area.m_BlockLight != NULL)
if (m_Area.m_BlockLight != nullptr)
{
for (int y = 0; y < SizeY; y++)
{
@ -1959,7 +1959,7 @@ void cBlockArea::cChunkReader::ChunkData(const cChunkData & a_BlockBuffer)
}
// Copy the skylight:
if (m_Area.m_BlockSkyLight != NULL)
if (m_Area.m_BlockSkyLight != nullptr)
{
for (int y = 0; y < SizeY; y++)
{

View File

@ -32,7 +32,7 @@ class cBlockArea
// tolua_end
DISALLOW_COPY_AND_ASSIGN(cBlockArea);
// tolua_begin
public:
/** What data is to be queried (bit-mask) */
@ -43,7 +43,7 @@ public:
baLight = 4,
baSkyLight = 8,
} ;
/** The per-block strategy to use when merging another block area into this object.
See the Merge function for the description of these */
enum eMergeStrategy
@ -56,64 +56,64 @@ public:
msDifference,
msMask,
} ;
cBlockArea(void);
~cBlockArea();
/** Clears the data stored to reclaim memory */
void Clear(void);
/** Creates a new area of the specified size and contents.
Origin is set to all zeroes.
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);
/** Creates a new area of the specified size and contents.
Origin is set to all zeroes.
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);
/** Resets the origin. No other changes are made, contents are untouched. */
void SetOrigin(int a_OriginX, int a_OriginY, int a_OriginZ);
/** Resets the origin. No other changes are made, contents are untouched. */
void SetOrigin(const Vector3i & a_Origin);
/** 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);
/** 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);
/** 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);
// 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
/** 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);
/** 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);
/** Copies this object's contents into the specified BlockArea. */
void CopyTo(cBlockArea & a_Into) const;
/** Copies the contents from the specified BlockArea into this object. */
void CopyFrom(const cBlockArea & a_From);
/** For testing purposes only, dumps the area into a file. */
void DumpToRawFile(const AString & a_FileName);
/** 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);
/** 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);
/** Merges another block area into this one, using the specified block combinating strategy
This function combines another BlockArea into the current object.
The strategy parameter specifies how individual blocks are combined together, using the table below.
@ -125,7 +125,7 @@ public:
| A | air | air | A | A |
| air | B | B | B | B |
| A | B | B | A | B |
So to sum up:
- msOverwrite completely overwrites all blocks with the Src's blocks
- msFillAir overwrites only those blocks that were air
@ -147,7 +147,7 @@ public:
| mycelium | stone | stone | ... and mycelium
| A | stone | A | ... but nothing else
| A | * | A | Everything else is left as it is
msSpongePrint:
Used for most generators, it allows carving out air pockets, too, and uses the Sponge as the NOP block
| area block | |
@ -155,7 +155,7 @@ public:
+----------+--------+--------+
| A | sponge | A | Sponge is the NOP block
| * | B | B | Everything else overwrites anything
msMask:
Combines two areas, the blocks that are the same are kept, differing ones are reset to air
| 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);
/** Merges another block area into this one, using the specified block combinating strategy.
See Merge() above for details. */
void Merge(const cBlockArea & a_Src, const Vector3i & a_RelMinCoords, eMergeStrategy a_Strategy);
/** 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);
/** 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,
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. a_Cuboid must be sorted. */
void FillRelCuboid(const cCuboid & a_RelCuboid,
int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0,
NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f
);
/** 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,
int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0,
NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f
);
/** Draws a line from between two points with the specified data */
void RelLine(const Vector3i & a_Point1, const Vector3i & a_Point2,
int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0,
NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f
);
/** Rotates the entire area counter-clockwise around the Y axis */
void RotateCCW(void);
/** Rotates the entire area clockwise around the Y axis */
void RotateCW(void);
/** Mirrors the entire area around the XY plane */
void MirrorXY(void);
/** Mirrors the entire area around the XZ plane */
void MirrorXZ(void);
/** Mirrors the entire area around the YZ plane */
void MirrorYZ(void);
/** Rotates the entire area counter-clockwise around the Y axis, doesn't use blockhandlers for block meta */
void RotateCCWNoMeta(void);
/** Rotates the entire area clockwise around the Y axis, doesn't use blockhandlers for block meta */
void RotateCWNoMeta(void);
/** Mirrors the entire area around the XY plane, doesn't use blockhandlers for block meta */
void MirrorXYNoMeta(void);
/** Mirrors the entire area around the XZ plane, doesn't use blockhandlers for block meta */
void MirrorXZNoMeta(void);
/** Mirrors the entire area around the YZ plane, doesn't use blockhandlers for block meta */
void MirrorYZNoMeta(void);
// Setters:
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);
@ -253,80 +253,80 @@ public:
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);
// tolua_end
// 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 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
const Vector3i & GetSize(void) const { return m_Size; }
// GetOrigin() is already exported manually to return 3 numbers, can't auto-export
const Vector3i & GetOrigin(void) const { return m_Origin; }
// tolua_begin
int GetSizeX(void) const { return m_Size.x; }
int GetSizeY(void) const { return m_Size.y; }
int GetSizeZ(void) const { return m_Size.z; }
/** 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 GetOriginX(void) const { return m_Origin.x; }
int GetOriginY(void) const { return m_Origin.y; }
int GetOriginZ(void) const { return m_Origin.z; }
/** Returns the datatypes that are stored in the object (bitmask of baXXX values) */
int GetDataTypes(void) const;
bool HasBlockTypes (void) const { return (m_BlockTypes != NULL); }
bool HasBlockMetas (void) const { return (m_BlockMetas != NULL); }
bool HasBlockLights (void) const { return (m_BlockLight != NULL); }
bool HasBlockSkyLights(void) const { return (m_BlockSkyLight != NULL); }
bool HasBlockTypes (void) const { return (m_BlockTypes != nullptr); }
bool HasBlockMetas (void) const { return (m_BlockMetas != nullptr); }
bool HasBlockLights (void) const { return (m_BlockLight != nullptr); }
bool HasBlockSkyLights(void) const { return (m_BlockSkyLight != nullptr); }
// tolua_end
// Clients can use these for faster access to all blocktypes. Be careful though!
/** Returns the internal pointer to the block types */
BLOCKTYPE * GetBlockTypes (void) const { return m_BlockTypes; }
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 * 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;
protected:
friend class cChunkDesc;
friend class cSchematicFileSerializer;
class cChunkReader :
public cChunkDataCallback
{
public:
cChunkReader(cBlockArea & a_Area);
protected:
cBlockArea & m_Area;
Vector3i m_Origin;
int m_CurrentChunkX;
int m_CurrentChunkZ;
void CopyNibbles(NIBBLETYPE * a_AreaDst, const NIBBLETYPE * a_ChunkSrc);
// cChunkDataCallback overrides:
virtual bool Coords(int a_ChunkX, int a_ChunkZ) override;
virtual void ChunkData(const cChunkData & a_BlockTypes) override;
} ;
typedef NIBBLETYPE * NIBBLEARRAY;
Vector3i m_Origin;
Vector3i m_Size;
/** 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. */
Vector3i m_WEOffset;
@ -335,10 +335,10 @@ protected:
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_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 */
bool SetSize(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes);
// Basic Setters:
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);
@ -346,11 +346,11 @@ protected:
// Basic Getters:
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;
// Crop helpers:
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);
// Expand helpers:
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);
@ -361,9 +361,13 @@ protected:
int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta,
NIBBLETYPE a_BlockLight, NIBBLETYPE a_BlockSkyLight
);
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);
// tolua_begin
} ;
// tolua_end

View File

@ -2,7 +2,6 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "BeaconEntity.h"
#include <algorithm>
#include "../BlockArea.h"
#include "../Entities/Player.h"
@ -98,7 +97,7 @@ bool cBeaconEntity::SetPrimaryEffect(cEntityEffect::eType a_Effect)
m_PrimaryEffect = a_Effect;
// Send window update:
if (GetWindow() != NULL)
if (GetWindow() != nullptr)
{
GetWindow()->SetProperty(1, m_PrimaryEffect);
}
@ -120,7 +119,7 @@ bool cBeaconEntity::SetSecondaryEffect(cEntityEffect::eType a_Effect)
m_SecondaryEffect = a_Effect;
// Send window update:
if (GetWindow() != NULL)
if (GetWindow() != nullptr)
{
GetWindow()->SetProperty(2, m_SecondaryEffect);
}
@ -185,7 +184,7 @@ void cBeaconEntity::UpdateBeacon(void)
if (m_BeaconLevel != OldBeaconLevel)
{
// Send window update:
if (GetWindow() != NULL)
if (GetWindow() != nullptr)
{
GetWindow()->SetProperty(0, m_BeaconLevel);
}
@ -228,7 +227,10 @@ void cBeaconEntity::GiveEffects(void)
virtual bool Item(cPlayer * a_Player)
{
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
Vector3d BeaconPosition = Vector3d(m_PosX, m_PosY, m_PosZ);
@ -253,7 +255,7 @@ void cBeaconEntity::GiveEffects(void)
, m_PrimaryEffect(a_PrimaryEffect)
, m_SecondaryEffect(a_SecondaryEffect)
, m_EffectLevel(a_EffectLevel)
{}
{};
} PlayerCallback(Radius, m_PosX, m_PosY, m_PosZ, m_PrimaryEffect, SecondaryEffect, EffectLevel);
GetWorld()->ForEachPlayer(PlayerCallback);
@ -281,13 +283,13 @@ bool cBeaconEntity::Tick(float a_Dt, cChunk & a_Chunk)
void cBeaconEntity::UsedBy(cPlayer * a_Player)
{
cWindow * Window = GetWindow();
if (Window == NULL)
if (Window == nullptr)
{
OpenWindow(new cBeaconWindow(m_PosX, m_PosY, m_PosZ, this));
Window = GetWindow();
}
if (Window != NULL)
if (Window != nullptr)
{
// if (a_Player->GetWindow() != Window)
// -> 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);
}

View File

@ -48,7 +48,7 @@ cBlockEntity * cBlockEntity::CreateByBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE
__FUNCTION__, a_BlockType, ItemTypeToString(a_BlockType).c_str()
);
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
/// If a_World is valid, then the entity is created bound to that world
/// Returns NULL 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);
/// Returns nullptr for unknown block types
static cBlockEntity * CreateByBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World = nullptr);
static const char * GetClassStatic(void) // Needed for ManualBindings's ForEach templates
{

View File

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

View File

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

View File

@ -154,7 +154,7 @@ void cCommandBlockEntity::SendTo(cClientHandle & a_Client)
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())
{

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);
AddDropSpenserDir(DispX, DispY, DispZ, Meta);
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
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)
{
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
cWindow * Window = GetWindow();
if (Window != NULL)
if (Window != nullptr)
{
Window->OwnerDestroyed();
}
@ -70,19 +70,19 @@ void cDropSpenserEntity::DropSpense(cChunk & a_Chunk)
SlotsCnt++;
}
} // for i - m_Contents[]
if (SlotsCnt == 0)
{
// 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);
return;
}
int RandomSlot = m_World->GetTickRandomNumber(SlotsCnt - 1);
// DropSpense the item, using the specialized behavior in the subclasses:
DropSpenseFromSlot(a_Chunk, OccupiedSlots[RandomSlot]);
// Broadcast a smoke and click effects:
NIBBLETYPE Meta = a_Chunk.GetMeta(m_RelX, m_PosY, m_RelZ);
int SmokeDir = 0;
@ -132,7 +132,7 @@ bool cDropSpenserEntity::Tick(float a_Dt, cChunk & a_Chunk)
{
return false;
}
m_ShouldDropSpense = false;
DropSpense(a_Chunk);
return true;
@ -155,13 +155,13 @@ void cDropSpenserEntity::SendTo(cClientHandle & a_Client)
void cDropSpenserEntity::UsedBy(cPlayer * a_Player)
{
cWindow * Window = GetWindow();
if (Window == NULL)
if (Window == nullptr)
{
OpenWindow(new cDropSpenserWindow(m_PosX, m_PosY, m_PosZ, this));
Window = GetWindow();
}
if (Window != NULL)
if (Window != nullptr)
{
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);
}

View File

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

View File

@ -59,7 +59,7 @@ void cFlowerPotEntity::Destroy(void)
// Drop the contents as pickups:
if (!m_Item.IsEmpty())
{
ASSERT(m_World != NULL);
ASSERT(m_World != nullptr);
cItems Pickups;
Pickups.Add(m_Item);
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);
/** 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);
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) :
super(a_BlockType, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, a_World),
m_BlockMeta(a_BlockMeta),
m_CurrentRecipe(NULL),
m_CurrentRecipe(nullptr),
m_IsDestroyed(false),
m_IsCooking(a_BlockType == E_BLOCK_LIT_FURNACE),
m_NeedCookTime(0),
@ -45,7 +45,7 @@ cFurnaceEntity::~cFurnaceEntity()
{
// Tell window its owner is destroyed
cWindow * Window = GetWindow();
if (Window != NULL)
if (Window != nullptr)
{
Window->OwnerDestroyed();
}
@ -145,7 +145,7 @@ void cFurnaceEntity::SendTo(cClientHandle & a_Client)
void cFurnaceEntity::BroadcastProgress(short a_ProgressbarID, short a_Value)
{
cWindow * Window = GetWindow();
if (Window != NULL)
if (Window != nullptr)
{
Window->SetProperty(a_ProgressbarID, a_Value);
}
@ -306,7 +306,7 @@ void cFurnaceEntity::UpdateOutput(void)
bool cFurnaceEntity::CanCookInputToOutput(void) const
{
if (m_CurrentRecipe == NULL)
if (m_CurrentRecipe == nullptr)
{
// This input cannot be cooked
return false;
@ -349,7 +349,7 @@ void cFurnaceEntity::UpdateProgressBars(bool a_ForceUpdate)
int CurFuel = (m_FuelBurnTime > 0) ? 200 - (200 * m_TimeBurned / m_FuelBurnTime) : 0;
BroadcastProgress(PROGRESSBAR_FUEL, static_cast<short>(CurFuel));
int CurCook = (m_NeedCookTime > 0) ? (200 * m_TimeCooked / m_NeedCookTime) : 0;
int CurCook = (m_NeedCookTime > 0) ? (200 * m_TimeCooked / m_NeedCookTime) : 0;
BroadcastProgress(PROGRESSBAR_SMELTING_CONFIRM, 200); // Post 1.8, Mojang requires a random packet with an ID of three and value of 200. Wat. Wat. Wat.
BroadcastProgress(PROGRESSBAR_SMELTING, static_cast<short>(CurCook));
}

View File

@ -133,7 +133,7 @@ protected:
int m_FuelBurnTime;
/** Amount of ticks that the current fuel has been burning */
int m_TimeBurned;
int m_TimeBurned;
/** Sends the specified progressbar value to all clients of the window */
void BroadcastProgress(short a_ProgressbarID, short a_Value);

View File

@ -86,14 +86,14 @@ void cHopperEntity::UsedBy(cPlayer * a_Player)
{
// If the window is not created, open it anew:
cWindow * Window = GetWindow();
if (Window == NULL)
if (Window == nullptr)
{
OpenNewWindow();
Window = GetWindow();
}
// Open the window for the player:
if (Window != NULL)
if (Window != nullptr)
{
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
{
ASSERT(a_Entity != NULL);
ASSERT(a_Entity != nullptr);
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 OutRelZ = OutZ - a_Chunk.GetPosZ() * cChunkDef::Width;
cChunk * DestChunk = a_Chunk.GetRelNeighborChunkAdjustCoords(OutRelX, OutRelZ);
if (DestChunk == NULL)
if (DestChunk == nullptr)
{
// The destination chunk has been unloaded, don't tick
return false;
@ -328,7 +328,7 @@ bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick)
case E_BLOCK_HOPPER:
{
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);
return false;
@ -355,7 +355,7 @@ bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick)
bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk)
{
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);
return false;
@ -383,7 +383,7 @@ bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk)
int x = m_RelX + Coords[i].x;
int z = m_RelZ + Coords[i].z;
cChunk * Neighbor = a_Chunk.GetRelNeighborChunkAdjustCoords(x, z);
if (Neighbor == NULL)
if (Neighbor == nullptr)
{
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));
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);
}
@ -422,7 +422,7 @@ bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk)
bool cHopperEntity::MoveItemsFromFurnace(cChunk & a_Chunk)
{
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);
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:
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);
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 z = RelZ + Coords[i].z;
cChunk * Neighbor = a_Chunk.GetRelNeighborChunkAdjustCoords(x, z);
if (Neighbor == NULL)
if (Neighbor == nullptr)
{
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));
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);
continue;

View File

@ -36,7 +36,7 @@ public:
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);
// tolua_begin

View File

@ -42,7 +42,7 @@ public:
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);
virtual ~cNoteEntity() {}

View File

@ -36,7 +36,7 @@ public:
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);
// tolua_begin

View File

@ -9,7 +9,7 @@
cBlockInfo::~cBlockInfo()
{
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)
{
if (a_Info[i].m_Handler == NULL)
if (a_Info[i].m_Handler == nullptr)
{
a_Info[i].m_Handler = cBlockHandler::CreateBlockHandler((BLOCKTYPE) i);
}

View File

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

View File

@ -17,15 +17,25 @@ public:
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
// Don't drop anything
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
return (a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) == E_BLOCK_SAND);
if (a_RelY <= 0)
{
return false;
}
BLOCKTYPE BelowBlock = a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ);
switch (BelowBlock)
{
case E_BLOCK_CLAY:
case E_BLOCK_HARDENED_CLAY:
case E_BLOCK_STAINED_CLAY:
case E_BLOCK_SAND:
{
return true;
}
default: return false;
}
}
} ;

View File

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

View File

@ -99,9 +99,9 @@ public:
for (BLOCKTYPE Type = 0; Type < E_BLOCK_MAX_TYPE_ID; 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;
}
AString BlockName = ItemTypeToString(Type);
@ -441,7 +441,7 @@ void cBlockHandler::DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterfac
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)
{
@ -562,7 +562,7 @@ void cBlockHandler::Check(cChunkInterface & a_ChunkInterface, cBlockPluginInterf
{
int BlockX = a_RelX + a_Chunk.GetPosX() * 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);

View File

@ -78,7 +78,7 @@ public:
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
@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_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:
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);
}
} ;

View File

@ -139,7 +139,7 @@ void cBlockPistonHandler::ExtendPiston(int a_BlockX, int a_BlockY, int a_BlockZ,
{
cChunkInterface ChunkInterface(a_World->GetChunkMap());
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

@ -35,7 +35,7 @@ public:
}
BLOCKTYPE Type = a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ);
return ((Type == E_BLOCK_SIGN_POST) || cBlockInfo::IsSolid(Type));
return ((Type == E_BLOCK_SIGN_POST) || (Type == E_BLOCK_WALLSIGN) || cBlockInfo::IsSolid(Type));
}

View File

@ -2,6 +2,7 @@
#pragma once
#include "BlockHandler.h"
#include "ChunkInterface.h"
@ -10,6 +11,7 @@
class cBlockTallGrassHandler :
public cBlockHandler
{
typedef cBlockHandler super;
public:
cBlockTallGrassHandler(BLOCKTYPE a_BlockType)
: cBlockHandler(a_BlockType)
@ -26,32 +28,58 @@ public:
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
// Drop seeds, sometimes
MTRand r1;
if (r1.randInt(10) == 5)
cFastRandom Random;
if (Random.NextInt(8) == 0)
{
a_Pickups.push_back(cItem(E_ITEM_SEEDS, 1, 0));
}
}
virtual void OnDestroyedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override
virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_CanDrop) override
{
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
if ((!a_Player->IsGameModeCreative()) && (a_Player->GetEquippedItem().m_ItemType == E_ITEM_SHEARS))
if (a_CanDrop && (a_Digger != NULL) && (a_Digger->GetEquippedWeapon().m_ItemType == E_ITEM_SHEARS))
{
cItems Pickups;
Pickups.Add(E_BLOCK_TALL_GRASS, 1, Meta);
a_WorldInterface.SpawnItemPickups(Pickups, a_BlockX, a_BlockY, a_BlockZ);
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
cItems Drops;
Drops.Add(m_BlockType, 1, Meta);
a_Player->UseEquippedItem();
// Allow plugins to modify the pickups:
a_BlockPluginInterface.CallHookBlockToPickups(a_Digger, a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta, Drops);
// Spawn the pickups:
if (!Drops.empty())
{
MTRand r1;
// Mid-block position first
double MicroX, MicroY, MicroZ;
MicroX = a_BlockX + 0.5;
MicroY = a_BlockY + 0.5;
MicroZ = a_BlockZ + 0.5;
// Add random offset second
MicroX += r1.rand(1) - 0.5;
MicroZ += r1.rand(1) - 0.5;
a_WorldInterface.SpawnItemPickups(Drops, MicroX, MicroY, MicroZ);
}
return;
}
super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_CanDrop);
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
return ((a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) != E_BLOCK_AIR));
if (a_RelY <= 0)
{
return false;
}
BLOCKTYPE BelowBlock = a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ);
return IsBlockTypeOfDirt(BelowBlock);
}
} ;

View File

@ -23,10 +23,6 @@ public:
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
{
UNUSED(a_Player);
UNUSED(a_CursorX);
UNUSED(a_CursorY);
UNUSED(a_CursorZ);
// TODO: Disallow placement where the vine doesn't attach to something properly
BLOCKTYPE BlockType = 0;
NIBBLETYPE BlockMeta;
@ -80,7 +76,21 @@ public:
/// Returns true if the specified block type is good for vines to attach to
static bool IsBlockAttachable(BLOCKTYPE a_BlockType)
{
return ((a_BlockType == E_BLOCK_LEAVES) || (a_BlockType == E_BLOCK_NEW_LEAVES) || cBlockInfo::IsSolid(a_BlockType));
switch (a_BlockType)
{
case E_BLOCK_GLASS:
case E_BLOCK_STAINED_GLASS:
case E_BLOCK_CHEST:
case E_BLOCK_TRAPPED_CHEST:
{
// You can't attach a vine to this solid blocks.
return false;
}
default:
{
return cBlockInfo::IsSolid(a_BlockType);
}
}
}
@ -138,7 +148,7 @@ public:
{
int BlockX = a_RelX + a_Chunk.GetPosX() * 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);
return;

View File

@ -7,6 +7,6 @@ public:
virtual ~cBroadcastInterface() {}
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 BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation, 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 = nullptr) = 0;
};

View File

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

View File

@ -95,19 +95,19 @@ cChunk::cChunk(
m_RedstoneSimulatorData(a_World->GetRedstoneSimulator()->CreateChunkData()),
m_AlwaysTicked(0)
{
if (a_NeighborXM != NULL)
if (a_NeighborXM != nullptr)
{
a_NeighborXM->m_NeighborXP = this;
}
if (a_NeighborXP != NULL)
if (a_NeighborXP != nullptr)
{
a_NeighborXP->m_NeighborXM = this;
}
if (a_NeighborZM != NULL)
if (a_NeighborZM != nullptr)
{
a_NeighborZM->m_NeighborZP = this;
}
if (a_NeighborZP != NULL)
if (a_NeighborZP != nullptr)
{
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;
m_WaterSimulatorData = NULL;
m_WaterSimulatorData = nullptr;
delete m_LavaSimulatorData;
m_LavaSimulatorData = NULL;
m_LavaSimulatorData = nullptr;
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);
if (newMob == NULL)
if (newMob == nullptr)
{
continue;
}
@ -639,7 +639,7 @@ void cChunk::Tick(float a_Dt)
{
// Remove all entities that are travelling to another world
MarkDirty();
(*itr)->SetWorldTravellingFrom(NULL);
(*itr)->SetWorldTravellingFrom(nullptr);
itr = m_Entities.erase(itr);
}
else if (
@ -668,7 +668,7 @@ void cChunk::Tick(float a_Dt)
void cChunk::TickBlock(int a_RelX, int a_RelY, int 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());
cBlockInServerPluginInterface PluginInterface(*this->GetWorld());
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)
{
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());
if (Neighbor == NULL)
if (Neighbor == nullptr)
{
// TODO: What to do with this?
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));
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);
} // for i - tickblocks
}
@ -1127,7 +1127,7 @@ bool cChunk::UnboundedRelGetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE
return false;
}
cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ);
if ((Chunk == NULL) || !Chunk->IsValid())
if ((Chunk == nullptr) || !Chunk->IsValid())
{
// The chunk is not available, bail out
return false;
@ -1148,7 +1148,7 @@ bool cChunk::UnboundedRelGetBlockType(int a_RelX, int a_RelY, int a_RelZ, BLOCKT
return false;
}
cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ);
if ((Chunk == NULL) || !Chunk->IsValid())
if ((Chunk == nullptr) || !Chunk->IsValid())
{
// The chunk is not available, bail out
return false;
@ -1169,7 +1169,7 @@ bool cChunk::UnboundedRelGetBlockMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLE
return false;
}
cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ);
if ((Chunk == NULL) || !Chunk->IsValid())
if ((Chunk == nullptr) || !Chunk->IsValid())
{
// The chunk is not available, bail out
return false;
@ -1190,7 +1190,7 @@ bool cChunk::UnboundedRelGetBlockBlockLight(int a_RelX, int a_RelY, int a_RelZ,
return false;
}
cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ);
if ((Chunk == NULL) || !Chunk->IsValid())
if ((Chunk == nullptr) || !Chunk->IsValid())
{
// The chunk is not available, bail out
return false;
@ -1211,7 +1211,7 @@ bool cChunk::UnboundedRelGetBlockSkyLight(int a_RelX, int a_RelY, int a_RelZ, NI
return false;
}
cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ);
if ((Chunk == NULL) || !Chunk->IsValid())
if ((Chunk == nullptr) || !Chunk->IsValid())
{
// The chunk is not available, bail out
return false;
@ -1232,7 +1232,7 @@ bool cChunk::UnboundedRelGetBlockLights(int a_RelX, int a_RelY, int a_RelZ, NIBB
return false;
}
cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ);
if ((Chunk == NULL) || !Chunk->IsValid())
if ((Chunk == nullptr) || !Chunk->IsValid())
{
// The chunk is not available, bail out
return false;
@ -1254,7 +1254,7 @@ bool cChunk::UnboundedRelSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE
return false;
}
cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ);
if ((Chunk == NULL) || !Chunk->IsValid())
if ((Chunk == nullptr) || !Chunk->IsValid())
{
// The chunk is not available, bail out
return false;
@ -1275,7 +1275,7 @@ bool cChunk::UnboundedRelFastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKT
return false;
}
cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ);
if ((Chunk == NULL) || !Chunk->IsValid())
if ((Chunk == nullptr) || !Chunk->IsValid())
{
// The chunk is not available, bail out
return false;
@ -1296,7 +1296,7 @@ void cChunk::UnboundedQueueTickBlock(int a_RelX, int a_RelY, int a_RelZ)
return;
}
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);
}
@ -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:
Vector3i WorldPos = PositionToWorldPosition(a_RelX, a_RelY, a_RelZ);
cBlockEntity * BlockEntity = GetBlockEntity(WorldPos);
if (BlockEntity != NULL)
if (BlockEntity != nullptr)
{
BlockEntity->Destroy();
RemoveBlockEntity(BlockEntity);
delete BlockEntity;
BlockEntity = NULL;
BlockEntity = nullptr;
}
// 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)
{
if (a_Client == NULL)
if (a_Client == nullptr)
{
// 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)));
@ -1673,7 +1673,7 @@ cBlockEntity * cChunk::GetBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ)
}
} // 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)
{
cBlockEntity * be = GetBlockEntity(a_X, a_Y, a_Z);
if (be != NULL)
if (be != nullptr)
{
be->UsedBy(a_Player);
}
@ -2664,10 +2664,10 @@ cChunk * cChunk::GetRelNeighborChunk(int a_RelX, int a_RelZ)
bool ReturnThis = true;
if (a_RelX < 0)
{
if (m_NeighborXM != NULL)
if (m_NeighborXM != nullptr)
{
cChunk * Candidate = m_NeighborXM->GetRelNeighborChunk(a_RelX + cChunkDef::Width, a_RelZ);
if (Candidate != NULL)
if (Candidate != nullptr)
{
return Candidate;
}
@ -2677,10 +2677,10 @@ cChunk * cChunk::GetRelNeighborChunk(int a_RelX, int a_RelZ)
}
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);
if (Candidate != NULL)
if (Candidate != nullptr)
{
return Candidate;
}
@ -2691,24 +2691,24 @@ cChunk * cChunk::GetRelNeighborChunk(int a_RelX, int a_RelZ)
if (a_RelZ < 0)
{
if (m_NeighborZM != NULL)
if (m_NeighborZM != nullptr)
{
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
}
return NULL;
return nullptr;
}
else if (a_RelZ >= cChunkDef::Width)
{
if (m_NeighborZP != NULL)
if (m_NeighborZP != nullptr)
{
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
}
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:
int RelX = a_RelX; // Make a local copy of the coords (faster access)
int RelZ = a_RelZ;
while ((RelX >= Width) && (ToReturn != NULL))
while ((RelX >= Width) && (ToReturn != nullptr))
{
RelX -= Width;
ToReturn = ToReturn->m_NeighborXP;
}
while ((RelX < 0) && (ToReturn != NULL))
while ((RelX < 0) && (ToReturn != nullptr))
{
RelX += Width;
ToReturn = ToReturn->m_NeighborXM;
}
while ((RelZ >= Width) && (ToReturn != NULL))
while ((RelZ >= Width) && (ToReturn != nullptr))
{
RelZ -= Width;
ToReturn = ToReturn->m_NeighborZP;
}
while ((RelZ < 0) && (ToReturn != NULL))
while ((RelZ < 0) && (ToReturn != nullptr))
{
RelZ += Width;
ToReturn = ToReturn->m_NeighborZM;
}
if (ToReturn != NULL)
if (ToReturn != nullptr)
{
a_RelX = RelX;
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
cBlockEntity * Entity = GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ);
if (Entity == NULL)
if (Entity == nullptr)
{
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)
{
cBlockEntity * Entity = GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ);
if (Entity == NULL)
if (Entity == nullptr)
{
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);
/** 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);
/**
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);
@ -316,28 +316,28 @@ public:
// Broadcast various packets to all clients of this chunk:
// (Please keep these alpha-sorted)
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 BroadcastBlockBreakAnimation(int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude = NULL);
void BroadcastBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL);
void BroadcastChunkData (cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = NULL);
void BroadcastCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL);
void BroadcastDestroyEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityHeadLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityMetadata (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityRelMove (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 = NULL);
void BroadcastEntityStatus (const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityVelocity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityAnimation (const cEntity & a_Entity, char a_Animation, const 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 = NULL);
void BroadcastRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID, 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 = NULL);
void BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = NULL);
void BroadcastSpawnEntity (cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ, 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 = nullptr);
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 = nullptr);
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 = nullptr);
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 = nullptr);
void BroadcastEntityHeadLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr);
void BroadcastEntityLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr);
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 = nullptr);
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 = nullptr);
void BroadcastEntityVelocity (const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr);
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 = nullptr);
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 = nullptr);
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 = nullptr);
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 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++)
{
m_Sections[i] = NULL;
m_Sections[i] = nullptr;
}
}
@ -56,7 +56,7 @@ cChunkData::~cChunkData()
for (size_t i = 0; i < NumSections; 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++)
{
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++)
{
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]);
m_Sections[i] = other.m_Sections[i];
other.m_Sections[i] = NULL;
other.m_Sections[i] = nullptr;
}
}
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_Z >= 0) && (a_Z < cChunkDef::Width));
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);
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;
if (m_Sections[Section] == NULL)
if (m_Sections[Section] == nullptr)
{
if (a_Block == 0x00)
{
return;
}
m_Sections[Section] = Allocate();
if (m_Sections[Section] == NULL)
if (m_Sections[Section] == nullptr)
{
ASSERT(!"Failed to allocate a new section in Chunkbuffer");
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))
{
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);
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;
if (m_Sections[Section] == NULL)
if (m_Sections[Section] == nullptr)
{
if ((a_Nibble & 0xf) == 0x00)
{
return false;
}
m_Sections[Section] = Allocate();
if (m_Sections[Section] == NULL)
if (m_Sections[Section] == nullptr)
{
ASSERT(!"Failed to allocate a new section in Chunkbuffer");
return false;
@ -279,7 +279,7 @@ NIBBLETYPE cChunkData::GetBlockLight(int a_RelX, int a_RelY, int a_RelZ) const
)
{
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);
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))
{
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);
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);
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] = *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);
a_Length -= ToCopy;
if (m_Sections[i] != NULL)
if (m_Sections[i] != nullptr)
{
BLOCKTYPE * blockbuffer = m_Sections[i]->m_BlockTypes;
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++)
{
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));
}
@ -394,7 +394,7 @@ void cChunkData::CopyBlockLight(NIBBLETYPE * a_Dest) const
{
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));
}
@ -413,7 +413,7 @@ void cChunkData::CopySkyLight(NIBBLETYPE * a_Dest) const
{
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));
}
@ -430,12 +430,12 @@ void cChunkData::CopySkyLight(NIBBLETYPE * a_Dest) const
void cChunkData::SetBlockTypes(const BLOCKTYPE * a_Src)
{
ASSERT(a_Src != NULL);
ASSERT(a_Src != nullptr);
for (size_t i = 0; i < NumSections; i++)
{
// 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));
continue;
@ -462,12 +462,12 @@ void cChunkData::SetBlockTypes(const BLOCKTYPE * 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++)
{
// 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));
continue;
@ -495,7 +495,7 @@ void cChunkData::SetMetas(const NIBBLETYPE * a_Src)
void cChunkData::SetBlockLight(const NIBBLETYPE * a_Src)
{
if (a_Src == NULL)
if (a_Src == nullptr)
{
return;
}
@ -503,7 +503,7 @@ void cChunkData::SetBlockLight(const NIBBLETYPE * a_Src)
for (size_t i = 0; i < NumSections; i++)
{
// 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));
continue;
@ -530,7 +530,7 @@ void cChunkData::SetBlockLight(const NIBBLETYPE * a_Src)
void cChunkData::SetSkyLight(const NIBBLETYPE * a_Src)
{
if (a_Src == NULL)
if (a_Src == nullptr)
{
return;
}
@ -538,7 +538,7 @@ void cChunkData::SetSkyLight(const NIBBLETYPE * a_Src)
for (size_t i = 0; i < NumSections; i++)
{
// 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));
continue;

View File

@ -88,12 +88,12 @@ public:
/** Copies the blocklight data from the specified flat array into the internal representation.
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);
/** Copies the skylight data from the specified flat array into the internal representation.
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);
struct sChunkSection
@ -118,7 +118,7 @@ private:
sChunkSection * Allocate(void);
/** 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);
/** 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
// (Please keep these alpha-sorted)
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 BroadcastBlockBreakAnimation(int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage, 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 = nullptr);
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 BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL);
void BroadcastCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL);
void BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityHeadLook(const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityLook(const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityMetadata(const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityRelMove(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 = NULL);
void BroadcastEntityStatus(const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityVelocity(const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation, const 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 = NULL);
void BroadcastRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID, 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 = NULL);
void BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = NULL);
void BroadcastSpawnEntity(cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, 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 = nullptr);
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 = nullptr);
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 = nullptr);
void BroadcastEntityHeadLook(const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr);
void BroadcastEntityLook(const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr);
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 = nullptr);
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 = nullptr);
void BroadcastEntityVelocity(const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr);
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 = nullptr);
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 = nullptr);
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 = nullptr);
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);
/** 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 */
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);
int GetX(void) const {return m_LayerX; }
@ -431,10 +431,10 @@ private:
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);
/** 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);
/** 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) :
super("ChunkSender"),
m_World(NULL),
m_World(nullptr),
m_RemoveCount(0),
m_Notify(NULL)
m_Notify(nullptr)
{
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, eChunkPriority a_Priority, cClientHandle * a_Client)
{
ASSERT(a_Client != NULL);
ASSERT(a_Client != nullptr);
{
sSendChunk Chunk(a_ChunkX, a_ChunkZ, a_Client);
@ -189,7 +189,7 @@ void cChunkSender::Execute(void)
m_ChunksReady.pop_front();
Lock.Unlock();
SendChunk(Coords.m_ChunkX, Coords.m_ChunkZ, NULL);
SendChunk(Coords.m_ChunkX, Coords.m_ChunkZ, nullptr);
}
else
{
@ -217,10 +217,10 @@ void cChunkSender::Execute(void)
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:
if ((a_Client != NULL) && !a_Client->WantsSendChunk(a_ChunkX, a_ChunkZ))
if ((a_Client != nullptr) && !a_Client->WantsSendChunk(a_ChunkX, a_ChunkZ))
{
return;
}
@ -252,7 +252,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);
// Send:
if (a_Client == NULL)
if (a_Client == nullptr)
{
m_World->BroadcastChunkData(a_ChunkX, a_ChunkZ, Data);
}
@ -264,7 +264,7 @@ void cChunkSender::SendChunk(int a_ChunkX, int a_ChunkZ, cClientHandle * a_Clien
// Send block-entity packets:
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);
}

View File

@ -165,7 +165,7 @@ protected:
virtual void Entity (cEntity * 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);
} ;

View File

@ -12,7 +12,7 @@
cChunkStay::cChunkStay(void) :
m_ChunkMap(NULL)
m_ChunkMap(nullptr)
{
}
@ -31,7 +31,7 @@ cChunkStay::~cChunkStay()
void cChunkStay::Clear(void)
{
ASSERT(m_ChunkMap == NULL);
ASSERT(m_ChunkMap == nullptr);
m_Chunks.clear();
}
@ -41,7 +41,7 @@ void cChunkStay::Clear(void)
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)
{
@ -60,7 +60,7 @@ void cChunkStay::Add(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)
{
@ -79,7 +79,7 @@ void cChunkStay::Remove(int a_ChunkX, int a_ChunkZ)
void cChunkStay::Enable(cChunkMap & a_ChunkMap)
{
ASSERT(m_ChunkMap == NULL);
ASSERT(m_ChunkMap == nullptr);
m_OutstandingChunks = m_Chunks;
m_ChunkMap = &a_ChunkMap;
@ -92,10 +92,10 @@ void cChunkStay::Enable(cChunkMap & a_ChunkMap)
void cChunkStay::Disable(void)
{
ASSERT(m_ChunkMap != NULL);
ASSERT(m_ChunkMap != nullptr);
cChunkMap * ChunkMap = m_ChunkMap;
m_ChunkMap = NULL;
m_ChunkMap = nullptr;
ChunkMap->DelChunkStay(*this);
}

View File

@ -68,7 +68,7 @@ cClientHandle::cClientHandle(const cSocket * a_Socket, int a_ViewDistance) :
m_ViewDistance(a_ViewDistance),
m_IPString(a_Socket->GetIPString()),
m_OutgoingData(64 KiB),
m_Player(NULL),
m_Player(nullptr),
m_HasSentDC(false),
m_LastStreamedChunkX(0x7fffffff), // bogus chunk coords to force streaming upon login
m_LastStreamedChunkZ(0x7fffffff),
@ -122,10 +122,10 @@ cClientHandle::~cClientHandle()
m_ChunksToSend.clear();
}
if (m_Player != NULL)
if (m_Player != nullptr)
{
cWorld * World = m_Player->GetWorld();
if (World != NULL)
if (World != nullptr)
{
if (!m_Username.empty())
{
@ -137,7 +137,7 @@ cClientHandle::~cClientHandle()
m_Player->Destroy();
}
delete m_Player;
m_Player = NULL;
m_Player = nullptr;
}
if (!m_HasSentDC)
@ -149,7 +149,7 @@ cClientHandle::~cClientHandle()
cRoot::Get()->GetServer()->RemoveClient(this);
delete m_Protocol;
m_Protocol = NULL;
m_Protocol = nullptr;
LOGD("ClientHandle at %p deleted", this);
}
@ -173,7 +173,7 @@ void cClientHandle::Destroy(void)
// DEBUG:
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();
m_Player->GetWorld()->RemoveClientFromChunkSender(this);
@ -314,7 +314,7 @@ void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID,
return;
}
ASSERT(m_Player == NULL);
ASSERT(m_Player == nullptr);
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());
cWorld * World = cRoot::Get()->GetWorld(m_Player->GetLoadedWorldName());
if (World == NULL)
if (World == nullptr)
{
World = cRoot::Get()->GetDefaultWorld();
}
@ -411,7 +411,7 @@ bool cClientHandle::StreamNextChunk(void)
{
return true;
}
ASSERT(m_Player != NULL);
ASSERT(m_Player != nullptr);
int ChunkPosX = m_Player->GetChunkX();
int ChunkPosZ = m_Player->GetChunkZ();
@ -574,7 +574,7 @@ void cClientHandle::StreamChunk(int a_ChunkX, int a_ChunkZ, cChunkSender::eChunk
}
cWorld * World = m_Player->GetWorld();
ASSERT(World != NULL);
ASSERT(World != nullptr);
if (World->AddChunkClient(a_ChunkX, a_ChunkZ, this))
{
@ -595,7 +595,7 @@ void cClientHandle::StreamChunk(int a_ChunkX, int a_ChunkZ, cChunkSender::eChunk
void cClientHandle::RemoveFromAllChunks()
{
cWorld * World = m_Player->GetWorld();
if (World != NULL)
if (World != nullptr)
{
World->RemoveClientFromChunks(this);
}
@ -711,7 +711,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)
{
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
return;
@ -845,7 +845,7 @@ void cClientHandle::UnregisterPluginChannels(const AStringVector & a_ChannelList
void cClientHandle::HandleBeaconSelection(int a_PrimaryEffect, int a_SecondaryEffect)
{
cWindow * Window = m_Player->GetWindow();
if ((Window == NULL) || (Window->GetWindowType() != cWindow::wtBeacon))
if ((Window == nullptr) || (Window->GetWindowType() != cWindow::wtBeacon))
{
return;
}
@ -921,7 +921,7 @@ void cClientHandle::HandleCommandBlockEntityChange(int a_EntityID, const AString
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;
}
@ -1558,7 +1558,7 @@ void cClientHandle::HandleChat(const AString & a_Message)
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;
}
@ -1658,7 +1658,7 @@ void cClientHandle::HandleWindowClick(char a_WindowID, short a_SlotNum, eClickAc
);
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());
return;
@ -1750,7 +1750,7 @@ void cClientHandle::HandleUseEntity(int a_TargetEntityID, bool a_IsLeftClick)
void cClientHandle::HandleRespawn(void)
{
if (m_Player == NULL)
if (m_Player == nullptr)
{
Destroy();
return;
@ -1840,7 +1840,7 @@ void cClientHandle::HandleEntitySprinting(int a_EntityID, bool a_IsSprinting)
void cClientHandle::HandleUnmount(void)
{
if (m_Player == NULL)
if (m_Player == nullptr)
{
return;
}
@ -1946,8 +1946,8 @@ void cClientHandle::RemoveFromWorld(void)
bool cClientHandle::CheckBlockInteractionsRate(void)
{
ASSERT(m_Player != NULL);
ASSERT(m_Player->GetWorld() != NULL);
ASSERT(m_Player != nullptr);
ASSERT(m_Player->GetWorld() != nullptr);
if (m_NumBlockChangeInteractionsThisTick > MAX_BLOCK_CHANGE_INTERACTIONS)
{
@ -1978,7 +1978,7 @@ void cClientHandle::Tick(float a_Dt)
Destroy();
}
if (m_Player == NULL)
if (m_Player == nullptr)
{
return;
}
@ -2149,10 +2149,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)
{
cWorld * World = GetPlayer()->GetWorld();
if (World == NULL)
if (World == nullptr)
{
World = cRoot::Get()->GetWorld(GetPlayer()->GetLoadedWorldName());
if (World == NULL)
if (World == nullptr)
{
World = cRoot::Get()->GetDefaultWorld();
}
@ -2177,7 +2177,7 @@ void cClientHandle::SendChat(const cCompositeChat & a_Message)
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:
bool Found = false;
@ -2998,7 +2998,7 @@ void cClientHandle::HandleEnchantItem(Byte & a_WindowID, Byte & a_Enchantment)
}
if (
(m_Player->GetWindow() == NULL) ||
(m_Player->GetWindow() == nullptr) ||
(m_Player->GetWindow()->GetWindowID() != a_WindowID) ||
(m_Player->GetWindow()->GetWindowType() != cWindow::wtEnchantment)
)

View File

@ -59,7 +59,7 @@ cCraftingGrid::cCraftingGrid(const cCraftingGrid & a_Original) :
cCraftingGrid::~cCraftingGrid()
{
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:
std::auto_ptr<cRecipe> Recipe(FindRecipe(a_CraftingGrid.GetItems(), a_CraftingGrid.GetWidth(), a_CraftingGrid.GetHeight()));
a_Recipe.Clear();
if (Recipe.get() == NULL)
if (Recipe.get() == nullptr)
{
// Allow plugins to intercept a no-recipe-found situation:
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:
const cItem * Grid = a_CraftingGrid + GridLeft + (a_GridWidth * GridTop);
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:
@ -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++)
{
cRecipe * Recipe = MatchRecipe(a_CraftingGrid, a_GridWidth, a_GridHeight, a_GridStride, *itr, x, y);
if (Recipe != NULL)
if (Recipe != nullptr)
{
return Recipe;
}
@ -645,7 +645,7 @@ cCraftingRecipes::cRecipe * cCraftingRecipes::FindRecipeCropped(const cItem * a_
} // for itr - m_Recipes[]
// No matching recipe found
return NULL;
return nullptr;
}
@ -681,7 +681,7 @@ cCraftingRecipes::cRecipe * cCraftingRecipes::MatchRecipe(const cItem * a_Crafti
)
{
// Doesn't match
return NULL;
return nullptr;
}
HasMatched[itrS->x + a_OffsetX][itrS->y + a_OffsetY] = true;
} // for itrS - Recipe->m_Ingredients[]
@ -743,7 +743,7 @@ cCraftingRecipes::cRecipe * cCraftingRecipes::MatchRecipe(const cItem * a_Crafti
} // for x
if (!Found)
{
return NULL;
return nullptr;
}
} // 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())
{
// There's an unmatched item in the grid
return NULL;
return nullptr;
}
} // for y, for x

View File

@ -157,13 +157,13 @@ protected:
/// Moves the recipe to top-left corner, sets its MinWidth / MinHeight
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);
/// 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);
/// 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);
/** 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)
{
// a_X = sinf ( a_Pan / 180 * PI) * cosf ( a_Pitch / 180 * PI);
// a_Y = -sinf ( 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_Y = sin(a_Pan / 180 * PI) * cos(a_Pitch / 180 * PI);
a_Z = sin(a_Pitch / 180 * PI);
a_X = cos(a_Pan / 180 * M_PI) * cos(a_Pitch / 180 * M_PI);
a_Y = sin(a_Pan / 180 * M_PI) * cos(a_Pitch / 180 * M_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
{
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;
cChunk * Chunk = a_Chunk.GetRelNeighborChunkAdjustCoords(RelPosX, RelPosZ);
if (Chunk == NULL)
if (Chunk == nullptr)
{
// Inside an unloaded chunk, abort
return;

View File

@ -1,6 +1,11 @@
//
// ArrowEntity.h
//
// ArrowEntity.h
// Declares the cArrowEntity representing the arrow that has been shot by the player or by a skeleton
#pragma once
@ -19,7 +24,7 @@ class cArrowEntity :
typedef cProjectileEntity super;
public:
/// Determines when the arrow can be picked up (depending on player gamemode). Corresponds to the MCA file "pickup" field
/** Determines when the arrow can be picked up (depending on player gamemode). Corresponds to the MCA file "pickup" field */
enum ePickupState
{
psNoPickup = 0,
@ -31,33 +36,33 @@ public:
CLASS_PROTODEF(cArrowEntity)
/// Creates a new arrow with psNoPickup state and default damage modifier coeff
/** Creates a new arrow with psNoPickup state and default damage modifier coeff */
cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
/// Creates a new arrow as shot by a player, initializes it from the player object
/** Creates a new arrow as shot by a player, initializes it from the player object */
cArrowEntity(cPlayer & a_Player, double a_Force);
// tolua_begin
/// Returns whether the arrow can be picked up by players
/** Returns whether the arrow can be picked up by players */
ePickupState GetPickupState(void) const { return m_PickupState; }
/// Sets a new pickup state
/** Sets a new pickup state */
void SetPickupState(ePickupState a_PickupState) { m_PickupState = a_PickupState; }
/// Returns the damage modifier coeff.
/** Returns the damage modifier coeff. */
double GetDamageCoeff(void) const { return m_DamageCoeff; }
/// Sets the damage modifier coeff
/** Sets the damage modifier coeff */
void SetDamageCoeff(double a_DamageCoeff) { m_DamageCoeff = a_DamageCoeff; }
/// Returns true if the specified player can pick the arrow up
/** Returns true if the specified player can pick the arrow up */
bool CanPickup(const cPlayer & a_Player) const;
/// Returns true if the arrow is set as critical
/** Returns true if the arrow is set as critical */
bool IsCritical(void) const { return m_IsCritical; }
/// Sets the IsCritical flag
/** Sets the IsCritical flag */
void SetIsCritical(bool a_IsCritical) { m_IsCritical = a_IsCritical; }
/** Gets the block arrow is in */
@ -70,28 +75,28 @@ public:
protected:
/// Determines when the arrow can be picked up by players
/** Determines when the arrow can be picked up by players */
ePickupState m_PickupState;
/// The coefficient applied to the damage that the arrow will deal, based on the bow enchantment. 2.0 for normal arrow
/** The coefficient applied to the damage that the arrow will deal, based on the bow enchantment. 2.0 for normal arrow */
double m_DamageCoeff;
/// If true, the arrow deals more damage
/** If true, the arrow deals more damage */
bool m_IsCritical;
/// Timer for pickup collection animation or five minute timeout
/** Timer for pickup collection animation or five minute timeout */
float m_Timer;
/// Timer for client arrow position confirmation via TeleportEntity
/** Timer for client arrow position confirmation via TeleportEntity */
float m_HitGroundTimer;
// Whether the arrow has already been teleported into the proper position in the ground.
bool m_HasTeleported;
/// If true, the arrow is in the process of being collected - don't go to anyone else
/** If true, the arrow is in the process of being collected - don't go to anyone else */
bool m_bIsCollected;
/// Stores the block position that arrow is lodged into, sets m_IsInGround to false if it becomes air
/** Stores the block position that arrow is lodged into, sets m_IsInGround to false if it becomes air */
Vector3i m_HitBlockPos;
// cProjectileEntity overrides:

View File

@ -42,7 +42,7 @@ bool cBoat::DoTakeDamage(TakeDamageInfo & TDI)
if (GetHealth() == 0)
{
if (TDI.Attacker != NULL)
if (TDI.Attacker != nullptr)
{
if (TDI.Attacker->IsPlayer())
{
@ -64,7 +64,7 @@ void cBoat::OnRightClicked(cPlayer & a_Player)
{
super::OnRightClicked(a_Player);
if (m_Attachee != NULL)
if (m_Attachee != nullptr)
{
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_Health(1)
, m_MaxHealth(1)
, m_AttachedTo(NULL)
, m_Attachee(NULL)
, m_AttachedTo(nullptr)
, m_Attachee(nullptr)
, m_bDirtyHead(true)
, m_bDirtyOrientation(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_LastPos(a_X, a_Y, a_Z)
, m_IsInitialized(false)
, m_WorldTravellingFrom(NULL)
, m_WorldTravellingFrom(nullptr)
, m_EntityType(a_EntityType)
, m_World(NULL)
, m_World(nullptr)
, m_IsFireproof(false)
, m_TicksSinceLastBurnDamage(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()
{
// 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:
@ -85,11 +85,11 @@ cEntity::~cEntity()
);
*/
if (m_AttachedTo != NULL)
if (m_AttachedTo != nullptr)
{
Detach();
}
if (m_Attachee != NULL)
if (m_Attachee != nullptr)
{
m_Attachee->Detach();
}
@ -242,7 +242,7 @@ void cEntity::TakeDamage(eDamageType a_DamageType, cEntity * a_Attacker, int a_R
TDI.FinalDamage = a_FinalDamage;
Vector3d Heading(0, 0, 0);
if (a_Attacker != NULL)
if (a_Attacker != nullptr)
{
Heading = a_Attacker->GetLookVector() * (a_Attacker->IsSprinting() ? 16 : 11);
Heading.y = 1.6;
@ -265,7 +265,7 @@ void cEntity::SetYawFromSpeed(void)
SetYaw(0);
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);
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;
}
if ((a_TDI.Attacker != NULL) && (a_TDI.Attacker->IsPlayer()))
if ((a_TDI.Attacker != nullptr) && (a_TDI.Attacker->IsPlayer()))
{
cPlayer * Player = (cPlayer *)a_TDI.Attacker;
@ -544,7 +544,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
m_Health = std::max(m_Health, 0);
// 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
if (KnockbackLevel < 1)
@ -571,7 +571,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
{
KilledBy(a_TDI);
if (a_TDI.Attacker != NULL)
if (a_TDI.Attacker != nullptr)
{
a_TDI.Attacker->Killed(this);
}
@ -778,7 +778,7 @@ void cEntity::Tick(float a_Dt, cChunk & a_Chunk)
m_InvulnerableTicks--;
}
if (m_AttachedTo != NULL)
if (m_AttachedTo != nullptr)
{
Vector3d DeltaPos = m_Pos - m_AttachedTo->GetPosition();
if (DeltaPos.Length() > 0.5)
@ -1092,7 +1092,7 @@ void cEntity::TickBurning(cChunk & a_Chunk)
{
if (!m_IsFireproof)
{
TakeDamage(dtOnFire, NULL, BURN_DAMAGE, 0);
TakeDamage(dtOnFire, nullptr, BURN_DAMAGE, 0);
}
m_TicksSinceLastBurnDamage = 0;
}
@ -1163,7 +1163,7 @@ void cEntity::TickBurning(cChunk & a_Chunk)
{
if (!m_IsFireproof)
{
TakeDamage(dtLavaContact, NULL, LAVA_DAMAGE, 0);
TakeDamage(dtLavaContact, nullptr, LAVA_DAMAGE, 0);
}
m_TicksSinceLastLavaDamage = 0;
}
@ -1184,7 +1184,7 @@ void cEntity::TickBurning(cChunk & a_Chunk)
{
if (!m_IsFireproof)
{
TakeDamage(dtFireContact, NULL, FIRE_DAMAGE, 0);
TakeDamage(dtFireContact, nullptr, FIRE_DAMAGE, 0);
}
m_TicksSinceLastFireDamage = 0;
}
@ -1213,7 +1213,7 @@ void cEntity::TickInVoid(cChunk & a_Chunk)
{
if (m_TicksSinceLastVoidDamage == 20)
{
TakeDamage(dtInVoid, NULL, 2, 0);
TakeDamage(dtInVoid, nullptr, 2, 0);
m_TicksSinceLastVoidDamage = 0;
}
else
@ -1239,7 +1239,7 @@ void cEntity::DetectCacti(void)
(((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)
{
UNUSED(a_ShouldSendRespawn);
ASSERT(a_World != NULL);
ASSERT(a_World != nullptr);
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)
{
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());
return false;
@ -1493,7 +1493,7 @@ void cEntity::HandleAir(void)
if (m_AirTickTimer <= 0)
{
// Damage player
TakeDamage(dtDrowning, NULL, 1, 1, 0);
TakeDamage(dtDrowning, nullptr, 1, 1, 0);
// Reset timer
m_AirTickTimer = DROWNING_TICKS;
}
@ -1708,7 +1708,7 @@ void cEntity::AttachTo(cEntity * a_AttachTo)
// Already attached to that entity, nothing to do here
return;
}
if (m_AttachedTo != NULL)
if (m_AttachedTo != nullptr)
{
// Detach from any previous entity:
Detach();
@ -1726,14 +1726,14 @@ void cEntity::AttachTo(cEntity * a_AttachTo)
void cEntity::Detach(void)
{
if (m_AttachedTo == NULL)
if (m_AttachedTo == nullptr)
{
// Attached to no entity, our work is done
return;
}
m_AttachedTo->m_Attachee = NULL;
m_AttachedTo = NULL;
m_World->BroadcastAttachEntity(*this, NULL);
m_AttachedTo->m_Attachee = nullptr;
m_AttachedTo = nullptr;
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)
{
if (m_AttachedTo == NULL)
if (m_AttachedTo == nullptr)
{
return;
}

View File

@ -32,7 +32,7 @@
#define POSZ_TOINT FloorC(GetPosZ())
#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,
etItemFrame,
etPainting,
// Common variations
etMob = etMonster, // DEPRECATED, use etMonster instead!
} ;
// tolua_end
enum eEntityStatus
{
// 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
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_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_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_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 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 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
cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, double a_Width, double a_Height);
virtual ~cEntity();
@ -151,9 +151,9 @@ public:
virtual bool Initialize(cWorld & a_World);
// tolua_begin
eEntityType GetEntityType(void) const { return m_EntityType; }
bool IsEnderCrystal(void) const { return (m_EntityType == etEnderCrystal); }
bool IsPlayer (void) const { return (m_EntityType == etPlayer); }
bool IsPickup (void) const { return (m_EntityType == etPickup); }
@ -168,16 +168,16 @@ public:
bool IsFloater (void) const { return (m_EntityType == etFloater); }
bool IsItemFrame (void) const { return (m_EntityType == etItemFrame); }
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)
virtual bool IsA(const char * a_ClassName) const;
/** Returns the class name of this class */
static const char * GetClassStatic(void);
/** Returns the topmost class name for the object */
virtual const char * GetClass(void) const;
/** Returns the topmost class's parent class name for the object. cEntity returns an empty string (no parent). */
virtual const char * GetParentClass(void) const;
@ -200,9 +200,9 @@ public:
double GetSpeedY (void) const { return m_Speed.y; }
double GetSpeedZ (void) const { return m_Speed.z; }
double GetWidth (void) const { return m_Width; }
int GetChunkX(void) const {return static_cast<int>(floor(m_Pos.x / cChunkDef::Width)); }
int GetChunkZ(void) const {return static_cast<int>(floor(m_Pos.z / cChunkDef::Width)); }
int GetChunkX(void) const {return (int)floor(m_Pos.x / cChunkDef::Width); }
int GetChunkZ(void) const {return (int)floor(m_Pos.z / cChunkDef::Width); }
void SetHeadYaw (double a_HeadYaw);
void SetHeight (double a_Height);
@ -219,21 +219,21 @@ public:
/** Sets the speed of the entity, measured in m / sec */
void SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ);
/** 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); }
/** Sets the speed in the X axis, leaving the other speed components intact. Measured in m / sec. */
void SetSpeedX(double a_SpeedX);
/** Sets the speed in the Y axis, leaving the other speed components intact. Measured in m / sec. */
void SetSpeedY(double a_SpeedY);
/** Sets the speed in the Z axis, leaving the other speed components intact. Measured in m / sec. */
void SetSpeedZ(double a_SpeedZ);
void SetWidth (double a_Width);
void AddPosX (double a_AddPosX);
void AddPosY (double a_AddPosY);
void AddPosZ (double a_AddPosZ);
@ -244,7 +244,7 @@ public:
void AddSpeedX (double a_AddSpeedX);
void AddSpeedY (double a_AddSpeedY);
void AddSpeedZ (double a_AddSpeedZ);
virtual void HandleSpeedFromAttachee(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
void TakeDamage(cEntity & a_Attacker);
/// 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);
/// 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);
float GetGravity(void) const { return m_Gravity; }
void SetGravity(float a_Gravity) { m_Gravity = a_Gravity; }
/// Sets the rotation to match the speed vector (entity goes "face-forward")
void SetYawFromSpeed(void);
/// Sets the pitch to match the speed vector (entity gies "face-forward")
void SetPitchFromSpeed(void);
// tolua_end
/** Makes this entity take damage specified in the a_TDI.
The TDI is sent through plugins first, then applied.
If it returns false, the entity hasn't receive any damage. */
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI);
// tolua_begin
/// Returns the hitpoints that this pawn can deal to a_Receiver using its equipped items
virtual int GetRawDamageAgainst(const cEntity & a_Receiver);
/** Returns whether armor will protect against the passed damage type **/
virtual bool ArmorCoversAgainst(eDamageType a_DamageType);
/// 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);
/// Returns the knockback amount that the currently equipped items would cause to a_Receiver on a hit
virtual double GetKnockbackAmountAgainst(const cEntity & a_Receiver);
/// Returns the curently equipped weapon; empty item if none
virtual cItem GetEquippedWeapon(void) const { return cItem(); }
/// Returns the currently equipped helmet; empty item if none
virtual cItem GetEquippedHelmet(void) const { return cItem(); }
/// Returns the currently equipped chestplate; empty item if none
virtual cItem GetEquippedChestplate(void) const { return cItem(); }
/// Returns the currently equipped leggings; empty item if none
virtual cItem GetEquippedLeggings(void) const { return cItem(); }
/// Returns the currently equipped boots; empty item if none
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);
/// Called when the entity kills another entity
@ -317,20 +317,20 @@ public:
/// Heals the specified amount of HPs
virtual void Heal(int a_HitPoints);
/// Returns the health of this entity
int GetHealth(void) const { return m_Health; }
/// Sets the health of this entity; doesn't broadcast any hurt animation
void SetHealth(int a_Health);
// tolua_end
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
virtual void HandlePhysics(float a_Dt, cChunk & a_Chunk);
/// Updates the state related to this entity being on fire
virtual void TickBurning(cChunk & a_Chunk);
@ -341,34 +341,34 @@ public:
Returns true if MoveToWorld() was called, false if not
*/
virtual bool DetectPortal(void);
/// Handles when the entity is in the void
virtual void TickInVoid(cChunk & a_Chunk);
/// Called when the entity starts burning
virtual void OnStartedBurning(void);
/// Called when the entity finishes burning
virtual void OnFinishedBurning(void);
// tolua_begin
/// Sets the maximum value for the health
void SetMaxHealth(int a_MaxHealth);
int GetMaxHealth(void) const { return m_MaxHealth; }
/// Sets whether the entity is fireproof
void SetIsFireproof(bool a_IsFireproof);
bool IsFireproof(void) const { return m_IsFireproof; }
/// Puts the entity on fire for the specified amount of ticks
void StartBurning(int a_TicksLeftBurning);
/// Stops the entity from burning, resets all burning timers
void StopBurning(void);
// tolua_end
/** 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;
// tolua_begin
/// Teleports to the entity specified
virtual void TeleportToEntity(cEntity & a_Entity);
/// Teleports to the coordinates specified
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 */
bool MoveToWorld(const AString & a_WorldName, bool a_ShouldSendRespawn = true);
// tolua_end
virtual bool DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn);
@ -399,16 +399,16 @@ public:
/** Sets the world the entity will be leaving */
void SetWorldTravellingFrom(cWorld * a_World) { m_WorldTravellingFrom = a_World; }
/// 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
void AttachTo(cEntity * a_AttachTo);
/// Detaches from the currently attached entity, if any
virtual void Detach(void);
/// Makes sure head yaw is not over the specified range.
void WrapHeadYaw();
@ -417,9 +417,9 @@ public:
/// Makes speed is not over 20. Max speed is 20 blocks / second
void WrapSpeed();
// tolua_begin
// COMMON metadata flags; descendants may override the defaults:
virtual bool IsOnFire (void) const {return (m_TicksLeftBurning > 0); }
virtual bool IsCrouched (void) const {return false; }
@ -437,20 +437,20 @@ public:
/** Gets number of ticks this entity has existed for */
long int GetTicksAlive(void) const { return m_TicksAlive; }
/** Gets the invulnerable ticks from the entity */
int GetInvulnerableTicks(void) const { return m_InvulnerableTicks; }
/** Set the invulnerable ticks from the entity */
void SetInvulnerableTicks(int a_InvulnerableTicks) { m_InvulnerableTicks = a_InvulnerableTicks; }
// tolua_end
/// Called when the specified player right-clicks this entity
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().
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_Killer);
@ -462,38 +462,38 @@ public:
protected:
static cCriticalSection m_CSCount;
static int m_EntityCount;
/** Measured in meter/second (m/s) */
Vector3d m_Speed;
int m_UniqueID;
int m_Health;
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;
/// 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;
/** Stores whether head yaw has been set manually */
bool m_bDirtyHead;
/** Stores whether our yaw/pitch/roll (body orientation) has been set manually */
bool m_bDirtyOrientation;
/** 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 */
bool m_bHasSentNoSpeed;
/** Stores if the entity is on the ground */
bool m_bOnGround;
/** 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 */
float m_Gravity;
/** Last position sent to client via the Relative Move or Teleport packets (not Velocity)
Only updated if cEntity::BroadcastMovementUpdate() is called! */
Vector3d m_LastPos;
@ -502,37 +502,37 @@ protected:
bool m_IsInitialized;
/** 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
*/
cWorld * m_WorldTravellingFrom;
eEntityType m_EntityType;
cWorld * m_World;
/// Whether the entity is capable of taking fire or lava damage.
bool m_IsFireproof;
/// Time, in ticks, since the last damage dealt by being on fire. Valid only if on fire (IsOnFire())
int m_TicksSinceLastBurnDamage;
/// Time, in ticks, since the last damage dealt by standing in lava. Reset to zero when moving out of lava.
int m_TicksSinceLastLavaDamage;
/// Time, in ticks, since the last damage dealt by standing in fire. Reset to zero when moving out of fire.
int m_TicksSinceLastFireDamage;
/// Time, in ticks, until the entity extinguishes its fire
int m_TicksLeftBurning;
/// Time, in ticks, since the last damage dealt by the void. Reset to zero when moving out of the void.
int m_TicksSinceLastVoidDamage;
/** 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. */
virtual void DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ);
virtual void Destroyed(void) {} // Called after the entity has been destroyed
/** Applies friction to an entity
@ -543,7 +543,7 @@ protected:
/** Called in each tick to handle air-related processing i.e. drowning */
virtual void HandleAir(void);
/** Called once per tick to set IsSwimming and IsSubmerged */
virtual void SetSwimState(cChunk & a_Chunk);
@ -568,29 +568,29 @@ protected:
/** Portal delay timer and cooldown boolean data */
sPortalCooldownData m_PortalCooldownData;
/** The number of ticks this entity has been alive for */
long int m_TicksAlive;
private:
/** Measured in degrees, [-180, +180) */
double m_HeadYaw;
/** Measured in degrees, [-180, +180) */
Vector3d m_Rot;
/** Position of the entity's XZ center and Y bottom */
Vector3d m_Pos;
/** Measured in meter / second */
Vector3d m_WaterSpeed;
/** Measured in Kilograms (Kg) */
double m_Mass;
/** Width of the entity, in the XZ plane. Since entities are represented as cylinders, this is more of a diameter. */
double m_Width;
/** Height of the entity (Y axis) */
double m_Height;
@ -600,3 +600,7 @@ private:
} ; // tolua_export
typedef std::list<cEntity *> cEntityList;

View File

@ -216,7 +216,7 @@ cEntityEffect * cEntityEffect::CreateEntityEffect(cEntityEffect::eType a_EffectT
}
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())
{
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;
}
a_Target.Heal(amount);
@ -352,7 +352,7 @@ void cEntityEffectInstantDamage::OnActivate(cPawn & a_Target)
a_Target.Heal(amount);
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
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)
{
a_Target.TakeDamage(dtWither, NULL, 1, 0);
a_Target.TakeDamage(dtWither, nullptr, 1, 0);
}
}

View File

@ -1,6 +1,11 @@
//
// ExpBottleEntity.h
//
// ExpBottleEntity.h
// Declares the cExpBottleEntity class representing the thrown exp bottle
#pragma once
@ -33,6 +38,10 @@ protected:
/** Breaks the bottle, fires its particle effects and sounds
@param a_HitPos The position where the bottle will break */
void Break(const Vector3d &a_HitPos);
void Break(const Vector3d & a_HitPos);
}; // tolua_export

View File

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

View File

@ -1,6 +1,11 @@
//
// FireChargeEntity.h
//
// FireChargeEntity.h
// Declares the cFireChargeEntity representing the fire charge shot by the blaze
#pragma once
@ -34,3 +39,7 @@ protected:
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
} ; // tolua_export

View File

@ -10,7 +10,7 @@
cFireworkEntity::cFireworkEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem & a_Item) :
super(pkFirework, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25),
m_ExplodeTimer(0),
m_TicksToExplosion(a_Item.m_FireworkItem.m_FlightTimeInTicks),
m_FireworkItem(a_Item)
{
}
@ -27,7 +27,9 @@ void cFireworkEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
if ((PosY < 0) || (PosY >= cChunkDef::Height))
{
goto setspeed;
AddSpeedY(1);
AddPosition(GetSpeed() * (a_Dt / 1000));
return;
}
if (m_IsInGround)
@ -50,7 +52,6 @@ void cFireworkEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
}
}
setspeed:
AddSpeedY(1);
AddPosition(GetSpeed() * (a_Dt / 1000));
}
@ -63,11 +64,13 @@ void cFireworkEntity::Tick(float a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
if (m_ExplodeTimer == m_FireworkItem.m_FireworkItem.m_FlightTimeInTicks)
if (m_TicksToExplosion <= 0)
{
// TODO: Notify the plugins
m_World->BroadcastEntityStatus(*this, esFireworkExploding);
Destroy();
return;
}
m_ExplodeTimer++;
m_TicksToExplosion -= 1;
}

View File

@ -1,6 +1,11 @@
//
// FireworkEntity.h
//
// FireworkEntity.h
// Declares the cFireworkEntity class representing the flying firework rocket
#pragma once
@ -24,7 +29,22 @@ public:
CLASS_PROTODEF(cFireworkEntity)
cFireworkEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem & a_Item);
// tolua_begin
/** Returns the item used to create the rocket (has all the firework effects on it) */
const cItem & GetItem(void) const { return m_FireworkItem; }
/** Sets the item that is used to create the rocket (has all the firework effects on it) */
void SetItem(const cItem & a_Item) { m_FireworkItem = a_Item; }
/** Returns the number of ticks left until the firework explosion. */
int GetTicksToExplosion(void) const { return m_TicksToExplosion; }
/** Sets the number of ticks left until the firework explosion. */
void SetTicksToExplosion(int a_TicksToExplosion) { m_TicksToExplosion = a_TicksToExplosion; }
// tolua_end
protected:
@ -34,7 +54,11 @@ protected:
private:
int m_ExplodeTimer;
int m_TicksToExplosion;
cItem m_FireworkItem;
}; // tolua_export

View File

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

View File

@ -1,6 +1,11 @@
//
// GhastFireballEntity.h
//
// GhastFireballEntity.h
// Declares the cGhastFireballEntity class representing the ghast fireball in flight.
#pragma once
@ -36,3 +41,7 @@ protected:
// TODO: Deflecting the fireballs by arrow- or sword- hits
} ; // tolua_export

View File

@ -9,9 +9,9 @@
cHangingEntity::cHangingEntity(eEntityType a_EntityType, eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z)
: cEntity(a_EntityType, a_X, a_Y, a_Z, 0.8, 0.8)
, m_BlockFace(a_BlockFace)
cHangingEntity::cHangingEntity(eEntityType a_EntityType, eBlockFace a_Facing, double a_X, double a_Y, double a_Z) :
cEntity(a_EntityType, a_X, a_Y, a_Z, 0.8, 0.8),
m_Facing(a_Facing)
{
SetMaxHealth(1);
SetHealth(1);
@ -21,15 +21,23 @@ cHangingEntity::cHangingEntity(eEntityType a_EntityType, eBlockFace a_BlockFace,
void cHangingEntity::SetDirection(eBlockFace a_BlockFace)
void cHangingEntity::SetFacing(eBlockFace a_Facing)
{
if ((a_BlockFace < 2) || (a_BlockFace > 5))
// Y-based faces are not allowed:
switch (a_Facing)
{
ASSERT(!"Tried to set a bad direction!");
return;
case BLOCK_FACE_NONE:
case BLOCK_FACE_YM:
case BLOCK_FACE_YP:
{
LOGWARNING("%s: Invalid facing: %d. Ignoring.", __FUNCTION__, a_Facing);
ASSERT(!"Tried to set a bad facing!");
return;
}
default: break;
}
m_BlockFace = a_BlockFace;
m_Facing = a_Facing;
}
@ -41,7 +49,7 @@ void cHangingEntity::SpawnOn(cClientHandle & a_ClientHandle)
int Dir = 0;
// The client uses different values for item frame directions and block faces. Our constants are for the block faces, so we convert them here to item frame faces
switch (m_BlockFace)
switch (m_Facing)
{
case BLOCK_FACE_ZP: Dir = 0; break;
case BLOCK_FACE_ZM: Dir = 2; break;
@ -49,8 +57,8 @@ void cHangingEntity::SpawnOn(cClientHandle & a_ClientHandle)
case BLOCK_FACE_XP: Dir = 3; break;
default:
{
LOGINFO("Invalid face (%d) in a cHangingEntity at {%d, %d, %d}, adjusting to BLOCK_FACE_XP.",
m_BlockFace, (int)GetPosX(), (int)GetPosY(), (int)GetPosZ()
LOGINFO("Invalid facing (%d) in a cHangingEntity at {%d, %d, %d}, adjusting to BLOCK_FACE_XP.",
m_Facing, (int)GetPosX(), (int)GetPosY(), (int)GetPosZ()
);
Dir = 3;
}

View File

@ -11,36 +11,41 @@
class cHangingEntity :
public cEntity
{
// tolua_end
typedef cEntity super;
public:
// tolua_end
CLASS_PROTODEF(cHangingEntity)
cHangingEntity(eEntityType a_EntityType, eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z);
/** Returns the orientation from the hanging entity */
eBlockFace GetDirection() const { return m_BlockFace; } // tolua_export
// tolua_begin
/** Returns the direction in which the entity is facing. */
eBlockFace GetFacing() const { return m_Facing; }
/** Set the orientation from the hanging entity */
void SetDirection(eBlockFace a_BlockFace); // tolua_export
/** Set the direction in which the entity is facing. */
void SetFacing(eBlockFace a_Facing);
/** Returns the X coord. */
int GetTileX() const { return POSX_TOINT; } // tolua_export
/** Returns the X coord of the block in which the entity resides. */
int GetBlockX() const { return POSX_TOINT; }
/** Returns the Y coord. */
int GetTileY() const { return POSY_TOINT; } // tolua_export
/** Returns the Y coord of the block in which the entity resides. */
int GetBlockY() const { return POSY_TOINT; }
/** Returns the Z coord. */
int GetTileZ() const { return POSZ_TOINT; } // tolua_export
/** Returns the Z coord of the block in which the entity resides. */
int GetBlockZ() const { return POSZ_TOINT; }
// tolua_end
private:
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override {}
eBlockFace m_BlockFace;
eBlockFace m_Facing;
}; // tolua_export

View File

@ -9,10 +9,10 @@
cItemFrame::cItemFrame(eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z)
: cHangingEntity(etItemFrame, a_BlockFace, a_X, a_Y, a_Z)
, m_Item(E_BLOCK_AIR)
, m_Rotation(0)
cItemFrame::cItemFrame(eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z) :
cHangingEntity(etItemFrame, a_BlockFace, a_X, a_Y, a_Z),
m_Item(E_BLOCK_AIR),
m_ItemRotation(0)
{
}
@ -27,10 +27,10 @@ void cItemFrame::OnRightClicked(cPlayer & a_Player)
if (!m_Item.IsEmpty())
{
// Item not empty, rotate, clipping values to zero to three inclusive
m_Rotation++;
if (m_Rotation >= 8)
m_ItemRotation++;
if (m_ItemRotation >= 8)
{
m_Rotation = 0;
m_ItemRotation = 0;
}
}
else if (!a_Player.GetEquippedItem().IsEmpty())
@ -62,7 +62,7 @@ void cItemFrame::KilledBy(TakeDamageInfo & a_TDI)
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;
Item.push_back(m_Item);
@ -72,7 +72,7 @@ void cItemFrame::KilledBy(TakeDamageInfo & a_TDI)
SetHealth(GetMaxHealth());
m_Item.Empty();
m_Rotation = 0;
m_ItemRotation = 0;
SetInvulnerableTicks(0);
GetWorld()->BroadcastEntityMetadata(*this);
}
@ -83,7 +83,7 @@ void cItemFrame::KilledBy(TakeDamageInfo & a_TDI)
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));
}

View File

@ -11,26 +11,31 @@
class cItemFrame :
public cHangingEntity
{
// tolua_end
typedef cHangingEntity super;
public:
// tolua_end
CLASS_PROTODEF(cItemFrame)
cItemFrame(eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z);
// tolua_begin
/** Returns the item in the frame */
const cItem & GetItem(void) { return m_Item; } // tolua_export
const cItem & GetItem(void) { return m_Item; }
/** Set the item in the frame */
void SetItem(cItem & a_Item) { m_Item = a_Item; } // tolua_export
void SetItem(cItem & a_Item) { m_Item = a_Item; }
/** Returns the rotation from the item in the frame */
Byte GetRotation(void) const { return m_Rotation; } // tolua_export
Byte GetItemRotation(void) const { return m_ItemRotation; }
/** Set the rotation from the item in the frame */
void SetRotation(Byte a_Rotation) { m_Rotation = a_Rotation; } // tolua_export
void SetItemRotation(Byte a_ItemRotation) { m_ItemRotation = a_ItemRotation; }
// tolua_end
private:
@ -39,7 +44,7 @@ private:
virtual void GetDrops(cItems & a_Items, cEntity * a_Killer) override;
cItem m_Item;
Byte m_Rotation;
Byte m_ItemRotation;
}; // tolua_export

View File

@ -36,7 +36,7 @@ public:
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())
{
@ -130,7 +130,7 @@ void cMinecart::HandlePhysics(float a_Dt, cChunk & a_Chunk)
int RelPosX = POSX_TOINT - a_Chunk.GetPosX() * cChunkDef::Width;
int RelPosZ = POSZ_TOINT - a_Chunk.GetPosZ() * cChunkDef::Width;
cChunk * Chunk = a_Chunk.GetRelNeighborChunkAdjustCoords(RelPosX, RelPosZ);
if (Chunk == NULL)
if (Chunk == nullptr)
{
// Inside an unloaded chunk, bail out all processing
return;
@ -806,7 +806,7 @@ bool cMinecart::TestBlockCollision(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;
cChunkDef::BlockToChunk(POSX_TOINT, POSZ_TOINT, ChunkX, ChunkZ);
m_World->ForEachEntityInChunk(ChunkX, ChunkZ, MinecartCollisionCallback);
@ -980,7 +980,7 @@ bool cMinecart::TestEntityCollision(NIBBLETYPE a_RailMeta)
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();
TDI.FinalDamage = GetMaxHealth(); // Instant hit for creative
@ -1074,7 +1074,7 @@ void cRideableMinecart::OnRightClicked(cPlayer & a_Player)
{
super::OnRightClicked(a_Player);
if (m_Attachee != NULL)
if (m_Attachee != nullptr)
{
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:
cWindow * Window = GetWindow();
if (Window == NULL)
if (Window == nullptr)
{
OpenNewWindow();
Window = GetWindow();
}
// Open the window for the player:
if (Window != NULL)
if (Window != nullptr)
{
if (a_Player.GetWindow() != Window)
{

View File

@ -140,9 +140,9 @@ protected:
{
UNUSED(a_SlotNum);
ASSERT(a_Grid == &m_Contents);
if (m_World != NULL)
if (m_World != nullptr)
{
if (GetWindow() != NULL)
if (GetWindow() != nullptr)
{
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)
{
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));
}

View File

@ -11,15 +11,22 @@
class cPainting :
public cEntity
{
// tolua_end
typedef cEntity super;
public:
// tolua_end
CLASS_PROTODEF(cPainting)
cPainting(const AString & a_Name, int a_Direction, double a_X, double a_Y, double a_Z);
const AString & GetName(void) const { return m_Name; } // tolua_export
int GetDirection(void) const { return m_Direction; } // tolua_export
// tolua_begin
const AString & GetName(void) const { return m_Name; }
int GetDirection(void) const { return m_Direction; }
// tolua_end
private:

View File

@ -56,8 +56,8 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) :
m_Stance(0.0),
m_Inventory(*this),
m_EnderChestContents(9, 3),
m_CurrentWindow(NULL),
m_InventoryWindow(NULL),
m_CurrentWindow(nullptr),
m_InventoryWindow(nullptr),
m_GameMode(eGameMode_NotSet),
m_IP(""),
m_ClientHandle(a_Client),
@ -78,10 +78,10 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) :
m_IsChargingBow(false),
m_BowCharge(0),
m_FloaterID(-1),
m_Team(NULL),
m_Team(nullptr),
m_TicksUntilNextSave(PLAYER_INVENTORY_SAVE_INTERVAL),
m_bIsTeleporting(false),
m_UUID((a_Client != NULL) ? a_Client->GetUUID() : ""),
m_UUID((a_Client != nullptr) ? a_Client->GetUUID() : ""),
m_CustomName("")
{
m_InventoryWindow = new cInventoryWindow(*this);
@ -96,7 +96,7 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) :
m_PlayerName = a_PlayerName;
cWorld * World = NULL;
cWorld * World = nullptr;
if (!LoadFromDisk(World))
{
m_Inventory.Clear();
@ -144,10 +144,10 @@ cPlayer::~cPlayer(void)
SaveToDisk();
m_ClientHandle = NULL;
m_ClientHandle = nullptr;
delete m_InventoryWindow;
m_InventoryWindow = NULL;
m_InventoryWindow = nullptr;
LOGD("Player %p deleted", this);
}
@ -186,12 +186,12 @@ void cPlayer::SpawnOn(cClientHandle & a_Client)
void cPlayer::Tick(float a_Dt, cChunk & a_Chunk)
{
if (m_ClientHandle != NULL)
if (m_ClientHandle != nullptr)
{
if (m_ClientHandle->IsDestroyed())
{
// 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;
}
@ -503,7 +503,7 @@ void cPlayer::SetTouchGround(bool a_bTouchGround)
if (Damage > 0)
{
// 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
GetWorld()->BroadcastSoundParticleEffect(2006, POSX_TOINT, (int)GetPosY() - 1, POSZ_TOINT, Damage /* Used as particle effect speed modifier */);
@ -650,7 +650,7 @@ void cPlayer::AbortEating(void)
void cPlayer::SendHealth(void)
{
if (m_ClientHandle != NULL)
if (m_ClientHandle != nullptr)
{
m_ClientHandle->SendHealth();
}
@ -662,7 +662,7 @@ void cPlayer::SendHealth(void)
void cPlayer::SendExperience(void)
{
if (m_ClientHandle != NULL)
if (m_ClientHandle != nullptr)
{
m_ClientHandle->SendExperience();
m_bDirtyExperience = false;
@ -858,11 +858,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;
if ((m_Team != NULL) && (m_Team == Attacker->m_Team))
if ((m_Team != nullptr) && (m_Team == Attacker->m_Team))
{
if (!m_Team->AllowsFriendlyFire())
{
@ -914,7 +914,7 @@ void cPlayer::KilledBy(TakeDamageInfo & a_TDI)
m_World->SpawnItemPickups(Pickups, GetPosX(), GetPosY(), GetPosZ(), 10);
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;
switch (a_TDI.DamageType)
@ -940,7 +940,7 @@ void cPlayer::KilledBy(TakeDamageInfo & a_TDI)
}
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
}
@ -996,7 +996,7 @@ void cPlayer::Killed(cEntity * a_Victim)
void cPlayer::Respawn(void)
{
ASSERT(m_World != NULL);
ASSERT(m_World != nullptr);
m_Health = GetMaxHealth();
SetInvulnerableTicks(20);
@ -1106,9 +1106,9 @@ void cPlayer::SetTeam(cTeam * a_Team)
cTeam * cPlayer::UpdateTeam(void)
{
if (m_World == NULL)
if (m_World == nullptr)
{
SetTeam(NULL);
SetTeam(nullptr);
}
else
{
@ -1141,7 +1141,7 @@ void cPlayer::OpenWindow(cWindow * a_Window)
void cPlayer::CloseWindow(bool a_CanRefuse)
{
if (m_CurrentWindow == NULL)
if (m_CurrentWindow == nullptr)
{
m_CurrentWindow = m_InventoryWindow;
return;
@ -1166,7 +1166,7 @@ void cPlayer::CloseWindow(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;
}
@ -1353,7 +1353,7 @@ void cPlayer::MoveTo( const Vector3d & a_NewPos)
// 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
// the client may still send more of these nonsensical packets.
if (m_AttachedTo != NULL)
if (m_AttachedTo != nullptr)
{
Vector3d AddSpeed(a_NewPos);
AddSpeed.y = 0;
@ -1580,7 +1580,7 @@ void cPlayer::TossItems(const cItems & a_Items)
bool cPlayer::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn)
{
ASSERT(a_World != NULL);
ASSERT(a_World != nullptr);
if (GetWorld() == a_World)
{
@ -1589,7 +1589,7 @@ bool cPlayer::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn)
}
// Send the respawn packet:
if (a_ShouldSendRespawn && (m_ClientHandle != NULL))
if (a_ShouldSendRespawn && (m_ClientHandle != nullptr))
{
m_ClientHandle->SendRespawn(a_World->GetDimension());
}
@ -1651,7 +1651,7 @@ bool cPlayer::LoadFromDisk(cWorldPtr & a_World)
GetName().c_str(), m_UUID.c_str(), OfflineUUID.c_str(), OfflineUsage
);
if (a_World == NULL)
if (a_World == nullptr)
{
a_World = cRoot::Get()->GetDefaultWorld();
}
@ -1728,7 +1728,7 @@ bool cPlayer::LoadFromFile(const AString & a_FileName, cWorldPtr & a_World)
m_LoadedWorldName = root.get("world", "world").asString();
a_World = cRoot::Get()->GetWorld(GetLoadedWorldName(), false);
if (a_World == NULL)
if (a_World == nullptr)
{
a_World = cRoot::Get()->GetDefaultWorld();
}
@ -1794,7 +1794,7 @@ bool cPlayer::SaveToDisk()
root["SpawnY"] = GetLastBedPos().y;
root["SpawnZ"] = GetLastBedPos().z;
if (m_World != NULL)
if (m_World != nullptr)
{
root["world"] = m_World->GetName();
if (m_GameMode == m_World->GetGameMode())
@ -1948,7 +1948,7 @@ void cPlayer::HandleFood(void)
else if ((m_FoodLevel <= 0) && (m_Health > 1))
{
// Damage from starving
TakeDamage(dtStarving, NULL, 1, 1, 0);
TakeDamage(dtStarving, nullptr, 1, 1, 0);
}
}
}
@ -2017,7 +2017,7 @@ void cPlayer::UpdateMovementStats(const Vector3d & a_DeltaPos)
{
StatValue Value = (StatValue)floor(a_DeltaPos.Length() * 100 + 0.5);
if (m_AttachedTo == NULL)
if (m_AttachedTo == nullptr)
{
if (IsClimbing())
{
@ -2090,7 +2090,7 @@ void cPlayer::ApplyFoodExhaustionFromMovement()
}
// If riding anything, apply no food exhaustion
if (m_AttachedTo != NULL)
if (m_AttachedTo != nullptr)
{
return;
}

View File

@ -176,10 +176,10 @@ public:
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
/** Sets the player team, NULL if none */
/** Sets the player team, nullptr if none */
void SetTeam(cTeam * a_Team);
// tolua_end

View File

@ -135,7 +135,7 @@ public:
m_Pos(a_Pos),
m_NextPos(a_NextPos),
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),
m_ProjectileKind(a_Kind),
m_CreatorData(
((a_Creator != NULL) ? a_Creator->GetUniqueID() : -1),
((a_Creator != NULL) ? (a_Creator->IsPlayer() ? ((cPlayer *)a_Creator)->GetName() : "") : ""),
((a_Creator != NULL) ? a_Creator->GetEquippedWeapon().m_Enchantments : cEnchantments())
((a_Creator != nullptr) ? a_Creator->GetUniqueID() : -1),
((a_Creator != nullptr) ? (a_Creator->IsPlayer() ? ((cPlayer *)a_Creator)->GetName() : "") : ""),
((a_Creator != nullptr) ? a_Creator->GetEquippedWeapon().m_Enchantments : cEnchantments())
),
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)
{
Vector3d Speed;
if (a_Speed != NULL)
if (a_Speed != nullptr)
{
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 pkFirework:
{
ASSERT(a_Item != NULL);
ASSERT(a_Item != nullptr);
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);
@ -280,7 +280,7 @@ cProjectileEntity * cProjectileEntity::Create(eKind a_Kind, cEntity * a_Creator,
}
LOGWARNING("%s: Unknown projectile kind: %d", __FUNCTION__, a_Kind);
return NULL;
return nullptr;
}

View File

@ -1,7 +1,7 @@
// ProjectileEntity.h
// Declares the cProjectileEntity class representing the common base class for projectiles, as well as individual projectile types
// Declares the cProjectileEntity class representing the common base class for projectiles
@ -23,7 +23,7 @@ class cProjectileEntity :
typedef cEntity super;
public:
/// The kind of the projectile. The numbers correspond to the network type ID used for spawning via the 0x17 packet.
/** The kind of the projectile. The numbers correspond to the network type ID used for spawning them in the protocol. */
enum eKind
{
pkArrow = 60,
@ -46,24 +46,24 @@ 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, 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);
/// Called by the physics blocktracer when the entity hits another entity
/** Called by the physics blocktracer when the entity hits another entity */
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
{
UNUSED(a_EntityHit);
UNUSED(a_HitPos);
}
/// Called by Chunk when the projectile is eligible for player collection
/** Called by Chunk when the projectile is eligible for player collection */
virtual void CollectedBy(cPlayer & a_Dest);
// tolua_begin
/// Returns the kind of the projectile (fast class identification)
/** Returns the kind of the projectile (fast class identification) */
eKind GetProjectileKind(void) const { return m_ProjectileKind; }
/** Returns the unique ID of the entity who created this projectile
@ -76,15 +76,15 @@ public:
*/
AString GetCreatorName(void) const { return m_CreatorData.m_Name; }
/// Returns the string that is used as the entity type (class name) in MCA files
/** Returns the string that is used as the entity type (class name) in MCA files */
AString GetMCAClassName(void) const;
/// Returns true if the projectile has hit the ground and is stuck there
/** Returns true if the projectile has hit the ground and is stuck there */
bool IsInGround(void) const { return m_IsInGround; }
// tolua_end
/// Sets the internal InGround flag. To be used by MCA loader only!
/** Sets the internal InGround flag. To be used by MCA loader only! */
void SetIsInGround(bool a_IsInGround) { m_IsInGround = a_IsInGround; }
protected:
@ -110,11 +110,11 @@ protected:
eKind m_ProjectileKind;
/** 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;
/// True if the projectile has hit the ground and is stuck there
/** True if the projectile has hit the ground and is stuck there */
bool m_IsInGround;
// cEntity overrides:

View File

@ -1,6 +1,11 @@
//
// SplashPotionEntity.h
//
// SplashPotionEntity.h
// Declares the cSplashPotionEntity class representing a splash potion that has been thrown
#pragma once
@ -32,6 +37,7 @@ public:
const cItem & a_Item
);
// tolua_begin
cEntityEffect::eType GetEntityEffectType(void) const { return m_EntityEffectType; }
cEntityEffect GetEntityEffect(void) const { return m_EntityEffect; }
int GetPotionColor(void) const { return m_PotionColor; }
@ -39,6 +45,8 @@ public:
void SetEntityEffectType(cEntityEffect::eType a_EntityEffectType) { m_EntityEffectType = a_EntityEffectType; }
void SetEntityEffect(cEntityEffect a_EntityEffect) { m_EntityEffect = a_EntityEffect; }
void SetPotionColor(int a_PotionColor) { m_PotionColor = a_PotionColor; }
// tolua_end
protected:
@ -77,3 +85,7 @@ private:
/** Time in ticks to wait for the hit animation to begin before destroying */
int m_DestroyTimer;
} ; // tolua_export

View File

@ -44,6 +44,27 @@ void cThrownEggEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_Hit
void cThrownEggEntity::Tick(float a_Dt, cChunk & a_Chunk)
{
if (m_DestroyTimer > 0)
{
m_DestroyTimer--;
if (m_DestroyTimer == 0)
{
Destroy();
return;
}
}
else
{
super::Tick(a_Dt, a_Chunk);
}
}
void cThrownEggEntity::TrySpawnChicken(const Vector3d & a_HitPos)
{
if (m_World->GetTickRandomNumber(7) == 1)

View File

@ -1,6 +1,11 @@
//
// ThrownEggEntity.h
//
// ThrownEggEntity.h
// Declares the cThrownEggEntity class representing a regular thrown egg
#pragma once
@ -29,23 +34,8 @@ protected:
// cProjectileEntity overrides:
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
virtual void Tick (float a_Dt, cChunk & a_Chunk) override
{
if (m_DestroyTimer > 0)
{
m_DestroyTimer--;
if (m_DestroyTimer == 0)
{
Destroy();
return;
}
}
else
{
super::Tick(a_Dt, a_Chunk);
}
}
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
// Randomly decides whether to spawn a chicken where the egg lands.
void TrySpawnChicken(const Vector3d & a_HitPos);
@ -56,3 +46,7 @@ private:
int m_DestroyTimer;
} ; // tolua_export

View File

@ -1,3 +1,4 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "ThrownEnderPearlEntity.h"
@ -45,6 +46,27 @@ void cThrownEnderPearlEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d
void cThrownEnderPearlEntity::Tick(float a_Dt, cChunk & a_Chunk)
{
if (m_DestroyTimer > 0)
{
m_DestroyTimer--;
if (m_DestroyTimer == 0)
{
Destroy();
return;
}
}
else
{
super::Tick(a_Dt, a_Chunk);
}
}
void cThrownEnderPearlEntity::TeleportCreator(const Vector3d & a_HitPos)
{
if (m_CreatorData.m_Name.empty())

View File

@ -1,6 +1,11 @@
//
// ThrownEnderPearlEntity.h
//
// ThrownEnderPearlEntity.h
// Declares the cThrownEnderPeralEntity class representing an ender pearl being thrown
#pragma once
@ -29,23 +34,8 @@ protected:
// cProjectileEntity overrides:
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
virtual void Tick (float a_Dt, cChunk & a_Chunk) override
{
if (m_DestroyTimer > 0)
{
m_DestroyTimer--;
if (m_DestroyTimer == 0)
{
Destroy();
return;
}
}
else
{
super::Tick(a_Dt, a_Chunk);
}
}
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
/** Teleports the creator where the ender pearl lands */
void TeleportCreator(const Vector3d & a_HitPos);
@ -56,3 +46,7 @@ private:
int m_DestroyTimer;
} ; // tolua_export

View File

@ -43,3 +43,28 @@ void cThrownSnowballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d &
m_DestroyTimer = 5;
}
void cThrownSnowballEntity::Tick(float a_Dt, cChunk & a_Chunk)
{
if (m_DestroyTimer > 0)
{
m_DestroyTimer--;
if (m_DestroyTimer == 0)
{
Destroy();
return;
}
}
else
{
super::Tick(a_Dt, a_Chunk);
}
}

View File

@ -1,6 +1,11 @@
//
// ThrownSnowballEntity.h
//
// ThrownSnowballEntity.h
// Declares the cThrownSnowballEntity representing a snowball that has been thrown
#pragma once
@ -29,23 +34,8 @@ protected:
// cProjectileEntity overrides:
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
virtual void Tick (float a_Dt, cChunk & a_Chunk) override
{
if (m_DestroyTimer > 0)
{
m_DestroyTimer--;
if (m_DestroyTimer == 0)
{
Destroy();
return;
}
}
else
{
super::Tick(a_Dt, a_Chunk);
}
}
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
private:
@ -53,3 +43,7 @@ private:
int m_DestroyTimer;
} ; // tolua_export

View File

@ -1,8 +1,12 @@
// WitherSkullEntity.h
// WitherSkullEntity.h
// Declares the cWitherSkullEntity class representing the entity used by both blue and black wither skulls
#pragma once
#include "ProjectileEntity.h"
@ -30,6 +34,10 @@ protected:
// cProjectileEntity overrides:
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
} ; // tolua_export

View File

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

View File

@ -32,7 +32,7 @@ public:
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;
/** 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()
{
delete[] m_CacheData;
m_CacheData = NULL;
m_CacheData = nullptr;
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";
}
cBiomeGen * res = NULL;
cBiomeGen * res = nullptr;
a_CacheOffByDefault = false;
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:
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
return NULL;
return nullptr;
}
m_BlockEntities.push_back(be);
return be;

View File

@ -172,7 +172,7 @@ public:
/** 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 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);
/** Updates the heightmap to match the current contents.

View File

@ -28,9 +28,9 @@ const unsigned int QUEUE_SKIP_LIMIT = 500;
cChunkGenerator::cChunkGenerator(void) :
super("cChunkGenerator"),
m_Seed(0), // Will be overwritten by the actual generator
m_Generator(NULL),
m_PluginInterface(NULL),
m_ChunkSink(NULL)
m_Generator(nullptr),
m_PluginInterface(nullptr),
m_ChunkSink(nullptr)
{
}
@ -80,7 +80,7 @@ bool cChunkGenerator::Start(cPluginInterface & a_PluginInterface, cChunkSink & a
m_Generator = new cComposableGenerator(*this);
}
if (m_Generator == NULL)
if (m_Generator == nullptr)
{
LOGERROR("Generator could not start, aborting the server");
return false;
@ -103,7 +103,7 @@ void cChunkGenerator::Stop(void)
Wait();
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)
{
if (m_Generator != NULL)
if (m_Generator != nullptr)
{
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)
{
ASSERT(m_Generator != NULL);
ASSERT(m_Generator != nullptr);
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)
{
ASSERT(m_PluginInterface != NULL);
ASSERT(m_ChunkSink != NULL);
ASSERT(m_PluginInterface != nullptr);
ASSERT(m_ChunkSink != nullptr);
ASSERT(m_ChunkSink->IsChunkQueued(a_ChunkX, a_ChunkZ));
cChunkDesc ChunkDesc(a_ChunkX, a_ChunkZ);

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