diff --git a/src/game/Maps/SpawnGroup.cpp b/src/game/Maps/SpawnGroup.cpp index 9cc8c96ee7..ed144da6d3 100644 --- a/src/game/Maps/SpawnGroup.cpp +++ b/src/game/Maps/SpawnGroup.cpp @@ -76,7 +76,7 @@ uint32 SpawnGroup::GetEligibleEntry(std::map& existingEntries, s { if (existingEntries[explicitly->Entry] > 0) { - if (roll < explicitly->Chance) + if (roll < static_cast(explicitly->Chance)) return explicitly->Entry; roll -= int32(explicitly->Chance); @@ -224,7 +224,7 @@ std::string SpawnGroup::to_string() const CreatureGroup::CreatureGroup(SpawnGroupEntry const& entry, Map& map) : SpawnGroup(entry, map, uint32(TYPEID_UNIT)) { if (entry.formationEntry) - m_formationData = std::make_shared(this); + m_formationData = std::make_shared(this, entry.formationEntry); else m_formationData = nullptr; } @@ -339,8 +339,8 @@ void GameObjectGroup::RemoveObject(WorldObject* wo) // Formation code // //////////////////// -FormationData::FormationData(CreatureGroup* gData, FormationEntrySPtr fEntry /*= nullptr*/) : - m_groupData(gData), m_mirrorState(false), m_lastWP(0), m_wpPathId(0) +FormationData::FormationData(CreatureGroup* gData, FormationEntrySPtr fEntry) : + m_groupData(gData), m_fEntry(fEntry), m_mirrorState(false), m_lastWP(0), m_wpPathId(0) { for (auto const& sData : m_groupData->GetGroupEntry().DbGuids) { @@ -351,21 +351,7 @@ FormationData::FormationData(CreatureGroup* gData, FormationEntrySPtr fEntry /*= m_realMasterDBGuid = sData.DbGuid; } - if (fEntry) - { - m_fEntry = fEntry; - m_masterMotionType = static_cast(fEntry->MovementType); - } - else - { - m_fEntry = m_groupData->GetFormationEntry(); - // temp hack until movetype is set correctly - auto cData = sObjectMgr.GetCreatureData(m_realMasterDBGuid); - if (cData) - m_masterMotionType = static_cast(cData->movementType); - else - m_masterMotionType = IDLE_MOTION_TYPE; - } + m_masterMotionType = static_cast(fEntry->MovementType); // provided slot id should be ordered with no gap! m_slotGuid = m_slotsMap.size(); @@ -378,7 +364,7 @@ FormationData::FormationData(CreatureGroup* gData, FormationEntrySPtr fEntry /*= FormationData::~FormationData() { - sLog.outDebug("Deleting formation (%u)!!!!!", m_groupData->GetGroupEntry().Id); + //sLog.outDebug("Deleting formation (%u)!!!!!", m_groupData->GetGroupEntry().Id); } bool FormationData::SetFollowersMaster() @@ -419,7 +405,7 @@ bool FormationData::SetFollowersMaster() } } - sLog.outString("FormationData::SetFollowersMaste> called for groupId(%u)", m_groupData->GetGroupEntry().Id); + //sLog.outDebug("FormationData::SetFollowersMaste> called for groupId(%u)", m_groupData->GetGroupEntry().Id); return false; } @@ -639,7 +625,7 @@ void FormationData::OnDeath(Creature* creature) auto slot = creature->GetFormationSlot(); if(!slot) return; - sLog.outString("Deleting %s from formation(%u)", creature->GetGuidStr().c_str(), m_groupData->GetGroupEntry().Id); + //sLog.outString("Deleting %s from formation(%u)", creature->GetGuidStr().c_str(), m_groupData->GetGroupEntry().Id); bool formationMaster = false; if (slot->IsFormationMaster()) @@ -771,7 +757,7 @@ bool FormationData::AddInFormationSlot(Unit* newUnit, SpawnGroupFormationSlotTyp slot->SetOwner(newUnit); newUnit->SetFormationSlot(slot); - sLog.outString("Slot(%u) filled by %s in formation(%u)", slot->GetSlotId(), newUnit->GetGuidStr().c_str(), m_groupData->GetGroupEntry().Id); + //sLog.outString("Slot(%u) filled by %s in formation(%u)", slot->GetSlotId(), newUnit->GetGuidStr().c_str(), m_groupData->GetGroupEntry().Id); return true; } @@ -983,7 +969,7 @@ FormationSlotDataSPtr FormationData::SetFormationSlot(Creature* creature, SpawnG return nullptr; // set the creature as active to avoid some problem - creature->SetActiveObjectState(true); + //creature->SetActiveObjectState(true); // maybe not needed? auto slot = creature->GetFormationSlot(); if (!m_realMasterDBGuid) diff --git a/src/game/Maps/SpawnGroup.h b/src/game/Maps/SpawnGroup.h index c19f31b936..df9476e8ae 100644 --- a/src/game/Maps/SpawnGroup.h +++ b/src/game/Maps/SpawnGroup.h @@ -151,7 +151,7 @@ class FormationSlotData class FormationData { public: - FormationData(CreatureGroup* gData, FormationEntrySPtr fEntry = nullptr); + FormationData(CreatureGroup* gData, FormationEntrySPtr fEntry); FormationData() = delete; ~FormationData(); diff --git a/src/game/MotionGenerators/TargetedMovementGenerator.cpp b/src/game/MotionGenerators/TargetedMovementGenerator.cpp index 3bf00c46f8..ae6b182735 100644 --- a/src/game/MotionGenerators/TargetedMovementGenerator.cpp +++ b/src/game/MotionGenerators/TargetedMovementGenerator.cpp @@ -1253,7 +1253,7 @@ float FormationMovementGenerator::BuildPath(Unit& owner, PointsArray& path) // clamp the speed to some limit speed = std::max(0.5f, speed); - speed = std::min(10.0f, speed); + speed = std::min(masterSpeed * 2, speed); } } return speed; @@ -1272,7 +1272,7 @@ bool FormationMovementGenerator::HandleMasterDistanceCheck(Unit& owner, const ui owner.NearTeleportTo(mPos.x, mPos.y, mPos.z, mPos.o); m_slot->GetRecomputePosition() = true; - sLog.outString("BIG TELEPORT TO MASTER!!"); + //sLog.outString("BIG TELEPORT TO MASTER!!"); return true; } else if (distToMaster > 20) @@ -1289,7 +1289,7 @@ bool FormationMovementGenerator::HandleMasterDistanceCheck(Unit& owner, const ui i_recheckDistance.Reset(init.Launch() / 2); m_headingToMaster = true; - sLog.outString("MOVE BACK FOLLOWER TO MASTER!!"); + //sLog.outString("MOVE BACK FOLLOWER TO MASTER!!"); return true; } else diff --git a/src/game/MotionGenerators/WaypointManager.cpp b/src/game/MotionGenerators/WaypointManager.cpp index 70ea580c67..737d34a7d5 100644 --- a/src/game/MotionGenerators/WaypointManager.cpp +++ b/src/game/MotionGenerators/WaypointManager.cpp @@ -383,16 +383,16 @@ void WaypointManager::Load() } // ///////////////////////////////////////////////////// - // movement_template + // waypoint_path // ///////////////////////////////////////////////////// - result = WorldDatabase.Query("SELECT entry, COUNT(point) FROM movement_template GROUP BY entry"); + result = WorldDatabase.Query("SELECT entry, COUNT(point) FROM waypoint_path GROUP BY entry"); if (!result) { BarGoLink bar(1); bar.step(); - sLog.outString(">> Loaded 0 path templates. DB table `movement_template` is empty."); + sLog.outString(">> Loaded 0 path templates. DB table `waypoint_path` is empty."); sLog.outString(); } else @@ -413,7 +413,7 @@ void WaypointManager::Load() delete result; // 0 1 2 3 4 5 6 7 - result = WorldDatabase.Query("SELECT entry, pathId, point, position_x, position_y, position_z, orientation, waittime, script_id FROM movement_template"); + result = WorldDatabase.Query("SELECT entry, pathId, point, position_x, position_y, position_z, orientation, waittime, script_id FROM waypoint_path"); BarGoLink bar(result->GetRowCount()); std::set blacklistWaypoints; @@ -430,7 +430,7 @@ void WaypointManager::Load() if (point == 0) { blacklistWaypoints.insert((entry << 8) + pathId); - sLog.outErrorDb("Table `movement_template` has invalid point 0 for entry %u in path %u. Skipping.`", entry, pathId); + sLog.outErrorDb("Table `waypoint_path` has invalid point 0 for entry %u in path %u. Skipping.`", entry, pathId); } WaypointPath& path = m_pathMovementTemplateMap[(entry << 8) + pathId]; @@ -446,20 +446,20 @@ void WaypointManager::Load() // prevent using invalid coordinates if (!MaNGOS::IsValidMapCoord(node.x, node.y, node.z, node.orientation)) { - sLog.outErrorDb("Table movement_template for entry %u (point %u) are using invalid coordinates position_x: %f, position_y: %f)", + sLog.outErrorDb("Table waypoint_path for entry %u (point %u) are using invalid coordinates position_x: %f, position_y: %f)", entry, point, node.x, node.y); MaNGOS::NormalizeMapCoord(node.x); MaNGOS::NormalizeMapCoord(node.y); - sLog.outErrorDb("Table movement_template for entry %u (point %u) are auto corrected to normalized position_x=%f, position_y=%f", + sLog.outErrorDb("Table waypoint_path for entry %u (point %u) are auto corrected to normalized position_x=%f, position_y=%f", entry, point, node.x, node.y); - WorldDatabase.PExecute("UPDATE movement_template SET position_x = '%f', position_y = '%f' WHERE entry = %u AND point = %u AND pathId = %u", node.x, node.y, entry, point, pathId); + WorldDatabase.PExecute("UPDATE waypoint_path SET position_x = '%f', position_y = '%f' WHERE entry = %u AND point = %u AND pathId = %u", node.x, node.y, entry, point, pathId); } if (node.script_id) - CheckDbscript(node, entry, point, movementScriptSet, "movement_template"); + CheckDbscript(node, entry, point, movementScriptSet, "waypoint_path"); } while (result->NextRow()); delete result;