From 47d5395d24c6f209a758a689bff9a44f68d7397b Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 30 Mar 2014 13:44:28 +0200 Subject: Added a blockface parameter to the OnProjectileHitBlock hook. --- src/Entities/ProjectileEntity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Entities') diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index a9735a53c..37964d102 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -67,7 +67,7 @@ protected: eBlockFace Face; if (bb.CalcLineIntersection(Line1, Line2, LineCoeff, Face)) { - if (cPluginManager::Get()->CallHookProjectileHitBlock(*m_Projectile)) + if (cPluginManager::Get()->CallHookProjectileHitBlock(*m_Projectile, Face)) { return false; } -- cgit v1.2.3 From 66f1bb7b677324dd59265b7b0776490caa661bcc Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 30 Mar 2014 14:04:44 +0200 Subject: Added a BlockHitPos parameter to OnProjectileHitBlock --- src/Entities/ProjectileEntity.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Entities') diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index 37964d102..72ebf5775 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -67,12 +67,12 @@ protected: eBlockFace Face; if (bb.CalcLineIntersection(Line1, Line2, LineCoeff, Face)) { - if (cPluginManager::Get()->CallHookProjectileHitBlock(*m_Projectile, Face)) + Vector3d Intersection = Line1 + m_Projectile->GetSpeed() * LineCoeff; + if (cPluginManager::Get()->CallHookProjectileHitBlock(*m_Projectile, Face, &Intersection)) { return false; } - Vector3d Intersection = Line1 + m_Projectile->GetSpeed() * LineCoeff; m_Projectile->OnHitSolidBlock(Intersection, Face); return true; } -- cgit v1.2.3 From 36e1e57d038eda0c183f616f2b45d2ae4733e27c Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 30 Mar 2014 17:21:13 +0200 Subject: Using recommendations (I think) --- src/Entities/ProjectileEntity.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Entities') diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index 72ebf5775..7a869a957 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -68,7 +68,8 @@ protected: if (bb.CalcLineIntersection(Line1, Line2, LineCoeff, Face)) { Vector3d Intersection = Line1 + m_Projectile->GetSpeed() * LineCoeff; - if (cPluginManager::Get()->CallHookProjectileHitBlock(*m_Projectile, Face, &Intersection)) + const Vector3i BlockHitPos = Vector3i(Intersection); + if (cPluginManager::Get()->CallHookProjectileHitBlock(*m_Projectile, Face, &BlockHitPos)) { return false; } -- cgit v1.2.3 From e40f9d6e5b93e840e3d67e79f5ba49da1fbb75f0 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sat, 26 Apr 2014 10:50:23 -0700 Subject: Implemented Chunk Sparsing with segments --- src/Entities/FallingBlock.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/Entities') diff --git a/src/Entities/FallingBlock.cpp b/src/Entities/FallingBlock.cpp index a66c7e4ae..e57c45eaf 100644 --- a/src/Entities/FallingBlock.cpp +++ b/src/Entities/FallingBlock.cpp @@ -55,9 +55,8 @@ void cFallingBlock::Tick(float a_Dt, cChunk & a_Chunk) return; } - int idx = a_Chunk.MakeIndexNoCheck(BlockX - a_Chunk.GetPosX() * cChunkDef::Width, BlockY, BlockZ - a_Chunk.GetPosZ() * cChunkDef::Width); - BLOCKTYPE BlockBelow = a_Chunk.GetBlock(idx); - NIBBLETYPE BelowMeta = a_Chunk.GetMeta(idx); + BLOCKTYPE BlockBelow = a_Chunk.GetBlock(BlockX - a_Chunk.GetPosX() * cChunkDef::Width, BlockY, BlockZ - a_Chunk.GetPosZ() * cChunkDef::Width); + NIBBLETYPE BelowMeta = a_Chunk.GetMeta(BlockX - a_Chunk.GetPosX() * cChunkDef::Width, BlockY, BlockZ - a_Chunk.GetPosZ() * cChunkDef::Width); if (cSandSimulator::DoesBreakFallingThrough(BlockBelow, BelowMeta)) { // Fallen onto a block that breaks this into pickups (e. g. half-slab) -- cgit v1.2.3 From 42c36429d7cd1e6c3f879b6749e18e912deefe0d Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 19 May 2014 20:40:56 +0100 Subject: Added client translation to achievements --- src/Entities/Player.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/Entities') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index c3b763278..3a32bfb2e 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1169,8 +1169,8 @@ unsigned int cPlayer::AwardAchievement(const eStatistic a_Ach) { // First time, announce it cCompositeChat Msg; - Msg.AddTextPart(m_PlayerName + " has just earned the achievement "); - Msg.AddTextPart(cStatInfo::GetName(a_Ach)); // TODO 2014-05-12 xdot: Use the proper cCompositeChat part (cAchievement) + Msg.SetMessageType(mtSuccess); + Msg.AddShowAchievementPart(GetName(), cStatInfo::GetName(a_Ach)); m_World->BroadcastChat(Msg); // Increment the statistic @@ -1788,7 +1788,7 @@ bool cPlayer::SaveToDisk() // Save the player stats. // We use the default world name (like bukkit) because stats are shared between dimensions/worlds. - cStatSerializer StatSerializer(cRoot::Get()->GetDefaultWorld()->GetName(), m_PlayerName, &m_Stats); + cStatSerializer StatSerializer(cRoot::Get()->GetDefaultWorld()->GetName(), GetName(), &m_Stats); if (!StatSerializer.Save()) { LOGERROR("Could not save stats for player %s", m_PlayerName.c_str()); @@ -1963,7 +1963,7 @@ void cPlayer::UpdateMovementStats(const Vector3d & a_DeltaPos) BLOCKTYPE Block; NIBBLETYPE Meta; - if (!m_World->GetBlockTypeMeta(PosX, PosY, PosZ, Block, Meta)) + if ((PosY < 0) || (PosY > cChunkDef::Height) || !m_World->GetBlockTypeMeta(PosX, PosY, PosZ, Block, Meta)) { return; } -- cgit v1.2.3 From 4008af692556ffb0f819c9a570267ffbaa871cad Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 19 May 2014 21:17:28 +0100 Subject: Simplified cacti conditions --- src/Entities/Entity.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Entities') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 15f456332..ed06e76b9 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1024,9 +1024,9 @@ void cEntity::DetectCacti() float w = m_Width / 2; if ( (((X + 1) - GetPosX() < w) && (GetWorld()->GetBlock(X + 1, Y, Z) == E_BLOCK_CACTUS)) || - (((GetPosX() - (X - 1)) - 1 < w) && (GetWorld()->GetBlock(X - 1, Y, Z) == E_BLOCK_CACTUS)) || + ((GetPosX() - X < w) && (GetWorld()->GetBlock(X - 1, Y, Z) == E_BLOCK_CACTUS)) || (((Z + 1) - GetPosZ() < w) && (GetWorld()->GetBlock(X, Y, Z + 1) == E_BLOCK_CACTUS)) || - (((GetPosZ() - (Z - 1)) - 1 < w) && (GetWorld()->GetBlock(X, Y, Z - 1) == E_BLOCK_CACTUS)) || + ((GetPosZ() - Z < w) && (GetWorld()->GetBlock(X, Y, Z - 1) == E_BLOCK_CACTUS)) || (((Y > 0) && (Y < cChunkDef::Height)) && ((GetPosY() - Y < 1) && (GetWorld()->GetBlock(X, Y, Z) == E_BLOCK_CACTUS))) ) { -- cgit v1.2.3 From 2bfe962e2831316f651aa22c4e7b7ea68021c978 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 19 May 2014 22:15:39 +0100 Subject: Fixed a cactus Y position issue --- src/Entities/Entity.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/Entities') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index ed06e76b9..8a584d2ca 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1023,11 +1023,12 @@ void cEntity::DetectCacti() int X = POSX_TOINT, Y = POSY_TOINT, Z = POSZ_TOINT; float w = m_Width / 2; if ( - (((X + 1) - GetPosX() < w) && (GetWorld()->GetBlock(X + 1, Y, Z) == E_BLOCK_CACTUS)) || + ((Y > 0) && (Y < cChunkDef::Height)) && + ((((X + 1) - GetPosX() < w) && (GetWorld()->GetBlock(X + 1, Y, Z) == E_BLOCK_CACTUS)) || ((GetPosX() - X < w) && (GetWorld()->GetBlock(X - 1, Y, Z) == E_BLOCK_CACTUS)) || (((Z + 1) - GetPosZ() < w) && (GetWorld()->GetBlock(X, Y, Z + 1) == E_BLOCK_CACTUS)) || ((GetPosZ() - Z < w) && (GetWorld()->GetBlock(X, Y, Z - 1) == E_BLOCK_CACTUS)) || - (((Y > 0) && (Y < cChunkDef::Height)) && ((GetPosY() - Y < 1) && (GetWorld()->GetBlock(X, Y, Z) == E_BLOCK_CACTUS))) + (((GetPosY() - Y < 1) && (GetWorld()->GetBlock(X, Y, Z) == E_BLOCK_CACTUS)))) ) { TakeDamage(dtCactusContact, NULL, 1, 0); -- cgit v1.2.3 From 507df718453483e6ca74ca897a78eed679222f06 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Tue, 20 May 2014 13:35:39 +0100 Subject: Update Player.cpp --- src/Entities/Player.cpp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'src/Entities') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 3a32bfb2e..c27456397 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -377,7 +377,7 @@ short cPlayer::DeltaExperience(short a_Xp_delta) } LOGD("Player \"%s\" gained/lost %d experience, total is now: %d", - m_PlayerName.c_str(), a_Xp_delta, m_CurrentXp); + GetName().c_str(), a_Xp_delta, m_CurrentXp); // Set experience to be updated m_bDirtyExperience = true; @@ -391,7 +391,7 @@ short cPlayer::DeltaExperience(short a_Xp_delta) void cPlayer::StartChargingBow(void) { - LOGD("Player \"%s\" started charging their bow", m_PlayerName.c_str()); + LOGD("Player \"%s\" started charging their bow", GetName().c_str()); m_IsChargingBow = true; m_BowCharge = 0; } @@ -402,7 +402,7 @@ void cPlayer::StartChargingBow(void) int cPlayer::FinishChargingBow(void) { - LOGD("Player \"%s\" finished charging their bow at a charge of %d", m_PlayerName.c_str(), m_BowCharge); + LOGD("Player \"%s\" finished charging their bow at a charge of %d", GetName().c_str(), m_BowCharge); int res = m_BowCharge; m_IsChargingBow = false; m_BowCharge = 0; @@ -415,7 +415,7 @@ int cPlayer::FinishChargingBow(void) void cPlayer::CancelChargingBow(void) { - LOGD("Player \"%s\" cancelled charging their bow at a charge of %d", m_PlayerName.c_str(), m_BowCharge); + LOGD("Player \"%s\" cancelled charging their bow at a charge of %d", GetName().c_str(), m_BowCharge); m_IsChargingBow = false; m_BowCharge = 0; } @@ -1305,7 +1305,7 @@ void cPlayer::AddToGroup( const AString & a_GroupName ) { cGroup* Group = cRoot::Get()->GetGroupManager()->GetGroup( a_GroupName ); m_Groups.push_back( Group ); - LOGD("Added %s to group %s", m_PlayerName.c_str(), a_GroupName.c_str() ); + LOGD("Added %s to group %s", GetName().c_str(), a_GroupName.c_str() ); ResolveGroups(); ResolvePermissions(); } @@ -1329,13 +1329,13 @@ void cPlayer::RemoveFromGroup( const AString & a_GroupName ) if( bRemoved ) { - LOGD("Removed %s from group %s", m_PlayerName.c_str(), a_GroupName.c_str() ); + LOGD("Removed %s from group %s", GetName().c_str(), a_GroupName.c_str() ); ResolveGroups(); ResolvePermissions(); } else { - LOGWARN("Tried to remove %s from group %s but was not in that group", m_PlayerName.c_str(), a_GroupName.c_str() ); + LOGWARN("Tried to remove %s from group %s but was not in that group", GetName().c_str(), a_GroupName.c_str() ); } } @@ -1441,7 +1441,7 @@ void cPlayer::ResolveGroups() if( AllGroups.find( CurrentGroup ) != AllGroups.end() ) { LOGWARNING("ERROR: Player \"%s\" is in the group multiple times (\"%s\"). Please fix your settings in users.ini!", - m_PlayerName.c_str(), CurrentGroup->GetName().c_str() + GetName().c_str(), CurrentGroup->GetName().c_str() ); } else @@ -1453,7 +1453,7 @@ void cPlayer::ResolveGroups() { if( AllGroups.find( *itr ) != AllGroups.end() ) { - LOGERROR("ERROR: Player %s is in the same group multiple times due to inheritance (%s). FIX IT!", m_PlayerName.c_str(), (*itr)->GetName().c_str() ); + LOGERROR("ERROR: Player %s is in the same group multiple times due to inheritance (%s). FIX IT!", GetName().c_str(), (*itr)->GetName().c_str() ); continue; } ToIterate.push_back( *itr ); @@ -1605,19 +1605,19 @@ void cPlayer::LoadPermissionsFromDisk() cIniFile IniFile; if (IniFile.ReadFile("users.ini")) { - AString Groups = IniFile.GetValueSet(m_PlayerName, "Groups", "Default"); + AString Groups = IniFile.GetValueSet(GetName(), "Groups", "Default"); AStringVector Split = StringSplitAndTrim(Groups, ","); for (AStringVector::const_iterator itr = Split.begin(), end = Split.end(); itr != end; ++itr) { if (!cRoot::Get()->GetGroupManager()->ExistsGroup(*itr)) { - LOGWARNING("The group %s for player %s was not found!", itr->c_str(), m_PlayerName.c_str()); + LOGWARNING("The group %s for player %s was not found!", itr->c_str(), GetName().c_str()); } AddToGroup(*itr); } - AString Color = IniFile.GetValue(m_PlayerName, "Color", "-"); + AString Color = IniFile.GetValue(GetName(), "Color", "-"); if (!Color.empty()) { m_Color = Color[0]; @@ -1626,7 +1626,7 @@ void cPlayer::LoadPermissionsFromDisk() else { cGroupManager::GenerateDefaultUsersIni(IniFile); - IniFile.AddValue("Groups", m_PlayerName, "Default"); + IniFile.AddValue("Groups", GetName(), "Default"); AddToGroup("Default"); } IniFile.WriteFile("users.ini"); @@ -1641,14 +1641,14 @@ bool cPlayer::LoadFromDisk() LoadPermissionsFromDisk(); // Log player permissions, cause it's what the cool kids do - LOGINFO("Player %s has permissions:", m_PlayerName.c_str() ); + LOGINFO("Player %s has permissions:", GetName().c_str() ); for( PermissionMap::iterator itr = m_ResolvedPermissions.begin(); itr != m_ResolvedPermissions.end(); ++itr ) { if( itr->second ) LOG(" - %s", itr->first.c_str() ); } AString SourceFile; - Printf(SourceFile, "players/%s.json", m_PlayerName.c_str() ); + Printf(SourceFile, "players/%s.json", GetName().c_str() ); cFile f; if (!f.Open(SourceFile, cFile::fmRead)) @@ -1716,7 +1716,7 @@ bool cPlayer::LoadFromDisk() StatSerializer.Load(); LOGD("Player \"%s\" was read from file, spawning at {%.2f, %.2f, %.2f} in world \"%s\"", - m_PlayerName.c_str(), GetPosX(), GetPosY(), GetPosZ(), m_LoadedWorldName.c_str() + GetName().c_str(), GetPosX(), GetPosY(), GetPosZ(), m_LoadedWorldName.c_str() ); return true; @@ -1772,12 +1772,12 @@ bool cPlayer::SaveToDisk() std::string JsonData = writer.write(root); AString SourceFile; - Printf(SourceFile, "players/%s.json", m_PlayerName.c_str() ); + Printf(SourceFile, "players/%s.json", GetName().c_str() ); cFile f; if (!f.Open(SourceFile, cFile::fmWrite)) { - LOGERROR("ERROR WRITING PLAYER \"%s\" TO FILE \"%s\" - cannot open file", m_PlayerName.c_str(), SourceFile.c_str()); + LOGERROR("ERROR WRITING PLAYER \"%s\" TO FILE \"%s\" - cannot open file", GetName().c_str(), SourceFile.c_str()); return false; } if (f.Write(JsonData.c_str(), JsonData.size()) != (int)JsonData.size()) @@ -1791,7 +1791,7 @@ bool cPlayer::SaveToDisk() cStatSerializer StatSerializer(cRoot::Get()->GetDefaultWorld()->GetName(), GetName(), &m_Stats); if (!StatSerializer.Save()) { - LOGERROR("Could not save stats for player %s", m_PlayerName.c_str()); + LOGERROR("Could not save stats for player %s", GetName().c_str()); return false; } -- cgit v1.2.3 From 07baf9bdd3b04e3aec6e77f367eb38c0547f54ca Mon Sep 17 00:00:00 2001 From: andrew Date: Tue, 20 May 2014 15:52:59 +0300 Subject: Cleaned up cPlayer::UpdateMovementStats; Wither achievements --- src/Entities/Player.cpp | 71 +++++++++++++++++++++++++++++++++++++++---------- src/Entities/Player.h | 3 +++ 2 files changed, 60 insertions(+), 14 deletions(-) (limited to 'src/Entities') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index c3b763278..0eacb67f9 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -456,8 +456,18 @@ void cPlayer::SetTouchGround(bool a_bTouchGround) else { float Dist = (float)(m_LastGroundHeight - floor(GetPosY())); + + if (Dist >= 2.0) // At least two blocks - TODO: Use m_LastJumpHeight instead of m_LastGroundHeight above + { + // Increment statistic + m_Stats.AddValue(statDistFallen, (StatValue)floor(Dist * 100 + 0.5)); + } + int Damage = (int)(Dist - 3.f); - if (m_LastJumpHeight > m_LastGroundHeight) Damage++; + if (m_LastJumpHeight > m_LastGroundHeight) + { + Damage++; + } m_LastJumpHeight = (float)GetPosY(); if (Damage > 0) @@ -1951,32 +1961,65 @@ void cPlayer::HandleFloater() +bool cPlayer::IsClimbing(void) const +{ + int PosX = POSX_TOINT; + int PosY = POSY_TOINT; + int PosZ = POSZ_TOINT; + + if ((PosY < 0) || (PosY >= cChunkDef::Height)) + { + return false; + } + + BLOCKTYPE Block = m_World->GetBlock(PosX, PosY, PosZ); + switch (Block) + { + case E_BLOCK_LADDER: + case E_BLOCK_VINES: + { + return true; + } + default: return false; + } +} + + + + + void cPlayer::UpdateMovementStats(const Vector3d & a_DeltaPos) { StatValue Value = (StatValue)floor(a_DeltaPos.Length() * 100 + 0.5); if (m_AttachedTo == NULL) { - int PosX = POSX_TOINT; - int PosY = POSY_TOINT; - int PosZ = POSZ_TOINT; - - BLOCKTYPE Block; - NIBBLETYPE Meta; - if (!m_World->GetBlockTypeMeta(PosX, PosY, PosZ, Block, Meta)) + if (IsClimbing()) { - return; + if (a_DeltaPos.y > 0.0) // Going up + { + m_Stats.AddValue(statDistClimbed, (StatValue)floor(a_DeltaPos.y * 100 + 0.5)); + } } - - if ((Block == E_BLOCK_LADDER) && (a_DeltaPos.y > 0.0)) // Going up + else if (IsSubmerged()) { - m_Stats.AddValue(statDistClimbed, (StatValue)floor(a_DeltaPos.y * 100 + 0.5)); + m_Stats.AddValue(statDistDove, Value); } - else + else if (IsSwimming()) + { + m_Stats.AddValue(statDistSwum, Value); + } + else if (IsOnGround()) { - // TODO 2014-05-12 xdot: Other types m_Stats.AddValue(statDistWalked, Value); } + else + { + if (Value >= 25) // Ignore small/slow movement + { + m_Stats.AddValue(statDistFlown, Value); + } + } } else { diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 78b534d83..b7cb27d6c 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -127,6 +127,9 @@ public: inline const cItem & GetEquippedItem(void) const { return GetInventory().GetEquippedItem(); } // tolua_export + /** Returns whether the player is climbing (ladders, vines e.t.c). */ + bool IsClimbing(void) const; + virtual void TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ) override; // tolua_begin -- cgit v1.2.3 From 941cb88ae456f0d8b91f6b5dc835c2536eef15f6 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 23 May 2014 12:33:30 +0200 Subject: Fixed datatype conversion warning. --- src/Entities/Entity.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Entities') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 15f456332..2567b7adc 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1018,10 +1018,10 @@ void cEntity::TickInVoid(cChunk & a_Chunk) -void cEntity::DetectCacti() +void cEntity::DetectCacti(void) { int X = POSX_TOINT, Y = POSY_TOINT, Z = POSZ_TOINT; - float w = m_Width / 2; + double w = m_Width / 2; if ( (((X + 1) - GetPosX() < w) && (GetWorld()->GetBlock(X + 1, Y, Z) == E_BLOCK_CACTUS)) || (((GetPosX() - (X - 1)) - 1 < w) && (GetWorld()->GetBlock(X - 1, Y, Z) == E_BLOCK_CACTUS)) || -- cgit v1.2.3 From d1b23060ada3946d68453e381867861bc768999b Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sat, 31 May 2014 14:14:55 +0200 Subject: Used recommendations --- src/Entities/ProjectileEntity.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/Entities') diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index 7a869a957..acb10539d 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -68,8 +68,7 @@ protected: if (bb.CalcLineIntersection(Line1, Line2, LineCoeff, Face)) { Vector3d Intersection = Line1 + m_Projectile->GetSpeed() * LineCoeff; - const Vector3i BlockHitPos = Vector3i(Intersection); - if (cPluginManager::Get()->CallHookProjectileHitBlock(*m_Projectile, Face, &BlockHitPos)) + if (cPluginManager::Get()->CallHookProjectileHitBlock(*m_Projectile, a_BlockX, a_BlockY, a_BlockZ, Face, &Intersection)) { return false; } -- cgit v1.2.3 From c0015d01c6be8b4061a19484d13b7d0e74426be5 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 3 Jun 2014 19:50:27 +0200 Subject: Player permissions aren't logged to console anymore. This was only logspam on most servers and there are alternative ways to list players' permissions. --- src/Entities/Player.cpp | 7 ------- 1 file changed, 7 deletions(-) (limited to 'src/Entities') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 0dfdcfd8b..3a9324d09 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1650,13 +1650,6 @@ bool cPlayer::LoadFromDisk() { LoadPermissionsFromDisk(); - // Log player permissions, cause it's what the cool kids do - LOGINFO("Player %s has permissions:", GetName().c_str() ); - for( PermissionMap::iterator itr = m_ResolvedPermissions.begin(); itr != m_ResolvedPermissions.end(); ++itr ) - { - if( itr->second ) LOG(" - %s", itr->first.c_str() ); - } - AString SourceFile; Printf(SourceFile, "players/%s.json", GetName().c_str() ); -- cgit v1.2.3 From 33fbdedea3b9d48f2bec329b93d86024befbb6ab Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 4 Jun 2014 15:16:30 +0200 Subject: Fix itemframe break. --- src/Entities/ItemFrame.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/Entities') diff --git a/src/Entities/ItemFrame.cpp b/src/Entities/ItemFrame.cpp index 9dd909880..7bc7bda8d 100644 --- a/src/Entities/ItemFrame.cpp +++ b/src/Entities/ItemFrame.cpp @@ -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); } -- cgit v1.2.3 From b904223b9dbbe7b696dbd30e748bc131742e11ea Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 6 Jun 2014 22:31:16 +0200 Subject: Added queue for adding entities to cWorld. This alone doesn't work properly yet, further changes to cPlayer are needed. --- src/Entities/Entity.h | 5 +++-- src/Entities/Player.cpp | 2 -- src/Entities/Player.h | 2 ++ 3 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src/Entities') diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 0c393c0f5..9fe771120 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -421,6 +421,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; @@ -485,8 +488,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(); diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 3a9324d09..b83419903 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1595,8 +1595,6 @@ bool cPlayer::MoveToWorld(const char * a_WorldName) m_ClientHandle->MoveToWorld(*World, (OldDimension != World->GetDimension())); // Add player to all the necessary parts of the new world - SetWorld(World); - m_ClientHandle->StreamChunks(); World->AddEntity(this); World->AddPlayer(this); diff --git a/src/Entities/Player.h b/src/Entities/Player.h index b7cb27d6c..83b9ad593 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -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). */ bool MoveToWorld(const char * a_WorldName); // tolua_export bool SaveToDisk(void); -- cgit v1.2.3 From af4a21ea0689107b377818574cb07dc4a2e8b755 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sun, 8 Jun 2014 21:58:08 +0200 Subject: Fixed deadlock when moving players to other worlds. Fixes #1039, fixes #851 --- src/Entities/Entity.cpp | 10 +++++----- src/Entities/Entity.h | 5 +++-- src/Entities/Player.cpp | 18 ++++++++++-------- 3 files changed, 18 insertions(+), 15 deletions(-) (limited to 'src/Entities') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 1226a2319..8f736a269 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -129,9 +129,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; } @@ -144,13 +144,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; } diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 9fe771120..85ad42d54 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -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 diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index b83419903..feb09b5d2 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -940,6 +940,8 @@ void cPlayer::Killed(cEntity * a_Victim) void cPlayer::Respawn(void) { + ASSERT(m_World != NULL); + m_Health = GetMaxHealth(); SetInvulnerableTicks(20); @@ -952,7 +954,7 @@ void cPlayer::Respawn(void) m_LifetimeTotalXp = 0; // ToDo: send score to client? How? - m_ClientHandle->SendRespawn(); + m_ClientHandle->SendRespawn(*m_World); // Extinguish the fire: StopBurning(); @@ -1583,19 +1585,19 @@ bool cPlayer::MoveToWorld(const char * a_WorldName) 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(); - m_World->RemoveEntity(this); // 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 - m_ClientHandle->MoveToWorld(*World, (OldDimension != World->GetDimension())); - // Add player to all the necessary parts of the new world - World->AddEntity(this); + // Queue adding player to the new world, including all the necessary adjustments to the object World->AddPlayer(this); return true; -- cgit v1.2.3