1
0

Merge branch 'master' into portals

Conflicts:
	src/Blocks/WorldInterface.h
	src/ClientHandle.cpp
	src/ClientHandle.h
	src/Entities/Player.cpp
	src/Entities/Player.h
	src/Generating/FinishGen.cpp
	src/Protocol/Protocol.h
	src/Protocol/Protocol125.cpp
	src/Protocol/Protocol125.h
	src/Protocol/Protocol16x.cpp
	src/Protocol/Protocol16x.h
	src/Protocol/Protocol17x.cpp
	src/Protocol/Protocol17x.h
	src/Protocol/ProtocolRecognizer.cpp
	src/Protocol/ProtocolRecognizer.h
	src/Root.h
	src/World.cpp
This commit is contained in:
Tiger Wang 2014-07-18 20:10:51 +01:00
commit 37140ae578
382 changed files with 7715 additions and 4736 deletions

1
.gitignore vendored
View File

@ -26,6 +26,7 @@ cloc.xsl
## Eclipse
.cproject
.project
*.cbp
# world inside source
ChunkWorx.ini

View File

@ -62,7 +62,10 @@ add_subdirectory(lib/tolua++/)
add_subdirectory(lib/sqlite/)
add_subdirectory(lib/expat/)
add_subdirectory(lib/luaexpat/)
add_subdirectory(lib/md5/)
if (WIN32)
add_subdirectory(lib/luaproxy/)
endif()
# We use EXCLUDE_FROM_ALL so that only the explicit dependencies are used

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

@ -1691,6 +1691,9 @@ a_Player:OpenWindow(Window);
TakeDamage = { Return = "" },
KilledBy = { Return = "" },
GetHealth = { Return = "number" },
AddEntityEffect = { Params = "EffectType, {{cEntityEffect}}", Return = "", Notes = "Applies an entity effect" },
RemoveEntityEffect = { Params = "EffectType", Return = "", Notes = "Removes a currently applied entity effect" },
ClearEntityEffects = { Return = "", Notes = "Removes all currently applied entity effects" },
},
Inherits = "cEntity",
}, -- cPawn
@ -1875,9 +1878,9 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage);
},
CallPlugin = { Params = "PluginName, FunctionName, [FunctionArgs...]", Return = "[FunctionRets]", Notes = "(STATIC) Calls the specified function in the specified plugin, passing all the given arguments to it. If it succeeds, it returns all the values returned by that function. If it fails, returns no value at all. Note that only strings, numbers, bools, nils and classes can be used for parameters and return values; tables and functions cannot be copied across plugins." },
DisablePlugin = { Params = "PluginName", Return = "bool", Notes = "Disables a plugin specified by its name. Returns true if the plugin was disabled, false if it wasn't found or wasn't active." },
ExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "bool", Notes = "Executes the command as if given by the specified Player. Checks permissions. Returns true if executed." },
ExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "{{cPluginManager#CommandResult|CommandResult}}", Notes = "Executes the command as if given by the specified Player. Checks permissions." },
FindPlugins = { Params = "", Return = "", Notes = "Refreshes the list of plugins to include all folders inside the Plugins folder (potentially new disabled plugins)" },
ForceExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "bool", Notes = "Same as ExecuteCommand, but doesn't check permissions" },
ForceExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "{{cPluginManager#CommandResult|CommandResult}}", Notes = "Same as ExecuteCommand, but doesn't check permissions" },
ForEachCommand = { Params = "CallbackFn", Return = "bool", Notes = "Calls the CallbackFn function for each command that has been bound using BindCommand(). The CallbackFn has the following signature: <pre class=\"prettyprint lang-lua\">function(Command, Permission, HelpString)</pre>. If the callback returns true, the enumeration is aborted and this API function returns false; if it returns false or no value, the enumeration continues with the next command, and the API function returns true." },
ForEachConsoleCommand = { Params = "CallbackFn", Return = "bool", Notes = "Calls the CallbackFn function for each command that has been bound using BindConsoleCommand(). The CallbackFn has the following signature: <pre class=\"prettyprint lang-lua\">function (Command, HelpString)</pre>. If the callback returns true, the enumeration is aborted and this API function returns false; if it returns false or no value, the enumeration continues with the next command, and the API function returns true." },
Get = { Params = "", Return = "cPluginManager", Notes = "(STATIC) Returns the single instance of the plugin manager" },
@ -1893,8 +1896,23 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage);
LogStackTrace = { Params = "", Return = "", Notes = "(STATIC) Logs a current stack trace of the Lua engine to the server console log. Same format as is used when the plugin fails." },
ReloadPlugins = { Params = "", Return = "", Notes = "Reloads all active plugins" },
},
ConstantGroups=
{
CommandResult =
{
Include = "^cr.*",
TextBefore = [[
Results that the (Force)ExecuteCommand return. This gives information if the command is executed or not and the reason.
]],
},
},
Constants =
{
crBlocked = { Notes = "When a plugin stopped the command using the OnExecuteCommand hook" },
crError = { Notes = "When the command handler for the given command results in an error" },
crExecuted = { Notes = "When the command is successfully executed." },
crNoPermission = { Notes = "When the player doesn't have permission to execute the given command." },
crUnknownCommand = { Notes = "When the given command doesn't exist." },
HOOK_BLOCK_SPREAD = { Notes = "Called when a block spreads based on world conditions" },
HOOK_BLOCK_TO_PICKUPS = { Notes = "Called when a block has been dug and is being converted to pickups. The server has provided the default pickups and the plugins may modify them." },
HOOK_CHAT = { Notes = "Called when a client sends a chat message that is not a command. The plugin may modify the chat message" },
@ -2325,6 +2343,7 @@ end
{ Params = "BlockX, BlockY, BlockZ, BlockMeta", Return = "", Notes = "Sets the meta for the block at the specified coords." },
{ Params = "{{Vector3i|BlockCoords}}, BlockMeta", Return = "", Notes = "Sets the meta for the block at the specified coords." },
},
SetChunkAlwaysTicked = { Params = "ChunkX, ChunkZ, IsAlwaysTicked", Return = "", Notes = "Sets the chunk to always be ticked even when it doesn't contain any clients. IsAlwaysTicked set to true turns forced ticking on, set to false turns it off. Every call with 'true' should be paired with a later call with 'false', otherwise the ticking won't stop. Multiple actions can request ticking independently, the ticking will continue until the last call with 'false'. Note that when the chunk unloads, it loses the value of this flag." },
SetNextBlockTick = { Params = "BlockX, BlockY, BlockZ", Return = "", Notes = "Sets the blockticking to start at the specified block in the next tick." },
SetCommandBlockCommand = { Params = "BlockX, BlockY, BlockZ, Command", Return = "bool", Notes = "Sets the command to be executed in a command block at the specified coordinates. Returns if command was changed." },
SetCommandBlocksEnabled = { Params = "IsEnabled (bool)", Return = "", Notes = "Sets whether command blocks should be enabled on the (entire) server." },

View File

@ -0,0 +1,33 @@
return
{
HOOK_ENTITY_ADD_EFFECT =
{
CalledWhen = "An entity effect is about to get added to an entity.",
DefaultFnName = "OnEntityAddEffect", -- also used as pagename
Desc = [[
This hook is called whenever an entity effect is about to be added to an entity. The plugin may
disallow the addition by returning true.</p>
<p>Note that this hook only fires for adding the effect, but not for the actual effect application. See
also the {{OnEntityRemoveEffect|HOOK_ENTITY_REMOVE_EFFECT}} for notification about effects expiring /
removing, and {{OnEntityApplyEffect|HOOK_ENTITY_APPLY_EFFECT}} for the actual effect application to the
entity.
]],
Params =
{
{ Name = "Entity", Type = "{{cEntity}}", Notes = "The entity to which the effect is about to be added" },
{ Name = "EffectType", Type = "number", Notes = "The type of the effect to be added. One of the effXXX constants." },
{ Name = "EffectDuration", Type = "number", Notes = "The duration of the effect to be added, in ticks." },
{ Name = "EffectIntensity", Type = "number", Notes = "The intensity (level) of the effect to be added. " },
{ Name = "DistanceModifier", Type = "number", Notes = "The modifier for the effect intensity, based on distance. Used mainly for splash potions." },
},
Returns = [[
If the plugin returns true, the effect will not be added and none of the remaining hook handlers will
be called. If the plugin returns false, MCServer calls all the remaining hook handlers and finally
the effect is added to the entity.
]],
}, -- HOOK_EXECUTE_COMMAND
}

View File

@ -0,0 +1,27 @@
return
{
HOOK_PLAYER_FOOD_LEVEL_CHANGE =
{
CalledWhen = "Called before the player food level changed. Plugin may override",
DefaultFnName = "OnPlayerFoodLevelChange", -- also used as pagename
Desc = [[
This hook is called before the food level changes.
The food level is not changed yet, plugins may choose
to refuse the change.
]],
Params =
{
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who changes the food level." },
{ Name = "NewFoodLevel", Type = "number", Notes = "The new food level." },
},
Returns = [[
If the function returns false or no value, the next plugin's callback is called. Afterwards, the
server changes the food level of the player. If the function returns true, no
other callback is called for this event and the player's food level doesn't change.
]],
}, -- HOOK_PLAYER_FOOD_LEVEL_CHANGE
};

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

@ -6,7 +6,7 @@ return
DefaultFnName = "OnWeatherChanging", -- also used as pagename
Desc = [[
This hook is called when the current weather has expired and a new weather is selected. Plugins may
override the new weather setting.</p>
override the new weather being set.</p>
<p>
The new weather setting is sent to the clients only after this hook has been processed.</p>
<p>
@ -19,9 +19,12 @@ return
{ Name = "Weather", Type = "number", Notes = "The newly selected weather. One of wSunny, wRain, wStorm" },
},
Returns = [[
If the function returns false or no value, the server calls other plugins' callbacks and finally
sets the weather. If the function returns true, the server takes the second returned value (wSunny
by default) and sets it as the new weather. No other plugins' callbacks are called in this case.
The hook handler can return up to two values. If the first value is false or not present, the server
calls other plugins' callbacks and finally sets the weather. If it is true, the server doesn't call any
more callbacks for this hook. The second value returned is used as the new weather. If no value is
given, the weather from the parameters is used as the weather. Returning false as the first value and a
specific weather constant as the second value makes the server call the rest of the hook handlers with
the new weather value.
]],
}, -- HOOK_WEATHER_CHANGING
}

View File

@ -31,6 +31,8 @@ function Initialize(Plugin)
PM:AddHook(cPluginManager.HOOK_PLUGIN_MESSAGE, OnPluginMessage);
PM:AddHook(cPluginManager.HOOK_PLAYER_JOINED, OnPlayerJoined);
PM:AddHook(cPluginManager.HOOK_PROJECTILE_HIT_BLOCK, OnProjectileHitBlock);
PM:AddHook(cPluginManager.HOOK_CHUNK_UNLOADING, OnChunkUnloading);
PM:AddHook(cPluginManager.HOOK_WORLD_STARTED, OnWorldStarted);
-- _X: Disabled so that the normal operation doesn't interfere with anything
-- PM:AddHook(cPluginManager.HOOK_CHUNK_GENERATED, OnChunkGenerated);
@ -1382,6 +1384,7 @@ end
function OnProjectileHitBlock(a_Projectile, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_BlockHitPos)
-- Test projectile hooks by setting the blocks they hit on fire:
local BlockX, BlockY, BlockZ = AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace)
local World = a_Projectile:GetWorld()
@ -1391,3 +1394,28 @@ end
function OnChunkUnloading(a_World, a_ChunkX, a_ChunkZ)
-- Do not let chunk [0, 0] unload, so that it continues ticking [cWorld:SetChunkAlwaysTicked() test]
if ((a_ChunkX == 0) and (a_ChunkZ == 0)) then
return true
end
end
function OnWorldStarted(a_World)
-- Make the chunk [0, 0] in every world keep ticking [cWorld:SetChunkAlwaysTicked() test]
a_World:ChunkStay({{0, 0}}, nil,
function()
-- The chunk is loaded, make it always tick:
a_World:SetChunkAlwaysTicked(0, 0, true)
end
)
end

View File

@ -22,6 +22,8 @@ function Initialize(Plugin)
Plugin:SetVersion(1);
cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_USED_ITEM, OnPlayerUsedItem);
LOG("Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion());
return true;
end
@ -36,8 +38,8 @@ function OnPlayerUsedItem(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, Cu
return false;
end;
if (Player:HasPermission("diamondmover.move") == false) then
return true;
if (not Player:HasPermission("diamondmover.move")) then
return false;
end;
-- Rclk with a diamond to push in the direction the player is facing
@ -56,7 +58,7 @@ function OnPlayerUsedItem(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, Cu
if (PlayerPitch > 70) then -- looking down
BlockY = BlockY - 1;
else
local PlayerRot = Player:GetRotation() + 180; -- Convert [-180, 180] into [0, 360] for simpler conditions
local PlayerRot = Player:GetYaw() + 180; -- Convert [-180, 180] into [0, 360] for simpler conditions
if ((PlayerRot < 45) or (PlayerRot > 315)) then
BlockZ = BlockZ - 1;
else

Binary file not shown.

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

@ -26,10 +26,18 @@ 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/")
include(CodeCoverage)
endif()
endif()
# Add the preprocessor macros used for distinguishing between debug and release builds (CMake does this automatically for MSVC):
if (NOT MSVC)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/lib/cmake-coverage/")
include(CodeCoverage)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_COVERAGE} -D_DEBUG")
@ -63,12 +71,16 @@ macro(set_flags)
else()
# Let gcc / clang know that we're compiling a multi-threaded app:
add_flags_cxx("-pthread")
if (UNIX)
add_flags_cxx("-pthread")
endif()
# Make CLang use C++11, otherwise MSVC2008-supported extensions don't work ("override" keyword etc.):
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++11")
set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_COVERAGE} -std=c++11")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++11")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++11")
endif()
# We use a signed char (fixes #640 on RasPi)

View File

@ -11,21 +11,16 @@ file(GLOB SOURCE
list(REMOVE_ITEM SOURCE "${PROJECT_SOURCE_DIR}/src/lua.c" "${PROJECT_SOURCE_DIR}/src/luac.c")
# add headers to MSVC project files:
if (WIN32)
if (MSVC)
file(GLOB HEADERS "src/*.h")
list(REMOVE_ITEM SOURCE "${PROJECT_SOURCE_DIR}/src/lua.h" "${PROJECT_SOURCE_DIR}/src/luac.h")
set(SOURCE ${SOURCE} ${HEADERS})
source_group("Sources" FILES ${SOURCE})
endif()
# Lua needs to be linked dynamically on Windows and statically on *nix, so that LuaRocks work
if (WIN32)
#for compiliers other than msvc we need to tell lua that its building as a dll
if (NOT MSVC)
add_flags_cxx(-DLUA_BUILD_AS_DLL=1)
endif()
add_library(lua SHARED ${SOURCE})
set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/MCServer)
@ -53,7 +48,7 @@ if (WIN32)
)
endif()
set_target_properties(lua PROPERTIES OUTPUT_NAME "lua51")
set_target_properties(lua PROPERTIES OUTPUT_NAME "lua51" PREFIX "")
# NOTE: The DLL for each configuration is stored at the same place, thus overwriting each other.
# This is known, however such behavior is needed for LuaRocks - they always load "lua5.1.dll" or "lua51.dll"
@ -63,6 +58,7 @@ else()
add_library(lua ${SOURCE})
endif()
# Tell Lua what dynamic loader to use (for LuaRocks):
if (UNIX)
add_definitions(-DLUA_USE_DLOPEN)

View File

@ -0,0 +1,61 @@
# This project adds a Lua Proxy DLL on Windows
# By an unfortunate choice in the popular LuaBinaries distribution, there are two names for the Lua DLL on Windows: lua51.dll and lua5.1.dll.
# Some binary Lua packages are built for one, the others for the other. Messy!
# In order to support both package flavors, we create a "proxy DLL":
# Basically the lua5.1.dll has its PE Exports section manipulated so that it points each exported function to its lua51.dll implementation.
# Effectively, this forwards all calls from lua5.1.dll to lua51.dll without any performance costs (the forwarding is done in the Windows PE loader on app start).
# This project creates the proxy DLL by using a specially crafted .DEF file that is used to link the Proxy DLL.
# Note that it has been tested only on MSVC, it might not work with other compilers.
# The initial implementation was taken from http://lua-users.org/wiki/LuaProxyDllFour , but adapted to MSVC
if (WIN32)
if (MSVC)
# Tell the linker to use the DEF file to generate the proxy:
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NOENTRY /DEF:lua5.1.def /MANIFEST:NO")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /NOENTRY /DEF:lua5.1.def /MANIFEST:NO")
set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} /NOENTRY /DEF:lua5.1.def /MANIFEST:NO")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NOENTRY /DEF:lua5.1.def /MANIFEST:NO")
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /NOENTRY /DEF:lua5.1.def /MANIFEST:NO")
set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG} /NOENTRY /DEF:lua5.1.def /MANIFEST:NO")
elseif (MINGW)
# MinGW requires no further flags and has been tested
else()
message ("LuaProxy: This cmake code has not been tested on your compiler. Please report your success or failure in the forum.")
endif()
add_library(luaproxy SHARED "lua5.1.def" "Dummy.c")
set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/MCServer)
set_target_properties(luaproxy PROPERTIES
OUTPUT_NAME "lua5.1"
PREFIX ""
)
target_link_libraries(luaproxy lua)
# Output the executable into the $/MCServer folder, so that MCServer can find it:
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/MCServer)
SET_TARGET_PROPERTIES(luaproxy PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/MCServer
ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/MCServer
ARCHIVE_OUTPUT_DIRECTORY_DEBUGPROFILE ${CMAKE_SOURCE_DIR}/MCServer
ARCHIVE_OUTPUT_DIRECTORY_RELEASEPROFILE ${CMAKE_SOURCE_DIR}/MCServer
LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/MCServer
LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/MCServer
LIBRARY_OUTPUT_DIRECTORY_DEBUGPROFILE ${CMAKE_SOURCE_DIR}/MCServer
LIBRARY_OUTPUT_DIRECTORY_RELEASEPROFILE ${CMAKE_SOURCE_DIR}/MCServer
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/MCServer
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/MCServer
RUNTIME_OUTPUT_DIRECTORY_DEBUGPROFILE ${CMAKE_SOURCE_DIR}/MCServer
RUNTIME_OUTPUT_DIRECTORY_RELEASEPROFILE ${CMAKE_SOURCE_DIR}/MCServer
)
else()
message (FATAL_ERROR "This project is needed only for Windows, modify your cmake file not to include it on Linux")
endif()

4
lib/luaproxy/Dummy.c Normal file
View File

@ -0,0 +1,4 @@
// Dummy.c
// Because the MSVC compiler needs at least one C file to compile the project

115
lib/luaproxy/lua5.1.def Normal file
View File

@ -0,0 +1,115 @@
EXPORTS
luaL_addlstring=lua51.luaL_addlstring
luaL_addstring=lua51.luaL_addstring
luaL_addvalue=lua51.luaL_addvalue
luaL_argerror=lua51.luaL_argerror
luaL_buffinit=lua51.luaL_buffinit
luaL_callmeta=lua51.luaL_callmeta
luaL_checkany=lua51.luaL_checkany
luaL_checkinteger=lua51.luaL_checkinteger
luaL_checklstring=lua51.luaL_checklstring
luaL_checknumber=lua51.luaL_checknumber
luaL_checkoption=lua51.luaL_checkoption
luaL_checkstack=lua51.luaL_checkstack
luaL_checktype=lua51.luaL_checktype
luaL_checkudata=lua51.luaL_checkudata
luaL_error=lua51.luaL_error
luaL_findtable=lua51.luaL_findtable
luaL_getmetafield=lua51.luaL_getmetafield
luaL_gsub=lua51.luaL_gsub
luaL_loadbuffer=lua51.luaL_loadbuffer
luaL_loadfile=lua51.luaL_loadfile
luaL_loadstring=lua51.luaL_loadstring
luaL_newmetatable=lua51.luaL_newmetatable
luaL_newstate=lua51.luaL_newstate
luaL_openlib=lua51.luaL_openlib
luaL_openlibs=lua51.luaL_openlibs
luaL_optinteger=lua51.luaL_optinteger
luaL_optlstring=lua51.luaL_optlstring
luaL_optnumber=lua51.luaL_optnumber
luaL_prepbuffer=lua51.luaL_prepbuffer
luaL_pushresult=lua51.luaL_pushresult
luaL_ref=lua51.luaL_ref
luaL_register=lua51.luaL_register
luaL_typerror=lua51.luaL_typerror
luaL_unref=lua51.luaL_unref
luaL_where=lua51.luaL_where
lua_atpanic=lua51.lua_atpanic
lua_call=lua51.lua_call
lua_checkstack=lua51.lua_checkstack
lua_close=lua51.lua_close
lua_concat=lua51.lua_concat
lua_cpcall=lua51.lua_cpcall
lua_createtable=lua51.lua_createtable
lua_dump=lua51.lua_dump
lua_equal=lua51.lua_equal
lua_error=lua51.lua_error
lua_gc=lua51.lua_gc
lua_getallocf=lua51.lua_getallocf
lua_getfenv=lua51.lua_getfenv
lua_getfield=lua51.lua_getfield
lua_gethook=lua51.lua_gethook
lua_gethookcount=lua51.lua_gethookcount
lua_gethookmask=lua51.lua_gethookmask
lua_getinfo=lua51.lua_getinfo
lua_getlocal=lua51.lua_getlocal
lua_getmetatable=lua51.lua_getmetatable
lua_getstack=lua51.lua_getstack
lua_gettable=lua51.lua_gettable
lua_gettop=lua51.lua_gettop
lua_getupvalue=lua51.lua_getupvalue
lua_insert=lua51.lua_insert
lua_iscfunction=lua51.lua_iscfunction
lua_isnumber=lua51.lua_isnumber
lua_isstring=lua51.lua_isstring
lua_isuserdata=lua51.lua_isuserdata
lua_lessthan=lua51.lua_lessthan
lua_load=lua51.lua_load
lua_newstate=lua51.lua_newstate
lua_newthread=lua51.lua_newthread
lua_newuserdata=lua51.lua_newuserdata
lua_next=lua51.lua_next
lua_objlen=lua51.lua_objlen
lua_pcall=lua51.lua_pcall
lua_pushboolean=lua51.lua_pushboolean
lua_pushcclosure=lua51.lua_pushcclosure
lua_pushfstring=lua51.lua_pushfstring
lua_pushinteger=lua51.lua_pushinteger
lua_pushlightuserdata=lua51.lua_pushlightuserdata
lua_pushlstring=lua51.lua_pushlstring
lua_pushnil=lua51.lua_pushnil
lua_pushnumber=lua51.lua_pushnumber
lua_pushstring=lua51.lua_pushstring
lua_pushthread=lua51.lua_pushthread
lua_pushvalue=lua51.lua_pushvalue
lua_pushvfstring=lua51.lua_pushvfstring
lua_rawequal=lua51.lua_rawequal
lua_rawget=lua51.lua_rawget
lua_rawgeti=lua51.lua_rawgeti
lua_rawset=lua51.lua_rawset
lua_rawseti=lua51.lua_rawseti
lua_remove=lua51.lua_remove
lua_replace=lua51.lua_replace
lua_resume=lua51.lua_resume
lua_setallocf=lua51.lua_setallocf
lua_setfenv=lua51.lua_setfenv
lua_setfield=lua51.lua_setfield
lua_sethook=lua51.lua_sethook
lua_setlocal=lua51.lua_setlocal
lua_setmetatable=lua51.lua_setmetatable
lua_settable=lua51.lua_settable
lua_settop=lua51.lua_settop
lua_setupvalue=lua51.lua_setupvalue
lua_status=lua51.lua_status
lua_toboolean=lua51.lua_toboolean
lua_tocfunction=lua51.lua_tocfunction
lua_tointeger=lua51.lua_tointeger
lua_tolstring=lua51.lua_tolstring
lua_tonumber=lua51.lua_tonumber
lua_topointer=lua51.lua_topointer
lua_tothread=lua51.lua_tothread
lua_touserdata=lua51.lua_touserdata
lua_type=lua51.lua_type
lua_typename=lua51.lua_typename
lua_xmove=lua51.lua_xmove
lua_yield=lua51.lua_yield

140
lib/luaproxy/lua5.1.lua Normal file
View File

@ -0,0 +1,140 @@
-- lua5.1.lua
-- Generates the lua5.1.def file from the list of Lua symbols below
local symbols =
{
"luaL_addlstring",
"luaL_addstring",
"luaL_addvalue",
"luaL_argerror",
"luaL_buffinit",
"luaL_callmeta",
"luaL_checkany",
"luaL_checkinteger",
"luaL_checklstring",
"luaL_checknumber",
"luaL_checkoption",
"luaL_checkstack",
"luaL_checktype",
"luaL_checkudata",
"luaL_error",
"luaL_findtable",
"luaL_getmetafield",
"luaL_gsub",
"luaL_loadbuffer",
"luaL_loadfile",
"luaL_loadstring",
"luaL_newmetatable",
"luaL_newstate",
"luaL_openlib",
"luaL_openlibs",
"luaL_optinteger",
"luaL_optlstring",
"luaL_optnumber",
"luaL_prepbuffer",
"luaL_pushresult",
"luaL_ref",
"luaL_register",
"luaL_typerror",
"luaL_unref",
"luaL_where",
"lua_atpanic",
"lua_call",
"lua_checkstack",
"lua_close",
"lua_concat",
"lua_cpcall",
"lua_createtable",
"lua_dump",
"lua_equal",
"lua_error",
"lua_gc",
"lua_getallocf",
"lua_getfenv",
"lua_getfield",
"lua_gethook",
"lua_gethookcount",
"lua_gethookmask",
"lua_getinfo",
"lua_getlocal",
"lua_getmetatable",
"lua_getstack",
"lua_gettable",
"lua_gettop",
"lua_getupvalue",
"lua_insert",
"lua_iscfunction",
"lua_isnumber",
"lua_isstring",
"lua_isuserdata",
"lua_lessthan",
"lua_load",
"lua_newstate",
"lua_newthread",
"lua_newuserdata",
"lua_next",
"lua_objlen",
"lua_pcall",
"lua_pushboolean",
"lua_pushcclosure",
"lua_pushfstring",
"lua_pushinteger",
"lua_pushlightuserdata",
"lua_pushlstring",
"lua_pushnil",
"lua_pushnumber",
"lua_pushstring",
"lua_pushthread",
"lua_pushvalue",
"lua_pushvfstring",
"lua_rawequal",
"lua_rawget",
"lua_rawgeti",
"lua_rawset",
"lua_rawseti",
"lua_remove",
"lua_replace",
"lua_resume",
"lua_setallocf",
"lua_setfenv",
"lua_setfield",
"lua_sethook",
"lua_setlocal",
"lua_setmetatable",
"lua_settable",
"lua_settop",
"lua_setupvalue",
"lua_status",
"lua_toboolean",
"lua_tocfunction",
"lua_tointeger",
"lua_tolstring",
"lua_tonumber",
"lua_topointer",
"lua_tothread",
"lua_touserdata",
"lua_type",
"lua_typename",
"lua_xmove",
"lua_yield",
-- "luaopen_base",
-- "luaopen_debug",
-- "luaopen_io",
-- "luaopen_math",
-- "luaopen_os",
-- "luaopen_package",
-- "luaopen_string",
-- "luaopen_table",
}
local def = io.open("lua5.1.def", "w")
def:write("EXPORTS\n")
for _,symbol in ipairs(symbols) do
def:write("\t" .. symbol .. "=lua51." .. symbol .. "\n")
end
def:close()

