summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/Bindings.cpp128
-rw-r--r--source/Bindings.h2
-rw-r--r--source/ClientHandle.cpp1
-rw-r--r--source/ClientHandle.h1
-rw-r--r--source/Entities/Entity.cpp5
-rw-r--r--source/Entities/Pickup.h2
-rw-r--r--source/Items/ItemHandler.cpp2
-rw-r--r--source/ManualBindings.cpp74
-rw-r--r--source/Mobs/Horse.h2
-rw-r--r--source/Mobs/IronGolem.h2
-rw-r--r--source/Mobs/Magmacube.cpp2
-rw-r--r--source/Mobs/Zombiepigman.cpp2
-rw-r--r--source/OSSupport/File.cpp15
-rw-r--r--source/OSSupport/File.h3
-rw-r--r--source/OSSupport/IsThread.cpp14
-rw-r--r--source/OSSupport/IsThread.h3
-rw-r--r--source/Plugin.cpp12
-rw-r--r--source/Plugin.h3
-rw-r--r--source/PluginLua.cpp3
-rw-r--r--source/PluginManager.cpp8
-rw-r--r--source/Protocol/Protocol125.cpp15
-rw-r--r--source/Protocol/Protocol16x.cpp2
-rw-r--r--source/Protocol/Protocol16x.h2
-rw-r--r--source/Protocol/ProtocolRecognizer.cpp6
-rw-r--r--source/Protocol/ProtocolRecognizer.h6
-rw-r--r--source/RCONServer.cpp4
-rw-r--r--source/Server.cpp4
-rw-r--r--source/WebAdmin.cpp89
-rw-r--r--source/WebAdmin.h4
-rw-r--r--source/World.cpp4
30 files changed, 283 insertions, 137 deletions
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
index a08985144..24289865a 100644
--- a/source/Bindings.cpp
+++ b/source/Bindings.cpp
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 09/16/13 11:41:45.
+** Generated automatically by tolua++-1.0.92 on 09/21/13 17:37:22.
*/
#ifndef __cplusplus
@@ -9676,15 +9676,15 @@ static int tolua_AllToLua_cPickup_new00(lua_State* tolua_S)
else
#endif
{
- int a_MicroPosX = ((int) tolua_tonumber(tolua_S,2,0));
- int a_MicroPosY = ((int) tolua_tonumber(tolua_S,3,0));
- int a_MicroPosZ = ((int) tolua_tonumber(tolua_S,4,0));
+ double a_X = ((double) tolua_tonumber(tolua_S,2,0));
+ double a_Y = ((double) tolua_tonumber(tolua_S,3,0));
+ double a_Z = ((double) tolua_tonumber(tolua_S,4,0));
const cItem* a_Item = ((const cItem*) tolua_tousertype(tolua_S,5,0));
float a_SpeedX = ((float) tolua_tonumber(tolua_S,6,0.f));
float a_SpeedY = ((float) tolua_tonumber(tolua_S,7,0.f));
float a_SpeedZ = ((float) tolua_tonumber(tolua_S,8,0.f));
{
- cPickup* tolua_ret = (cPickup*) Mtolua_new((cPickup)(a_MicroPosX,a_MicroPosY,a_MicroPosZ,*a_Item,a_SpeedX,a_SpeedY,a_SpeedZ));
+ cPickup* tolua_ret = (cPickup*) Mtolua_new((cPickup)(a_X,a_Y,a_Z,*a_Item,a_SpeedX,a_SpeedY,a_SpeedZ));
tolua_pushusertype(tolua_S,(void*)tolua_ret,"cPickup");
}
}
@@ -9718,15 +9718,15 @@ static int tolua_AllToLua_cPickup_new00_local(lua_State* tolua_S)
else
#endif
{
- int a_MicroPosX = ((int) tolua_tonumber(tolua_S,2,0));
- int a_MicroPosY = ((int) tolua_tonumber(tolua_S,3,0));
- int a_MicroPosZ = ((int) tolua_tonumber(tolua_S,4,0));
+ double a_X = ((double) tolua_tonumber(tolua_S,2,0));
+ double a_Y = ((double) tolua_tonumber(tolua_S,3,0));
+ double a_Z = ((double) tolua_tonumber(tolua_S,4,0));
const cItem* a_Item = ((const cItem*) tolua_tousertype(tolua_S,5,0));
float a_SpeedX = ((float) tolua_tonumber(tolua_S,6,0.f));
float a_SpeedY = ((float) tolua_tonumber(tolua_S,7,0.f));
float a_SpeedZ = ((float) tolua_tonumber(tolua_S,8,0.f));
{
- cPickup* tolua_ret = (cPickup*) Mtolua_new((cPickup)(a_MicroPosX,a_MicroPosY,a_MicroPosZ,*a_Item,a_SpeedX,a_SpeedY,a_SpeedZ));
+ cPickup* tolua_ret = (cPickup*) Mtolua_new((cPickup)(a_X,a_Y,a_Z,*a_Item,a_SpeedX,a_SpeedY,a_SpeedZ));
tolua_pushusertype(tolua_S,(void*)tolua_ret,"cPickup");
tolua_register_gc(tolua_S,lua_gettop(tolua_S));
}
@@ -10828,6 +10828,38 @@ static int tolua_AllToLua_cPlugin_GetLocalDirectory00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* method: GetLocalFolder of class cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_GetLocalFolder00
+static int tolua_AllToLua_cPlugin_GetLocalFolder00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cPlugin",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cPlugin* self = (const cPlugin*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetLocalFolder'", NULL);
+#endif
+ {
+ AString tolua_ret = (AString) self->GetLocalFolder();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetLocalFolder'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* get function: __cWebPlugin__ of class cPluginLua */
#ifndef TOLUA_DISABLE_tolua_get_cPluginLua___cWebPlugin__
static int tolua_get_cPluginLua___cWebPlugin__(lua_State* tolua_S)
@@ -18621,8 +18653,8 @@ static int tolua_AllToLua_cWebAdmin_GetMemoryUsage00(lua_State* tolua_S)
#endif
{
{
- AString tolua_ret = (AString) cWebAdmin::GetMemoryUsage();
- tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ int tolua_ret = (int) cWebAdmin::GetMemoryUsage();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
return 1;
@@ -29030,14 +29062,17 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_constant(tolua_S,"E_ITEM_BOOK_AND_QUILL",E_ITEM_BOOK_AND_QUILL);
tolua_constant(tolua_S,"E_ITEM_WRITTEN_BOOK",E_ITEM_WRITTEN_BOOK);
tolua_constant(tolua_S,"E_ITEM_EMERALD",E_ITEM_EMERALD);
+ tolua_constant(tolua_S,"E_ITEM_ITEM_FRAME",E_ITEM_ITEM_FRAME);
tolua_constant(tolua_S,"E_ITEM_FLOWER_POT",E_ITEM_FLOWER_POT);
tolua_constant(tolua_S,"E_ITEM_CARROT",E_ITEM_CARROT);
tolua_constant(tolua_S,"E_ITEM_POTATO",E_ITEM_POTATO);
tolua_constant(tolua_S,"E_ITEM_BAKED_POTATO",E_ITEM_BAKED_POTATO);
tolua_constant(tolua_S,"E_ITEM_POISONOUS_POTATO",E_ITEM_POISONOUS_POTATO);
+ tolua_constant(tolua_S,"E_ITEM_EMPTY_MAP",E_ITEM_EMPTY_MAP);
tolua_constant(tolua_S,"E_ITEM_GOLDEN_CARROT",E_ITEM_GOLDEN_CARROT);
tolua_constant(tolua_S,"E_ITEM_HEAD",E_ITEM_HEAD);
tolua_constant(tolua_S,"E_ITEM_CARROT_ON_STICK",E_ITEM_CARROT_ON_STICK);
+ tolua_constant(tolua_S,"E_ITEM_NETHER_STAR",E_ITEM_NETHER_STAR);
tolua_constant(tolua_S,"E_ITEM_PUMPKIN_PIE",E_ITEM_PUMPKIN_PIE);
tolua_constant(tolua_S,"E_ITEM_FIREWORK_ROCKET",E_ITEM_FIREWORK_ROCKET);
tolua_constant(tolua_S,"E_ITEM_FIREWORK_STAR",E_ITEM_FIREWORK_STAR);
@@ -29231,11 +29266,35 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_constant(tolua_S,"E_META_GOLDEN_APPLE_ENCHANTED",E_META_GOLDEN_APPLE_ENCHANTED);
tolua_constant(tolua_S,"E_META_TRACKS_X",E_META_TRACKS_X);
tolua_constant(tolua_S,"E_META_TRACKS_Z",E_META_TRACKS_Z);
+ tolua_constant(tolua_S,"E_META_SPAWN_EGG_PICKUP",E_META_SPAWN_EGG_PICKUP);
+ tolua_constant(tolua_S,"E_META_SPAWN_EGG_EXPERIENCE_ORB",E_META_SPAWN_EGG_EXPERIENCE_ORB);
+ tolua_constant(tolua_S,"E_META_SPAWN_EGG_LEASH_KNOT",E_META_SPAWN_EGG_LEASH_KNOT);
+ tolua_constant(tolua_S,"E_META_SPAWN_EGG_PAINTING",E_META_SPAWN_EGG_PAINTING);
+ tolua_constant(tolua_S,"E_META_SPAWN_EGG_ARROW",E_META_SPAWN_EGG_ARROW);
+ tolua_constant(tolua_S,"E_META_SPAWN_EGG_SNOWBALL",E_META_SPAWN_EGG_SNOWBALL);
+ tolua_constant(tolua_S,"E_META_SPAWN_EGG_FIREBALL",E_META_SPAWN_EGG_FIREBALL);
+ tolua_constant(tolua_S,"E_META_SPAWN_EGG_SMALL_FIREBALL",E_META_SPAWN_EGG_SMALL_FIREBALL);
+ tolua_constant(tolua_S,"E_META_SPAWN_EGG_ENDER_PEARL",E_META_SPAWN_EGG_ENDER_PEARL);
+ tolua_constant(tolua_S,"E_META_SPAWN_EGG_EYE_OF_ENDER",E_META_SPAWN_EGG_EYE_OF_ENDER);
+ tolua_constant(tolua_S,"E_META_SPAWN_EGG_SPLASH_POTION",E_META_SPAWN_EGG_SPLASH_POTION);
+ tolua_constant(tolua_S,"E_META_SPAWN_EGG_EXP_BOTTLE",E_META_SPAWN_EGG_EXP_BOTTLE);
+ tolua_constant(tolua_S,"E_META_SPAWN_EGG_ITEM_FRAME",E_META_SPAWN_EGG_ITEM_FRAME);
+ tolua_constant(tolua_S,"E_META_SPAWN_EGG_WITHER_SKULL",E_META_SPAWN_EGG_WITHER_SKULL);
+ tolua_constant(tolua_S,"E_META_SPAWN_EGG_PRIMED_TNT",E_META_SPAWN_EGG_PRIMED_TNT);
+ tolua_constant(tolua_S,"E_META_SPAWN_EGG_FALLING_BLOCK",E_META_SPAWN_EGG_FALLING_BLOCK);
+ tolua_constant(tolua_S,"E_META_SPAWN_EGG_FIREWORK",E_META_SPAWN_EGG_FIREWORK);
+ tolua_constant(tolua_S,"E_META_SPAWN_EGG_BOAT",E_META_SPAWN_EGG_BOAT);
+ tolua_constant(tolua_S,"E_META_SPAWN_EGG_MINECART",E_META_SPAWN_EGG_MINECART);
+ tolua_constant(tolua_S,"E_META_SPAWN_EGG_MINECART_CHEST",E_META_SPAWN_EGG_MINECART_CHEST);
+ tolua_constant(tolua_S,"E_META_SPAWN_EGG_MINECART_FURNACE",E_META_SPAWN_EGG_MINECART_FURNACE);
+ tolua_constant(tolua_S,"E_META_SPAWN_EGG_MINECART_TNT",E_META_SPAWN_EGG_MINECART_TNT);
+ tolua_constant(tolua_S,"E_META_SPAWN_EGG_MINECART_HOPPER",E_META_SPAWN_EGG_MINECART_HOPPER);
+ tolua_constant(tolua_S,"E_META_SPAWN_EGG_MINECART_SPAWNER",E_META_SPAWN_EGG_MINECART_SPAWNER);
tolua_constant(tolua_S,"E_META_SPAWN_EGG_CREEPER",E_META_SPAWN_EGG_CREEPER);
tolua_constant(tolua_S,"E_META_SPAWN_EGG_SKELETON",E_META_SPAWN_EGG_SKELETON);
tolua_constant(tolua_S,"E_META_SPAWN_EGG_SPIDER",E_META_SPAWN_EGG_SPIDER);
- tolua_constant(tolua_S,"E_META_SPAWN_EGG_ZOMBIE",E_META_SPAWN_EGG_ZOMBIE);
tolua_constant(tolua_S,"E_META_SPAWN_EGG_GIANT",E_META_SPAWN_EGG_GIANT);
+ tolua_constant(tolua_S,"E_META_SPAWN_EGG_ZOMBIE",E_META_SPAWN_EGG_ZOMBIE);
tolua_constant(tolua_S,"E_META_SPAWN_EGG_SLIME",E_META_SPAWN_EGG_SLIME);
tolua_constant(tolua_S,"E_META_SPAWN_EGG_GHAST",E_META_SPAWN_EGG_GHAST);
tolua_constant(tolua_S,"E_META_SPAWN_EGG_ZOMBIE_PIGMAN",E_META_SPAWN_EGG_ZOMBIE_PIGMAN);
@@ -29260,6 +29319,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_constant(tolua_S,"E_META_SPAWN_EGG_IRON_GOLEM",E_META_SPAWN_EGG_IRON_GOLEM);
tolua_constant(tolua_S,"E_META_SPAWN_EGG_HORSE",E_META_SPAWN_EGG_HORSE);
tolua_constant(tolua_S,"E_META_SPAWN_EGG_VILLAGER",E_META_SPAWN_EGG_VILLAGER);
+ tolua_constant(tolua_S,"E_META_SPAWN_EGG_ENDER_CRYSTAL",E_META_SPAWN_EGG_ENDER_CRYSTAL);
tolua_constant(tolua_S,"dimNether",dimNether);
tolua_constant(tolua_S,"dimOverworld",dimOverworld);
tolua_constant(tolua_S,"dimEnd",dimEnd);
@@ -29797,6 +29857,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"SetVersion",tolua_AllToLua_cPlugin_SetVersion00);
tolua_function(tolua_S,"GetDirectory",tolua_AllToLua_cPlugin_GetDirectory00);
tolua_function(tolua_S,"GetLocalDirectory",tolua_AllToLua_cPlugin_GetLocalDirectory00);
+ tolua_function(tolua_S,"GetLocalFolder",tolua_AllToLua_cPlugin_GetLocalFolder00);
tolua_endmodule(tolua_S);
tolua_cclass(tolua_S,"cPluginLua","cPluginLua","cPlugin",NULL);
tolua_beginmodule(tolua_S,"cPluginLua");
@@ -30599,34 +30660,35 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_endmodule(tolua_S);
tolua_cclass(tolua_S,"cMonster","cMonster","cPawn",NULL);
tolua_beginmodule(tolua_S,"cMonster");
+ tolua_constant(tolua_S,"mtBat",cMonster::mtBat);
+ tolua_constant(tolua_S,"mtBlaze",cMonster::mtBlaze);
+ tolua_constant(tolua_S,"mtCaveSpider",cMonster::mtCaveSpider);
+ tolua_constant(tolua_S,"mtChicken",cMonster::mtChicken);
+ tolua_constant(tolua_S,"mtCow",cMonster::mtCow);
tolua_constant(tolua_S,"mtCreeper",cMonster::mtCreeper);
- tolua_constant(tolua_S,"mtSkeleton",cMonster::mtSkeleton);
- tolua_constant(tolua_S,"mtSpider",cMonster::mtSpider);
- tolua_constant(tolua_S,"mtGiant",cMonster::mtGiant);
- tolua_constant(tolua_S,"mtZombie",cMonster::mtZombie);
- tolua_constant(tolua_S,"mtSlime",cMonster::mtSlime);
- tolua_constant(tolua_S,"mtGhast",cMonster::mtGhast);
- tolua_constant(tolua_S,"mtZombiePigman",cMonster::mtZombiePigman);
+ tolua_constant(tolua_S,"mtEnderDragon",cMonster::mtEnderDragon);
tolua_constant(tolua_S,"mtEnderman",cMonster::mtEnderman);
- tolua_constant(tolua_S,"mtCaveSpider",cMonster::mtCaveSpider);
- tolua_constant(tolua_S,"mtSilverfish",cMonster::mtSilverfish);
- tolua_constant(tolua_S,"mtBlaze",cMonster::mtBlaze);
+ tolua_constant(tolua_S,"mtGhast",cMonster::mtGhast);
+ tolua_constant(tolua_S,"mtGiant",cMonster::mtGiant);
+ tolua_constant(tolua_S,"mtHorse",cMonster::mtHorse);
+ tolua_constant(tolua_S,"mtIronGolem",cMonster::mtIronGolem);
tolua_constant(tolua_S,"mtMagmaCube",cMonster::mtMagmaCube);
- tolua_constant(tolua_S,"mtEnderDragon",cMonster::mtEnderDragon);
- tolua_constant(tolua_S,"mtWither",cMonster::mtWither);
- tolua_constant(tolua_S,"mtBat",cMonster::mtBat);
- tolua_constant(tolua_S,"mtWitch",cMonster::mtWitch);
+ tolua_constant(tolua_S,"mtMooshroom",cMonster::mtMooshroom);
+ tolua_constant(tolua_S,"mtOcelot",cMonster::mtOcelot);
tolua_constant(tolua_S,"mtPig",cMonster::mtPig);
tolua_constant(tolua_S,"mtSheep",cMonster::mtSheep);
- tolua_constant(tolua_S,"mtCow",cMonster::mtCow);
- tolua_constant(tolua_S,"mtChicken",cMonster::mtChicken);
- tolua_constant(tolua_S,"mtSquid",cMonster::mtSquid);
- tolua_constant(tolua_S,"mtWolf",cMonster::mtWolf);
- tolua_constant(tolua_S,"mtMooshroom",cMonster::mtMooshroom);
+ tolua_constant(tolua_S,"mtSilverfish",cMonster::mtSilverfish);
+ tolua_constant(tolua_S,"mtSkeleton",cMonster::mtSkeleton);
+ tolua_constant(tolua_S,"mtSlime",cMonster::mtSlime);
tolua_constant(tolua_S,"mtSnowGolem",cMonster::mtSnowGolem);
- tolua_constant(tolua_S,"mtOcelot",cMonster::mtOcelot);
- tolua_constant(tolua_S,"mtIronGolem",cMonster::mtIronGolem);
+ tolua_constant(tolua_S,"mtSpider",cMonster::mtSpider);
+ tolua_constant(tolua_S,"mtSquid",cMonster::mtSquid);
tolua_constant(tolua_S,"mtVillager",cMonster::mtVillager);
+ tolua_constant(tolua_S,"mtWitch",cMonster::mtWitch);
+ tolua_constant(tolua_S,"mtWither",cMonster::mtWither);
+ tolua_constant(tolua_S,"mtWolf",cMonster::mtWolf);
+ tolua_constant(tolua_S,"mtZombie",cMonster::mtZombie);
+ tolua_constant(tolua_S,"mtZombiePigman",cMonster::mtZombiePigman);
tolua_function(tolua_S,"GetMobType",tolua_AllToLua_cMonster_GetMobType00);
tolua_endmodule(tolua_S);
tolua_cclass(tolua_S,"cLineBlockTracer","cLineBlockTracer","",NULL);
diff --git a/source/Bindings.h b/source/Bindings.h
index 4d1777180..0fa3665a3 100644
--- a/source/Bindings.h
+++ b/source/Bindings.h
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 09/16/13 11:41:45.
+** Generated automatically by tolua++-1.0.92 on 09/21/13 17:37:22.
*/
/* Exported function */
diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp
index 074b50bad..f67a546fd 100644
--- a/source/ClientHandle.cpp
+++ b/source/ClientHandle.cpp
@@ -735,6 +735,7 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo
cWorld * World = m_Player->GetWorld();
ItemHandler->OnBlockDestroyed(World, m_Player, m_Player->GetEquippedItem(), a_BlockX, a_BlockY, a_BlockZ);
+ // The ItemHandler is also responsible for spawning the pickups
BlockHandler(a_OldBlock)->OnDestroyedByPlayer(World, m_Player, a_BlockX, a_BlockY, a_BlockZ);
World->BroadcastSoundParticleEffect(2001, a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, a_OldBlock, this);
diff --git a/source/ClientHandle.h b/source/ClientHandle.h
index 01059c511..ef6dbd124 100644
--- a/source/ClientHandle.h
+++ b/source/ClientHandle.h
@@ -1,3 +1,4 @@
+
// cClientHandle.h
// Interfaces to the cClientHandle class representing a client connected to this server. The client need not be a player yet
diff --git a/source/Entities/Entity.cpp b/source/Entities/Entity.cpp
index dc3c7796e..d465c75bd 100644
--- a/source/Entities/Entity.cpp
+++ b/source/Entities/Entity.cpp
@@ -549,12 +549,11 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
int RelBlockX = BlockX - (NextChunk->GetPosX() * cChunkDef::Width);
int RelBlockZ = BlockZ - (NextChunk->GetPosZ() * cChunkDef::Width);
BLOCKTYPE BlockIn = NextChunk->GetBlock( RelBlockX, BlockY, RelBlockZ );
- BLOCKTYPE BlockBelow = NextChunk->GetBlock( RelBlockX, BlockY - 1, RelBlockZ );
+ BLOCKTYPE BlockBelow = (BlockY > 0) ? NextChunk->GetBlock(RelBlockX, BlockY - 1, RelBlockZ) : E_BLOCK_AIR;
if (!g_BlockIsSolid[BlockIn]) // Making sure we are not inside a solid block
{
if (m_bOnGround) // check if it's still on the ground
{
- BLOCKTYPE BlockBelow = NextChunk->GetBlock( RelBlockX, BlockY - 1, RelBlockZ );
if (!g_BlockIsSolid[BlockBelow]) // Check if block below is air or water.
{
m_bOnGround = false;
@@ -613,7 +612,7 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
{
fallspeed = m_Gravity * a_Dt / 3; // Fall 3x slower in water.
}
- else if ((IsBlockRail(BlockBelow)) && (IsMinecart())) // Rails aren't solid, except for Minecarts
+ else if (IsBlockRail(BlockBelow) && IsMinecart()) // Rails aren't solid, except for Minecarts
{
fallspeed = 0;
m_bOnGround = true;
diff --git a/source/Entities/Pickup.h b/source/Entities/Pickup.h
index e35914684..488f91fb2 100644
--- a/source/Entities/Pickup.h
+++ b/source/Entities/Pickup.h
@@ -24,7 +24,7 @@ class cPickup :
public:
CLASS_PROTODEF(cPickup);
- cPickup(double a_MicroPosX, double a_MicroPosY, double a_MicroPosZ, const cItem & a_Item, float a_SpeedX = 0.f, float a_SpeedY = 0.f, float a_SpeedZ = 0.f); // tolua_export
+ cPickup(double a_X, double a_Y, double a_Z, const cItem & a_Item, float a_SpeedX = 0.f, float a_SpeedY = 0.f, float a_SpeedZ = 0.f); // tolua_export
cItem & GetItem(void) {return m_Item; } // tolua_export
const cItem & GetItem(void) const {return m_Item; }
diff --git a/source/Items/ItemHandler.cpp b/source/Items/ItemHandler.cpp
index 9d38e6f3a..13f5293b9 100644
--- a/source/Items/ItemHandler.cpp
+++ b/source/Items/ItemHandler.cpp
@@ -247,7 +247,7 @@ void cItemHandler::OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const
BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
cBlockHandler * Handler = cBlockHandler::GetBlockHandler(Block);
- if (a_Player->GetGameMode() == gmSurvival)
+ if (a_Player->IsGameModeSurvival())
{
if (!BlockRequiresSpecialTool(Block) || CanHarvestBlock(Block))
{
diff --git a/source/ManualBindings.cpp b/source/ManualBindings.cpp
index a80e186eb..a2b4c8810 100644
--- a/source/ManualBindings.cpp
+++ b/source/ManualBindings.cpp
@@ -1235,7 +1235,10 @@ static int tolua_cPluginManager_ForEachConsoleCommand(lua_State * tolua_S)
static int tolua_cPluginManager_BindCommand(lua_State * L)
{
- // Function signature: cPluginManager:BindCommand(Command, Permission, Function, HelpString)
+ /* Function signatures:
+ cPluginManager:BindCommand(Command, Permission, Function, HelpString)
+ cPluginManager.BindCommand(Command, Permission, Function, HelpString) -- without the "self" param
+ */
cPluginLua * Plugin = GetLuaPlugin(L);
if (Plugin == NULL)
{
@@ -1244,26 +1247,30 @@ static int tolua_cPluginManager_BindCommand(lua_State * L)
// Read the arguments to this API call:
tolua_Error tolua_err;
+ int idx = 1;
+ if (tolua_isusertype(L, 1, "cPluginManager", 0, &tolua_err))
+ {
+ idx++;
+ }
if (
- !tolua_isusertype (L, 1, "cPluginManager", 0, &tolua_err) ||
- !tolua_iscppstring(L, 2, 0, &tolua_err) ||
- !tolua_iscppstring(L, 3, 0, &tolua_err) ||
- !tolua_iscppstring(L, 5, 0, &tolua_err) ||
- !tolua_isnoobj (L, 6, &tolua_err)
+ !tolua_iscppstring(L, idx, 0, &tolua_err) ||
+ !tolua_iscppstring(L, idx + 1, 0, &tolua_err) ||
+ !tolua_iscppstring(L, idx + 3, 0, &tolua_err) ||
+ !tolua_isnoobj (L, idx + 4, &tolua_err)
)
{
tolua_error(L, "#ferror in function 'BindCommand'.", &tolua_err);
return 0;
}
- if (!lua_isfunction(L, 4))
+ if (!lua_isfunction(L, idx + 2))
{
luaL_error(L, "\"BindCommand\" function expects a function as its 3rd parameter. Command-binding aborted.");
return 0;
}
- cPluginManager * self = (cPluginManager *)tolua_tousertype(L, 1, 0);
- AString Command (tolua_tocppstring(L, 2, ""));
- AString Permission(tolua_tocppstring(L, 3, ""));
- AString HelpString(tolua_tocppstring(L, 5, ""));
+ cPluginManager * self = cPluginManager::Get();
+ AString Command (tolua_tocppstring(L, idx, ""));
+ AString Permission(tolua_tocppstring(L, idx + 1, ""));
+ AString HelpString(tolua_tocppstring(L, idx + 3, ""));
// Store the function reference:
lua_pop(L, 1); // Pop the help string off the stack
@@ -1290,37 +1297,42 @@ static int tolua_cPluginManager_BindCommand(lua_State * L)
static int tolua_cPluginManager_BindConsoleCommand(lua_State * L)
{
- // Function signature: cPluginManager:BindConsoleCommand(Command, Function, HelpString)
+ /* Function signatures:
+ cPluginManager:BindConsoleCommand(Command, Function, HelpString)
+ cPluginManager.BindConsoleCommand(Command, Function, HelpString) -- without the "self" param
+ */
// Get the plugin identification out of LuaState:
- lua_getglobal(L, LUA_PLUGIN_INSTANCE_VAR_NAME);
- if (!lua_islightuserdata(L, -1))
+ cPluginLua * Plugin = GetLuaPlugin(L);
+ if (Plugin == NULL)
{
- LOGERROR("cPluginManager:BindConsoleCommand() cannot get plugin instance, what have you done to my Lua state? Command-binding aborted.");
+ return 0;
}
- cPluginLua * Plugin = (cPluginLua *)lua_topointer(L, -1);
- lua_pop(L, 1);
// Read the arguments to this API call:
tolua_Error tolua_err;
+ int idx = 1;
+ if (tolua_isusertype(L, 1, "cPluginManager", 0, &tolua_err))
+ {
+ idx++;
+ }
if (
- !tolua_isusertype (L, 1, "cPluginManager", 0, &tolua_err) || // self
- !tolua_iscppstring(L, 2, 0, &tolua_err) || // Command
- !tolua_iscppstring(L, 4, 0, &tolua_err) || // HelpString
- !tolua_isnoobj (L, 5, &tolua_err)
+ !tolua_iscppstring(L, idx, 0, &tolua_err) || // Command
+ !tolua_iscppstring(L, idx + 2, 0, &tolua_err) || // HelpString
+ !tolua_isnoobj (L, idx + 3, &tolua_err)
)
{
tolua_error(L, "#ferror in function 'BindConsoleCommand'.", &tolua_err);
return 0;
}
- if (!lua_isfunction(L, 3))
+ if (!lua_isfunction(L, idx + 1))
{
luaL_error(L, "\"BindConsoleCommand\" function expects a function as its 2nd parameter. Command-binding aborted.");
return 0;
}
- cPluginManager * self = (cPluginManager *)tolua_tousertype(L, 1, 0);
- AString Command (tolua_tocppstring(L, 2, ""));
- AString HelpString(tolua_tocppstring(L, 4, ""));
+ cPluginManager * self = cPluginManager::Get();
+ AString Command (tolua_tocppstring(L, idx, ""));
+ AString HelpString(tolua_tocppstring(L, idx + 2, ""));
// Store the function reference:
lua_pop(L, 1); // Pop the help string off the stack
@@ -1489,14 +1501,16 @@ static int tolua_cPluginLua_AddWebTab(lua_State * tolua_S)
tolua_Error tolua_err;
tolua_err.array = 0;
- tolua_err.index = 0;
- tolua_err.type = 0;
+ tolua_err.index = 3;
+ tolua_err.type = "function";
std::string Title = "";
int Reference = LUA_REFNIL;
- if( tolua_isstring( tolua_S, 2, 0, &tolua_err ) &&
- lua_isfunction( tolua_S, 3 ) )
+ if (
+ tolua_isstring(tolua_S, 2, 0, &tolua_err ) &&
+ lua_isfunction(tolua_S, 3 )
+ )
{
Reference = luaL_ref(tolua_S, LUA_REGISTRYINDEX);
Title = ((std::string) tolua_tocppstring(tolua_S,2,0));
@@ -2028,12 +2042,12 @@ void ManualBindings::Bind(lua_State * tolua_S)
tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S, "cPluginManager");
+ tolua_function(tolua_S, "AddHook", tolua_cPluginManager_AddHook);
tolua_function(tolua_S, "BindCommand", tolua_cPluginManager_BindCommand);
tolua_function(tolua_S, "BindConsoleCommand", tolua_cPluginManager_BindConsoleCommand);
tolua_function(tolua_S, "ForEachCommand", tolua_cPluginManager_ForEachCommand);
tolua_function(tolua_S, "ForEachConsoleCommand", tolua_cPluginManager_ForEachConsoleCommand);
tolua_function(tolua_S, "GetAllPlugins", tolua_cPluginManager_GetAllPlugins);
- tolua_function(tolua_S, "AddHook", tolua_cPluginManager_AddHook);
tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S, "cPlayer");
diff --git a/source/Mobs/Horse.h b/source/Mobs/Horse.h
index ea6e441bd..83e64308e 100644
--- a/source/Mobs/Horse.h
+++ b/source/Mobs/Horse.h
@@ -1,7 +1,7 @@
#pragma once
-#include "AggressiveMonster.h"
+#include "PassiveMonster.h"
diff --git a/source/Mobs/IronGolem.h b/source/Mobs/IronGolem.h
index d253aefac..d49ff4cab 100644
--- a/source/Mobs/IronGolem.h
+++ b/source/Mobs/IronGolem.h
@@ -1,7 +1,7 @@
#pragma once
-#include "AggressiveMonster.h"
+#include "PassiveAggressiveMonster.h"
diff --git a/source/Mobs/Magmacube.cpp b/source/Mobs/Magmacube.cpp
index 7d553758e..c72b4831b 100644
--- a/source/Mobs/Magmacube.cpp
+++ b/source/Mobs/Magmacube.cpp
@@ -1,7 +1,7 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-#include "MagmaCube.h"
+#include "Magmacube.h"
diff --git a/source/Mobs/Zombiepigman.cpp b/source/Mobs/Zombiepigman.cpp
index 1aea006a6..1e31a72d9 100644
--- a/source/Mobs/Zombiepigman.cpp
+++ b/source/Mobs/Zombiepigman.cpp
@@ -1,7 +1,7 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-#include "ZombiePigman.h"
+#include "Zombiepigman.h"
#include "../World.h"
diff --git a/source/OSSupport/File.cpp b/source/OSSupport/File.cpp
index cc0916711..a4c9a22f4 100644
--- a/source/OSSupport/File.cpp
+++ b/source/OSSupport/File.cpp
@@ -287,6 +287,21 @@ bool cFile::Rename(const AString & a_OrigFileName, const AString & a_NewFileName
+bool cFile::IsFolder(const AString & a_Path)
+{
+ #ifdef _WIN32
+ DWORD FileAttrib = GetFileAttributes(a_Path.c_str());
+ return ((FileAttrib != INVALID_FILE_ATTRIBUTES) && ((FileAttrib & FILE_ATTRIBUTE_DIRECTORY) != 0));
+ #else
+ struct stat st;
+ return ((stat(a_Path.c_str(), &st) == 0) && S_ISDIR(st.st_mode));
+ #endif
+}
+
+
+
+
+
int cFile::Printf(const char * a_Fmt, ...)
{
AString buf;
diff --git a/source/OSSupport/File.h b/source/OSSupport/File.h
index 8a057afa8..d4ea0d3a8 100644
--- a/source/OSSupport/File.h
+++ b/source/OSSupport/File.h
@@ -99,6 +99,9 @@ public:
/// Renames a file, returns true if successful. May fail if dest already exists (libc-dependant)!
static bool Rename(const AString & a_OrigFileName, const AString & a_NewFileName);
+ /// Returns true if the specified path is a folder
+ static bool IsFolder(const AString & a_Path);
+
int Printf(const char * a_Fmt, ...);
private:
diff --git a/source/OSSupport/IsThread.cpp b/source/OSSupport/IsThread.cpp
index d5fbfcf19..e1ef84c17 100644
--- a/source/OSSupport/IsThread.cpp
+++ b/source/OSSupport/IsThread.cpp
@@ -53,11 +53,7 @@ static void SetThreadName( DWORD dwThreadID, LPCSTR szThreadName)
cIsThread::cIsThread(const AString & iThreadName) :
m_ThreadName(iThreadName),
m_ShouldTerminate(false),
- #ifdef _WIN32
- m_Handle(NULL)
- #else // _WIN32
- m_HasStarted(false)
- #endif // else _WIN32
+ m_Handle(NULL)
{
}
@@ -77,9 +73,9 @@ cIsThread::~cIsThread()
bool cIsThread::Start(void)
{
+ ASSERT(m_Handle == NULL); // Has already started one thread?
+
#ifdef _WIN32
- ASSERT(m_Handle == NULL); // Has already started one thread?
-
// Create the thread suspended, so that the mHandle variable is valid in the thread procedure
DWORD ThreadID = 0;
m_Handle = CreateThread(NULL, 0, thrExecute, this, CREATE_SUSPENDED, &ThreadID);
@@ -99,14 +95,11 @@ bool cIsThread::Start(void)
#endif // _DEBUG and _MSC_VER
#else // _WIN32
- ASSERT(!m_HasStarted);
-
if (pthread_create(&m_Handle, NULL, thrExecute, this))
{
LOGERROR("ERROR: Could not create thread \"%s\", !", m_ThreadName.c_str());
return false;
}
- m_HasStarted = true;
#endif // else _WIN32
return true;
@@ -158,7 +151,6 @@ bool cIsThread::Wait(void)
LOGD("Thread %s finished", m_ThreadName.c_str());
#endif // LOGD
- m_HasStarted = false;
return (res == 0);
#endif // else _WIN32
}
diff --git a/source/OSSupport/IsThread.h b/source/OSSupport/IsThread.h
index 9b7f0b73e..2ea8bf6f9 100644
--- a/source/OSSupport/IsThread.h
+++ b/source/OSSupport/IsThread.h
@@ -48,7 +48,7 @@ public:
/// Returns the OS-dependent thread ID for the caller's thread
static unsigned long GetCurrentID(void);
-private:
+protected:
AString m_ThreadName;
#ifdef _WIN32
@@ -66,7 +66,6 @@ private:
#else // _WIN32
pthread_t m_Handle;
- bool m_HasStarted;
static void * thrExecute(void * a_Param)
{
diff --git a/source/Plugin.cpp b/source/Plugin.cpp
index 229b997cd..98ccfb88c 100644
--- a/source/Plugin.cpp
+++ b/source/Plugin.cpp
@@ -2,10 +2,6 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Plugin.h"
-#include "Entities/Player.h"
-#include "World.h"
-#include "CommandOutput.h"
-#include "Mobs/Monster.h"
@@ -32,7 +28,11 @@ cPlugin::~cPlugin()
-AString cPlugin::GetLocalDirectory(void) const
+AString cPlugin::GetLocalFolder(void) const
{
return std::string("Plugins/") + m_Directory;
-} \ No newline at end of file
+}
+
+
+
+
diff --git a/source/Plugin.h b/source/Plugin.h
index be803bab2..06e5819df 100644
--- a/source/Plugin.h
+++ b/source/Plugin.h
@@ -121,7 +121,8 @@ public:
void SetVersion(int a_Version) { m_Version = a_Version; }
const AString & GetDirectory(void) const {return m_Directory; }
- AString GetLocalDirectory(void) const;
+ AString GetLocalDirectory(void) const {return GetLocalFolder(); } // OBSOLETE, use GetLocalFolder() instead
+ AString GetLocalFolder(void) const;
// tolua_end
diff --git a/source/PluginLua.cpp b/source/PluginLua.cpp
index 81a536838..03aefb098 100644
--- a/source/PluginLua.cpp
+++ b/source/PluginLua.cpp
@@ -81,6 +81,9 @@ bool cPluginLua::Initialize(void)
lua_setglobal(m_LuaState, LUA_PLUGIN_INSTANCE_VAR_NAME);
lua_pushstring(m_LuaState, GetName().c_str());
lua_setglobal(m_LuaState, LUA_PLUGIN_NAME_VAR_NAME);
+
+ tolua_pushusertype(m_LuaState, this, "cPluginLua");
+ lua_setglobal(m_LuaState, "g_Plugin");
}
std::string PluginPath = FILE_IO_PREFIX + GetLocalDirectory() + "/";
diff --git a/source/PluginManager.cpp b/source/PluginManager.cpp
index 93ee71926..68cb6e40b 100644
--- a/source/PluginManager.cpp
+++ b/source/PluginManager.cpp
@@ -75,16 +75,16 @@ void cPluginManager::FindPlugins(void)
AStringList Files = GetDirectoryContents(PluginsPath.c_str());
for (AStringList::const_iterator itr = Files.begin(); itr != Files.end(); ++itr)
{
- if (itr->rfind(".") != AString::npos)
+ if (!cFile::IsFolder(PluginsPath + *itr))
{
- // Ignore files, we only want directories
+ // We only want folders
continue;
}
// Add plugin name/directory to the list
- if (m_Plugins.find( *itr ) == m_Plugins.end())
+ if (m_Plugins.find(*itr) == m_Plugins.end())
{
- m_Plugins[ *itr ] = NULL;
+ m_Plugins[*itr] = NULL;
}
}
}
diff --git a/source/Protocol/Protocol125.cpp b/source/Protocol/Protocol125.cpp
index 54bd28c9f..050132917 100644
--- a/source/Protocol/Protocol125.cpp
+++ b/source/Protocol/Protocol125.cpp
@@ -436,15 +436,18 @@ void cProtocol125::SendExplosion(double a_BlockX, double a_BlockY, double a_Bloc
WriteDouble (a_BlockZ);
WriteFloat (a_Radius);
WriteInt (a_BlocksAffected.size());
+ int BlockX = (int)a_BlockX;
+ int BlockY = (int)a_BlockY;
+ int BlockZ = (int)a_BlockZ;
for (cVector3iArray::const_iterator itr = a_BlocksAffected.begin(); itr != a_BlocksAffected.end(); ++itr)
{
- WriteByte ((Byte)(itr->x - a_BlockX));
- WriteByte ((Byte)(itr->y - a_BlockY));
- WriteByte ((Byte)(itr->z - a_BlockZ));
+ WriteByte((Byte)(itr->x - BlockX));
+ WriteByte((Byte)(itr->y - BlockY));
+ WriteByte((Byte)(itr->z - BlockZ));
}
- WriteFloat ((float)a_PlayerMotion.x);
- WriteFloat ((float)a_PlayerMotion.y);
- WriteFloat ((float)a_PlayerMotion.z);
+ WriteFloat((float)a_PlayerMotion.x);
+ WriteFloat((float)a_PlayerMotion.y);
+ WriteFloat((float)a_PlayerMotion.z);
Flush();
}
diff --git a/source/Protocol/Protocol16x.cpp b/source/Protocol/Protocol16x.cpp
index be5b45f19..0eac7b081 100644
--- a/source/Protocol/Protocol16x.cpp
+++ b/source/Protocol/Protocol16x.cpp
@@ -7,6 +7,8 @@ Implements the 1.6.x protocol classes:
- release 1.6.1 protocol (#73)
- cProtocol162
- release 1.6.2 protocol (#74)
+ - release 1.6.3 protocol (#77) - no relevant changes
+ - release 1.6.4 protocol (#78) - no relevant changes
(others may be added later in the future for the 1.6 release series)
*/
diff --git a/source/Protocol/Protocol16x.h b/source/Protocol/Protocol16x.h
index 077c7958b..2447f90a7 100644
--- a/source/Protocol/Protocol16x.h
+++ b/source/Protocol/Protocol16x.h
@@ -7,6 +7,8 @@ Declares the 1.6.x protocol classes:
- release 1.6.1 protocol (#73)
- cProtocol162
- release 1.6.2 protocol (#74)
+ - release 1.6.3 protocol (#77) - no relevant changes
+ - release 1.6.4 protocol (#78) - no relevant changes
(others may be added later in the future for the 1.6 release series)
*/
diff --git a/source/Protocol/ProtocolRecognizer.cpp b/source/Protocol/ProtocolRecognizer.cpp
index 853018329..fe99b22e1 100644
--- a/source/Protocol/ProtocolRecognizer.cpp
+++ b/source/Protocol/ProtocolRecognizer.cpp
@@ -55,6 +55,8 @@ AString cProtocolRecognizer::GetVersionTextFromInt(int a_ProtocolVersion)
case PROTO_VERSION_1_5_2: return "1.5.2";
case PROTO_VERSION_1_6_1: return "1.6.1";
case PROTO_VERSION_1_6_2: return "1.6.2";
+ case PROTO_VERSION_1_6_3: return "1.6.3";
+ case PROTO_VERSION_1_6_4: return "1.6.4";
}
ASSERT(!"Unknown protocol version");
return Printf("Unknown protocol (%d)", a_ProtocolVersion);
@@ -707,6 +709,8 @@ bool cProtocolRecognizer::TryRecognizeProtocol(void)
return true;
}
case PROTO_VERSION_1_6_2:
+ case PROTO_VERSION_1_6_3:
+ case PROTO_VERSION_1_6_4:
{
m_Protocol = new cProtocol162(m_Client);
return true;
@@ -746,6 +750,8 @@ void cProtocolRecognizer::HandleServerPing(void)
case PROTO_VERSION_1_5_2:
case PROTO_VERSION_1_6_1:
case PROTO_VERSION_1_6_2:
+ case PROTO_VERSION_1_6_3:
+ case PROTO_VERSION_1_6_4:
{
// The server list ping now has 1 more byte of "magic". Mojang just loves to complicate stuff.
// http://wiki.vg/wiki/index.php?title=Protocol&oldid=3101#Server_List_Ping_.280xFE.29
diff --git a/source/Protocol/ProtocolRecognizer.h b/source/Protocol/ProtocolRecognizer.h
index 2178d5e61..c53288230 100644
--- a/source/Protocol/ProtocolRecognizer.h
+++ b/source/Protocol/ProtocolRecognizer.h
@@ -18,8 +18,8 @@
// Adjust these if a new protocol is added or an old one is removed:
-#define MCS_CLIENT_VERSIONS "1.2.4, 1.2.5, 1.3.1, 1.3.2, 1.4.2, 1.4.4, 1.4.5, 1.4.6, 1.4.7, 1.5, 1.5.1, 1.5.2, 1.6.1, 1.6.2"
-#define MCS_PROTOCOL_VERSIONS "29, 39, 47, 49, 51, 60, 61, 73, 74"
+#define MCS_CLIENT_VERSIONS "1.2.4, 1.2.5, 1.3.1, 1.3.2, 1.4.2, 1.4.4, 1.4.5, 1.4.6, 1.4.7, 1.5, 1.5.1, 1.5.2, 1.6.1, 1.6.2, 1.6.3, 1.6.4"
+#define MCS_PROTOCOL_VERSIONS "29, 39, 47, 49, 51, 60, 61, 73, 74, 77, 78"
@@ -42,6 +42,8 @@ public:
PROTO_VERSION_1_5_2 = 61,
PROTO_VERSION_1_6_1 = 73,
PROTO_VERSION_1_6_2 = 74,
+ PROTO_VERSION_1_6_3 = 77,
+ PROTO_VERSION_1_6_4 = 78,
PROTO_VERSION_NEXT,
PROTO_VERSION_LATEST = PROTO_VERSION_NEXT - 1, ///< Automatically assigned to the last protocol version, this serves as the default for PrimaryServerVersion
diff --git a/source/RCONServer.cpp b/source/RCONServer.cpp
index 04c06c887..93f2ccdd3 100644
--- a/source/RCONServer.cpp
+++ b/source/RCONServer.cpp
@@ -78,8 +78,8 @@ protected:
cRCONServer::cRCONServer(cServer & a_Server) :
m_Server(a_Server),
- m_ListenThread4(*this, cSocket::IPv4, "RCON"),
- m_ListenThread6(*this, cSocket::IPv6, "RCON")
+ m_ListenThread4(*this, cSocket::IPv4, "RCON IPv4"),
+ m_ListenThread6(*this, cSocket::IPv6, "RCON IPv6")
{
}
diff --git a/source/Server.cpp b/source/Server.cpp
index dd18f8d3d..e73580e79 100644
--- a/source/Server.cpp
+++ b/source/Server.cpp
@@ -103,8 +103,8 @@ void cServer::cTickThread::Execute(void)
// cServer:
cServer::cServer(void) :
- m_ListenThreadIPv4(*this, cSocket::IPv4, "Client"),
- m_ListenThreadIPv6(*this, cSocket::IPv6, "Client"),
+ m_ListenThreadIPv4(*this, cSocket::IPv4, "Client IPv4"),
+ m_ListenThreadIPv6(*this, cSocket::IPv6, "Client IPv6"),
m_bIsConnected(false),
m_bRestarting(false),
m_RCONServer(*this),
diff --git a/source/WebAdmin.cpp b/source/WebAdmin.cpp
index 77a5865d3..e53fb84e6 100644
--- a/source/WebAdmin.cpp
+++ b/source/WebAdmin.cpp
@@ -18,8 +18,10 @@
#ifdef _WIN32
#include <psapi.h>
-#else
- #include <sys/resource.h>
+#elif defined(__linux__)
+ #include <fstream>
+#elif defined(__APPLE__)
+ #include <mach/mach.h>
#endif
@@ -241,8 +243,17 @@ void cWebAdmin::Request_Handler(webserver::http_request* r)
Content += "\n<p><a href='" + BaseURL + "'>Go back</a></p>";
}
- AString MemUsage = GetMemoryUsage();
- ReplaceString(Template, "{MEM}", MemUsage);
+ int MemUsageKiB = GetMemoryUsage();
+ if (MemUsageKiB > 0)
+ {
+ ReplaceString(Template, "{MEM}", Printf("%.02f", (double)MemUsageKiB / 1024));
+ ReplaceString(Template, "{MEMKIB}", Printf("%d", MemUsageKiB));
+ }
+ else
+ {
+ ReplaceString(Template, "{MEM}", "unknown");
+ ReplaceString(Template, "{MEMKIB}", "unknown");
+ }
ReplaceString(Template, "{USERNAME}", r->username_);
ReplaceString(Template, "{MENU}", Menu);
ReplaceString(Template, "{PLUGIN_NAME}", FoundPlugin);
@@ -412,26 +423,54 @@ AString cWebAdmin::GetBaseURL( const AStringVector& a_URLSplit )
-AString cWebAdmin::GetMemoryUsage(void)
+int cWebAdmin::GetMemoryUsage(void)
{
- AString MemUsage;
-#ifndef _WIN32
- rusage resource_usage;
- if (getrusage(RUSAGE_SELF, &resource_usage) != 0)
- {
- MemUsage = "Error :(";
- }
- else
- {
- Printf(MemUsage, "%0.2f", ((double)resource_usage.ru_maxrss / 1024 / 1024) );
- }
-#else
- HANDLE hProcess = GetCurrentProcess();
- PROCESS_MEMORY_COUNTERS pmc;
- if( GetProcessMemoryInfo( hProcess, &pmc, sizeof(pmc) ) )
- {
- Printf(MemUsage, "%0.2f", (pmc.WorkingSetSize / 1024.f / 1024.f) );
- }
-#endif
- return MemUsage;
+ #ifdef _WIN32
+ PROCESS_MEMORY_COUNTERS pmc;
+ if (GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc)))
+ {
+ return (int)(pmc.WorkingSetSize / 1024);
+ }
+ return -1;
+ #elif defined(__linux__)
+ // Code adapted from http://stackoverflow.com/questions/63166/how-to-determine-cpu-and-memory-consumption-from-inside-a-process
+ std::ifstream StatFile("/proc/self/status");
+ if (!StatFile.good())
+ {
+ return -1;
+ }
+ while (StatFile.good())
+ {
+ AString Line;
+ std::getline(StatFile, Line);
+ if (strncmp(Line.c_str(), "VmSize:", 7) == 0)
+ {
+ int res = atoi(Line.c_str() + 8);
+ return (res == 0) ? -1 : res; // If parsing failed, return -1
+ }
+ }
+ return -1;
+ #elif defined (__APPLE__)
+ // Code adapted from http://stackoverflow.com/questions/63166/how-to-determine-cpu-and-memory-consumption-from-inside-a-process
+ struct task_basic_info t_info;
+ mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT;
+
+ if (KERN_SUCCESS == task_info(
+ mach_task_self(),
+ TASK_BASIC_INFO,
+ (task_info_t)&t_info,
+ &t_info_count
+ ))
+ {
+ return (int)(t_info.resident_size / 1024);
+ }
+ return -1;
+ #else
+ LOGINFO("%s: Unknown platform, cannot query memory usage", __FUNCTION__);
+ return -1;
+ #endif
}
+
+
+
+
diff --git a/source/WebAdmin.h b/source/WebAdmin.h
index a62b532f1..7b710bd3b 100644
--- a/source/WebAdmin.h
+++ b/source/WebAdmin.h
@@ -95,7 +95,9 @@ public:
static void Request_Handler(webserver::http_request* r);
// tolua_begin
- static AString GetMemoryUsage(void);
+
+ /// Returns the amount of currently used memory, in KiB, or -1 if it cannot be queried
+ static int GetMemoryUsage(void);
int GetPort() { return m_Port; }
diff --git a/source/World.cpp b/source/World.cpp
index 606ef0787..96a4731d7 100644
--- a/source/World.cpp
+++ b/source/World.cpp
@@ -40,7 +40,7 @@
#include "Mobs/Giant.h"
#include "Mobs/Horse.h"
#include "Mobs/IronGolem.h"
-#include "Mobs/MagmaCube.h"
+#include "Mobs/Magmacube.h"
#include "Mobs/Mooshroom.h"
#include "Mobs/Ocelot.h"
#include "Mobs/Pig.h"
@@ -56,7 +56,7 @@
#include "Mobs/Wither.h"
#include "Mobs/Wolf.h"
#include "Mobs/Zombie.h"
-#include "Mobs/ZombiePigman.h"
+#include "Mobs/Zombiepigman.h"
#include "OSSupport/MakeDir.h"
#include "MersenneTwister.h"