summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/Bindings.cpp228
-rw-r--r--source/Bindings.h2
-rw-r--r--source/cBlockEntity.h12
-rw-r--r--source/cCavespider.cpp6
-rw-r--r--source/cChestEntity.cpp7
-rw-r--r--source/cChestEntity.h2
-rw-r--r--source/cChicken.cpp4
-rw-r--r--source/cChunk.cpp65
-rw-r--r--source/cChunk.h11
-rw-r--r--source/cChunkMap.cpp7
-rw-r--r--source/cChunkMap.h4
-rw-r--r--source/cClientHandle.cpp31
-rw-r--r--source/cCow.cpp4
-rw-r--r--source/cCraftingWindow.cpp2
-rw-r--r--source/cCreeper.cpp4
-rw-r--r--source/cEnderman.cpp6
-rw-r--r--source/cEntity.cpp26
-rw-r--r--source/cEntity.h6
-rw-r--r--source/cFurnaceEntity.cpp18
-rw-r--r--source/cFurnaceEntity.h3
-rw-r--r--source/cGhast.cpp4
-rw-r--r--source/cMonster.cpp26
-rw-r--r--source/cPawn.cpp4
-rw-r--r--source/cPickup.cpp6
-rw-r--r--source/cPig.cpp4
-rw-r--r--source/cPlayer.cpp43
-rw-r--r--source/cServer.cpp8
-rw-r--r--source/cSheep.cpp4
-rw-r--r--source/cSignEntity.cpp8
-rw-r--r--source/cSignEntity.h3
-rw-r--r--source/cSilverfish.cpp4
-rw-r--r--source/cSkeleton.cpp6
-rw-r--r--source/cSlime.cpp4
-rw-r--r--source/cSpider.cpp6
-rw-r--r--source/cSquid.cpp4
-rw-r--r--source/cWebAdmin.cpp2
-rw-r--r--source/cWolf.cpp4
-rw-r--r--source/cWorld.cpp8
-rw-r--r--source/cZombie.cpp6
-rw-r--r--source/cZombiepigman.cpp6
40 files changed, 402 insertions, 206 deletions
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
index 3104dc702..690d7af7f 100644
--- a/source/Bindings.cpp
+++ b/source/Bindings.cpp
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 07/15/11 01:36:28.
+** Generated automatically by tolua++-1.0.92 on 10/31/11 01:51:08.
*/
#ifndef __cplusplus
@@ -2700,6 +2700,15 @@ static int tolua_get_cChatColor_Color(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* get function: Delimiter of class cChatColor */
+#ifndef TOLUA_DISABLE_tolua_get_cChatColor_Delimiter
+static int tolua_get_cChatColor_Delimiter(lua_State* tolua_S)
+{
+ tolua_pushcppstring(tolua_S,(const char*)cChatColor::Delimiter);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* get function: Black of class cChatColor */
#ifndef TOLUA_DISABLE_tolua_get_cChatColor_Black
static int tolua_get_cChatColor_Black(lua_State* tolua_S)
@@ -2976,18 +2985,20 @@ static int tolua_AllToLua_cEntity_Initialize00(lua_State* tolua_S)
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) ||
- !tolua_isnoobj(tolua_S,2,&tolua_err)
+ !tolua_isusertype(tolua_S,2,"cWorld",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0);
+ cWorld* a_World = ((cWorld*) tolua_tousertype(tolua_S,2,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Initialize'", NULL);
#endif
{
- self->Initialize();
+ self->Initialize(a_World);
}
}
return 0;
@@ -3097,6 +3108,38 @@ static int tolua_AllToLua_cEntity_GetClass00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* method: GetWorld of class cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_GetWorld00
+static int tolua_AllToLua_cEntity_GetWorld00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetWorld'", NULL);
+#endif
+ {
+ cWorld* tolua_ret = (cWorld*) self->GetWorld();
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cWorld");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetWorld'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: GetPosition of class cEntity */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_GetPosition00
static int tolua_AllToLua_cEntity_GetPosition00(lua_State* tolua_S)
@@ -3860,11 +3903,12 @@ static int tolua_AllToLua_cEntity_SpawnOn00(lua_State* tolua_S)
class Lua__cEntity : public cEntity, public ToluaBase {
public:
- void Initialize( void ) {
+ void Initialize( cWorld* a_World) {
if (push_method("Initialize", tolua_AllToLua_cEntity_Initialize00)) {
- ToluaBase::dbcall(lua_state, 1, 0);
+ tolua_pushusertype(lua_state, (void*)a_World, "cWorld");
+ ToluaBase::dbcall(lua_state, 2, 0);
} else {
- return ( void ) cEntity:: Initialize();
+ return ( void ) cEntity:: Initialize(a_World);
};
};
unsigned int GetEntityType( void ) {
@@ -3927,8 +3971,8 @@ public:
};
};
- void cEntity__Initialize( void ) {
- return ( void )cEntity::Initialize();
+ void cEntity__Initialize( cWorld* a_World) {
+ return ( void )cEntity::Initialize(a_World);
};
unsigned int cEntity__GetEntityType( void ) {
return (unsigned int )cEntity::GetEntityType();
@@ -3983,18 +4027,20 @@ static int tolua_AllToLua_Lua__cEntity_cEntity__Initialize00(lua_State* tolua_S)
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"Lua__cEntity",0,&tolua_err) ||
- !tolua_isnoobj(tolua_S,2,&tolua_err)
+ !tolua_isusertype(tolua_S,2,"cWorld",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
Lua__cEntity* self = (Lua__cEntity*) tolua_tousertype(tolua_S,1,0);
+ cWorld* a_World = ((cWorld*) tolua_tousertype(tolua_S,2,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cEntity__Initialize'", NULL);
#endif
{
- self->cEntity__Initialize();
+ self->cEntity__Initialize(a_World);
}
}
return 0;
@@ -4518,11 +4564,12 @@ public:
return ( void ) cPawn:: KilledBy(a_Killer);
};
};
- void Initialize( void ) {
+ void Initialize( cWorld* a_World) {
if (push_method("Initialize", tolua_AllToLua_cEntity_Initialize00)) {
- ToluaBase::dbcall(lua_state, 1, 0);
+ tolua_pushusertype(lua_state, (void*)a_World, "cWorld");
+ ToluaBase::dbcall(lua_state, 2, 0);
} else {
- return ( void ) cPawn:: Initialize();
+ return ( void ) cPawn:: Initialize(a_World);
};
};
unsigned int GetEntityType( void ) {
@@ -4597,8 +4644,8 @@ public:
void cPawn__KilledBy( cEntity* a_Killer) {
return ( void )cPawn::KilledBy(a_Killer);
};
- void cPawn__Initialize( void ) {
- return ( void )cPawn::Initialize();
+ void cPawn__Initialize( cWorld* a_World) {
+ return ( void )cPawn::Initialize(a_World);
};
unsigned int cPawn__GetEntityType( void ) {
return (unsigned int )cPawn::GetEntityType();
@@ -5625,11 +5672,12 @@ public:
return ( void ) cPlayer:: KilledBy(a_Killer);
};
};
- void Initialize( void ) {
+ void Initialize( cWorld* a_World) {
if (push_method("Initialize", tolua_AllToLua_cEntity_Initialize00)) {
- ToluaBase::dbcall(lua_state, 1, 0);
+ tolua_pushusertype(lua_state, (void*)a_World, "cWorld");
+ ToluaBase::dbcall(lua_state, 2, 0);
} else {
- return ( void ) cPlayer:: Initialize();
+ return ( void ) cPlayer:: Initialize(a_World);
};
};
unsigned int GetEntityType( void ) {
@@ -5707,8 +5755,8 @@ public:
void cPlayer__KilledBy( cEntity* a_Killer) {
return ( void )cPlayer::KilledBy(a_Killer);
};
- void cPlayer__Initialize( void ) {
- return ( void )cPlayer::Initialize();
+ void cPlayer__Initialize( cWorld* a_World) {
+ return ( void )cPlayer::Initialize(a_World);
};
unsigned int cPlayer__GetEntityType( void ) {
return (unsigned int )cPlayer::GetEntityType();
@@ -9748,11 +9796,12 @@ public:
return ( bool ) cPickup:: CollectedBy(a_Dest);
};
};
- void Initialize( void ) {
+ void Initialize( cWorld* a_World) {
if (push_method("Initialize", tolua_AllToLua_cEntity_Initialize00)) {
- ToluaBase::dbcall(lua_state, 1, 0);
+ tolua_pushusertype(lua_state, (void*)a_World, "cWorld");
+ ToluaBase::dbcall(lua_state, 2, 0);
} else {
- return ( void ) cPickup:: Initialize();
+ return ( void ) cPickup:: Initialize(a_World);
};
};
unsigned int GetEntityType( void ) {
@@ -9818,8 +9867,8 @@ public:
bool cPickup__CollectedBy( cPlayer* a_Dest) {
return ( bool )cPickup::CollectedBy(a_Dest);
};
- void cPickup__Initialize( void ) {
- return ( void )cPickup::Initialize();
+ void cPickup__Initialize( cWorld* a_World) {
+ return ( void )cPickup::Initialize(a_World);
};
unsigned int cPickup__GetEntityType( void ) {
return (unsigned int )cPickup::GetEntityType();
@@ -13964,6 +14013,36 @@ static int tolua_set_cPacket_Login_m_MapSeed(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* get function: m_ServerMode of class cPacket_Login */
+#ifndef TOLUA_DISABLE_tolua_get_cPacket_Login_m_ServerMode
+static int tolua_get_cPacket_Login_m_ServerMode(lua_State* tolua_S)
+{
+ cPacket_Login* self = (cPacket_Login*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_ServerMode'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->m_ServerMode);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: m_ServerMode of class cPacket_Login */
+#ifndef TOLUA_DISABLE_tolua_set_cPacket_Login_m_ServerMode
+static int tolua_set_cPacket_Login_m_ServerMode(lua_State* tolua_S)
+{
+ cPacket_Login* self = (cPacket_Login*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_ServerMode'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->m_ServerMode = ((int) tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* get function: m_Dimension of class cPacket_Login */
#ifndef TOLUA_DISABLE_tolua_get_cPacket_Login_m_Dimension
static int tolua_get_cPacket_Login_m_Dimension(lua_State* tolua_S)
@@ -13994,6 +14073,96 @@ static int tolua_set_cPacket_Login_m_Dimension(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* get function: m_Difficulty of class cPacket_Login */
+#ifndef TOLUA_DISABLE_tolua_get_cPacket_Login_m_Difficulty
+static int tolua_get_cPacket_Login_m_Difficulty(lua_State* tolua_S)
+{
+ cPacket_Login* self = (cPacket_Login*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_Difficulty'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->m_Difficulty);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: m_Difficulty of class cPacket_Login */
+#ifndef TOLUA_DISABLE_tolua_set_cPacket_Login_m_Difficulty
+static int tolua_set_cPacket_Login_m_Difficulty(lua_State* tolua_S)
+{
+ cPacket_Login* self = (cPacket_Login*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_Difficulty'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->m_Difficulty = ((char) tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: m_WorldHeight of class cPacket_Login */
+#ifndef TOLUA_DISABLE_tolua_get_cPacket_Login_unsigned_m_WorldHeight
+static int tolua_get_cPacket_Login_unsigned_m_WorldHeight(lua_State* tolua_S)
+{
+ cPacket_Login* self = (cPacket_Login*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_WorldHeight'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->m_WorldHeight);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: m_WorldHeight of class cPacket_Login */
+#ifndef TOLUA_DISABLE_tolua_set_cPacket_Login_unsigned_m_WorldHeight
+static int tolua_set_cPacket_Login_unsigned_m_WorldHeight(lua_State* tolua_S)
+{
+ cPacket_Login* self = (cPacket_Login*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_WorldHeight'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->m_WorldHeight = ((unsigned char) tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* get function: m_MaxPlayers of class cPacket_Login */
+#ifndef TOLUA_DISABLE_tolua_get_cPacket_Login_unsigned_m_MaxPlayers
+static int tolua_get_cPacket_Login_unsigned_m_MaxPlayers(lua_State* tolua_S)
+{
+ cPacket_Login* self = (cPacket_Login*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_MaxPlayers'",NULL);
+#endif
+ tolua_pushnumber(tolua_S,(lua_Number)self->m_MaxPlayers);
+ return 1;
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* set function: m_MaxPlayers of class cPacket_Login */
+#ifndef TOLUA_DISABLE_tolua_set_cPacket_Login_unsigned_m_MaxPlayers
+static int tolua_set_cPacket_Login_unsigned_m_MaxPlayers(lua_State* tolua_S)
+{
+ cPacket_Login* self = (cPacket_Login*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_MaxPlayers'",NULL);
+ if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
+ tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
+#endif
+ self->m_MaxPlayers = ((unsigned char) tolua_tonumber(tolua_S,2,0))
+;
+ return 0;
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: new of class cPacket_BlockDig */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cPacket_BlockDig_new00
static int tolua_AllToLua_cPacket_BlockDig_new00(lua_State* tolua_S)
@@ -14816,7 +14985,6 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_constant(tolua_S,"E_CHAT",E_CHAT);
tolua_constant(tolua_S,"E_UPDATE_TIME",E_UPDATE_TIME);
tolua_constant(tolua_S,"E_ENTITY_EQUIPMENT",E_ENTITY_EQUIPMENT);
- tolua_constant(tolua_S,"E_CREATE_INVENTORY_ACTION",E_CREATE_INVENTORY_ACTION);
tolua_constant(tolua_S,"E_USE_ENTITY",E_USE_ENTITY);
tolua_constant(tolua_S,"E_UPDATE_HEALTH",E_UPDATE_HEALTH);
tolua_constant(tolua_S,"E_RESPAWN",E_RESPAWN);
@@ -14853,7 +15021,9 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_constant(tolua_S,"E_INVENTORY_SLOT",E_INVENTORY_SLOT);
tolua_constant(tolua_S,"E_INVENTORY_WHOLE",E_INVENTORY_WHOLE);
tolua_constant(tolua_S,"E_INVENTORY_PROGRESS",E_INVENTORY_PROGRESS);
+ tolua_constant(tolua_S,"E_CREATE_INVENTORY_ACTION",E_CREATE_INVENTORY_ACTION);
tolua_constant(tolua_S,"E_UPDATE_SIGN",E_UPDATE_SIGN);
+ tolua_constant(tolua_S,"E_PING",E_PING);
tolua_constant(tolua_S,"E_DISCONNECT",E_DISCONNECT);
tolua_array(tolua_S,"g_BlockLightValue",tolua_get_AllToLua_g_BlockLightValue,tolua_set_AllToLua_g_BlockLightValue);
tolua_array(tolua_S,"g_BlockSpreadLightFalloff",tolua_get_AllToLua_g_BlockSpreadLightFalloff,tolua_set_AllToLua_g_BlockSpreadLightFalloff);
@@ -14873,6 +15043,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_cclass(tolua_S,"cChatColor","cChatColor","",NULL);
tolua_beginmodule(tolua_S,"cChatColor");
tolua_variable(tolua_S,"Color",tolua_get_cChatColor_Color,NULL);
+ tolua_variable(tolua_S,"Delimiter",tolua_get_cChatColor_Delimiter,NULL);
tolua_variable(tolua_S,"Black",tolua_get_cChatColor_Black,NULL);
tolua_variable(tolua_S,"Navy",tolua_get_cChatColor_Navy,NULL);
tolua_variable(tolua_S,"Green",tolua_get_cChatColor_Green,NULL);
@@ -14910,6 +15081,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"GetEntityType",tolua_AllToLua_cEntity_GetEntityType00);
tolua_function(tolua_S,"IsA",tolua_AllToLua_cEntity_IsA00);
tolua_function(tolua_S,"GetClass",tolua_AllToLua_cEntity_GetClass00);
+ tolua_function(tolua_S,"GetWorld",tolua_AllToLua_cEntity_GetWorld00);
tolua_function(tolua_S,"GetPosition",tolua_AllToLua_cEntity_GetPosition00);
tolua_function(tolua_S,"GetPosX",tolua_AllToLua_cEntity_GetPosX00);
tolua_function(tolua_S,"GetPosY",tolua_AllToLua_cEntity_GetPosY00);
@@ -15416,7 +15588,11 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_variable(tolua_S,"m_ProtocolVersion",tolua_get_cPacket_Login_m_ProtocolVersion,tolua_set_cPacket_Login_m_ProtocolVersion);
tolua_variable(tolua_S,"m_Username",tolua_get_cPacket_Login_m_Username,tolua_set_cPacket_Login_m_Username);
tolua_variable(tolua_S,"m_MapSeed",tolua_get_cPacket_Login_m_MapSeed,tolua_set_cPacket_Login_m_MapSeed);
+ tolua_variable(tolua_S,"m_ServerMode",tolua_get_cPacket_Login_m_ServerMode,tolua_set_cPacket_Login_m_ServerMode);
tolua_variable(tolua_S,"m_Dimension",tolua_get_cPacket_Login_m_Dimension,tolua_set_cPacket_Login_m_Dimension);
+ tolua_variable(tolua_S,"m_Difficulty",tolua_get_cPacket_Login_m_Difficulty,tolua_set_cPacket_Login_m_Difficulty);
+ tolua_variable(tolua_S,"m_WorldHeight",tolua_get_cPacket_Login_unsigned_m_WorldHeight,tolua_set_cPacket_Login_unsigned_m_WorldHeight);
+ tolua_variable(tolua_S,"m_MaxPlayers",tolua_get_cPacket_Login_unsigned_m_MaxPlayers,tolua_set_cPacket_Login_unsigned_m_MaxPlayers);
tolua_endmodule(tolua_S);
#ifdef __cplusplus
tolua_cclass(tolua_S,"cPacket_BlockDig","cPacket_BlockDig","cPacket",tolua_collect_cPacket_BlockDig);
diff --git a/source/Bindings.h b/source/Bindings.h
index 4fb3dfa9e..d779e1f5b 100644
--- a/source/Bindings.h
+++ b/source/Bindings.h
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 07/15/11 01:36:28.
+** Generated automatically by tolua++-1.0.92 on 10/31/11 01:51:08.
*/
/* Exported function */
diff --git a/source/cBlockEntity.h b/source/cBlockEntity.h
index 75c864cec..cbb6e7681 100644
--- a/source/cBlockEntity.h
+++ b/source/cBlockEntity.h
@@ -6,12 +6,19 @@
enum ENUM_BLOCK_ID;
#endif
+class cChunk;
class cClientHandle;
class cPlayer;
class cBlockEntity
{
protected:
- cBlockEntity(ENUM_BLOCK_ID a_BlockType, int a_X, int a_Y, int a_Z) : m_PosX( a_X ), m_PosY( a_Y ), m_PosZ( a_Z ), m_BlockType( a_BlockType ) {}
+ cBlockEntity(ENUM_BLOCK_ID a_BlockType, int a_X, int a_Y, int a_Z, cChunk* a_Chunk)
+ : m_PosX( a_X )
+ , m_PosY( a_Y )
+ , m_PosZ( a_Z )
+ , m_BlockType( a_BlockType )
+ , m_Chunk( a_Chunk )
+ {}
public:
virtual ~cBlockEntity() {};
virtual void Destroy() {};
@@ -19,6 +26,7 @@ public:
int GetPosX() { return m_PosX; }
int GetPosY() { return m_PosY; }
int GetPosZ() { return m_PosZ; }
+ cChunk* GetChunk() { return m_Chunk; }
ENUM_BLOCK_ID GetBlockType() { return m_BlockType; }
@@ -30,5 +38,7 @@ protected:
int m_PosY;
int m_PosZ;
+ cChunk* m_Chunk;
+
ENUM_BLOCK_ID m_BlockType;
};
diff --git a/source/cCavespider.cpp b/source/cCavespider.cpp
index 75673d5ec..a34f72465 100644
--- a/source/cCavespider.cpp
+++ b/source/cCavespider.cpp
@@ -41,7 +41,7 @@ bool cCavespider::IsA( const char* a_EntityType )
void cCavespider::Tick(float a_Dt)
{
cMonster::Tick(a_Dt);
- m_EMPersonality = (cRoot::Get()->GetWorld()->GetWorldTime() < (12000 + 1000) )? PASSIVE:AGGRESSIVE;
+ m_EMPersonality = (GetWorld()->GetWorldTime() < (12000 + 1000) )? PASSIVE:AGGRESSIVE;
}
void cCavespider::KilledBy( cEntity* a_Killer )
@@ -49,12 +49,12 @@ void cCavespider::KilledBy( cEntity* a_Killer )
if( (rand() % 5) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
if( (rand() % 1) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
cMonster::KilledBy( a_Killer );
}
diff --git a/source/cChestEntity.cpp b/source/cChestEntity.cpp
index f76848879..54a06fcb9 100644
--- a/source/cChestEntity.cpp
+++ b/source/cChestEntity.cpp
@@ -7,11 +7,12 @@
#include "cWindow.h"
#include "cPickup.h"
#include "cMCLogger.h"
+#include "cChunk.h"
#include <json/json.h>
-cChestEntity::cChestEntity(int a_X, int a_Y, int a_Z)
- : cBlockEntity( E_BLOCK_CHEST, a_X, a_Y, a_Z )
+cChestEntity::cChestEntity(int a_X, int a_Y, int a_Z, cChunk* a_Chunk)
+ : cBlockEntity( E_BLOCK_CHEST, a_X, a_Y, a_Z, a_Chunk )
{
m_Content = new cItem[ c_ChestHeight*c_ChestWidth ];
}
@@ -37,7 +38,7 @@ void cChestEntity::Destroy()
if( !m_Content[i].IsEmpty() )
{
cPickup* Pickup = new cPickup( m_PosX*32 + 16, m_PosY*32 + 16, m_PosZ*32 + 16, m_Content[i], 0, 1.f, 0 );
- Pickup->Initialize();
+ Pickup->Initialize( GetChunk()->GetWorld() );
m_Content[i].Empty();
}
}
diff --git a/source/cChestEntity.h b/source/cChestEntity.h
index 5170b168d..785f57553 100644
--- a/source/cChestEntity.h
+++ b/source/cChestEntity.h
@@ -16,7 +16,7 @@ class cNBTData;
class cChestEntity : public cBlockEntity, public cWindowOwner
{
public:
- cChestEntity(int a_X, int a_Y, int a_Z);
+ cChestEntity(int a_X, int a_Y, int a_Z, cChunk* a_Chunk);
virtual ~cChestEntity();
virtual void Destroy();
diff --git a/source/cChicken.cpp b/source/cChicken.cpp
index ed420f256..ba534cc61 100644
--- a/source/cChicken.cpp
+++ b/source/cChicken.cpp
@@ -52,12 +52,12 @@ void cChicken::KilledBy( cEntity* a_Killer )
if( (rand() % 5) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
if( (rand() % 1) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
cMonster::KilledBy( a_Killer );
}
diff --git a/source/cChunk.cpp b/source/cChunk.cpp
index 8e03ff6c7..c509e23b7 100644
--- a/source/cChunk.cpp
+++ b/source/cChunk.cpp
@@ -74,7 +74,7 @@ cChunk::~cChunk()
{
if( (*itr)->GetEntityType() != cEntity::E_PLAYER )
{
- cRoot::Get()->GetWorld()->AddToRemoveEntityQueue( **itr ); // World also destroys the entity
+ m_World->AddToRemoveEntityQueue( **itr ); // World also destroys the entity
}
}
m_pState->m_Entities.clear();
@@ -88,7 +88,7 @@ cChunk::~cChunk()
delete m_pState;
}
-cChunk::cChunk(int a_X, int a_Y, int a_Z)
+cChunk::cChunk(int a_X, int a_Y, int a_Z, cWorld* a_World)
: m_pState( new sChunkState )
, m_bCalculateLighting( false )
, m_bCalculateHeightmap( false )
@@ -104,6 +104,7 @@ cChunk::cChunk(int a_X, int a_Y, int a_Z)
, m_BlockTickY( 0 )
, m_BlockTickZ( 0 )
, m_EntitiesCriticalSection( 0 )
+ , m_World( a_World )
{
//LOG("cChunk::cChunk(%i, %i, %i)", a_X, a_Y, a_Z);
m_EntitiesCriticalSection = new cCriticalSection();
@@ -237,7 +238,7 @@ void cChunk::Tick(float a_Dt)
{
SetBlock( X, Y, Z, 0, 0 );
cPickup* Pickup = new cPickup( (X+m_PosX*16) * 32 + 16, (Y+m_PosY*128) * 32 + 16, (Z+m_PosZ*16) * 32 + 16, cItem( (ENUM_ITEM_ID)BlockID, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( m_World );
}
}
break;
@@ -251,12 +252,11 @@ void cChunk::Tick(float a_Dt)
char YY = (char)Y;
int ZZ = Z + m_PosZ*16;
AddDirection( XX, YY, ZZ, Dir, true );
- cWorld* World = cRoot::Get()->GetWorld();
- if( World->GetBlock( XX, YY, ZZ ) == E_BLOCK_AIR )
+ if( m_World->GetBlock( XX, YY, ZZ ) == E_BLOCK_AIR )
{
SetBlock( X, Y, Z, 0, 0 );
cPickup* Pickup = new cPickup( (X+m_PosX*16) * 32 + 16, (Y+m_PosY*128) * 32 + 16, (Z+m_PosZ*16) * 32 + 16, cItem( (ENUM_ITEM_ID)BlockID, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( m_World );
}
}
break;
@@ -267,12 +267,11 @@ void cChunk::Tick(float a_Dt)
char YY = (char)Y;
int ZZ = Z + m_PosZ*16;
AddDirection( XX, YY, ZZ, Dir, true );
- cWorld* World = cRoot::Get()->GetWorld();
- if( World->GetBlock( XX, YY, ZZ ) == E_BLOCK_AIR )
+ if( m_World->GetBlock( XX, YY, ZZ ) == E_BLOCK_AIR )
{
SetBlock( X, Y, Z, 0, 0 );
cPickup* Pickup = new cPickup( (X+m_PosX*16) * 32 + 16, (Y+m_PosY*128) * 32 + 16, (Z+m_PosZ*16) * 32 + 16, cItem( (ENUM_ITEM_ID)BlockID, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( m_World );
}
}
break;
@@ -337,7 +336,7 @@ void cChunk::Tick(float a_Dt)
case E_BLOCK_SAPLING:
{
FastSetBlock( m_BlockTickX, m_BlockTickY, m_BlockTickZ, E_BLOCK_AIR, GetLight( m_BlockMeta, Index ) );
- cRoot::Get()->GetWorld()->GrowTree( m_BlockTickX + m_PosX*16, m_BlockTickY, m_BlockTickZ + m_PosZ*16 );
+ m_World->GrowTree( m_BlockTickX + m_PosX*16, m_BlockTickY, m_BlockTickZ + m_PosZ*16 );
}
default:
break;
@@ -375,18 +374,18 @@ void cChunk::CreateBlockEntities()
{
case E_BLOCK_CHEST:
{
- m_pState->m_BlockEntities.push_back( new cChestEntity( x + m_PosX*16, y + m_PosY*128, z + m_PosZ*16 ) );
+ m_pState->m_BlockEntities.push_back( new cChestEntity( x + m_PosX*16, y + m_PosY*128, z + m_PosZ*16, this ) );
}
break;
case E_BLOCK_FURNACE:
{
- m_pState->m_BlockEntities.push_back( new cFurnaceEntity( x + m_PosX*16, y + m_PosY*128, z + m_PosZ*16 ) );
+ m_pState->m_BlockEntities.push_back( new cFurnaceEntity( x + m_PosX*16, y + m_PosY*128, z + m_PosZ*16, this ) );
}
break;
case E_BLOCK_SIGN_POST:
case E_BLOCK_WALLSIGN:
{
- m_pState->m_BlockEntities.push_back( new cSignEntity( BlockType, x + m_PosX*16, y + m_PosY*128, z + m_PosZ*16 ) );
+ m_pState->m_BlockEntities.push_back( new cSignEntity( BlockType, x + m_PosX*16, y + m_PosY*128, z + m_PosZ*16, this ) );
}
break;
default:
@@ -595,8 +594,8 @@ void cChunk::SpreadLight(char* a_LightBuffer)
bool bCalcLeft, bCalcRight, bCalcFront, bCalcBack;
bCalcLeft = bCalcRight = bCalcFront = bCalcBack = false;
// Spread to neighbour chunks X-axis
- cChunk* LeftChunk = cRoot::Get()->GetWorld()->GetChunkUnreliable( m_PosX-1, m_PosY, m_PosZ );
- cChunk* RightChunk = cRoot::Get()->GetWorld()->GetChunkUnreliable( m_PosX+1, m_PosY, m_PosZ );
+ cChunk* LeftChunk = m_World->GetChunkUnreliable( m_PosX-1, m_PosY, m_PosZ );
+ cChunk* RightChunk = m_World->GetChunkUnreliable( m_PosX+1, m_PosY, m_PosZ );
char* LeftSky = 0, *RightSky = 0;
if(LeftChunk) LeftSky = (a_LightBuffer==m_BlockSkyLight)?LeftChunk->pGetSkyLight():LeftChunk->pGetLight();
if(RightChunk) RightSky = (a_LightBuffer==m_BlockSkyLight)?RightChunk->pGetSkyLight():RightChunk->pGetLight();
@@ -633,8 +632,8 @@ void cChunk::SpreadLight(char* a_LightBuffer)
}
// Spread to neighbour chunks Z-axis
- cChunk* FrontChunk = cRoot::Get()->GetWorld()->GetChunkUnreliable( m_PosX, m_PosY, m_PosZ-1 );
- cChunk* BackChunk = cRoot::Get()->GetWorld()->GetChunkUnreliable( m_PosX, m_PosY, m_PosZ+1 );
+ cChunk* FrontChunk = m_World->GetChunkUnreliable( m_PosX, m_PosY, m_PosZ-1 );
+ cChunk* BackChunk = m_World->GetChunkUnreliable( m_PosX, m_PosY, m_PosZ+1 );
char* FrontSky = 0, *BackSky = 0;
if(FrontChunk) FrontSky = (a_LightBuffer==m_BlockSkyLight)?FrontChunk->pGetSkyLight():FrontChunk->pGetLight();
if(BackChunk) BackSky = (a_LightBuffer==m_BlockSkyLight)?BackChunk->pGetSkyLight():BackChunk->pGetLight();
@@ -670,10 +669,10 @@ void cChunk::SpreadLight(char* a_LightBuffer)
}
}
- if( bCalcLeft ) cRoot::Get()->GetWorld()->ReSpreadLighting( LeftChunk );
- if( bCalcRight ) cRoot::Get()->GetWorld()->ReSpreadLighting( RightChunk );
- if( bCalcFront ) cRoot::Get()->GetWorld()->ReSpreadLighting( FrontChunk );
- if( bCalcBack ) cRoot::Get()->GetWorld()->ReSpreadLighting( BackChunk );
+ if( bCalcLeft ) m_World->ReSpreadLighting( LeftChunk );
+ if( bCalcRight ) m_World->ReSpreadLighting( RightChunk );
+ if( bCalcFront ) m_World->ReSpreadLighting( FrontChunk );
+ if( bCalcBack ) m_World->ReSpreadLighting( BackChunk );
}
float GetNoise( float x, float y, cNoise & a_Noise )
@@ -745,7 +744,7 @@ void cChunk::GenerateTerrain()
const ENUM_BLOCK_ID RedID = E_BLOCK_REDSTONE_ORE;
*/
- cNoise m_Noise( cRoot::Get()->GetWorld()->GetWorldSeed() );
+ cNoise m_Noise( m_World->GetWorldSeed() );
for(int z = 0; z < 16; z++)
{
const float zz = (float)(m_PosZ*16 + z);
@@ -855,7 +854,7 @@ void cChunk::GenerateTerrain()
float val3 = m_Noise.SSE_CubicNoise2D( xx*0.01f+10, zz*0.01f+10 );
float val4 = m_Noise.SSE_CubicNoise2D( xx*0.05f+20, zz*0.05f+20 );
if( val1 + val2 > 0.2f && (rand()%128) > 124 )
- cRoot::Get()->GetWorld()->GrowTree( xx, TopY, zz );
+ m_World->GrowTree( xx, TopY, zz );
else if( val3 > 0.2f && (rand()%128) > 124 )
m_BlockType[ MakeIndex(x, TopY+1, z) ] = E_BLOCK_YELLOW_FLOWER;
else if( val4 > 0.2f && (rand()%128) > 124 )
@@ -931,14 +930,14 @@ void cChunk::SetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_Block
switch( a_BlockType )
{
case E_BLOCK_CHEST:
- AddBlockEntity( new cChestEntity( a_X + m_PosX*16, a_Y + m_PosY*128, a_Z + m_PosZ*16 ) );
+ AddBlockEntity( new cChestEntity( a_X + m_PosX*16, a_Y + m_PosY*128, a_Z + m_PosZ*16, this ) );
break;
case E_BLOCK_FURNACE:
- AddBlockEntity( new cFurnaceEntity( a_X + m_PosX*16, a_Y + m_PosY*128, a_Z + m_PosZ*16 ) );
+ AddBlockEntity( new cFurnaceEntity( a_X + m_PosX*16, a_Y + m_PosY*128, a_Z + m_PosZ*16, this ) );
break;
case E_BLOCK_SIGN_POST:
case E_BLOCK_WALLSIGN:
- AddBlockEntity( new cSignEntity( (ENUM_BLOCK_ID)a_BlockType, a_X + m_PosX*16, a_Y + m_PosY*128, a_Z + m_PosZ*16 ) );
+ AddBlockEntity( new cSignEntity( (ENUM_BLOCK_ID)a_BlockType, a_X + m_PosX*16, a_Y + m_PosY*128, a_Z + m_PosZ*16, this ) );
break;
default:
break;
@@ -1056,7 +1055,7 @@ bool cChunk::RemoveEntity( cEntity & a_Entity, cChunk* a_CalledFrom /* = 0 */ )
if( !a_CalledFrom )
{
UnlockEntities();
- return cRoot::Get()->GetWorld()->RemoveEntityFromChunk( a_Entity, this );
+ return m_World->RemoveEntityFromChunk( a_Entity, this );
}
UnlockEntities();
return false;
@@ -1125,7 +1124,7 @@ bool cChunk::LoadFromDisk()
{
case E_BLOCK_CHEST:
{
- cChestEntity* ChestEntity = new cChestEntity( 0, 0, 0 );
+ cChestEntity* ChestEntity = new cChestEntity( 0, 0, 0, this );
if( !ChestEntity->LoadFromFile( f ) )
{
LOGERROR("ERROR READING CHEST FROM FILE %s", SourceFile );
@@ -1138,7 +1137,7 @@ bool cChunk::LoadFromDisk()
break;
case E_BLOCK_FURNACE:
{
- cFurnaceEntity* FurnaceEntity = new cFurnaceEntity( 0, 0, 0 );
+ cFurnaceEntity* FurnaceEntity = new cFurnaceEntity( 0, 0, 0, this );
if( !FurnaceEntity->LoadFromFile( f ) )
{
LOGERROR("ERROR READING FURNACE FROM FILE %s", SourceFile );
@@ -1153,7 +1152,7 @@ bool cChunk::LoadFromDisk()
case E_BLOCK_SIGN_POST:
case E_BLOCK_WALLSIGN:
{
- cSignEntity* SignEntity = new cSignEntity(BlockType, 0, 0, 0 );
+ cSignEntity* SignEntity = new cSignEntity(BlockType, 0, 0, 0, this );
if( !SignEntity->LoadFromFile( f ) )
{
LOGERROR("ERROR READING SIGN FROM FILE %s", SourceFile );
@@ -1275,7 +1274,7 @@ void cChunk::LoadFromJson( const Json::Value & a_Value )
for( Json::Value::iterator itr = AllChests.begin(); itr != AllChests.end(); ++itr )
{
Json::Value & Chest = *itr;
- cChestEntity* ChestEntity = new cChestEntity(0,0,0);
+ cChestEntity* ChestEntity = new cChestEntity(0,0,0, this);
if( !ChestEntity->LoadFromJson( Chest ) )
{
LOGERROR("ERROR READING CHEST FROM JSON!" );
@@ -1292,7 +1291,7 @@ void cChunk::LoadFromJson( const Json::Value & a_Value )
for( Json::Value::iterator itr = AllFurnaces.begin(); itr != AllFurnaces.end(); ++itr )
{
Json::Value & Furnace = *itr;
- cFurnaceEntity* FurnaceEntity = new cFurnaceEntity(0,0,0);
+ cFurnaceEntity* FurnaceEntity = new cFurnaceEntity(0,0,0, this);
if( !FurnaceEntity->LoadFromJson( Furnace ) )
{
LOGERROR("ERROR READING FURNACE FROM JSON!" );
@@ -1309,7 +1308,7 @@ void cChunk::LoadFromJson( const Json::Value & a_Value )
for( Json::Value::iterator itr = AllSigns.begin(); itr != AllSigns.end(); ++itr )
{
Json::Value & Sign = *itr;
- cSignEntity* SignEntity = new cSignEntity( E_BLOCK_SIGN_POST, 0,0,0);
+ cSignEntity* SignEntity = new cSignEntity( E_BLOCK_SIGN_POST, 0,0,0, this);
if( !SignEntity->LoadFromJson( Sign ) )
{
LOGERROR("ERROR READING SIGN FROM JSON!" );
diff --git a/source/cChunk.h b/source/cChunk.h
index d90e817cf..c8db5f69c 100644
--- a/source/cChunk.h
+++ b/source/cChunk.h
@@ -7,6 +7,7 @@ namespace Json
class Value;
};
+class cWorld;
class cCriticalSection;
class cFurnaceEntity;
class cPacket;
@@ -17,16 +18,17 @@ class cServer;
class cChunk
{
public:
- cChunk(int a_X, int a_Y, int a_Z);
+ cChunk(int a_X, int a_Y, int a_Z, cWorld* a_World);
~cChunk();
void Initialize();
void Tick(float a_Dt);
- inline int GetPosX() { return m_PosX; }
- inline int GetPosY() { return m_PosY; }
- inline int GetPosZ() { return m_PosZ; }
+ int GetPosX() { return m_PosX; }
+ int GetPosY() { return m_PosY; }
+ int GetPosZ() { return m_PosZ; }
+ cWorld* GetWorld() { return m_World; }
void Send( cClientHandle* a_Client );
void AsyncUnload( cClientHandle* a_Client );
@@ -112,6 +114,7 @@ private:
bool m_bCalculateHeightmap;
int m_PosX, m_PosY, m_PosZ;
+ cWorld* m_World;
char m_BlockData[c_BlockDataSize]; // Chunk data ready to be compressed and sent
char *m_BlockType; // Pointers to an element in m_BlockData
diff --git a/source/cChunkMap.cpp b/source/cChunkMap.cpp
index 32bdf576a..44dfe3a29 100644
--- a/source/cChunkMap.cpp
+++ b/source/cChunkMap.cpp
@@ -19,12 +19,13 @@
#define LAYER_SIZE (32)
-cChunkMap::cChunkMap( int a_Width, int a_Height )
+cChunkMap::cChunkMap( int a_Width, int a_Height, cWorld* a_World )
: m_Nodes( new cChunkNode[ a_Width * a_Height ] )
, m_Width( a_Width )
, m_Height( a_Height )
, m_Layers( 0 )
, m_NumLayers( 0 )
+ , m_World( a_World )
{
}
@@ -362,7 +363,7 @@ cChunk* cChunkMap::GetChunk( int a_X, int a_Y, int a_Z )
}
else
{
- cChunk* Chunk = new cChunk(a_X, a_Y, a_Z);
+ cChunk* Chunk = new cChunk(a_X, a_Y, a_Z, m_World);
memcpy( Chunk->m_BlockData, BlockData, cChunk::c_BlockDataSize );
Chunk->CalculateHeightmap();
Data->m_LiveChunk = Chunk;
@@ -426,7 +427,7 @@ void cChunkMap::Tick( float a_Dt )
void cChunkMap::UnloadUnusedChunks()
{
- cWorld* World = cRoot::Get()->GetWorld();
+ cWorld* World = m_World;
/* // OLD
for( int i = 0; i < m_Width*m_Height; ++i )
{
diff --git a/source/cChunkMap.h b/source/cChunkMap.h
index 19619f0c5..d1a289a7d 100644
--- a/source/cChunkMap.h
+++ b/source/cChunkMap.h
@@ -1,11 +1,12 @@
#pragma once
+class cWorld;
class cEntity;
class cChunk;
class cChunkMap
{
public:
- cChunkMap( int a_Width, int a_Height );
+ cChunkMap( int a_Width, int a_Height, cWorld* a_World );
~cChunkMap();
void AddChunk( cChunk* a_Chunk );
@@ -88,4 +89,5 @@ private:
cChunkNode* m_Nodes;
int m_Width, m_Height;
+ cWorld* m_World;
};
diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp
index 32920b028..ab7e66786 100644
--- a/source/cClientHandle.cpp
+++ b/source/cClientHandle.cpp
@@ -432,7 +432,7 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
}
// Now initialize player (adds to entity list etc.)
- m_Player->Initialize();
+ m_Player->Initialize( cRoot::Get()->GetWorld() ); // TODO - Get correct world for player
// Broadcasts to all but this ( this is actually handled in cChunk.cpp, after entity is added to the chunk )
//m_Player->SpawnOn( 0 );
@@ -479,13 +479,13 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
}
else
{
- cWorld* World = cRoot::Get()->GetWorld();
+ cWorld* World = m_Player->GetWorld();
char OldBlock = World->GetBlock(PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ);
char MetaData = World->GetBlockMeta(PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ);
- bool bBroken = (PacketData->m_Status == 0x02) || g_BlockOneHitDig[(int)OldBlock] || ( (PacketData->m_Status == 0x00) && (cRoot::Get()->GetWorld()->GetGameMode() == 1) ); //need to change to check for client's gamemode.
+ bool bBroken = (PacketData->m_Status == 0x02) || g_BlockOneHitDig[(int)OldBlock] || ( (PacketData->m_Status == 0x00) && (World->GetGameMode() == 1) ); //need to change to check for client's gamemode.
cItem PickupItem;
- if( bBroken && !(cRoot::Get()->GetWorld()->GetGameMode() == 1) ) // broken
+ if( bBroken && !(World->GetGameMode() == 1) ) // broken
{
ENUM_ITEM_ID PickupID = cBlockToPickup::ToPickup( (ENUM_BLOCK_ID)OldBlock, m_Player->GetInventory().GetEquippedItem().m_ItemID );
PickupItem.m_ItemID = PickupID;
@@ -496,7 +496,7 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
{
if( bBroken ) // Block broken
{
- if( cRoot::Get()->GetWorld()->DigBlock( PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ, PickupItem ) )
+ if( World->DigBlock( PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ, PickupItem ) )
{
int helditem = m_Player->GetInventory().GetEquippedItem().m_ItemID;
bool itemhasdur = false;
@@ -572,7 +572,7 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
}
else
{
- cRoot::Get()->GetWorld()->SendBlockTo( PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ, m_Player );
+ World->SendBlockTo( PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ, m_Player );
}
}
}
@@ -592,7 +592,8 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
if( PacketData->m_Direction > -1 )
{
AddDirection( PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ, PacketData->m_Direction );
- cRoot::Get()->GetWorld()->SendBlockTo( PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ, m_Player );
+
+ m_Player->GetWorld()->SendBlockTo( PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ, m_Player );
}
break;
}
@@ -604,7 +605,7 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
bool bPlaceBlock = true;
if( PacketData->m_Direction >= 0 )
{
- ENUM_BLOCK_ID BlockID = (ENUM_BLOCK_ID)cRoot::Get()->GetWorld()->GetBlock( PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ );
+ ENUM_BLOCK_ID BlockID = (ENUM_BLOCK_ID)m_Player->GetWorld()->GetBlock( PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ );
switch( BlockID )
{
case E_BLOCK_WORKBENCH:
@@ -618,7 +619,7 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
case E_BLOCK_CHEST:
{
bPlaceBlock = false;
- cBlockEntity* BlockEntity = cRoot::Get()->GetWorld()->GetBlockEntity( PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ );
+ cBlockEntity* BlockEntity = m_Player->GetWorld()->GetBlockEntity( PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ );
if( BlockEntity )
{
BlockEntity->UsedBy( *m_Player );
@@ -727,7 +728,7 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
int Z = PacketData->m_PosZ;
AddDirection( X, Y, Z, PacketData->m_Direction );
- cRoot::Get()->GetWorld()->SetBlock( X, Y, Z, (char)PacketData->m_ItemType, MetaData );
+ m_Player->GetWorld()->SetBlock( X, Y, Z, (char)PacketData->m_ItemType, MetaData );
}
}
}
@@ -755,7 +756,7 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
if( m_Player->GetInventory().RemoveItem( DroppedItem ) )
{
cPickup* Pickup = new cPickup( PacketData );
- Pickup->Initialize();
+ Pickup->Initialize( m_Player->GetWorld() );
}
}
break;
@@ -836,7 +837,7 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
case E_UPDATE_SIGN:
{
cPacket_UpdateSign* PacketData = reinterpret_cast<cPacket_UpdateSign*>(a_Packet);
- cWorld* World = cRoot::Get()->GetWorld();
+ cWorld* World = m_Player->GetWorld();
cChunk* Chunk = World->GetChunkOfBlock( PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ );
cBlockEntity* BlockEntity = Chunk->GetBlockEntity( PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ );
if( BlockEntity && (BlockEntity->GetBlockType() == E_BLOCK_SIGN_POST || BlockEntity->GetBlockType() == E_BLOCK_WALLSIGN ) )
@@ -852,7 +853,7 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
cPacket_UseEntity* PacketData = reinterpret_cast<cPacket_UseEntity*>(a_Packet);
if( PacketData->m_bLeftClick )
{
- cWorld* World = cRoot::Get()->GetWorld();
+ cWorld* World = m_Player->GetWorld();
cEntity* Entity = World->GetEntity( PacketData->m_TargetID );
if( Entity && Entity->IsA("cPawn") )
{
@@ -902,12 +903,12 @@ void cClientHandle::AuthenticateThread( void* a_Param )
void cClientHandle::SendLoginResponse()
{
- cWorld* World = cRoot::Get()->GetWorld();
+ cWorld* World = cRoot::Get()->GetWorld(); // TODO - Get the correct world or better yet, move this to the main thread so we don't have to lock anything
World->LockEntities();
// Spawn player (only serversided, so data is loaded)
m_Player = new cPlayer( this, GetUsername() ); // !!DO NOT INITIALIZE!! <- is done after receiving MoveLook Packet
- cRoot::Get()->GetPluginManager()->CallHook( cPluginManager::E_PLUGIN_PLAYER_SPAWN, 1, m_Player );
+ cRoot::Get()->GetPluginManager()->CallHook( cPluginManager::E_PLUGIN_PLAYER_SPAWN, 1, m_Player ); // TODO - this function is called from a seperate thread, which might be dangerous
// Return a server login packet
cPacket_Login LoginResponse;
diff --git a/source/cCow.cpp b/source/cCow.cpp
index 3f6286dec..517fa84d8 100644
--- a/source/cCow.cpp
+++ b/source/cCow.cpp
@@ -52,12 +52,12 @@ void cCow::KilledBy( cEntity* a_Killer )
if( (rand() % 5) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
if( (rand() % 1) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
cMonster::KilledBy( a_Killer );
}
diff --git a/source/cCraftingWindow.cpp b/source/cCraftingWindow.cpp
index be3de600b..c8ddaa5d7 100644
--- a/source/cCraftingWindow.cpp
+++ b/source/cCraftingWindow.cpp
@@ -95,7 +95,7 @@ void cCraftingWindow::Close( cPlayer & a_Player )
EulerToVector( -a_Player.GetRotation(), a_Player.GetPitch(), vZ, vX, vY );
vY = -vY*2 + 1.f;
cPickup* Pickup = new cPickup( (int)(a_Player.GetPosX()*32), (int)(a_Player.GetPosY()*32) + (int)(1.6f*32), (int)(a_Player.GetPosZ()*32), *Item, vX*2, vY*2, vZ*2 );
- Pickup->Initialize();
+ Pickup->Initialize( a_Player.GetWorld() );
}
Item->Empty();
}
diff --git a/source/cCreeper.cpp b/source/cCreeper.cpp
index ffebc2c58..18f9a6730 100644
--- a/source/cCreeper.cpp
+++ b/source/cCreeper.cpp
@@ -48,12 +48,12 @@ void cCreeper::KilledBy( cEntity* a_Killer )
if( (rand() % 5) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
if( (rand() % 1) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
cMonster::KilledBy( a_Killer );
}
diff --git a/source/cEnderman.cpp b/source/cEnderman.cpp
index 42a57a613..166d05b20 100644
--- a/source/cEnderman.cpp
+++ b/source/cEnderman.cpp
@@ -41,7 +41,7 @@ bool cEnderman::IsA( const char* a_EntityType )
void cEnderman::Tick(float a_Dt)
{
cMonster::Tick(a_Dt);
- if (cRoot::Get()->GetWorld()->GetWorldTime() < (12000 + 1000) ) { //if daylight
+ if (GetWorld()->GetWorldTime() < (12000 + 1000) ) { //if daylight
m_EMMetaState = BURNING; // BURN, BABY, BURN! >:D
}
}
@@ -51,12 +51,12 @@ void cEnderman::KilledBy( cEntity* a_Killer )
if( (rand() % 5) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
if( (rand() % 1) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
cMonster::KilledBy( a_Killer );
}
diff --git a/source/cEntity.cpp b/source/cEntity.cpp
index 3b62bec9c..b8cc26199 100644
--- a/source/cEntity.cpp
+++ b/source/cEntity.cpp
@@ -27,6 +27,7 @@ cEntity::cEntity(const double & a_X, const double & a_Y, const double & a_Z)
, m_bDirtyOrientation( true )
, m_bDestroyed( false )
, m_EntityType( E_ENTITY )
+ , m_World( 0 )
{
m_EntityCount++;
m_UniqueID = m_EntityCount;
@@ -36,23 +37,27 @@ cEntity::~cEntity()
{
delete m_Referencers;
delete m_References;
- cChunk* Chunk = cRoot::Get()->GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
- if( Chunk )
+ if( m_World )
{
- cPacket_DestroyEntity DestroyEntity( this );
- Chunk->Broadcast( DestroyEntity );
- Chunk->RemoveEntity( *this );
+ cChunk* Chunk = m_World->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
+ if( Chunk )
+ {
+ cPacket_DestroyEntity DestroyEntity( this );
+ Chunk->Broadcast( DestroyEntity );
+ Chunk->RemoveEntity( *this );
+ }
}
delete m_Pos;
delete m_Rot;
}
-void cEntity::Initialize()
+void cEntity::Initialize( cWorld* a_World )
{
- cRoot::Get()->GetWorld()->AddEntity( this );
+ m_World = a_World;
+ m_World->AddEntity( this );
cWorld::BlockToChunk( (int)m_Pos->x, (int)m_Pos->y, (int)m_Pos->z, m_ChunkX, m_ChunkY, m_ChunkZ );
- cChunk* Chunk = cRoot::Get()->GetWorld()->GetChunk( m_ChunkX, m_ChunkY, m_ChunkZ );
+ cChunk* Chunk = m_World->GetChunk( m_ChunkX, m_ChunkY, m_ChunkZ );
if( Chunk )
{
//LOG("Adding entity %i to chunk %i %i %i", m_UniqueID, Chunk->GetPosX(), Chunk->GetPosY(), Chunk->GetPosZ() );
@@ -74,9 +79,8 @@ void cEntity::MoveToCorrectChunk()
cWorld::BlockToChunk( (int)m_Pos->x, (int)m_Pos->y, (int)m_Pos->z, ChunkX, ChunkY, ChunkZ );
if( m_ChunkX != ChunkX || m_ChunkY != ChunkY || m_ChunkZ != ChunkZ )
{
- cWorld* World = cRoot::Get()->GetWorld();
LOG("From %i %i To %i %i", m_ChunkX, m_ChunkZ, ChunkX, ChunkZ );
- cChunk* Chunk = World->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
+ cChunk* Chunk = m_World->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
typedef std::list< cClientHandle* > ClientList;
ClientList BeforeClients;
@@ -86,7 +90,7 @@ void cEntity::MoveToCorrectChunk()
BeforeClients = Chunk->GetClients();
}
m_ChunkX = ChunkX; m_ChunkY = ChunkY; m_ChunkZ = ChunkZ;
- cChunk* NewChunk = World->GetChunk( m_ChunkX, m_ChunkY, m_ChunkZ );
+ cChunk* NewChunk = m_World->GetChunk( m_ChunkX, m_ChunkY, m_ChunkZ );
ClientList AfterClients;
if( NewChunk )
{
diff --git a/source/cEntity.h b/source/cEntity.h
index 602abeeaf..509a5c1d5 100644
--- a/source/cEntity.h
+++ b/source/cEntity.h
@@ -27,6 +27,7 @@
CLASS_DEF_ISA( classname, superclass ) \
CLASS_DEF_GETCLASS( classname )
+class cWorld;
class cReferenceManager;
class Vector3d;
class Vector3f;
@@ -37,7 +38,7 @@ public: //tolua_export
cEntity(const double & a_X, const double & a_Y, const double & a_Z); //tolua_export
virtual ~cEntity(); //tolua_export
- virtual void Initialize(); //tolua_export
+ virtual void Initialize( cWorld* a_World ); //tolua_export
enum ENUM_ENTITY_TYPE //tolua_export
{ //tolua_export
@@ -50,6 +51,7 @@ public: //tolua_export
virtual bool IsA( const char* a_EntityType ); //tolua_export
virtual const char* GetClass(); //tolua_export
+ cWorld* GetWorld() { return m_World; } //tolua_export
const Vector3d & GetPosition(); //tolua_export
const double & GetPosX(); //tolua_export
@@ -105,4 +107,6 @@ protected:
bool m_bDestroyed;
ENUM_ENTITY_TYPE m_EntityType;
+private:
+ cWorld* m_World;
}; //tolua_export
diff --git a/source/cFurnaceEntity.cpp b/source/cFurnaceEntity.cpp
index 1bca35aca..95f5f566c 100644
--- a/source/cFurnaceEntity.cpp
+++ b/source/cFurnaceEntity.cpp
@@ -17,8 +17,8 @@
#include <json/json.h>
-cFurnaceEntity::cFurnaceEntity(int a_X, int a_Y, int a_Z)
- : cBlockEntity( E_BLOCK_FURNACE, a_X, a_Y, a_Z )
+cFurnaceEntity::cFurnaceEntity(int a_X, int a_Y, int a_Z, cChunk* a_Chunk)
+ : cBlockEntity( E_BLOCK_FURNACE, a_X, a_Y, a_Z, a_Chunk )
, m_Items( new cItem[3] )
, m_CookingItem( 0 )
, m_CookTime( 0 )
@@ -51,15 +51,13 @@ void cFurnaceEntity::Destroy()
if( !m_Items[i].IsEmpty() )
{
cPickup* Pickup = new cPickup( m_PosX*32 + 16, m_PosY*32 + 16, m_PosZ*32 + 16, m_Items[i], 0, 1.f, 0 );
- Pickup->Initialize();
+ Pickup->Initialize( m_Chunk->GetWorld() );
m_Items[i].Empty();
}
}
// Remove from tick list
- cWorld* World = cRoot::Get()->GetWorld();
- cChunk* Chunk = World->GetChunkOfBlock( m_PosX, m_PosY, m_PosZ );
- Chunk->RemoveTickBlockEntity( this );
+ GetChunk()->RemoveTickBlockEntity( this );
}
void cFurnaceEntity::UsedBy( cPlayer & a_Player )
@@ -200,9 +198,7 @@ bool cFurnaceEntity::StartCooking()
m_TimeCooked = 0.f;
m_CookTime = R->CookTime;
}
- cWorld* World = cRoot::Get()->GetWorld();
- cChunk* Chunk = World->GetChunkOfBlock( m_PosX, m_PosY, m_PosZ );
- Chunk->AddTickBlockEntity( this );
+ GetChunk()->AddTickBlockEntity( this );
return true;
}
}
@@ -317,9 +313,7 @@ bool cFurnaceEntity::LoadFromJson( const Json::Value& a_Value )
if( !Item.IsEmpty() )
{
m_CookingItem = new cItem( Item );
-
- cChunk* Chunk = cRoot::Get()->GetWorld()->GetChunkOfBlock( m_PosX, m_PosY, m_PosZ );
- Chunk->AddTickBlockEntity( this );
+ GetChunk()->AddTickBlockEntity( this );
}
}
diff --git a/source/cFurnaceEntity.h b/source/cFurnaceEntity.h
index a1ab051ba..86052d363 100644
--- a/source/cFurnaceEntity.h
+++ b/source/cFurnaceEntity.h
@@ -9,6 +9,7 @@ namespace Json
class Value;
}
+class cChunk;
class cClientHandle;
class cServer;
class cItem;
@@ -16,7 +17,7 @@ class cNBTData;
class cFurnaceEntity : public cBlockEntity, public cWindowOwner
{
public:
- cFurnaceEntity(int a_X, int a_Y, int a_Z);
+ cFurnaceEntity(int a_X, int a_Y, int a_Z, cChunk* a_Chunk);
virtual ~cFurnaceEntity();
virtual void Destroy();
diff --git a/source/cGhast.cpp b/source/cGhast.cpp
index 54c89a279..3189e5d63 100644
--- a/source/cGhast.cpp
+++ b/source/cGhast.cpp
@@ -48,12 +48,12 @@ void cGhast::KilledBy( cEntity* a_Killer )
if( (rand() % 5) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
if( (rand() % 1) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
cMonster::KilledBy( a_Killer );
}
diff --git a/source/cMonster.cpp b/source/cMonster.cpp
index 63ef1d862..99a74a86f 100644
--- a/source/cMonster.cpp
+++ b/source/cMonster.cpp
@@ -103,7 +103,7 @@ void cMonster::SpawnOn( cClientHandle* a_Target )
//Spawn.m_MetaData[1] = 0x7f; // terminator
if( a_Target == 0 )
{
- cChunk* Chunk = cRoot::Get()->GetWorld()->GetChunk( m_ChunkX, m_ChunkY, m_ChunkZ );
+ cChunk* Chunk = GetWorld()->GetChunk( m_ChunkX, m_ChunkY, m_ChunkZ );
Chunk->Broadcast( Spawn );
}
else
@@ -166,7 +166,7 @@ void cMonster::Tick(float a_Dt)
{
Vector3f NormSpeed = m_Speed->NormalizeCopy();
Vector3f NextBlock = Vector3f( *m_Pos ) + NormSpeed;
- double NextHeight = (double)cRoot::Get()->GetWorld()->GetHeight( (int)NextBlock.x, (int)NextBlock.z );
+ double NextHeight = (double)GetWorld()->GetHeight( (int)NextBlock.x, (int)NextBlock.z );
if( NextHeight > m_Pos->y - 1.2 && NextHeight - m_Pos->y < 2.5 )
{
m_bOnGround = false;
@@ -230,7 +230,7 @@ void cMonster::Tick(float a_Dt)
void cMonster::ReplicateMovement()
{
- cChunk* InChunk = cRoot::Get()->GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
+ cChunk* InChunk = GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
if( !InChunk ) return;
if(m_bDirtyOrientation && !m_bDirtyPosition)
@@ -288,7 +288,7 @@ void cMonster::HandlePhysics(float a_Dt)
{
if( m_bOnGround ) // check if it's still on the ground
{
- cWorld* World = cRoot::Get()->GetWorld();
+ cWorld* World = GetWorld();
if( World->GetBlock( (int)m_Pos->x, (int)m_Pos->y -1, (int)m_Pos->z ) == E_BLOCK_AIR )
{
m_bOnGround = false;
@@ -313,7 +313,7 @@ void cMonster::HandlePhysics(float a_Dt)
if( m_Speed->SqrLength() > 0.f )
{
- cTracer Tracer( cRoot::Get()->GetWorld() );
+ cTracer Tracer( GetWorld() );
int Ret = Tracer.Trace( *m_Pos, *m_Speed, 2 );
if( Ret ) // Oh noez! we hit something
{
@@ -414,7 +414,7 @@ void cMonster::CheckEventSeePlayer() {
void cMonster::CheckEventLostPlayer() {
Vector3f pos;
- cTracer LineOfSight(cRoot::Get()->GetWorld() );
+ cTracer LineOfSight(GetWorld() );
//LOG("Checking if I lost my enemy");
if(m_Target != 0) {
@@ -464,7 +464,7 @@ void cMonster::InStateIdle(float a_Dt) {
{
m_Destination->x = (float)(m_Pos->x + Dist.x);
m_Destination->z = (float)(m_Pos->z + Dist.z);
- m_Destination->y = (float)cRoot::Get()->GetWorld()->GetHeight( (int)m_Destination->x, (int)m_Destination->z ) + 1.2f;
+ m_Destination->y = (float)GetWorld()->GetHeight( (int)m_Destination->x, (int)m_Destination->z ) + 1.2f;
MoveToPosition( *m_Destination );
}
}
@@ -473,8 +473,8 @@ void cMonster::InStateIdle(float a_Dt) {
//What to do if On fire
void cMonster::InStateBurning(float a_Dt) {
m_FireDamageInterval += a_Dt;
- char block = cRoot::Get()->GetWorld()->GetBlock( (int)m_Pos->x, (int)m_Pos->y, (int)m_Pos->z );
- char bblock = cRoot::Get()->GetWorld()->GetBlock( (int)m_Pos->x, (int)m_Pos->y -1, (int)m_Pos->z );
+ char block = GetWorld()->GetBlock( (int)m_Pos->x, (int)m_Pos->y, (int)m_Pos->z );
+ char bblock = GetWorld()->GetBlock( (int)m_Pos->x, (int)m_Pos->y -1, (int)m_Pos->z );
if(m_FireDamageInterval > 1) {
m_FireDamageInterval = 0;
@@ -490,7 +490,7 @@ void cMonster::InStateBurning(float a_Dt) {
if(m_BurnPeriod > 5) {
- cChunk* InChunk = cRoot::Get()->GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
+ cChunk* InChunk = GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
m_EMMetaState = NORMAL;
cPacket_Metadata md(NORMAL, GetUniqueID());
//md.m_UniqueID = GetUniqueID();
@@ -534,11 +534,11 @@ void cMonster::Attack(float a_Dt) {
}
//----Change Entity MetaData
void cMonster::CheckMetaDataBurn() {
- char block = cRoot::Get()->GetWorld()->GetBlock( (int)m_Pos->x, (int)m_Pos->y, (int)m_Pos->z );
- char bblock = cRoot::Get()->GetWorld()->GetBlock( (int)m_Pos->x, (int)m_Pos->y -1, (int)m_Pos->z );
+ char block = GetWorld()->GetBlock( (int)m_Pos->x, (int)m_Pos->y, (int)m_Pos->z );
+ char bblock = GetWorld()->GetBlock( (int)m_Pos->x, (int)m_Pos->y -1, (int)m_Pos->z );
if(m_bBurnable && m_EMMetaState != BURNING && (block == E_BLOCK_LAVA || block == E_BLOCK_STATIONARY_LAVA || block == E_BLOCK_FIRE
|| bblock == E_BLOCK_LAVA || bblock == E_BLOCK_STATIONARY_LAVA || bblock == E_BLOCK_FIRE)) {
- cChunk* InChunk = cRoot::Get()->GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
+ cChunk* InChunk = GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
if(!InChunk)
return;
//printf("I should burn");
diff --git a/source/cPawn.cpp b/source/cPawn.cpp
index d9f2ec8b5..2c1471156 100644
--- a/source/cPawn.cpp
+++ b/source/cPawn.cpp
@@ -50,7 +50,7 @@ void cPawn::TakeDamage( int a_Damage, cEntity* a_Instigator )
cPacket_EntityStatus Status;
Status.m_UniqueID = GetUniqueID();
Status.m_Status = cPacket_EntityStatus::STATUS_TAKEDAMAGE;
- cChunk* Chunk = cRoot::Get()->GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
+ cChunk* Chunk = GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
if( Chunk )
Chunk->Broadcast( Status );
@@ -70,7 +70,7 @@ void cPawn::KilledBy( cEntity* a_Killer )
cPacket_EntityStatus Status;
Status.m_UniqueID = GetUniqueID();
Status.m_Status = cPacket_EntityStatus::STATUS_DIE;
- cChunk* Chunk = cRoot::Get()->GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
+ cChunk* Chunk = GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
if( Chunk )
Chunk->Broadcast( Status ); // Die
}
diff --git a/source/cPickup.cpp b/source/cPickup.cpp
index 585c1e32b..ba36077e0 100644
--- a/source/cPickup.cpp
+++ b/source/cPickup.cpp
@@ -130,7 +130,7 @@ void cPickup::Tick(float a_Dt)
MoveToCorrectChunk();
m_bReplicated = true;
m_bDirtyPosition = false;
- cChunk* Chunk = cRoot::Get()->GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
+ cChunk* Chunk = GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
if( Chunk )
{
cPacket_TeleportEntity TeleportEntity( this );
@@ -145,7 +145,7 @@ void cPickup::HandlePhysics(float a_Dt)
{
if( m_bOnGround ) // check if it's still on the ground
{
- cWorld* World = cRoot::Get()->GetWorld();
+ cWorld* World = GetWorld();
int BlockX = (int)m_Pos->x;
if( m_Pos->x < 0 ) BlockX--;
int BlockZ = (int)m_Pos->z;
@@ -172,7 +172,7 @@ void cPickup::HandlePhysics(float a_Dt)
float Gravity = -9.81f*a_Dt;
m_Speed->y += Gravity;
- cTracer Tracer( cRoot::Get()->GetWorld() );
+ cTracer Tracer( GetWorld() );
int Ret = Tracer.Trace( *m_Pos, *m_Speed, 2 );
if( Ret ) // Oh noez! we hit something
{
diff --git a/source/cPig.cpp b/source/cPig.cpp
index fa86949ab..424b2c53b 100644
--- a/source/cPig.cpp
+++ b/source/cPig.cpp
@@ -52,12 +52,12 @@ void cPig::KilledBy( cEntity* a_Killer )
if( (rand() % 5) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
if( (rand() % 1) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
cMonster::KilledBy( a_Killer );
}
diff --git a/source/cPlayer.cpp b/source/cPlayer.cpp
index 2f7e27988..898bac54f 100644
--- a/source/cPlayer.cpp
+++ b/source/cPlayer.cpp
@@ -83,13 +83,13 @@ cPlayer::cPlayer(cClientHandle* a_Client, const char* a_PlayerName)
if( !LoadFromDisk() )
{
m_Inventory->Clear();
- SetPosX( cRoot::Get()->GetWorld()->GetSpawnX() );
+ SetPosX( cRoot::Get()->GetWorld()->GetSpawnX() ); // TODO - Get from the correct world?
SetPosY( cRoot::Get()->GetWorld()->GetSpawnY() );
SetPosZ( cRoot::Get()->GetWorld()->GetSpawnZ() );
}
- MoveToCorrectChunk();
- cRoot::Get()->GetWorld()->AddPlayer( this );
+ //MoveToCorrectChunk();
+ cRoot::Get()->GetWorld()->AddPlayer( this ); // TODO - Add to correct world? Or get rid of this?
}
cPlayer::~cPlayer(void)
@@ -103,7 +103,7 @@ cPlayer::~cPlayer(void)
m_Inventory = 0;
}
delete m_pState;
- cRoot::Get()->GetWorld()->RemovePlayer( this );
+ cRoot::Get()->GetWorld()->RemovePlayer( this ); // TODO - Remove from correct world? Or get rid of this?
}
void cPlayer::SpawnOn( cClientHandle* a_Target )
@@ -121,7 +121,7 @@ void cPlayer::SpawnOn( cClientHandle* a_Target )
SpawnPacket.m_CurrentItem = (short)m_Inventory->GetEquippedItem().m_ItemID;
if( a_Target == 0 )
{
- cChunk* Chunk = cRoot::Get()->GetWorld()->GetChunk( m_ChunkX, m_ChunkY, m_ChunkZ );
+ cChunk* Chunk = GetWorld()->GetChunk( m_ChunkX, m_ChunkY, m_ChunkZ );
Chunk->Broadcast( SpawnPacket, m_ClientHandle );
}
else
@@ -132,7 +132,7 @@ void cPlayer::SpawnOn( cClientHandle* a_Target )
void cPlayer::Tick(float a_Dt)
{
- cChunk* InChunk = cRoot::Get()->GetWorld()->GetChunk( m_ChunkX, m_ChunkY, m_ChunkZ );
+ cChunk* InChunk = GetWorld()->GetChunk( m_ChunkX, m_ChunkY, m_ChunkZ );
if(m_bDirtyOrientation && !m_bDirtyPosition)
{
cPacket_EntityLook EntityLook( this );
@@ -192,7 +192,7 @@ void cPlayer::Tick(float a_Dt)
m_TimeLastPickupCheck = cWorld::GetTime();
// and also check if near a pickup
// TODO: Don't only check in current chunks, but also close chunks (chunks within range)
- cChunk* Chunk = cRoot::Get()->GetWorld()->GetChunk( m_ChunkX, m_ChunkY, m_ChunkZ );
+ cChunk* Chunk = GetWorld()->GetChunk( m_ChunkX, m_ChunkY, m_ChunkZ );
Chunk->LockEntities();
cWorld::EntityList Entities = Chunk->GetEntities();
for( cWorld::EntityList::iterator itr = Entities.begin(); itr != Entities.end();++itr)
@@ -219,8 +219,8 @@ void cPlayer::Tick(float a_Dt)
void cPlayer::InStateBurning(float a_Dt) {
m_FireDamageInterval += a_Dt;
- char block = cRoot::Get()->GetWorld()->GetBlock( (int)m_Pos->x, (int)m_Pos->y, (int)m_Pos->z );
- char bblock = cRoot::Get()->GetWorld()->GetBlock( (int)m_Pos->x, (int)m_Pos->y -1, (int)m_Pos->z );
+ char block = GetWorld()->GetBlock( (int)m_Pos->x, (int)m_Pos->y, (int)m_Pos->z );
+ char bblock = GetWorld()->GetBlock( (int)m_Pos->x, (int)m_Pos->y -1, (int)m_Pos->z );
if(m_FireDamageInterval > 1000) {
m_FireDamageInterval = 0;
@@ -236,7 +236,7 @@ void cPlayer::InStateBurning(float a_Dt) {
if(m_BurnPeriod > 5) {
- cChunk* InChunk = cRoot::Get()->GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
+ cChunk* InChunk = GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
e_EPMetaState = NORMAL;
cPacket_Metadata md(NORMAL, GetUniqueID());
//md.m_UniqueID = GetUniqueID();
@@ -251,11 +251,11 @@ void cPlayer::InStateBurning(float a_Dt) {
//----Change Entity MetaData
void cPlayer::CheckMetaDataBurn() {
- char block = cRoot::Get()->GetWorld()->GetBlock( (int)m_Pos->x, (int)m_Pos->y, (int)m_Pos->z );
- char bblock = cRoot::Get()->GetWorld()->GetBlock( (int)m_Pos->x, (int)m_Pos->y -1, (int)m_Pos->z );
+ char block = GetWorld()->GetBlock( (int)m_Pos->x, (int)m_Pos->y, (int)m_Pos->z );
+ char bblock = GetWorld()->GetBlock( (int)m_Pos->x, (int)m_Pos->y -1, (int)m_Pos->z );
if(m_bBurnable && e_EPMetaState != BURNING && (block == E_BLOCK_LAVA || block == E_BLOCK_STATIONARY_LAVA || block == E_BLOCK_FIRE
|| bblock == E_BLOCK_LAVA || bblock == E_BLOCK_STATIONARY_LAVA || bblock == E_BLOCK_FIRE)) {
- cChunk* InChunk = cRoot::Get()->GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
+ cChunk* InChunk = GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
if(!InChunk)
return;
printf("I should burn");
@@ -271,7 +271,7 @@ void cPlayer::SetTouchGround( bool a_bTouchGround )
if( !m_bTouchGround )
{
- cWorld* World = cRoot::Get()->GetWorld();
+ cWorld* World = GetWorld();
char BlockID = World->GetBlock( (int)m_Pos->x, (int)m_Pos->y, (int)m_Pos->z );
if( BlockID != E_BLOCK_AIR )
{
@@ -317,7 +317,7 @@ void cPlayer::Heal( int a_Health )
void cPlayer::TakeDamage( int a_Damage, cEntity* a_Instigator )
{
- if ( !(cRoot::Get()->GetWorld()->GetGameMode() == 1) ) {
+ if ( !(GetWorld()->GetGameMode() == 1) ) {
cPawn::TakeDamage( a_Damage, a_Instigator );
cPacket_UpdateHealth Health;
@@ -344,7 +344,7 @@ void cPlayer::KilledBy( cEntity* a_Killer )
float SpeedY = ((rand()%1000)) /100.f;
float SpeedZ = ((rand()%1000)-500) /100.f;
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), Items[i], SpeedX, SpeedY, SpeedZ );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
Items[i].Empty();
}
@@ -355,14 +355,13 @@ void cPlayer::Respawn()
{
m_Health = 20;
- cWorld* World = cRoot::Get()->GetWorld();
// Create Respawn player packet
cPacket_Respawn Packet;
//Set Gamemode for packet by looking at world's gamemode (Need to check players gamemode.)
- Packet.m_CreativeMode = cRoot::Get()->GetWorld()->GetGameMode();
+ Packet.m_CreativeMode = (char)GetWorld()->GetGameMode();
//Send Packet
m_ClientHandle->Send( Packet );
- TeleportTo( World->GetSpawnX(), World->GetSpawnY(), World->GetSpawnZ() );
+ TeleportTo( GetWorld()->GetSpawnX(), GetWorld()->GetSpawnY(), GetWorld()->GetSpawnZ() );
SetVisible( true );
}
@@ -428,7 +427,7 @@ void cPlayer::SetVisible( bool a_bVisible )
{
m_bVisible = false;
cPacket_DestroyEntity DestroyEntity( this );
- cChunk* Chunk = cRoot::Get()->GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
+ cChunk* Chunk = GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
if( Chunk )
{
Chunk->Broadcast( DestroyEntity ); // Destroy on all clients
@@ -576,7 +575,7 @@ void cPlayer::TossItem( bool a_bDraggingItem, int a_Amount /* = 1 */ )
EulerToVector( -GetRotation(), GetPitch(), vZ, vX, vY );
vY = -vY*2 + 1.f;
cPickup* Pickup = new cPickup( (int)(GetPosX()*32), (int)(GetPosY()*32) + (int)(1.6f*32), (int)(GetPosZ()*32), cItem( Item->m_ItemID, (char)a_Amount, Item->m_ItemHealth), vX*2, vY*2, vZ*2 );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
if( Item->m_ItemCount > a_Amount )
Item->m_ItemCount -= (char)a_Amount;
else
@@ -597,7 +596,7 @@ void cPlayer::TossItem( bool a_bDraggingItem, int a_Amount /* = 1 */ )
EulerToVector( -GetRotation(), GetPitch(), vZ, vX, vY );
vY = -vY*2 + 1.f;
cPickup* Pickup = new cPickup( (int)(GetPosX()*32), (int)(GetPosY()*32) + (int)(1.6f*32), (int)(GetPosZ()*32), DroppedItem, vX*2, vY*2, vZ*2 );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
}
}
diff --git a/source/cServer.cpp b/source/cServer.cpp
index 511678939..8ea00a523 100644
--- a/source/cServer.cpp
+++ b/source/cServer.cpp
@@ -227,6 +227,7 @@ cServer::~cServer()
delete m_pState;
}
+// TODO - Need to modify this or something, so it broadcasts to all worlds? And move this to cWorld?
void cServer::Broadcast( const cPacket & a_Packet, cClientHandle* a_Exclude /* = 0 */ )
{
//m_World->LockClientHandle();
@@ -239,6 +240,7 @@ void cServer::Broadcast( const cPacket & a_Packet, cClientHandle* a_Exclude /* =
//m_World->UnlockClientHandle();
}
+// TODO - Need to move this to cWorld I think
void cServer::SendAllEntitiesTo(cClientHandle* a_Target)
{
cWorld* World = cRoot::Get()->GetWorld();
@@ -261,7 +263,7 @@ void cServer::StartListenClient()
LOG("%s connected!", ClientIP);
cClientHandle *NewHandle = new cClientHandle( SClient );
- cWorld* World = cRoot::Get()->GetWorld();
+ cWorld* World = cRoot::Get()->GetWorld(); // TODO - I don't think the world cares for the client at this stage, besides for calling the tick function
World->LockClientHandle();
World->AddClient( NewHandle );
World->UnlockClientHandle();
@@ -282,7 +284,7 @@ bool cServer::Tick(float a_Dt)
m_Millisecondsf = m_Millisecondsf - (int)m_Millisecondsf;
}
- cWorld* World = cRoot::Get()->GetWorld();
+ cWorld* World = cRoot::Get()->GetWorld(); // TODO - Iterate through all worlds, or give all worlds their own thread
World->Tick(a_Dt);
World->LockClientHandle();
@@ -440,7 +442,7 @@ void cServer::ServerCommand( const char* a_Cmd )
}
if( split[0].compare( "save-all" ) == 0 )
{
- cRoot::Get()->GetWorld()->SaveAllChunks();
+ cRoot::Get()->GetWorld()->SaveAllChunks(); // TODO - Force ALL worlds to save their chunks
return;
}
if( split[0].compare( "list" ) == 0 )
diff --git a/source/cSheep.cpp b/source/cSheep.cpp
index 98d17e4d4..2b3f93888 100644
--- a/source/cSheep.cpp
+++ b/source/cSheep.cpp
@@ -52,12 +52,12 @@ void cSheep::KilledBy( cEntity* a_Killer )
if( (rand() % 5) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
if( (rand() % 1) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
cMonster::KilledBy( a_Killer );
}
diff --git a/source/cSignEntity.cpp b/source/cSignEntity.cpp
index 883da223e..2c82563f1 100644
--- a/source/cSignEntity.cpp
+++ b/source/cSignEntity.cpp
@@ -11,8 +11,8 @@
#include <json/json.h>
-cSignEntity::cSignEntity(ENUM_BLOCK_ID a_BlockType, int a_X, int a_Y, int a_Z)
- : cBlockEntity(a_BlockType, a_X, a_Y, a_Z)
+cSignEntity::cSignEntity(ENUM_BLOCK_ID a_BlockType, int a_X, int a_Y, int a_Z, cChunk* a_Chunk)
+ : cBlockEntity(a_BlockType, a_X, a_Y, a_Z, a_Chunk)
{
}
@@ -65,9 +65,7 @@ void cSignEntity::SendTo( cClientHandle* a_Client )
if( a_Client ) a_Client->Send( Sign );
else // broadcast of a_Client == 0
{
- cWorld* World = cRoot::Get()->GetWorld();
- cChunk* Chunk = World->GetChunkOfBlock( m_PosX, m_PosY, m_PosZ );
- Chunk->Broadcast( Sign );
+ GetChunk()->Broadcast( Sign );
}
}
diff --git a/source/cSignEntity.h b/source/cSignEntity.h
index b704fdd3c..b0e95e38c 100644
--- a/source/cSignEntity.h
+++ b/source/cSignEntity.h
@@ -10,10 +10,11 @@ namespace Json
class Value;
}
+class cWorld;
class cSignEntity : public cBlockEntity
{
public:
- cSignEntity(ENUM_BLOCK_ID a_BlockType, int a_X, int a_Y, int a_Z);
+ cSignEntity(ENUM_BLOCK_ID a_BlockType, int a_X, int a_Y, int a_Z, cChunk* a_Chunk);
virtual ~cSignEntity();
void WriteToFile(FILE* a_File);
diff --git a/source/cSilverfish.cpp b/source/cSilverfish.cpp
index 25a3befa6..c1ebb9558 100644
--- a/source/cSilverfish.cpp
+++ b/source/cSilverfish.cpp
@@ -48,12 +48,12 @@ void cSilverfish::KilledBy( cEntity* a_Killer )
if( (rand() % 5) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
if( (rand() % 1) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
cMonster::KilledBy( a_Killer );
}
diff --git a/source/cSkeleton.cpp b/source/cSkeleton.cpp
index 84de27d7a..6cdb7b23b 100644
--- a/source/cSkeleton.cpp
+++ b/source/cSkeleton.cpp
@@ -41,7 +41,7 @@ bool cSkeleton::IsA( const char* a_EntityType )
void cSkeleton::Tick(float a_Dt)
{
cMonster::Tick(a_Dt);
- if (cRoot::Get()->GetWorld()->GetWorldTime() < (12000 + 1000) ) { //if daylight
+ if (GetWorld()->GetWorldTime() < (12000 + 1000) ) { //if daylight
m_EMMetaState = BURNING; // BURN, BABY, BURN! >:D
}
}
@@ -51,12 +51,12 @@ void cSkeleton::KilledBy( cEntity* a_Killer )
if( (rand() % 5) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
if( (rand() % 1) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
cMonster::KilledBy( a_Killer );
}
diff --git a/source/cSlime.cpp b/source/cSlime.cpp
index c568ac78c..90729e169 100644
--- a/source/cSlime.cpp
+++ b/source/cSlime.cpp
@@ -48,12 +48,12 @@ void cSlime::KilledBy( cEntity* a_Killer )
if( (rand() % 5) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
if( (rand() % 1) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
cMonster::KilledBy( a_Killer );
}
diff --git a/source/cSpider.cpp b/source/cSpider.cpp
index 00d63c409..7b7268e78 100644
--- a/source/cSpider.cpp
+++ b/source/cSpider.cpp
@@ -41,7 +41,7 @@ bool cSpider::IsA( const char* a_EntityType )
void cSpider::Tick(float a_Dt)
{
cMonster::Tick(a_Dt);
- m_EMPersonality = (cRoot::Get()->GetWorld()->GetWorldTime() < (12000 + 1000) )? PASSIVE:AGGRESSIVE;
+ m_EMPersonality = (GetWorld()->GetWorldTime() < (12000 + 1000) )? PASSIVE:AGGRESSIVE;
}
void cSpider::KilledBy( cEntity* a_Killer )
@@ -49,12 +49,12 @@ void cSpider::KilledBy( cEntity* a_Killer )
if( (rand() % 5) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
if( (rand() % 1) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
cMonster::KilledBy( a_Killer );
}
diff --git a/source/cSquid.cpp b/source/cSquid.cpp
index e528e7e95..2b519a5c7 100644
--- a/source/cSquid.cpp
+++ b/source/cSquid.cpp
@@ -52,12 +52,12 @@ void cSquid::KilledBy( cEntity* a_Killer )
if( (rand() % 5) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
if( (rand() % 1) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
cMonster::KilledBy( a_Killer );
}
diff --git a/source/cWebAdmin.cpp b/source/cWebAdmin.cpp
index d6881c55f..03775ee3f 100644
--- a/source/cWebAdmin.cpp
+++ b/source/cWebAdmin.cpp
@@ -114,7 +114,7 @@ void cWebAdmin::Request_Handler(webserver::http_request* r)
Content += "</p>";
Content += "<h4>Players:</h4><p>";
- cWorld* World = cRoot::Get()->GetWorld();
+ cWorld* World = cRoot::Get()->GetWorld(); // TODO - Create a list of worlds and players
cWorld::PlayerList PlayerList = World->GetAllPlayers();
for( cWorld::PlayerList::iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr )
{
diff --git a/source/cWolf.cpp b/source/cWolf.cpp
index 5a2c14f83..f504d79df 100644
--- a/source/cWolf.cpp
+++ b/source/cWolf.cpp
@@ -48,12 +48,12 @@ void cWolf::KilledBy( cEntity* a_Killer )
if( (rand() % 5) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
if( (rand() % 1) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
cMonster::KilledBy( a_Killer );
}
diff --git a/source/cWorld.cpp b/source/cWorld.cpp
index c5dfc683e..29115d15e 100644
--- a/source/cWorld.cpp
+++ b/source/cWorld.cpp
@@ -179,7 +179,7 @@ cWorld::cWorld()
m_SpawnMonsterRate = (float)IniFile2.GetValueF("Monsters", "AnimalSpawnInterval", 10 );
}
- m_ChunkMap = new cChunkMap( 32, 32 );
+ m_ChunkMap = new cChunkMap( 32, 32, this );
m_Time = 0;
m_WorldTimeFraction = 0.f;
@@ -388,7 +388,7 @@ void cWorld::Tick(float a_Dt)
if( Monster )
{
- Monster->Initialize();
+ Monster->Initialize( this );
Monster->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
Monster->SpawnOn( 0 );
}
@@ -475,7 +475,7 @@ cChunk* cWorld::GetChunk( int a_X, int a_Y, int a_Z )
}
// Found nothing, create a chunk
- Chunk = new cChunk( a_X, a_Y, a_Z );
+ Chunk = new cChunk( a_X, a_Y, a_Z, this );
if(Chunk)
{
LOGWARN("Created new chunk! %i %i", a_X, a_Z);
@@ -570,7 +570,7 @@ bool cWorld::DigBlock( int a_X, int a_Y, int a_Z, cItem & a_PickupItem )
if( !a_PickupItem.IsEmpty() )
{
cPickup* Pickup = new cPickup( a_X*32 + 16 + (int)fRadRand(16.f), a_Y*32 + 16 + (int)fRadRand(16.f), a_Z*32 + 16 + (int)fRadRand(16.f), a_PickupItem );
- Pickup->Initialize();
+ Pickup->Initialize( this );
}
}
diff --git a/source/cZombie.cpp b/source/cZombie.cpp
index 23953f274..10fb609bb 100644
--- a/source/cZombie.cpp
+++ b/source/cZombie.cpp
@@ -41,7 +41,7 @@ bool cZombie::IsA( const char* a_EntityType )
void cZombie::Tick(float a_Dt)
{
cMonster::Tick(a_Dt);
- if (cRoot::Get()->GetWorld()->GetWorldTime() < (12000 + 1000) ) { //if daylight
+ if (GetWorld()->GetWorldTime() < (12000 + 1000) ) { //if daylight
m_EMMetaState = BURNING; // BURN, BABY, BURN! >:D
}
}
@@ -51,12 +51,12 @@ void cZombie::KilledBy( cEntity* a_Killer )
if( (rand() % 5) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
if( (rand() % 1) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
cMonster::KilledBy( a_Killer );
}
diff --git a/source/cZombiepigman.cpp b/source/cZombiepigman.cpp
index 5ace226af..da550d3df 100644
--- a/source/cZombiepigman.cpp
+++ b/source/cZombiepigman.cpp
@@ -41,7 +41,7 @@ bool cZombiepigman::IsA( const char* a_EntityType )
void cZombiepigman::Tick(float a_Dt)
{
cMonster::Tick(a_Dt);
- if (cRoot::Get()->GetWorld()->GetWorldTime() < (12000 + 1000) ) { //if daylight
+ if (GetWorld()->GetWorldTime() < (12000 + 1000) ) { //if daylight
m_EMMetaState = BURNING; // BURN, BABY, BURN! >:D
}
}
@@ -51,12 +51,12 @@ void cZombiepigman::KilledBy( cEntity* a_Killer )
if( (rand() % 5) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
if( (rand() % 1) == 0 )
{
cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
- Pickup->Initialize();
+ Pickup->Initialize( GetWorld() );
}
cMonster::KilledBy( a_Killer );
}