diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-07-09 10:50:38 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-07-09 10:50:38 +0200 |
commit | 372dbbb994a1414369fe38367d458a0c32866a79 (patch) | |
tree | 5cd564fbb0c4b7c0b47f3cb64594c34f9361f1dc /src/Entities/ProjectileEntity.h | |
parent | Updated generator prefabs to current Gallery contents. (diff) | |
parent | Added extra space before comments (diff) | |
download | cuberite-372dbbb994a1414369fe38367d458a0c32866a79.tar cuberite-372dbbb994a1414369fe38367d458a0c32866a79.tar.gz cuberite-372dbbb994a1414369fe38367d458a0c32866a79.tar.bz2 cuberite-372dbbb994a1414369fe38367d458a0c32866a79.tar.lz cuberite-372dbbb994a1414369fe38367d458a0c32866a79.tar.xz cuberite-372dbbb994a1414369fe38367d458a0c32866a79.tar.zst cuberite-372dbbb994a1414369fe38367d458a0c32866a79.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Entities/ProjectileEntity.h | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h index ae06b072f..7b38169e2 100644 --- a/src/Entities/ProjectileEntity.h +++ b/src/Entities/ProjectileEntity.h @@ -66,8 +66,15 @@ public: /// Returns the kind of the projectile (fast class identification) eKind GetProjectileKind(void) const { return m_ProjectileKind; } - /// Returns the entity who created this projectile; may be NULL - cEntity * GetCreator(void) { return m_Creator; } + /** Returns the unique ID of the entity who created this projectile + May return an ID <0 + */ + int GetCreatorUniqueID(void) { return m_CreatorData.m_UniqueID; } + + /** Returns the name of the player that created the projectile + Will be empty for non-player creators + */ + AString GetCreatorName(void) const { return m_CreatorData.m_Name; } /// Returns the string that is used as the entity type (class name) in MCA files AString GetMCAClassName(void) const; @@ -81,10 +88,29 @@ public: void SetIsInGround(bool a_IsInGround) { m_IsInGround = a_IsInGround; } protected: + + /** A structure that stores the Entity ID and Playername of the projectile's creator + Used to migitate invalid pointers caused by the creator being destroyed + */ + struct CreatorData + { + CreatorData(int a_UniqueID, const AString & a_Name) : + m_UniqueID(a_UniqueID), + m_Name(a_Name) + { + } + + const int m_UniqueID; + AString m_Name; + }; + + /** The type of projectile I am */ eKind m_ProjectileKind; - /// The entity who has created this projectile; may be NULL (e. g. for dispensers) - cEntity * m_Creator; + /** The structure for containing the entity ID and name who has created this projectile + The ID and/or name may be NULL (e.g. for dispensers/mobs) + */ + CreatorData m_CreatorData; /// True if the projectile has hit the ground and is stuck there bool m_IsInGround; |