View File

@ -1,12 +0,0 @@
cmake_minimum_required (VERSION 2.6)
project (md5)
include_directories ("${PROJECT_SOURCE_DIR}/../../src/")
file(GLOB SOURCE
"*.cpp"
"*.h"
)
add_library(md5 ${SOURCE})

View File

@ -1,369 +0,0 @@
/* MD5
converted to C++ class by Frank Thilo (thilo@unix-ag.org)
for bzflag (http://www.bzflag.org)
based on:
md5.h and md5.c
reference implemantion of RFC 1321
Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
rights reserved.
License to copy and use this software is granted provided that it
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
Algorithm" in all material mentioning or referencing this software
or this function.
License is also granted to make and use derivative works provided
that such works are identified as "derived from the RSA Data
Security, Inc. MD5 Message-Digest Algorithm" in all material
mentioning or referencing the derived work.
RSA Data Security, Inc. makes no representations concerning either
the merchantability of this software or the suitability of this
software for any particular purpose. It is provided "as is"
without express or implied warranty of any kind.
These notices must be retained in any copies of any part of this
documentation and/or software.
*/
/* interface header */
#include "md5.h"
/* system implementation headers */
#include <stdio.h>
#ifndef _WIN32
#include <cstring>
#endif
// Constants for MD5Transform routine.
#define S11 7
#define S12 12
#define S13 17
#define S14 22
#define S21 5
#define S22 9
#define S23 14
#define S24 20
#define S31 4
#define S32 11
#define S33 16
#define S34 23
#define S41 6
#define S42 10
#define S43 15
#define S44 21
///////////////////////////////////////////////
// F, G, H and I are basic MD5 functions.
inline MD5::uint4 MD5::F(uint4 x, uint4 y, uint4 z) {
return x&y | ~x&z;
}
inline MD5::uint4 MD5::G(uint4 x, uint4 y, uint4 z) {
return x&z | y&~z;
}
inline MD5::uint4 MD5::H(uint4 x, uint4 y, uint4 z) {
return x^y^z;
}
inline MD5::uint4 MD5::I(uint4 x, uint4 y, uint4 z) {
return y ^ (x | ~z);
}
// rotate_left rotates x left n bits.
inline MD5::uint4 MD5::rotate_left(uint4 x, int n) {
return (x << n) | (x >> (32-n));
}
// FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
// Rotation is separate from addition to prevent recomputation.
inline void MD5::FF(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {
a = rotate_left(a+ F(b,c,d) + x + ac, s) + b;
}
inline void MD5::GG(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {
a = rotate_left(a + G(b,c,d) + x + ac, s) + b;
}
inline void MD5::HH(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {
a = rotate_left(a + H(b,c,d) + x + ac, s) + b;
}
inline void MD5::II(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {
a = rotate_left(a + I(b,c,d) + x + ac, s) + b;
}
//////////////////////////////////////////////
// default ctor, just initailize
MD5::MD5()
{
init();
}
//////////////////////////////////////////////
// nifty shortcut ctor, compute MD5 for string and finalize it right away
MD5::MD5(const std::string &text)
{
init();
update(text.c_str(), text.length());
finalize();
}
//////////////////////////////
void MD5::init()
{
finalized=false;
count[0] = 0;
count[1] = 0;
// load magic initialization constants.
state[0] = 0x67452301;
state[1] = 0xefcdab89;
state[2] = 0x98badcfe;
state[3] = 0x10325476;
}
//////////////////////////////
// decodes input (unsigned char) into output (uint4). Assumes len is a multiple of 4.
void MD5::decode(uint4 output[], const uint1 input[], size_type len)
{
for (unsigned int i = 0, j = 0; j < len; i++, j += 4)
output[i] = ((uint4)input[j]) | (((uint4)input[j+1]) << 8) |
(((uint4)input[j+2]) << 16) | (((uint4)input[j+3]) << 24);
}
//////////////////////////////
// encodes input (uint4) into output (unsigned char). Assumes len is
// a multiple of 4.
void MD5::encode(uint1 output[], const uint4 input[], size_type len)
{
for (size_type i = 0, j = 0; j < len; i++, j += 4) {
output[j] = input[i] & 0xff;
output[j+1] = (input[i] >> 8) & 0xff;
output[j+2] = (input[i] >> 16) & 0xff;
output[j+3] = (input[i] >> 24) & 0xff;
}
}
//////////////////////////////
// apply MD5 algo on a block
void MD5::transform(const uint1 block[blocksize])
{
uint4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
decode (x, block, blocksize);
/* Round 1 */
FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
/* Round 2 */
GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */
GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
/* Round 3 */
HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
/* Round 4 */
II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
state[0] += a;
state[1] += b;
state[2] += c;
state[3] += d;
// Zeroize sensitive information.
memset(x, 0, sizeof x);
}
//////////////////////////////
// MD5 block update operation. Continues an MD5 message-digest
// operation, processing another message block
void MD5::update(const unsigned char input[], size_type length)
{
// compute number of bytes mod 64
size_type index = count[0] / 8 % blocksize;
// Update number of bits
if ((count[0] += (length << 3)) < (length << 3))
count[1]++;
count[1] += (length >> 29);
// number of bytes we need to fill in buffer
size_type firstpart = 64 - index;
size_type i;
// transform as many times as possible.
if (length >= firstpart)
{
// fill buffer first, transform
memcpy(&buffer[index], input, firstpart);
transform(buffer);
// transform chunks of blocksize (64 bytes)
for (i = firstpart; i + blocksize <= length; i += blocksize)
transform(&input[i]);
index = 0;
}
else
i = 0;
// buffer remaining input
memcpy(&buffer[index], &input[i], length-i);
}
//////////////////////////////
// for convenience provide a verson with signed char
void MD5::update(const char input[], size_type length)
{
update((const unsigned char*)input, length);
}
//////////////////////////////
// MD5 finalization. Ends an MD5 message-digest operation, writing the
// the message digest and zeroizing the context.
MD5& MD5::finalize()
{
static unsigned char padding[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
if (!finalized) {
// Save number of bits
unsigned char bits[8];
encode(bits, count, 8);
// pad out to 56 mod 64.
size_type index = count[0] / 8 % 64;
size_type padLen = (index < 56) ? (56 - index) : (120 - index);
update(padding, padLen);
// Append length (before padding)
update(bits, 8);
// Store state in digest
encode(digest, state, 16);
// Zeroize sensitive information.
memset(buffer, 0, sizeof buffer);
memset(count, 0, sizeof count);
finalized=true;
}
return *this;
}
//////////////////////////////
// return hex representation of digest as string
std::string MD5::hexdigest() const
{
if (!finalized)
return "";
char buf[33];
for (int i=0; i<16; i++)
sprintf(buf+i*2, "%02x", digest[i]);
buf[32]=0;
return std::string(buf);
}
//////////////////////////////
std::ostream& operator<<(std::ostream& out, MD5 md5)
{
return out << md5.hexdigest();
}
//////////////////////////////
std::string md5(const std::string & str)
{
MD5 md5 = MD5(str);
return md5.hexdigest();
}

View File

@ -1,93 +0,0 @@
/* MD5
converted to C++ class by Frank Thilo (thilo@unix-ag.org)
for bzflag (http://www.bzflag.org)
based on:
md5.h and md5.c
reference implementation of RFC 1321
Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
rights reserved.
License to copy and use this software is granted provided that it
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
Algorithm" in all material mentioning or referencing this software
or this function.
License is also granted to make and use derivative works provided
that such works are identified as "derived from the RSA Data
Security, Inc. MD5 Message-Digest Algorithm" in all material
mentioning or referencing the derived work.
RSA Data Security, Inc. makes no representations concerning either
the merchantability of this software or the suitability of this
software for any particular purpose. It is provided "as is"
without express or implied warranty of any kind.
These notices must be retained in any copies of any part of this
documentation and/or software.
*/
#ifndef BZF_MD5_H
#define BZF_MD5_H
#include <string>
#include <iostream>
// a small class for calculating MD5 hashes of strings or byte arrays
// it is not meant to be fast or secure
//
// usage: 1) feed it blocks of uchars with update()
// 2) finalize()
// 3) get hexdigest() string
// or
// MD5(std::string).hexdigest()
//
// assumes that char is 8 bit and int is 32 bit
class MD5
{
public:
typedef unsigned int size_type; // must be 32bit
MD5();
MD5(const std::string& text);
void update(const unsigned char *buf, size_type length);
void update(const char *buf, size_type length);
MD5& finalize();
std::string hexdigest() const;
friend std::ostream& operator<<(std::ostream&, MD5 md5);
private:
void init();
typedef unsigned char uint1; // 8bit
typedef unsigned int uint4; // 32bit
enum {blocksize = 64}; // VC6 won't eat a const static int here
void transform(const uint1 block[blocksize]);
static void decode(uint4 output[], const uint1 input[], size_type len);
static void encode(uint1 output[], const uint4 input[], size_type len);
bool finalized;
uint1 buffer[blocksize]; // bytes that didn't fit in last 64 byte chunk
uint4 count[2]; // 64bit counter for number of bits (lo, hi)
uint4 state[4]; // digest so far
uint1 digest[16]; // the result
// low level logic operations
static inline uint4 F(uint4 x, uint4 y, uint4 z);
static inline uint4 G(uint4 x, uint4 y, uint4 z);
static inline uint4 H(uint4 x, uint4 y, uint4 z);
static inline uint4 I(uint4 x, uint4 y, uint4 z);
static inline uint4 rotate_left(uint4 x, int n);
static inline void FF(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
static inline void GG(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
static inline void HH(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
static inline void II(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
};
std::string md5(const std::string & str);
#endif

View File

@ -1,9 +1,9 @@
if(NOT TARGET polarssl)
message("including polarssl")
set(ENABLE_TESTING OFF CACHE BOOL "Disable tests")
set(ENABLE_PROGRAMS OFF CACHE BOOL "Disable programs")
if (SELF_TEST)
set(ENABLE_TESTING OFF CACHE BOOL "Disable tests")
set(ENABLE_PROGRAMS OFF CACHE BOOL "Disable programs")
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/polarssl/ ${CMAKE_CURRENT_BINARY_DIR}/lib/polarssl)
else()
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/polarssl/ ${CMAKE_CURRENT_BINARY_DIR}/lib/polarssl EXCLUDE_FROM_ALL)

View File

@ -9,8 +9,14 @@ file(GLOB SOURCE
)
# add headers to MSVC project files:
# Lua is required as a DLL for LuaSQLite:
if (WIN32)
add_definitions(-DLUA_BUILD_AS_DLL)
endif()
# add headers to MSVC project files:
if (MSVC)
file(GLOB HEADERS "src/*.h")
list(REMOVE_ITEM SOURCE "${PROJECT_SOURCE_DIR}/src/lua.h" "${PROJECT_SOURCE_DIR}/src/luac.h")
set(SOURCE ${SOURCE} ${HEADERS})
@ -23,6 +29,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
endif()
add_library(sqlite ${SOURCE})
target_link_libraries(sqlite lua)
if (UNIX)
target_link_libraries(sqlite ${DYNAMIC_LOADER})

View File

@ -44,14 +44,13 @@ file(GLOB BIN_SOURCE
"src/bin/*.c"
)
add_executable(tolua ${BIN_SOURCE})
add_library(tolualib ${LIB_SOURCE})
target_link_libraries(tolualib lua)
#m is the standard math librarys
if(UNIX)
target_link_libraries(tolua m ${DYNAMIC_LOADER})
endif()
target_link_libraries(tolua lua tolualib)
target_link_libraries(tolua tolualib lua)

View File

@ -6,21 +6,21 @@ if mobdebugfound then mobdebug.start() end
-- The list of valid arguments that the ToLua scripts can process:
local KnownArgs = {
['v'] = true,
['h'] = true,
['p'] = true,
['P'] = true,
['o'] = true,
['n'] = true,
['H'] = true,
['S'] = true,
['1'] = true,
['L'] = true,
['D'] = true,
['W'] = true,
['C'] = true,
['E'] = true,
['t'] = true,
['q'] = true,
['h'] = true,
['p'] = true,
['P'] = true,
['o'] = true,
['n'] = true,
['H'] = true,
['S'] = true,
['1'] = true,
['L'] = true,
['D'] = true,
['W'] = true,
['C'] = true,
['E'] = true,
['t'] = true,
['q'] = true,
}

View File

@ -61,7 +61,7 @@ class cListAllocationPool : public cAllocationPool<T>
free (m_FreeList.front());
m_FreeList.pop_front();
}
}
}
virtual T * Allocate() override
{
@ -90,7 +90,7 @@ class cListAllocationPool : public cAllocationPool<T>
}
virtual void Free(T * a_ptr) override
{
if (a_ptr == NULL)
if (a_ptr == NULL)
{
return;
}
@ -107,3 +107,7 @@ class cListAllocationPool : public cAllocationPool<T>
std::list<void *> m_FreeList;
std::auto_ptr<typename cAllocationPool<T>::cStarvationCallbacks> m_Callbacks;
};

View File

@ -1 +1,2 @@
lua51.dll
LuaState_Call.inc

View File

@ -40,7 +40,7 @@ $cfile "../Entities/Painting.h"
$cfile "../Entities/Pickup.h"
$cfile "../Entities/ProjectileEntity.h"
$cfile "../Entities/TNTEntity.h"
$cfile "../Entities/Effects.h"
$cfile "../Entities/EntityEffect.h"
$cfile "../Server.h"
$cfile "../World.h"
$cfile "../Inventory.h"

View File

@ -39,7 +39,7 @@ static int tolua_get_AllToLua_g_BlockLightValue(lua_State* tolua_S)
tolua_pushnumber(tolua_S,(lua_Number)cBlockInfo::GetLightValue((BLOCKTYPE)BlockType));
return 1;
}
#endif //#ifndef TOLUA_DISABLE
#endif // #ifndef TOLUA_DISABLE
@ -65,7 +65,7 @@ static int tolua_get_AllToLua_g_BlockSpreadLightFalloff(lua_State* tolua_S)
tolua_pushnumber(tolua_S, (lua_Number)cBlockInfo::GetSpreadLightFalloff((BLOCKTYPE)BlockType));
return 1;
}
#endif //#ifndef TOLUA_DISABLE
#endif // #ifndef TOLUA_DISABLE
@ -91,7 +91,7 @@ static int tolua_get_AllToLua_g_BlockTransparent(lua_State* tolua_S)
tolua_pushboolean(tolua_S, cBlockInfo::IsTransparent((BLOCKTYPE)BlockType));
return 1;
}
#endif //#ifndef TOLUA_DISABLE
#endif // #ifndef TOLUA_DISABLE
@ -117,7 +117,7 @@ static int tolua_get_AllToLua_g_BlockOneHitDig(lua_State* tolua_S)
tolua_pushboolean(tolua_S, cBlockInfo::IsOneHitDig((BLOCKTYPE)BlockType));
return 1;
}
#endif //#ifndef TOLUA_DISABLE
#endif // #ifndef TOLUA_DISABLE
@ -143,7 +143,7 @@ static int tolua_get_AllToLua_g_BlockPistonBreakable(lua_State* tolua_S)
tolua_pushboolean(tolua_S, cBlockInfo::IsPistonBreakable((BLOCKTYPE)BlockType));
return 1;
}
#endif //#ifndef TOLUA_DISABLE
#endif // #ifndef TOLUA_DISABLE
@ -169,7 +169,7 @@ static int tolua_get_AllToLua_g_BlockIsSnowable(lua_State* tolua_S)
tolua_pushboolean(tolua_S, cBlockInfo::IsSnowable((BLOCKTYPE)BlockType));
return 1;
}
#endif //#ifndef TOLUA_DISABLE
#endif // #ifndef TOLUA_DISABLE
@ -195,7 +195,7 @@ static int tolua_get_AllToLua_g_BlockRequiresSpecialTool(lua_State* tolua_S)
tolua_pushboolean(tolua_S, cBlockInfo::RequiresSpecialTool((BLOCKTYPE)BlockType));
return 1;
}
#endif //#ifndef TOLUA_DISABLE
#endif // #ifndef TOLUA_DISABLE
@ -221,7 +221,7 @@ static int tolua_get_AllToLua_g_BlockIsSolid(lua_State* tolua_S)
tolua_pushboolean(tolua_S, (bool)cBlockInfo::IsSolid((BLOCKTYPE)BlockType));
return 1;
}
#endif //#ifndef TOLUA_DISABLE
#endif // #ifndef TOLUA_DISABLE
@ -247,7 +247,7 @@ static int tolua_get_AllToLua_g_BlockFullyOccupiesVoxel(lua_State* tolua_S)
tolua_pushboolean(tolua_S, (bool)cBlockInfo::FullyOccupiesVoxel((BLOCKTYPE)BlockType));
return 1;
}
#endif //#ifndef TOLUA_DISABLE
#endif // #ifndef TOLUA_DISABLE

View File

