1
0

Merge branch 'master' into Inventory

This commit is contained in:
Howaner 2014-07-26 13:27:27 +02:00
commit ef4d68adfd
257 changed files with 3251 additions and 2012 deletions

2
.gitignore vendored
View File

@ -15,6 +15,7 @@ cloc.xsl
*.suo
/EveryNight.cmd
/UploadLuaAPI.cmd
AllFiles.lst
# IDE Stuff
## Sublime Text
@ -65,6 +66,7 @@ lib/tolua++/tolua
src/Bindings/Bindings.*
src/Bindings/BindingDependecies.txt
MCServer.dir/
src/AllFiles.lst
#win32 cmake stuff
*.vcxproj

View File

@ -28,5 +28,6 @@ UltraCoderRU
worktycho
xoft
Yeeeeezus (Donated AlchemistVillage prefabs)
Howaner
Please add yourself to this list if you contribute to MCServer.

View File

@ -1155,6 +1155,7 @@ These ItemGrids are available in the API and can be manipulated by the plugins,
HasItems = { Params = "{{cItem|cItem}}", Return = "bool", Notes = "Returns true if there are at least as many items of the specified type as in the parameter" },
HowManyCanFit = { Params = "{{cItem|cItem}}", Return = "number", Notes = "Returns the number of the specified items that can fit in the storage, including empty slots" },
HowManyItems = { Params = "{{cItem|cItem}}", Return = "number", Notes = "Returns the number of the specified items that are currently stored" },
RemoveItem = { Params = "{{cItem}}", Return = "number", Notes = "Removes the specified item from the inventory, as many as possible, up to the item's m_ItemCount. Returns the number of items that were removed." },
RemoveOneEquippedItem = { Params = "", Return = "", Notes = "Removes one item from the hotbar's currently selected slot" },
SetArmorSlot = { Params = "ArmorSlotNum, {{cItem|cItem}}", Return = "", Notes = "Sets the specified armor slot contents" },
SetEquippedSlotNum = { Params = "EquippedSlotNum", Return = "", Notes = "Sets the currently selected hotbar slot number" },
@ -1384,6 +1385,7 @@ local Item5 = cItem(E_ITEM_DIAMOND_CHESTPLATE, 1, 0, "thorns=1;unbreaking=3");
{ Params = "SlotNum", Return = "bool", Notes = "Returns true if the specified slot is empty, or an invalid slot is specified" },
{ Params = "X, Y", Return = "bool", Notes = "Returns true if the specified slot is empty, or an invalid slot is specified" },
},
RemoveItem = { Params = "{{cItem}}", Return = "number", Notes = "Removes the specified item from the grid, as many as possible, up to the item's m_ItemCount. Returns the number of items that were removed." },
RemoveOneItem =
{
{ Params = "SlotNum", Return = "{{cItem|cItem}}", Notes = "Removes one item from the stack in the specified slot and returns it as a single cItem. Empty slots are skipped and an empty item is returned" },

View File

@ -2,7 +2,7 @@ return
{
HOOK_PLAYER_USED_BLOCK =
{
CalledWhen = "A player has just used a block (chest, furnace). Notification only.",
CalledWhen = "A player has just used a block (chest, furnace...). Notification only.",
DefaultFnName = "OnPlayerUsedBlock", -- also used as pagename
Desc = [[
This hook is called after a {{cPlayer|player}} has right-clicked a block that can be used, such as a

View File

@ -60,9 +60,10 @@ function Initialize(Plugin)
PM:BindCommand("/ff", "debuggers", HandleFurnaceFuel, "- Shows how long the currently held item would burn in a furnace");
PM:BindCommand("/sched", "debuggers", HandleSched, "- Schedules a simple countdown using cWorld:ScheduleTask()");
PM:BindCommand("/cs", "debuggers", HandleChunkStay, "- Tests the ChunkStay Lua integration for the specified chunk coords");
PM:BindCommand("/compo", "debuggers", HandleCompo, "- Tests the cCompositeChat bindings")
PM:BindCommand("/sb", "debuggers", HandleSetBiome, "- Sets the biome around you to the specified one")
PM:BindCommand("/wesel", "debuggers", HandleWESel, "- Expands the current WE selection by 1 block in X/Z")
PM:BindCommand("/compo", "debuggers", HandleCompo, "- Tests the cCompositeChat bindings");
PM:BindCommand("/sb", "debuggers", HandleSetBiome, "- Sets the biome around you to the specified one");
PM:BindCommand("/wesel", "debuggers", HandleWESel, "- Expands the current WE selection by 1 block in X/Z");
PM:BindCommand("/rmitem", "debuggers", HandleRMItem, "- Remove the specified item from the inventory.");
Plugin:AddWebTab("Debuggers", HandleRequest_Debuggers)
Plugin:AddWebTab("StressTest", HandleRequest_StressTest)
@ -533,7 +534,7 @@ function OnTakeDamage(Receiver, TDI)
-- Receiver is cPawn
-- TDI is TakeDamageInfo
LOG(Receiver:GetClass() .. " was dealt " .. DamageTypeToString(TDI.DamageType) .. " damage: Raw " .. TDI.RawDamage .. ", Final " .. TDI.FinalDamage .. " (" .. (TDI.RawDamage - TDI.FinalDamage) .. " covered by armor)");
-- LOG(Receiver:GetClass() .. " was dealt " .. DamageTypeToString(TDI.DamageType) .. " damage: Raw " .. TDI.RawDamage .. ", Final " .. TDI.FinalDamage .. " (" .. (TDI.RawDamage - TDI.FinalDamage) .. " covered by armor)");
return false;
end
@ -1105,6 +1106,41 @@ end
function HandleRMItem(a_Split, a_Player)
-- Check params:
if (a_Split[2] == nil) then
a_Player:SendMessage("Usage: /rmitem <Item> [Count]")
return true
end
-- Parse the item type:
local Item = cItem()
if (not StringToItem(a_Split[2], Item)) then
a_Player:SendMessageFailure(a_Split[2] .. " isn't a valid item")
return true
end
-- Parse the optional item count
if (a_Split[3] ~= nil) then
local Count = tonumber(a_Split[3])
if (Count == nil) then
a_Player:SendMessageFailure(a_Split[3] .. " isn't a valid number")
return true
end
Item.m_ItemCount = Count
end
-- Remove the item:
local NumRemovedItems = a_Player:GetInventory():RemoveItem(Item)
a_Player:SendMessageSuccess("Removed " .. NumRemovedItems .. " Items!")
return true
end
function HandleRequest_Debuggers(a_Request)
local FolderContents = cFile:GetFolderContents("./");
return "<p>The following objects have been returned by cFile:GetFolderContents():<ul><li>" .. table.concat(FolderContents, "</li><li>") .. "</li></ul></p>";

View File

@ -5,7 +5,7 @@ MCServer is a Minecraft server that is written in C++ and designed to be efficie
MCServer can run on PCs, Macs, and *nix. This includes android phones and tablets as well as Raspberry Pis.
We currently support the protocol from Minecraft 1.2 all the way up to Minecraft 1.7.9.
We currently support the protocol from Minecraft 1.2 all the way up to Minecraft 1.7.10.
Installation
------------

View File

@ -28,7 +28,7 @@ endmacro()
macro(set_flags)
# Add coverage processing, if requested:
if (NOT MSVC)
if (CMAKE_BUILD_TYPE STREQUAL "COVERAGE")
message("Including CodeCoverage")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/lib/cmake-coverage/")
@ -85,7 +85,7 @@ macro(set_flags)
# We use a signed char (fixes #640 on RasPi)
add_flags_cxx("-fsigned-char")
endif()
@ -202,7 +202,7 @@ macro(enable_profile)
set(CMAKE_CONFIGURATION_TYPES "Debug;Release;DebugProfile;ReleaseProfile;Coverage" CACHE STRING "" FORCE)
endif()
endmacro()
macro(set_exe_flags)
# Remove disabling the maximum warning level:
# clang does not like a command line that reads -Wall -Wextra -w -Wall -Wextra and does not output any warnings
@ -216,22 +216,22 @@ macro(set_exe_flags)
string(REPLACE "-w" "" CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_COVERAGE}")
string(REPLACE "-w" "" CMAKE_C_FLAGS_COVERAGE "${CMAKE_C_FLAGS_COVERAGE}")
add_flags_cxx("-Wall -Wextra -Wno-unused-parameter -Wno-error=switch")
# we support non-IEEE 754 fpus so can make no guarentees about error
add_flags_cxx("-ffast-math")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# clang does not provide the __extern_always_inline macro and a part of libm depends on this when using fast-math
add_flags_cxx("-D__extern_always_inline=inline")
add_flags_cxx("-Werror -Weverything -Wno-c++98-compat-pedantic -Wno-string-conversion")
add_flags_cxx("-Wno-extra-semi -Wno-error=switch-enum -Wno-documentation")
add_flags_cxx("-Wno-error=switch-enum -Wno-documentation -Wno-exit-time-destructors")
add_flags_cxx("-Wno-error=sign-conversion -Wno-error=conversion -Wno-padded")
add_flags_cxx("-Wno-error=deprecated -Wno-error=weak-vtables -Wno-error=float-equal")
add_flags_cxx("-Wno-error=missing-prototypes -Wno-error=non-virtual-dtor")
add_flags_cxx("-Wno-error=covered-switch-default -Wno-error=shadow")
add_flags_cxx("-Wno-error=covered-switch-default -Wno-error=shadow -Wno-error=old-style-cast")
add_flags_cxx("-Wno-error=exit-time-destructors -Wno-error=missing-variable-declarations")
add_flags_cxx("-Wno-error=global-constructors -Wno-implicit-fallthrough")
add_flags_cxx("-Wno-weak-vtables -Wno-switch-enum -Wno-exit-time-destructors")
add_flags_cxx("-Wno-error=extra-semi -Wno-weak-vtables -Wno-switch-enum")
endif()
endif()

View File

@ -240,7 +240,7 @@ template <typename Type> class cItemCallback
public:
/// Called for each item in the internal list; return true to stop the loop, or false to continue enumerating
virtual bool Item(Type * a_Type) = 0;
virtual ~cItemCallback() {};
virtual ~cItemCallback() {}
} ;

@ -1 +1 @@
Subproject commit 784b04ff9afd5faeaeb15c3fa159ff98adf55182
Subproject commit 1ed82759c68f92c4acc7e3f33b850cf9f01c8aba

135
src/Bindings/CMakeLists.txt Normal file
View File

@ -0,0 +1,135 @@
cmake_minimum_required (VERSION 2.6)
project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
include_directories (".")
SET (SRCS
Bindings.cpp
DeprecatedBindings.cpp
LuaChunkStay.cpp
LuaState.cpp
LuaWindow.cpp
ManualBindings.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
)
# 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}/LuaState_Call.inc
)
set(BINDING_DEPENDENCIES
tolua
../Bindings/virtual_method_hooks.lua
../Bindings/AllToLua.pkg
../Bindings/gen_LuaState_Call.lua
../Bindings/LuaFunctions.h
../Bindings/LuaState_Call.inc
../Bindings/LuaWindow.h
../Bindings/Plugin.h
../Bindings/PluginLua.h
../Bindings/PluginManager.h
../Bindings/WebPlugin.h
../BiomeDef.h
../BlockArea.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
../Group.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}
# 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}
)
endif ()
set_source_files_properties(Bindings/Bindings.cpp PROPERTIES GENERATED TRUE)
set_source_files_properties(Bindings/Bindings.h PROPERTIES GENERATED TRUE)
if(NOT MSVC)
add_library(Bindings ${SRCS} ${HDRS})
target_link_libraries(Bindings lua sqlite tolualib polarssl)
endif()

View File

@ -25,9 +25,9 @@ static int tolua_get_AllToLua_g_BlockLightValue(lua_State* tolua_S)
#ifndef TOLUA_RELEASE
{
tolua_Error tolua_err;
if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
{
tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
}
}
#endif
@ -36,7 +36,7 @@ static int tolua_get_AllToLua_g_BlockLightValue(lua_State* tolua_S)
{
tolua_error(tolua_S, "array indexing out of range.", NULL);
}
tolua_pushnumber(tolua_S,(lua_Number)cBlockInfo::GetLightValue((BLOCKTYPE)BlockType));
tolua_pushnumber(tolua_S, (lua_Number)cBlockInfo::GetLightValue((BLOCKTYPE)BlockType));
return 1;
}
#endif // #ifndef TOLUA_DISABLE
@ -53,8 +53,8 @@ static int tolua_get_AllToLua_g_BlockSpreadLightFalloff(lua_State* tolua_S)
#ifndef TOLUA_RELEASE
{
tolua_Error tolua_err;
if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
}
#endif
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
@ -79,8 +79,8 @@ static int tolua_get_AllToLua_g_BlockTransparent(lua_State* tolua_S)
#ifndef TOLUA_RELEASE
{
tolua_Error tolua_err;
if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
}
#endif
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
@ -105,8 +105,8 @@ static int tolua_get_AllToLua_g_BlockOneHitDig(lua_State* tolua_S)
#ifndef TOLUA_RELEASE
{
tolua_Error tolua_err;
if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
}
#endif
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
@ -131,8 +131,8 @@ static int tolua_get_AllToLua_g_BlockPistonBreakable(lua_State* tolua_S)
#ifndef TOLUA_RELEASE
{
tolua_Error tolua_err;
if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
}
#endif
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
@ -157,8 +157,8 @@ static int tolua_get_AllToLua_g_BlockIsSnowable(lua_State* tolua_S)
#ifndef TOLUA_RELEASE
{
tolua_Error tolua_err;
if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
}
#endif
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
@ -175,32 +175,6 @@ static int tolua_get_AllToLua_g_BlockIsSnowable(lua_State* tolua_S)
/* get function: g_BlockRequiresSpecialTool */
#ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockRequiresSpecialTool
static int tolua_get_AllToLua_g_BlockRequiresSpecialTool(lua_State* tolua_S)
{
int BlockType;
#ifndef TOLUA_RELEASE
{
tolua_Error tolua_err;
if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
}
#endif
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_pushboolean(tolua_S, cBlockInfo::RequiresSpecialTool((BLOCKTYPE)BlockType));
return 1;
}
#endif // #ifndef TOLUA_DISABLE
/* get function: g_BlockIsSolid */
#ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockIsSolid
static int tolua_get_AllToLua_g_BlockIsSolid(lua_State* tolua_S)
@ -209,8 +183,8 @@ static int tolua_get_AllToLua_g_BlockIsSolid(lua_State* tolua_S)
#ifndef TOLUA_RELEASE
{
tolua_Error tolua_err;
if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
}
#endif
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
@ -235,8 +209,8 @@ static int tolua_get_AllToLua_g_BlockFullyOccupiesVoxel(lua_State* tolua_S)
#ifndef TOLUA_RELEASE
{
tolua_Error tolua_err;
if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
}
#endif
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
@ -263,7 +237,6 @@ void DeprecatedBindings::Bind(lua_State * tolua_S)
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_BlockRequiresSpecialTool", tolua_get_AllToLua_g_BlockRequiresSpecialTool, 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);

View File

@ -4,5 +4,5 @@ struct lua_State;
class DeprecatedBindings
{
public:
static void Bind( lua_State* tolua_S );
static void Bind( lua_State* tolua_S);
};

View File

@ -9,7 +9,7 @@ inline unsigned int GetTime()
return (unsigned int)time(0);
}
inline std::string GetChar( std::string & a_Str, unsigned int a_Idx )
inline std::string GetChar( std::string & a_Str, unsigned int a_Idx)
{
return std::string(1, a_Str[ a_Idx ]);
}

View File

