Merge pull request #3399 from megamage/master

Fix the relocation of creatures across cells. Try to fix #3054.
This commit is contained in:
megamage
2011-10-10 13:12:15 -07:00
6 changed files with 100 additions and 54 deletions
@@ -143,7 +143,8 @@ m_PlayerDamageReq(0), m_lootMoney(0), m_lootRecipient(0), m_lootRecipientGroup(0
m_respawnDelay(300), m_corpseDelay(60), m_respawnradius(0.0f), m_reactState(REACT_AGGRESSIVE),
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_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL),
m_creatureInfo(NULL), m_creatureData(NULL), m_formation(NULL)
m_creatureInfo(NULL), m_creatureData(NULL), m_formation(NULL),
MapCreature()
{
m_regenTimer = CREATURE_REGEN_INTERVAL;
m_valuesCount = UNIT_END;
+30 -6
View File
@@ -407,7 +407,36 @@ typedef std::map<uint32, time_t> CreatureSpellCooldowns;
#define MAX_VENDOR_ITEMS 150 // Limitation in 3.x.x item count in SMSG_LIST_INVENTORY
class Creature : public Unit, public GridObject<Creature>
enum CreatureCellMoveState
{
CREATURE_CELL_MOVE_NONE, //not in move list
CREATURE_CELL_MOVE_ACTIVE, //in move list
CREATURE_CELL_MOVE_INACTIVE, //in move list but should not move
};
class MapCreature
{
friend class Map; //map for moving creatures
friend class ObjectGridLoader; //grid loader for loading creatures
public:
MapCreature() : _moveState(CREATURE_CELL_MOVE_NONE) {}
private:
Cell _currentCell;
Cell const& GetCurrentCell() const { return _currentCell; }
void SetCurrentCell(Cell const& cell) { _currentCell = cell; }
CreatureCellMoveState _moveState;
Position _newPosition;
void SetNewCellPosition(float x, float y, float z, float o)
{
_moveState = CREATURE_CELL_MOVE_ACTIVE;
_newPosition.Relocate(x, y, z, o);
}
};
class Creature : public Unit, public GridObject<Creature>, public MapCreature
{
public:
@@ -598,10 +627,6 @@ class Creature : public Unit, public GridObject<Creature>
MovementGeneratorType GetDefaultMovementType() const { return m_defaultMovementType; }
void SetDefaultMovementType(MovementGeneratorType mgt) { m_defaultMovementType = mgt; }
// for use only in LoadHelper, Map::Add Map::CreatureCellRelocation
Cell const& GetCurrentCell() const { return m_currentCell; }
void SetCurrentCell(Cell const& cell) { m_currentCell = cell; }
void RemoveCorpse(bool setSpawnTime = true);
void ForcedDespawn(uint32 timeMSToDespawn = 0);
@@ -703,7 +728,6 @@ class Creature : public Unit, public GridObject<Creature>
void RegenerateHealth();
void Regenerate(Powers power);
MovementGeneratorType m_defaultMovementType;
Cell m_currentCell; // store current cell where creature listed
uint32 m_DBTableGuid; ///< For new or temporary creatures is 0 for saved it is lowguid
uint32 m_equipmentId;