Skip to content

Commit

Permalink
Last fixes for release
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberium committed Jan 3, 2022
1 parent 803a198 commit 3db02e9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 37 deletions.
34 changes: 10 additions & 24 deletions src/game/Maps/SpawnGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ uint32 SpawnGroup::GetEligibleEntry(std::map<uint32, uint32>& existingEntries, s
{
if (existingEntries[explicitly->Entry] > 0)
{
if (roll < explicitly->Chance)
if (roll < static_cast<int>(explicitly->Chance))
return explicitly->Entry;

roll -= int32(explicitly->Chance);
Expand Down Expand Up @@ -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<FormationData>(this);
m_formationData = std::make_shared<FormationData>(this, entry.formationEntry);
else
m_formationData = nullptr;
}
Expand Down Expand Up @@ -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)
{
Expand All @@ -351,21 +351,7 @@ FormationData::FormationData(CreatureGroup* gData, FormationEntrySPtr fEntry /*=
m_realMasterDBGuid = sData.DbGuid;
}

if (fEntry)
{
m_fEntry = fEntry;
m_masterMotionType = static_cast<MovementGeneratorType>(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<MovementGeneratorType>(cData->movementType);
else
m_masterMotionType = IDLE_MOTION_TYPE;
}
m_masterMotionType = static_cast<MovementGeneratorType>(fEntry->MovementType);

// provided slot id should be ordered with no gap!
m_slotGuid = m_slotsMap.size();
Expand All @@ -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()
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/game/Maps/SpawnGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class FormationSlotData
class FormationData
{
public:
FormationData(CreatureGroup* gData, FormationEntrySPtr fEntry = nullptr);
FormationData(CreatureGroup* gData, FormationEntrySPtr fEntry);
FormationData() = delete;
~FormationData();

Expand Down
6 changes: 3 additions & 3 deletions src/game/MotionGenerators/TargetedMovementGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand All @@ -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
Expand Down
18 changes: 9 additions & 9 deletions src/game/MotionGenerators/WaypointManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<uint32> blacklistWaypoints;
Expand All @@ -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];
Expand All @@ -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;
Expand Down

0 comments on commit 3db02e9

Please sign in to comment.