@ -76,7 +76,7 @@ bool cLuaChunkStay::AddChunks(int a_ChunkCoordTableStackPos)
void cLuaChunkStay::AddChunkCoord(cLuaState & L, int a_Index)
void cLuaChunkStay::AddChunkCoord(cLuaState & L, int a_Index)
{
// Check that the element has 2 coords:
int NumCoords = luaL_getn(L, -1);

View File

@ -40,7 +40,7 @@ const cLuaState::cRet cLuaState::Return = {};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// cLuaState:
cLuaState::cLuaState(const AString & a_SubsystemName) :
@ -811,6 +811,18 @@ void cLuaState::GetStackValue(int a_StackPos, double & a_ReturnedVal)
void cLuaState::GetStackValue(int a_StackPos, eWeather & a_ReturnedVal)
{
if (lua_isnumber(m_LuaState, a_StackPos))
{
a_ReturnedVal = (eWeather)Clamp((int)tolua_tonumber(m_LuaState, a_StackPos, a_ReturnedVal), (int)wSunny, (int)wThunderstorm);
}
}
bool cLuaState::CallFunction(int a_NumResults)
{
ASSERT (m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
@ -1359,7 +1371,7 @@ int cLuaState::ReportFnCallErrors(lua_State * a_LuaState)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// cLuaState::cRef:
cLuaState::cRef::cRef(void) :

View File

@ -9,10 +9,11 @@ Owned lua_State is created by calling Create() and the cLuaState automatically c
Or, lua_State can be attached by calling Attach(), the cLuaState doesn't close such a state
Attaching a state will automatically close an owned state.
Calling a Lua function is done by pushing the function, either by PushFunction() or PushFunctionFromRegistry(),
then pushing the arguments (PushString(), PushNumber(), PushUserData() etc.) and finally
executing CallFunction(). cLuaState automatically keeps track of the number of arguments and the name of the
function (for logging purposes), which makes the call less error-prone.
Calling a Lua function is done internally by pushing the function using PushFunction(), then pushing the
arguments and finally executing CallFunction(). cLuaState automatically keeps track of the number of
arguments and the name of the function (for logging purposes). After the call the return values are read from
the stack using GetStackValue(). All of this is wrapped in a templated function overloads cLuaState::Call(),
which is generated automatically by gen_LuaState_Call.lua script file into the LuaState_Call.inc file.
Reference management is provided by the cLuaState::cRef class. This is used when you need to hold a reference to
any Lua object across several function calls; usually this is used for callbacks. The class is RAII-like, with
@ -30,6 +31,7 @@ extern "C"
}
#include "../Vector3.h"
#include "../Defines.h"
@ -126,7 +128,7 @@ public:
/** Creates a new instance. The LuaState is not initialized.
a_SubsystemName is used for reporting problems in the console, it is "plugin %s" for plugins,
a_SubsystemName is used for reporting problems in the console, it is "plugin %s" for plugins,
or "LuaScript" for the cLuaScript template
*/
cLuaState(const AString & a_SubsystemName);
@ -222,625 +224,13 @@ public:
/** Retrieve value at a_StackPos, if it is a valid number. If not, a_Value is unchanged */
void GetStackValue(int a_StackPos, double & a_Value);
/** Call any 0-param 0-return Lua function in a single line: */
template <typename FnT>
bool Call(FnT a_FnName)
{
if (!PushFunction(a_FnName))
{
return false;
}
return CallFunction(0);
}
/** Call any 1-param 0-return Lua function in a single line: */
template<
typename FnT,
typename ArgT1
>
bool Call(FnT a_FnName, ArgT1 a_Arg1)
{
if (!PushFunction(a_FnName))
{
return false;
}
Push(a_Arg1);
return CallFunction(0);
}
/** Call any 2-param 0-return Lua function in a single line: */
template<
typename FnT, typename ArgT1, typename ArgT2
>
bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2)
{
if (!PushFunction(a_FnName))
{
return false;
}
Push(a_Arg1);
Push(a_Arg2);
return CallFunction(0);
}
/** Call any 3-param 0-return Lua function in a single line: */
template<
typename FnT, typename ArgT1, typename ArgT2, typename ArgT3
>
bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3)
{
if (!PushFunction(a_FnName))
{
return false;
}
Push(a_Arg1);
Push(a_Arg2);
Push(a_Arg3);
return CallFunction(0);
}
/** Call any 0-param 1-return Lua function in a single line: */
template<
typename FnT, typename RetT1
>
bool Call(FnT a_FnName, const cRet & a_Mark, RetT1 & a_Ret1)
{
UNUSED(a_Mark);
if (!PushFunction(a_FnName))
{
return false;
}
if (!CallFunction(1))
{
return false;
}
GetStackValue(-1, a_Ret1);
lua_pop(m_LuaState, 1);
return true;
}
/** Call any 1-param 1-return Lua function in a single line: */
template<
typename FnT, typename ArgT1, typename RetT1
>
bool Call(FnT a_FnName, ArgT1 a_Arg1, const cRet & a_Mark, RetT1 & a_Ret1)
{
int InitialTop = lua_gettop(m_LuaState);
UNUSED(a_Mark);
if (!PushFunction(a_FnName))
{
return false;
}
Push(a_Arg1);
if (!CallFunction(1))
{
return false;
}
GetStackValue(-1, a_Ret1);
lua_pop(m_LuaState, 1);
ASSERT(InitialTop == lua_gettop(m_LuaState));
return true;
}
/** Call any 2-param 1-return Lua function in a single line: */
template<
typename FnT, typename ArgT1, typename ArgT2, typename RetT1
>
bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, const cRet & a_Mark, RetT1 & a_Ret1)
{
UNUSED(a_Mark);
if (!PushFunction(a_FnName))
{
return false;
}
Push(a_Arg1);
Push(a_Arg2);
if (!CallFunction(1))
{
return false;
}
GetStackValue(-1, a_Ret1);
lua_pop(m_LuaState, 1);
return true;
}
/** Call any 3-param 1-return Lua function in a single line: */
template<
typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename RetT1
>
bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, const cRet & a_Mark, RetT1 & a_Ret1)
{
UNUSED(a_Mark);
if (!PushFunction(a_FnName))
{
return false;
}
Push(a_Arg1);
Push(a_Arg2);
Push(a_Arg3);
if (!CallFunction(1))
{
return false;
}
GetStackValue(-1, a_Ret1);
lua_pop(m_LuaState, 1);
return true;
}
/** Retrieve value at a_StackPos, if it is a valid number, converting and clamping it to eWeather.
If not, a_Value is unchanged. */
void GetStackValue(int a_StackPos, eWeather & a_Value);
/** Call any 4-param 1-return Lua function in a single line: */
template<
typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename RetT1
>
bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, const cRet & a_Mark, RetT1 & a_Ret1)
{
UNUSED(a_Mark);
if (!PushFunction(a_FnName))
{
return false;
}
Push(a_Arg1);
Push(a_Arg2);
Push(a_Arg3);
Push(a_Arg4);
if (!CallFunction(1))
{
return false;
}
GetStackValue(-1, a_Ret1);
lua_pop(m_LuaState, 1);
return true;
}
/** Call any 5-param 1-return Lua function in a single line: */
template<
typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename RetT1
>
bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, const cRet & a_Mark, RetT1 & a_Ret1)
{
UNUSED(a_Mark);
if (!PushFunction(a_FnName))
{
return false;
}
Push(a_Arg1);
Push(a_Arg2);
Push(a_Arg3);
Push(a_Arg4);
Push(a_Arg5);
if (!CallFunction(1))
{
return false;
}
GetStackValue(-1, a_Ret1);
lua_pop(m_LuaState, 1);
return true;
}
/** Call any 6-param 1-return Lua function in a single line: */
template<
typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename ArgT6,
typename RetT1
>
bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, const cRet & a_Mark, RetT1 & a_Ret1)
{
UNUSED(a_Mark);
if (!PushFunction(a_FnName))
{
return false;
}
Push(a_Arg1);
Push(a_Arg2);
Push(a_Arg3);
Push(a_Arg4);
Push(a_Arg5);
Push(a_Arg6);
if (!CallFunction(1))
{
return false;
}
GetStackValue(-1, a_Ret1);
lua_pop(m_LuaState, 1);
return true;
}
/** Call any 7-param 1-return Lua function in a single line: */
template<
typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename ArgT6,
typename ArgT7, typename RetT1
>
bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, const cRet & a_Mark, RetT1 & a_Ret1)
{
UNUSED(a_Mark);
if (!PushFunction(a_FnName))
{
return false;
}
Push(a_Arg1);
Push(a_Arg2);
Push(a_Arg3);
Push(a_Arg4);
Push(a_Arg5);
Push(a_Arg6);
Push(a_Arg7);
if (!CallFunction(1))
{
return false;
}
GetStackValue(-1, a_Ret1);
lua_pop(m_LuaState, 1);
return true;
}
/** Call any 8-param 1-return Lua function in a single line: */
template<
typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename ArgT6,
typename ArgT7, typename ArgT8, typename RetT1
>
bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, const cRet & a_Mark, RetT1 & a_Ret1)
{
UNUSED(a_Mark);
if (!PushFunction(a_FnName))
{
return false;
}
Push(a_Arg1);
Push(a_Arg2);
Push(a_Arg3);
Push(a_Arg4);
Push(a_Arg5);
Push(a_Arg6);
Push(a_Arg7);
Push(a_Arg8);
if (!CallFunction(1))
{
return false;
}
GetStackValue(-1, a_Ret1);
lua_pop(m_LuaState, 1);
return true;
}
/** Call any 9-param 1-return Lua function in a single line: */
template<
typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename ArgT6,
typename ArgT7, typename ArgT8, typename ArgT9, typename RetT1
>
bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, ArgT9 a_Arg9, const cRet & a_Mark, RetT1 & a_Ret1)
{
UNUSED(a_Mark);
if (!PushFunction(a_FnName))
{
return false;
}
Push(a_Arg1);
Push(a_Arg2);
Push(a_Arg3);
Push(a_Arg4);
Push(a_Arg5);
Push(a_Arg6);
Push(a_Arg7);
Push(a_Arg8);
Push(a_Arg9);
if (!CallFunction(1))
{
return false;
}
GetStackValue(-1, a_Ret1);
lua_pop(m_LuaState, 1);
return true;
}
/** Call any 10-param 1-return Lua function in a single line: */
template<
typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename ArgT6,
typename ArgT7, typename ArgT8, typename ArgT9, typename ArgT10, typename RetT1
>
bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, ArgT9 a_Arg9, ArgT10 a_Arg10, const cRet & a_Mark, RetT1 & a_Ret1)
{
UNUSED(a_Mark);
if (!PushFunction(a_FnName))
{
return false;
}
Push(a_Arg1);
Push(a_Arg2);
Push(a_Arg3);
Push(a_Arg4);
Push(a_Arg5);
Push(a_Arg6);
Push(a_Arg7);
Push(a_Arg8);
Push(a_Arg9);
Push(a_Arg10);
if (!CallFunction(1))
{
return false;
}
GetStackValue(-1, a_Ret1);
lua_pop(m_LuaState, 1);
return true;
}
/** Call any 1-param 2-return Lua function in a single line: */
template<
typename FnT, typename ArgT1, typename RetT1, typename RetT2
>
bool Call(FnT a_FnName, ArgT1 a_Arg1, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2)
{
UNUSED(a_Mark);
if (!PushFunction(a_FnName))
{
return false;
}
Push(a_Arg1);
if (!CallFunction(2))
{
return false;
}
GetStackValue(-2, a_Ret1);
GetStackValue(-1, a_Ret2);
lua_pop(m_LuaState, 2);
return true;
}
/** Call any 2-param 2-return Lua function in a single line: */
template<
typename FnT, typename ArgT1, typename ArgT2, typename RetT1, typename RetT2
>
bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2)
{
UNUSED(a_Mark);
if (!PushFunction(a_FnName))
{
return false;
}
Push(a_Arg1);
Push(a_Arg2);
if (!CallFunction(2))
{
return false;
}
GetStackValue(-2, a_Ret1);
GetStackValue(-1, a_Ret2);
lua_pop(m_LuaState, 2);
return true;
}
/** Call any 3-param 2-return Lua function in a single line: */
template<
typename FnT, typename ArgT1, typename ArgT2, typename ArgT3,
typename RetT1, typename RetT2
>
bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2)
{
UNUSED(a_Mark);
if (!PushFunction(a_FnName))
{
return false;
}
Push(a_Arg1);
Push(a_Arg2);
Push(a_Arg3);
if (!CallFunction(2))
{
return false;
}
GetStackValue(-2, a_Ret1);
GetStackValue(-1, a_Ret2);
lua_pop(m_LuaState, 2);
return true;
}
/** Call any 4-param 2-return Lua function in a single line: */
template<
typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4,
typename RetT1, typename RetT2
>
bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2)
{
UNUSED(a_Mark);
if (!PushFunction(a_FnName))
{
return false;
}
Push(a_Arg1);
Push(a_Arg2);
Push(a_Arg3);
Push(a_Arg4);
if (!CallFunction(2))
{
return false;
}
GetStackValue(-2, a_Ret1);
GetStackValue(-1, a_Ret2);
lua_pop(m_LuaState, 2);
return true;
}
/** Call any 5-param 2-return Lua function in a single line: */
template<
typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5,
typename RetT1, typename RetT2
>
bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2)
{
UNUSED(a_Mark);
if (!PushFunction(a_FnName))
{
return false;
}
Push(a_Arg1);
Push(a_Arg2);
Push(a_Arg3);
Push(a_Arg4);
Push(a_Arg5);
if (!CallFunction(2))
{
return false;
}
GetStackValue(-2, a_Ret1);
GetStackValue(-1, a_Ret2);
lua_pop(m_LuaState, 2);
return true;
}
/** Call any 6-param 2-return Lua function in a single line: */
template<
typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5,
typename ArgT6,
typename RetT1, typename RetT2
>
bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2)
{
UNUSED(a_Mark);
if (!PushFunction(a_FnName))
{
return false;
}
Push(a_Arg1);
Push(a_Arg2);
Push(a_Arg3);
Push(a_Arg4);
Push(a_Arg5);
Push(a_Arg6);
if (!CallFunction(2))
{
return false;
}
GetStackValue(-2, a_Ret1);
GetStackValue(-1, a_Ret2);
lua_pop(m_LuaState, 2);
return true;
}
/** Call any 7-param 2-return Lua function in a single line: */
template<
typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5,
typename ArgT6, typename ArgT7,
typename RetT1, typename RetT2
>
bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2)
{
UNUSED(a_Mark);
if (!PushFunction(a_FnName))
{
return false;
}
Push(a_Arg1);
Push(a_Arg2);
Push(a_Arg3);
Push(a_Arg4);
Push(a_Arg5);
Push(a_Arg6);
Push(a_Arg7);
if (!CallFunction(2))
{
return false;
}
GetStackValue(-2, a_Ret1);
GetStackValue(-1, a_Ret2);
lua_pop(m_LuaState, 2);
return true;
}
/** Call any 7-param 3-return Lua function in a single line: */
template<
typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5,
typename ArgT6, typename ArgT7,
typename RetT1, typename RetT2, typename RetT3
>
bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2, RetT3 & a_Ret3)
{
UNUSED(a_Mark);
if (!PushFunction(a_FnName))
{
return false;
}
Push(a_Arg1);
Push(a_Arg2);
Push(a_Arg3);
Push(a_Arg4);
Push(a_Arg5);
Push(a_Arg6);
Push(a_Arg7);
if (!CallFunction(3))
{
return false;
}
GetStackValue(-3, a_Ret1);
GetStackValue(-2, a_Ret2);
GetStackValue(-1, a_Ret3);
lua_pop(m_LuaState, 3);
return true;
}
/** Call any 8-param 3-return Lua function in a single line: */
template<
typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5,
typename ArgT6, typename ArgT7, typename ArgT8,
typename RetT1, typename RetT2, typename RetT3
>
bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2, RetT3 & a_Ret3)
{
UNUSED(a_Mark);
if (!PushFunction(a_FnName))
{
return false;
}
Push(a_Arg1);
Push(a_Arg2);
Push(a_Arg3);
Push(a_Arg4);
Push(a_Arg5);
Push(a_Arg6);
Push(a_Arg7);
Push(a_Arg8);
if (!CallFunction(3))
{
return false;
}
GetStackValue(-3, a_Ret1);
GetStackValue(-2, a_Ret2);
GetStackValue(-1, a_Ret3);
lua_pop(m_LuaState, 3);
return true;
}
/** Call any 9-param 5-return Lua function in a single line: */
template<
typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5,
typename ArgT6, typename ArgT7, typename ArgT8, typename ArgT9,
typename RetT1, typename RetT2, typename RetT3, typename RetT4, typename RetT5
>
bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, ArgT9 a_Arg9, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2, RetT3 & a_Ret3, RetT4 & a_Ret4, RetT5 & a_Ret5)
{
UNUSED(a_Mark);
if (!PushFunction(a_FnName))
{
return false;
}
Push(a_Arg1);
Push(a_Arg2);
Push(a_Arg3);
Push(a_Arg4);
Push(a_Arg5);
Push(a_Arg6);
Push(a_Arg7);
Push(a_Arg8);
Push(a_Arg9);
if (!CallFunction(5))
{
return false;
}
GetStackValue(-5, a_Ret1);
GetStackValue(-4, a_Ret2);
GetStackValue(-3, a_Ret3);
GetStackValue(-2, a_Ret4);
GetStackValue(-1, a_Ret5);
lua_pop(m_LuaState, 5);
return true;
}
// Include the cLuaState::Call() overload implementation that is generated by the gen_LuaState_Call.lua script:
#include "LuaState_Call.inc"
/** Returns true if the specified parameters on the stack are of the specified usertable type; also logs warning if not. Used for static functions */

View File

@ -7,13 +7,13 @@
#include "../UI/SlotArea.h"
#include "PluginLua.h"
#include "../Entities/Player.h"
#include "lua/src/lauxlib.h" // Needed for LUA_REFNIL
#include "lua/src/lauxlib.h" // Needed for LUA_REFNIL
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// cLuaWindow:
cLuaWindow::cLuaWindow(cWindow::WindowType a_WindowType, int a_SlotsX, int a_SlotsY, const AString & a_Title) :

View File

@ -4,7 +4,7 @@
#include "ManualBindings.h"
#undef TOLUA_TEMPLATE_BIND
#include "tolua++/include/tolua++.h"
#include "polarssl/md5.h"
#include "Plugin.h"
#include "PluginLua.h"
#include "PluginManager.h"
@ -25,7 +25,6 @@
#include "../BlockEntities/NoteEntity.h"
#include "../BlockEntities/MobHeadEntity.h"
#include "../BlockEntities/FlowerPotEntity.h"
#include "md5/md5.h"
#include "../LineBlockTracer.h"
#include "../WorldStorage/SchematicFileSerializer.h"
#include "../CompositeChat.h"
@ -34,9 +33,7 @@
/****************************
* Better error reporting for Lua
**/
// Better error reporting for Lua
static int tolua_do_error(lua_State* L, const char * a_pMsg, tolua_Error * a_pToLuaError)
{
// Retrieve current function name
@ -82,10 +79,7 @@ static int lua_do_error(lua_State* L, const char * a_pFormat, ...)
/****************************
* Lua bound functions with special return types
**/
// Lua bound functions with special return types
static int tolua_StringSplit(lua_State * tolua_S)
{
cLuaState LuaState(tolua_S);
@ -558,10 +552,12 @@ static int tolua_DoWithXYZ(lua_State* tolua_S)
template< class Ty1,
class Ty2,
bool (Ty1::*Func1)(int, int, cItemCallback<Ty2> &) >
static int tolua_ForEachInChunk(lua_State* tolua_S)
template<
class Ty1,
class Ty2,
bool (Ty1::*Func1)(int, int, cItemCallback<Ty2> &)
>
static int tolua_ForEachInChunk(lua_State * tolua_S)
{
int NumArgs = lua_gettop(tolua_S) - 1; /* This includes 'self' */
if ((NumArgs != 3) && (NumArgs != 4))
@ -652,9 +648,11 @@ static int tolua_ForEachInChunk(lua_State* tolua_S)
template< class Ty1,
class Ty2,
bool (Ty1::*Func1)(cItemCallback<Ty2> &) >
template<
class Ty1,
class Ty2,
bool (Ty1::*Func1)(cItemCallback<Ty2> &)
>
static int tolua_ForEach(lua_State * tolua_S)
{
int NumArgs = lua_gettop(tolua_S) - 1; /* This includes 'self' */
@ -2001,9 +1999,11 @@ static int tolua_cPlugin_Call(lua_State * tolua_S)
static int tolua_md5(lua_State* tolua_S)
{
std::string SourceString = tolua_tostring(tolua_S, 1, 0);
std::string CryptedString = md5( SourceString );
tolua_pushstring( tolua_S, CryptedString.c_str() );
unsigned char Output[16];
size_t len = 0;
const unsigned char * SourceString = (const unsigned char *)lua_tolstring(tolua_S, 1, &len);
md5(SourceString, len, Output);
lua_pushlstring(tolua_S, (const char *)Output, ARRAYCOUNT(Output));
return 1;
}
@ -2064,7 +2064,7 @@ static int tolua_get_HTTPRequest_FormData(lua_State* tolua_S)
{
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_pushlstring(tolua_S, it->second.Value.c_str(), it->second.Value.size() ); // Might contain binary data
lua_settable(tolua_S, top);
}
@ -2113,7 +2113,7 @@ static int tolua_cWebPlugin_GetTabNames(lua_State * tolua_S)
{
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, 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);

View File

@ -42,10 +42,7 @@ public:
// Called each tick
virtual void Tick(float a_Dt) = 0;
/**
* On all these functions, return true if you want to override default behavior and not call other plugins on that callback.
* You can also return false, so default behavior is used.
**/
/** Calls the specified hook with the params given. Returns the bool that the hook callback returns.*/
virtual bool OnBlockSpread (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source) = 0;
virtual bool OnBlockToPickups (cWorld * a_World, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cItems & a_Pickups) = 0;
virtual bool OnChat (cPlayer * a_Player, AString & a_Message) = 0;
@ -57,13 +54,14 @@ public:
virtual bool OnCollectingPickup (cPlayer * a_Player, cPickup * a_Pickup) = 0;
virtual bool OnCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0;
virtual bool OnDisconnect (cClientHandle & a_Client, const AString & a_Reason) = 0;
virtual bool OnEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier) = 0;
virtual bool OnExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split) = 0;
virtual bool OnExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) = 0;
virtual bool OnExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) = 0;
virtual bool OnHandshake (cClientHandle * a_Client, const AString & a_Username) = 0;
virtual bool OnHopperPullingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_DstSlotNum, cBlockEntityWithItems & a_SrcEntity, int a_SrcSlotNum) = 0;
virtual bool OnHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum) = 0;
virtual bool OnKilling (cEntity & a_Victim, cEntity * a_Killer) = 0;
virtual bool OnKilling (cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI) = 0;
virtual bool OnLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username) = 0;
virtual bool OnPlayerAnimation (cPlayer & a_Player, int a_Animation) = 0;
virtual bool OnPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0;
@ -72,6 +70,7 @@ public:
virtual bool OnPlayerEating (cPlayer & a_Player) = 0;
virtual bool OnPlayerFished (cPlayer & a_Player, const cItems & a_Reward) = 0;
virtual bool OnPlayerFishing (cPlayer & a_Player, cItems & a_Reward) = 0;
virtual bool OnPlayerFoodLevelChange (cPlayer & a_Player, int a_NewFoodLevel) = 0;
virtual bool OnPlayerJoined (cPlayer & a_Player) = 0;
virtual bool OnPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status) = 0;
virtual bool OnPlayerMoved (cPlayer & a_Player) = 0;
@ -150,7 +149,7 @@ private:
int m_Version;
AString m_Directory;
}; // tolua_export
}; // tolua_export

View File

@ -25,7 +25,7 @@ extern "C"
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// cPluginLua:
cPluginLua::cPluginLua(const AString & a_PluginDirectory) :
@ -78,7 +78,7 @@ bool cPluginLua::Initialize(void)
{
cCSLock Lock(m_CriticalSection);
if (!m_LuaState.IsValid())
{
{
m_LuaState.Create();
m_LuaState.RegisterAPILibs();
@ -420,6 +420,26 @@ bool cPluginLua::OnDisconnect(cClientHandle & a_Client, const AString & a_Reason
bool cPluginLua::OnEntityAddEffect(cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier)
{
cCSLock Lock(m_CriticalSection);
bool res = false;
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_ENTITY_ADD_EFFECT];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
m_LuaState.Call((int)(**itr), &a_Entity, a_EffectType, a_EffectDurationTicks, a_EffectIntensity, a_DistanceModifier, cLuaState::Return, res);
if (res)
{
return true;
}
}
return false;
}
bool cPluginLua::OnExecuteCommand(cPlayer * a_Player, const AStringVector & a_Split)
{
cCSLock Lock(m_CriticalSection);
@ -575,14 +595,14 @@ bool cPluginLua::OnHopperPushingItem(cWorld & a_World, cHopperEntity & a_Hopper,
bool cPluginLua::OnKilling(cEntity & a_Victim, cEntity * a_Killer)
bool cPluginLua::OnKilling(cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI)
{
cCSLock Lock(m_CriticalSection);
bool res = false;
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_KILLING];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
m_LuaState.Call((int)(**itr), &a_Victim, a_Killer, cLuaState::Return, res);
m_LuaState.Call((int)(**itr), &a_Victim, a_Killer, &a_TDI, cLuaState::Return, res);
if (res)
{
return true;
@ -715,6 +735,26 @@ bool cPluginLua::OnPlayerEating(cPlayer & a_Player)
bool cPluginLua::OnPlayerFoodLevelChange(cPlayer & a_Player, int a_NewFoodLevel)
{
cCSLock Lock(m_CriticalSection);
bool res = false;
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_FOOD_LEVEL_CHANGE];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
m_LuaState.Call((int)(**itr), &a_Player, a_NewFoodLevel, cLuaState::Return, res);
if (res)
{
return true;
}
}
return false;
}
bool cPluginLua::OnPlayerFished(cPlayer & a_Player, const cItems & a_Reward)
{
cCSLock Lock(m_CriticalSection);
@ -975,7 +1015,7 @@ bool cPluginLua::OnPlayerUsedBlock(cPlayer & a_Player, int a_BlockX, int a_Block
bool cPluginLua::OnPlayerUsedItem(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
bool cPluginLua::OnPlayerUsedItem(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
{
cCSLock Lock(m_CriticalSection);
bool res = false;
@ -1254,8 +1294,8 @@ bool cPluginLua::OnTakeDamage(cEntity & a_Receiver, TakeDamageInfo & a_TDI)
bool cPluginLua::OnUpdatedSign(
cWorld * a_World,
int a_BlockX, int a_BlockY, int a_BlockZ,
cWorld * a_World,
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,
cPlayer * a_Player
)
@ -1279,8 +1319,8 @@ bool cPluginLua::OnUpdatedSign(
bool cPluginLua::OnUpdatingSign(
cWorld * a_World,
int a_BlockX, int a_BlockY, int a_BlockZ,
cWorld * a_World,
int a_BlockX, int a_BlockY, int a_BlockZ,
AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4,
cPlayer * a_Player
)
@ -1327,18 +1367,15 @@ bool cPluginLua::OnWeatherChanging(cWorld & a_World, eWeather & a_NewWeather)
{
cCSLock Lock(m_CriticalSection);
bool res = false;
int NewWeather = a_NewWeather;
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_WEATHER_CHANGING];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
m_LuaState.Call((int)(**itr), &a_World, NewWeather, cLuaState::Return, res, NewWeather);
m_LuaState.Call((int)(**itr), &a_World, a_NewWeather, cLuaState::Return, res, a_NewWeather);
if (res)
{
a_NewWeather = (eWeather)NewWeather;
return true;
}
}
a_NewWeather = (eWeather)NewWeather;
return false;
}
@ -1480,7 +1517,7 @@ bool cPluginLua::CanAddOldStyleHook(int a_HookType)
return true;
}
LOGWARNING("Plugin %s wants to add a hook (%d), but it doesn't provide the callback function \"%s\" for it. The plugin need not work properly.",
LOGWARNING("Plugin %s wants to add a hook (%d), but it doesn't provide the callback function \"%s\" for it. The plugin need not work properly.",
GetName().c_str(), a_HookType, FnName
);
m_LuaState.LogStackTrace();
@ -1507,6 +1544,7 @@ const char * cPluginLua::GetHookFnName(int a_HookType)
case cPluginManager::HOOK_CRAFTING_NO_RECIPE: return "OnCraftingNoRecipe";
case cPluginManager::HOOK_DISCONNECT: return "OnDisconnect";
case cPluginManager::HOOK_PLAYER_ANIMATION: return "OnPlayerAnimation";
case cPluginManager::HOOK_ENTITY_ADD_EFFECT: return "OnEntityAddEffect";
case cPluginManager::HOOK_EXECUTE_COMMAND: return "OnExecuteCommand";
case cPluginManager::HOOK_HANDSHAKE: return "OnHandshake";
case cPluginManager::HOOK_KILLING: return "OnKilling";
@ -1632,7 +1670,7 @@ AString cPluginLua::HandleWebRequest(const HTTPRequest * a_Request )
sWebPluginTab * Tab = 0;
for (TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr)
{
if ((*itr)->SafeTitle.compare(SafeTabName) == 0) // This is the one! Rawr
if ((*itr)->SafeTitle.compare(SafeTabName) == 0) // This is the one! Rawr
{
Tab = *itr;
break;
@ -1714,7 +1752,7 @@ bool cPluginLua::CallbackWindowClosing(int a_FnRef, cWindow & a_Window, cPlayer
ASSERT(a_FnRef != LUA_REFNIL);
cCSLock Lock(m_CriticalSection);
bool res;
bool res = false;
m_LuaState.Call(a_FnRef, &a_Window, &a_Player, a_CanRefuse, cLuaState::Return, res);
return res;
}

View File

@ -80,13 +80,14 @@ public:
virtual bool OnCollectingPickup (cPlayer * a_Player, cPickup * a_Pickup) override;
virtual bool OnCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override;
virtual bool OnDisconnect (cClientHandle & a_Client, const AString & a_Reason) override;
virtual bool OnEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier) override;
virtual bool OnExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split) override;
virtual bool OnExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) override;
virtual bool OnExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) override;
virtual bool OnHandshake (cClientHandle * a_Client, const AString & a_Username) override;
virtual bool OnHopperPullingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_DstSlotNum, cBlockEntityWithItems & a_SrcEntity, int a_SrcSlotNum) override;
virtual bool OnHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum) override;
virtual bool OnKilling (cEntity & a_Victim, cEntity * a_Killer) override;
virtual bool OnKilling (cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI) override;
virtual bool OnLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username) override;
virtual bool OnPlayerAnimation (cPlayer & a_Player, int a_Animation) override;
virtual bool OnPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override;
@ -95,6 +96,7 @@ public:
virtual bool OnPlayerEating (cPlayer & a_Player) override;
virtual bool OnPlayerFished (cPlayer & a_Player, const cItems & a_Reward) override;
virtual bool OnPlayerFishing (cPlayer & a_Player, cItems & a_Reward) override;
virtual bool OnPlayerFoodLevelChange (cPlayer & a_Player, int a_NewFoodLevel) override;
virtual bool OnPlayerJoined (cPlayer & a_Player) override;
virtual bool OnPlayerMoved (cPlayer & a_Player) override;
virtual bool OnPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status) override;
@ -143,7 +145,7 @@ public:
// cWebPlugin and WebAdmin stuff
virtual AString HandleWebRequest(const HTTPRequest * a_Request ) override;
bool AddWebTab(const AString & a_Title, lua_State * a_LuaState, int a_FunctionReference); // >> EXPORTED IN MANUALBINDINGS <<
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. */
void BindCommand(const AString & a_Command, int a_FnRef);

View File

@ -257,18 +257,44 @@ bool cPluginManager::CallHookBlockToPickups(
bool cPluginManager::CallHookChat(cPlayer * a_Player, AString & a_Message)
{
bool WasCommandForbidden = false;
if (HandleCommand(a_Player, a_Message, true, WasCommandForbidden)) // We use HandleCommand as opposed to ExecuteCommand to accomodate the need to the WasCommandForbidden bool
// Check if the message contains a command, execute it:
switch (HandleCommand(a_Player, a_Message, true))
{
return true; // Chat message was handled as command
}
else if (WasCommandForbidden) // Couldn't be handled as command, was it because of insufficient permissions?
{
return true; // Yes - message was sent in HandleCommand, abort
case crExecuted:
{
// The command has executed successfully
return true;
}
case crBlocked:
{
// The command was blocked by a plugin using HOOK_EXECUTE_COMMAND
// The plugin has most likely sent a message to the player already
return true;
}
case crError:
{
// An error in the plugin has prevented the command from executing. Report the error to the player:
a_Player->SendMessageFailure(Printf("Something went wrong while executing command \"%s\"", a_Message.c_str()));
return true;
}
case crNoPermission:
{
// The player is not allowed to execute this command
a_Player->SendMessageFailure(Printf("Forbidden command; insufficient privileges: \"%s\"", a_Message.c_str()));
return true;
}
case crUnknownCommand:
{
// This was not a known command, keep processing as a message
break;
}
}
// Check if it was a standard command (starts with a slash)
// If it was, we know that it was completely unrecognised (WasCommandForbidden == false)
// Check if the message is a command (starts with a slash). If it is, we know that it wasn't recognised:
if (!a_Message.empty() && (a_Message[0] == '/'))
{
AStringVector Split(StringSplit(a_Message, " "));
@ -448,6 +474,27 @@ bool cPluginManager::CallHookDisconnect(cClientHandle & a_Client, const AString
bool cPluginManager::CallHookEntityAddEffect(cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier)
{
HookMap::iterator Plugins = m_Hooks.find(HOOK_ENTITY_ADD_EFFECT);
if (Plugins == m_Hooks.end())
{
return false;
}
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnEntityAddEffect(a_Entity, a_EffectType, a_EffectDurationTicks, a_EffectIntensity, a_DistanceModifier))
{
return true;
}
}
return false;
}
bool cPluginManager::CallHookExecuteCommand(cPlayer * a_Player, const AStringVector & a_Split)
{
FIND_HOOK(HOOK_EXECUTE_COMMAND);
@ -562,14 +609,14 @@ bool cPluginManager::CallHookHopperPushingItem(cWorld & a_World, cHopperEntity &
bool cPluginManager::CallHookKilling(cEntity & a_Victim, cEntity * a_Killer)
bool cPluginManager::CallHookKilling(cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI)
{
FIND_HOOK(HOOK_KILLING);
VERIFY_HOOK;
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnKilling(a_Victim, a_Killer))
if ((*itr)->OnKilling(a_Victim, a_Killer, a_TDI))
{
return true;
}
@ -695,6 +742,25 @@ bool cPluginManager::CallHookPlayerEating(cPlayer & a_Player)
bool cPluginManager::CallHookPlayerFoodLevelChange(cPlayer & a_Player, int a_NewFoodLevel)
{
FIND_HOOK(HOOK_PLAYER_FOOD_LEVEL_CHANGE);
VERIFY_HOOK;
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerFoodLevelChange(a_Player, a_NewFoodLevel))
{
return true;
}
}
return false;
}
bool cPluginManager::CallHookPlayerFished(cPlayer & a_Player, const cItems a_Reward)
{
FIND_HOOK(HOOK_PLAYER_FISHED);
@ -1318,28 +1384,28 @@ bool cPluginManager::CallHookWorldTick(cWorld & a_World, float a_Dt, int a_LastT
bool cPluginManager::HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions, bool & a_WasCommandForbidden)
cPluginManager::CommandResult cPluginManager::HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions)
{
ASSERT(a_Player != NULL);
AStringVector Split(StringSplit(a_Command, " "));
if (Split.empty())
{
return false;
return crUnknownCommand;
}
CommandMap::iterator cmd = m_Commands.find(Split[0]);
if (cmd == m_Commands.end())
{
// Command not found
return false;
return crUnknownCommand;
}
// Ask plugins first if a command is okay to execute the command:
if (CallHookExecuteCommand(a_Player, Split))
{
LOGINFO("Player %s tried executing command \"%s\" that was stopped by the HOOK_EXECUTE_COMMAND hook", a_Player->GetName().c_str(), Split[0].c_str());
return false;
return crBlocked;
}
if (
@ -1348,15 +1414,18 @@ bool cPluginManager::HandleCommand(cPlayer * a_Player, const AString & a_Command
!a_Player->HasPermission(cmd->second.m_Permission)
)
{
a_Player->SendMessageFailure(Printf("Forbidden command; insufficient privileges: \"%s\"", Split[0].c_str()));
LOGINFO("Player %s tried to execute forbidden command: \"%s\"", a_Player->GetName().c_str(), Split[0].c_str());
a_WasCommandForbidden = true;
return false;
return crNoPermission;
}
ASSERT(cmd->second.m_Plugin != NULL);
return cmd->second.m_Plugin->HandleCommand(Split, a_Player);
if (!cmd->second.m_Plugin->HandleCommand(Split, a_Player))
{
return crError;
}
return crExecuted;
}
@ -1417,7 +1486,7 @@ bool cPluginManager::DisablePlugin(const AString & a_PluginName)
if (itr->first.compare(a_PluginName) == 0) // _X 2013_02_01: wtf? Isn't this supposed to be what find() does?
{
m_DisablePluginList.push_back(itr->second);
itr->second = NULL; // Get rid of this thing right away
itr->second = NULL; // Get rid of this thing right away
return true;
}
return false;
@ -1554,7 +1623,7 @@ AString cPluginManager::GetCommandPermission(const AString & a_Command)
bool cPluginManager::ExecuteCommand(cPlayer * a_Player, const AString & a_Command)
cPluginManager::CommandResult cPluginManager::ExecuteCommand(cPlayer * a_Player, const AString & a_Command)
{
return HandleCommand(a_Player, a_Command, true);
}
@ -1563,7 +1632,7 @@ bool cPluginManager::ExecuteCommand(cPlayer * a_Player, const AString & a_Comman
bool cPluginManager::ForceExecuteCommand(cPlayer * a_Player, const AString & a_Command)
cPluginManager::CommandResult cPluginManager::ForceExecuteCommand(cPlayer * a_Player, const AString & a_Command)
{
return HandleCommand(a_Player, a_Command, false);
}

View File

@ -51,14 +51,25 @@ class cBlockEntityWithItems;
class cPluginManager // tolua_export
{ // tolua_export
public: // tolua_export
// tolua_begin
class cPluginManager
{
public:
// tolua_end
// Called each tick
virtual void Tick(float a_Dt);
// tolua_begin
enum CommandResult
{
crExecuted,
crUnknownCommand,
crError,
crBlocked,
crNoPermission,
} ;
enum PluginHook
{
HOOK_BLOCK_SPREAD,
@ -73,6 +84,7 @@ public: // tolua_export
HOOK_CRAFTING_NO_RECIPE,
HOOK_DISCONNECT,
HOOK_PLAYER_ANIMATION,
HOOK_ENTITY_ADD_EFFECT,
HOOK_EXECUTE_COMMAND,
HOOK_EXPLODED,
HOOK_EXPLODING,
@ -87,6 +99,7 @@ public: // tolua_export
HOOK_PLAYER_EATING,
HOOK_PLAYER_FISHED,
HOOK_PLAYER_FISHING,
HOOK_PLAYER_FOOD_LEVEL_CHANGE,
HOOK_PLAYER_JOINED,
HOOK_PLAYER_LEFT_CLICK,
HOOK_PLAYER_MOVING,
@ -146,15 +159,17 @@ public: // tolua_export
/** Returns the instance of the Plugin Manager (there is only ever one) */
static cPluginManager * Get(void); // tolua_export
static cPluginManager * Get(void); // tolua_export
typedef std::map< AString, cPlugin * > PluginMap;
typedef std::list< cPlugin * > PluginList;
cPlugin * GetPlugin( const AString & a_Plugin ) const; // tolua_export
const PluginMap & GetAllPlugins() const; // >> EXPORTED IN MANUALBINDINGS <<
cPlugin * GetPlugin( const AString & a_Plugin ) const; // tolua_export
const PluginMap & GetAllPlugins() const; // >> EXPORTED IN MANUALBINDINGS <<
void FindPlugins(); // tolua_export
void ReloadPlugins(); // tolua_export
// tolua_begin
void FindPlugins();
void ReloadPlugins();
// tolua_end
/** Adds the plugin to the list of plugins called for the specified hook type. Handles multiple adds as a single add */
void AddHook(cPlugin * a_Plugin, int a_HookType);
@ -173,13 +188,14 @@ public: // tolua_export
bool CallHookCollectingPickup (cPlayer * a_Player, cPickup & a_Pickup);
bool CallHookCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe);
bool CallHookDisconnect (cClientHandle & a_Client, const AString & a_Reason);
bool CallHookEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier);
bool CallHookExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split); // If a_Player == NULL, it is a console cmd
bool CallHookExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData);
bool CallHookExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData);
bool CallHookHandshake (cClientHandle * a_ClientHandle, const AString & a_Username);
bool CallHookHopperPullingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_DstSlotNum, cBlockEntityWithItems & a_SrcEntity, int a_SrcSlotNum);
bool CallHookHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum);
bool CallHookKilling (cEntity & a_Victim, cEntity * a_Killer);
bool CallHookKilling (cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI);
bool CallHookLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username);
bool CallHookPlayerAnimation (cPlayer & a_Player, int a_Animation);
bool CallHookPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
@ -188,6 +204,7 @@ public: // tolua_export
bool CallHookPlayerEating (cPlayer & a_Player);
bool CallHookPlayerFished (cPlayer & a_Player, const cItems a_Reward);
bool CallHookPlayerFishing (cPlayer & a_Player, cItems a_Reward);
bool CallHookPlayerFoodLevelChange (cPlayer & a_Player, int a_NewFoodLevel);
bool CallHookPlayerJoined (cPlayer & a_Player);
bool CallHookPlayerMoving (cPlayer & a_Player);
bool CallHookPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status);
@ -244,11 +261,11 @@ public: // tolua_export
/** Returns the permission needed for the specified command; empty string if command not found */
AString GetCommandPermission(const AString & a_Command); // tolua_export
/** Executes the command, as if it was requested by a_Player. Checks permissions first. Returns true if executed. */
bool ExecuteCommand(cPlayer * a_Player, const AString & a_Command); // tolua_export
/** Executes the command, as if it was requested by a_Player. Checks permissions first. Returns crExecuted if executed. */
CommandResult ExecuteCommand(cPlayer * a_Player, const AString & a_Command); // tolua_export
/** Executes the command, as if it was requested by a_Player. Permisssions are not checked. Returns true if executed (false if not found) */
bool ForceExecuteCommand(cPlayer * a_Player, const AString & a_Command); // tolua_export
/** Executes the command, as if it was requested by a_Player. Permisssions are not checked. Returns crExecuted if executed. */
CommandResult ForceExecuteCommand(cPlayer * a_Player, const AString & a_Command); // tolua_export
/** Removes all console command bindings that the specified plugin has made */
void RemovePluginConsoleCommands(cPlugin * a_Plugin);
@ -321,14 +338,9 @@ private:
/** Adds the plugin into the internal list of plugins and initializes it. If initialization fails, the plugin is removed again. */
bool AddPlugin(cPlugin * a_Plugin);
/** Tries to match a_Command to the internal table of commands, if a match is found, the corresponding plugin is called. Returns true if the command is handled. */
bool HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions, bool & a_WasCommandForbidden);
bool HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions)
{
bool DummyBoolean = false;
return HandleCommand(a_Player, a_Command, a_ShouldCheckPermissions, DummyBoolean);
}
} ; // tolua_export
/** Tries to match a_Command to the internal table of commands, if a match is found, the corresponding plugin is called. Returns crExecuted if the command is executed. */
cPluginManager::CommandResult HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions);
} ; // tolua_export

