Core/Formations: update codestyle and fix crash

Closes #21288
This commit is contained in:
ariel-
2018-01-22 01:54:15 -03:00
parent 4402f71eb7
commit 73cc613dc8
7 changed files with 206 additions and 145 deletions

View File

@@ -1644,7 +1644,7 @@ public:
ObjectGuid::LowType lowguid = creature->GetSpawnId();
if (creature->GetFormation())
{
handler->PSendSysMessage("Selected creature is already member of group %u", creature->GetFormation()->GetId());
handler->PSendSysMessage("Selected creature is already member of group %u", creature->GetFormation()->GetLeaderSpawnId());
return false;
}
@@ -1652,24 +1652,19 @@ public:
return false;
Player* chr = handler->GetSession()->GetPlayer();
FormationInfo* group_member;
group_member = new FormationInfo;
group_member->follow_angle = (creature->GetAngle(chr) - chr->GetOrientation()) * 180 / float(M_PI);
group_member->follow_dist = std::sqrt(std::pow(chr->GetPositionX() - creature->GetPositionX(), 2.f) + std::pow(chr->GetPositionY() - creature->GetPositionY(), 2.f));
group_member->leaderGUID = leaderGUID;
group_member->groupAI = 0;
sFormationMgr->CreatureGroupMap[lowguid] = group_member;
float followAngle = (creature->GetAngle(chr) - chr->GetOrientation()) * 180.0f / float(M_PI);
float followDist = std::sqrt(std::pow(chr->GetPositionX() - creature->GetPositionX(), 2.f) + std::pow(chr->GetPositionY() - creature->GetPositionY(), 2.f));
uint32 groupAI = 0;
sFormationMgr->AddFormationMember(lowguid, followAngle, followDist, leaderGUID, groupAI);
creature->SearchFormation();
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_CREATURE_FORMATION);
stmt->setUInt32(0, leaderGUID);
stmt->setUInt32(1, lowguid);
stmt->setFloat(2, group_member->follow_dist);
stmt->setFloat(3, group_member->follow_angle);
stmt->setUInt32(4, uint32(group_member->groupAI));
stmt->setFloat (2, followAngle);
stmt->setFloat (3, followDist);
stmt->setUInt32(4, groupAI);
WorldDatabase.Execute(stmt);

View File

@@ -252,7 +252,7 @@ struct npc_cameron : public ScriptedAI
_childrenGUIDs.push_back(jose->GetGUID());
// If Formation was disbanded, remake.
if (!me->GetFormation()->isFormed())
if (!me->GetFormation()->IsFormed())
for (auto guid : _childrenGUIDs)
if (Creature* child = ObjectAccessor::GetCreature(*me, guid))
child->SearchFormation();