From a49c004278b0e300521e9cedf44a46ac843a958b Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sat, 13 Apr 2013 21:02:10 +0000 Subject: Rewritten entities so that they are owned by individual chunks and ticked within their chunk's Tick() git-svn-id: http://mc-server.googlecode.com/svn/trunk@1385 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Player.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'source/Player.cpp') diff --git a/source/Player.cpp b/source/Player.cpp index af2e00570..cfbf5cdff 100644 --- a/source/Player.cpp +++ b/source/Player.cpp @@ -99,7 +99,7 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) cPlayer::~cPlayer(void) { - LOG("Deleting cPlayer \"%s\" at %p, ID %d; inv win %p", m_PlayerName.c_str(), this, GetUniqueID(), m_InventoryWindow); + LOG("Deleting cPlayer \"%s\" at %p, ID %d", m_PlayerName.c_str(), this, GetUniqueID()); SaveToDisk(); @@ -109,7 +109,7 @@ cPlayer::~cPlayer(void) delete m_InventoryWindow; - LOG("Player %p deleted", this); + LOGD("Player %p deleted", this); } @@ -119,7 +119,7 @@ cPlayer::~cPlayer(void) void cPlayer::Initialize( cWorld* a_World ) { cPawn::Initialize( a_World ); - GetWorld()->AddPlayer( this ); + GetWorld()->AddPlayer(this); } @@ -156,7 +156,7 @@ void cPlayer::SpawnOn(cClientHandle & a_Client) -void cPlayer::Tick(float a_Dt, MTRand & a_TickRandom) +void cPlayer::Tick(float a_Dt, cChunk & a_Chunk) { if (!m_ClientHandle->IsPlaying()) { @@ -164,7 +164,7 @@ void cPlayer::Tick(float a_Dt, MTRand & a_TickRandom) return; } - super::Tick(a_Dt, a_TickRandom); + super::Tick(a_Dt, a_Chunk); //TODO: Change this to use the BroadcastMovementUpdate function if (m_bDirtyOrientation && !m_bDirtyPosition) { @@ -853,12 +853,11 @@ bool cPlayer::MoveToWorld( const char* a_WorldName ) /* Remove all links to the old world */ m_World->RemovePlayer( this ); m_ClientHandle->RemoveFromAllChunks(); - m_World->RemoveEntityFromChunk(this, m_ChunkX, m_ChunkY, m_ChunkZ); + m_World->RemoveEntityFromChunk(this, GetChunkX(), GetChunkZ()); /* Add player to all the necessary parts of the new world */ SetWorld( World ); - GetWorld()->AddPlayer( this ); - MoveToCorrectChunk(true); + GetWorld()->AddPlayer(this); GetClientHandle()->StreamChunks(); return true; -- cgit v1.2.3