Core/Entities: Phase Rework (main commit)
This commit is contained in:
1 parent
4a268b3fd3
commit
e44bb5f387
79 files changed
+1738
-851
No files matched your search
@@ -27,6 +27,7 @@ EndScriptData */
|
||||
#include "ObjectMgr.h"
|
||||
#include "Opcodes.h"
|
||||
#include "Pet.h"
|
||||
#include "PhasingHandler.h"
|
||||
#include "Player.h"
|
||||
#include "ReputationMgr.h"
|
||||
#include "ScriptMgr.h"
|
||||
@@ -828,9 +829,18 @@ public:
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
uint32 phaseId = uint32(atoul(args));
|
||||
char* phaseText = strtok((char*)args, " ");
|
||||
if (!phaseText)
|
||||
return false;
|
||||
|
||||
if (!sPhaseStore.LookupEntry(phaseId))
|
||||
uint32 phaseId = uint32(strtoul(phaseText, nullptr, 10));
|
||||
uint32 visibleMapId = 0;
|
||||
|
||||
char* visibleMapIdText = strtok(nullptr, " ");
|
||||
if (visibleMapIdText)
|
||||
visibleMapId = uint32(strtoul(visibleMapIdText, nullptr, 10));
|
||||
|
||||
if (phaseId && !sPhaseStore.LookupEntry(phaseId))
|
||||
{
|
||||
handler->SendSysMessage(LANG_PHASE_NOTFOUND);
|
||||
handler->SetSentErrorMessage(true);
|
||||
@@ -838,13 +848,29 @@ public:
|
||||
}
|
||||
|
||||
Unit* target = handler->getSelectedUnit();
|
||||
if (!target)
|
||||
target = handler->GetSession()->GetPlayer();
|
||||
if (visibleMapId)
|
||||
{
|
||||
MapEntry const* visibleMap = sMapStore.LookupEntry(visibleMapId);
|
||||
if (!visibleMap || visibleMap->rootPhaseMap != int32(target->GetMapId()))
|
||||
{
|
||||
handler->SendSysMessage(LANG_PHASE_NOTFOUND);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
target->SetInPhase(phaseId, true, !target->IsInPhase(phaseId));
|
||||
if (!target->GetPhaseShift().HasVisibleMapId(visibleMapId))
|
||||
PhasingHandler::AddVisibleMapId(target, visibleMapId);
|
||||
else
|
||||
PhasingHandler::RemoveVisibleMapId(target, visibleMapId);
|
||||
}
|
||||
|
||||
if (target->GetTypeId() == TYPEID_PLAYER)
|
||||
target->ToPlayer()->SendUpdatePhasing();
|
||||
if (phaseId)
|
||||
{
|
||||
if (!target->GetPhaseShift().HasPhase(phaseId))
|
||||
PhasingHandler::AddPhase(target, phaseId, true);
|
||||
else
|
||||
PhasingHandler::RemovePhase(target, phaseId, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user