View File

@ -64,27 +64,27 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest
std::pair< AString, AString > Names;
AStringVector Split = StringSplit(a_Request->Path, "/");
if( Split.size() > 1 )
if (Split.size() > 1)
{
sWebPluginTab* Tab = 0;
if( Split.size() > 2 ) // If we got the tab name, show that page
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 )
{
if( (*itr)->SafeTitle.compare( Split[2] ) == 0 ) // This is the one! Rawr
if ((*itr)->SafeTitle.compare(Split[2]) == 0) // This is the one!
{
Tab = *itr;
break;
}
}
}
else // Otherwise show the first tab
else // Otherwise show the first tab
{
if( GetTabs().size() > 0 )
Tab = *GetTabs().begin();
}
if( Tab )
if (Tab != NULL)
{
Names.first = Tab->Title;
Names.second = Tab->SafeTitle;
@ -97,13 +97,13 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest
AString cWebPlugin::SafeString( const AString & a_String )
AString cWebPlugin::SafeString(const AString & a_String)
{
AString RetVal;
for( unsigned int i = 0; i < a_String.size(); ++i )
{
char c = a_String[i];
if( c == ' ' )
if( c == ' ' )
{
c = '_';
}
@ -111,3 +111,7 @@ AString cWebPlugin::SafeString( const AString & a_String )
}
return RetVal;
}

View File

@ -36,7 +36,7 @@ public:
TabList & GetTabs() { return m_Tabs; }
typedef std::list< std::pair<AString, AString> > TabNameList;
TabNameList GetTabNames(); // >> EXPORTED IN MANUALBINDINGS <<
TabNameList GetTabNames(); // >> EXPORTED IN MANUALBINDINGS <<
std::pair< AString, AString > GetTabNameForRequest(const HTTPRequest* a_Request );
private:

View File

@ -0,0 +1,196 @@
-- gen_LuaState_Call.lua
-- Generates the cLuaState::Call() function templates that are included from LuaState.h
--[[
The cLuaState::Call() family of functions provides a template-based system for calling any Lua function
either by name or by reference with almost any number of parameters and return values. This is done by
providing a number of overloads of the same name with variable number of template-type parameters. To
separate the arguments from the return values, a special type of cLuaState::cRet is used.
--]]
print("Generating LuaState_Call.inc...")
-- List of combinations (# params, # returns) to generate:
local Combinations =
{
-- no return values:
{0, 0},
{1, 0},
{2, 0},
{3, 0},
{4, 0},
-- 1 return value:
{0, 1},
{1, 1},
{2, 1},
{3, 1},
{4, 1},
{5, 1},
{6, 1},
{7, 1},
{8, 1},
{9, 1},
{10, 1},
-- 2 return values:
{0, 2},
{1, 2},
{2, 2},
{3, 2},
{4, 2},
{5, 2},
{6, 2},
{7, 2},
{8, 2},
{9, 2},
-- Special combinations:
{7, 3},
{8, 3},
{9, 5},
}
--- Writes a single overloaded function definition for the specified number of params and returns into f
--[[
The format for the generated function is this:
/** Call the specified 3-param 2-return Lua function:
Returns true if call succeeded, false if there was an error. */
template <typename FnT, typename ParamT1, typename ParamT2, typename ParamT3, typename RetT1, typename RetT2>
bool Call(FnT a_Function, ParamT1 a_Param1, ParamT2 a_Param2, ParamT3 a_Param3, const cLuaState::cRet & a_RetMark, RetT1 & a_Ret1, RetT2 & a_Ret2)
{
UNUSED(a_RetMark);
if (!PushFunction(a_Function))
{
return false;
}
Push(a_Param1);
Push(a_Param2);
Push(a_Param3);
if (!CallFunction(2))
{
return false;
}
GetStackValue(-2, a_Ret1);
GetStackValue(-1, a_Ret2);
lua_pop(m_LuaState, 2);
return true;
}
Note especially the negative numbers in GetStackValue() calls.
--]]
local function WriteOverload(f, a_NumParams, a_NumReturns)
-- Write the function doxy-comments:
f:write("/** Call the specified ", a_NumParams, "-param ", a_NumReturns, "-return Lua function:\n")
f:write("Returns true if call succeeded, false if there was an error. */\n")
-- Write the template <...> line:
f:write("template <typename FnT")
for i = 1, a_NumParams do
f:write(", typename ParamT", i)
end
if (a_NumReturns > 0) then
for i = 1, a_NumReturns do
f:write(", typename RetT", i)
end
end
f:write(">\n")
-- Write the function signature:
f:write("bool Call(")
f:write("FnT a_Function")
for i = 1, a_NumParams do
f:write(", ParamT", i, " a_Param", i)
end
if (a_NumReturns > 0) then
f:write(", const cLuaState::cRet & a_RetMark")
for i = 1, a_NumReturns do
f:write(", RetT", i, " & a_Ret", i)
end
end
f:write(")\n")
-- Common code:
f:write("{\n")
if (a_NumReturns > 0) then
f:write("\tUNUSED(a_RetMark);\n")
end
f:write("\tif (!PushFunction(a_Function))\n")
f:write("\t{\n")
f:write("\t\treturn false;\n")
f:write("\t}\n")
-- Push the params:
for i = 1, a_NumParams do
f:write("\tPush(a_Param", i, ");\n")
end
-- Call the function:
f:write("\tif (!CallFunction(", a_NumReturns, "))\n")
f:write("\t{\n")
f:write("\t\treturn false;\n")
f:write("\t}\n")
-- Get the return values:
for i = 1, a_NumReturns do
f:write("\tGetStackValue(", -1 - a_NumReturns + i, ", a_Ret", i, ");\n")
end
-- Pop the returns off the stack, if needed:
if (a_NumReturns > 0) then
f:write("\tlua_pop(m_LuaState, ", a_NumReturns, ");\n")
end
-- Everything ok:
f:write("\treturn true;\n")
f:write("}\n")
-- Separate from the next function:
f:write("\n\n\n\n\n")
end
local f = assert(io.open("LuaState_Call.inc", "w"))
-- Write file header:
f:write([[
// LuaState_Call.inc
// This file is auto-generated by gen_LuaState_Call.lua
// Make changes to the generator instead of to this file!
// This file contains the various overloads for the cLuaState::Call() function
// Each overload handles a different number of parameters / return values
]])
f:write("\n\n\n\n\n")
-- Write out a template function for each overload:
for _, combination in ipairs(Combinations) do
WriteOverload(f, combination[1], combination[2])
end
-- Close the generated file
f:close()
print("LuaState_Call.inc generated")

View File

@ -3,6 +3,20 @@ local disable_virtual_hooks = true
local enable_pure_virtual = true
local default_private_access = false
-- Code generators used by the build
-- Note that these are not exactly needed for the bindings, but rather we
-- misuse tolua's Lua engine to process files for us
dofile("gen_LuaState_Call.lua")
local access = {public = 0, protected = 1, private = 2}
function preparse_hook(p)

View File

@ -15,7 +15,7 @@ static struct {
const char * m_String;
} g_BiomeMap[] =
{
{biOcean, "Ocean"} ,
{biOcean, "Ocean"},
{biPlains, "Plains"},
{biDesert, "Desert"},
{biExtremeHills, "ExtremeHills"},

View File

@ -28,10 +28,10 @@ typedef void (CombinatorFunc)(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLE
// This wild construct allows us to pass a function argument and still have it inlined by the compiler :)
/// Merges two blocktypes and blockmetas of the specified sizes and offsets using the specified combinator function
template<bool MetasValid, CombinatorFunc Combinator>
template<bool MetasValid, CombinatorFunc Combinator>
void InternalMergeBlocks(
BLOCKTYPE * a_DstTypes, const BLOCKTYPE * a_SrcTypes,
NIBBLETYPE * a_DstMetas, const NIBBLETYPE * a_SrcMetas,
NIBBLETYPE * a_DstMetas, const NIBBLETYPE * a_SrcMetas,
int a_SizeX, int a_SizeY, int a_SizeZ,
int a_SrcOffX, int a_SrcOffY, int a_SrcOffZ,
int a_DstOffX, int a_DstOffY, int a_DstOffZ,
@ -59,7 +59,7 @@ void InternalMergeBlocks(
}
else
{
BLOCKTYPE FakeDestMeta = 0;
NIBBLETYPE FakeDestMeta = 0;
Combinator(a_DstTypes[DstIdx], a_SrcTypes[SrcIdx], FakeDestMeta, (NIBBLETYPE)0);
}
++DstIdx;
@ -136,7 +136,7 @@ void MergeCombinatorLake(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE
return;
}
// Air is always hollowed out
// Air is always hollowed out
if (a_SrcType == E_BLOCK_AIR)
{
a_DstType = E_BLOCK_AIR;
@ -269,7 +269,7 @@ void MergeCombinatorMask(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// cBlockArea:
cBlockArea::cBlockArea(void) :
@ -781,7 +781,7 @@ void cBlockArea::Fill(int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_Block
void cBlockArea::FillRelCuboid(int a_MinRelX, int a_MaxRelX, int a_MinRelY, int a_MaxRelY, int a_MinRelZ, int a_MaxRelZ,
void cBlockArea::FillRelCuboid(int a_MinRelX, int a_MaxRelX, int a_MinRelY, int a_MaxRelY, int a_MinRelZ, int a_MaxRelZ,
int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta,
NIBBLETYPE a_BlockLight, NIBBLETYPE a_BlockSkyLight
)
@ -1759,7 +1759,7 @@ NIBBLETYPE cBlockArea::GetNibble(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBL
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// cBlockArea::cChunkReader:
cBlockArea::cChunkReader::cChunkReader(cBlockArea & a_Area) :
@ -2226,7 +2226,7 @@ void cBlockArea::MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_Rel
m_Size.x, m_Size.y, m_Size.z
);
return;
} // case msDifference
} // case msDifference
case cBlockArea::msMask:
{

View File

@ -175,7 +175,7 @@ public:
void Fill(int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0, NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f);
/** Fills a cuboid inside the block area with the specified data */
void FillRelCuboid(int a_MinRelX, int a_MaxRelX, int a_MinRelY, int a_MaxRelY, int a_MinRelZ, int a_MaxRelZ,
void FillRelCuboid(int a_MinRelX, int a_MaxRelX, int a_MinRelY, int a_MaxRelY, int a_MinRelZ, int a_MaxRelZ,
int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0,
NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f
);
@ -357,7 +357,7 @@ protected:
/** Sets the specified datatypes at the specified location. */
void RelSetData(
int a_RelX, int a_RelY, int a_RelZ,
int a_RelX, int a_RelY, int a_RelZ,
int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta,
NIBBLETYPE a_BlockLight, NIBBLETYPE a_BlockSkyLight
);

View File

@ -32,7 +32,7 @@ int cBeaconEntity::GetPyramidLevel(void)
}
Area.Read(
m_World,
m_World,
GetPosX() - 4, GetPosX() + 4,
MinY, MaxY,
GetPosZ() - 4, GetPosZ() + 4,

View File

@ -28,24 +28,26 @@ cBlockEntity * cBlockEntity::CreateByBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE
switch (a_BlockType)
{
case E_BLOCK_BEACON: return new cBeaconEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_CHEST: return new cChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_CHEST: return new cChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World, a_BlockType);
case E_BLOCK_COMMAND_BLOCK: return new cCommandBlockEntity(a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_DISPENSER: return new cDispenserEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_DROPPER: return new cDropperEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_ENDER_CHEST: return new cEnderChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_FLOWER_POT: return new cFlowerPotEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_HEAD: return new cMobHeadEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_LIT_FURNACE: return new cFurnaceEntity (a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World);
case E_BLOCK_FURNACE: return new cFurnaceEntity (a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World);
case E_BLOCK_HEAD: return new cMobHeadEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_HOPPER: return new cHopperEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_JUKEBOX: return new cJukeboxEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_LIT_FURNACE: return new cFurnaceEntity (a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World);
case E_BLOCK_SIGN_POST: return new cSignEntity (a_BlockType, a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_TRAPPED_CHEST: return new cChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World, a_BlockType);
case E_BLOCK_WALLSIGN: return new cSignEntity (a_BlockType, a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_NOTE_BLOCK: return new cNoteEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_JUKEBOX: return new cJukeboxEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
}
LOGD("%s: Requesting creation of an unknown block entity - block type %d (%s)",
__FUNCTION__, a_BlockType, ItemTypeToString(a_BlockType).c_str()
);
ASSERT(!"Requesting creation of an unknown block entity");
return NULL;
}

View File

@ -50,7 +50,7 @@ public:
cItems Pickups;
m_Contents.CopyToItems(Pickups);
m_Contents.Clear();
m_World->SpawnItemPickups(Pickups, m_PosX + 0.5, m_PosY + 0.5, m_PosZ + 0.5); // Spawn in centre of block
m_World->SpawnItemPickups(Pickups, m_PosX + 0.5, m_PosY + 0.5, m_PosZ + 0.5); // Spawn in centre of block
}
// tolua_begin

View File

@ -11,8 +11,9 @@
cChestEntity::cChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) :
super(E_BLOCK_CHEST, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, a_World)
cChestEntity::cChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World, BLOCKTYPE a_Type) :
super(a_Type, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, a_World),
m_NumActivePlayers(0)
{
cBlockEntityWindowOwner::SetBlockEntity(this);
}
@ -113,7 +114,7 @@ void cChestEntity::UsedBy(cPlayer * a_Player)
// The few false positives aren't much to worry about
int ChunkX, ChunkZ;
cChunkDef::BlockToChunk(m_PosX, m_PosZ, ChunkX, ChunkZ);
m_World->MarkChunkDirty(ChunkX, ChunkZ);
m_World->MarkChunkDirty(ChunkX, ChunkZ, true);
}
@ -168,15 +169,15 @@ 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
return;
}
// There is no chest neighbor, open a single-chest window:
// There is no chest neighbor, open a single-chest window:
OpenWindow(new cChestWindow(this));
}

View File

@ -34,8 +34,8 @@ public:
// tolua_end
/// Constructor used for normal operation
cChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
/** Constructor used for normal operation */
cChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World, BLOCKTYPE a_Type);
virtual ~cChestEntity();
@ -48,8 +48,20 @@ public:
virtual void SendTo(cClientHandle & a_Client) override;
virtual void UsedBy(cPlayer * a_Player) override;
/// Opens a new chest window for this chest. Scans for neighbors to open a double chest window, if appropriate.
/** Opens a new chest window for this chest.
Scans for neighbors to open a double chest window, if appropriate. */
void OpenNewWindow(void);
/** Gets the number of players who currently have this chest open */
int GetNumberOfPlayers(void) const { return m_NumActivePlayers; }
/** Sets the number of players who currently have this chest open */
void SetNumberOfPlayers(int a_NumActivePlayers) { m_NumActivePlayers = a_NumActivePlayers; }
private:
/** Number of players who currently have this chest open */
int m_NumActivePlayers;
} ; // tolua_export

View File

@ -11,7 +11,7 @@
#include "../CommandOutput.h"
#include "../Root.h"
#include "../Server.h" // ExecuteConsoleCommand()
#include "../Server.h" // ExecuteConsoleCommand()
#include "../Chunk.h"

View File

@ -26,7 +26,7 @@ namespace Json
// tolua_begin
class cCommandBlockEntity :
class cCommandBlockEntity :
public cBlockEntity
{
typedef cBlockEntity super;

View File

@ -42,7 +42,7 @@ cDropSpenserEntity::~cDropSpenserEntity()
void cDropSpenserEntity::AddDropSpenserDir(int & a_BlockX, int & a_BlockY, int & a_BlockZ, NIBBLETYPE a_Direction)
{
switch (a_Direction)
switch (a_Direction & 0x07) // Vanilla uses the 8th bit to determine power state - we don't
{
case E_META_DROPSPENSER_FACING_YM: a_BlockY--; return;
case E_META_DROPSPENSER_FACING_YP: a_BlockY++; return;
@ -90,7 +90,7 @@ void cDropSpenserEntity::DropSpense(cChunk & a_Chunk)
int SmokeDir = 0;
switch (Meta)
{
case E_META_DROPSPENSER_FACING_YP: SmokeDir = 4; break; // YP & YM don't have associated smoke dirs, just do 4 (centre of block)
case E_META_DROPSPENSER_FACING_YP: SmokeDir = 4; break; // YP & YM don't have associated smoke dirs, just do 4 (centre of block)
case E_META_DROPSPENSER_FACING_YM: SmokeDir = 4; break;
case E_META_DROPSPENSER_FACING_XM: SmokeDir = 3; break;
case E_META_DROPSPENSER_FACING_XP: SmokeDir = 5; break;
@ -99,7 +99,7 @@ void cDropSpenserEntity::DropSpense(cChunk & a_Chunk)
}
m_World->BroadcastSoundParticleEffect(2000, m_PosX, m_PosY, m_PosZ, SmokeDir);
m_World->BroadcastSoundEffect("random.click", m_PosX * 8, m_PosY * 8, m_PosZ * 8, 1.0f, 1.0f);
}
}
@ -235,7 +235,7 @@ void cDropSpenserEntity::DropFromSlot(cChunk & a_Chunk, int a_SlotNum)
cItems Pickups;
Pickups.push_back(m_Contents.RemoveOneItem(a_SlotNum));
const int PickupSpeed = m_World->GetTickRandomNumber(4) + 2; // At least 2, at most 6
const int PickupSpeed = m_World->GetTickRandomNumber(4) + 2; // At least 2, at most 6
int PickupSpeedX = 0, PickupSpeedY = 0, PickupSpeedZ = 0;
switch (Meta)
{
@ -249,7 +249,7 @@ void cDropSpenserEntity::DropFromSlot(cChunk & a_Chunk, int a_SlotNum)
double MicroX, MicroY, MicroZ;
MicroX = DispX + 0.5;
MicroY = DispY + 0.4; // Slightly less than half, to accomodate actual texture hole on DropSpenser
MicroY = DispY + 0.4; // Slightly less than half, to accomodate actual texture hole on DropSpenser
MicroZ = DispZ + 0.5;

View File

@ -12,9 +12,8 @@
cEnderChestEntity::cEnderChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) :
super(E_BLOCK_ENDER_CHEST, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, a_World)
super(E_BLOCK_ENDER_CHEST, a_BlockX, a_BlockY, a_BlockZ, a_World)
{
cBlockEntityWindowOwner::SetBlockEntity(this);
}
@ -34,60 +33,6 @@ cEnderChestEntity::~cEnderChestEntity()
bool cEnderChestEntity::LoadFromJson(const Json::Value & a_Value)
{
m_PosX = a_Value.get("x", 0).asInt();
m_PosY = a_Value.get("y", 0).asInt();
m_PosZ = a_Value.get("z", 0).asInt();
Json::Value AllSlots = a_Value.get("Slots", 0);
int SlotIdx = 0;
for (Json::Value::iterator itr = AllSlots.begin(); itr != AllSlots.end(); ++itr)
{
cItem Item;
Item.FromJson(*itr);
SetSlot(SlotIdx, Item);
SlotIdx++;
}
return true;
}
void cEnderChestEntity::SaveToJson(Json::Value & a_Value)
{
a_Value["x"] = m_PosX;
a_Value["y"] = m_PosY;
a_Value["z"] = m_PosZ;
Json::Value AllSlots;
for (int i = m_Contents.GetNumSlots() - 1; i >= 0; i--)
{
Json::Value Slot;
m_Contents.GetSlot(i).GetJson(Slot);
AllSlots.append(Slot);
}
a_Value["Slots"] = AllSlots;
}
void cEnderChestEntity::SendTo(cClientHandle & a_Client)
{
// The chest entity doesn't need anything sent to the client when it's created / gets in the viewdistance
// All the actual handling is in the cWindow UI code that gets called when the chest is rclked
UNUSED(a_Client);
}
void cEnderChestEntity::UsedBy(cPlayer * a_Player)
{
// If the window is not created, open it anew:
@ -106,21 +51,13 @@ void cEnderChestEntity::UsedBy(cPlayer * a_Player)
a_Player->OpenWindow(Window);
}
}
// This is rather a hack
// Instead of marking the chunk as dirty upon chest contents change, we mark it dirty now
// We cannot properly detect contents change, but such a change doesn't happen without a player opening the chest first.
// The few false positives aren't much to worry about
int ChunkX, ChunkZ;
cChunkDef::BlockToChunk(m_PosX, m_PosZ, ChunkX, ChunkZ);
m_World->MarkChunkDirty(ChunkX, ChunkZ);
}
void cEnderChestEntity::OpenNewWindow(void)
void cEnderChestEntity::OpenNewWindow()
{
OpenWindow(new cEnderChestWindow(this));
}
@ -128,3 +65,33 @@ void cEnderChestEntity::OpenNewWindow(void)
void cEnderChestEntity::LoadFromJson(const Json::Value & a_Value, cItemGrid & a_Grid)
{
int SlotIdx = 0;
for (Json::Value::iterator itr = a_Value.begin(); itr != a_Value.end(); ++itr)
{
cItem Item;
Item.FromJson(*itr);
a_Grid.SetSlot(SlotIdx, Item);
SlotIdx++;
}
}
void cEnderChestEntity::SaveToJson(Json::Value & a_Value, const cItemGrid & a_Grid)
{
for (int i = 0; i < a_Grid.GetNumSlots(); i++)
{
Json::Value Slot;
a_Grid.GetSlot(i).GetJson(Slot);
a_Value.append(Slot);
}
}

