mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 10:37:03 +00:00
[9232] Replace list bool fields with exclusive true values by subtype field in Creature.
Use it in recently added code instead dynamic_cast use.
This commit is contained in:
parent
6653539a5e
commit
797dd6d931
9 changed files with 29 additions and 21 deletions
|
|
@ -111,13 +111,12 @@ bool ForcedDespawnDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
|
|||
return true;
|
||||
}
|
||||
|
||||
Creature::Creature() :
|
||||
Creature::Creature(CreatureSubtype subtype) :
|
||||
Unit(), i_AI(NULL),
|
||||
lootForPickPocketed(false), lootForBody(false), m_groupLootTimer(0), lootingGroupLeaderGUID(0),
|
||||
m_lootMoney(0), m_lootRecipient(0),
|
||||
m_deathTimer(0), m_respawnTime(0), m_respawnDelay(25), m_corpseDelay(60), m_respawnradius(0.0f),
|
||||
m_isPet(false), m_isVehicle(false), m_isTotem(false),
|
||||
m_defaultMovementType(IDLE_MOTION_TYPE), m_DBTableGuid(0), m_equipmentId(0),
|
||||
m_subtype(subtype), m_defaultMovementType(IDLE_MOTION_TYPE), m_DBTableGuid(0), m_equipmentId(0),
|
||||
m_AlreadyCallAssistance(false), m_AlreadySearchedAssistance(false),
|
||||
m_regenHealth(true), m_AI_locked(false), m_isDeadByDefault(false), m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL),
|
||||
m_creatureInfo(NULL), m_isActiveObject(false), m_monsterMoveFlags(MONSTER_MOVE_WALK)
|
||||
|
|
|
|||
|
|
@ -361,13 +361,22 @@ typedef std::map<uint32,time_t> CreatureSpellCooldowns;
|
|||
|
||||
#define MAX_VENDOR_ITEMS 150 // Limitation in 3.x.x item count in SMSG_LIST_INVENTORY
|
||||
|
||||
enum CreatureSubtype
|
||||
{
|
||||
CREATURE_SUBTYPE_GENERIC, // new Creature
|
||||
CREATURE_SUBTYPE_PET, // new Pet
|
||||
CREATURE_SUBTYPE_TOTEM, // new Totem
|
||||
CREATURE_SUBTYPE_VEHICLE, // new Vehicle
|
||||
CREATURE_SUBTYPE_TEMPORARY_SUMMON, // new TemporarySummon
|
||||
};
|
||||
|
||||
class MANGOS_DLL_SPEC Creature : public Unit
|
||||
{
|
||||
CreatureAI *i_AI;
|
||||
|
||||
public:
|
||||
|
||||
explicit Creature();
|
||||
explicit Creature(CreatureSubtype subtype = CREATURE_SUBTYPE_GENERIC);
|
||||
virtual ~Creature();
|
||||
|
||||
void AddToWorld();
|
||||
|
|
@ -385,10 +394,13 @@ class MANGOS_DLL_SPEC Creature : public Unit
|
|||
void GetRespawnCoord(float &x, float &y, float &z, float* ori = NULL, float* dist =NULL) const;
|
||||
uint32 GetEquipmentId() const { return m_equipmentId; }
|
||||
|
||||
bool isPet() const { return m_isPet; }
|
||||
bool isVehicle() const { return m_isVehicle; }
|
||||
CreatureSubtype GetSubtype() const { return m_subtype; }
|
||||
bool isPet() const { return m_subtype == CREATURE_SUBTYPE_PET; }
|
||||
bool isVehicle() const { return m_subtype == CREATURE_SUBTYPE_VEHICLE; }
|
||||
bool isTotem() const { return m_subtype == CREATURE_SUBTYPE_TOTEM; }
|
||||
bool isTemporarySummon() const { return m_subtype == CREATURE_SUBTYPE_TEMPORARY_SUMMON; }
|
||||
|
||||
void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; }
|
||||
bool isTotem() const { return m_isTotem; }
|
||||
bool isRacialLeader() const { return GetCreatureInfo()->RacialLeader; }
|
||||
bool isCivilian() const { return GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN; }
|
||||
bool canWalk() const { return GetCreatureInfo()->InhabitType & INHABIT_GROUND; }
|
||||
|
|
@ -628,9 +640,7 @@ class MANGOS_DLL_SPEC Creature : public Unit
|
|||
uint32 m_corpseDelay; // (secs) delay between death and corpse disappearance
|
||||
float m_respawnradius;
|
||||
|
||||
bool m_isPet; // set only in Pet::Pet
|
||||
bool m_isVehicle; // set only in Vehicle::Vehicle
|
||||
bool m_isTotem; // set only in Totem::Totem
|
||||
CreatureSubtype m_subtype; // set in Creatures subclasses for fast it detect without dynamic_cast use
|
||||
void RegenerateMana();
|
||||
void RegenerateHealth();
|
||||
MovementGeneratorType m_defaultMovementType;
|
||||
|
|
|
|||
|
|
@ -38,11 +38,10 @@ char const* petTypeSuffix[MAX_PET_TYPE] =
|
|||
};
|
||||
|
||||
Pet::Pet(PetType type) :
|
||||
Creature(), m_removed(false), m_petType(type), m_happinessTimer(7500), m_duration(0), m_resetTalentsCost(0),
|
||||
Creature(CREATURE_SUBTYPE_PET), m_removed(false), m_petType(type), m_happinessTimer(7500), m_duration(0), m_resetTalentsCost(0),
|
||||
m_bonusdamage(0), m_resetTalentsTime(0), m_usedTalentCount(0), m_auraUpdateMask(0), m_loading(false),
|
||||
m_declinedname(NULL), m_petModeFlags(PET_MODE_DEFAULT)
|
||||
{
|
||||
m_isPet = true;
|
||||
m_name = "Pet";
|
||||
m_regenTimer = 4000;
|
||||
|
||||
|
|
|
|||
|
|
@ -94,11 +94,12 @@ void PointMovementGenerator<Creature>::MovementInform(Creature &unit)
|
|||
if (unit.AI())
|
||||
unit.AI()->MovementInform(POINT_MOTION_TYPE, id);
|
||||
|
||||
if (TemporarySummon* pSummon = dynamic_cast<TemporarySummon*>(&unit))
|
||||
if (unit.isTemporarySummon())
|
||||
{
|
||||
TemporarySummon* pSummon = (TemporarySummon*)(&unit);
|
||||
if (IS_CREATURE_GUID(pSummon->GetSummonerGUID()))
|
||||
{
|
||||
if (Unit* pSummoner = pSummon->GetSummoner())
|
||||
{
|
||||
if (pSummoner->GetTypeId() == TYPEID_UNIT)
|
||||
{
|
||||
if (((Creature*)pSummoner)->AI())
|
||||
((Creature*)pSummoner)->AI()->SummonedMovementInform(&unit, POINT_MOTION_TYPE, id);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
#include "CreatureAI.h"
|
||||
|
||||
TemporarySummon::TemporarySummon( uint64 summoner ) :
|
||||
Creature(), m_type(TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN), m_timer(0), m_lifetime(0), m_summoner(summoner)
|
||||
Creature(CREATURE_SUBTYPE_TEMPORARY_SUMMON), m_type(TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN), m_timer(0), m_lifetime(0), m_summoner(summoner)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ class TemporarySummon : public Creature
|
|||
void Summon(TempSummonType type, uint32 lifetime);
|
||||
void MANGOS_DLL_SPEC UnSummon();
|
||||
void SaveToDB();
|
||||
uint64 GetSummonerGUID() const { return m_summoner ; }
|
||||
Unit* GetSummoner() const { return m_summoner ? ObjectAccessor::GetUnit(*this, m_summoner) : NULL; }
|
||||
private:
|
||||
TempSummonType m_type;
|
||||
|
|
|
|||
|
|
@ -24,9 +24,8 @@
|
|||
#include "ObjectMgr.h"
|
||||
#include "SpellMgr.h"
|
||||
|
||||
Totem::Totem() : Creature()
|
||||
Totem::Totem() : Creature(CREATURE_SUBTYPE_TOTEM)
|
||||
{
|
||||
m_isTotem = true;
|
||||
m_duration = 0;
|
||||
m_type = TOTEM_PASSIVE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,9 +23,8 @@
|
|||
#include "Unit.h"
|
||||
#include "Util.h"
|
||||
|
||||
Vehicle::Vehicle() : Creature(), m_vehicleId(0)
|
||||
Vehicle::Vehicle() : Creature(CREATURE_SUBTYPE_VEHICLE), m_vehicleId(0)
|
||||
{
|
||||
m_isVehicle = true;
|
||||
m_updateFlag = (UPDATEFLAG_LIVING | UPDATEFLAG_HAS_POSITION | UPDATEFLAG_VEHICLE);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "9231"
|
||||
#define REVISION_NR "9232"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue