1
0

Merge branch 'master' into portals

Conflicts:
	src/ClientHandle.cpp
	src/Entities/Player.cpp
	src/Entities/Player.h
	src/Protocol/Protocol125.cpp
	src/Protocol/Protocol17x.cpp
This commit is contained in:
Tiger Wang
2014-06-10 20:51:22 +01:00
72 changed files with 2885 additions and 310 deletions

View File

@@ -130,9 +130,9 @@ const char * cEntity::GetParentClass(void) const
bool cEntity::Initialize(cWorld * a_World)
bool cEntity::Initialize(cWorld & a_World)
{
if (cPluginManager::Get()->CallHookSpawningEntity(*a_World, *this))
if (cPluginManager::Get()->CallHookSpawningEntity(a_World, *this))
{
return false;
}
@@ -145,13 +145,13 @@ bool cEntity::Initialize(cWorld * a_World)
*/
m_IsInitialized = true;
m_World = a_World;
m_World = &a_World;
m_World->AddEntity(this);
cPluginManager::Get()->CallHookSpawnedEntity(*a_World, *this);
cPluginManager::Get()->CallHookSpawnedEntity(a_World, *this);
// Spawn the entity on the clients:
a_World->BroadcastSpawnEntity(*this);
a_World.BroadcastSpawnEntity(*this);
return true;
}

View File

@@ -146,8 +146,9 @@ public:
cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, double a_Width, double a_Height);
virtual ~cEntity();
/// Spawns the entity in the world; returns true if spawned, false if not (plugin disallowed)
virtual bool Initialize(cWorld * a_World);
/** Spawns the entity in the world; returns true if spawned, false if not (plugin disallowed).
Adds the entity to the world. */
virtual bool Initialize(cWorld & a_World);
// tolua_begin
@@ -430,6 +431,9 @@ public:
UNUSED(a_Killer);
}
/** Sets the internal world pointer to a new cWorld, doesn't update anything else. */
void SetWorld(cWorld * a_World) { m_World = a_World; }
protected:
static cCriticalSection m_CSCount;
static int m_EntityCount;
@@ -494,8 +498,6 @@ protected:
virtual void Destroyed(void) {} // Called after the entity has been destroyed
void SetWorld(cWorld * a_World) { m_World = a_World; }
/** Called in each tick to handle air-related processing i.e. drowning */
virtual void HandleAir();

View File

@@ -55,6 +55,7 @@ void cItemFrame::KilledBy(cEntity * a_Killer)
{
if (m_Item.IsEmpty())
{
SetHealth(0);
super::KilledBy(a_Killer);
Destroy();
return;
@@ -69,8 +70,9 @@ void cItemFrame::KilledBy(cEntity * a_Killer)
}
SetHealth(GetMaxHealth());
m_Item.Clear();
m_Item.Empty();
m_Rotation = 0;
SetInvulnerableTicks(0);
GetWorld()->BroadcastEntityMetadata(*this);
}

View File

@@ -934,6 +934,8 @@ void cPlayer::Killed(cEntity * a_Victim)
void cPlayer::Respawn(void)
{
ASSERT(m_World != NULL);
m_Health = GetMaxHealth();
SetInvulnerableTicks(20);
@@ -1590,24 +1592,22 @@ bool cPlayer::MoveToWorld(const AString & a_WorldName, cWorld * a_World)
return false;
}
eDimension OldDimension = m_World->GetDimension();
// Send the respawn packet:
if (m_ClientHandle != NULL)
{
m_ClientHandle->SendRespawn(*World);
}
// Remove all links to the old world
m_World->RemovePlayer(this);
m_ClientHandle->RemoveFromAllChunks();
// If the dimension is different, we can send the respawn packet
// http://wiki.vg/Protocol#0x09 says "don't send if dimension is the same" as of 2013_07_02
bool SendRespawn = OldDimension != World->GetDimension();
m_ClientHandle->MoveToWorld(*World, SendRespawn);
// Add player to all the necessary parts of the new world
SetWorld(World);
m_ClientHandle->StreamChunks();
World->AddEntity(this);
// Queue adding player to the new world, including all the necessary adjustments to the object
World->AddPlayer(this);
if (SendRespawn)
if (GetWorld()->GetDimension() != World->GetDimension())
{
GetClientHandle()->SendPlayerMoveLook();
GetClientHandle()->SendHealth();

View File

@@ -328,6 +328,8 @@ public:
void SetVisible( bool a_bVisible ); // tolua_export
bool IsVisible(void) const { return m_bVisible; } // tolua_export
/** Moves the player to the specified world.
Returns true if successful, false on failure (world not found). */
virtual bool MoveToWorld(const AString & a_WorldName, cWorld * a_World = NULL) override; // tolua_export
/** Saves all player data, such as inventory, to JSON */