View File

@ -1,20 +1,9 @@
#pragma once
#include "BlockEntityWithItems.h"
namespace Json
{
class Value;
};
class cClientHandle;
class cServer;
class cNBTData;
#include "BlockEntity.h"
#include "UI/WindowOwner.h"
#include "json/json.h"
@ -22,33 +11,28 @@ class cNBTData;
// tolua_begin
class cEnderChestEntity :
public cBlockEntityWithItems
public cBlockEntity,
public cBlockEntityWindowOwner
{
typedef cBlockEntityWithItems super;
typedef cBlockEntity super;
public:
enum {
ContentsHeight = 3,
ContentsWidth = 9,
} ;
// tolua_end
/// Constructor used for normal operation
cEnderChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
virtual ~cEnderChestEntity();
static const char * GetClassStatic(void) { return "cEnderChestEntity"; }
bool LoadFromJson(const Json::Value & a_Value);
// cBlockEntity overrides:
virtual void SaveToJson(Json::Value & a_Value) override;
virtual void SendTo(cClientHandle & a_Client) override;
virtual void UsedBy(cPlayer * a_Player) override;
virtual void SaveToJson(Json::Value & a_Value) override { UNUSED(a_Value); }
virtual void SendTo(cClientHandle & a_Client) override { UNUSED(a_Client); }
static void LoadFromJson(const Json::Value & a_Value, cItemGrid & a_Grid);
static void SaveToJson(Json::Value & a_Value, const cItemGrid & a_Grid);
/// Opens a new chest window for this chest. Scans for neighbors to open a double chest window, if appropriate.
/** Opens a new enderchest window for this enderchest */
void OpenNewWindow(void);
} ; // tolua_export

View File

