summaryrefslogtreecommitdiffstats
path: root/src/Bindings
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-10-23 08:40:39 +0200
committerMattes D <github@xoft.cz>2014-10-23 08:40:39 +0200
commitf8c54f4243049abbcafff1e96f994f742ea9f50d (patch)
tree67fe10bfea90cbb21952039bd795666682d43ad5 /src/Bindings
parentCompile fix? (diff)
parentMerge pull request #1559 from mc-server/nullptr (diff)
downloadcuberite-f8c54f4243049abbcafff1e96f994f742ea9f50d.tar
cuberite-f8c54f4243049abbcafff1e96f994f742ea9f50d.tar.gz
cuberite-f8c54f4243049abbcafff1e96f994f742ea9f50d.tar.bz2
cuberite-f8c54f4243049abbcafff1e96f994f742ea9f50d.tar.lz
cuberite-f8c54f4243049abbcafff1e96f994f742ea9f50d.tar.xz
cuberite-f8c54f4243049abbcafff1e96f994f742ea9f50d.tar.zst
cuberite-f8c54f4243049abbcafff1e96f994f742ea9f50d.zip
Diffstat (limited to 'src/Bindings')
-rw-r--r--src/Bindings/AllToLua.pkg14
-rw-r--r--src/Bindings/CMakeLists.txt208
-rw-r--r--src/Bindings/LuaState.cpp55
3 files changed, 166 insertions, 111 deletions
diff --git a/src/Bindings/AllToLua.pkg b/src/Bindings/AllToLua.pkg
index 73de98e22..1bff26b0e 100644
--- a/src/Bindings/AllToLua.pkg
+++ b/src/Bindings/AllToLua.pkg
@@ -33,15 +33,27 @@ $cfile "../StringUtils.h"
$cfile "../Defines.h"
$cfile "../ChatColor.h"
$cfile "../ClientHandle.h"
+$cfile "../Entities/ArrowEntity.h"
$cfile "../Entities/Entity.h"
+$cfile "../Entities/EntityEffect.h"
+$cfile "../Entities/ExpBottleEntity.h"
+$cfile "../Entities/FireChargeEntity.h"
+$cfile "../Entities/FireworkEntity.h"
$cfile "../Entities/Floater.h"
+$cfile "../Entities/GhastFireballEntity.h"
+$cfile "../Entities/HangingEntity.h"
+$cfile "../Entities/ItemFrame.h"
$cfile "../Entities/Pawn.h"
$cfile "../Entities/Player.h"
$cfile "../Entities/Painting.h"
$cfile "../Entities/Pickup.h"
$cfile "../Entities/ProjectileEntity.h"
+$cfile "../Entities/SplashPotionEntity.h"
+$cfile "../Entities/ThrownEggEntity.h"
+$cfile "../Entities/ThrownEnderPearlEntity.h"
+$cfile "../Entities/ThrownSnowballEntity.h"
$cfile "../Entities/TNTEntity.h"
-$cfile "../Entities/EntityEffect.h"
+$cfile "../Entities/WitherSkullEntity.h"
$cfile "../Server.h"
$cfile "../World.h"
$cfile "../Inventory.h"
diff --git a/src/Bindings/CMakeLists.txt b/src/Bindings/CMakeLists.txt
index 5c56231c6..d47579cd6 100644
--- a/src/Bindings/CMakeLists.txt
+++ b/src/Bindings/CMakeLists.txt
@@ -5,131 +5,133 @@ include_directories ("${PROJECT_SOURCE_DIR}/../")
include_directories (".")
SET (SRCS
- Bindings.cpp
- DeprecatedBindings.cpp
- LuaChunkStay.cpp
- LuaState.cpp
- LuaWindow.cpp
- ManualBindings.cpp
- ManualBindings_RankManager.cpp
- Plugin.cpp
- PluginLua.cpp
- PluginManager.cpp
- WebPlugin.cpp
+ Bindings.cpp
+ DeprecatedBindings.cpp
+ LuaChunkStay.cpp
+ LuaState.cpp
+ LuaWindow.cpp
+ ManualBindings.cpp
+ ManualBindings_RankManager.cpp
+ Plugin.cpp
+ PluginLua.cpp
+ PluginManager.cpp
+ WebPlugin.cpp
)
SET (HDRS
- Bindings.h
- DeprecatedBindings.h
- LuaChunkStay.h
- LuaFunctions.h
- LuaState.h
- LuaWindow.h
- ManualBindings.h
- Plugin.h
- PluginLua.h
- PluginManager.h
- WebPlugin.h
- tolua++.h
+ Bindings.h
+ DeprecatedBindings.h
+ LuaChunkStay.h
+ LuaFunctions.h
+ LuaState.h
+ LuaWindow.h
+ ManualBindings.h
+ Plugin.h
+ PluginLua.h
+ PluginManager.h
+ WebPlugin.h
+ tolua++.h
)
# List all the files that are generated as part of the Bindings build process
set (BINDING_OUTPUTS
- ${CMAKE_CURRENT_SOURCE_DIR}/Bindings.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/Bindings.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/Bindings.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/Bindings.h
)
set(BINDING_DEPENDENCIES
- tolua
- ../Bindings/virtual_method_hooks.lua
- ../Bindings/AllToLua.pkg
- ../Bindings/LuaFunctions.h
- ../Bindings/LuaWindow.h
- ../Bindings/Plugin.h
- ../Bindings/PluginLua.h
- ../Bindings/PluginManager.h
- ../Bindings/WebPlugin.h
- ../BiomeDef.h
- ../BlockArea.h
+ tolua
+ ../Bindings/virtual_method_hooks.lua
+ ../Bindings/AllToLua.pkg
+ ../Bindings/LuaFunctions.h
+ ../Bindings/LuaWindow.h
+ ../Bindings/Plugin.h
+ ../Bindings/PluginLua.h
+ ../Bindings/PluginManager.h
+ ../Bindings/WebPlugin.h
+ ../BiomeDef.h
+ ../BlockArea.h
../BlockEntities/BeaconEntity.h
- ../BlockEntities/BlockEntity.h
- ../BlockEntities/BlockEntityWithItems.h
- ../BlockEntities/ChestEntity.h
- ../BlockEntities/DispenserEntity.h
- ../BlockEntities/DropSpenserEntity.h
- ../BlockEntities/DropperEntity.h
- ../BlockEntities/FurnaceEntity.h
- ../BlockEntities/HopperEntity.h
- ../BlockEntities/JukeboxEntity.h
- ../BlockEntities/NoteEntity.h
- ../BlockEntities/SignEntity.h
- ../BlockEntities/MobHeadEntity.h
- ../BlockEntities/FlowerPotEntity.h
- ../BlockID.h
- ../BoundingBox.h
- ../ChatColor.h
- ../ChunkDef.h
- ../ClientHandle.h
- ../CraftingRecipes.h
- ../Cuboid.h
- ../Defines.h
- ../Enchantments.h
- ../Entities/EntityEffect.h
- ../Entities/Entity.h
- ../Entities/Floater.h
- ../Entities/Pawn.h
- ../Entities/Painting.h
- ../Entities/Pickup.h
- ../Entities/Player.h
- ../Entities/ProjectileEntity.h
- ../Entities/ArrowEntity.h
- ../Entities/ThrownEggEntity.h
- ../Entities/ThrownEnderPearlEntity.h
- ../Entities/ExpBottleEntity.h
- ../Entities/ThrownSnowballEntity.h
- ../Entities/FireChargeEntity.h
- ../Entities/FireworkEntity.h
- ../Entities/GhastFireballEntity.h
- ../Entities/TNTEntity.h
- ../Entities/ExpOrb.h
- ../Entities/HangingEntity.h
- ../Entities/ItemFrame.h
- ../Generating/ChunkDesc.h
- ../Inventory.h
- ../Item.h
- ../ItemGrid.h
- ../Mobs/Monster.h
- ../OSSupport/File.h
- ../Root.h
- ../Server.h
- ../StringUtils.h
- ../Tracer.h
- ../UI/Window.h
- ../Vector3.h
- ../WebAdmin.h
- ../World.h
+ ../BlockEntities/BlockEntity.h
+ ../BlockEntities/BlockEntityWithItems.h
+ ../BlockEntities/ChestEntity.h
+ ../BlockEntities/DispenserEntity.h
+ ../BlockEntities/DropSpenserEntity.h
+ ../BlockEntities/DropperEntity.h
+ ../BlockEntities/FurnaceEntity.h
+ ../BlockEntities/HopperEntity.h
+ ../BlockEntities/JukeboxEntity.h
+ ../BlockEntities/NoteEntity.h
+ ../BlockEntities/SignEntity.h
+ ../BlockEntities/MobHeadEntity.h
+ ../BlockEntities/FlowerPotEntity.h
+ ../BlockID.h
+ ../BoundingBox.h
+ ../ChatColor.h
+ ../ChunkDef.h
+ ../ClientHandle.h
+ ../CraftingRecipes.h
+ ../Cuboid.h
+ ../Defines.h
+ ../Enchantments.h
+ ../Entities/ArrowEntity.h
+ ../Entities/Entity.h
+ ../Entities/EntityEffect.h
+ ../Entities/ExpBottleEntity.h
+ ../Entities/FireChargeEntity.h
+ ../Entities/FireworkEntity.h
+ ../Entities/Floater.h
+ ../Entities/GhastFireballEntity.h
+ ../Entities/HangingEntity.h
+ ../Entities/ItemFrame.h
+ ../Entities/Pawn.h
+ ../Entities/Player.h
+ ../Entities/Painting.h
+ ../Entities/Pickup.h
+ ../Entities/ProjectileEntity.h
+ ../Entities/SplashPotionEntity.h
+ ../Entities/ThrownEggEntity.h
+ ../Entities/ThrownEnderPearlEntity.h
+ ../Entities/ThrownSnowballEntity.h
+ ../Entities/TNTEntity.h
+ ../Entities/WitherSkullEntity.h
+ ../Generating/ChunkDesc.h
+ ../Inventory.h
+ ../Item.h
+ ../ItemGrid.h
+ ../Mobs/Monster.h
+ ../OSSupport/File.h
+ ../Root.h
+ ../Server.h
+ ../StringUtils.h
+ ../Tracer.h
+ ../UI/Window.h
+ ../Vector3.h
+ ../WebAdmin.h
+ ../World.h
)
if (NOT MSVC)
- ADD_CUSTOM_COMMAND(
- # add any new generated bindings here
- OUTPUT ${BINDING_OUTPUTS}
+ ADD_CUSTOM_COMMAND(
+ # add any new generated bindings here
+ OUTPUT ${BINDING_OUTPUTS}
- # Regenerate bindings:
- COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ # Regenerate bindings:
+ COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- # add any new generation dependencies here
- DEPENDS ${BINDING_DEPENDENCIES}
- )
+ # add any new generation dependencies here
+ DEPENDS ${BINDING_DEPENDENCIES}
+ )
endif ()
+
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.cpp PROPERTIES GENERATED TRUE)
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.h PROPERTIES GENERATED TRUE)
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.cpp PROPERTIES COMPILE_FLAGS -Wno-error)
if(NOT MSVC)
- add_library(Bindings ${SRCS} ${HDRS})
+ add_library(Bindings ${SRCS} ${HDRS})
- target_link_libraries(Bindings lua sqlite tolualib polarssl)
+ target_link_libraries(Bindings lua sqlite tolualib polarssl)
endif()
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp
index 3b4ce3376..2f5d173fd 100644
--- a/src/Bindings/LuaState.cpp
+++ b/src/Bindings/LuaState.cpp
@@ -562,16 +562,57 @@ void cLuaState::Push(cEntity * a_Entity)
{
lua_pushnil(m_LuaState);
}
- else if (a_Entity->IsMob())
- {
- // Don't push specific mob types, as those are not exported in the API:
- tolua_pushusertype(m_LuaState, a_Entity, "cMonster");
- }
else
{
- // Push the specific class type:
- tolua_pushusertype(m_LuaState, a_Entity, a_Entity->GetClass());
+ switch (a_Entity->GetEntityType())
+ {
+ case cEntity::etMonster:
+ {
+ // Don't push specific mob types, as those are not exported in the API:
+ tolua_pushusertype(m_LuaState, a_Entity, "cMonster");
+ break;
+ }
+ case cEntity::etPlayer:
+ {
+ tolua_pushusertype(m_LuaState, a_Entity, "cPlayer");
+ break;
+ }
+ case cEntity::etPickup:
+ {
+ tolua_pushusertype(m_LuaState, a_Entity, "cPickup");
+ break;
+ }
+ case cEntity::etTNT:
+ {
+ tolua_pushusertype(m_LuaState, a_Entity, "cTNTEntity");
+ break;
+ }
+ case cEntity::etProjectile:
+ {
+ tolua_pushusertype(m_LuaState, a_Entity, a_Entity->GetClass());
+ break;
+ }
+ case cEntity::etFloater:
+ {
+ tolua_pushusertype(m_LuaState, a_Entity, "cFloater");
+ break;
+ }
+
+ case cEntity::etEntity:
+ case cEntity::etEnderCrystal:
+ case cEntity::etFallingBlock:
+ case cEntity::etMinecart:
+ case cEntity::etBoat:
+ case cEntity::etExpOrb:
+ case cEntity::etItemFrame:
+ case cEntity::etPainting:
+ {
+ // Push the generic entity class type:
+ tolua_pushusertype(m_LuaState, a_Entity, "cEntity");
+ }
+ } // switch (EntityType)
}
+
m_NumCurrentFunctionArgs += 1;
}