summaryrefslogtreecommitdiffstats
path: root/src/Entities
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-07-04 23:07:26 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-07-04 23:07:26 +0200
commitf4e11d194e9e4a2e85a9f9688312ad08ade45b83 (patch)
tree1d5f2e405bd8a99bcfe298ecf89dcc8211861af2 /src/Entities
parentCompile fix (diff)
downloadcuberite-f4e11d194e9e4a2e85a9f9688312ad08ade45b83.tar
cuberite-f4e11d194e9e4a2e85a9f9688312ad08ade45b83.tar.gz
cuberite-f4e11d194e9e4a2e85a9f9688312ad08ade45b83.tar.bz2
cuberite-f4e11d194e9e4a2e85a9f9688312ad08ade45b83.tar.lz
cuberite-f4e11d194e9e4a2e85a9f9688312ad08ade45b83.tar.xz
cuberite-f4e11d194e9e4a2e85a9f9688312ad08ade45b83.tar.zst
cuberite-f4e11d194e9e4a2e85a9f9688312ad08ade45b83.zip
Diffstat (limited to 'src/Entities')
-rw-r--r--src/Entities/ProjectileEntity.cpp11
-rw-r--r--src/Entities/ProjectileEntity.h2
2 files changed, 9 insertions, 4 deletions
diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp
index ddcc0f7fd..50f62b018 100644
--- a/src/Entities/ProjectileEntity.cpp
+++ b/src/Entities/ProjectileEntity.cpp
@@ -216,7 +216,10 @@ protected:
cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, double a_Width, double a_Height) :
super(etProjectile, a_X, a_Y, a_Z, a_Width, a_Height),
m_ProjectileKind(a_Kind),
- m_CreatorData(a_Creator->GetUniqueID(), a_Creator->IsPlayer() ? ((cPlayer *)a_Creator)->GetName() : ""),
+ m_CreatorData(
+ ((a_Creator != NULL) ? a_Creator->GetUniqueID() : -1),
+ ((a_Creator != NULL) ? (a_Creator->IsPlayer() ? ((cPlayer *)a_Creator)->GetName() : "") : "")
+ ),
m_IsInGround(false)
{
}
@@ -298,7 +301,7 @@ void cProjectileEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_
cEntity * cProjectileEntity::GetCreator()
{
- if (m_CreatorData.m_Name.empty())
+ if (m_CreatorData.m_Name.empty() && (m_CreatorData.m_UniqueID >= 1))
{
class cProjectileCreatorCallback : public cEntityCallback
{
@@ -328,7 +331,7 @@ cEntity * cProjectileEntity::GetCreator()
GetWorld()->DoWithEntityByID(m_CreatorData.m_UniqueID, PCC);
return PCC.GetEntity();
}
- else
+ else if (!m_CreatorData.m_Name.empty())
{
class cProjectileCreatorCallbackForPlayers : public cPlayerListCallback
{
@@ -358,6 +361,8 @@ cEntity * cProjectileEntity::GetCreator()
GetWorld()->FindAndDoWithPlayer(m_CreatorData.m_Name, PCCFP);
return PCCFP.GetEntity();
}
+
+ return NULL;
}
diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h
index e2ebe9f27..84eefb9ee 100644
--- a/src/Entities/ProjectileEntity.h
+++ b/src/Entities/ProjectileEntity.h
@@ -94,7 +94,7 @@ protected:
*/
struct CreatorData
{
- CreatorData(int a_UniqueID, AString & a_Name) :
+ CreatorData(int a_UniqueID, const AString & a_Name) :
m_UniqueID(a_UniqueID),
m_Name(a_Name)
{