@ -27,7 +27,7 @@ namespace Json
// tolua_begin
class cFlowerPotEntity :
class cFlowerPotEntity :
public cBlockEntity
{
typedef cBlockEntity super;
@ -53,7 +53,7 @@ public:
cItem GetItem(void) const { return m_Item; }
/** Set the item in the flower pot */
void SetItem(const cItem a_Item) { m_Item = a_Item; }
void SetItem(const cItem & a_Item) { m_Item = a_Item; }
// tolua_end

View File

@ -157,6 +157,7 @@ bool cHopperEntity::MoveItemsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
bool res = false;
switch (a_Chunk.GetBlock(m_RelX, m_PosY + 1, m_RelZ))
{
case E_BLOCK_TRAPPED_CHEST:
case E_BLOCK_CHEST:
{
// Chests have special handling because of double-chests
@ -218,7 +219,7 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
}
Vector3f EntityPos = a_Entity->GetPosition();
Vector3f BlockPos(m_Pos.x + 0.5f, (float)m_Pos.y + 1, m_Pos.z + 0.5f); // One block above hopper, and search from center outwards
Vector3f BlockPos(m_Pos.x + 0.5f, (float)m_Pos.y + 1, m_Pos.z + 0.5f); // One block above hopper, and search from center outwards
double Distance = (EntityPos - BlockPos).Length();
if (Distance < 0.5)
@ -242,7 +243,7 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
{
m_bFoundPickupsAbove = true;
m_Contents.SetSlot(i, Item);
a_Pickup->Destroy(); // Kill pickup
a_Pickup->Destroy(); // Kill pickup
return true;
}
@ -252,11 +253,11 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
int PreviousCount = m_Contents.GetSlot(i).m_ItemCount;
Item.m_ItemCount -= m_Contents.ChangeSlotCount(i, Item.m_ItemCount) - PreviousCount; // Set count to however many items were added
Item.m_ItemCount -= m_Contents.ChangeSlotCount(i, Item.m_ItemCount) - PreviousCount; // Set count to however many items were added
if (Item.IsEmpty())
{
a_Pickup->Destroy(); // Kill pickup if all items were added
a_Pickup->Destroy(); // Kill pickup if all items were added
}
return true;
}
@ -322,6 +323,7 @@ bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick)
bool res = false;
switch (DestChunk->GetBlock(OutRelX, OutY, OutRelZ))
{
case E_BLOCK_TRAPPED_CHEST:
case E_BLOCK_CHEST:
{
// Chests have special handling because of double-chests
@ -366,19 +368,19 @@ bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick)
/// Moves items from a chest (dblchest) above the hopper into this hopper. Returns true if contents have changed.
bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk)
{
cChestEntity * Chest = (cChestEntity *)a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ);
if (Chest == NULL)
cChestEntity * MainChest = (cChestEntity *)a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ);
if (MainChest == NULL)
{
LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, m_PosX, m_PosY + 1, m_PosZ);
return false;
}
if (MoveItemsFromGrid(*Chest))
if (MoveItemsFromGrid(*MainChest))
{
// Moved the item from the chest directly above the hopper
return true;
}
// Check if the chest is a double-chest, if so, try to move from there:
// Check if the chest is a double-chest (chest directly above was empty), if so, try to move from there:
static const struct
{
int x, z;
@ -395,21 +397,26 @@ bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk)
int x = m_RelX + Coords[i].x;
int z = m_RelZ + Coords[i].z;
cChunk * Neighbor = a_Chunk.GetRelNeighborChunkAdjustCoords(x, z);
if (
(Neighbor == NULL) ||
(Neighbor->GetBlock(x, m_PosY + 1, z) != E_BLOCK_CHEST)
)
if (Neighbor == NULL)
{
continue;
}
Chest = (cChestEntity *)Neighbor->GetBlockEntity(m_PosX + Coords[i].x, m_PosY + 1, m_PosZ + Coords[i].z);
if (Chest == NULL)
BLOCKTYPE Block = Neighbor->GetBlock(x, m_PosY + 1, z);
if (Block != MainChest->GetBlockType())
{
// Not the same kind of chest
continue;
}
cChestEntity * SideChest = (cChestEntity *)Neighbor->GetBlockEntity(m_PosX + Coords[i].x, m_PosY + 1, m_PosZ + Coords[i].z);
if (SideChest == NULL)
{
LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, m_PosX + Coords[i].x, m_PosY + 1, m_PosZ + Coords[i].z);
}
else
{
if (MoveItemsFromGrid(*Chest))
if (MoveItemsFromGrid(*SideChest))
{
return true;
}
@ -550,10 +557,11 @@ bool cHopperEntity::MoveItemsToChest(cChunk & a_Chunk, int a_BlockX, int a_Block
}
if (MoveItemsToGrid(*Chest))
{
// Chest block directly connected was not full
return true;
}
// Check if the chest is a double-chest, if so, try to move into the other half:
// Check if the chest is a double-chest (chest block directly connected was full), if so, try to move into the other half:
static const struct
{
int x, z;
@ -572,13 +580,18 @@ bool cHopperEntity::MoveItemsToChest(cChunk & a_Chunk, int a_BlockX, int a_Block
int x = RelX + Coords[i].x;
int z = RelZ + Coords[i].z;
cChunk * Neighbor = a_Chunk.GetRelNeighborChunkAdjustCoords(x, z);
if (
(Neighbor == NULL) ||
(Neighbor->GetBlock(x, a_BlockY, z) != E_BLOCK_CHEST)
)
if (Neighbor == NULL)
{
continue;
}
BLOCKTYPE Block = Neighbor->GetBlock(x, a_BlockY, z);
if (Block != Chest->GetBlockType())
{
// Not the same kind of chest
continue;
}
Chest = (cChestEntity *)Neighbor->GetBlockEntity(a_BlockX + Coords[i].x, a_BlockY, a_BlockZ + Coords[i].z);
if (Chest == NULL)
{

View File

@ -19,7 +19,7 @@ namespace Json
// tolua_begin
class cJukeboxEntity :
class cJukeboxEntity :
public cBlockEntity
{
typedef cBlockEntity super;

View File

@ -25,7 +25,7 @@ namespace Json
// tolua_begin
class cMobHeadEntity :
class cMobHeadEntity :
public cBlockEntity
{
typedef cBlockEntity super;

View File

@ -91,7 +91,7 @@ void cNoteEntity::MakeSound(void)
// TODO: instead of calculating the power function over and over, make a precalculated table - there's only 24 pitches after all
float calcPitch = pow(2.0f, ((float)m_Pitch - 12.0f) / 12.0f);
m_World->BroadcastSoundEffect(sampleName, m_PosX * 8, m_PosY * 8, m_PosZ * 8, 3.0f, calcPitch);
m_World->BroadcastSoundEffect(sampleName, (double)m_PosX, (double)m_PosY, (double)m_PosZ, 3.0f, calcPitch);
}

View File

@ -28,7 +28,7 @@ enum ENUM_NOTE_INSTRUMENTS
// tolua_begin
class cNoteEntity :
class cNoteEntity :
public cBlockEntity
{
typedef cBlockEntity super;

View File

@ -25,7 +25,7 @@ namespace Json
// tolua_begin
class cSignEntity :
class cSignEntity :
public cBlockEntity
{
typedef cBlockEntity super;

View File

@ -286,7 +286,7 @@ int StringToMobType(const AString & a_MobString)
{cMonster::mtMooshroom, "Mooshroom"},
{cMonster::mtSnowGolem, "SnowGolem"},
{cMonster::mtOcelot, "Ocelot"},
{cMonster::mtIronGolem, "IronGolem"},
{cMonster::mtIronGolem, "IronGolem"},
{cMonster::mtVillager, "Villager"},
};
for (size_t i = 0; i < ARRAYCOUNT(MobMap); i++)
@ -394,6 +394,7 @@ AString DamageTypeToString(eDamageType a_DamageType)
case dtLightning: return "dtLightning";
case dtOnFire: return "dtOnFire";
case dtPoisoning: return "dtPoisoning";
case dtWithering: return "dtWithering";
case dtPotionOfHarming: return "dtPotionOfHarming";
case dtRangedAttack: return "dtRangedAttack";
case dtStarving: return "dtStarving";
@ -439,6 +440,7 @@ eDamageType StringToDamageType(const AString & a_DamageTypeString)
{ dtCactusContact, "dtCactusContact"},
{ dtLavaContact, "dtLavaContact"},
{ dtPoisoning, "dtPoisoning"},
{ dtWithering, "dtWithering"},
{ dtOnFire, "dtOnFire"},
{ dtFireContact, "dtFireContact"},
{ dtInVoid, "dtInVoid"},
@ -464,6 +466,7 @@ eDamageType StringToDamageType(const AString & a_DamageTypeString)
{ dtCactusContact, "dtCacti"},
{ dtLavaContact, "dtLava"},
{ dtPoisoning, "dtPoison"},
{ dtWithering, "dtWither"},
{ dtOnFire, "dtBurning"},
{ dtFireContact, "dtInFire"},
{ dtAdmin, "dtPlugin"},

View File

@ -171,12 +171,12 @@ enum ENUM_BLOCK_ID
E_BLOCK_DROPPER = 158,
E_BLOCK_STAINED_CLAY = 159,
E_BLOCK_STAINED_GLASS_PANE = 160,
E_BLOCK_NEW_LEAVES = 161, // Acacia and Dark Oak IDs in Minecraft 1.7.x
E_BLOCK_NEW_LEAVES = 161, // Acacia and Dark Oak IDs in Minecraft 1.7.x
E_BLOCK_NEW_LOG = 162,
E_BLOCK_ACACIA_WOOD_STAIRS = 163,
E_BLOCK_DARK_OAK_WOOD_STAIRS = 164,
E_BLOCK_HAY_BALE = 170,
E_BLOCK_CARPET = 171,
E_BLOCK_CARPET = 171,
E_BLOCK_HARDENED_CLAY = 172,
E_BLOCK_BLOCK_OF_COAL = 173,
E_BLOCK_PACKED_ICE = 174,
@ -187,7 +187,7 @@ enum ENUM_BLOCK_ID
E_BLOCK_NUMBER_OF_TYPES, ///< Number of individual (different) blocktypes
E_BLOCK_MAX_TYPE_ID = E_BLOCK_NUMBER_OF_TYPES - 1, ///< Maximum BlockType number used
// Synonym or ID compatibility
// Synonym or ID compatibility
E_BLOCK_YELLOW_FLOWER = E_BLOCK_DANDELION,
E_BLOCK_RED_ROSE = E_BLOCK_FLOWER,
E_BLOCK_LOCKED_CHEST = E_BLOCK_STAINED_GLASS,
@ -319,7 +319,8 @@ enum ENUM_ITEM_ID
E_ITEM_GHAST_TEAR = 370,
E_ITEM_GOLD_NUGGET = 371,
E_ITEM_NETHER_WART = 372,
E_ITEM_POTIONS = 373,
E_ITEM_POTION = 373,
E_ITEM_POTIONS = 373, // OBSOLETE, use E_ITEM_POTION instead
E_ITEM_GLASS_BOTTLE = 374,
E_ITEM_SPIDER_EYE = 375,
E_ITEM_FERMENTED_SPIDER_EYE = 376,
@ -398,7 +399,7 @@ enum
// Please keep this list alpha-sorted by the blocktype / itemtype part
// then number-sorted for the same block / item
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Block metas:
// E_BLOCK_BIG_FLOWER metas
@ -677,7 +678,7 @@ enum
E_META_WOOL_RED = 14,
E_META_WOOL_BLACK = 15,
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Item metas:
// E_ITEM_COAL metas:
@ -811,6 +812,7 @@ enum eDamageType
dtCactusContact, // Contact with a cactus block
dtLavaContact, // Contact with a lava block
dtPoisoning, // Having the poison effect
dtWithering, // Having the wither effect
dtOnFire, // Being on fire
dtFireContact, // Standing inside a fire block
dtInVoid, // Falling into the Void (Y < 0)
@ -837,6 +839,7 @@ enum eDamageType
dtCacti = dtCactusContact,
dtLava = dtLavaContact,
dtPoison = dtPoisoning,
dtWither = dtWithering,
dtBurning = dtOnFire,
dtInFire = dtFireContact,
dtPlugin = dtAdmin,

View File

@ -8,20 +8,13 @@
cBlockInfo cBlockInfo::ms_Info[256];
static bool g_IsBlockInfoInitialized = false;
cBlockInfo::cBlockInfo()
: m_LightValue(0x00)
, m_SpreadLightFalloff(0x0f)
, m_Transparent(false)
, m_OneHitDig(false)
, m_PistonBreakable(false)
, m_IsSnowable(true)
, m_IsSnowable(false)
, m_RequiresSpecialTool(false)
, m_IsSolid(true)
, m_FullyOccupiesVoxel(false)
@ -42,12 +35,17 @@ cBlockInfo::~cBlockInfo()
/** This accessor makes sure that the cBlockInfo structures are properly initialized exactly once.
It does so by using the C++ singleton approximation - storing the actual singleton as the function's static variable.
It works only if it is called for the first time before the app spawns other threads. */
cBlockInfo & cBlockInfo::Get(BLOCKTYPE a_Type)
{
if (!g_IsBlockInfoInitialized)
static cBlockInfo ms_Info[256];
static bool IsBlockInfoInitialized = false;
if (!IsBlockInfoInitialized)
{
cBlockInfo::Initialize();
g_IsBlockInfoInitialized = true;
cBlockInfo::Initialize(ms_Info);
IsBlockInfoInitialized = true;
}
return ms_Info[a_Type];
}
@ -56,399 +54,545 @@ cBlockInfo & cBlockInfo::Get(BLOCKTYPE a_Type)
void cBlockInfo::Initialize(void)
void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
{
for (unsigned int i = 0; i < 256; ++i)
{
if (ms_Info[i].m_Handler == NULL)
if (a_Info[i].m_Handler == NULL)
{
ms_Info[i].m_Handler = cBlockHandler::CreateBlockHandler((BLOCKTYPE) i);
a_Info[i].m_Handler = cBlockHandler::CreateBlockHandler((BLOCKTYPE) i);
}
}
// Emissive blocks
ms_Info[E_BLOCK_FIRE ].m_LightValue = 15;
ms_Info[E_BLOCK_GLOWSTONE ].m_LightValue = 15;
ms_Info[E_BLOCK_JACK_O_LANTERN ].m_LightValue = 15;
ms_Info[E_BLOCK_LAVA ].m_LightValue = 15;
ms_Info[E_BLOCK_STATIONARY_LAVA ].m_LightValue = 15;
ms_Info[E_BLOCK_END_PORTAL ].m_LightValue = 15;
ms_Info[E_BLOCK_REDSTONE_LAMP_ON ].m_LightValue = 15;
ms_Info[E_BLOCK_TORCH ].m_LightValue = 14;
ms_Info[E_BLOCK_BURNING_FURNACE ].m_LightValue = 13;
ms_Info[E_BLOCK_NETHER_PORTAL ].m_LightValue = 11;
ms_Info[E_BLOCK_REDSTONE_ORE_GLOWING].m_LightValue = 9;
ms_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_LightValue = 9;
ms_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_LightValue = 7;
ms_Info[E_BLOCK_BREWING_STAND ].m_LightValue = 1;
ms_Info[E_BLOCK_BROWN_MUSHROOM ].m_LightValue = 1;
ms_Info[E_BLOCK_DRAGON_EGG ].m_LightValue = 1;
a_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_LightValue = 9;
a_Info[E_BLOCK_BEACON ].m_LightValue = 15;
a_Info[E_BLOCK_BREWING_STAND ].m_LightValue = 1;
a_Info[E_BLOCK_BROWN_MUSHROOM ].m_LightValue = 1;
a_Info[E_BLOCK_BURNING_FURNACE ].m_LightValue = 13;
a_Info[E_BLOCK_DRAGON_EGG ].m_LightValue = 1;
a_Info[E_BLOCK_END_PORTAL ].m_LightValue = 15;
a_Info[E_BLOCK_END_PORTAL_FRAME ].m_LightValue = 1;
a_Info[E_BLOCK_ENDER_CHEST ].m_LightValue = 7;
a_Info[E_BLOCK_FIRE ].m_LightValue = 15;
a_Info[E_BLOCK_GLOWSTONE ].m_LightValue = 15;
a_Info[E_BLOCK_JACK_O_LANTERN ].m_LightValue = 15;
a_Info[E_BLOCK_LAVA ].m_LightValue = 15;
a_Info[E_BLOCK_NETHER_PORTAL ].m_LightValue = 11;
a_Info[E_BLOCK_REDSTONE_LAMP_ON ].m_LightValue = 15;
a_Info[E_BLOCK_REDSTONE_ORE_GLOWING].m_LightValue = 9;
a_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_LightValue = 9;
a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_LightValue = 7;
a_Info[E_BLOCK_STATIONARY_LAVA ].m_LightValue = 15;
a_Info[E_BLOCK_TORCH ].m_LightValue = 14;
// Spread blocks
ms_Info[E_BLOCK_AIR ].m_SpreadLightFalloff = 1;
ms_Info[E_BLOCK_CAKE ].m_SpreadLightFalloff = 1;
ms_Info[E_BLOCK_CHEST ].m_SpreadLightFalloff = 1;
ms_Info[E_BLOCK_COBWEB ].m_SpreadLightFalloff = 1;
ms_Info[E_BLOCK_CROPS ].m_SpreadLightFalloff = 1;
ms_Info[E_BLOCK_FENCE ].m_SpreadLightFalloff = 1;
ms_Info[E_BLOCK_FENCE_GATE ].m_SpreadLightFalloff = 1;
ms_Info[E_BLOCK_FIRE ].m_SpreadLightFalloff = 1;
ms_Info[E_BLOCK_GLASS ].m_SpreadLightFalloff = 1;
ms_Info[E_BLOCK_GLASS_PANE ].m_SpreadLightFalloff = 1;
ms_Info[E_BLOCK_GLOWSTONE ].m_SpreadLightFalloff = 1;
ms_Info[E_BLOCK_IRON_BARS ].m_SpreadLightFalloff = 1;
ms_Info[E_BLOCK_IRON_DOOR ].m_SpreadLightFalloff = 1;
ms_Info[E_BLOCK_LEAVES ].m_SpreadLightFalloff = 1;
ms_Info[E_BLOCK_NEW_LEAVES ].m_SpreadLightFalloff = 1;
ms_Info[E_BLOCK_SIGN_POST ].m_SpreadLightFalloff = 1;
ms_Info[E_BLOCK_TORCH ].m_SpreadLightFalloff = 1;
ms_Info[E_BLOCK_VINES ].m_SpreadLightFalloff = 1;
ms_Info[E_BLOCK_WALLSIGN ].m_SpreadLightFalloff = 1;
ms_Info[E_BLOCK_WOODEN_DOOR ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_ACTIVATOR_RAIL ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_AIR ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_ANVIL ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_BEACON ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_BED ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_BIG_FLOWER ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_BROWN_MUSHROOM ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_BREWING_STAND ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_CACTUS ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_CAKE ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_CARPET ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_CARROTS ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_CAULDRON ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_CHEST ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_COBBLESTONE_WALL ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_COCOA_POD ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_COBWEB ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_CROPS ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_DANDELION ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_DAYLIGHT_SENSOR ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_DEAD_BUSH ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_DETECTOR_RAIL ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_DRAGON_EGG ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_ENCHANTMENT_TABLE ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_ENDER_CHEST ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_END_PORTAL ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_END_PORTAL_FRAME ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_FARMLAND ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_FENCE ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_FENCE_GATE ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_FIRE ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_FLOWER ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_FLOWER_POT ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_GLASS ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_GLASS_PANE ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_HEAD ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_HOPPER ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_ICE ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_IRON_BARS ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_IRON_DOOR ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_LADDER ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_LEAVES ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_LEVER ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_LILY_PAD ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_MELON_STEM ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_MOB_SPAWNER ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_NETHER_PORTAL ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_NETHER_WART ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_NEW_LEAVES ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_PISTON ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_PISTON_EXTENSION ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_PISTON_MOVED_BLOCK ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_POTATOES ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_POWERED_RAIL ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_PUMPKIN_STEM ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_RAIL ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_RED_MUSHROOM ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_REDSTONE_WIRE ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_SAPLING ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_SIGN_POST ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_SNOW ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_STAINED_GLASS ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_STAINED_GLASS_PANE ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_STICKY_PISTON ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_STONE_BUTTON ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_STONE_SLAB ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_SUGARCANE ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_TALL_GRASS ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_TORCH ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_TRAPDOOR ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_TRAPPED_CHEST ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_TRIPWIRE ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_TRIPWIRE_HOOK ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_VINES ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_WALLSIGN ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_WOODEN_BUTTON ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_WOODEN_DOOR ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_WOODEN_SLAB ].m_SpreadLightFalloff = 1;
// Light in water and lava dissapears faster:
ms_Info[E_BLOCK_LAVA ].m_SpreadLightFalloff = 3;
ms_Info[E_BLOCK_STATIONARY_LAVA ].m_SpreadLightFalloff = 3;
ms_Info[E_BLOCK_STATIONARY_WATER ].m_SpreadLightFalloff = 3;
ms_Info[E_BLOCK_WATER ].m_SpreadLightFalloff = 3;
a_Info[E_BLOCK_LAVA ].m_SpreadLightFalloff = 3;
a_Info[E_BLOCK_STATIONARY_LAVA ].m_SpreadLightFalloff = 3;
a_Info[E_BLOCK_STATIONARY_WATER ].m_SpreadLightFalloff = 3;
a_Info[E_BLOCK_WATER ].m_SpreadLightFalloff = 3;
// Transparent blocks
ms_Info[E_BLOCK_ACTIVATOR_RAIL ].m_Transparent = true;
ms_Info[E_BLOCK_AIR ].m_Transparent = true;
ms_Info[E_BLOCK_ANVIL ].m_Transparent = true;
ms_Info[E_BLOCK_BIG_FLOWER ].m_Transparent = true;
ms_Info[E_BLOCK_BROWN_MUSHROOM ].m_Transparent = true;
ms_Info[E_BLOCK_CAKE ].m_Transparent = true;
ms_Info[E_BLOCK_CARROTS ].m_Transparent = true;
ms_Info[E_BLOCK_CHEST ].m_Transparent = true;
ms_Info[E_BLOCK_COBBLESTONE_WALL ].m_Transparent = true;
ms_Info[E_BLOCK_COBWEB ].m_Transparent = true;
ms_Info[E_BLOCK_CROPS ].m_Transparent = true;
ms_Info[E_BLOCK_DANDELION ].m_Transparent = true;
ms_Info[E_BLOCK_DETECTOR_RAIL ].m_Transparent = true;
ms_Info[E_BLOCK_ENDER_CHEST ].m_Transparent = true;
ms_Info[E_BLOCK_FENCE ].m_Transparent = true;
ms_Info[E_BLOCK_FENCE_GATE ].m_Transparent = true;
ms_Info[E_BLOCK_FIRE ].m_Transparent = true;
ms_Info[E_BLOCK_FLOWER ].m_Transparent = true;
ms_Info[E_BLOCK_FLOWER_POT ].m_Transparent = true;
ms_Info[E_BLOCK_GLASS ].m_Transparent = true;
ms_Info[E_BLOCK_GLASS_PANE ].m_Transparent = true;
ms_Info[E_BLOCK_HEAD ].m_Transparent = true;
ms_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_Transparent = true;
ms_Info[E_BLOCK_ICE ].m_Transparent = true;
ms_Info[E_BLOCK_IRON_DOOR ].m_Transparent = true;
ms_Info[E_BLOCK_LADDER ].m_Transparent = true;
ms_Info[E_BLOCK_LAVA ].m_Transparent = true;
ms_Info[E_BLOCK_LEAVES ].m_Transparent = true;
ms_Info[E_BLOCK_LEVER ].m_Transparent = true;
ms_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_Transparent = true;
ms_Info[E_BLOCK_MELON_STEM ].m_Transparent = true;
ms_Info[E_BLOCK_NETHER_BRICK_FENCE ].m_Transparent = true;
ms_Info[E_BLOCK_NEW_LEAVES ].m_Transparent = true;
ms_Info[E_BLOCK_POTATOES ].m_Transparent = true;
ms_Info[E_BLOCK_POWERED_RAIL ].m_Transparent = true;
ms_Info[E_BLOCK_PISTON_EXTENSION ].m_Transparent = true;
ms_Info[E_BLOCK_PUMPKIN_STEM ].m_Transparent = true;
ms_Info[E_BLOCK_RAIL ].m_Transparent = true;
ms_Info[E_BLOCK_RED_MUSHROOM ].m_Transparent = true;
ms_Info[E_BLOCK_SIGN_POST ].m_Transparent = true;
ms_Info[E_BLOCK_SNOW ].m_Transparent = true;
ms_Info[E_BLOCK_STAINED_GLASS ].m_Transparent = true;
ms_Info[E_BLOCK_STAINED_GLASS_PANE ].m_Transparent = true;
ms_Info[E_BLOCK_STATIONARY_LAVA ].m_Transparent = true;
ms_Info[E_BLOCK_STATIONARY_WATER ].m_Transparent = true;
ms_Info[E_BLOCK_STONE_BUTTON ].m_Transparent = true;
ms_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_Transparent = true;
ms_Info[E_BLOCK_TALL_GRASS ].m_Transparent = true;
ms_Info[E_BLOCK_TORCH ].m_Transparent = true;
ms_Info[E_BLOCK_VINES ].m_Transparent = true;
ms_Info[E_BLOCK_WALLSIGN ].m_Transparent = true;
ms_Info[E_BLOCK_WATER ].m_Transparent = true;
ms_Info[E_BLOCK_WOODEN_BUTTON ].m_Transparent = true;
ms_Info[E_BLOCK_WOODEN_DOOR ].m_Transparent = true;
ms_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_Transparent = true;
// TODO: Any other transparent blocks?
a_Info[E_BLOCK_ACTIVATOR_RAIL ].m_Transparent = true;
a_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_Transparent = true;
a_Info[E_BLOCK_AIR ].m_Transparent = true;
a_Info[E_BLOCK_ANVIL ].m_Transparent = true;
a_Info[E_BLOCK_BEACON ].m_Transparent = true;
a_Info[E_BLOCK_BED ].m_Transparent = true;
a_Info[E_BLOCK_BIG_FLOWER ].m_Transparent = true;
a_Info[E_BLOCK_BROWN_MUSHROOM ].m_Transparent = true;
a_Info[E_BLOCK_BREWING_STAND ].m_Transparent = true;
a_Info[E_BLOCK_CACTUS ].m_Transparent = true;
a_Info[E_BLOCK_CAKE ].m_Transparent = true;
a_Info[E_BLOCK_CARPET ].m_Transparent = true;
a_Info[E_BLOCK_CARROTS ].m_Transparent = true;
a_Info[E_BLOCK_CAULDRON ].m_Transparent = true;
a_Info[E_BLOCK_CHEST ].m_Transparent = true;
a_Info[E_BLOCK_COBBLESTONE_WALL ].m_Transparent = true;
a_Info[E_BLOCK_COCOA_POD ].m_Transparent = true;
a_Info[E_BLOCK_COBWEB ].m_Transparent = true;
a_Info[E_BLOCK_CROPS ].m_Transparent = true;
a_Info[E_BLOCK_DANDELION ].m_Transparent = true;
a_Info[E_BLOCK_DAYLIGHT_SENSOR ].m_Transparent = true;
a_Info[E_BLOCK_DEAD_BUSH ].m_Transparent = true;
a_Info[E_BLOCK_DETECTOR_RAIL ].m_Transparent = true;
a_Info[E_BLOCK_DRAGON_EGG ].m_Transparent = true;
a_Info[E_BLOCK_ENCHANTMENT_TABLE ].m_Transparent = true;
a_Info[E_BLOCK_ENDER_CHEST ].m_Transparent = true;
a_Info[E_BLOCK_END_PORTAL ].m_Transparent = true;
a_Info[E_BLOCK_END_PORTAL_FRAME ].m_Transparent = true;
a_Info[E_BLOCK_FARMLAND ].m_Transparent = true;
a_Info[E_BLOCK_FENCE ].m_Transparent = true;
a_Info[E_BLOCK_FENCE_GATE ].m_Transparent = true;
a_Info[E_BLOCK_FIRE ].m_Transparent = true;
a_Info[E_BLOCK_FLOWER ].m_Transparent = true;
a_Info[E_BLOCK_FLOWER_POT ].m_Transparent = true;
a_Info[E_BLOCK_GLASS ].m_Transparent = true;
a_Info[E_BLOCK_GLASS_PANE ].m_Transparent = true;
a_Info[E_BLOCK_HEAD ].m_Transparent = true;
a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_Transparent = true;
a_Info[E_BLOCK_HOPPER ].m_Transparent = true;
a_Info[E_BLOCK_ICE ].m_Transparent = true;
a_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_Transparent = true;
a_Info[E_BLOCK_IRON_BARS ].m_Transparent = true;
a_Info[E_BLOCK_IRON_DOOR ].m_Transparent = true;
a_Info[E_BLOCK_LADDER ].m_Transparent = true;
a_Info[E_BLOCK_LAVA ].m_Transparent = true;
a_Info[E_BLOCK_LEAVES ].m_Transparent = true;
a_Info[E_BLOCK_LEVER ].m_Transparent = true;
a_Info[E_BLOCK_LILY_PAD ].m_Transparent = true;
a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_Transparent = true;
a_Info[E_BLOCK_MELON_STEM ].m_Transparent = true;
a_Info[E_BLOCK_MOB_SPAWNER ].m_Transparent = true;
a_Info[E_BLOCK_NETHER_BRICK_FENCE ].m_Transparent = true;
a_Info[E_BLOCK_NETHER_PORTAL ].m_Transparent = true;
a_Info[E_BLOCK_NETHER_WART ].m_Transparent = true;
a_Info[E_BLOCK_NEW_LEAVES ].m_Transparent = true;
a_Info[E_BLOCK_PISTON ].m_Transparent = true;
a_Info[E_BLOCK_PISTON_EXTENSION ].m_Transparent = true;
a_Info[E_BLOCK_PISTON_MOVED_BLOCK ].m_Transparent = true;
a_Info[E_BLOCK_POTATOES ].m_Transparent = true;
a_Info[E_BLOCK_POWERED_RAIL ].m_Transparent = true;
a_Info[E_BLOCK_PUMPKIN_STEM ].m_Transparent = true;
a_Info[E_BLOCK_RAIL ].m_Transparent = true;
a_Info[E_BLOCK_RED_MUSHROOM ].m_Transparent = true;
a_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_Transparent = true;
a_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_Transparent = true;
a_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_Transparent = true;
a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_Transparent = true;
a_Info[E_BLOCK_REDSTONE_WIRE ].m_Transparent = true;
a_Info[E_BLOCK_SAPLING ].m_Transparent = true;
a_Info[E_BLOCK_SIGN_POST ].m_Transparent = true;
a_Info[E_BLOCK_SNOW ].m_Transparent = true;
a_Info[E_BLOCK_STAINED_GLASS ].m_Transparent = true;
a_Info[E_BLOCK_STAINED_GLASS_PANE ].m_Transparent = true;
a_Info[E_BLOCK_STATIONARY_LAVA ].m_Transparent = true;
a_Info[E_BLOCK_STATIONARY_WATER ].m_Transparent = true;
a_Info[E_BLOCK_STICKY_PISTON ].m_Transparent = true;
a_Info[E_BLOCK_STONE_BUTTON ].m_Transparent = true;
a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_Transparent = true;
a_Info[E_BLOCK_STONE_SLAB ].m_Transparent = true;
a_Info[E_BLOCK_SUGARCANE ].m_Transparent = true;
a_Info[E_BLOCK_TALL_GRASS ].m_Transparent = true;
a_Info[E_BLOCK_TORCH ].m_Transparent = true;
a_Info[E_BLOCK_TRAPDOOR ].m_Transparent = true;
a_Info[E_BLOCK_TRAPPED_CHEST ].m_Transparent = true;
a_Info[E_BLOCK_TRIPWIRE ].m_Transparent = true;
a_Info[E_BLOCK_TRIPWIRE_HOOK ].m_Transparent = true;
a_Info[E_BLOCK_VINES ].m_Transparent = true;
a_Info[E_BLOCK_WALLSIGN ].m_Transparent = true;
a_Info[E_BLOCK_WATER ].m_Transparent = true;
a_Info[E_BLOCK_WOODEN_BUTTON ].m_Transparent = true;
a_Info[E_BLOCK_WOODEN_DOOR ].m_Transparent = true;
a_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_Transparent = true;
a_Info[E_BLOCK_WOODEN_SLAB ].m_Transparent = true;
// One hit break blocks:
ms_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_OneHitDig = true;
ms_Info[E_BLOCK_BIG_FLOWER ].m_OneHitDig = true;
ms_Info[E_BLOCK_BROWN_MUSHROOM ].m_OneHitDig = true;
ms_Info[E_BLOCK_CARROTS ].m_OneHitDig = true;
ms_Info[E_BLOCK_CROPS ].m_OneHitDig = true;
ms_Info[E_BLOCK_DANDELION ].m_OneHitDig = true;
ms_Info[E_BLOCK_FIRE ].m_OneHitDig = true;
ms_Info[E_BLOCK_FLOWER ].m_OneHitDig = true;
ms_Info[E_BLOCK_FLOWER_POT ].m_OneHitDig = true;
ms_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_OneHitDig = true;
ms_Info[E_BLOCK_MELON_STEM ].m_OneHitDig = true;
ms_Info[E_BLOCK_POTATOES ].m_OneHitDig = true;
ms_Info[E_BLOCK_PUMPKIN_STEM ].m_OneHitDig = true;
ms_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_OneHitDig = true;
ms_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_OneHitDig = true;
ms_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_OneHitDig = true;
ms_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_OneHitDig = true;
ms_Info[E_BLOCK_REDSTONE_WIRE ].m_OneHitDig = true;
ms_Info[E_BLOCK_RED_MUSHROOM ].m_OneHitDig = true;
ms_Info[E_BLOCK_REEDS ].m_OneHitDig = true;
ms_Info[E_BLOCK_SAPLING ].m_OneHitDig = true;
ms_Info[E_BLOCK_TNT ].m_OneHitDig = true;
ms_Info[E_BLOCK_TALL_GRASS ].m_OneHitDig = true;
ms_Info[E_BLOCK_TORCH ].m_OneHitDig = true;
a_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_OneHitDig = true;
a_Info[E_BLOCK_BIG_FLOWER ].m_OneHitDig = true;
a_Info[E_BLOCK_BROWN_MUSHROOM ].m_OneHitDig = true;
a_Info[E_BLOCK_CARROTS ].m_OneHitDig = true;
a_Info[E_BLOCK_CROPS ].m_OneHitDig = true;
a_Info[E_BLOCK_DANDELION ].m_OneHitDig = true;
a_Info[E_BLOCK_DEAD_BUSH ].m_OneHitDig = true;
a_Info[E_BLOCK_FIRE ].m_OneHitDig = true;
a_Info[E_BLOCK_FLOWER ].m_OneHitDig = true;
a_Info[E_BLOCK_FLOWER_POT ].m_OneHitDig = true;
a_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_OneHitDig = true;
a_Info[E_BLOCK_LILY_PAD ].m_OneHitDig = true;
a_Info[E_BLOCK_MELON_STEM ].m_OneHitDig = true;
a_Info[E_BLOCK_POTATOES ].m_OneHitDig = true;
a_Info[E_BLOCK_PUMPKIN_STEM ].m_OneHitDig = true;
a_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_OneHitDig = true;
a_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_OneHitDig = true;
a_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_OneHitDig = true;
a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_OneHitDig = true;
a_Info[E_BLOCK_REDSTONE_WIRE ].m_OneHitDig = true;
a_Info[E_BLOCK_RED_MUSHROOM ].m_OneHitDig = true;
a_Info[E_BLOCK_REEDS ].m_OneHitDig = true;
a_Info[E_BLOCK_SAPLING ].m_OneHitDig = true;
a_Info[E_BLOCK_TNT ].m_OneHitDig = true;
a_Info[E_BLOCK_TALL_GRASS ].m_OneHitDig = true;
a_Info[E_BLOCK_TORCH ].m_OneHitDig = true;
a_Info[E_BLOCK_TRIPWIRE ].m_OneHitDig = true;
// Blocks that break when pushed by piston:
ms_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_PistonBreakable = true;
ms_Info[E_BLOCK_AIR ].m_PistonBreakable = true;
ms_Info[E_BLOCK_BED ].m_PistonBreakable = true;
ms_Info[E_BLOCK_BIG_FLOWER ].m_PistonBreakable = true;
ms_Info[E_BLOCK_BROWN_MUSHROOM ].m_PistonBreakable = true;
ms_Info[E_BLOCK_CAKE ].m_PistonBreakable = true;
ms_Info[E_BLOCK_COBWEB ].m_PistonBreakable = true;
ms_Info[E_BLOCK_CROPS ].m_PistonBreakable = true;
ms_Info[E_BLOCK_DANDELION ].m_PistonBreakable = true;
ms_Info[E_BLOCK_DEAD_BUSH ].m_PistonBreakable = true;
ms_Info[E_BLOCK_FIRE ].m_PistonBreakable = true;
ms_Info[E_BLOCK_FLOWER ].m_PistonBreakable = true;
ms_Info[E_BLOCK_HEAD ].m_PistonBreakable = true;
ms_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_PistonBreakable = true;
ms_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_PistonBreakable = true;
ms_Info[E_BLOCK_IRON_DOOR ].m_PistonBreakable = true;
ms_Info[E_BLOCK_JACK_O_LANTERN ].m_PistonBreakable = true;
ms_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_PistonBreakable = true;
ms_Info[E_BLOCK_LADDER ].m_PistonBreakable = true;
ms_Info[E_BLOCK_LAVA ].m_PistonBreakable = true;
ms_Info[E_BLOCK_LEVER ].m_PistonBreakable = true;
ms_Info[E_BLOCK_MELON ].m_PistonBreakable = true;
ms_Info[E_BLOCK_MELON_STEM ].m_PistonBreakable = true;
ms_Info[E_BLOCK_PUMPKIN ].m_PistonBreakable = true;
ms_Info[E_BLOCK_PUMPKIN_STEM ].m_PistonBreakable = true;
ms_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_PistonBreakable = true;
ms_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_PistonBreakable = true;
ms_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_PistonBreakable = true;
ms_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_PistonBreakable = true;
ms_Info[E_BLOCK_REDSTONE_WIRE ].m_PistonBreakable = true;
ms_Info[E_BLOCK_RED_MUSHROOM ].m_PistonBreakable = true;
ms_Info[E_BLOCK_REEDS ].m_PistonBreakable = true;
ms_Info[E_BLOCK_SNOW ].m_PistonBreakable = true;
ms_Info[E_BLOCK_STATIONARY_LAVA ].m_PistonBreakable = true;
ms_Info[E_BLOCK_STATIONARY_WATER ].m_PistonBreakable = true;
ms_Info[E_BLOCK_STONE_BUTTON ].m_PistonBreakable = true;
ms_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_PistonBreakable = true;
ms_Info[E_BLOCK_TALL_GRASS ].m_PistonBreakable = true;
ms_Info[E_BLOCK_TORCH ].m_PistonBreakable = true;
ms_Info[E_BLOCK_VINES ].m_PistonBreakable = true;
ms_Info[E_BLOCK_WATER ].m_PistonBreakable = true;
ms_Info[E_BLOCK_WOODEN_BUTTON ].m_PistonBreakable = true;
ms_Info[E_BLOCK_WOODEN_DOOR ].m_PistonBreakable = true;
ms_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_PistonBreakable = true;
a_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_PistonBreakable = true;
a_Info[E_BLOCK_AIR ].m_PistonBreakable = true;
a_Info[E_BLOCK_BED ].m_PistonBreakable = true;
a_Info[E_BLOCK_BIG_FLOWER ].m_PistonBreakable = true;
a_Info[E_BLOCK_BROWN_MUSHROOM ].m_PistonBreakable = true;
a_Info[E_BLOCK_CACTUS ].m_PistonBreakable = true;
a_Info[E_BLOCK_CAKE ].m_PistonBreakable = true;
a_Info[E_BLOCK_CARROTS ].m_PistonBreakable = true;
a_Info[E_BLOCK_COCOA_POD ].m_PistonBreakable = true;
a_Info[E_BLOCK_COBWEB ].m_PistonBreakable = true;
a_Info[E_BLOCK_CROPS ].m_PistonBreakable = true;
a_Info[E_BLOCK_DANDELION ].m_PistonBreakable = true;
a_Info[E_BLOCK_DEAD_BUSH ].m_PistonBreakable = true;
a_Info[E_BLOCK_DRAGON_EGG ].m_PistonBreakable = true;
a_Info[E_BLOCK_FIRE ].m_PistonBreakable = true;
a_Info[E_BLOCK_FLOWER ].m_PistonBreakable = true;
a_Info[E_BLOCK_FLOWER_POT ].m_PistonBreakable = true;
a_Info[E_BLOCK_HEAD ].m_PistonBreakable = true;
a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_PistonBreakable = true;
a_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_PistonBreakable = true;
a_Info[E_BLOCK_IRON_DOOR ].m_PistonBreakable = true;
a_Info[E_BLOCK_JACK_O_LANTERN ].m_PistonBreakable = true;
a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_PistonBreakable = true;
a_Info[E_BLOCK_LILY_PAD ].m_PistonBreakable = true;
a_Info[E_BLOCK_LADDER ].m_PistonBreakable = true;
a_Info[E_BLOCK_LAVA ].m_PistonBreakable = true;
a_Info[E_BLOCK_LEVER ].m_PistonBreakable = true;
a_Info[E_BLOCK_MELON ].m_PistonBreakable = true;
a_Info[E_BLOCK_MELON_STEM ].m_PistonBreakable = true;
a_Info[E_BLOCK_NETHER_WART ].m_PistonBreakable = true;
a_Info[E_BLOCK_POTATOES ].m_PistonBreakable = true;
a_Info[E_BLOCK_PUMPKIN ].m_PistonBreakable = true;
a_Info[E_BLOCK_PUMPKIN_STEM ].m_PistonBreakable = true;
a_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_PistonBreakable = true;
a_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_PistonBreakable = true;
a_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_PistonBreakable = true;
a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_PistonBreakable = true;
a_Info[E_BLOCK_REDSTONE_WIRE ].m_PistonBreakable = true;
a_Info[E_BLOCK_RED_MUSHROOM ].m_PistonBreakable = true;
a_Info[E_BLOCK_REEDS ].m_PistonBreakable = true;
a_Info[E_BLOCK_SAPLING ].m_PistonBreakable = true;
a_Info[E_BLOCK_SIGN_POST ].m_PistonBreakable = true;
a_Info[E_BLOCK_SNOW ].m_PistonBreakable = true;
a_Info[E_BLOCK_STATIONARY_LAVA ].m_PistonBreakable = true;
a_Info[E_BLOCK_STATIONARY_WATER ].m_PistonBreakable = true;
a_Info[E_BLOCK_STONE_BUTTON ].m_PistonBreakable = true;
a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_PistonBreakable = true;
a_Info[E_BLOCK_TALL_GRASS ].m_PistonBreakable = true;
a_Info[E_BLOCK_TORCH ].m_PistonBreakable = true;
a_Info[E_BLOCK_TRAPDOOR ].m_PistonBreakable = true;
a_Info[E_BLOCK_TRIPWIRE ].m_PistonBreakable = true;
a_Info[E_BLOCK_TRIPWIRE_HOOK ].m_PistonBreakable = true;
a_Info[E_BLOCK_VINES ].m_PistonBreakable = true;
a_Info[E_BLOCK_WALLSIGN ].m_PistonBreakable = true;
a_Info[E_BLOCK_WATER ].m_PistonBreakable = true;
a_Info[E_BLOCK_WOODEN_BUTTON ].m_PistonBreakable = true;
a_Info[E_BLOCK_WOODEN_DOOR ].m_PistonBreakable = true;
a_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_PistonBreakable = true;
// Blocks that cannot be snowed over:
ms_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_IsSnowable = false;
ms_Info[E_BLOCK_AIR ].m_IsSnowable = false;
ms_Info[E_BLOCK_BIG_FLOWER ].m_IsSnowable = false;
ms_Info[E_BLOCK_BROWN_MUSHROOM ].m_IsSnowable = false;
ms_Info[E_BLOCK_CACTUS ].m_IsSnowable = false;
ms_Info[E_BLOCK_CHEST ].m_IsSnowable = false;
ms_Info[E_BLOCK_CROPS ].m_IsSnowable = false;
ms_Info[E_BLOCK_COBBLESTONE_WALL ].m_IsSnowable = false;
ms_Info[E_BLOCK_DANDELION ].m_IsSnowable = false;
ms_Info[E_BLOCK_FIRE ].m_IsSnowable = false;
ms_Info[E_BLOCK_FLOWER ].m_IsSnowable = false;
ms_Info[E_BLOCK_GLASS ].m_IsSnowable = false;
ms_Info[E_BLOCK_ICE ].m_IsSnowable = false;
ms_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_IsSnowable = false;
ms_Info[E_BLOCK_LAVA ].m_IsSnowable = false;
ms_Info[E_BLOCK_LILY_PAD ].m_IsSnowable = false;
ms_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_IsSnowable = false;
ms_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_IsSnowable = false;
ms_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_IsSnowable = false;
ms_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_IsSnowable = false;
ms_Info[E_BLOCK_REDSTONE_WIRE ].m_IsSnowable = false;
ms_Info[E_BLOCK_RED_MUSHROOM ].m_IsSnowable = false;
ms_Info[E_BLOCK_REEDS ].m_IsSnowable = false;
ms_Info[E_BLOCK_SAPLING ].m_IsSnowable = false;
ms_Info[E_BLOCK_SIGN_POST ].m_IsSnowable = false;
ms_Info[E_BLOCK_SNOW ].m_IsSnowable = false;
ms_Info[E_BLOCK_STAINED_GLASS ].m_IsSnowable = false;
ms_Info[E_BLOCK_STAINED_GLASS_PANE ].m_IsSnowable = false;
ms_Info[E_BLOCK_STATIONARY_LAVA ].m_IsSnowable = false;
ms_Info[E_BLOCK_STATIONARY_WATER ].m_IsSnowable = false;
ms_Info[E_BLOCK_TALL_GRASS ].m_IsSnowable = false;
ms_Info[E_BLOCK_TNT ].m_IsSnowable = false;
ms_Info[E_BLOCK_TORCH ].m_IsSnowable = false;
ms_Info[E_BLOCK_VINES ].m_IsSnowable = false;
ms_Info[E_BLOCK_WALLSIGN ].m_IsSnowable = false;
ms_Info[E_BLOCK_WATER ].m_IsSnowable = false;
ms_Info[E_BLOCK_RAIL ].m_IsSnowable = false;
ms_Info[E_BLOCK_ACTIVATOR_RAIL ].m_IsSnowable = false;
ms_Info[E_BLOCK_POWERED_RAIL ].m_IsSnowable = false;
ms_Info[E_BLOCK_DETECTOR_RAIL ].m_IsSnowable = false;
ms_Info[E_BLOCK_COBWEB ].m_IsSnowable = false;
ms_Info[E_BLOCK_HEAD ].m_IsSnowable = false;
// Blocks that can be snowed over:
a_Info[E_BLOCK_BEDROCK ].m_IsSnowable = true;
a_Info[E_BLOCK_BLOCK_OF_COAL ].m_IsSnowable = true;
a_Info[E_BLOCK_BLOCK_OF_REDSTONE ].m_IsSnowable = true;
a_Info[E_BLOCK_BOOKCASE ].m_IsSnowable = true;
a_Info[E_BLOCK_BRICK ].m_IsSnowable = true;
a_Info[E_BLOCK_CLAY ].m_IsSnowable = true;
a_Info[E_BLOCK_CRAFTING_TABLE ].m_IsSnowable = true;
a_Info[E_BLOCK_COAL_ORE ].m_IsSnowable = true;
a_Info[E_BLOCK_COMMAND_BLOCK ].m_IsSnowable = true;
a_Info[E_BLOCK_COBBLESTONE ].m_IsSnowable = true;
a_Info[E_BLOCK_DIAMOND_BLOCK ].m_IsSnowable = true;
a_Info[E_BLOCK_DIAMOND_ORE ].m_IsSnowable = true;
a_Info[E_BLOCK_DIRT ].m_IsSnowable = true;
a_Info[E_BLOCK_DISPENSER ].m_IsSnowable = true;
a_Info[E_BLOCK_DOUBLE_STONE_SLAB ].m_IsSnowable = true;
a_Info[E_BLOCK_DOUBLE_WOODEN_SLAB ].m_IsSnowable = true;
a_Info[E_BLOCK_DROPPER ].m_IsSnowable = true;
a_Info[E_BLOCK_EMERALD_BLOCK ].m_IsSnowable = true;
a_Info[E_BLOCK_EMERALD_ORE ].m_IsSnowable = true;
a_Info[E_BLOCK_END_STONE ].m_IsSnowable = true;
a_Info[E_BLOCK_FURNACE ].m_IsSnowable = true;
a_Info[E_BLOCK_GLOWSTONE ].m_IsSnowable = true;
a_Info[E_BLOCK_GOLD_BLOCK ].m_IsSnowable = true;
a_Info[E_BLOCK_GOLD_ORE ].m_IsSnowable = true;
a_Info[E_BLOCK_GRASS ].m_IsSnowable = true;
a_Info[E_BLOCK_GRAVEL ].m_IsSnowable = true;
a_Info[E_BLOCK_HARDENED_CLAY ].m_IsSnowable = true;
a_Info[E_BLOCK_HAY_BALE ].m_IsSnowable = true;
a_Info[E_BLOCK_HUGE_BROWN_MUSHROOM ].m_IsSnowable = true;
a_Info[E_BLOCK_HUGE_RED_MUSHROOM ].m_IsSnowable = true;
a_Info[E_BLOCK_IRON_BLOCK ].m_IsSnowable = true;
a_Info[E_BLOCK_IRON_ORE ].m_IsSnowable = true;
a_Info[E_BLOCK_JACK_O_LANTERN ].m_IsSnowable = true;
a_Info[E_BLOCK_JUKEBOX ].m_IsSnowable = true;
a_Info[E_BLOCK_LAPIS_BLOCK ].m_IsSnowable = true;
a_Info[E_BLOCK_LAPIS_ORE ].m_IsSnowable = true;
a_Info[E_BLOCK_LEAVES ].m_IsSnowable = true;
a_Info[E_BLOCK_LIT_FURNACE ].m_IsSnowable = true;
a_Info[E_BLOCK_LOG ].m_IsSnowable = true;
a_Info[E_BLOCK_MELON ].m_IsSnowable = true;
a_Info[E_BLOCK_MOSSY_COBBLESTONE ].m_IsSnowable = true;
a_Info[E_BLOCK_MYCELIUM ].m_IsSnowable = true;
a_Info[E_BLOCK_NETHER_BRICK ].m_IsSnowable = true;
a_Info[E_BLOCK_NETHER_QUARTZ_ORE ].m_IsSnowable = true;
a_Info[E_BLOCK_NETHERRACK ].m_IsSnowable = true;
a_Info[E_BLOCK_NEW_LEAVES ].m_IsSnowable = true;
a_Info[E_BLOCK_NEW_LOG ].m_IsSnowable = true;
a_Info[E_BLOCK_NOTE_BLOCK ].m_IsSnowable = true;
a_Info[E_BLOCK_OBSIDIAN ].m_IsSnowable = true;
a_Info[E_BLOCK_PLANKS ].m_IsSnowable = true;
a_Info[E_BLOCK_PUMPKIN ].m_IsSnowable = true;
a_Info[E_BLOCK_QUARTZ_BLOCK ].m_IsSnowable = true;
a_Info[E_BLOCK_REDSTONE_LAMP_OFF ].m_IsSnowable = true;
a_Info[E_BLOCK_REDSTONE_LAMP_ON ].m_IsSnowable = true;
a_Info[E_BLOCK_REDSTONE_ORE ].m_IsSnowable = true;
a_Info[E_BLOCK_REDSTONE_ORE_GLOWING].m_IsSnowable = true;
a_Info[E_BLOCK_SAND ].m_IsSnowable = true;
a_Info[E_BLOCK_SANDSTONE ].m_IsSnowable = true;
a_Info[E_BLOCK_SILVERFISH_EGG ].m_IsSnowable = true;
a_Info[E_BLOCK_SNOW_BLOCK ].m_IsSnowable = true;
a_Info[E_BLOCK_SOULSAND ].m_IsSnowable = true;
a_Info[E_BLOCK_SPONGE ].m_IsSnowable = true;
a_Info[E_BLOCK_STAINED_CLAY ].m_IsSnowable = true;
a_Info[E_BLOCK_STONE ].m_IsSnowable = true;
a_Info[E_BLOCK_STONE_BRICKS ].m_IsSnowable = true;
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:
ms_Info[E_BLOCK_BRICK ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_CAULDRON ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_COAL_ORE ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_COBBLESTONE ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_COBBLESTONE_WALL ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_COBBLESTONE_STAIRS ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_COBWEB ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_DIAMOND_BLOCK ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_DIAMOND_ORE ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_DOUBLE_STONE_SLAB ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_EMERALD_ORE ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_END_STONE ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_GOLD_BLOCK ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_GOLD_ORE ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_IRON_BLOCK ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_IRON_ORE ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_LAPIS_BLOCK ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_LAPIS_ORE ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_MOSSY_COBBLESTONE ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_NETHERRACK ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_NETHER_BRICK ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_NETHER_BRICK_STAIRS ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_OBSIDIAN ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_REDSTONE_ORE ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_REDSTONE_ORE_GLOWING].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_SANDSTONE ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_SANDSTONE_STAIRS ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_SNOW ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_STONE ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_STONE_BRICKS ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_STONE_BRICK_STAIRS ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_STONE_SLAB ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_VINES ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_FURNACE ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_LIT_FURNACE ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_ANVIL ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_ENCHANTMENT_TABLE ].m_RequiresSpecialTool = true;
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:
ms_Info[E_BLOCK_ACTIVATOR_RAIL ].m_IsSolid = false;
ms_Info[E_BLOCK_AIR ].m_IsSolid = false;
ms_Info[E_BLOCK_BIG_FLOWER ].m_IsSolid = false;
ms_Info[E_BLOCK_BROWN_MUSHROOM ].m_IsSolid = false;
ms_Info[E_BLOCK_CAKE ].m_IsSolid = false;
ms_Info[E_BLOCK_CARROTS ].m_IsSolid = false;
ms_Info[E_BLOCK_COBWEB ].m_IsSolid = false;
ms_Info[E_BLOCK_CROPS ].m_IsSolid = false;
ms_Info[E_BLOCK_DANDELION ].m_IsSolid = false;
ms_Info[E_BLOCK_DETECTOR_RAIL ].m_IsSolid = false;
ms_Info[E_BLOCK_END_PORTAL ].m_IsSolid = false;
ms_Info[E_BLOCK_FENCE ].m_IsSolid = false;
ms_Info[E_BLOCK_FENCE_GATE ].m_IsSolid = false;
ms_Info[E_BLOCK_FIRE ].m_IsSolid = false;
ms_Info[E_BLOCK_FLOWER ].m_IsSolid = false;
ms_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_IsSolid = false;
ms_Info[E_BLOCK_LAVA ].m_IsSolid = false;
ms_Info[E_BLOCK_LEVER ].m_IsSolid = false;
ms_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_IsSolid = false;
ms_Info[E_BLOCK_MELON_STEM ].m_IsSolid = false;
ms_Info[E_BLOCK_NETHER_PORTAL ].m_IsSolid = false;
ms_Info[E_BLOCK_PISTON_EXTENSION ].m_IsSolid = false;
ms_Info[E_BLOCK_POTATOES ].m_IsSolid = false;
ms_Info[E_BLOCK_POWERED_RAIL ].m_IsSolid = false;
ms_Info[E_BLOCK_RAIL ].m_IsSolid = false;
ms_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_IsSolid = false;
ms_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_IsSolid = false;
ms_Info[E_BLOCK_REDSTONE_WIRE ].m_IsSolid = false;
ms_Info[E_BLOCK_RED_MUSHROOM ].m_IsSolid = false;
ms_Info[E_BLOCK_REEDS ].m_IsSolid = false;
ms_Info[E_BLOCK_SAPLING ].m_IsSolid = false;
ms_Info[E_BLOCK_SIGN_POST ].m_IsSolid = false;
ms_Info[E_BLOCK_SNOW ].m_IsSolid = false;
ms_Info[E_BLOCK_STATIONARY_LAVA ].m_IsSolid = false;
ms_Info[E_BLOCK_STATIONARY_WATER ].m_IsSolid = false;
ms_Info[E_BLOCK_STONE_BUTTON ].m_IsSolid = false;
ms_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_IsSolid = false;
ms_Info[E_BLOCK_TALL_GRASS ].m_IsSolid = false;
ms_Info[E_BLOCK_TORCH ].m_IsSolid = false;
ms_Info[E_BLOCK_TRIPWIRE ].m_IsSolid = false;
ms_Info[E_BLOCK_VINES ].m_IsSolid = false;
ms_Info[E_BLOCK_WALLSIGN ].m_IsSolid = false;
ms_Info[E_BLOCK_WATER ].m_IsSolid = false;
ms_Info[E_BLOCK_WOODEN_BUTTON ].m_IsSolid = false;
ms_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_IsSolid = false;
ms_Info[E_BLOCK_WOODEN_SLAB ].m_IsSolid = false;
a_Info[E_BLOCK_ACTIVATOR_RAIL ].m_IsSolid = false;
a_Info[E_BLOCK_AIR ].m_IsSolid = false;
a_Info[E_BLOCK_BIG_FLOWER ].m_IsSolid = false;
a_Info[E_BLOCK_BROWN_MUSHROOM ].m_IsSolid = false;
a_Info[E_BLOCK_CAKE ].m_IsSolid = false;
a_Info[E_BLOCK_CARROTS ].m_IsSolid = false;
a_Info[E_BLOCK_COBWEB ].m_IsSolid = false;
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_FIRE ].m_IsSolid = false;
a_Info[E_BLOCK_FLOWER ].m_IsSolid = false;
a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_IsSolid = false;
a_Info[E_BLOCK_LAVA ].m_IsSolid = false;
a_Info[E_BLOCK_LEVER ].m_IsSolid = false;
a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_IsSolid = false;
a_Info[E_BLOCK_MELON_STEM ].m_IsSolid = false;
a_Info[E_BLOCK_NETHER_PORTAL ].m_IsSolid = false;
a_Info[E_BLOCK_POTATOES ].m_IsSolid = false;
a_Info[E_BLOCK_POWERED_RAIL ].m_IsSolid = false;
a_Info[E_BLOCK_RAIL ].m_IsSolid = false;
a_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_IsSolid = false;
a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_IsSolid = false;
a_Info[E_BLOCK_REDSTONE_WIRE ].m_IsSolid = false;
a_Info[E_BLOCK_RED_MUSHROOM ].m_IsSolid = false;
a_Info[E_BLOCK_REEDS ].m_IsSolid = false;
a_Info[E_BLOCK_SAPLING ].m_IsSolid = false;
a_Info[E_BLOCK_SIGN_POST ].m_IsSolid = false;
a_Info[E_BLOCK_SNOW ].m_IsSolid = false;
a_Info[E_BLOCK_STATIONARY_LAVA ].m_IsSolid = false;
a_Info[E_BLOCK_STATIONARY_WATER ].m_IsSolid = false;
a_Info[E_BLOCK_STONE_BUTTON ].m_IsSolid = false;
a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_IsSolid = false;
a_Info[E_BLOCK_TALL_GRASS ].m_IsSolid = false;
a_Info[E_BLOCK_TORCH ].m_IsSolid = false;
a_Info[E_BLOCK_TRIPWIRE ].m_IsSolid = false;
a_Info[E_BLOCK_VINES ].m_IsSolid = false;
a_Info[E_BLOCK_WALLSIGN ].m_IsSolid = false;
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;
// Blocks that fully occupy their voxel - used as a guide for torch placeable blocks, amongst other things:
ms_Info[E_BLOCK_NEW_LOG ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_BEDROCK ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_BLOCK_OF_COAL ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_BLOCK_OF_REDSTONE ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_BOOKCASE ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_BRICK ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_CLAY ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_COAL_ORE ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_COBBLESTONE ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_COMMAND_BLOCK ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_CRAFTING_TABLE ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_DIAMOND_BLOCK ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_DIAMOND_ORE ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_DIRT ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_DISPENSER ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_DOUBLE_STONE_SLAB ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_DOUBLE_WOODEN_SLAB ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_DROPPER ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_EMERALD_BLOCK ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_EMERALD_ORE ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_END_STONE ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_FURNACE ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_GLOWSTONE ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_GOLD_BLOCK ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_GOLD_ORE ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_GRASS ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_GRAVEL ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_HARDENED_CLAY ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_HAY_BALE ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_HUGE_BROWN_MUSHROOM ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_HUGE_RED_MUSHROOM ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_ICE ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_IRON_BLOCK ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_IRON_ORE ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_JACK_O_LANTERN ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_JUKEBOX ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_LAPIS_BLOCK ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_LAPIS_ORE ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_LOG ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_MELON ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_MOSSY_COBBLESTONE ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_MYCELIUM ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_NETHERRACK ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_NETHER_BRICK ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_NETHER_QUARTZ_ORE ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_NOTE_BLOCK ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_OBSIDIAN ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_PACKED_ICE ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_PLANKS ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_PUMPKIN ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_QUARTZ_BLOCK ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_REDSTONE_LAMP_OFF ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_REDSTONE_LAMP_ON ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_REDSTONE_ORE ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_REDSTONE_ORE_GLOWING].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_SANDSTONE ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_SAND ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_SILVERFISH_EGG ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_SPONGE ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_STAINED_CLAY ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_WOOL ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_STONE ].m_FullyOccupiesVoxel = true;
ms_Info[E_BLOCK_STONE_BRICKS ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_NEW_LOG ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_BEDROCK ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_BLOCK_OF_COAL ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_BLOCK_OF_REDSTONE ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_BOOKCASE ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_BRICK ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_CLAY ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_COAL_ORE ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_COBBLESTONE ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_COMMAND_BLOCK ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_CRAFTING_TABLE ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_DIAMOND_BLOCK ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_DIAMOND_ORE ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_DIRT ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_DISPENSER ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_DOUBLE_STONE_SLAB ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_DOUBLE_WOODEN_SLAB ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_DROPPER ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_EMERALD_BLOCK ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_EMERALD_ORE ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_END_STONE ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_FURNACE ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_GLOWSTONE ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_GOLD_BLOCK ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_GOLD_ORE ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_GRASS ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_GRAVEL ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_HARDENED_CLAY ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_HAY_BALE ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_HUGE_BROWN_MUSHROOM ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_HUGE_RED_MUSHROOM ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_ICE ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_IRON_BLOCK ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_IRON_ORE ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_JACK_O_LANTERN ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_JUKEBOX ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_LAPIS_BLOCK ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_LAPIS_ORE ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_LOG ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_MELON ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_MOSSY_COBBLESTONE ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_MYCELIUM ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_NETHERRACK ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_NETHER_BRICK ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_NETHER_QUARTZ_ORE ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_NOTE_BLOCK ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_OBSIDIAN ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_PACKED_ICE ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_PLANKS ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_PUMPKIN ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_QUARTZ_BLOCK ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_REDSTONE_LAMP_OFF ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_REDSTONE_LAMP_ON ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_REDSTONE_ORE ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_REDSTONE_ORE_GLOWING].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_SANDSTONE ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_SAND ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_SILVERFISH_EGG ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_SPONGE ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_STAINED_CLAY ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_STONE ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_STONE_BRICKS ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_WOOL ].m_FullyOccupiesVoxel = true;
}

View File

@ -16,18 +16,8 @@ class cBlockHandler;
class cBlockInfo
{
public:
// tolua_end
cBlockInfo();
~cBlockInfo();
/** (Re-)Initializes the internal BlockInfo structures. */
static void Initialize(void);
// tolua_begin
/** Returns the associated BlockInfo structure. */
/** Returns the associated BlockInfo structure for the specified block type. */
static cBlockInfo & Get(BLOCKTYPE a_Type);
@ -79,14 +69,19 @@ public:
inline static cBlockHandler * GetHandler (BLOCKTYPE a_Type) { return Get(a_Type).m_Handler; }
protected:
/** Storage for all the BlockInfo structures. */
typedef cBlockInfo cBlockInfoArray[256];
// TODO xdot: Change to std::vector to support dynamic block IDs
static cBlockInfo ms_Info[256];
/** Creates a default BlockInfo structure, initializes all values to their defaults */
cBlockInfo();
/** Cleans up the stored values */
~cBlockInfo();
}; // tolua_export
/** Initializes the specified BlockInfo structures with block-specific values. */
static void Initialize(cBlockInfoArray & a_BlockInfos);
}; // tolua_export

View File

@ -39,13 +39,13 @@ public:
/** Called on each block encountered along the path, including the first block (path start), if chunk data is not loaded
When this callback returns true, the tracing is aborted.
*/
virtual bool OnNextBlockNoData(int a_BlockX, int a_BlockY, int a_BlockZ, char a_EntryFace)
{
virtual bool OnNextBlockNoData(int a_BlockX, int a_BlockY, int a_BlockZ, char a_EntryFace)
{
UNUSED(a_BlockX);
UNUSED(a_BlockY);
UNUSED(a_BlockZ);
UNUSED(a_EntryFace);
return false;
return false;
}
/** Called when the path goes out of world, either below (a_BlockY < 0) or above (a_BlockY >= cChunkDef::Height)
@ -54,8 +54,8 @@ public:
Note that some paths can go out of the world and come back again (parabola),
in such a case this callback is followed by OnIntoWorld() and further OnNextBlock() calls
*/
virtual bool OnOutOfWorld(double a_BlockX, double a_BlockY, double a_BlockZ)
{
virtual bool OnOutOfWorld(double a_BlockX, double a_BlockY, double a_BlockZ)
{
UNUSED(a_BlockX);
UNUSED(a_BlockY);
UNUSED(a_BlockZ);
@ -68,12 +68,12 @@ public:
Note that some paths can go out of the world and come back again (parabola),
in such a case this callback is followed by further OnNextBlock() calls
*/
virtual bool OnIntoWorld(double a_BlockX, double a_BlockY, double a_BlockZ)
{
virtual bool OnIntoWorld(double a_BlockX, double a_BlockY, double a_BlockZ)
{
UNUSED(a_BlockX);
UNUSED(a_BlockY);
UNUSED(a_BlockZ);
return false;
return false;
}
/** Called when the path is sure not to hit any more blocks.

View File

@ -34,7 +34,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override

View File

@ -116,22 +116,22 @@ void cBlockBedHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface
if (Meta & 0x8)
{
// Is pillow
// Is pillow
a_WorldInterface.GetBroadcastManager().BroadcastUseBed(*a_Player, a_BlockX, a_BlockY, a_BlockZ);
}
else
{
// Is foot end
VERIFY((Meta & 0x4) != 0x4); // Occupied flag should never be set, else our compilator (intended) is broken
VERIFY((Meta & 0x4) != 0x4); // Occupied flag should never be set, else our compilator (intended) is broken
PillowDirection = MetaDataToDirection(Meta & 0x7);
if (a_ChunkInterface.GetBlock(a_BlockX + PillowDirection.x, a_BlockY, a_BlockZ + PillowDirection.z) == E_BLOCK_BED) // Must always use pillow location for sleeping
if (a_ChunkInterface.GetBlock(a_BlockX + PillowDirection.x, a_BlockY, a_BlockZ + PillowDirection.z) == E_BLOCK_BED) // Must always use pillow location for sleeping
{
a_WorldInterface.GetBroadcastManager().BroadcastUseBed(*a_Player, a_BlockX + PillowDirection.x, a_BlockY, a_BlockZ + PillowDirection.z);
}
}
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta | 0x4); // Where 0x4 = occupied bit
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta | 0x4); // Where 0x4 = occupied bit
a_Player->SetIsInBed(true);
a_Player->SetBedPos(Vector3i(a_BlockX, a_BlockY, a_BlockZ));
a_Player->SendMessageSuccess("Home position set successfully");
@ -142,9 +142,9 @@ void cBlockBedHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface
cPlayerBedStateUnsetter Unsetter(Vector3i(a_BlockX + PillowDirection.x, a_BlockY, a_BlockZ + PillowDirection.z), a_WorldInterface);
a_WorldInterface.ForEachPlayer(Unsetter);
a_WorldInterface.SetTimeOfDay(0);
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta & 0xB); // Where 0xB = 1011, and zero is to make sure 'occupied' bit is always unset
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta & 0xB); // Where 0xB = 1011, and zero is to make sure 'occupied' bit is always unset
}
}
}
}
else
{

View File

@ -86,8 +86,8 @@ public:
virtual void OnPlacedByPlayer(
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
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

View File

@ -23,7 +23,8 @@ public:
NIBBLETYPE Meta = (a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) | 0x08);
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("random.click", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, (Meta & 0x08) ? 0.6f : 0.5f);
a_WorldInterface.WakeUpSimulators(a_BlockX, a_BlockY, a_BlockZ);
a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("random.click", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 0.5f, (Meta & 0x08) ? 0.6f : 0.5f);
// Queue a button reset (unpress)
a_ChunkInterface.QueueSetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, (a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) & 0x07), m_BlockType == E_BLOCK_STONE_BUTTON ? 20 : 30, m_BlockType, a_WorldInterface);
@ -45,7 +46,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
@ -73,7 +74,7 @@ public:
default:
{
ASSERT(!"Unhandled block face!");
return 0x0; // No idea, give a special meta (button in centre of block)
return 0x0; // No idea, give a special meta (button in centre of block)
}
}
}
@ -102,7 +103,7 @@ public:
AddFaceDirection(a_RelX, a_RelY, a_RelZ, BlockMetaDataToBlockFace(Meta), true);
BLOCKTYPE BlockIsOn; a_Chunk.UnboundedRelGetBlockType(a_RelX, a_RelY, a_RelZ, BlockIsOn);
return (a_RelY > 0) && (cBlockInfo::IsSolid(BlockIsOn));
return (a_RelY > 0) && (cBlockInfo::FullyOccupiesVoxel(BlockIsOn));
}
} ;

View File

@ -32,7 +32,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override

View File

@ -22,7 +22,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
@ -44,16 +44,16 @@ public:
}
double yaw = a_Player->GetYaw();
if (
(Area.GetRelBlockType(0, 0, 1) == E_BLOCK_CHEST) ||
(Area.GetRelBlockType(2, 0, 1) == E_BLOCK_CHEST)
(Area.GetRelBlockType(0, 0, 1) == m_BlockType) ||
(Area.GetRelBlockType(2, 0, 1) == m_BlockType)
)
{
a_BlockMeta = ((yaw >= -90) && (yaw < 90)) ? 2 : 3;
return true;
}
if (
(Area.GetRelBlockType(0, 0, 1) == E_BLOCK_CHEST) ||
(Area.GetRelBlockType(2, 0, 1) == E_BLOCK_CHEST)
(Area.GetRelBlockType(0, 0, 1) == m_BlockType) ||
(Area.GetRelBlockType(2, 0, 1) == m_BlockType)
)
{
// FIXME: This is unreachable, as the condition is the same as the above one
@ -68,7 +68,7 @@ public:
virtual void OnPlacedByPlayer(
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player,
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
@ -130,12 +130,12 @@ public:
}
int NumChestNeighbors = 0;
if (Area.GetRelBlockType(1, 0, 2) == E_BLOCK_CHEST)
if (Area.GetRelBlockType(1, 0, 2) == m_BlockType)
{
if (
(Area.GetRelBlockType(0, 0, 2) == E_BLOCK_CHEST) ||
(Area.GetRelBlockType(1, 0, 1) == E_BLOCK_CHEST) ||
(Area.GetRelBlockType(1, 0, 3) == E_BLOCK_CHEST)
(Area.GetRelBlockType(0, 0, 2) == m_BlockType) ||
(Area.GetRelBlockType(1, 0, 1) == m_BlockType) ||
(Area.GetRelBlockType(1, 0, 3) == m_BlockType)
)
{
// Already a doublechest neighbor, disallow:
@ -143,12 +143,12 @@ public:
}
NumChestNeighbors += 1;
}
if (Area.GetRelBlockType(3, 0, 2) == E_BLOCK_CHEST)
if (Area.GetRelBlockType(3, 0, 2) == m_BlockType)
{
if (
(Area.GetRelBlockType(4, 0, 2) == E_BLOCK_CHEST) ||
(Area.GetRelBlockType(3, 0, 1) == E_BLOCK_CHEST) ||
(Area.GetRelBlockType(3, 0, 3) == E_BLOCK_CHEST)
(Area.GetRelBlockType(4, 0, 2) == m_BlockType) ||
(Area.GetRelBlockType(3, 0, 1) == m_BlockType) ||
(Area.GetRelBlockType(3, 0, 3) == m_BlockType)
)
{
// Already a doublechest neighbor, disallow:
@ -156,12 +156,12 @@ public:
}
NumChestNeighbors += 1;
}
if (Area.GetRelBlockType(2, 0, 1) == E_BLOCK_CHEST)
if (Area.GetRelBlockType(2, 0, 1) == m_BlockType)
{
if (
(Area.GetRelBlockType(2, 0, 0) == E_BLOCK_CHEST) ||
(Area.GetRelBlockType(1, 0, 1) == E_BLOCK_CHEST) ||
(Area.GetRelBlockType(3, 0, 1) == E_BLOCK_CHEST)
(Area.GetRelBlockType(2, 0, 0) == m_BlockType) ||
(Area.GetRelBlockType(1, 0, 1) == m_BlockType) ||
(Area.GetRelBlockType(3, 0, 1) == m_BlockType)
)
{
// Already a doublechest neighbor, disallow:
@ -169,12 +169,12 @@ public:
}
NumChestNeighbors += 1;
}
if (Area.GetRelBlockType(2, 0, 3) == E_BLOCK_CHEST)
if (Area.GetRelBlockType(2, 0, 3) == m_BlockType)
{
if (
(Area.GetRelBlockType(2, 0, 4) == E_BLOCK_CHEST) ||
(Area.GetRelBlockType(1, 0, 3) == E_BLOCK_CHEST) ||
(Area.GetRelBlockType(3, 0, 3) == E_BLOCK_CHEST)
(Area.GetRelBlockType(2, 0, 4) == m_BlockType) ||
(Area.GetRelBlockType(1, 0, 3) == m_BlockType) ||
(Area.GetRelBlockType(3, 0, 3) == m_BlockType)
)
{
// Already a doublechest neighbor, disallow:
@ -217,7 +217,7 @@ public:
/// If there's a chest in the a_Area in the specified coords, modifies its meta to a_NewMeta and returns true.
bool CheckAndAdjustNeighbor(cChunkInterface & a_ChunkInterface, const cBlockArea & a_Area, int a_RelX, int a_RelZ, NIBBLETYPE a_NewMeta)
{
if (a_Area.GetRelBlockType(a_RelX, 0, a_RelZ) != E_BLOCK_CHEST)
if (a_Area.GetRelBlockType(a_RelX, 0, a_RelZ) != m_BlockType)
{
return false;
}
@ -228,7 +228,7 @@ public:
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
a_Pickups.push_back(cItem(E_BLOCK_CHEST, 1, 0));
a_Pickups.push_back(cItem(m_BlockType, 1, 0));
}
} ;

View File

@ -16,13 +16,6 @@ public:
{
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
a_Pickups.push_back(cItem(E_BLOCK_WOOL, 1, a_BlockMeta));
}
virtual const char * GetStepSound(void) override
{
return "step.cloth";

View File

@ -22,7 +22,7 @@ public:
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) override
{
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
Meta ^= 0x04; // Toggle 3rd (addition/subtraction) bit with XOR
Meta ^= 0x04; // Toggle 3rd (addition/subtraction) bit with XOR
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
}

View File

@ -71,7 +71,7 @@ public:
}
}
}
}
}
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override

View File

@ -152,7 +152,7 @@ NIBBLETYPE cBlockDoorHandler::MetaMirrorXY(NIBBLETYPE a_Meta)
// Return a_Meta if panel is a top panel (0x08 bit is set to 1)
// Note: Currently, you can not properly mirror the hinges on a double door. The orientation of the door is stored
// in only the bottom tile while the hinge position is in the top tile. This function only operates on one tile at a time,
// in only the bottom tile while the hinge position is in the top tile. This function only operates on one tile at a time,
// so the function can only see either the hinge position or orientation, but not both, at any given time. The class itself
// needs extra datamembers.
if (a_Meta & 0x08) return a_Meta;
@ -179,7 +179,7 @@ NIBBLETYPE cBlockDoorHandler::MetaMirrorYZ(NIBBLETYPE a_Meta)
// Return a_Meta if panel is a top panel (0x08 bit is set to 1)
// Note: Currently, you can not properly mirror the hinges on a double door. The orientation of the door is stored
// in only the bottom tile while the hinge position is in the top tile. This function only operates on one tile at a time,
// in only the bottom tile while the hinge position is in the top tile. This function only operates on one tile at a time,
// so the function can only see either the hinge position or orientation, but not both, at any given time.The class itself
// needs extra datamembers.

View File

@ -28,7 +28,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override

View File

@ -24,7 +24,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
@ -43,8 +43,8 @@ public:
// Mirrors defined by by a table. (Source, mincraft.gamepedia.com) 0x07 == 0111
switch (a_Meta & 0x07)
{
case 0x00: return 0x01 + OtherMeta; // Down -> Up
case 0x01: return 0x00 + OtherMeta; // Up -> Down
case 0x00: return 0x01 + OtherMeta; // Down -> Up
case 0x01: return 0x00 + OtherMeta; // Up -> Down
}
// Not Facing Up or Down; No change.
return a_Meta;

View File

@ -18,7 +18,7 @@ public:
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
//todo: Drop Ender Chest if using silk touch pickaxe
// todo: Drop Ender Chest if using silk touch pickaxe
a_Pickups.push_back(cItem(E_BLOCK_OBSIDIAN, 8, 0));
}

View File

@ -19,15 +19,13 @@
class cBlockFarmlandHandler :
public cBlockHandler
{
typedef cBlockHandler super;
public:
cBlockFarmlandHandler(void) :
super(E_BLOCK_FARMLAND)
cBlockFarmlandHandler(BLOCKTYPE a_BlockType) :
cBlockHandler(a_BlockType)
{
}
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
{
bool Found = false;
@ -105,6 +103,11 @@ public:
}
}
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
a_Pickups.Add(E_BLOCK_DIRT, 1, 0); // Reset meta
}
} ;

View File

@ -19,7 +19,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override

View File

@ -100,7 +100,7 @@ public:
/// Evaluates if coords have a valid border on top, based on MaxY
bool EvaluatePortalBorder(int X, int FoundObsidianY, int Z, int MaxY, cChunkInterface & a_ChunkInterface)
{
for (int checkBorder = FoundObsidianY + 1; checkBorder <= MaxY - 1; checkBorder++) // FoundObsidianY + 1: FoundObsidianY has already been checked in FindObsidianCeiling; MaxY - 1: portal doesn't need corners
for (int checkBorder = FoundObsidianY + 1; checkBorder <= MaxY - 1; checkBorder++) // FoundObsidianY + 1: FoundObsidianY has already been checked in FindObsidianCeiling; MaxY - 1: portal doesn't need corners
{
if (a_ChunkInterface.GetBlock(X, checkBorder, Z) != E_BLOCK_OBSIDIAN)
{
@ -115,10 +115,10 @@ public:
/// Finds entire frame in any direction with the coordinates of a base block and fills hole with nether portal (START HERE)
void FindAndSetPortalFrame(int X, int Y, int Z, cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface)
{
int MaxY = FindObsidianCeiling(X, Y, Z, a_ChunkInterface); // Get topmost obsidian block as reference for all other checks
int X1 = X + 1, Z1 = Z + 1, X2 = X - 1, Z2 = Z - 1; // Duplicate XZ values, add/subtract one as we've checked the original already the line above
int MaxY = FindObsidianCeiling(X, Y, Z, a_ChunkInterface); // Get topmost obsidian block as reference for all other checks
int X1 = X + 1, Z1 = Z + 1, X2 = X - 1, Z2 = Z - 1; // Duplicate XZ values, add/subtract one as we've checked the original already the line above
if (MaxY == 0) // Oh noes! Not a portal coordinate :(
if (MaxY == 0) // Oh noes! Not a portal coordinate :(
{
return;
}
@ -127,11 +127,11 @@ public:
{
if (!FindPortalSliceZ(X, Y, Z1, Z2, MaxY, a_ChunkInterface))
{
return; // No eligible portal construct, abort abort abort!!
return; // No eligible portal construct, abort abort abort!!
}
}
for (int Height = Y + 1; Height <= MaxY - 1; Height++) // Loop through boundary to set portal blocks
for (int Height = Y + 1; Height <= MaxY - 1; Height++) // Loop through boundary to set portal blocks
{
for (int Width = XZM; Width <= XZP; Width++)
{
@ -153,23 +153,23 @@ public:
/// Takes coordinates of base block and Y coord of target obsidian ceiling
bool FindPortalSliceX(int X1, int X2, int Y, int Z, int MaxY, cChunkInterface & a_ChunkInterface)
{
Dir = 1; // Set assumed direction (will change if portal turns out to be facing the other direction)
Dir = 1; // Set assumed direction (will change if portal turns out to be facing the other direction)
bool FoundFrameXP = false, FoundFrameXM = false;
for (; ((a_ChunkInterface.GetBlock(X1, Y, Z) == E_BLOCK_OBSIDIAN) || (a_ChunkInterface.GetBlock(X1, Y + 1, Z) == E_BLOCK_OBSIDIAN)); X1++) // Check XP for obsidian blocks, exempting corners
for (; ((a_ChunkInterface.GetBlock(X1, Y, Z) == E_BLOCK_OBSIDIAN) || (a_ChunkInterface.GetBlock(X1, Y + 1, Z) == E_BLOCK_OBSIDIAN)); X1++) // Check XP for obsidian blocks, exempting corners
{
int Value = FindObsidianCeiling(X1, Y, Z, a_ChunkInterface, MaxY);
int ValueTwo = FindObsidianCeiling(X1, Y + 1, Z, a_ChunkInterface, MaxY); // For corners without obsidian
if ((Value == -1) || (ValueTwo == -1)) // FindObsidianCeiling returns -1 upon frame-find
int ValueTwo = FindObsidianCeiling(X1, Y + 1, Z, a_ChunkInterface, MaxY); // For corners without obsidian
if ((Value == -1) || (ValueTwo == -1)) // FindObsidianCeiling returns -1 upon frame-find
{
FoundFrameXP = true; // Found a frame border in this direction, proceed in other direction (don't go further)
FoundFrameXP = true; // Found a frame border in this direction, proceed in other direction (don't go further)
break;
}
else if ((Value != MaxY) && (ValueTwo != MaxY)) // Make sure that there is a valid portal 'slice'
else if ((Value != MaxY) && (ValueTwo != MaxY)) // Make sure that there is a valid portal 'slice'
{
return false; // Not valid slice, no portal can be formed
return false; // Not valid slice, no portal can be formed
}
} XZP = X1 - 1; // Set boundary of frame interior
for (; ((a_ChunkInterface.GetBlock(X2, Y, Z) == E_BLOCK_OBSIDIAN) || (a_ChunkInterface.GetBlock(X2, Y + 1, Z) == E_BLOCK_OBSIDIAN)); X2--) // Go the other direction (XM)
} XZP = X1 - 1; // Set boundary of frame interior
for (; ((a_ChunkInterface.GetBlock(X2, Y, Z) == E_BLOCK_OBSIDIAN) || (a_ChunkInterface.GetBlock(X2, Y + 1, Z) == E_BLOCK_OBSIDIAN)); X2--) // Go the other direction (XM)
{
int Value = FindObsidianCeiling(X2, Y, Z, a_ChunkInterface, MaxY);
int ValueTwo = FindObsidianCeiling(X2, Y + 1, Z, a_ChunkInterface, MaxY);
@ -182,7 +182,7 @@ public:
{
return false;
}
} XZM = X2 + 1; // Set boundary, see previous
} XZM = X2 + 1; // Set boundary, see previous
return (FoundFrameXP && FoundFrameXM);
}

View File

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

View File

@ -13,7 +13,7 @@ class cBlockFurnaceHandler :
public cMetaRotator<cBlockEntityHandler, 0x07, 0x02, 0x05, 0x03, 0x04>
{
public:
cBlockFurnaceHandler(BLOCKTYPE a_BlockType)
cBlockFurnaceHandler(BLOCKTYPE a_BlockType)
: cMetaRotator<cBlockEntityHandler, 0x07, 0x02, 0x05, 0x03, 0x04>(a_BlockType)
{
}
@ -27,7 +27,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override

View File

@ -65,6 +65,8 @@
#include "BlockRedstoneRepeater.h"
#include "BlockRedstoneTorch.h"
#include "BlockTNT.h"
#include "BlockTripwire.h"
#include "BlockTripwireHook.h"
#include "BlockSand.h"
#include "BlockSapling.h"
#include "BlockSideways.h"
@ -209,7 +211,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_EMERALD_ORE: return new cBlockOreHandler (a_BlockType);
case E_BLOCK_ENCHANTMENT_TABLE: return new cBlockEnchantmentTableHandler(a_BlockType);
case E_BLOCK_ENDER_CHEST: return new cBlockEnderchestHandler (a_BlockType);
case E_BLOCK_FARMLAND: return new cBlockFarmlandHandler ( );
case E_BLOCK_FARMLAND: return new cBlockFarmlandHandler (a_BlockType);
case E_BLOCK_FENCE_GATE: return new cBlockFenceGateHandler (a_BlockType);
case E_BLOCK_FIRE: return new cBlockFireHandler (a_BlockType);
case E_BLOCK_FLOWER_POT: return new cBlockFlowerPotHandler (a_BlockType);
@ -236,9 +238,9 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_LAPIS_ORE: return new cBlockOreHandler (a_BlockType);
case E_BLOCK_LAVA: return new cBlockLavaHandler (a_BlockType);
case E_BLOCK_LEAVES: return new cBlockLeavesHandler (a_BlockType);
case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE: return new cBlockPressurePlateHandler(a_BlockType);
case E_BLOCK_LILY_PAD: return new cBlockLilypadHandler (a_BlockType);
case E_BLOCK_LIT_FURNACE: return new cBlockFurnaceHandler (a_BlockType);
case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE: return new cBlockPressurePlateHandler(a_BlockType);
case E_BLOCK_LOG: return new cBlockSidewaysHandler (a_BlockType);
case E_BLOCK_MELON: return new cBlockMelonHandler (a_BlockType);
case E_BLOCK_MELON_STEM: return new cBlockStemsHandler (a_BlockType);
@ -291,6 +293,9 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_TORCH: return new cBlockTorchHandler (a_BlockType);
case E_BLOCK_TRAPDOOR: return new cBlockTrapdoorHandler (a_BlockType);
case E_BLOCK_TNT: return new cBlockTNTHandler (a_BlockType);
case E_BLOCK_TRAPPED_CHEST: return new cBlockChestHandler (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_WATER: return new cBlockFluidHandler (a_BlockType);
@ -322,7 +327,7 @@ cBlockHandler::cBlockHandler(BLOCKTYPE a_BlockType)
bool cBlockHandler::GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
)

View File

@ -30,14 +30,14 @@ public:
/// Note that the coords are chunk-relative!
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ);
/** Called before a block is placed into a world.
/** Called before a block is placed into a world.
The handler should return true to allow placement, false to refuse.
Also, the handler should set a_BlockType and a_BlockMeta to correct values for the newly placed block.
Called by cItemHandler::GetPlacementBlockTypeMeta() if the item is a block
*/
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
);
@ -47,8 +47,8 @@ public:
/// Called by cClientHandle::HandlePlaceBlock() after the player has placed a new block. Called after OnPlaced().
virtual void OnPlacedByPlayer(
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
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
);
@ -90,7 +90,7 @@ public:
virtual bool CanDirtGrowGrass(NIBBLETYPE a_Meta);
/** Checks if the block can be placed at this point.
Default: CanBeAt(...)
Default: CanBeAt(...)
NOTE: This call doesn't actually place the block
*/
// virtual bool CanBePlacedAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir);
@ -98,27 +98,27 @@ public:
/// Called to check whether this block supports a rclk action. If it returns true, OnUse() is called
virtual bool IsUseable(void);
/** Indicates whether the client will click through this block.
/** Indicates whether the client will click through this block.
For example digging a fire will hit the block below the fire so fire is clicked through
*/
virtual bool IsClickedThrough(void);
/** Checks if the player can build "inside" this block.
/** Checks if the player can build "inside" this block.
For example blocks placed "on" snow will be placed at the same position. So: Snow ignores Build collision
*/
virtual bool DoesIgnoreBuildCollision(void);
/// <summary>Similar to DoesIgnoreBuildCollision(void), but is used for cases where block meta/player item-in-hand is needed to determine collision (thin snow)</summary>
virtual bool DoesIgnoreBuildCollision(cPlayer *, NIBBLETYPE a_Meta)
{
virtual bool DoesIgnoreBuildCollision(cPlayer *, NIBBLETYPE a_Meta)
{
UNUSED(a_Meta);
return DoesIgnoreBuildCollision();
return DoesIgnoreBuildCollision();
}
/// <summary>Returns if this block drops if it gets destroyed by an unsuitable situation. Default: true</summary>
virtual bool DoesDropOnUnsuitable(void);
/** Called when one of the neighbors gets set; equivalent to MC block update.
/** Called when one of the neighbors gets set; equivalent to MC block update.
By default drops if position no more suitable (CanBeAt(), DoesDropOnUnsuitable(), Drop()),
and wakes up all simulators on the block.
*/

View File

@ -1,7 +1,6 @@
#pragma once
#include "BlockHandler.h"
#include "BlockSideways.h"

View File

@ -19,7 +19,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override

View File

@ -29,7 +29,7 @@ public:
// TODO: Ice destroyed with air below it should turn into air instead of water
a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_WATER, 0);
// This is called later than the real destroying of this ice block
}
}
} ;

View File

@ -3,24 +3,26 @@
#include "BlockHandler.h"
#include "../World.h"
#include "ClearMetaOnDrop.h"
class cBlockLadderHandler :
public cMetaRotator<cBlockHandler, 0x07, 0x02, 0x05, 0x03, 0x04>
public cClearMetaOnDrop<cMetaRotator<cBlockHandler, 0x07, 0x02, 0x05, 0x03, 0x04> >
{
typedef cClearMetaOnDrop<cMetaRotator<cBlockHandler, 0x07, 0x02, 0x05, 0x03, 0x04> > super;
public:
cBlockLadderHandler(BLOCKTYPE a_BlockType)
: cMetaRotator<cBlockHandler, 0x07, 0x02, 0x05, 0x03, 0x04>(a_BlockType)
: super(a_BlockType)
{
}
}
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
@ -41,21 +43,27 @@ public:
}
static NIBBLETYPE DirectionToMetaData(eBlockFace a_Direction) // tolua_export
{ // tolua_export
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
a_Pickups.Add(m_BlockType, 1, 0); // Reset meta
}
static NIBBLETYPE DirectionToMetaData(eBlockFace a_Direction)
{
switch (a_Direction)
{
case BLOCK_FACE_ZM: return 0x2;
case BLOCK_FACE_ZP: return 0x3;
case BLOCK_FACE_XM: return 0x4;
case BLOCK_FACE_XP: return 0x5;
default: return 0x2;
default: return 0x2;
}
} // tolua_export
}
static eBlockFace MetaDataToDirection(NIBBLETYPE a_MetaData) // tolua_export
{ // tolua_export
static eBlockFace MetaDataToDirection(NIBBLETYPE a_MetaData)
{
switch (a_MetaData)
{
case 0x2: return BLOCK_FACE_ZM;
@ -64,10 +72,10 @@ public:
case 0x5: return BLOCK_FACE_XP;
default: return BLOCK_FACE_ZM;
}
} // tolua_export
}
/// Finds a suitable Direction for the Ladder. Returns BLOCK_FACE_BOTTOM on failure
/** Finds a suitable Direction for the Ladder. Returns BLOCK_FACE_BOTTOM on failure */
static eBlockFace FindSuitableBlockFace(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ)
{
for (int FaceInt = BLOCK_FACE_ZM; FaceInt <= BLOCK_FACE_XP; FaceInt++)

View File

@ -76,7 +76,7 @@ public:
virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) override
{
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta & 0x7); // Unset 0x8 bit so it gets checked for decay
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta & 0x7); // Unset 0x8 bit so it gets checked for decay
}
@ -100,10 +100,10 @@ public:
int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
cBlockArea Area;
if (!Area.Read(
a_Chunk.GetWorld(),
BlockX - LEAVES_CHECK_DISTANCE, BlockX + LEAVES_CHECK_DISTANCE,
a_RelY - LEAVES_CHECK_DISTANCE, a_RelY + LEAVES_CHECK_DISTANCE,
BlockZ - LEAVES_CHECK_DISTANCE, BlockZ + LEAVES_CHECK_DISTANCE,
a_Chunk.GetWorld(),
BlockX - LEAVES_CHECK_DISTANCE, BlockX + LEAVES_CHECK_DISTANCE,
a_RelY - LEAVES_CHECK_DISTANCE, a_RelY + LEAVES_CHECK_DISTANCE,
BlockZ - LEAVES_CHECK_DISTANCE, BlockZ + LEAVES_CHECK_DISTANCE,
cBlockArea::baTypes)
)
{

View File

@ -22,8 +22,9 @@ public:
// Flip the ON bit on/off using the XOR bitwise operation
NIBBLETYPE Meta = (a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) ^ 0x08);
a_ChunkInterface.SetBlock(a_WorldInterface, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_LEVER, Meta); // SetMeta doesn't work for unpowering levers, so setblock
a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("random.click", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, (Meta & 0x08) ? 0.6f : 0.5f);
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
a_WorldInterface.WakeUpSimulators(a_BlockX, a_BlockY, a_BlockZ);
a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("random.click", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 0.5f, (Meta & 0x08) ? 0.6f : 0.5f);
}
@ -42,7 +43,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
@ -104,7 +105,7 @@ public:
AddFaceDirection(a_RelX, a_RelY, a_RelZ, BlockMetaDataToBlockFace(Meta), true);
BLOCKTYPE BlockIsOn; a_Chunk.UnboundedRelGetBlockType(a_RelX, a_RelY, a_RelZ, BlockIsOn);
return (a_RelY > 0) && cBlockInfo::IsSolid(BlockIsOn);
return (a_RelY > 0) && cBlockInfo::FullyOccupiesVoxel(BlockIsOn);
}

