summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Bindings/AllToLua.pkg81
-rw-r--r--src/Bindings/LuaWindow.h6
-rw-r--r--src/Bindings/ManualBindings.cpp8
-rw-r--r--src/BlockEntities/BlockEntityWithItems.h2
-rw-r--r--src/Inventory.h2
-rw-r--r--src/Map.h5
-rw-r--r--src/Simulator/FloodyFluidSimulator.cpp3
-rw-r--r--src/WebAdmin.h2
-rw-r--r--src/World.cpp25
-rw-r--r--src/main.cpp4
10 files changed, 90 insertions, 48 deletions
diff --git a/src/Bindings/AllToLua.pkg b/src/Bindings/AllToLua.pkg
index 7e174e770..8f55eba07 100644
--- a/src/Bindings/AllToLua.pkg
+++ b/src/Bindings/AllToLua.pkg
@@ -1,4 +1,19 @@
+// AllToLua.pkg
+
+// Defines the bindings that are exported to Lua by the ToLua processor
+
+/*
+ Each file referenced in the $cfile is parsed by ToLua, and bindings are generated for classes and functions
+marked with "// tolua_export", or between the "// tolua_begin" and "// tolua_end" markers.
+
+ Note that if class D inherits from class B, then class B needs to be parsed before class D, otherwise the
+inheritance doesn't work properly (#1789).
+*/
+
+
+
+
$#include "../Globals.h"
// Typedefs from Globals.h, so that we don't have to process that file:
@@ -27,14 +42,38 @@ $cfile "WebPlugin.h"
$cfile "LuaWindow.h"
$cfile "../BlockID.h"
-$cfile "../Mobs/MonsterTypes.h"
$cfile "../BlockInfo.h"
$cfile "../StringUtils.h"
$cfile "../Defines.h"
$cfile "../ChatColor.h"
$cfile "../ClientHandle.h"
-$cfile "../Entities/ArrowEntity.h"
+$cfile "../Server.h"
+$cfile "../World.h"
+$cfile "../Inventory.h"
+$cfile "../Enchantments.h"
+$cfile "../Item.h"
+$cfile "../ItemGrid.h"
+$cfile "../WebAdmin.h"
+$cfile "../Root.h"
+$cfile "../Cuboid.h"
+$cfile "../BoundingBox.h"
+$cfile "../Tracer.h"
+$cfile "../BlockArea.h"
+$cfile "../Generating/ChunkDesc.h"
+$cfile "../CraftingRecipes.h"
+$cfile "../UI/Window.h"
+$cfile "../CompositeChat.h"
+$cfile "../Map.h"
+$cfile "../MapManager.h"
+$cfile "../Scoreboard.h"
+$cfile "../Statistics.h"
+$cfile "../Protocol/MojangAPI.h"
+
+// Entities:
$cfile "../Entities/Entity.h"
+$cfile "../Entities/Pawn.h"
+$cfile "../Entities/ProjectileEntity.h"
+$cfile "../Entities/ArrowEntity.h"
$cfile "../Entities/EntityEffect.h"
$cfile "../Entities/ExpBottleEntity.h"
$cfile "../Entities/FireChargeEntity.h"
@@ -43,25 +82,21 @@ $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/WitherSkullEntity.h"
-$cfile "../Server.h"
-$cfile "../World.h"
-$cfile "../Inventory.h"
-$cfile "../Enchantments.h"
-$cfile "../Item.h"
-$cfile "../ItemGrid.h"
-$cfile "../BlockEntities/BeaconEntity.h"
+$cfile "../Mobs/MonsterTypes.h"
+$cfile "../Mobs/Monster.h"
+
+// Block entities:
$cfile "../BlockEntities/BlockEntity.h"
+$cfile "../BlockEntities/BeaconEntity.h"
$cfile "../BlockEntities/BlockEntityWithItems.h"
$cfile "../BlockEntities/ChestEntity.h"
$cfile "../BlockEntities/CommandBlockEntity.h"
@@ -76,30 +111,6 @@ $cfile "../BlockEntities/SignEntity.h"
$cfile "../BlockEntities/MobHeadEntity.h"
$cfile "../BlockEntities/MobSpawnerEntity.h"
$cfile "../BlockEntities/FlowerPotEntity.h"
-$cfile "../WebAdmin.h"
-$cfile "../Root.h"
-$cfile "../Cuboid.h"
-$cfile "../BoundingBox.h"
-$cfile "../Tracer.h"
-$cfile "../BlockArea.h"
-$cfile "../Generating/ChunkDesc.h"
-$cfile "../CraftingRecipes.h"
-$cfile "../UI/Window.h"
-$cfile "../Mobs/Monster.h"
-$cfile "../CompositeChat.h"
-$cfile "../Map.h"
-$cfile "../MapManager.h"
-$cfile "../Scoreboard.h"
-$cfile "../Statistics.h"
-$cfile "../Protocol/MojangAPI.h"
-
-
-
-
-
-// Need to declare this class so that the usertype is properly registered in Bindings.cpp -
-// it seems impossible to register a usertype in ManualBindings.cpp
-class cLineBlockTracer;
diff --git a/src/Bindings/LuaWindow.h b/src/Bindings/LuaWindow.h
index 76530d99d..d4fc58660 100644
--- a/src/Bindings/LuaWindow.h
+++ b/src/Bindings/LuaWindow.h
@@ -35,8 +35,10 @@ This reference needs to be unreferenced in the Destroy() function.
*/
// tolua_begin
class cLuaWindow :
- public cWindow,
- public cItemGrid::cListener
+ public cWindow
+ // tolua_end
+ , public cItemGrid::cListener
+ // tolua_begin
{
typedef cWindow super;
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp
index 40ac12b41..035be55ae 100644
--- a/src/Bindings/ManualBindings.cpp
+++ b/src/Bindings/ManualBindings.cpp
@@ -638,11 +638,11 @@ static int tolua_DoWithID(lua_State* tolua_S)
private:
virtual bool Item(Ty2 * a_Item) override
{
- lua_rawgeti(LuaState, LUA_REGISTRYINDEX, FuncRef); // Push function to call
- tolua_pushusertype(LuaState, a_Item, Ty2::GetClassStatic()); // Push the item
+ lua_rawgeti(LuaState, LUA_REGISTRYINDEX, FuncRef); // Push function to call
+ tolua_pushusertype(LuaState, a_Item, a_Item->GetClass()); // Push the item
if (TableRef != LUA_REFNIL)
{
- lua_rawgeti(LuaState, LUA_REGISTRYINDEX, TableRef); // Push the optional callbackdata param
+ lua_rawgeti(LuaState, LUA_REGISTRYINDEX, TableRef); // Push the optional callbackdata param
}
int s = lua_pcall(LuaState, (TableRef == LUA_REFNIL ? 1 : 2), 1, 0);
@@ -3677,6 +3677,8 @@ void ManualBindings::Bind(lua_State * tolua_S)
tolua_cclass(tolua_S, "cCryptoHash", "cCryptoHash", "", nullptr);
tolua_usertype(tolua_S, "cStringCompression");
tolua_cclass(tolua_S, "cStringCompression", "cStringCompression", "", nullptr);
+ tolua_usertype(tolua_S, "cLineBlockTracer");
+ tolua_cclass(tolua_S, "cLineBlockTracer", "cLineBlockTracer", "", nullptr);
// Globals:
tolua_function(tolua_S, "Clamp", tolua_Clamp);
diff --git a/src/BlockEntities/BlockEntityWithItems.h b/src/BlockEntities/BlockEntityWithItems.h
index 2c2ced1cb..740dbca51 100644
--- a/src/BlockEntities/BlockEntityWithItems.h
+++ b/src/BlockEntities/BlockEntityWithItems.h
@@ -21,7 +21,9 @@
// tolua_begin
class cBlockEntityWithItems :
public cBlockEntity,
+ // tolua_end
public cItemGrid::cListener,
+ // tolua_begin
public cBlockEntityWindowOwner
{
typedef cBlockEntity super;
diff --git a/src/Inventory.h b/src/Inventory.h
index 4e76bc0d3..311f64562 100644
--- a/src/Inventory.h
+++ b/src/Inventory.h
@@ -31,7 +31,9 @@ You can use the invArmorOffset, invInventoryOffset and invHotbarOffset constants
*/
class cInventory :
+ // tolua_end
public cItemGrid::cListener
+ // tolua_begin
{
public:
diff --git a/src/Map.h b/src/Map.h
index fe324a5e7..3e775231a 100644
--- a/src/Map.h
+++ b/src/Map.h
@@ -189,6 +189,11 @@ public:
return "cMap";
}
+ const char * GetClass(void) // Needed for ManualBindings' DoWith templates
+ {
+ return "cMap";
+ }
+
protected:
diff --git a/src/Simulator/FloodyFluidSimulator.cpp b/src/Simulator/FloodyFluidSimulator.cpp
index bcd083294..a9481edb0 100644
--- a/src/Simulator/FloodyFluidSimulator.cpp
+++ b/src/Simulator/FloodyFluidSimulator.cpp
@@ -108,8 +108,9 @@ void cFloodyFluidSimulator::SimulateBlock(cChunk * a_Chunk, int a_RelX, int a_Re
{
SpreadXZ(a_Chunk, a_RelX, a_RelY, a_RelZ, NewMeta);
}
+
// If source creation is on, check for it here:
- else if (
+ if (
(m_NumNeighborsForSource > 0) && // Source creation is on
(MyMeta == m_Falloff) && // Only exactly one block away from a source (fast bail-out)
!IsPassableForFluid(Below) && // Only exactly 1 block deep
diff --git a/src/WebAdmin.h b/src/WebAdmin.h
index 86a8a9a4b..1e1a9bfa9 100644
--- a/src/WebAdmin.h
+++ b/src/WebAdmin.h
@@ -95,7 +95,9 @@ struct sWebAdminPage
// tolua_begin
class cWebAdmin :
+ // tolua_end
public cHTTPServer::cCallbacks
+ // tolua_begin
{
public:
// tolua_end
diff --git a/src/World.cpp b/src/World.cpp
index f3837eb02..292ff9b94 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -714,6 +714,7 @@ void cWorld::GenerateRandomSpawn(void)
bool cWorld::CheckPlayerSpawnPoint(int a_PosX, int a_PosY, int a_PosZ)
{
+ // Check that spawnblock and surrounding blocks are neither solid nor water / lava
static const struct
{
int x, z;
@@ -725,26 +726,22 @@ bool cWorld::CheckPlayerSpawnPoint(int a_PosX, int a_PosY, int a_PosZ)
{ 0, -1 },
{ 0, 1 },
};
-
- // Checking that spawnblock and surrounding blocks are air and not water/lava
for (size_t i = 0; i < ARRAYCOUNT(Coords); i++)
{
BLOCKTYPE BlockType = GetBlock(a_PosX + Coords[i].x, a_PosY, a_PosZ + Coords[i].x);
-
if (cBlockInfo::IsSolid(BlockType) || IsBlockLiquid(BlockType))
{
return false;
}
} // for i - Coords[]
- // Check if block below is solid
- BLOCKTYPE BlockType = GetBlock(a_PosX, a_PosY - 1, a_PosZ);
- if (!cBlockInfo::IsSolid(BlockType))
+ // Check that the block below is solid:
+ if (!cBlockInfo::IsSolid(GetBlock(a_PosX, a_PosY - 1, a_PosZ)))
{
return false;
}
- // Checking that all the blocks above the spawnpoint is air.
+ // Check that all the blocks above the spawnpoint are not solid:
for (int i = a_PosY; i < cChunkDef::Height; i++)
{
BLOCKTYPE BlockType = GetBlock(a_PosX, i, a_PosZ);
@@ -2911,6 +2908,20 @@ bool cWorld::ForEachEntityInBox(const cBoundingBox & a_Box, cEntityCallback & a_
bool cWorld::DoWithEntityByID(int a_UniqueID, cEntityCallback & a_Callback)
{
+ // First check the entities-to-add:
+ {
+ cCSLock Lock(m_CSEntitiesToAdd);
+ for (auto & ent: m_EntitiesToAdd)
+ {
+ if (ent->GetUniqueID() == a_UniqueID)
+ {
+ a_Callback.Item(ent);
+ return true;
+ }
+ } // for ent - m_EntitiesToAdd[]
+ }
+
+ // Then check the chunkmap:
return m_ChunkMap->DoWithEntityByID(a_UniqueID, a_Callback);
}
diff --git a/src/main.cpp b/src/main.cpp
index 20609a2f8..428e89e93 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -282,8 +282,12 @@ int main( int argc, char **argv)
}
} // for i - argv[]
+ // Initialize logging subsystem:
cLogger::InitiateMultithreading();
+ // Initialize LibEvent:
+ cNetworkSingleton::Get();
+
#if !defined(ANDROID_NDK)
try
#endif