@ -1336,9 +1336,8 @@ void cLuaState::LogStack(lua_State * a_LuaState, const char * a_Header)
{
UNUSED(a_Header); // The param seems unused when compiling for release, so the compiler warns
// Format string consisting only of %s is used to appease the compiler
LOGD("%s",(a_Header != NULL) ? a_Header : "Lua C API Stack contents:");
LOGD("%s", (a_Header != NULL) ? a_Header : "Lua C API Stack contents:");
for (int i = lua_gettop(a_LuaState); i > 0; i--)
{
AString Value;

View File

@ -319,9 +319,9 @@ static int tolua_DoWith(lua_State* tolua_S)
{
public:
cLuaCallback(lua_State* a_LuaState, int a_FuncRef, int a_TableRef)
: LuaState( a_LuaState )
, FuncRef( a_FuncRef )
, TableRef( a_TableRef )
: LuaState( a_LuaState)
, FuncRef( a_FuncRef)
, TableRef( a_TableRef)
{}
private:
@ -358,7 +358,7 @@ static int tolua_DoWith(lua_State* tolua_S)
luaL_unref(tolua_S, LUA_REGISTRYINDEX, FuncRef);
/* Push return value on stack */
tolua_pushboolean(tolua_S, bRetVal );
tolua_pushboolean(tolua_S, bRetVal);
return 1;
}
@ -448,7 +448,7 @@ static int tolua_DoWithID(lua_State* tolua_S)
luaL_unref(tolua_S, LUA_REGISTRYINDEX, FuncRef);
/* Push return value on stack */
tolua_pushboolean(tolua_S, bRetVal );
tolua_pushboolean(tolua_S, bRetVal);
return 1;
}
@ -478,7 +478,7 @@ static int tolua_DoWithXYZ(lua_State* tolua_S)
int ItemX = ((int)tolua_tonumber(tolua_S, 2, 0));
int ItemY = ((int)tolua_tonumber(tolua_S, 3, 0));
int ItemZ = ((int)tolua_tonumber(tolua_S, 4, 0));
LOG("x %i y %i z %i", ItemX, ItemY, ItemZ );
LOG("x %i y %i z %i", ItemX, ItemY, ItemZ);
if (!lua_isfunction( tolua_S, 5))
{
return lua_do_error(tolua_S, "Error in function call '#funcname#': Expected a function for parameter #4");
@ -506,9 +506,9 @@ static int tolua_DoWithXYZ(lua_State* tolua_S)
{
public:
cLuaCallback(lua_State* a_LuaState, int a_FuncRef, int a_TableRef)
: LuaState( a_LuaState )
, FuncRef( a_FuncRef )
, TableRef( a_TableRef )
: LuaState( a_LuaState)
, FuncRef( a_FuncRef)
, TableRef( a_TableRef)
{}
private:
@ -544,7 +544,7 @@ static int tolua_DoWithXYZ(lua_State* tolua_S)
luaL_unref(tolua_S, LUA_REGISTRYINDEX, FuncRef);
/* Push return value on stack */
tolua_pushboolean(tolua_S, bRetVal );
tolua_pushboolean(tolua_S, bRetVal);
return 1;
}
@ -601,9 +601,9 @@ static int tolua_ForEachInChunk(lua_State * tolua_S)
{
public:
cLuaCallback(lua_State* a_LuaState, int a_FuncRef, int a_TableRef)
: LuaState( a_LuaState )
, FuncRef( a_FuncRef )
, TableRef( a_TableRef )
: LuaState( a_LuaState)
, FuncRef( a_FuncRef)
, TableRef( a_TableRef)
{}
private:
@ -640,7 +640,7 @@ static int tolua_ForEachInChunk(lua_State * tolua_S)
luaL_unref(tolua_S, LUA_REGISTRYINDEX, FuncRef);
/* Push return value on stack */
tolua_pushboolean(tolua_S, bRetVal );
tolua_pushboolean(tolua_S, bRetVal);
return 1;
}
@ -656,12 +656,12 @@ template<
static int tolua_ForEach(lua_State * tolua_S)
{
int NumArgs = lua_gettop(tolua_S) - 1; /* This includes 'self' */
if( NumArgs != 1 && NumArgs != 2)
if ((NumArgs != 1) && (NumArgs != 2))
{
return lua_do_error(tolua_S, "Error in function call '#funcname#': Requires 1 or 2 arguments, got %i", NumArgs);
}
Ty1 * self = (Ty1 *) tolua_tousertype(tolua_S, 1, NULL);
Ty1 * self = (Ty1 *)tolua_tousertype(tolua_S, 1, NULL);
if (self == NULL)
{
return lua_do_error(tolua_S, "Error in function call '#funcname#': Not called on an object instance");
@ -694,16 +694,16 @@ static int tolua_ForEach(lua_State * tolua_S)
{
public:
cLuaCallback(lua_State* a_LuaState, int a_FuncRef, int a_TableRef)
: LuaState( a_LuaState )
, FuncRef( a_FuncRef )
, TableRef( a_TableRef )
: LuaState( a_LuaState)
, FuncRef( a_FuncRef)
, TableRef( a_TableRef)
{}
private:
virtual bool Item(Ty2 * a_Item) override
{
lua_rawgeti( LuaState, LUA_REGISTRYINDEX, FuncRef); /* Push function reference */
tolua_pushusertype( LuaState, a_Item, Ty2::GetClassStatic() );
tolua_pushusertype( LuaState, a_Item, Ty2::GetClassStatic());
if (TableRef != LUA_REFNIL)
{
lua_rawgeti( LuaState, LUA_REGISTRYINDEX, TableRef); /* Push table reference */
@ -733,7 +733,7 @@ static int tolua_ForEach(lua_State * tolua_S)
luaL_unref(tolua_S, LUA_REGISTRYINDEX, FuncRef);
/* Push return value on stack */
tolua_pushboolean(tolua_S, bRetVal );
tolua_pushboolean(tolua_S, bRetVal);
return 1;
}
@ -958,7 +958,7 @@ tolua_lerror:
static int tolua_cWorld_TryGetHeight(lua_State * tolua_S)
{
// Exported manually, because tolua would require the out-only param a_Height to be used when calling
// Takes (a_World,) a_BlockX, a_BlockZ
// Takes a_World, a_BlockX, a_BlockZ
// Returns Height, IsValid
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
@ -1360,7 +1360,7 @@ static int tolua_cPluginManager_AddHook(lua_State * tolua_S)
static int tolua_cPluginManager_ForEachCommand(lua_State * tolua_S)
{
int NumArgs = lua_gettop(tolua_S) - 1; /* This includes 'self' */
if( NumArgs != 1)
if (NumArgs != 1)
{
LOGWARN("Error in function call 'ForEachCommand': Requires 1 argument, got %i", NumArgs);
return 0;
@ -1390,8 +1390,8 @@ static int tolua_cPluginManager_ForEachCommand(lua_State * tolua_S)
{
public:
cLuaCallback(lua_State * a_LuaState, int a_FuncRef)
: LuaState( a_LuaState )
, FuncRef( a_FuncRef )
: LuaState( a_LuaState)
, FuncRef( a_FuncRef)
{}
private:
@ -1437,7 +1437,7 @@ static int tolua_cPluginManager_ForEachCommand(lua_State * tolua_S)
static int tolua_cPluginManager_ForEachConsoleCommand(lua_State * tolua_S)
{
int NumArgs = lua_gettop(tolua_S) - 1; /* This includes 'self' */
if( NumArgs != 1)
if (NumArgs != 1)
{
LOGWARN("Error in function call 'ForEachConsoleCommand': Requires 1 argument, got %i", NumArgs);
return 0;
@ -1467,8 +1467,8 @@ static int tolua_cPluginManager_ForEachConsoleCommand(lua_State * tolua_S)
{
public:
cLuaCallback(lua_State * a_LuaState, int a_FuncRef)
: LuaState( a_LuaState )
, FuncRef( a_FuncRef )
: LuaState( a_LuaState)
, FuncRef( a_FuncRef)
{}
private:
@ -1926,28 +1926,28 @@ static int tolua_cPluginLua_AddWebTab(lua_State * tolua_S)
int Reference = LUA_REFNIL;
if (
tolua_isstring(tolua_S, 2, 0, &tolua_err ) &&
lua_isfunction(tolua_S, 3 )
tolua_isstring(tolua_S, 2, 0, &tolua_err) &&
lua_isfunction(tolua_S, 3)
)
{
Reference = luaL_ref(tolua_S, LUA_REGISTRYINDEX);
Title = ((std::string) tolua_tocppstring(tolua_S,2,0));
Title = ((std::string)tolua_tocppstring(tolua_S, 2, 0));
}
else
{
return tolua_do_error(tolua_S, "#ferror calling function '#funcname#'", &tolua_err);
}
if( Reference != LUA_REFNIL )
if (Reference != LUA_REFNIL)
{
if( !self->AddWebTab( Title.c_str(), tolua_S, Reference ) )
if (!self->AddWebTab(Title.c_str(), tolua_S, Reference))
{
luaL_unref( tolua_S, LUA_REGISTRYINDEX, Reference );
luaL_unref(tolua_S, LUA_REGISTRYINDEX, Reference);
}
}
else
{
LOGERROR("ERROR: cPluginLua:AddWebTab invalid function reference in 2nd argument (Title: \"%s\")", Title.c_str() );
LOGWARNING("cPluginLua:AddWebTab: invalid function reference in 2nd argument (Title: \"%s\")", Title.c_str());
}
return 0;
@ -1963,7 +1963,7 @@ static int tolua_cPluginLua_AddTab(lua_State* tolua_S)
LOGWARN("WARNING: Using deprecated function AddTab()! Use AddWebTab() instead. (plugin \"%s\" in folder \"%s\")",
self->GetName().c_str(), self->GetDirectory().c_str()
);
return tolua_cPluginLua_AddWebTab( tolua_S );
return tolua_cPluginLua_AddWebTab( tolua_S);
}
@ -2011,12 +2011,12 @@ static int tolua_md5(lua_State* tolua_S)
static int tolua_push_StringStringMap(lua_State* tolua_S, std::map< std::string, std::string >& a_StringStringMap )
static int tolua_push_StringStringMap(lua_State* tolua_S, std::map< std::string, std::string >& a_StringStringMap)
{
lua_newtable(tolua_S);
int top = lua_gettop(tolua_S);
for( std::map< std::string, std::string >::iterator it = a_StringStringMap.begin(); it != a_StringStringMap.end(); ++it )
for (std::map<std::string, std::string>::iterator it = a_StringStringMap.begin(); it != a_StringStringMap.end(); ++it)
{
const char* key = it->first.c_str();
const char* value = it->second.c_str();
@ -2060,11 +2060,11 @@ static int tolua_get_HTTPRequest_FormData(lua_State* tolua_S)
lua_newtable(tolua_S);
int top = lua_gettop(tolua_S);
for( std::map< std::string, HTTPFormData >::iterator it = FormData.begin(); it != FormData.end(); ++it )
for (std::map<std::string, HTTPFormData>::iterator it = FormData.begin(); it != FormData.end(); ++it)
{
lua_pushstring(tolua_S, it->first.c_str() );
tolua_pushusertype(tolua_S, &(it->second), "HTTPFormData" );
// lua_pushlstring(tolua_S, it->second.Value.c_str(), it->second.Value.size() ); // Might contain binary data
lua_pushstring(tolua_S, it->first.c_str());
tolua_pushusertype(tolua_S, &(it->second), "HTTPFormData");
// lua_pushlstring(tolua_S, it->second.Value.c_str(), it->second.Value.size()); // Might contain binary data
lua_settable(tolua_S, top);
}
@ -2109,12 +2109,12 @@ static int tolua_cWebPlugin_GetTabNames(lua_State * tolua_S)
lua_newtable(tolua_S);
int index = 1;
cWebPlugin::TabNameList::const_iterator iter = TabNames.begin();
while(iter != TabNames.end())
while (iter != TabNames.end())
{
const AString & FancyName = iter->first;
const AString & WebName = iter->second;
tolua_pushstring( tolua_S, WebName.c_str() ); // Because the WebName is supposed to be unique, use it as key
tolua_pushstring( tolua_S, FancyName.c_str() );
tolua_pushstring( tolua_S, WebName.c_str()); // Because the WebName is supposed to be unique, use it as key
tolua_pushstring( tolua_S, FancyName.c_str());
//
lua_rawset(tolua_S, -3);
++iter;
@ -2591,7 +2591,7 @@ static int tolua_cBlockArea_LoadFromSchematicFile(lua_State * tolua_S)
}
AString Filename = tolua_tostring(tolua_S, 2, 0);
bool res = cSchematicFileSerializer::LoadFromSchematicFile(*self,Filename);
bool res = cSchematicFileSerializer::LoadFromSchematicFile(*self, Filename);
tolua_pushboolean(tolua_S, res);
return 1;
}
@ -2651,7 +2651,7 @@ static int tolua_cBlockArea_SaveToSchematicFile(lua_State * tolua_S)
return 0;
}
AString Filename = tolua_tostring(tolua_S, 2, 0);
bool res = cSchematicFileSerializer::SaveToSchematicFile(*self,Filename);
bool res = cSchematicFileSerializer::SaveToSchematicFile(*self, Filename);
tolua_pushboolean(tolua_S, res);
return 1;
}
@ -3065,13 +3065,13 @@ 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_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);
tolua_variable(tolua_S,"FormData",tolua_get_HTTPRequest_FormData,0);
tolua_variable(tolua_S,"Params",tolua_get_HTTPRequest_Params,0);
tolua_variable(tolua_S,"PostParams",tolua_get_HTTPRequest_PostParams,0);
tolua_cclass(tolua_S, "HTTPRequest", "HTTPRequest", "", NULL);
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);
tolua_variable(tolua_S, "FormData", tolua_get_HTTPRequest_FormData, 0);
tolua_variable(tolua_S, "Params", tolua_get_HTTPRequest_Params, 0);
tolua_variable(tolua_S, "PostParams", tolua_get_HTTPRequest_PostParams, 0);
tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S, "cWebAdmin");

View File

@ -4,5 +4,5 @@ struct lua_State;
class ManualBindings
{
public:
static void Bind( lua_State* tolua_S );
static void Bind( lua_State* tolua_S);
};

View File

@ -33,7 +33,7 @@ class cPlugin
public:
// tolua_end
cPlugin( const AString & a_PluginDirectory );
cPlugin( const AString & a_PluginDirectory);
virtual ~cPlugin();
virtual void OnDisable(void) {}
@ -115,10 +115,10 @@ public:
virtual bool HandleConsoleCommand(const AStringVector & a_Split, cCommandOutputCallback & a_Output) = 0;
/// All bound commands are to be removed, do any language-dependent cleanup here
virtual void ClearCommands(void) {} ;
virtual void ClearCommands(void) {}
/// All bound console commands are to be removed, do any language-dependent cleanup here
virtual void ClearConsoleCommands(void) {} ;
virtual void ClearConsoleCommands(void) {}
// tolua_begin
const AString & GetName(void) const { return m_Name; }
@ -141,7 +141,7 @@ public:
E_SQUIRREL, // OBSOLETE, but kept in place to remind us of the horrors lurking in the history
};
PluginLanguage GetLanguage() { return m_Language; }
void SetLanguage( PluginLanguage a_Language ) { m_Language = a_Language; }
void SetLanguage( PluginLanguage a_Language) { m_Language = a_Language; }
private:
PluginLanguage m_Language;

View File

@ -1655,7 +1655,7 @@ int cPluginLua::CallFunctionFromForeignState(
AString cPluginLua::HandleWebRequest(const HTTPRequest * a_Request )
AString cPluginLua::HandleWebRequest(const HTTPRequest * a_Request)
{
cCSLock Lock(m_CriticalSection);
std::string RetVal = "";

View File

@ -144,7 +144,7 @@ public:
virtual const AString GetWebTitle(void) const {return GetName(); }
// cWebPlugin and WebAdmin stuff
virtual AString HandleWebRequest(const HTTPRequest * a_Request ) override;
virtual AString HandleWebRequest(const HTTPRequest * a_Request) override;
bool AddWebTab(const AString & a_Title, lua_State * a_LuaState, int a_FunctionReference); // >> EXPORTED IN MANUALBINDINGS <<
/** Binds the command to call the function specified by a Lua function reference. Simply adds to CommandMap. */

View File

@ -72,7 +72,7 @@ void cPluginManager::FindPlugins(void)
{
PluginMap::iterator thiz = itr;
++thiz;
m_Plugins.erase( itr );
m_Plugins.erase( itr);
itr = thiz;
continue;
}
@ -1432,11 +1432,11 @@ cPluginManager::CommandResult cPluginManager::HandleCommand(cPlayer * a_Player,
cPlugin * cPluginManager::GetPlugin( const AString & a_Plugin ) const
cPlugin * cPluginManager::GetPlugin( const AString & a_Plugin) const
{
for( PluginMap::const_iterator itr = m_Plugins.begin(); itr != m_Plugins.end(); ++itr )
for (PluginMap::const_iterator itr = m_Plugins.begin(); itr != m_Plugins.end(); ++itr)
{
if (itr->second == NULL ) continue;
if (itr->second == NULL) continue;
if (itr->second->GetName().compare(a_Plugin) == 0)
{
return itr->second;

View File

@ -163,7 +163,7 @@ public:
typedef std::map< AString, cPlugin * > PluginMap;
typedef std::list< cPlugin * > PluginList;
cPlugin * GetPlugin( const AString & a_Plugin ) const; // tolua_export
cPlugin * GetPlugin( const AString & a_Plugin) const; // tolua_export
const PluginMap & GetAllPlugins() const; // >> EXPORTED IN MANUALBINDINGS <<
// tolua_begin

View File

@ -45,12 +45,12 @@ cWebPlugin::~cWebPlugin()
std::list<std::pair<AString, AString> > cWebPlugin::GetTabNames(void)
{
std::list< std::pair< AString, AString > > NameList;
for( TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr )
for (TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr)
{
std::pair< AString, AString > StringPair;
StringPair.first = (*itr)->Title;
StringPair.second = (*itr)->SafeTitle;
NameList.push_back( StringPair );
NameList.push_back( StringPair);
}
return NameList;
}
@ -69,7 +69,7 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest
sWebPluginTab * Tab = NULL;
if (Split.size() > 2) // If we got the tab name, show that page
{
for( TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr )
for (TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr)
{
if ((*itr)->SafeTitle.compare(Split[2]) == 0) // This is the one!
{
@ -80,7 +80,7 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest
}
else // Otherwise show the first tab
{
if( GetTabs().size() > 0 )
if (GetTabs().size() > 0)
Tab = *GetTabs().begin();
}
@ -100,14 +100,14 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest
AString cWebPlugin::SafeString(const AString & a_String)
{
AString RetVal;
for( unsigned int i = 0; i < a_String.size(); ++i )
for (unsigned int i = 0; i < a_String.size(); ++i)
{
char c = a_String[i];
if( c == ' ' )
if (c == ' ')
{
c = '_';
}
RetVal.push_back( c );
RetVal.push_back( c);
}
return RetVal;
}

View File

@ -19,9 +19,9 @@ public:
// tolua_begin
virtual const AString GetWebTitle(void) const = 0;
virtual AString HandleWebRequest(const HTTPRequest * a_Request ) = 0;
virtual AString HandleWebRequest(const HTTPRequest * a_Request) = 0;
static AString SafeString( const AString & a_String );
static AString SafeString( const AString & a_String);
// tolua_end
struct sWebPluginTab
@ -37,7 +37,7 @@ public:
typedef std::list< std::pair<AString, AString> > TabNameList;
TabNameList GetTabNames(); // >> EXPORTED IN MANUALBINDINGS <<
std::pair< AString, AString > GetTabNameForRequest(const HTTPRequest* a_Request );
std::pair< AString, AString > GetTabNameForRequest(const HTTPRequest* a_Request);
private:
TabList m_Tabs;

View File

@ -10,12 +10,13 @@
// The "map" used for biome <-> string conversions:
static struct {
static struct
{
EMCSBiome m_Biome;
const char * m_String;
} g_BiomeMap[] =
{
{biOcean, "Ocean"} ,
{biOcean, "Ocean"},
{biPlains, "Plains"},
{biDesert, "Desert"},
{biExtremeHills, "ExtremeHills"},

View File

@ -66,7 +66,7 @@ int cBeaconEntity::GetPyramidLevel(void)
bool cBeaconEntity::IsMineralBlock(BLOCKTYPE a_BlockType)
{
switch(a_BlockType)
switch (a_BlockType)
{
case E_BLOCK_DIAMOND_BLOCK:
case E_BLOCK_GOLD_BLOCK:

View File

@ -33,7 +33,7 @@ public:
static bool IsMineralBlock(BLOCKTYPE a_BlockType);
// cBlockEntity overrides:
virtual void SaveToJson(Json::Value& a_Value ) override;
virtual void SaveToJson(Json::Value& a_Value) override;
virtual void SendTo(cClientHandle & a_Client) override;
virtual void UsedBy(cPlayer * a_Player) override;
virtual bool Tick(float a_Dt, cChunk & /* a_Chunk */) override;

View File

@ -38,9 +38,9 @@ protected:
public:
// tolua_end
virtual ~cBlockEntity() {}; // force a virtual destructor in all descendants
virtual ~cBlockEntity() {} // force a virtual destructor in all descendants
virtual void Destroy(void) {};
virtual void Destroy(void) {}
void SetWorld(cWorld * a_World)
{
@ -79,7 +79,7 @@ public:
virtual void SaveToJson (Json::Value & a_Value) = 0;
/// Called when a player uses this entity; should open the UI window
virtual void UsedBy( cPlayer * a_Player ) = 0;
virtual void UsedBy( cPlayer * a_Player) = 0;
/** Sends the packet defining the block entity to the client specified.
To send to all eligible clients, use cWorld::BroadcastBlockEntity()

View File

@ -4,9 +4,41 @@ project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
file(GLOB SOURCE
"*.cpp"
"*.h"
)
SET (SRCS
BeaconEntity.cpp
BlockEntity.cpp
ChestEntity.cpp
CommandBlockEntity.cpp
DispenserEntity.cpp
DropSpenserEntity.cpp
DropperEntity.cpp
EnderChestEntity.cpp
FlowerPotEntity.cpp
FurnaceEntity.cpp
HopperEntity.cpp
JukeboxEntity.cpp
MobHeadEntity.cpp
NoteEntity.cpp
SignEntity.cpp)
add_library(BlockEntities ${SOURCE})
SET (HDRS
BeaconEntity.h
BlockEntity.h
BlockEntityWithItems.h
ChestEntity.h
CommandBlockEntity.h
DispenserEntity.h
DropSpenserEntity.h
DropperEntity.h
EnderChestEntity.h
FlowerPotEntity.h
FurnaceEntity.h
HopperEntity.h
JukeboxEntity.h
MobHeadEntity.h
NoteEntity.h
SignEntity.h)
if(NOT MSVC)
add_library(BlockEntities ${SRCS} ${HDRS})
endif()

View File

@ -169,8 +169,8 @@ void cChestEntity::OpenNewWindow(void)
if (
m_World->DoWithChestAt(m_PosX - 1, m_PosY, m_PosZ, OpenDbl) ||
m_World->DoWithChestAt(m_PosX + 1, m_PosY, m_PosZ, OpenDbl) ||
m_World->DoWithChestAt(m_PosX , m_PosY, m_PosZ - 1, OpenDbl) ||
m_World->DoWithChestAt(m_PosX , m_PosY, m_PosZ + 1, OpenDbl)
m_World->DoWithChestAt(m_PosX, m_PosY, m_PosZ - 1, OpenDbl) ||
m_World->DoWithChestAt(m_PosX, m_PosY, m_PosZ + 1, OpenDbl)
)
{
// The double-chest window has been opened in the callback

View File

@ -27,7 +27,8 @@ class cChestEntity :
typedef cBlockEntityWithItems super;
public:
enum {
enum
{
ContentsHeight = 3,
ContentsWidth = 9,
} ;

View File

@ -38,8 +38,8 @@ public:
/// Creates a new empty command block entity
cCommandBlockEntity(int a_X, int a_Y, int a_Z, cWorld * a_World);
bool LoadFromJson( const Json::Value& a_Value );
virtual void SaveToJson(Json::Value& a_Value ) override;
bool LoadFromJson( const Json::Value& a_Value);
virtual void SaveToJson(Json::Value& a_Value) override;
virtual bool Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void SendTo(cClientHandle & a_Client) override;

View File

@ -35,7 +35,8 @@ class cDropSpenserEntity :
typedef cBlockEntityWithItems super;
public:
enum {
enum
{
ContentsHeight = 3,
ContentsWidth = 3,
} ;

View File

@ -39,8 +39,8 @@ public:
/** Creates a new flowerpot entity at the specified block coords. a_World may be NULL */
cFlowerPotEntity(int a_BlocX, int a_BlockY, int a_BlockZ, cWorld * a_World);
bool LoadFromJson( const Json::Value& a_Value );
virtual void SaveToJson(Json::Value& a_Value ) override;
bool LoadFromJson( const Json::Value& a_Value);
virtual void SaveToJson(Json::Value& a_Value) override;
virtual void Destroy(void) override;

View File

@ -160,7 +160,7 @@ bool cFurnaceEntity::LoadFromJson(const Json::Value & a_Value)
void cFurnaceEntity::SaveToJson( Json::Value& a_Value )
void cFurnaceEntity::SaveToJson( Json::Value& a_Value)
{
a_Value["x"] = m_PosX;
a_Value["y"] = m_PosY;

View File

@ -22,7 +22,8 @@ class cHopperEntity :
typedef cBlockEntityWithItems super;
public:
enum {
enum
{
ContentsHeight = 1,
ContentsWidth = 5,
TICKS_PER_TRANSFER = 8, ///< How many ticks at minimum between two item transfers to or from the hopper

View File

@ -58,7 +58,7 @@ public:
static const char * GetClassStatic(void) { return "cJukeboxEntity"; }
virtual void UsedBy(cPlayer * a_Player) override;
virtual void SendTo(cClientHandle &) override { };
virtual void SendTo(cClientHandle &) override {}
private:
int m_Record;

View File

@ -37,8 +37,8 @@ public:
/** Creates a new mob head entity at the specified block coords. a_World may be NULL */
cMobHeadEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
bool LoadFromJson( const Json::Value& a_Value );
virtual void SaveToJson(Json::Value& a_Value ) override;
bool LoadFromJson( const Json::Value& a_Value);
virtual void SaveToJson(Json::Value& a_Value) override;
// tolua_begin

View File

@ -52,7 +52,7 @@ public:
// tolua_end
virtual void UsedBy(cPlayer * a_Player) override;
virtual void SendTo(cClientHandle &) override { };
virtual void SendTo(cClientHandle &) override {}
static const char * GetClassStatic(void) { return "cNoteEntity"; }

View File

@ -37,8 +37,8 @@ public:
/// Creates a new empty sign entity at the specified block coords and block type (wall or standing). a_World may be NULL
cSignEntity(BLOCKTYPE a_BlockType, int a_X, int a_Y, int a_Z, cWorld * a_World);
bool LoadFromJson( const Json::Value& a_Value );
virtual void SaveToJson(Json::Value& a_Value ) override;
bool LoadFromJson( const Json::Value& a_Value);
virtual void SaveToJson(Json::Value& a_Value) override;
// tolua_begin

View File

@ -255,7 +255,8 @@ AString ItemToFullString(const cItem & a_Item)
int StringToMobType(const AString & a_MobString)
{
static struct {
static struct
{
int m_MobType;
const char * m_String;
} MobMap [] =

View File

@ -15,7 +15,6 @@ cBlockInfo::cBlockInfo()
, m_OneHitDig(false)
, m_PistonBreakable(false)
, m_IsSnowable(false)
, m_RequiresSpecialTool(false)
, m_IsSolid(true)
, m_FullyOccupiesVoxel(false)
, m_Handler(NULL)
@ -440,51 +439,6 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_TNT ].m_IsSnowable = true;
a_Info[E_BLOCK_WOOL ].m_IsSnowable = true;
// Blocks that don't drop without a special tool:
a_Info[E_BLOCK_BRICK ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_CAULDRON ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_COAL_ORE ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_COBBLESTONE ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_COBBLESTONE_WALL ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_COBBLESTONE_STAIRS ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_COBWEB ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_DIAMOND_BLOCK ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_DIAMOND_ORE ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_DOUBLE_STONE_SLAB ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_EMERALD_ORE ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_END_STONE ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_GOLD_BLOCK ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_GOLD_ORE ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_IRON_BLOCK ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_IRON_ORE ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_LAPIS_BLOCK ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_LAPIS_ORE ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_LEAVES ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_MOSSY_COBBLESTONE ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_NETHERRACK ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_NETHER_BRICK ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_NETHER_BRICK_STAIRS ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_OBSIDIAN ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_REDSTONE_ORE ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_REDSTONE_ORE_GLOWING].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_SANDSTONE ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_SANDSTONE_STAIRS ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_SNOW ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_STONE ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_STONE_BRICKS ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_STONE_BRICK_STAIRS ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_STONE_SLAB ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_VINES ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_FURNACE ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_LIT_FURNACE ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_ANVIL ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_ENCHANTMENT_TABLE ].m_RequiresSpecialTool = true;
// Nonsolid blocks:
a_Info[E_BLOCK_ACTIVATOR_RAIL ].m_IsSolid = false;
a_Info[E_BLOCK_AIR ].m_IsSolid = false;
@ -496,9 +450,6 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_CROPS ].m_IsSolid = false;
a_Info[E_BLOCK_DANDELION ].m_IsSolid = false;
a_Info[E_BLOCK_DETECTOR_RAIL ].m_IsSolid = false;
a_Info[E_BLOCK_END_PORTAL ].m_IsSolid = false;
a_Info[E_BLOCK_FENCE ].m_IsSolid = false;
a_Info[E_BLOCK_FENCE_GATE ].m_IsSolid = false;
a_Info[E_BLOCK_FIRE ].m_IsSolid = false;
a_Info[E_BLOCK_FLOWER ].m_IsSolid = false;
a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_IsSolid = false;
@ -530,7 +481,6 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_WATER ].m_IsSolid = false;
a_Info[E_BLOCK_WOODEN_BUTTON ].m_IsSolid = false;
a_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_IsSolid = false;
a_Info[E_BLOCK_WOODEN_SLAB ].m_IsSolid = false;
// Blocks that fully occupy their voxel - used as a guide for torch placeable blocks, amongst other things:

View File

@ -39,9 +39,6 @@ public:
/** Can this block hold snow atop? */
bool m_IsSnowable;
/** Does this block require a tool to drop? */
bool m_RequiresSpecialTool;
/** Is this block solid (player cannot walk through)? */
bool m_IsSolid;
@ -61,7 +58,6 @@ public:
inline static bool IsOneHitDig (BLOCKTYPE a_Type) { return Get(a_Type).m_OneHitDig; }
inline static bool IsPistonBreakable (BLOCKTYPE a_Type) { return Get(a_Type).m_PistonBreakable; }
inline static bool IsSnowable (BLOCKTYPE a_Type) { return Get(a_Type).m_IsSnowable; }
inline static bool RequiresSpecialTool (BLOCKTYPE a_Type) { return Get(a_Type).m_RequiresSpecialTool; }
inline static bool IsSolid (BLOCKTYPE a_Type) { return Get(a_Type).m_IsSolid; }
inline static bool FullyOccupiesVoxel (BLOCKTYPE a_Type) { return Get(a_Type).m_FullyOccupiesVoxel; }

View File

@ -15,7 +15,7 @@ void cBlockBedHandler::OnPlacedByPlayer(
if (a_BlockMeta < 8)
{
Vector3i Direction = MetaDataToDirection(a_BlockMeta);
a_ChunkInterface.SetBlock(a_WorldInterface,a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z, E_BLOCK_BED, a_BlockMeta | 0x8);
a_ChunkInterface.SetBlock(a_WorldInterface, a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z, E_BLOCK_BED, a_BlockMeta | 0x8);
}
}
@ -27,8 +27,8 @@ void cBlockBedHandler::OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInt
{
NIBBLETYPE OldMeta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
Vector3i ThisPos( a_BlockX, a_BlockY, a_BlockZ );
Vector3i Direction = MetaDataToDirection( OldMeta & 0x7 );
Vector3i ThisPos( a_BlockX, a_BlockY, a_BlockZ);
Vector3i Direction = MetaDataToDirection( OldMeta & 0x7);
if (OldMeta & 0x8)
{
// Was pillow

View File

@ -16,7 +16,7 @@ class cBlockBedHandler :
{
public:
cBlockBedHandler(BLOCKTYPE a_BlockType)
: cMetaRotator<cBlockHandler, 0x3, 0x02, 0x03, 0x00, 0x01,true>(a_BlockType)
: cMetaRotator<cBlockHandler, 0x3, 0x02, 0x03, 0x00, 0x01, true>(a_BlockType)
{
}

View File

@ -19,16 +19,16 @@ public:
}
virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, 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, bool a_DropVerbatim) override
{
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
if (Meta & 0x8)
{
super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY - 1, a_BlockZ);
super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY - 1, a_BlockZ, a_CanDrop, a_DropVerbatim);
}
else
{
super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY, a_BlockZ);
super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_CanDrop, a_DropVerbatim);
}
}

View File

@ -70,7 +70,7 @@
#include "BlockSand.h"
#include "BlockSapling.h"
#include "BlockSideways.h"
#include "BlockSign.h"
#include "BlockSignPost.h"
#include "BlockSlab.h"
#include "BlockSnow.h"
#include "BlockStairs.h"
@ -81,6 +81,7 @@
#include "BlockTorch.h"
#include "BlockTrapdoor.h"
#include "BlockVine.h"
#include "BlockWallSign.h"
#include "BlockWorkbench.h"
@ -174,7 +175,7 @@ public:
cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
{
switch(a_BlockType)
switch (a_BlockType)
{
// Block handlers, alphabetically sorted:
case E_BLOCK_ACACIA_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType);
@ -253,7 +254,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_NEW_LOG: return new cBlockSidewaysHandler (a_BlockType);
case E_BLOCK_NOTE_BLOCK: return new cBlockNoteHandler (a_BlockType);
case E_BLOCK_PISTON: return new cBlockPistonHandler (a_BlockType);
case E_BLOCK_PISTON_EXTENSION: return new cBlockPistonHeadHandler ( );
case E_BLOCK_PISTON_EXTENSION: return new cBlockPistonHeadHandler;
case E_BLOCK_PLANKS: return new cBlockPlanksHandler (a_BlockType);
case E_BLOCK_POTATOES: return new cBlockCropsHandler (a_BlockType);
case E_BLOCK_POWERED_RAIL: return new cBlockRailHandler (a_BlockType);
@ -275,7 +276,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_SAND: return new cBlockSandHandler (a_BlockType);
case E_BLOCK_SANDSTONE_STAIRS: return new cBlockStairsHandler (a_BlockType);
case E_BLOCK_SAPLING: return new cBlockSaplingHandler (a_BlockType);
case E_BLOCK_SIGN_POST: return new cBlockSignHandler (a_BlockType);
case E_BLOCK_SIGN_POST: return new cBlockSignPostHandler (a_BlockType);
case E_BLOCK_SNOW: return new cBlockSnowHandler (a_BlockType);
case E_BLOCK_SPRUCE_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType);
case E_BLOCK_STAINED_GLASS: return new cBlockGlassHandler (a_BlockType);
@ -297,7 +298,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_TRIPWIRE: return new cBlockTripwireHandler (a_BlockType);
case E_BLOCK_TRIPWIRE_HOOK: return new cBlockTripwireHookHandler (a_BlockType);
case E_BLOCK_VINES: return new cBlockVineHandler (a_BlockType);
case E_BLOCK_WALLSIGN: return new cBlockSignHandler (a_BlockType); // TODO: This needs a special handler
case E_BLOCK_WALLSIGN: return new cBlockWallSignHandler (a_BlockType);
case E_BLOCK_WATER: return new cBlockFluidHandler (a_BlockType);
case E_BLOCK_WOODEN_BUTTON: return new cBlockButtonHandler (a_BlockType);
case E_BLOCK_WOODEN_DOOR: return new cBlockDoorHandler (a_BlockType);
@ -407,39 +408,6 @@ void cBlockHandler::NeighborChanged(cChunkInterface & a_ChunkInterface, int a_Bl
void cBlockHandler::OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ)
{
}
void cBlockHandler::OnDigging(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
{
}
void cBlockHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
{
}
void cBlockHandler::OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace)
{
}
void cBlockHandler::ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta)
{
// Setting the meta to a_BlockMeta keeps most textures. The few other blocks have to override this.
@ -450,11 +418,23 @@ void cBlockHandler::ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta)
void cBlockHandler::DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ)
void cBlockHandler::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, bool a_DropVerbatim)
{
cItems Pickups;
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
ConvertToPickups(Pickups, Meta);
if (a_CanDrop)
{
if (!a_DropVerbatim)
{
ConvertToPickups(Pickups, Meta);
}
else
{
// TODO: Add a proper overridable function for this
Pickups.Add(m_BlockType, 1, Meta);
}
}
// Allow plugins to modify the pickups:
a_BlockPluginInterface.CallHookBlockToPickups(a_Digger, a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta, Pickups);

View File

@ -60,25 +60,29 @@ public:
virtual void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ);
/// Called when a direct neighbor of this block has been changed (The position is the own position, not the neighbor position)
virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ);
virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) {}
/// Notifies all neighbors of the given block about a change
static void NeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ);
/// Called while the player diggs the block.
virtual void OnDigging(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ);
virtual void OnDigging(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) {}
/// Called if the user right clicks the block and the block is useable
virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ);
virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) {}
/** Called when a Right Click to this Block is cancelled */
virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace);
/** Called when a right click to this block is cancelled */
virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) {}
/// <summary>Called when the item is mined to convert it into pickups. Pickups may specify multiple items. Appends items to a_Pickups, preserves its original contents</summary>
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta);
/// Handles the dropping of a block based on what ConvertToDrops() returns. This will not destroy the block. a_Digger is the entity causing the drop; it may be NULL
virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ);
/** 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_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)
*/
virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_CanDrop = true, bool a_DropVerbatim = false);
/// Returns step sound name of block
virtual const char * GetStepSound(void);

View File

@ -103,7 +103,7 @@ public:
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface,int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
// TODO: Use AdjustCoordsByMeta(), then cChunk::UnboundedRelGetBlock() and finally some comparison
eBlockFace BlockFace = MetaDataToDirection(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ));

View File

@ -11,7 +11,7 @@
// Leaves can be this many blocks that away (inclusive) from the log not to decay
#define LEAVES_CHECK_DISTANCE 6
#define PROCESS_NEIGHBOR(x,y,z) \
#define PROCESS_NEIGHBOR(x, y, z) \
switch (a_Area.GetBlockType(x, y, z)) \
{ \
case E_BLOCK_LEAVES: a_Area.SetBlockType(x, y, z, (BLOCKTYPE)(E_BLOCK_SPONGE + i + 1)); break; \
@ -40,14 +40,20 @@ public:
{
cFastRandom rand;
// Only the first 2 bits contain the display information, the others are for growing
// Old leaves - 3 bits contain display; new leaves - 1st bit, shifted left two for saplings to understand
if (rand.NextInt(6) == 0)
{
a_Pickups.push_back(cItem(E_BLOCK_SAPLING, 1, a_BlockMeta & 3));
a_Pickups.push_back(
cItem(
E_BLOCK_SAPLING,
1,
(m_BlockType == E_BLOCK_LEAVES) ? (a_BlockMeta & 0x03) : (2 << (a_BlockMeta & 0x01))
)
);
}
// 1 % chance of dropping an apple, if the leaves' type is Apple Leaves
if ((a_BlockMeta & 3) == E_META_LEAVES_APPLE)
if ((m_BlockType == E_BLOCK_LEAVES) && ((a_BlockMeta & 0x03) == E_META_LEAVES_APPLE))
{
if (rand.NextInt(101) == 0)
{

View File

@ -70,7 +70,7 @@ public:
} PortalCheck[] =
{
{ 0, 1, 0},
{ 0,-1, 0},
{ 0, -1, 0},
{ 1, 0, 0},
{-1, 0, 0},
} ;
@ -95,7 +95,7 @@ public:
} PortalCheck[] =
{
{ 0, 1, 0},
{ 0,-1, 0},
{ 0, -1, 0},
{ 0, 0, -1},
{ 0, 0, 1},
} ;

View File

@ -20,8 +20,8 @@ public:
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
// Only the first 2 bits contain the display information, the others are for growing
a_Pickups.push_back(cItem(E_BLOCK_SAPLING, 1, a_BlockMeta & 0x7));
// Only the first 2 bits contain the display information and the 4th bit is for the growth indicator, but, we use 0x07 for forward compatibility
a_Pickups.push_back(cItem(E_BLOCK_SAPLING, 1, a_BlockMeta & 0x07));
}

View File

@ -9,21 +9,23 @@
class cBlockSignHandler :
class cBlockSignPostHandler :
public cBlockHandler
{
typedef cBlockHandler super;
public:
cBlockSignHandler(BLOCKTYPE a_BlockType)
: cBlockHandler(a_BlockType)
cBlockSignPostHandler(BLOCKTYPE a_BlockType) :
super(a_BlockType)
{
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
a_Pickups.push_back(cItem(E_ITEM_SIGN, 1, 0));
}
virtual const char * GetStepSound(void) override
{
@ -31,6 +33,17 @@ public:
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
if (a_RelY <= 0)
{
return false;
}
return (cBlockInfo::IsSolid(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ)));
}
static NIBBLETYPE RotationToMetaData(double a_Rotation)
{
a_Rotation += 180 + (180 / 16); // So it's not aligned with axis
@ -43,23 +56,6 @@ public:
return ((char)a_Rotation) % 16;
}
static NIBBLETYPE DirectionToMetaData(eBlockFace a_Direction)
{
switch (a_Direction)
{
case 0x2: return 0x2;
case 0x3: return 0x3;
case 0x4: return 0x4;
case 0x5: return 0x5;
default:
{
break;
}
}
return 0x2;
}
virtual void OnPlacedByPlayer(
@ -84,22 +80,23 @@ public:
return (a_Meta + 12) & 0x0f;
}
virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override
{
// Mirrors signs over the XY plane (North-South Mirroring)
// Mirrors signs over the XY plane (North-South Mirroring)
// There are 16 meta values which correspond to different directions.
// These values are equated to angles on a circle; 0x08 = 180 degrees.
// There are 16 meta values which correspond to different directions.
// These values are equated to angles on a circle; 0x08 = 180 degrees.
return (a_Meta < 0x08) ? (0x08 + a_Meta) : (0x08 - a_Meta);
}
virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override
{
// Mirrors signs over the YZ plane (East-West Mirroring)
// Mirrors signs over the YZ plane (East-West Mirroring)
// There are 16 meta values which correspond to different directions.
// These values are equated to angles on a circle; 0x10 = 360 degrees.
// There are 16 meta values which correspond to different directions.
// These values are equated to angles on a circle; 0x10 = 360 degrees.
return 0x10 - a_Meta;
}
} ;

View File

@ -99,7 +99,7 @@ public:
static bool CanBePlacedOn(BLOCKTYPE a_BlockType, eBlockFace a_BlockFace)
{
if ( !cBlockInfo::FullyOccupiesVoxel(a_BlockType) )
if (!cBlockInfo::FullyOccupiesVoxel(a_BlockType))
{
return (a_BlockFace == BLOCK_FACE_TOP); // Allow placement only when torch upright (for glass, etc.); exceptions won't even be sent by client, no need to handle
}
@ -119,7 +119,8 @@ public:
AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, Face, true);
BLOCKTYPE BlockInQuestion = a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ);
if ( // If on a block that can only hold a torch if torch is standing on it, return that face
// If on a block that can only hold a torch if torch is standing on it, return that face
if (
((BlockInQuestion == E_BLOCK_GLASS) ||
(BlockInQuestion == E_BLOCK_FENCE) ||
(BlockInQuestion == E_BLOCK_NETHER_BRICK_FENCE) ||
@ -167,7 +168,7 @@ public:
// No need to check for upright orientation, it was done when the torch was placed
return true;
}
else if ( !cBlockInfo::FullyOccupiesVoxel(BlockInQuestion) )
else if (!cBlockInfo::FullyOccupiesVoxel(BlockInQuestion))
{
return false;
}

View File

@ -59,7 +59,7 @@ public:
static char MetaDataToDirection(NIBBLETYPE a_MetaData)
{
switch(a_MetaData)
switch (a_MetaData)
{
case 0x1: return BLOCK_FACE_NORTH;
case 0x4: return BLOCK_FACE_SOUTH;

View File

@ -0,0 +1,89 @@
#pragma once
#include "BlockHandler.h"
#include "../Entities/Player.h"
#include "Chunk.h"
class cBlockWallSignHandler :
public cBlockHandler
{
typedef cBlockHandler super;
public:
cBlockWallSignHandler(BLOCKTYPE a_BlockType) :
super(a_BlockType)
{
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
a_Pickups.push_back(cItem(E_ITEM_SIGN, 1, 0));
}
virtual const char * GetStepSound(void) override
{
return "step.wood";
}
virtual void OnPlacedByPlayer(
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta
) override
{
a_Player->GetClientHandle()->SendEditSign(a_BlockX, a_BlockY, a_BlockZ);
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
int BlockX = (a_Chunk.GetPosX() * cChunkDef::Width) + a_RelX;
int BlockZ = (a_Chunk.GetPosZ() * cChunkDef::Width) + a_RelZ;
GetBlockCoordsBehindTheSign(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ), BlockX, BlockZ);
return (cBlockInfo::IsSolid(a_ChunkInterface.GetBlock(BlockX, a_RelY, BlockZ)));
}
static void GetBlockCoordsBehindTheSign(NIBBLETYPE a_BlockMeta, int & a_BlockX, int & a_BlockZ)
{
switch (a_BlockMeta)
{
case 2: a_BlockZ++; break;
case 3: a_BlockZ--; break;
case 4: a_BlockX++; break;
case 5: a_BlockX--; break;
default: break;
}
}
static NIBBLETYPE DirectionToMetaData(eBlockFace a_Direction)
{
switch (a_Direction)
{
case 0x2: return 0x2;
case 0x3: return 0x3;
case 0x4: return 0x4;
case 0x5: return 0x5;
default:
{
break;
}
}
return 0x2;
}
} ;

View File

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

View File

@ -4,9 +4,99 @@ project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
file(GLOB SOURCE
"*.cpp"
"*.h"
)
SET (SRCS
BlockBed.cpp
BlockDoor.cpp
BlockHandler.cpp
BlockPiston.cpp
ChunkInterface.cpp)
add_library(Blocks ${SOURCE})
SET (HDRS
BlockAnvil.h
BlockBed.h
BlockBigFlower.h
BlockBrewingStand.h
BlockButton.h
BlockCactus.h
BlockCake.h
BlockCarpet.h
BlockCauldron.h
BlockChest.h
BlockCloth.h
BlockCobWeb.h
BlockCommandBlock.h
BlockComparator.h
BlockCrops.h
BlockDeadBush.h
BlockDirt.h
BlockDoor.h
BlockDropSpenser.h
BlockEnchantmentTable.h
BlockEnderchest.h
BlockEntity.h
BlockFarmland.h
BlockFenceGate.h
BlockFire.h
BlockFlower.h
BlockFlowerPot.h
BlockFluid.h
BlockFurnace.h
BlockGlass.h
BlockGlowstone.h
BlockGravel.h
BlockHandler.h
BlockHayBale.h
BlockHopper.h
BlockIce.h
BlockLadder.h
BlockLeaves.h
BlockLever.h
BlockLilypad.h
BlockMelon.h
BlockMobHead.h
BlockMushroom.h
BlockMycelium.h
BlockNetherWart.h
BlockNewLeaves.h
BlockNote.h
BlockOre.h
BlockPiston.h
BlockPlanks.h
BlockPluginInterface.h
BlockPortal.h
BlockPressurePlate.h
BlockPumpkin.h
BlockQuartz.h
BlockRail.h
BlockRedstone.h
BlockRedstoneLamp.h
BlockRedstoneRepeater.h
BlockRedstoneTorch.h
BlockSand.h
BlockSapling.h
BlockSideways.h
BlockSignPost.h
BlockSlab.h
BlockSnow.h
BlockStairs.h
BlockStems.h
BlockStone.h
BlockSugarcane.h
BlockTNT.h
BlockTallGrass.h
BlockTorch.h
BlockTrapdoor.h
BlockTripwire.h
BlockTripwireHook.h
BlockVine.h
BlockWallSign.h
BlockWorkbench.h
BroadcastInterface.h
ChunkInterface.h
ClearMetaOnDrop.h
MetaRotator.h
WorldInterface.h)
if(NOT MSVC)
add_library(Blocks ${SRCS} ${HDRS})
endif()

View File

@ -18,7 +18,7 @@ public:
BLOCKTYPE GetBlock(int a_BlockX, int a_BlockY, int a_BlockZ)
{
return m_ChunkMap->GetBlock(a_BlockX,a_BlockY,a_BlockZ);
return m_ChunkMap->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
}
BLOCKTYPE GetBlock(const Vector3i & a_Pos)
{
@ -61,9 +61,9 @@ public:
m_ChunkMap->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
}
void FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta )
void FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
FastSetBlock( a_Pos.x, a_Pos.y, a_Pos.z, a_BlockType, a_BlockMeta );
FastSetBlock( a_Pos.x, a_Pos.y, a_Pos.z, a_BlockType, a_BlockMeta);
}
void UseBlockEntity(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)

View File

@ -191,7 +191,7 @@ bool cBoundingBox::IsInside(const Vector3d & a_Point)
bool cBoundingBox::IsInside(double a_X, double a_Y,double a_Z)
bool cBoundingBox::IsInside(double a_X, double a_Y, double a_Z)
{
return IsInside(m_Min, m_Max, a_X, a_Y, a_Z);
}

View File

@ -49,7 +49,7 @@ public:
bool IsInside(const Vector3d & a_Point);
/// Returns true if the point is inside the bounding box
bool IsInside(double a_X, double a_Y,double a_Z);
bool IsInside(double a_X, double a_Y, double a_Z);
/// Returns true if a_Other is inside this bounding box
bool IsInside(cBoundingBox & a_Other);

View File

@ -5,144 +5,150 @@ include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/")
include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/jsoncpp/include")
include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/polarssl/include")
set(FOLDERS OSSupport HTTPServer Items Blocks Protocol Generating PolarSSL++)
set(FOLDERS ${FOLDERS} WorldStorage Mobs Entities Simulator UI BlockEntities Generating/Prefabs)
set(FOLDERS
OSSupport HTTPServer Items Blocks Protocol Generating PolarSSL++ Bindings
WorldStorage Mobs Entities Simulator UI BlockEntities Generating/Prefabs
)
set(BINDING_DEPENDECIES
tolua
${CMAKE_CURRENT_SOURCE_DIR}/Bindings/virtual_method_hooks.lua
${CMAKE_CURRENT_SOURCE_DIR}/Bindings/AllToLua.pkg
Bindings/gen_LuaState_Call.lua
Bindings/LuaFunctions.h
Bindings/LuaWindow.h
Bindings/Plugin.h
Bindings/PluginLua.h
Bindings/PluginManager.h
Bindings/WebPlugin.h
SET (SRCS
BiomeDef.cpp
BlockArea.cpp
BlockID.cpp
BlockInfo.cpp
BoundingBox.cpp
ByteBuffer.cpp
ChatColor.cpp
Chunk.cpp
ChunkData.cpp
ChunkMap.cpp
ChunkSender.cpp
ChunkStay.cpp
ClientHandle.cpp
CommandOutput.cpp
CompositeChat.cpp
CraftingRecipes.cpp
Cuboid.cpp
DeadlockDetect.cpp
Enchantments.cpp
FastRandom.cpp
FurnaceRecipe.cpp
Globals.cpp
Group.cpp
GroupManager.cpp
Inventory.cpp
Item.cpp
ItemGrid.cpp
LightingThread.cpp
LineBlockTracer.cpp
LinearInterpolation.cpp
Log.cpp
MCLogger.cpp
Map.cpp
MapManager.cpp
MobCensus.cpp
MobFamilyCollecter.cpp
MobProximityCounter.cpp
MobSpawner.cpp
MonsterConfig.cpp
Noise.cpp
ProbabDistrib.cpp
RCONServer.cpp
Root.cpp
Scoreboard.cpp
Server.cpp
SetChunkData.cpp
Statistics.cpp
StringCompression.cpp
StringUtils.cpp
Tracer.cpp
VoronoiMap.cpp
WebAdmin.cpp
World.cpp
main.cpp)
SET (HDRS
AllocationPool.h
BiomeDef.h
BlockArea.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
BlockInServerPluginInterface.h
BlockInfo.h
BlockTracer.h
BoundingBox.h
ByteBuffer.h
ChatColor.h
Chunk.h
ChunkData.h
ChunkDataCallback.h
ChunkDef.h
ChunkMap.h
ChunkSender.h
ChunkStay.h
ClientHandle.h
CommandOutput.h
CompositeChat.h
CraftingRecipes.h
Cuboid.h
DeadlockDetect.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
Endianness.h
FastRandom.h
ForEachChunkProvider.h
FurnaceRecipe.h
Globals.h
Group.h
GroupManager.h
Inventory.h
Item.h
ItemGrid.h
Mobs/Monster.h
OSSupport/File.h
LeakFinder.h
LightingThread.h
LineBlockTracer.h
LinearInterpolation.h
LinearUpscale.h
Log.h
MCLogger.h
Map.h
MapManager.h
Matrix4.h
MemoryLeak.h
MersenneTwister.h
MobCensus.h
MobFamilyCollecter.h
MobProximityCounter.h
MobSpawner.h
MonsterConfig.h
Noise.h
ProbabDistrib.h
RCONServer.h
Root.h
Scoreboard.h
Server.h
SetChunkData.h
StackWalker.h
Statistics.h
StringCompression.h
StringUtils.h
Tracer.h
UI/Window.h
Vector3.h
VoronoiMap.h
WebAdmin.h
World.h
)
XMLParser.h)
# List all the files that are generated as part of the Bindings build process
set (BINDING_OUTPUTS
${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.h
${CMAKE_CURRENT_SOURCE_DIR}/Bindings/LuaState_Call.inc
)
include_directories(Bindings)
include_directories(.)
if (WIN32)
ADD_CUSTOM_COMMAND(
OUTPUT ${BINDING_OUTPUTS}
# Copy the Lua DLL into the Bindings folder, so that tolua can run from there:
COMMAND ${CMAKE_COMMAND} -E copy_if_different ../../MCServer/lua51.dll ./lua51.dll
# Regenerate bindings:
COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/
# add any new generation dependencies here
DEPENDS ${BINDING_DEPENDECIES}
)
else ()
ADD_CUSTOM_COMMAND(
# add any new generated bindings here
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.h
# Regenerate bindings:
COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/
# add any new generation dependencies here
DEPENDS ${BINDING_DEPENDECIES}
)
endif ()
set_source_files_properties(Bindings/Bindings.cpp PROPERTIES GENERATED TRUE)
set_source_files_properties(Bindings/Bindings.h PROPERTIES GENERATED TRUE)
include_directories(".")
if (NOT MSVC)
# Bindings need to reference other folders, so they are done here instead
# lib dependencies are not included
include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/../lib/polarssl/include")
#add cpp files here
add_library(Bindings
Bindings/Bindings
Bindings/DeprecatedBindings
Bindings/LuaChunkStay
Bindings/LuaState
Bindings/LuaWindow
Bindings/ManualBindings
Bindings/Plugin
Bindings/PluginLua
Bindings/PluginManager
Bindings/WebPlugin
)
foreach(folder ${FOLDERS})
add_subdirectory(${folder})
endforeach(folder)
target_link_libraries(Bindings lua sqlite tolualib polarssl)
get_directory_property(BINDING_DEPENDENCIES DIRECTORY "Bindings" DEFINITION BINDING_DEPENDENCIES)
#clear file
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/BindingDependecies.txt)
@ -153,43 +159,19 @@ if (NOT MSVC)
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "Bindings.cpp Bindings.h")
foreach(folder ${FOLDERS})
add_subdirectory(${folder})
endforeach(folder)
file(GLOB SOURCE
"*.cpp"
"*.h"
)
list(REMOVE_ITEM SOURCE "${PROJECT_SOURCE_DIR}/StackWalker.cpp" "${PROJECT_SOURCE_DIR}/LeakFinder.cpp")
list(APPEND SOURCE "${SRCS}")
list(APPEND SOURCE "${HDRS}")
# If building a windows version, but not using MSVC, add the resources directly to the makefile:
if (WIN32)
FILE(GLOB ResourceFiles
"Resources/*.rc"
)
list(APPEND SOURCE "${ResourceFiles}")
list(APPEND SOURCE "Resources/MCServer.rc")
endif()
else ()
# MSVC-specific handling: Put all files into one project, separate by the folders:
# Get all files in this folder:
file(GLOB_RECURSE SOURCE
"*.cpp"
"*.h"
"*.pkg"
)
source_group("" FILES ${SOURCE})
LIST(APPEND SOURCE "Bindings/Bindings.cpp" "Bindings/Bindings.h")
source_group(Bindings FILES "Bindings/Bindings.cpp" "Bindings/Bindings.h")
# Add all subfolders as solution-folders:
list(APPEND FOLDERS "Resources")
list(APPEND FOLDERS "Bindings")
function(includefolder PATH)
FILE(GLOB FOLDER_FILES
"${PATH}/*.cpp"
@ -202,9 +184,29 @@ else ()
endfunction(includefolder)
foreach(folder ${FOLDERS})
add_subdirectory(${folder})
includefolder(${folder})
# Get all source files in this folder:
get_directory_property(FOLDER_SRCS DIRECTORY ${folder} DEFINITION SRCS)
foreach (src ${FOLDER_SRCS})
list(APPEND SOURCE "${folder}/${src}")
endforeach(src)
# Get all headers in this folder:
get_directory_property(FOLDER_HDRS DIRECTORY ${folder} DEFINITION HDRS)
foreach (hdr ${FOLDER_HDRS})
list(APPEND SOURCE "${folder}/${hdr}")
endforeach(hdr)
endforeach(folder)
list(APPEND SOURCE "${SRCS}")
list(APPEND SOURCE "${HDRS}")
list(APPEND SOURCE "Bindings/AllToLua.pkg")
includefolder("Resources")
source_group("" FILES ${SOURCE})
include_directories("${PROJECT_SOURCE_DIR}")
# Precompiled headers (1st part)
@ -228,8 +230,47 @@ else ()
set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} /DEBUG")
endif()
# Generate a list of all source files:
set(ALLFILES "")
foreach(folder ${FOLDERS})
get_directory_property(FOLDER_SRCS DIRECTORY ${folder} DEFINITION SRCS)
foreach (src ${FOLDER_SRCS})
list(APPEND ALLFILES "${folder}/${src}")
endforeach(src)
get_directory_property(FOLDER_HDRS DIRECTORY ${folder} DEFINITION HDRS)
foreach (hdr ${FOLDER_HDRS})
list(APPEND ALLFILES "${folder}/${hdr}")
endforeach(hdr)
endforeach(folder)
foreach(arg ${ALLFILES})
set(ALLFILESLINES "${ALLFILESLINES}${arg}\n")
endforeach()
FILE(WRITE "AllFiles.lst" "${ALLFILESLINES}")
set(EXECUTABLE MCServer)
if (MSVC)
get_directory_property(BINDING_OUTPUTS DIRECTORY "Bindings" DEFINITION BINDING_OUTPUTS)
get_directory_property(BINDING_DEPENDENCIES DIRECTORY "Bindings" DEFINITION BINDING_DEPENDENCIES)
ADD_CUSTOM_COMMAND(
OUTPUT ${BINDING_OUTPUTS}
# Copy the Lua DLL into the Bindings folder, so that tolua can run from there:
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/MCServer/lua51.dll ./lua51.dll
# Regenerate bindings:
COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/
# add any new generation dependencies here
DEPENDS ${BINDING_DEPENDENCIES}
)
endif()
add_executable(${EXECUTABLE} ${SOURCE})
@ -261,9 +302,11 @@ endif ()
if (NOT MSVC)
target_link_libraries(${EXECUTABLE} OSSupport HTTPServer Bindings Items Blocks)
target_link_libraries(${EXECUTABLE} Protocol Generating Generating_Prefabs WorldStorage)
target_link_libraries(${EXECUTABLE} Mobs Entities Simulator UI BlockEntities PolarSSL++)
target_link_libraries(${EXECUTABLE}
OSSupport HTTPServer Bindings Items Blocks
Protocol Generating Generating_Prefabs WorldStorage
Mobs Entities Simulator UI BlockEntities PolarSSL++
)
endif ()
if (WIN32)
target_link_libraries(${EXECUTABLE} expat tolualib ws2_32.lib Psapi.lib)

View File

@ -2,31 +2,31 @@
#include "ChatColor.h"
const std::string cChatColor::Color = "\xc2\xa7"; // or in other words: "§" in UTF-8
const std::string cChatColor::Delimiter = "\xc2\xa7"; // or in other words: "§" in UTF-8
const std::string cChatColor::Black = cChatColor::Color + "0";
const std::string cChatColor::Navy = cChatColor::Color + "1";
const std::string cChatColor::Green = cChatColor::Color + "2";
const std::string cChatColor::Blue = cChatColor::Color + "3";
const std::string cChatColor::Red = cChatColor::Color + "4";
const std::string cChatColor::Purple = cChatColor::Color + "5";
const std::string cChatColor::Gold = cChatColor::Color + "6";
const std::string cChatColor::LightGray = cChatColor::Color + "7";
const std::string cChatColor::Gray = cChatColor::Color + "8";
const std::string cChatColor::DarkPurple = cChatColor::Color + "9";
const std::string cChatColor::LightGreen = cChatColor::Color + "a";
const std::string cChatColor::LightBlue = cChatColor::Color + "b";
const std::string cChatColor::Rose = cChatColor::Color + "c";
const std::string cChatColor::LightPurple = cChatColor::Color + "d";
const std::string cChatColor::Yellow = cChatColor::Color + "e";
const std::string cChatColor::White = cChatColor::Color + "f";
const char * cChatColor::Color = "\xc2\xa7"; // or in other words: "§" in UTF-8
const char * cChatColor::Delimiter = "\xc2\xa7"; // or in other words: "§" in UTF-8
const char * cChatColor::Black = "\xc2\xa7""0";
const char * cChatColor::Navy = "\xc2\xa7""1";
const char * cChatColor::Green = "\xc2\xa7""2";
const char * cChatColor::Blue = "\xc2\xa7""3";
const char * cChatColor::Red = "\xc2\xa7""4";
const char * cChatColor::Purple = "\xc2\xa7""5";
const char * cChatColor::Gold = "\xc2\xa7""6";
const char * cChatColor::LightGray = "\xc2\xa7""7";
const char * cChatColor::Gray = "\xc2\xa7""8";
const char * cChatColor::DarkPurple = "\xc2\xa7""9";
const char * cChatColor::LightGreen = "\xc2\xa7""a";
const char * cChatColor::LightBlue = "\xc2\xa7""b";
const char * cChatColor::Rose = "\xc2\xa7""c";
const char * cChatColor::LightPurple = "\xc2\xa7""d";
const char * cChatColor::Yellow = "\xc2\xa7""e";
const char * cChatColor::White = "\xc2\xa7""f";
const std::string cChatColor::Random = cChatColor::Color + "k";
const std::string cChatColor::Bold = cChatColor::Color + "l";
const std::string cChatColor::Strikethrough = cChatColor::Color + "m";
const std::string cChatColor::Underlined = cChatColor::Color + "n";
const std::string cChatColor::Italic = cChatColor::Color + "o";
const std::string cChatColor::Plain = cChatColor::Color + "r";
const char * cChatColor::Random = "\xc2\xa7""k";
const char * cChatColor::Bold = "\xc2\xa7""l";
const char * cChatColor::Strikethrough = "\xc2\xa7""m";
const char * cChatColor::Underlined = "\xc2\xa7""n";
const char * cChatColor::Italic = "\xc2\xa7""o";
const char * cChatColor::Plain = "\xc2\xa7""r";

View File

@ -9,34 +9,36 @@
class cChatColor
{
public:
static const std::string Color;
static const std::string Delimiter;
static const char * Delimiter;
/** @deprecated use ChatColor::Delimiter instead */
static const char * Color;
static const std::string Black;
static const std::string Navy;
static const std::string Green;
static const std::string Blue;
static const std::string Red;
static const std::string Purple;
static const std::string Gold;
static const std::string LightGray;
static const std::string Gray;
static const std::string DarkPurple;
static const std::string LightGreen;
static const std::string LightBlue;
static const std::string Rose;
static const std::string LightPurple;
static const std::string Yellow;
static const std::string White;
// Styles ( source: http://wiki.vg/Chat )
static const std::string Random;
static const std::string Bold;
static const std::string Strikethrough;
static const std::string Underlined;
static const std::string Italic;
static const std::string Plain;
static const char * Black;
static const char * Navy;
static const char * Green;
static const char * Blue;
static const char * Red;
static const char * Purple;
static const char * Gold;
static const char * LightGray;
static const char * Gray;
static const char * DarkPurple;
static const char * LightGreen;
static const char * LightBlue;
static const char * Rose;
static const char * LightPurple;
static const char * Yellow;
static const char * White;
// Styles
// source: http://wiki.vg/Chat
static const char * Random;
static const char * Bold;
static const char * Strikethrough;
static const char * Underlined;
static const char * Italic;
static const char * Plain;
};
// tolua_end

View File

@ -1,3 +1,4 @@
#!/usr/bin/env lua
-- CheckBasicStyle.lua
@ -6,39 +7,29 @@ Checks that all source files (*.cpp, *.h) use the basic style requirements of th
- Tabs for indentation, spaces for alignment
- Trailing whitespace on non-empty lines
- Two spaces between code and line-end comment ("//")
- (TODO) Spaces around +, -, (cannot check /, * or & due to their other usage - comment, ptr deref, address-of)
- Spaces after comma, not before
- Opening braces not at the end of a code line
- Spaces after if, for, while
- (TODO) Spaces before *, /, &
- (TODO) Spaces after ,
- (TODO) Hex numbers with even digit length
- (TODO) Hex numbers in lowercase
- (TODO) Braces not on the end of line
- (TODO) Line dividers (////...) exactly 80 slashes
- (TODO) Not using "* "-style doxy comment continuation lines
Violations that cannot be checked easily:
- Spaces around "+" (there are things like "a++", "++a", "a += 1", "X+", "stack +1" and ascii-drawn tables)
Reports all violations on stdout in a form that is readable by Visual Studio's parser, so that dblclicking
the line brings the editor directly to the violation.
Returns 0 on success, 1 on internal failure, 2 if any violations found
This script requires LuaFileSystem to be available in the current Lua interpreter.
--]]
-- Check that LFS is installed:
local hasLfs = pcall(require, "lfs")
if not(hasLfs) then
print("This script requires LuaFileSystem to be installed")
os.exit(1)
end
local lfs = require("lfs")
assert(lfs ~= nil)
-- The list of file extensions that are processed:
local g_ShouldProcessExt =
{
@ -49,13 +40,12 @@ local g_ShouldProcessExt =
--- The list of files not to be processed:
local g_IgnoredFiles =
{
"./Bindings/Bindings.cpp",
"./Bindings/DeprecatedBindings.cpp",
"./LeakFinder.cpp",
"./LeakFinder.h",
"./MersenneTwister.h",
"./StackWalker.cpp",
"./StackWalker.h",
"Bindings/Bindings.cpp",
"LeakFinder.cpp",
"LeakFinder.h",
"MersenneTwister.h",
"StackWalker.cpp",
"StackWalker.h",
}
--- The list of files not to be processed, as a dictionary (filename => true), built from g_IgnoredFiles
@ -76,8 +66,8 @@ local g_NumViolations = 0
--- Reports one violation
-- Pretty-prints the message
-- Also increments g_NumViolations
local function ReportViolation(a_FileName, a_LineNumber, a_Message)
print(a_FileName .. "(" .. a_LineNumber .. "): " .. a_Message)
local function ReportViolation(a_FileName, a_LineNumber, a_PatStart, a_PatEnd, a_Message)
print(a_FileName .. "(" .. a_LineNumber .. "): " .. a_PatStart .. " .. " .. a_PatEnd .. ": " .. a_Message)
g_NumViolations = g_NumViolations + 1
end
@ -85,6 +75,64 @@ end
--- Searches for the specified pattern, if found, reports it as a violation with the given message
local function ReportViolationIfFound(a_Line, a_FileName, a_LineNum, a_Pattern, a_Message)
local patStart, patEnd = a_Line:find(a_Pattern)
if not(patStart) then
return
end
ReportViolation(a_FileName, a_LineNum, patStart, patEnd, a_Message)
end
local g_ViolationPatterns =
{
-- Check against indenting using spaces:
{"^\t* +", "Indenting with a space"},
-- Check against alignment using tabs:
{"[^%s]\t+[^%s]", "Aligning with a tab"},
-- Check against trailing whitespace:
{"[^%s]%s+\n", "Trailing whitespace"},
-- Check that all "//"-style comments have at least two spaces in front (unless alone on line):
{"[^%s] //", "Needs at least two spaces in front of a \"//\"-style comment"},
-- Check that all "//"-style comments have at least one spaces after:
{"%s//[^%s/*<]", "Needs a space after a \"//\"-style comment"},
-- Check that all commas have spaces after them and not in front of them:
{" ,", "Extra space before a \",\""},
{",[^%s\"%%]", "Needs a space after a \",\""}, -- Report all except >> "," << needed for splitting and >>,%s<< needed for formatting
-- Check that opening braces are not at the end of a code line:
{"[^%s].-{\n?$", "Brace should be on a separate line"},
-- Space after keywords:
{"[^_]if%(", "Needs a space after \"if\""},
{"for%(", "Needs a space after \"for\""},
{"while%(", "Needs a space after \"while\""},
{"switch%(", "Needs a space after \"switch\""},
{"catch%(", "Needs a space after \"catch\""},
-- No space after keyword's parenthesis:
{"[^%a#]if %( ", "Remove the space after \"(\""},
{"for %( ", "Remove the space after \"(\""},
{"while %( ", "Remove the space after \"(\""},
{"catch %( ", "Remove the space after \"(\""},
-- No space before a closing parenthesis:
{" %)", "Remove the space before \")\""},
}
--- Processes one file
local function ProcessFile(a_FileName)
assert(type(a_FileName) == "string")
@ -103,7 +151,7 @@ local function ProcessFile(a_FileName)
if ((lastChar ~= 13) and (lastChar ~= 10)) then
local numLines = 1
string.gsub(all, "\n", function() numLines = numLines + 1 end) -- Count the number of line-ends
ReportViolation(a_FileName, numLines, "Missing empty line at file end")
ReportViolation(a_FileName, numLines, 1, 1, "Missing empty line at file end")
return
end
@ -113,26 +161,11 @@ local function ProcessFile(a_FileName)
all:gsub("\r\n", "\n") -- normalize CRLF into LF-only
string.gsub(all .. "\n", "[^\n]*\n", -- Iterate over each line, while preserving empty lines
function(a_Line)
-- Check against indenting using spaces:
if (a_Line:find("^\t* +")) then -- Find any number of tabs at the start of line (incl 0), followed by a space
ReportViolation(a_FileName, lineCounter, "Indenting with a space")
end
-- Check against alignment using tabs:
if (a_Line:find("[^%s]\t+[^%s]")) then -- Find any number of tabs after non-whitespace followed by non-whitespace
ReportViolation(a_FileName, lineCounter, "Aligning with a tab")
end
-- Check against trailing whitespace:
if (a_Line:find("[^%s]%s+\n")) then -- Find any whitespace after non-whitespace at the end of line
ReportViolation(a_FileName, lineCounter, "Trailing whitespace")
end
-- Check that all "//"-style comments have at least two spaces in front (unless alone on line):
if (a_Line:find("[^%s] //")) then
ReportViolation(a_FileName, lineCounter, "Needs at least two spaces in front of a \"//\"-style comment")
end
-- Check that all "//"-style comments have at least one spaces after:
if (a_Line:find("%s//[^%s/*<]")) then
ReportViolation(a_FileName, lineCounter, "Needs a space after a \"//\"-style comment")
-- Check against each violation pattern:
for _, pat in ipairs(g_ViolationPatterns) do
ReportViolationIfFound(a_Line, a_FileName, lineCounter, pat[1], pat[2])
end
lineCounter = lineCounter + 1
end
)
@ -151,17 +184,6 @@ local function ProcessItem(a_ItemName)
return
end
-- If the item is a folder, recurse:
local attrs = lfs.attributes(a_ItemName)
if (attrs and (attrs.mode == "directory")) then
for fnam in lfs.dir(a_ItemName) do
if ((fnam ~= ".") and (fnam ~= "..")) then
ProcessItem(a_ItemName .. "/" .. fnam)
end
end
return
end
local ext = a_ItemName:match("%.([^/%.]-)$")
if (g_ShouldProcessExt[ext]) then
ProcessFile(a_ItemName)
@ -172,8 +194,10 @@ end
-- Process the entire current folder:
ProcessItem(".")
-- Process all files in the AllFiles.lst file (generated by cmake):
for fnam in io.lines("AllFiles.lst") do
ProcessItem(fnam)
end
-- Report final verdict:
print("Number of violations found: " .. g_NumViolations)

View File

@ -34,6 +34,7 @@
#include "MobCensus.h"
#include "MobSpawner.h"
#include "BlockInServerPluginInterface.h"
#include "SetChunkData.h"
#include "json/json.h"
@ -44,12 +45,12 @@
////////////////////////////////////////////////////////////////////////////////
// sSetBlock:
sSetBlock::sSetBlock( int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ) // absolute block position
: x( a_BlockX )
, y( a_BlockY )
, z( a_BlockZ )
, BlockType( a_BlockType )
, BlockMeta( a_BlockMeta )
sSetBlock::sSetBlock( int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) // absolute block position
: x( a_BlockX)
, y( a_BlockY)
, z( a_BlockZ)
, BlockType( a_BlockType)
, BlockMeta( a_BlockMeta)
{
cChunkDef::AbsoluteToRelative(x, y, z, ChunkX, ChunkZ);
}
@ -116,7 +117,7 @@ cChunk::~cChunk()
{
cPluginManager::Get()->CallHookChunkUnloaded(m_World, m_PosX, m_PosZ);
// LOGINFO("### delete cChunk() (%i, %i) from %p, thread 0x%x ###", m_PosX, m_PosZ, this, GetCurrentThreadId() );
// LOGINFO("### delete cChunk() (%i, %i) from %p, thread 0x%x ###", m_PosX, m_PosZ, this, GetCurrentThreadId());
for (cBlockEntityList::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end(); ++itr)
{
@ -265,41 +266,34 @@ void cChunk::GetAllData(cChunkDataCallback & a_Callback)
void cChunk::SetAllData(
const BLOCKTYPE * a_BlockTypes,
const NIBBLETYPE * a_BlockMeta,
const NIBBLETYPE * a_BlockLight,
const NIBBLETYPE * a_BlockSkyLight,
const HeightMap * a_HeightMap,
const BiomeMap & a_BiomeMap,
cBlockEntityList & a_BlockEntities
)
void cChunk::SetAllData(cSetChunkData & a_SetChunkData)
{
memcpy(m_BiomeMap, a_BiomeMap, sizeof(m_BiomeMap));
if (a_HeightMap != NULL)
{
memcpy(m_HeightMap, a_HeightMap, sizeof(m_HeightMap));
}
if (a_HeightMap == NULL)
{
CalculateHeightmap(a_BlockTypes);
}
m_ChunkData.SetBlockTypes(a_BlockTypes);
m_ChunkData.SetMetas(a_BlockMeta);
m_ChunkData.SetBlockLight(a_BlockLight);
m_ChunkData.SetSkyLight(a_BlockSkyLight);
ASSERT(a_SetChunkData.IsHeightMapValid());
ASSERT(a_SetChunkData.AreBiomesValid());
m_IsLightValid = (a_BlockLight != NULL) && (a_BlockSkyLight != NULL);
memcpy(m_BiomeMap, a_SetChunkData.GetBiomes(), sizeof(m_BiomeMap));
memcpy(m_HeightMap, a_SetChunkData.GetHeightMap(), sizeof(m_HeightMap));
m_ChunkData.SetBlockTypes(a_SetChunkData.GetBlockTypes());
m_ChunkData.SetMetas(a_SetChunkData.GetBlockMetas());
if (a_SetChunkData.IsLightValid())
{
m_ChunkData.SetBlockLight(a_SetChunkData.GetBlockLight());
m_ChunkData.SetSkyLight(a_SetChunkData.GetSkyLight());
m_IsLightValid = true;
}
else
{
m_IsLightValid = false;
}
// Clear the block entities present - either the loader / saver has better, or we'll create empty ones:
for (cBlockEntityList::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end(); ++itr)
{
delete *itr;
}
std::swap(a_BlockEntities, m_BlockEntities);
m_BlockEntities.clear();
std::swap(a_SetChunkData.GetBlockEntities(), m_BlockEntities);
// Set all block entities' World variable:
for (cBlockEntityList::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end(); ++itr)
@ -455,7 +449,7 @@ void cChunk::CollectMobCensus(cMobCensus& toFill)
currentPosition = Monster.GetPosition();
for (std::list<const Vector3d*>::const_iterator itr2 = playerPositions.begin(); itr2 != playerPositions.end(); ++itr2)
{
toFill.CollectMob(Monster,*this,(currentPosition-**itr2).SqrLength());
toFill.CollectMob(Monster, *this, (currentPosition - **itr2).SqrLength());
}
}
} // for itr - m_Entitites[]
@ -464,7 +458,7 @@ void cChunk::CollectMobCensus(cMobCensus& toFill)
void cChunk::GetThreeRandomNumbers(int & a_X, int & a_Y, int & a_Z,int a_MaxX, int a_MaxY, int a_MaxZ)
void cChunk::GetThreeRandomNumbers(int & a_X, int & a_Y, int & a_Z, int a_MaxX, int a_MaxY, int a_MaxZ)
{
ASSERT(a_MaxX * a_MaxY * a_MaxZ * 8 < 0x00ffffff);
int Random = m_World->GetTickRandomNumber(0x00ffffff);
@ -638,7 +632,7 @@ void cChunk::TickBlock(int a_RelX, int a_RelY, int a_RelZ)
ASSERT(Handler != NULL); // 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);
Handler->OnUpdate(ChunkInterface, *this->GetWorld(), PluginInterface, *this, a_RelX, a_RelY, a_RelZ);
}
@ -781,7 +775,7 @@ void cChunk::CheckBlocks()
void cChunk::TickBlocks(void)
{
// Tick dem blocks
// _X: We must limit the random number or else we get a nasty int overflow bug ( http://forum.mc-server.org/showthread.php?tid=457 )
// _X: We must limit the random number or else we get a nasty int overflow bug - http://forum.mc-server.org/showthread.php?tid=457
int RandomX = m_World->GetTickRandomNumber(0x00ffffff);
int RandomY = m_World->GetTickRandomNumber(0x00ffffff);
int RandomZ = m_World->GetTickRandomNumber(0x00ffffff);
@ -1394,7 +1388,7 @@ void cChunk::CalculateHeightmap(const BLOCKTYPE * a_BlockTypes)
{
for (int y = Height - 1; y > -1; y--)
{
int index = MakeIndex( x, y, z );
int index = MakeIndex( x, y, z);
if (a_BlockTypes[index] != E_BLOCK_AIR)
{
m_HeightMap[x + z * Width] = (HEIGHTTYPE)y;
@ -1530,11 +1524,12 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT
m_ChunkData.SetBlock(a_RelX, a_RelY, a_RelZ, a_BlockType);
if ( // Queue block to be sent only if ...
// Queue block to be sent only if ...
if (
a_SendToClients && // ... we are told to do so AND ...
(
(OldBlockMeta != a_BlockMeta) || // ... the meta value is different OR ...
!( // ... the old and new blocktypes AREN'T liquids (because client doesn't need to distinguish betwixt them); see below for specifics:
!( // ... the old and new blocktypes AREN'T liquids (because client doesn't need to distinguish betwixt them):
((OldBlockType == E_BLOCK_STATIONARY_WATER) && (a_BlockType == E_BLOCK_WATER)) || // Replacing stationary water with water
((OldBlockType == E_BLOCK_WATER) && (a_BlockType == E_BLOCK_STATIONARY_WATER)) || // Replacing water with stationary water
((OldBlockType == E_BLOCK_STATIONARY_LAVA) && (a_BlockType == E_BLOCK_LAVA)) || // Replacing stationary water with water
@ -1729,9 +1724,9 @@ void cChunk::CollectPickupsByPlayer(cPlayer * a_Player)
{
continue; // Only pickups and projectiles can be picked up
}
float DiffX = (float)((*itr)->GetPosX() - PosX );
float DiffY = (float)((*itr)->GetPosY() - PosY );
float DiffZ = (float)((*itr)->GetPosZ() - PosZ );
float DiffX = (float)((*itr)->GetPosX() - PosX);
float DiffY = (float)((*itr)->GetPosY() - PosY);
float DiffZ = (float)((*itr)->GetPosZ() - PosZ);
float SqrDist = DiffX * DiffX + DiffY * DiffY + DiffZ * DiffZ;
if (SqrDist < 1.5f * 1.5f) // 1.5 block
{
@ -1793,7 +1788,7 @@ bool cChunk::SetSignLines(int a_PosX, int a_PosY, int a_PosZ, const AString & a_
void cChunk::RemoveBlockEntity( cBlockEntity* a_BlockEntity )
void cChunk::RemoveBlockEntity( cBlockEntity* a_BlockEntity)
{
MarkDirty();
m_BlockEntities.remove(a_BlockEntity);
@ -1813,9 +1808,9 @@ bool cChunk::AddClient(cClientHandle* a_Client)
return false;
}
}
m_LoadedByClient.push_back( a_Client );
m_LoadedByClient.push_back( a_Client);
for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr )
for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr)
{
/*
// DEBUG:
@ -1834,7 +1829,7 @@ bool cChunk::AddClient(cClientHandle* a_Client)
void cChunk::RemoveClient( cClientHandle* a_Client )
void cChunk::RemoveClient( cClientHandle* a_Client)
{
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
@ -1847,7 +1842,7 @@ void cChunk::RemoveClient( cClientHandle* a_Client )
if (!a_Client->IsDestroyed())
{
for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr )
for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr)
{
/*
// DEBUG:
@ -1867,7 +1862,7 @@ void cChunk::RemoveClient( cClientHandle* a_Client )
bool cChunk::HasClient( cClientHandle* a_Client )
bool cChunk::HasClient( cClientHandle* a_Client)
{
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
@ -2652,7 +2647,7 @@ cChunk * cChunk::GetRelNeighborChunkAdjustCoords(int & a_RelX, int & a_RelZ) con
void cChunk::BroadcastAttachEntity(const cEntity & a_Entity, const cEntity * a_Vehicle)
{
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
(*itr)->SendAttachEntity(a_Entity, a_Vehicle);
} // for itr - LoadedByClient[]
@ -2664,7 +2659,7 @@ void cChunk::BroadcastAttachEntity(const cEntity & a_Entity, const cEntity * a_V
void cChunk::BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude)
{
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@ -2680,7 +2675,7 @@ void cChunk::BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char
void cChunk::BroadcastBlockBreakAnimation(int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage, const cClientHandle * a_Exclude)
{
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@ -2702,7 +2697,7 @@ void cChunk::BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cons
{
return;
}
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@ -2718,7 +2713,7 @@ void cChunk::BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cons
void cChunk::BroadcastChunkData(cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude)
{
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@ -2734,7 +2729,7 @@ void cChunk::BroadcastChunkData(cChunkDataSerializer & a_Serializer, const cClie
void cChunk::BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, const cClientHandle * a_Exclude)
{
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@ -2750,7 +2745,7 @@ void cChunk::BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_
void cChunk::BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandle * a_Exclude)
{
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@ -2766,7 +2761,7 @@ void cChunk::BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandl
void cChunk::BroadcastEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude)
{
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@ -2782,7 +2777,7 @@ void cChunk::BroadcastEntityEffect(const cEntity & a_Entity, int a_EffectID, int
void cChunk::BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude)
{
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@ -2798,7 +2793,7 @@ void cChunk::BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum,
void cChunk::BroadcastEntityHeadLook(const cEntity & a_Entity, const cClientHandle * a_Exclude)
{
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@ -2814,7 +2809,7 @@ void cChunk::BroadcastEntityHeadLook(const cEntity & a_Entity, const cClientHand
void cChunk::BroadcastEntityLook(const cEntity & a_Entity, const cClientHandle * a_Exclude)
{
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@ -2830,7 +2825,7 @@ void cChunk::BroadcastEntityLook(const cEntity & a_Entity, const cClientHandle *
void cChunk::BroadcastEntityMetadata(const cEntity & a_Entity, const cClientHandle * a_Exclude)
{
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@ -2846,7 +2841,7 @@ void cChunk::BroadcastEntityMetadata(const cEntity & a_Entity, const cClientHand
void cChunk::BroadcastEntityRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude)
{
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@ -2862,7 +2857,7 @@ void cChunk::BroadcastEntityRelMove(const cEntity & a_Entity, char a_RelX, char
void cChunk::BroadcastEntityRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude)
{
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@ -2878,7 +2873,7 @@ void cChunk::BroadcastEntityRelMoveLook(const cEntity & a_Entity, char a_RelX, c
void cChunk::BroadcastEntityStatus(const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude)
{
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@ -2894,7 +2889,7 @@ void cChunk::BroadcastEntityStatus(const cEntity & a_Entity, char a_Status, cons
void cChunk::BroadcastEntityVelocity(const cEntity & a_Entity, const cClientHandle * a_Exclude)
{
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@ -2910,7 +2905,7 @@ void cChunk::BroadcastEntityVelocity(const cEntity & a_Entity, const cClientHand
void cChunk::BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude)
{
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@ -2926,7 +2921,7 @@ void cChunk::BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation
void cChunk::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_ParticleAmmount, cClientHandle * a_Exclude)
{
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@ -2942,7 +2937,7 @@ void cChunk::BroadcastParticleEffect(const AString & a_ParticleName, float a_Src
void cChunk::BroadcastRemoveEntityEffect(const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude)
{
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@ -2958,7 +2953,7 @@ void cChunk::BroadcastRemoveEntityEffect(const cEntity & a_Entity, int a_EffectI
void cChunk::BroadcastSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude)
{
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@ -2974,7 +2969,7 @@ void cChunk::BroadcastSoundEffect(const AString & a_SoundName, double a_X, doubl
void cChunk::BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude)
{
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@ -2990,7 +2985,7 @@ void cChunk::BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY
void cChunk::BroadcastSpawnEntity(cEntity & a_Entity, const cClientHandle * a_Exclude)
{
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@ -3006,7 +3001,7 @@ void cChunk::BroadcastSpawnEntity(cEntity & a_Entity, const cClientHandle * a_Ex
void cChunk::BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude)
{
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
if (*itr == a_Exclude)
{
@ -3020,9 +3015,9 @@ void cChunk::BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, cons
void cChunk::BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ )
void cChunk::BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ)
{
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
(*itr)->SendUseBed(a_Entity, a_BlockX, a_BlockY, a_BlockZ);
} // for itr - LoadedByClient[]

View File

@ -82,9 +82,9 @@ public:
/*
To save a chunk, the WSSchema must:
1. Mark the chunk as being saved (MarkSaving() )
1. Mark the chunk as being saved (MarkSaving())
2. Get the chunk's data using GetAllData()
3. Mark the chunk as saved (MarkSaved() )
3. Mark the chunk as saved (MarkSaved())
If anywhere inside this sequence another thread mmodifies the chunk, the chunk will not get marked as saved in MarkSaved()
*/
void MarkSaving(void); // Marks the chunk as being saved.
@ -95,16 +95,10 @@ public:
/** Gets all chunk data, calls the a_Callback's methods for each data type */
void GetAllData(cChunkDataCallback & a_Callback);
/** Sets all chunk data */
void SetAllData(
const BLOCKTYPE * a_BlockTypes,
const NIBBLETYPE * a_BlockMeta,
const NIBBLETYPE * a_BlockLight,
const NIBBLETYPE * a_BlockSkyLight,
const cChunkDef::HeightMap * a_HeightMap,
const cChunkDef::BiomeMap & a_BiomeMap,
cBlockEntityList & a_BlockEntities
);
/** Sets all chunk data as either loaded from the storage or generated.
BlockLight and BlockSkyLight are optional, if not present, chunk will be marked as unlighted.
Modifies the BlockEntity list in a_SetChunkData - moves the block entities into the chunk. */
void SetAllData(cSetChunkData & a_SetChunkData);
void SetLight(
const cChunkDef::BlockNibbles & a_BlockLight,
@ -144,7 +138,7 @@ public:
void SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, bool a_SendToClients = true);
// SetBlock() does a lot of work (heightmap, tickblocks, blockentities) so a BlockIdx version doesn't make sense
void SetBlock( const Vector3i & a_RelBlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ) { SetBlock( a_RelBlockPos.x, a_RelBlockPos.y, a_RelBlockPos.z, a_BlockType, a_BlockMeta ); }
void SetBlock( const Vector3i & a_RelBlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) { SetBlock( a_RelBlockPos.x, a_RelBlockPos.y, a_RelBlockPos.z, a_BlockType, a_BlockMeta); }
/** Queues a block change till the specified world tick */
void QueueSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Int64 a_Tick, BLOCKTYPE a_PreviousBlockType = E_BLOCK_AIR);
@ -195,7 +189,7 @@ public:
/** Sets the sign text. Returns true if successful. Also sends update packets to all clients in the chunk */
bool SetSignLines(int a_RelX, int a_RelY, int a_RelZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4);
int GetHeight( int a_X, int a_Z );
int GetHeight( int a_X, int a_Z);
void SendBlockTo(int a_RelX, int a_RelY, int a_RelZ, cClientHandle * a_Client);
@ -301,7 +295,7 @@ public:
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 BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ );
void BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ);
void SendBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client);
@ -311,7 +305,7 @@ public:
}
void PositionToWorldPosition(int a_RelX, int a_RelY, int a_RelZ, int & a_BlockX, int & a_BlockY, int & a_BlockZ);
Vector3i PositionToWorldPosition(int a_RelX, int a_RelY, int a_RelZ );
Vector3i PositionToWorldPosition(int a_RelX, int a_RelY, int a_RelZ);
inline void MarkDirty(void)
{
@ -386,9 +380,9 @@ public:
cRedstoneSimulatorChunkData * GetRedstoneSimulatorData(void) { return &m_RedstoneSimulatorData; }
cRedstoneSimulatorChunkData * GetRedstoneSimulatorQueuedData(void) { return &m_RedstoneSimulatorQueuedData; }
cIncrementalRedstoneSimulator::PoweredBlocksList * GetRedstoneSimulatorPoweredBlocksList(void) { return &m_RedstoneSimulatorPoweredBlocksList; }
cIncrementalRedstoneSimulator::LinkedBlocksList * GetRedstoneSimulatorLinkedBlocksList(void) { return &m_RedstoneSimulatorLinkedBlocksList; };
cIncrementalRedstoneSimulator::SimulatedPlayerToggleableList * GetRedstoneSimulatorSimulatedPlayerToggleableList(void) { return &m_RedstoneSimulatorSimulatedPlayerToggleableList; };
cIncrementalRedstoneSimulator::RepeatersDelayList * GetRedstoneSimulatorRepeatersDelayList(void) { return &m_RedstoneSimulatorRepeatersDelayList; };
cIncrementalRedstoneSimulator::LinkedBlocksList * GetRedstoneSimulatorLinkedBlocksList(void) { return &m_RedstoneSimulatorLinkedBlocksList; }
cIncrementalRedstoneSimulator::SimulatedPlayerToggleableList * GetRedstoneSimulatorSimulatedPlayerToggleableList(void) { return &m_RedstoneSimulatorSimulatedPlayerToggleableList; }
cIncrementalRedstoneSimulator::RepeatersDelayList * GetRedstoneSimulatorRepeatersDelayList(void) { return &m_RedstoneSimulatorRepeatersDelayList; }
bool IsRedstoneDirty(void) const { return m_IsRedstoneDirty; }
void SetIsRedstoneDirty(bool a_Flag) { m_IsRedstoneDirty = a_Flag; }

View File

@ -29,25 +29,25 @@ public:
(only in processes where multiple chunks can be processed, such as cWorld::ForEachChunkInRect()).
If false is returned, the chunk is skipped.
*/
virtual bool Coords(int a_ChunkX, int a_ChunkZ) { UNUSED(a_ChunkX); UNUSED(a_ChunkZ); return true; };
virtual bool Coords(int a_ChunkX, int a_ChunkZ) { UNUSED(a_ChunkX); UNUSED(a_ChunkZ); return true; }
/// Called once to provide heightmap data
virtual void HeightMap(const cChunkDef::HeightMap * a_HeightMap) {UNUSED(a_HeightMap); };
virtual void HeightMap(const cChunkDef::HeightMap * a_HeightMap) { UNUSED(a_HeightMap); }
/// Called once to provide biome data
virtual void BiomeData(const cChunkDef::BiomeMap * a_BiomeMap) {UNUSED(a_BiomeMap); };
virtual void BiomeData(const cChunkDef::BiomeMap * a_BiomeMap) { UNUSED(a_BiomeMap); }
/// Called once to let know if the chunk lighting is valid. Return value is ignored
virtual void LightIsValid(bool a_IsLightValid) {UNUSED(a_IsLightValid); };
virtual void LightIsValid(bool a_IsLightValid) { UNUSED(a_IsLightValid); }
/// Called once to export block info
virtual void ChunkData(const cChunkData & a_Buffer) {UNUSED(a_Buffer); };
virtual void ChunkData(const cChunkData & a_Buffer) { UNUSED(a_Buffer); }
/// Called for each entity in the chunk
virtual void Entity(cEntity * a_Entity) {UNUSED(a_Entity); };
virtual void Entity(cEntity * a_Entity) { UNUSED(a_Entity); }
/// Called for each blockentity in the chunk
virtual void BlockEntity(cBlockEntity * a_Entity) {UNUSED(a_Entity); };
virtual void BlockEntity(cBlockEntity * a_Entity) { UNUSED(a_Entity); }
} ;

View File

@ -92,7 +92,7 @@ public:
/// Converts absolute block coords into relative (chunk + block) coords:
inline static void AbsoluteToRelative(/* in-out */ int & a_X, int & a_Y, int & a_Z, /* out */ int & a_ChunkX, int & a_ChunkZ )
inline static void AbsoluteToRelative(/* in-out */ int & a_X, int & a_Y, int & a_Z, /* out */ int & a_ChunkX, int & a_ChunkZ)
{
UNUSED(a_Y);
BlockToChunk(a_X, a_Z, a_ChunkX, a_ChunkZ);
@ -118,7 +118,7 @@ public:
}
inline static int MakeIndex(int x, int y, int z )
inline static int MakeIndex(int x, int y, int z)
{
if (
(x < Width) && (x > -1) &&
@ -145,7 +145,7 @@ public:
}
inline static Vector3i IndexToCoordinate( unsigned int index )
inline static Vector3i IndexToCoordinate( unsigned int index)
{
#if AXIS_ORDER == AXIS_ORDER_XZY
return Vector3i( // 1.2
@ -357,7 +357,7 @@ struct sSetBlock
BLOCKTYPE BlockType;
NIBBLETYPE BlockMeta;
sSetBlock( int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ); // absolute block position
sSetBlock( int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); // absolute block position
sSetBlock(int a_ChunkX, int a_ChunkZ, int a_X, int a_Y, int a_Z, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) :
x(a_X), y(a_Y), z(a_Z),
ChunkX(a_ChunkX), ChunkZ(a_ChunkZ),

View File

@ -16,6 +16,7 @@
#include "MobCensus.h"
#include "MobSpawner.h"
#include "BoundingBox.h"
#include "SetChunkData.h"
#include "Entities/Pickup.h"
@ -64,7 +65,7 @@ cChunkMap::~cChunkMap()
void cChunkMap::RemoveLayer( cChunkLayer* a_Layer )
void cChunkMap::RemoveLayer( cChunkLayer* a_Layer)
{
cCSLock Lock(m_CSLayers);
m_Layers.remove(a_Layer);
@ -147,7 +148,7 @@ cChunkPtr cChunkMap::GetChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
// No need to lock m_CSLayers, since it's already locked by the operation that called us
ASSERT(m_CSLayers.IsLockedByCurrentThread());
cChunkLayer * Layer = GetLayerForChunk( a_ChunkX, a_ChunkZ );
cChunkLayer * Layer = GetLayerForChunk( a_ChunkX, a_ChunkZ);
if (Layer == NULL)
{
// An error must have occurred, since layers are automatically created if they don't exist
@ -170,10 +171,10 @@ cChunkPtr cChunkMap::GetChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
cChunkPtr cChunkMap::GetChunkNoGen( int a_ChunkX, int a_ChunkY, int a_ChunkZ )
cChunkPtr cChunkMap::GetChunkNoGen( int a_ChunkX, int a_ChunkY, int a_ChunkZ)
{
// No need to lock m_CSLayers, since it's already locked by the operation that called us
cChunkLayer * Layer = GetLayerForChunk( a_ChunkX, a_ChunkZ );
cChunkLayer * Layer = GetLayerForChunk( a_ChunkX, a_ChunkZ);
if (Layer == NULL)
{
// An error must have occurred, since layers are automatically created if they don't exist
@ -197,10 +198,10 @@ cChunkPtr cChunkMap::GetChunkNoGen( int a_ChunkX, int a_ChunkY, int a_ChunkZ )
cChunkPtr cChunkMap::GetChunkNoLoad( int a_ChunkX, int a_ChunkY, int a_ChunkZ )
cChunkPtr cChunkMap::GetChunkNoLoad( int a_ChunkX, int a_ChunkY, int a_ChunkZ)
{
// No need to lock m_CSLayers, since it's already locked by the operation that called us
cChunkLayer * Layer = GetLayerForChunk( a_ChunkX, a_ChunkZ );
cChunkLayer * Layer = GetLayerForChunk( a_ChunkX, a_ChunkZ);
if (Layer == NULL)
{
// An error must have occurred, since layers are automatically created if they don't exist
@ -720,7 +721,7 @@ void cChunkMap::BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, c
void cChunkMap::BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ )
void cChunkMap::BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ)
{
cCSLock Lock(m_CSLayers);
int ChunkX, ChunkZ;
@ -912,28 +913,20 @@ void cChunkMap::MarkChunkSaved (int a_ChunkX, int a_ChunkZ)
void cChunkMap::SetChunkData(
int a_ChunkX, int a_ChunkZ,
const BLOCKTYPE * a_BlockTypes,
const NIBBLETYPE * a_BlockMeta,
const NIBBLETYPE * a_BlockLight,
const NIBBLETYPE * a_BlockSkyLight,
const cChunkDef::HeightMap * a_HeightMap,
const cChunkDef::BiomeMap & a_BiomeMap,
cBlockEntityList & a_BlockEntities,
bool a_MarkDirty
)
void cChunkMap::SetChunkData(cSetChunkData & a_SetChunkData)
{
int ChunkX = a_SetChunkData.GetChunkX();
int ChunkZ = a_SetChunkData.GetChunkZ();
{
cCSLock Lock(m_CSLayers);
cChunkPtr Chunk = GetChunkNoLoad(a_ChunkX, ZERO_CHUNK_Y, a_ChunkZ);
cChunkPtr Chunk = GetChunkNoLoad(ChunkX, ZERO_CHUNK_Y, ChunkZ);
if (Chunk == NULL)
{
return;
}
Chunk->SetAllData(a_BlockTypes, a_BlockMeta, a_BlockLight, a_BlockSkyLight, a_HeightMap, a_BiomeMap, a_BlockEntities);
Chunk->SetAllData(a_SetChunkData);
if (a_MarkDirty)
if (a_SetChunkData.ShouldMarkDirty())
{
Chunk->MarkDirty();
}
@ -942,7 +935,7 @@ void cChunkMap::SetChunkData(
cChunkStays ToBeDisabled;
for (cChunkStays::iterator itr = m_ChunkStays.begin(), end = m_ChunkStays.end(); itr != end; ++itr)
{
if ((*itr)->ChunkAvailable(a_ChunkX, a_ChunkZ))
if ((*itr)->ChunkAvailable(ChunkX, ChunkZ))
{
// The chunkstay wants to be disabled, add it to a list of to-be-disabled chunkstays for later processing:
ToBeDisabled.push_back(*itr);
@ -957,7 +950,7 @@ void cChunkMap::SetChunkData(
}
// Notify plugins of the chunk becoming available
cPluginManager::Get()->CallHookChunkAvailable(m_World, a_ChunkX, a_ChunkZ);
cPluginManager::Get()->CallHookChunkAvailable(m_World, ChunkX, ChunkZ);
}
@ -1154,9 +1147,9 @@ void cChunkMap::CollectPickupsByPlayer(cPlayer * a_Player)
GetChunkNoLoad(ChunkX, ChunkY, ChunkZ)->CollectPickupsByPlayer(a_Player);
// Check the neighboring chunks as well:
GetChunkNoLoad(OtherChunkX, ChunkY, ChunkZ )->CollectPickupsByPlayer(a_Player);
GetChunkNoLoad(OtherChunkX, ChunkY, ChunkZ)->CollectPickupsByPlayer (a_Player);
GetChunkNoLoad(OtherChunkX, ChunkY, OtherChunkZ)->CollectPickupsByPlayer(a_Player);
GetChunkNoLoad(ChunkX, ChunkY, ChunkZ )->CollectPickupsByPlayer(a_Player);
GetChunkNoLoad(ChunkX, ChunkY, ChunkZ)->CollectPickupsByPlayer (a_Player);
GetChunkNoLoad(ChunkX, ChunkY, OtherChunkZ)->CollectPickupsByPlayer(a_Player);
}
@ -1181,7 +1174,7 @@ BLOCKTYPE cChunkMap::GetBlock(int a_BlockX, int a_BlockY, int a_BlockZ)
} // for itr - m_FastSetBlockQueue[]
}
int ChunkX, ChunkZ;
cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ );
cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ);
cCSLock Lock(m_CSLayers);
cChunkPtr Chunk = GetChunk(ChunkX, ZERO_CHUNK_Y, ChunkZ);
@ -1210,11 +1203,11 @@ NIBBLETYPE cChunkMap::GetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ)
} // for itr - m_FastSetBlockQueue[]
}
int ChunkX, ChunkZ;
cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ );
cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ);
cCSLock Lock(m_CSLayers);
cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ );
if ((Chunk != NULL) && Chunk->IsValid() )
cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ);
if ((Chunk != NULL) && Chunk->IsValid())
{
return Chunk->GetMeta(a_BlockX, a_BlockY, a_BlockZ);
}
@ -1228,11 +1221,11 @@ NIBBLETYPE cChunkMap::GetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ)
NIBBLETYPE cChunkMap::GetBlockSkyLight(int a_BlockX, int a_BlockY, int a_BlockZ)
{
int ChunkX, ChunkZ;
cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ );
cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ);
cCSLock Lock(m_CSLayers);
cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ );
if ((Chunk != NULL) && Chunk->IsValid() )
cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ);
if ((Chunk != NULL) && Chunk->IsValid())
{
return Chunk->GetSkyLight(a_BlockX, a_BlockY, a_BlockZ);
}
@ -1246,11 +1239,11 @@ NIBBLETYPE cChunkMap::GetBlockSkyLight(int a_BlockX, int a_BlockY, int a_BlockZ)
NIBBLETYPE cChunkMap::GetBlockBlockLight(int a_BlockX, int a_BlockY, int a_BlockZ)
{
int ChunkX, ChunkZ;
cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ );
cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ);
cCSLock Lock(m_CSLayers);
cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ );
if ((Chunk != NULL) && Chunk->IsValid() )
cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ);
if ((Chunk != NULL) && Chunk->IsValid())
{
return Chunk->GetBlockLight(a_BlockX, a_BlockY, a_BlockZ);
}
@ -1288,10 +1281,10 @@ void cChunkMap::SetBlock(cWorldInterface & a_WorldInterface, int a_BlockX, int a
}
int ChunkX, ChunkZ, X = a_BlockX, Y = a_BlockY, Z = a_BlockZ;
cChunkDef::AbsoluteToRelative( X, Y, Z, ChunkX, ChunkZ );
cChunkDef::AbsoluteToRelative( X, Y, Z, ChunkX, ChunkZ);
cCSLock Lock(m_CSLayers);
cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ );
cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ);
if ((Chunk != NULL) && Chunk->IsValid())
{
Chunk->SetBlock(X, Y, Z, a_BlockType, a_BlockMeta, a_SendToClients);
@ -1324,10 +1317,10 @@ void cChunkMap::QueueSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYP
bool cChunkMap::GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta)
{
int ChunkX, ChunkZ, X = a_BlockX, Y = a_BlockY, Z = a_BlockZ;
cChunkDef::AbsoluteToRelative( X, Y, Z, ChunkX, ChunkZ );
cChunkDef::AbsoluteToRelative( X, Y, Z, ChunkX, ChunkZ);
cCSLock Lock(m_CSLayers);
cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ );
cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ);
if ((Chunk != NULL) && Chunk->IsValid())
{
Chunk->GetBlockTypeMeta(X, Y, Z, a_BlockType, a_BlockMeta);
@ -1343,10 +1336,10 @@ bool cChunkMap::GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCK
bool cChunkMap::GetBlockInfo(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_Meta, NIBBLETYPE & a_SkyLight, NIBBLETYPE & a_BlockLight)
{
int ChunkX, ChunkZ, X = a_BlockX, Y = a_BlockY, Z = a_BlockZ;
cChunkDef::AbsoluteToRelative( X, Y, Z, ChunkX, ChunkZ );
cChunkDef::AbsoluteToRelative( X, Y, Z, ChunkX, ChunkZ);
cCSLock Lock(m_CSLayers);
cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ );
cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ);
if ((Chunk != NULL) && Chunk->IsValid())
{
Chunk->GetBlockInfo(X, Y, Z, a_BlockType, a_Meta, a_SkyLight, a_BlockLight);
@ -1364,7 +1357,7 @@ void cChunkMap::ReplaceBlocks(const sSetBlockVector & a_Blocks, BLOCKTYPE a_Filt
cCSLock Lock(m_CSLayers);
for (sSetBlockVector::const_iterator itr = a_Blocks.begin(); itr != a_Blocks.end(); ++itr)
{
cChunkPtr Chunk = GetChunk(itr->ChunkX, ZERO_CHUNK_Y, itr->ChunkZ );
cChunkPtr Chunk = GetChunk(itr->ChunkX, ZERO_CHUNK_Y, itr->ChunkZ);
if ((Chunk == NULL) || !Chunk->IsValid())
{
continue;
@ -1385,7 +1378,7 @@ void cChunkMap::ReplaceTreeBlocks(const sSetBlockVector & a_Blocks)
cCSLock Lock(m_CSLayers);
for (sSetBlockVector::const_iterator itr = a_Blocks.begin(); itr != a_Blocks.end(); ++itr)
{
cChunkPtr Chunk = GetChunk(itr->ChunkX, ZERO_CHUNK_Y, itr->ChunkZ );
cChunkPtr Chunk = GetChunk(itr->ChunkX, ZERO_CHUNK_Y, itr->ChunkZ);
if ((Chunk == NULL) || !Chunk->IsValid())
{
continue;
@ -1498,7 +1491,7 @@ bool cChunkMap::GetBlocks(sSetBlockVector & a_Blocks, bool a_ContinueOnFailure)
cCSLock Lock(m_CSLayers);
for (sSetBlockVector::iterator itr = a_Blocks.begin(); itr != a_Blocks.end(); ++itr)
{
cChunkPtr Chunk = GetChunk(itr->ChunkX, ZERO_CHUNK_Y, itr->ChunkZ );
cChunkPtr Chunk = GetChunk(itr->ChunkX, ZERO_CHUNK_Y, itr->ChunkZ);
if ((Chunk == NULL) || !Chunk->IsValid())
{
if (!a_ContinueOnFailure)
@ -1522,17 +1515,17 @@ bool cChunkMap::DigBlock(int a_X, int a_Y, int a_Z)
{
int PosX = a_X, PosY = a_Y, PosZ = a_Z, ChunkX, ChunkZ;
cChunkDef::AbsoluteToRelative( PosX, PosY, PosZ, ChunkX, ChunkZ );
cChunkDef::AbsoluteToRelative( PosX, PosY, PosZ, ChunkX, ChunkZ);
{
cCSLock Lock(m_CSLayers);
cChunkPtr DestChunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ );
cChunkPtr DestChunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ);
if ((DestChunk == NULL) || !DestChunk->IsValid())
{
return false;
}
DestChunk->SetBlock(PosX, PosY, PosZ, E_BLOCK_AIR, 0 );
DestChunk->SetBlock(PosX, PosY, PosZ, E_BLOCK_AIR, 0);
m_World->GetSimulatorManager()->WakeUp(a_X, a_Y, a_Z, DestChunk);
}
@ -1951,10 +1944,7 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
double FinalDamage = (((1 / AbsoluteEntityPos.x) + (1 / AbsoluteEntityPos.y) + (1 / AbsoluteEntityPos.z)) * 2) * m_ExplosionSize;
// Clip damage values
if (FinalDamage > a_Entity->GetMaxHealth())
FinalDamage = a_Entity->GetMaxHealth();
else if (FinalDamage < 0)
FinalDamage = 0;
FinalDamage = Clamp(FinalDamage, 0.0, (double)a_Entity->GetMaxHealth());
if (!a_Entity->IsTNT() && !a_Entity->IsFallingBlock()) // Don't apply damage to other TNT entities and falling blocks, they should be invincible
{
@ -2718,10 +2708,10 @@ cChunkMap::cChunkLayer::cChunkLayer(
cChunkMap * a_Parent,
cAllocationPool<cChunkData::sChunkSection> & a_Pool
)
: m_LayerX( a_LayerX )
, m_LayerZ( a_LayerZ )
, m_Parent( a_Parent )
, m_NumChunksLoaded( 0 )
: m_LayerX( a_LayerX)
, m_LayerZ( a_LayerZ)
, m_Parent( a_Parent)
, m_NumChunksLoaded( 0)
, m_Pool(a_Pool)
{
memset(m_Chunks, 0, sizeof(m_Chunks));
@ -2744,7 +2734,7 @@ cChunkMap::cChunkLayer::~cChunkLayer()
cChunkPtr cChunkMap::cChunkLayer::GetChunk( int a_ChunkX, int a_ChunkY, int a_ChunkZ )
cChunkPtr cChunkMap::cChunkLayer::GetChunk( int a_ChunkX, int a_ChunkY, int a_ChunkZ)
{
// Always returns an assigned chunkptr, but the chunk needn't be valid (loaded / generated) - callers must check
@ -2762,8 +2752,8 @@ cChunkPtr cChunkMap::cChunkLayer::GetChunk( int a_ChunkX, int a_ChunkY, int a_Ch
{
cChunk * neixm = (LocalX > 0) ? m_Chunks[Index - 1] : m_Parent->FindChunk(a_ChunkX - 1, a_ChunkZ);
cChunk * neixp = (LocalX < LAYER_SIZE - 1) ? m_Chunks[Index + 1] : m_Parent->FindChunk(a_ChunkX + 1, a_ChunkZ);
cChunk * neizm = (LocalZ > 0) ? m_Chunks[Index - LAYER_SIZE] : m_Parent->FindChunk(a_ChunkX , a_ChunkZ - 1);
cChunk * neizp = (LocalZ < LAYER_SIZE - 1) ? m_Chunks[Index + LAYER_SIZE] : m_Parent->FindChunk(a_ChunkX , a_ChunkZ + 1);
cChunk * neizm = (LocalZ > 0) ? m_Chunks[Index - LAYER_SIZE] : m_Parent->FindChunk(a_ChunkX, a_ChunkZ - 1);
cChunk * neizp = (LocalZ < LAYER_SIZE - 1) ? m_Chunks[Index + LAYER_SIZE] : m_Parent->FindChunk(a_ChunkX, a_ChunkZ + 1);
m_Chunks[Index] = new cChunk(a_ChunkX, 0, a_ChunkZ, m_Parent, m_Parent->GetWorld(), neixm, neixp, neizm, neizp, m_Pool);
}
return m_Chunks[Index];

View File

@ -34,6 +34,7 @@ class cChunkDataSerializer;
class cBlockArea;
class cMobCensus;
class cMobSpawner;
class cSetChunkData;
typedef std::list<cClientHandle *> cClientHandleList;
typedef cChunk * cChunkPtr;
@ -60,7 +61,7 @@ public:
static const int LAYER_SIZE = 32;
cChunkMap(cWorld* a_World );
cChunkMap(cWorld* a_World);
~cChunkMap();
// Broadcast respective packets to all clients of the chunk where the event is taking place
@ -89,7 +90,7 @@ public:
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 BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ );
void BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ);
/** Sends the block entity, if it is at the coords specified, to a_Client */
void SendBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client);
@ -112,22 +113,11 @@ public:
void MarkChunkSaved (int a_ChunkX, int a_ChunkZ);
/** Sets the chunk data as either loaded from the storage or generated.
a_BlockLight and a_BlockSkyLight are optional, if not present, chunk will be marked as unlighted.
a_BiomeMap is optional, if not present, biomes will be calculated by the generator
a_HeightMap is optional, if not present, will be calculated.
If a_MarkDirty is set, the chunk is set as dirty (used after generating)
BlockLight and BlockSkyLight are optional, if not present, chunk will be marked as unlighted.
If MarkDirty is set, the chunk is set as dirty (used after generating)
Modifies the BlockEntity list in a_SetChunkData - moves the block entities into the chunk.
*/
void SetChunkData(
int a_ChunkX, int a_ChunkZ,
const BLOCKTYPE * a_BlockTypes,
const NIBBLETYPE * a_BlockMeta,
const NIBBLETYPE * a_BlockLight,
const NIBBLETYPE * a_BlockSkyLight,
const cChunkDef::HeightMap * a_HeightMap,
const cChunkDef::BiomeMap & a_BiomeMap,
cBlockEntityList & a_BlockEntities,
bool a_MarkDirty
);
void SetChunkData(cSetChunkData & a_SetChunkData);
void ChunkLighted(
int a_ChunkX, int a_ChunkZ,
@ -289,7 +279,7 @@ public:
/** Sets the sign text. Returns true if sign text changed. */
bool SetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4);
/** Marks the chunk as being regenerated - all its clients want that chunk again (used by cWorld::RegenerateChunk() ) */
/** Marks the chunk as being regenerated - all its clients want that chunk again (used by cWorld::RegenerateChunk()) */
void MarkChunkRegenerating(int a_ChunkX, int a_ChunkZ);
bool IsChunkLighted(int a_ChunkX, int a_ChunkZ);
@ -368,7 +358,7 @@ private:
~cChunkLayer();
/** Always returns an assigned chunkptr, but the chunk needn't be valid (loaded / generated) - callers must check */
cChunkPtr GetChunk( int a_ChunkX, int a_ChunkY, int a_ChunkZ );
cChunkPtr GetChunk( int a_ChunkX, int a_ChunkY, int a_ChunkZ);
/** Returns the specified chunk, or NULL if not created yet */
cChunk * FindChunk(int a_ChunkX, int a_ChunkZ);

View File

@ -6,7 +6,7 @@
/*
The whole thing is a thread that runs in a loop, waiting for either:
"finished chunks" (ChunkReady()), or
"chunks to send" (QueueSendChunkTo() )
"chunks to send" (QueueSendChunkTo())
to come to a queue.
And once they do, it requests the chunk data and sends it all away, either
broadcasting (ChunkReady), or

View File

@ -210,11 +210,11 @@ AString cClientHandle::FormatMessageType(bool ShouldAppendChatPrefixes, eMessage
{
if (ShouldAppendChatPrefixes)
{
return Printf("%s[MSG: %s] %s%s", cChatColor::LightBlue.c_str(), a_AdditionalData.c_str(), cChatColor::White.c_str(), cChatColor::Italic.c_str());
return Printf("%s[MSG: %s] %s%s", cChatColor::LightBlue, a_AdditionalData.c_str(), cChatColor::White, cChatColor::Italic);
}
else
{
return Printf("%s: %s", a_AdditionalData.c_str(), cChatColor::LightBlue.c_str());
return Printf("%s: %s", a_AdditionalData.c_str(), cChatColor::LightBlue);
}
}
}
@ -533,9 +533,9 @@ void cClientHandle::HandlePing(void)
Printf(Reply, "%s%s%i%s%i",
Server.GetDescription().c_str(),
cChatColor::Delimiter.c_str(),
cChatColor::Delimiter,
Server.GetNumPlayers(),
cChatColor::Delimiter.c_str(),
cChatColor::Delimiter,
Server.GetMaxPlayers()
);
Kick(Reply);
@ -1070,7 +1070,7 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo
ItemHandler->OnBlockDestroyed(World, m_Player, m_Player->GetEquippedItem(), a_BlockX, a_BlockY, a_BlockZ);
// The ItemHandler is also responsible for spawning the pickups
cChunkInterface ChunkInterface(World->GetChunkMap());
BlockHandler(a_OldBlock)->OnDestroyedByPlayer(ChunkInterface,*World, m_Player, a_BlockX, a_BlockY, a_BlockZ);
BlockHandler(a_OldBlock)->OnDestroyedByPlayer(ChunkInterface, *World, m_Player, a_BlockX, a_BlockY, a_BlockZ);
World->BroadcastSoundParticleEffect(2001, a_BlockX, a_BlockY, a_BlockZ, a_OldBlock, this);
World->DigBlock(a_BlockX, a_BlockY, a_BlockZ);
@ -1170,7 +1170,7 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e
{
// Only compare ItemType, not meta (torches have different metas)
// The -1 check is there because sometimes the client sends -1 instead of the held item
// ( http://forum.mc-server.org/showthread.php?tid=549&pid=4502#pid4502 )
// Ref.: http://forum.mc-server.org/showthread.php?tid=549&pid=4502#pid4502
LOGWARN("Player %s tried to place a block that was not equipped (exp %d, got %d)",
m_Username.c_str(), Equipped.m_ItemType, a_HeldItem.m_ItemType
);
@ -1209,11 +1209,12 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e
{
HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler);
}
else if ((ItemHandler->IsFood() || ItemHandler->IsDrinkable(EquippedDamage)) && !m_Player->IsGameModeCreative())
else if ((ItemHandler->IsFood() || ItemHandler->IsDrinkable(EquippedDamage)))
{
if (m_Player->IsSatiated() && !ItemHandler->IsDrinkable(EquippedDamage))
if ((m_Player->IsSatiated() || m_Player->IsGameModeCreative()) &&
ItemHandler->IsFood())
{
// The player is satiated, they cannot eat
// The player is satiated or in creative, and trying to eat
return;
}
m_Player->StartEating();
@ -1360,7 +1361,7 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, e
m_Player->GetInventory().RemoveOneEquippedItem();
}
cChunkInterface ChunkInterface(World->GetChunkMap());
NewBlock->OnPlacedByPlayer(ChunkInterface,*World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta);
NewBlock->OnPlacedByPlayer(ChunkInterface, *World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta);
// Step sound with 0.8f pitch is used as block placement sound
World->BroadcastSoundEffect(NewBlock->GetStepSound(), (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 1.0f, 0.8f);
@ -2561,7 +2562,7 @@ void cClientHandle::SendUpdateSign(
void cClientHandle::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ )
void cClientHandle::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ)
{
m_Protocol->SendUseBed(a_Entity, a_BlockX, a_BlockY, a_BlockZ);
}
@ -2623,7 +2624,7 @@ const AString & cClientHandle::GetUsername(void) const
void cClientHandle::SetUsername( const AString & a_Username )
void cClientHandle::SetUsername( const AString & a_Username)
{
m_Username = a_Username;
}

View File

@ -56,8 +56,8 @@ public:
#else
static const int DEFAULT_VIEW_DISTANCE = 10;
#endif
static const int MAX_VIEW_DISTANCE = 15;
static const int MIN_VIEW_DISTANCE = 3;
static const int MAX_VIEW_DISTANCE = 32;
static const int MIN_VIEW_DISTANCE = 1;
cClientHandle(const cSocket * a_Socket, int a_ViewDistance);
virtual ~cClientHandle();
@ -151,7 +151,7 @@ public:
void SendMapInfo (int a_ID, unsigned int a_Scale);
void SendPaintingSpawn (const cPainting & a_Painting);
void SendPickupSpawn (const cPickup & a_Pickup);
void SendEntityAnimation (const cEntity & a_Entity, char a_Animation);
void SendEntityAnimation (const cEntity & a_Entity, char a_Animation); // tolua_export
void SendParticleEffect (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_ParticleAmmount);
void SendPlayerAbilities (void);
void SendPlayerListItem (const cPlayer & a_Player, bool a_IsOnline);
@ -181,7 +181,7 @@ public:
void SendUnloadChunk (int a_ChunkX, int a_ChunkZ);
void SendUpdateBlockEntity (cBlockEntity & a_BlockEntity);
void SendUpdateSign (int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4);
void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ );
void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ);
void SendWeather (eWeather a_Weather);
void SendWholeInventory (const cWindow & a_Window);
void SendWindowClose (const cWindow & a_Window);
@ -190,7 +190,7 @@ public:
// tolua_begin
const AString & GetUsername(void) const;
void SetUsername( const AString & a_Username );
void SetUsername( const AString & a_Username);
inline short GetPing(void) const { return m_Ping; }
@ -274,7 +274,7 @@ private:
/** The type used for storing the names of registered plugin channels. */
typedef std::set<AString> cChannels;
/** Number of chunks the player can see in each direction; 4 is the minimum ( http://wiki.vg/Protocol_FAQ#.E2.80.A6all_connecting_clients_spasm_and_jerk_uncontrollably.21 ) */
/** Number of chunks the player can see in each direction */
int m_ViewDistance;
/** Server generates this many chunks AHEAD of player sight. */

View File

@ -14,16 +14,16 @@ Descendants override that function to provide specific processing of the output.
class cCommandOutputCallback
{
public:
virtual ~cCommandOutputCallback() {}; // Force a virtual destructor in subclasses
virtual ~cCommandOutputCallback() {} // Force a virtual destructor in subclasses
/// Syntax sugar function, calls Out() with Printf()-ed parameters; appends a "\n"
/// Syntax sugar function, calls Out() with Printf()-ed parameters; appends a newline"
void Out(const char * a_Fmt, ...) FORMATSTRING(2, 3);
/// Called when the command wants to output anything; may be called multiple times
virtual void Out(const AString & a_Text) = 0;
/// Called when the command processing has been finished
virtual void Finished(void) {};
virtual void Finished(void) {}
} ;

View File

@ -582,7 +582,7 @@ cCraftingRecipes::cRecipe * cCraftingRecipes::FindRecipe(const cItem * a_Craftin
// Get the real bounds of the crafting grid:
int GridLeft = MAX_GRID_WIDTH, GridTop = MAX_GRID_HEIGHT;
int GridRight = 0, GridBottom = 0;
for (int y = 0; y < a_GridHeight; y++ ) for(int x = 0; x < a_GridWidth; x++)
for (int y = 0; y < a_GridHeight; y++) for (int x = 0; x < a_GridWidth; x++)
{
if (!a_CraftingGrid[x + y * a_GridWidth].IsEmpty())
{

View File

@ -127,7 +127,7 @@ protected:
typedef std::vector<cRecipeSlot> cRecipeSlots;
/** A single recipe, stored. Each recipe is normalized right after parsing (NormalizeIngredients())
A normalized recipe starts at (0,0)
A normalized recipe starts at (0, 0)
*/
struct cRecipe
{

View File

@ -24,6 +24,17 @@ static bool DoIntervalsIntersect(int a_Min1, int a_Max1, int a_Min2, int a_Max2)
////////////////////////////////////////////////////////////////////////////////
// cCuboid:
cCuboid & cCuboid::operator=(cCuboid a_Other)
{
std::swap(p1, a_Other.p1);
std::swap(p2, a_Other.p2);
return *this;
}
void cCuboid::Assign(int a_X1, int a_Y1, int a_Z1, int a_X2, int a_Y2, int a_Z2)
{
p1.x = a_X1;

View File

@ -15,10 +15,12 @@ public:
Vector3i p1, p2;
cCuboid(void) {}
cCuboid(const cCuboid & a_Cuboid ) : p1(a_Cuboid.p1), p2(a_Cuboid.p2) {}
cCuboid(const cCuboid & a_Cuboid) : p1(a_Cuboid.p1), p2(a_Cuboid.p2) {}
cCuboid(const Vector3i & a_p1, const Vector3i & a_p2) : p1(a_p1), p2(a_p2) {}
cCuboid(int a_X1, int a_Y1, int a_Z1) : p1(a_X1, a_Y1, a_Z1), p2(a_X1, a_Y1, a_Z1) {}
cCuboid(int a_X1, int a_Y1, int a_Z1, int a_X2, int a_Y2, int a_Z2) : p1(a_X1, a_Y1, a_Z1), p2(a_X2, a_Y2, a_Z2) {}
cCuboid & operator=(cCuboid a_Other);
void Assign(int a_X1, int a_Y1, int a_Z1, int a_X2, int a_Y2, int a_Z2);
void Assign(const cCuboid & a_SrcCuboid);
@ -56,7 +58,7 @@ public:
);
}
bool IsInside( const Vector3d & v ) const
bool IsInside( const Vector3d & v) const
{
return (
(v.x >= p1.x) && (v.x <= p2.x) &&

View File

@ -1,7 +1,6 @@
#pragma once
#include "ChatColor.h"
#include <limits>
#include <cmath>
@ -471,18 +470,7 @@ inline void AddFaceDirection(int & a_BlockX, unsigned char & a_BlockY, int & a_B
{
int Y = a_BlockY;
AddFaceDirection(a_BlockX, Y, a_BlockZ, a_BlockFace, a_bInverse);
if (Y < 0)
{
a_BlockY = 0;
}
else if (Y > 255)
{
a_BlockY = 255;
}
else
{
a_BlockY = (unsigned char)Y;
}
a_BlockY = Clamp<unsigned char>((unsigned char)Y, 0, 255);
}
@ -491,9 +479,9 @@ inline void AddFaceDirection(int & a_BlockX, unsigned char & a_BlockY, int & a_B
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 = 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);
@ -531,7 +519,7 @@ inline float GetSignf(float a_Val)
inline float GetSpecialSignf( float a_Val )
inline float GetSpecialSignf( float a_Val)
{
return (a_Val <= 0.f) ? -1.f : 1.f;
}
@ -652,11 +640,11 @@ namespace ItemCategory
inline bool IsTool(short a_ItemID)
{
return IsPickaxe( a_ItemID )
|| IsAxe ( a_ItemID )
|| IsSword ( a_ItemID )
|| IsHoe ( a_ItemID )
|| IsShovel ( a_ItemID );
return IsPickaxe( a_ItemID)
|| IsAxe ( a_ItemID)
|| IsSword ( a_ItemID)
|| IsHoe ( a_ItemID)
|| IsShovel ( a_ItemID);
}
@ -727,14 +715,5 @@ namespace ItemCategory
// tolua_end
inline bool BlockRequiresSpecialTool(BLOCKTYPE a_BlockType)
{
if(!IsValidBlock(a_BlockType)) return false;
return cBlockInfo::RequiresSpecialTool(a_BlockType);
}

View File

@ -40,7 +40,7 @@ Serialization will never put zero-level enchantments into the stringspec and wil
class cEnchantments
{
public:
/** Individual enchantment IDs, corresponding to their NBT IDs ( http://www.minecraftwiki.net/wiki/Data_Values#Enchantment_IDs )
/** Individual enchantment IDs, corresponding to their NBT IDs: http://www.minecraftwiki.net/wiki/Data_Values#Enchantment_IDs
*/
enum

View File

@ -1,6 +1,7 @@
#pragma once
#undef ntohll
#define ntohll(x) ((((UInt64)ntohl((u_long)x)) << 32) + ntohl(x >> 32))
@ -11,8 +12,8 @@
inline UInt64 HostToNetwork8(const void * a_Value)
{
unsigned long long __HostToNetwork8;
memcpy( &__HostToNetwork8, a_Value, sizeof( __HostToNetwork8 ) );
__HostToNetwork8 = (( ( (unsigned long long)htonl((u_long)__HostToNetwork8) ) << 32) + htonl(__HostToNetwork8 >> 32));
memcpy( &__HostToNetwork8, a_Value, sizeof( __HostToNetwork8));
__HostToNetwork8 = (( ( (unsigned long long)htonl((u_long)__HostToNetwork8)) << 32) + htonl(__HostToNetwork8 >> 32));
return __HostToNetwork8;
}
@ -20,11 +21,11 @@ inline UInt64 HostToNetwork8(const void * a_Value)
inline UInt32 HostToNetwork4(const void* a_Value )
inline UInt32 HostToNetwork4(const void* a_Value)
{
unsigned int __HostToNetwork4;
memcpy( &__HostToNetwork4, a_Value, sizeof( __HostToNetwork4 ) );
__HostToNetwork4 = ntohl( __HostToNetwork4 );
memcpy( &__HostToNetwork4, a_Value, sizeof( __HostToNetwork4));
__HostToNetwork4 = ntohl( __HostToNetwork4);
return __HostToNetwork4;
}

View File

@ -28,7 +28,7 @@ public:
// tolua_end
CLASS_PROTODEF(cArrowEntity);
CLASS_PROTODEF(cArrowEntity)
/// 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);

View File

@ -21,7 +21,7 @@ class cBoat :
typedef cEntity super;
public:
CLASS_PROTODEF(cBoat);
CLASS_PROTODEF(cBoat)
// cEntity overrides:
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;

View File

@ -4,11 +4,64 @@ project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
file(GLOB SOURCE
"*.cpp"
"*.h"
)
SET (SRCS
ArrowEntity.cpp
Boat.cpp
EnderCrystal.cpp
Entity.cpp
EntityEffect.cpp
ExpBottleEntity.cpp
ExpOrb.cpp
FallingBlock.cpp
FireChargeEntity.cpp
FireworkEntity.cpp
Floater.cpp
GhastFireballEntity.cpp
HangingEntity.cpp
ItemFrame.cpp
Minecart.cpp
Painting.cpp
Pawn.cpp
Pickup.cpp
Player.cpp
ProjectileEntity.cpp
SplashPotionEntity.cpp
TNTEntity.cpp
ThrownEggEntity.cpp
ThrownEnderPearlEntity.cpp
ThrownSnowballEntity.cpp
WitherSkullEntity.cpp)
add_library(Entities ${SOURCE})
SET (HDRS
ArrowEntity.h
Boat.h
EnderCrystal.h
Entity.h
EntityEffect.h
ExpBottleEntity.h
ExpOrb.h
FallingBlock.h
FireChargeEntity.h
FireworkEntity.h
Floater.h
GhastFireballEntity.h
HangingEntity.h
ItemFrame.h
Minecart.h
Painting.h
Pawn.h
Pickup.h
Player.h
ProjectileEntity.h
SplashPotionEntity.h
TNTEntity.h
ThrownEggEntity.h
ThrownEnderPearlEntity.h
ThrownSnowballEntity.h
WitherSkullEntity.h)
target_link_libraries(Entities WorldStorage)
if(NOT MSVC)
add_library(Entities ${SRCS} ${HDRS})
target_link_libraries(Entities WorldStorage)
endif()

View File

@ -15,7 +15,7 @@ class cEnderCrystal :
typedef cEntity super;
public:
CLASS_PROTODEF(cEnderCrystal);
CLASS_PROTODEF(cEnderCrystal)
cEnderCrystal(double a_X, double a_Y, double a_Z);

View File

@ -49,6 +49,7 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d
, m_IsSubmerged(false)
, m_AirLevel(0)
, m_AirTickTimer(0)
, m_TicksAlive(0)
, m_HeadYaw(0.0)
, m_Rot(0.0, 0.0, 0.0)
, m_Pos(a_X, a_Y, a_Z)
@ -327,10 +328,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
// TODO: Apply damage to armor
if (m_Health < 0)
{
m_Health = 0;
}
m_Health = std::max(m_Health, 0);
if ((IsMob() || IsPlayer()) && (a_TDI.Attacker != NULL)) // Knockback for only players and mobs
{
@ -562,6 +560,8 @@ void cEntity::SetHealth(int a_Health)
void cEntity::Tick(float a_Dt, cChunk & a_Chunk)
{
m_TicksAlive++;
if (m_InvulnerableTicks > 0)
{
m_InvulnerableTicks--;
@ -648,7 +648,7 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
int RelBlockX = BlockX - (NextChunk->GetPosX() * cChunkDef::Width);
int RelBlockZ = BlockZ - (NextChunk->GetPosZ() * cChunkDef::Width);
BLOCKTYPE BlockIn = NextChunk->GetBlock( RelBlockX, BlockY, RelBlockZ );
BLOCKTYPE BlockIn = NextChunk->GetBlock( RelBlockX, BlockY, RelBlockZ);
BLOCKTYPE BlockBelow = (BlockY > 0) ? NextChunk->GetBlock(RelBlockX, BlockY - 1, RelBlockZ) : E_BLOCK_AIR;
if (!cBlockInfo::IsSolid(BlockIn)) // Making sure we are not inside a solid block
{
@ -758,7 +758,7 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
m_WaterSpeed *= 0.9f; // Reduce speed each tick
switch(WaterDir)
switch (WaterDir)
{
case X_PLUS:
m_WaterSpeed.x = 0.2f;
@ -1146,10 +1146,7 @@ void cEntity::SetMaxHealth(int a_MaxHealth)
m_MaxHealth = a_MaxHealth;
// Reset health, if too high:
if (m_Health > a_MaxHealth)
{
m_Health = a_MaxHealth;
}
m_Health = std::min(m_Health, a_MaxHealth);
}

View File

@ -416,6 +416,9 @@ public:
/** Gets remaining air of a monster */
int GetAirLevel(void) const { return m_AirLevel; }
/** 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; }
@ -425,7 +428,7 @@ public:
// tolua_end
/// Called when the specified player right-clicks this entity
virtual void OnRightClicked(cPlayer &) {};
virtual void OnRightClicked(cPlayer &) {}
/// 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)
@ -521,6 +524,9 @@ protected:
int m_AirLevel;
int m_AirTickTimer;
/** The number of ticks this entity has been alive for */
long int m_TicksAlive;
private:
/** Measured in degrees, [-180, +180) */
double m_HeadYaw;

View File

@ -55,7 +55,7 @@ public:
@param a_OtherEffect The other effect to copy */
cEntityEffect & operator=(cEntityEffect a_OtherEffect);
virtual ~cEntityEffect(void) {};
virtual ~cEntityEffect(void) {}
/** Creates a pointer to the proper entity effect from the effect type
@warning This function creates raw pointers that must be manually managed.

View File

@ -21,7 +21,7 @@ public:
// tolua_end
CLASS_PROTODEF(cExpBottleEntity);
CLASS_PROTODEF(cExpBottleEntity)
cExpBottleEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);

View File

@ -62,9 +62,9 @@ void cExpOrb::Tick(float a_Dt, cChunk & a_Chunk)
}
a_Distance.Normalize();
a_Distance *= ((float) (5.5 - Distance));
SetSpeedX( a_Distance.x );
SetSpeedY( a_Distance.y );
SetSpeedZ( a_Distance.z );
SetSpeedX( a_Distance.x);
SetSpeedY( a_Distance.y);
SetSpeedZ( a_Distance.z);
BroadcastMovementUpdate();
}
HandlePhysics(a_Dt, a_Chunk);

View File

@ -16,7 +16,7 @@ class cExpOrb :
public:
// tolua_end
CLASS_PROTODEF(cExpOrb);
CLASS_PROTODEF(cExpOrb)
cExpOrb(double a_X, double a_Y, double a_Z, int a_Reward);
cExpOrb(const Vector3d & a_Pos, int a_Reward);

View File

@ -20,7 +20,7 @@ class cFallingBlock :
typedef cEntity super;
public:
CLASS_PROTODEF(cFallingBlock);
CLASS_PROTODEF(cFallingBlock)
/// Creates a new falling block. a_BlockPosition is expected in world coords
cFallingBlock(const Vector3i & a_BlockPosition, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);

View File

@ -21,7 +21,7 @@ public:
// tolua_end
CLASS_PROTODEF(cFireChargeEntity);
CLASS_PROTODEF(cFireChargeEntity)
cFireChargeEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);

View File

@ -21,7 +21,7 @@ public:
// tolua_end
CLASS_PROTODEF(cFireworkEntity);
CLASS_PROTODEF(cFireworkEntity)
cFireworkEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem & a_Item);
const cItem & GetItem(void) const { return m_FireworkItem; }

View File

@ -16,7 +16,7 @@ class cFloater :
public:
// tolua_end
CLASS_PROTODEF(cFloater);
CLASS_PROTODEF(cFloater)
cFloater(double a_X, double a_Y, double a_Z, Vector3d a_Speed, int a_PlayerID, int a_CountDownTime);

View File

@ -21,7 +21,7 @@ public:
// tolua_end
CLASS_PROTODEF(cGhastFireballEntity);
CLASS_PROTODEF(cGhastFireballEntity)
cGhastFireballEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);

View File

@ -16,7 +16,7 @@ class cHangingEntity :
public:
CLASS_PROTODEF(cHangingEntity);
CLASS_PROTODEF(cHangingEntity)
cHangingEntity(eEntityType a_EntityType, eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z);
@ -38,7 +38,7 @@ public:
private:
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override {};
virtual void Tick(float a_Dt, cChunk & a_Chunk) override {}
eBlockFace m_BlockFace;

View File

@ -16,7 +16,7 @@ class cItemFrame :
public:
CLASS_PROTODEF(cItemFrame);
CLASS_PROTODEF(cItemFrame)
cItemFrame(eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z);
@ -24,7 +24,7 @@ public:
const cItem & GetItem(void) { return m_Item; } // tolua_export
/** 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; } // tolua_export
/** Returns the rotation from the item in the frame */
Byte GetRotation(void) const { return m_Rotation; } // tolua_export

View File

@ -103,21 +103,7 @@ cMinecart::cMinecart(ePayload a_Payload, double a_X, double a_Y, double a_Z) :
void cMinecart::SpawnOn(cClientHandle & a_ClientHandle)
{
char SubType = 0;
switch (m_Payload)
{
case mpNone: SubType = 0; break;
case mpChest: SubType = 1; break;
case mpFurnace: SubType = 2; break;
case mpTNT: SubType = 3; break;
case mpHopper: SubType = 5; break;
default:
{
ASSERT(!"Unknown payload, cannot spawn on client");
return;
}
}
a_ClientHandle.SendSpawnVehicle(*this, 10, SubType); // 10 = Minecarts, SubType = What type of Minecart
a_ClientHandle.SendSpawnVehicle(*this, 10, (char)m_Payload); // 10 = Minecarts
a_ClientHandle.SendEntityMetadata(*this);
}

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