View File

@ -8,19 +8,15 @@
class cBlockLilypadHandler :
public cBlockHandler
public cClearMetaOnDrop<cBlockHandler>
{
typedef cClearMetaOnDrop<cBlockHandler> super;
public:
cBlockLilypadHandler(BLOCKTYPE a_BlockType)
: cBlockHandler(a_BlockType)
cBlockLilypadHandler(BLOCKTYPE a_BlockType) :
super(a_BlockType)
{
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
// Reset meta to zero
a_Pickups.push_back(cItem(E_BLOCK_LILY_PAD, 1, 0));
}
};

View File

@ -193,8 +193,8 @@ public:
}
virtual void OnPlacedByPlayer(
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
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

View File

@ -62,7 +62,7 @@ void cBlockPistonHandler::OnDestroyed(cChunkInterface & a_ChunkInterface, cWorld
bool cBlockPistonHandler::GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
)
@ -85,7 +85,7 @@ int cBlockPistonHandler::FirstPassthroughBlock(int a_PistonX, int a_PistonY, int
NIBBLETYPE currMeta;
AddPistonDir(a_PistonX, a_PistonY, a_PistonZ, pistonmeta, 1);
a_World->GetBlockTypeMeta(a_PistonX, a_PistonY, a_PistonZ, currBlock, currMeta);
if (CanBreakPush(currBlock))
if (cBlockInfo::IsPistonBreakable(currBlock))
{
// This block breaks when pushed, extend up to here
return ret;
@ -124,7 +124,7 @@ void cBlockPistonHandler::ExtendPiston(int a_BlockX, int a_BlockY, int a_BlockZ,
}
a_World->BroadcastBlockAction(a_BlockX, a_BlockY, a_BlockZ, 0, pistonMeta, pistonBlock);
a_World->BroadcastSoundEffect("tile.piston.out", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, 0.7f);
a_World->BroadcastSoundEffect("tile.piston.out", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 0.5f, 0.7f);
// Drop the breakable block in the line, if appropriate:
AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, dist + 1); // "a_Block" now at the breakable / empty block
@ -198,7 +198,7 @@ void cBlockPistonHandler::RetractPiston(int a_BlockX, int a_BlockY, int a_BlockZ
AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, -1);
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, pistonBlock, pistonMeta & ~(8));
a_World->BroadcastBlockAction(a_BlockX, a_BlockY, a_BlockZ, 1, pistonMeta & ~(8), pistonBlock);
a_World->BroadcastSoundEffect("tile.piston.in", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, 0.7f);
a_World->BroadcastSoundEffect("tile.piston.in", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 0.5f, 0.7f);
AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, 1);
// Retract the extension, pull block if appropriate
@ -235,7 +235,7 @@ void cBlockPistonHandler::RetractPiston(int a_BlockX, int a_BlockY, int a_BlockZ
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// cBlockPistonHeadHandler:
cBlockPistonHeadHandler::cBlockPistonHeadHandler(void) :
@ -262,7 +262,7 @@ void cBlockPistonHeadHandler::OnDestroyedByPlayer(cChunkInterface & a_ChunkInter
a_ChunkInterface.DigBlock(a_WorldInterface, newX, newY, newZ);
if (a_Player->IsGameModeCreative())
{
return; // No pickups if creative
return; // No pickups if creative
}
cItems Pickups;

View File

@ -17,7 +17,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override;
@ -75,7 +75,7 @@ public:
return BLOCK_FACE_NONE;
}
}
}
}
static void ExtendPiston(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
static void RetractPiston(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
@ -94,7 +94,6 @@ private:
switch (a_BlockType)
{
case E_BLOCK_ANVIL:
case E_BLOCK_BED:
case E_BLOCK_BEDROCK:
case E_BLOCK_BREWING_STAND:
case E_BLOCK_CHEST:
@ -104,6 +103,7 @@ private:
case E_BLOCK_ENCHANTMENT_TABLE:
case E_BLOCK_END_PORTAL:
case E_BLOCK_END_PORTAL_FRAME:
// Notice the lack of an E_BLOCK_ENDER_CHEST here; its because ender chests can totally be pushed/pulled in MCS :)
case E_BLOCK_FURNACE:
case E_BLOCK_LIT_FURNACE:
case E_BLOCK_HOPPER:
@ -113,6 +113,7 @@ private:
case E_BLOCK_NOTE_BLOCK:
case E_BLOCK_OBSIDIAN:
case E_BLOCK_PISTON_EXTENSION:
case E_BLOCK_TRAPPED_CHEST:
{
return false;
}
@ -126,26 +127,12 @@ private:
return true;
}
/// Returns true if the specified block can be pushed by a piston and broken / replaced
static inline bool CanBreakPush(BLOCKTYPE a_BlockType) { return cBlockInfo::IsPistonBreakable(a_BlockType); }
/// Returns true if the specified block can be pulled by a sticky piston
static inline bool CanPull(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
switch (a_BlockType)
if (cBlockInfo::IsPistonBreakable(a_BlockType))
{
case E_BLOCK_LAVA:
case E_BLOCK_STATIONARY_LAVA:
case E_BLOCK_STATIONARY_WATER:
case E_BLOCK_WATER:
{
return false;
}
}
if (CanBreakPush(a_BlockType))
{
return false; // CanBreakPush returns true, but we need false to prevent pulling
return false; // CanBreakPush returns true, but we need false to prevent pulling
}
return CanPush(a_BlockType, a_BlockMeta);

View File

@ -18,7 +18,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override

View File

@ -19,7 +19,7 @@ public:
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
@ -36,7 +36,7 @@ public:
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
return; // No pickups
return; // No pickups
}
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
@ -57,7 +57,7 @@ public:
{
if ((a_RelY == 0) || (a_RelY == cChunkDef::Height)) // Y can't be < 0 or > Height; (Fast)SetBlock won't allow it
{
return false; // In case someone places a portal with meta 1 or 2 at boundaries, and server tries to get invalid coords at Y - 1 or Y + 1
return false; // In case someone places a portal with meta 1 or 2 at boundaries, and server tries to get invalid coords at Y - 1 or Y + 1
}
switch (a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ))

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