diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 859cba5c7..d18f8aff2 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -697,40 +697,27 @@ Map::PlayerRelocation(Player *player, float x, float y, float z, float orientati } } -void -Map::CreatureRelocation(Creature *creature, float x, float y, float z, float ang) +void Map::CreatureRelocation(Creature *creature, float x, float y, float z, float ang) { MANGOS_ASSERT(CheckGridIntegrity(creature,false)); Cell old_cell = creature->GetCurrentCell(); + Cell new_cell(MaNGOS::ComputeCellPair(x, y)); - CellPair new_val = MaNGOS::ComputeCellPair(x, y); - Cell new_cell(new_val); - - if (old_cell.DiffCell(new_cell) || old_cell.DiffGrid(new_cell)) - { - DEBUG_FILTER_LOG(LOG_FILTER_CREATURE_MOVES, "Creature (GUID: %u Entry: %u) added to moving list from grid[%u,%u]cell[%u,%u] to grid[%u,%u]cell[%u,%u].", creature->GetGUIDLow(), creature->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY()); - - // do move or do move to respawn or remove creature if previous all fail - if (CreatureCellRelocation(creature,new_cell)) - { - // update pos - creature->Relocate(x, y, z, ang); - creature->OnRelocated(); - } - // if creature can't be move in new cell/grid (not loaded) move it to repawn cell/grid - // creature coordinates will be updated and notifiers send - else if (!CreatureRespawnRelocation(creature)) - { - // ... or unload (if respawn grid also not loaded) - DEBUG_FILTER_LOG(LOG_FILTER_CREATURE_MOVES, "Creature (GUID: %u Entry: %u ) can't be move to unloaded respawn grid.",creature->GetGUIDLow(),creature->GetEntry()); - } - } - else + // do move or do move to respawn or remove creature if previous all fail + if (CreatureCellRelocation(creature,new_cell)) { + // update pos creature->Relocate(x, y, z, ang); creature->OnRelocated(); } + // if creature can't be move in new cell/grid (not loaded) move it to repawn cell/grid + // creature coordinates will be updated and notifiers send + else if (!CreatureRespawnRelocation(creature)) + { + // ... or unload (if respawn grid also not loaded) + DEBUG_FILTER_LOG(LOG_FILTER_CREATURE_MOVES, "Creature (GUID: %u Entry: %u ) can't be move to unloaded respawn grid.",creature->GetGUIDLow(),creature->GetEntry()); + } MANGOS_ASSERT(CheckGridIntegrity(creature,true)); } @@ -738,63 +725,26 @@ Map::CreatureRelocation(Creature *creature, float x, float y, float z, float ang bool Map::CreatureCellRelocation(Creature *c, Cell new_cell) { Cell const& old_cell = c->GetCurrentCell(); - if(!old_cell.DiffGrid(new_cell) ) // in same grid + if (old_cell.DiffGrid(new_cell)) { - // if in same cell then none do - if(old_cell.DiffCell(new_cell)) + if (!c->isActiveObject() && !loaded(new_cell.gridPair())) { - DEBUG_FILTER_LOG(LOG_FILTER_CREATURE_MOVES, "Creature (GUID: %u Entry: %u) moved in grid[%u,%u] from cell[%u,%u] to cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.CellX(), new_cell.CellY()); - - RemoveFromGrid(c,getNGrid(old_cell.GridX(), old_cell.GridY()),old_cell); - - NGridType* new_grid = getNGrid(new_cell.GridX(), new_cell.GridY()); - AddToGrid(c,new_grid,new_cell); - - c->GetViewPoint().Event_GridChanged( &(*new_grid)(new_cell.CellX(),new_cell.CellY()) ); + DEBUG_FILTER_LOG(LOG_FILTER_CREATURE_MOVES, "Creature (GUID: %u Entry: %u) attempt move from grid[%u,%u]cell[%u,%u] to unloaded grid[%u,%u]cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY()); + return false; } - else - { - DEBUG_FILTER_LOG(LOG_FILTER_CREATURE_MOVES, "Creature (GUID: %u Entry: %u) move in same grid[%u,%u]cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY()); - } - - return true; - } - - // in diff. grids but active creature - if(c->isActiveObject()) - { EnsureGridLoadedAtEnter(new_cell); - - DEBUG_FILTER_LOG(LOG_FILTER_CREATURE_MOVES, "Active creature (GUID: %u Entry: %u) moved from grid[%u,%u]cell[%u,%u] to grid[%u,%u]cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY()); - - RemoveFromGrid(c,getNGrid(old_cell.GridX(), old_cell.GridY()),old_cell); - - NGridType* new_grid = getNGrid(new_cell.GridX(), new_cell.GridY()); - AddToGrid(c,new_grid,new_cell); - c->GetViewPoint().Event_GridChanged( &(*new_grid)(new_cell.CellX(),new_cell.CellY()) ); - - return true; } - // in diff. loaded grid normal creature - if(loaded(GridPair(new_cell.GridX(), new_cell.GridY()))) + if (old_cell != new_cell) { - DEBUG_FILTER_LOG(LOG_FILTER_CREATURE_MOVES, "Creature (GUID: %u Entry: %u) moved from grid[%u,%u]cell[%u,%u] to grid[%u,%u]cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY()); - - RemoveFromGrid(c,getNGrid(old_cell.GridX(), old_cell.GridY()),old_cell); - { - EnsureGridCreated(GridPair(new_cell.GridX(), new_cell.GridY())); - NGridType* new_grid = getNGrid(new_cell.GridX(), new_cell.GridY()); - AddToGrid(c,new_grid,new_cell); - c->GetViewPoint().Event_GridChanged( &(*new_grid)(new_cell.CellX(),new_cell.CellY()) ); - } - - return true; + DEBUG_FILTER_LOG(LOG_FILTER_CREATURE_MOVES, "Creature (GUID: %u Entry: %u) moved in grid[%u,%u] from cell[%u,%u] to cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.CellX(), new_cell.CellY()); + NGridType* oldGrid = getNGrid(old_cell.GridX(), old_cell.GridY()); + NGridType* newGrid = getNGrid(new_cell.GridX(), new_cell.GridY()); + RemoveFromGrid(c, oldGrid, old_cell); + AddToGrid(c, newGrid, new_cell); + c->GetViewPoint().Event_GridChanged(&(*newGrid)(new_cell.CellX(),new_cell.CellY())); } - - // fail to move: normal creature attempt move to unloaded grid - DEBUG_FILTER_LOG(LOG_FILTER_CREATURE_MOVES, "Creature (GUID: %u Entry: %u) attempt move from grid[%u,%u]cell[%u,%u] to unloaded grid[%u,%u]cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY()); - return false; + return true; } bool Map::CreatureRespawnRelocation(Creature *c) diff --git a/src/game/PointMovementGenerator.cpp b/src/game/PointMovementGenerator.cpp index cee9f163f..2db1bae07 100644 --- a/src/game/PointMovementGenerator.cpp +++ b/src/game/PointMovementGenerator.cpp @@ -37,7 +37,7 @@ void PointMovementGenerator::Initialize(T &unit) i_destinationHolder.SetDestination(traveller, i_x, i_y, i_z); if (unit.GetTypeId() == TYPEID_UNIT && ((Creature*)&unit)->CanFly()) - ((Creature&)unit).AddSplineFlag(SPLINEFLAG_UNKNOWN7); + ((Creature&)unit).AddSplineFlag(SPLINEFLAG_FLYING); } template diff --git a/src/game/RandomMovementGenerator.cpp b/src/game/RandomMovementGenerator.cpp index 2dc92ff1f..9353e32e7 100644 --- a/src/game/RandomMovementGenerator.cpp +++ b/src/game/RandomMovementGenerator.cpp @@ -100,7 +100,7 @@ RandomMovementGenerator::_setRandomLocation(Creature &creature) if (is_air_ok) { i_nextMoveTime.Reset(i_destinationHolder.GetTotalTravelTime()); - creature.AddSplineFlag(SPLINEFLAG_UNKNOWN7); + creature.AddSplineFlag(SPLINEFLAG_FLYING); } //else if (is_water_ok) // Swimming mode to be done with more than this check else @@ -117,7 +117,7 @@ void RandomMovementGenerator::Initialize(Creature &creature) return; if (creature.CanFly()) - creature.AddSplineFlag(SPLINEFLAG_UNKNOWN7); + creature.AddSplineFlag(SPLINEFLAG_FLYING); else creature.AddSplineFlag(SPLINEFLAG_WALKMODE); @@ -171,7 +171,7 @@ bool RandomMovementGenerator::Update(Creature &creature, const uint32 if (i_nextMoveTime.Passed()) { if (creature.CanFly()) - creature.AddSplineFlag(SPLINEFLAG_UNKNOWN7); + creature.AddSplineFlag(SPLINEFLAG_FLYING); else creature.AddSplineFlag(SPLINEFLAG_WALKMODE); diff --git a/src/game/TargetedMovementGenerator.cpp b/src/game/TargetedMovementGenerator.cpp index 270a6910a..bf1aeb9ba 100644 --- a/src/game/TargetedMovementGenerator.cpp +++ b/src/game/TargetedMovementGenerator.cpp @@ -80,7 +80,7 @@ void TargetedMovementGeneratorMedium::_setTargetLocation(T &owner) D::_addUnitStateMove(owner); if (owner.GetTypeId() == TYPEID_UNIT && ((Creature*)&owner)->CanFly()) - ((Creature&)owner).AddSplineFlag(SPLINEFLAG_UNKNOWN7); + ((Creature&)owner).AddSplineFlag(SPLINEFLAG_FLYING); } template<> @@ -147,7 +147,7 @@ bool TargetedMovementGeneratorMedium::Update(T &owner, const uint32 & time_ { D::_addUnitStateMove(owner); if (owner.GetTypeId() == TYPEID_UNIT && ((Creature*)&owner)->CanFly()) - ((Creature&)owner).AddSplineFlag(SPLINEFLAG_UNKNOWN7); + ((Creature&)owner).AddSplineFlag(SPLINEFLAG_FLYING); i_destinationHolder.StartTravel(traveller); return true; @@ -211,7 +211,7 @@ void ChaseMovementGenerator::Initialize(Creature &owner) owner.RemoveSplineFlag(SPLINEFLAG_WALKMODE); if (((Creature*)&owner)->CanFly()) - owner.AddSplineFlag(SPLINEFLAG_UNKNOWN7); + owner.AddSplineFlag(SPLINEFLAG_FLYING); _setTargetLocation(owner); } @@ -282,7 +282,7 @@ void FollowMovementGenerator::Initialize(Creature &owner) _updateSpeed(owner); if (((Creature*)&owner)->CanFly()) - owner.AddSplineFlag(SPLINEFLAG_UNKNOWN7); + owner.AddSplineFlag(SPLINEFLAG_FLYING); _setTargetLocation(owner); } diff --git a/src/game/Traveller.h b/src/game/Traveller.h index 210152784..ed58f1023 100644 --- a/src/game/Traveller.h +++ b/src/game/Traveller.h @@ -75,7 +75,7 @@ inline float Traveller::Speed() { if(i_traveller.HasSplineFlag(SPLINEFLAG_WALKMODE)) return i_traveller.GetSpeed(MOVE_WALK); - else if(i_traveller.HasSplineFlag(SPLINEFLAG_UNKNOWN7)) + else if(i_traveller.HasSplineFlag(SPLINEFLAG_FLYING)) return i_traveller.GetSpeed(MOVE_FLIGHT); else return i_traveller.GetSpeed(MOVE_RUN); diff --git a/src/game/WaypointMovementGenerator.cpp b/src/game/WaypointMovementGenerator.cpp index c1c06e6ef..e7bcddb47 100644 --- a/src/game/WaypointMovementGenerator.cpp +++ b/src/game/WaypointMovementGenerator.cpp @@ -79,7 +79,7 @@ void WaypointMovementGenerator::LoadPath(Creature &creature) CreatureTraveller traveller(creature); if (creature.CanFly()) - creature.AddSplineFlag(SPLINEFLAG_UNKNOWN7); + creature.AddSplineFlag(SPLINEFLAG_FLYING); const WaypointNode &node = i_path->at(i_currentNode); i_destinationHolder.SetDestination(traveller, node.x, node.y, node.z); @@ -156,7 +156,7 @@ bool WaypointMovementGenerator::Update(Creature &creature, const uint3 creature.addUnitState(UNIT_STAT_ROAMING_MOVE); if (creature.CanFly()) - creature.AddSplineFlag(SPLINEFLAG_UNKNOWN7); + creature.AddSplineFlag(SPLINEFLAG_FLYING); // Now we re-set destination to same node and start travel const WaypointNode &node = i_path->at(i_currentNode); @@ -254,7 +254,7 @@ bool WaypointMovementGenerator::Update(Creature &creature, const uint3 creature.addUnitState(UNIT_STAT_ROAMING_MOVE); if (creature.CanFly()) - creature.AddSplineFlag(SPLINEFLAG_UNKNOWN7); + creature.AddSplineFlag(SPLINEFLAG_FLYING); if (WaypointBehavior *behavior = i_path->at(i_currentNode).behavior) { diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index cff7b74c9..2de66c486 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "11382" + #define REVISION_NR "11384" #endif // __REVISION_NR_H__