Skip to content

Commit ec970dc

Browse files
author
Github Actions
committed
Merge 3.3.5 to 3.3.5-lfgsolo
2 parents 748b4ee + cab8975 commit ec970dc

File tree

7 files changed

+87
-45
lines changed

7 files changed

+87
-45
lines changed

src/server/game/Handlers/MovementHandler.cpp

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -530,16 +530,7 @@ void WorldSession::HandleForceSpeedChangeAck(WorldPacket &recvData)
530530
}
531531

532532
/* the client data has been verified. let's do the actual change now */
533-
int64 movementTime = (int64)movementInfo.time + _timeSyncClockDelta;
534-
if (_timeSyncClockDelta == 0 || movementTime < 0 || movementTime > 0xFFFFFFFF)
535-
{
536-
TC_LOG_WARN("misc", "The computed movement time using clockDelta is erronous. Using fallback instead");
537-
movementInfo.time = GameTime::GetGameTimeMS();
538-
}
539-
else
540-
{
541-
movementInfo.time = (uint32)movementTime;
542-
}
533+
movementInfo.time = AdjustClientMovementTime(movementInfo.time);
543534

544535
mover->m_movementInfo = movementInfo;
545536
mover->UpdatePosition(movementInfo.pos);
@@ -630,17 +621,7 @@ void WorldSession::HandleMoveKnockBackAck(WorldPacket& recvData)
630621
MovementInfo movementInfo;
631622
movementInfo.guid = guid;
632623
ReadMovementInfo(recvData, &movementInfo);
633-
634-
int64 movementTime = (int64)movementInfo.time + _timeSyncClockDelta;
635-
if (_timeSyncClockDelta == 0 || movementTime < 0 || movementTime > 0xFFFFFFFF)
636-
{
637-
TC_LOG_WARN("misc", "The computed movement time using clockDelta is erronous. Using fallback instead");
638-
movementInfo.time = GameTime::GetGameTimeMS();
639-
}
640-
else
641-
{
642-
movementInfo.time = (uint32)movementTime;
643-
}
624+
movementInfo.time = AdjustClientMovementTime(movementInfo.time);
644625

645626
mover->m_movementInfo = movementInfo;
646627
mover->UpdatePosition(movementInfo.pos);

src/server/game/Spells/Spell.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2362,6 +2362,30 @@ void Spell::AddDestTarget(SpellDestination const& dest, uint32 effIndex)
23622362
m_destTargets[effIndex] = dest;
23632363
}
23642364

2365+
int64 Spell::GetUnitTargetCountForEffect(SpellEffIndex effect) const
2366+
{
2367+
return std::count_if(m_UniqueTargetInfo.begin(), m_UniqueTargetInfo.end(), [effect](TargetInfo const& targetInfo)
2368+
{
2369+
return targetInfo.EffectMask & (1 << effect);
2370+
});
2371+
}
2372+
2373+
int64 Spell::GetGameObjectTargetCountForEffect(SpellEffIndex effect) const
2374+
{
2375+
return std::count_if(m_UniqueGOTargetInfo.begin(), m_UniqueGOTargetInfo.end(), [effect](GOTargetInfo const& targetInfo)
2376+
{
2377+
return targetInfo.EffectMask & (1 << effect);
2378+
});
2379+
}
2380+
2381+
int64 Spell::GetItemTargetCountForEffect(SpellEffIndex effect) const
2382+
{
2383+
return std::count_if(m_UniqueItemInfo.begin(), m_UniqueItemInfo.end(), [effect](ItemTargetInfo const& targetInfo)
2384+
{
2385+
return targetInfo.EffectMask & (1 << effect);
2386+
});
2387+
}
2388+
23652389
void Spell::TargetInfo::PreprocessTarget(Spell* spell)
23662390
{
23672391
Unit* unit = spell->m_caster->GetGUID() == TargetGUID ? spell->m_caster->ToUnit() : ObjectAccessor::GetUnit(*spell->m_caster, TargetGUID);
@@ -7784,7 +7808,7 @@ void Spell::DoEffectOnLaunchTarget(TargetInfo& targetInfo, float multiplier, Spe
77847808
if (m_originalCaster->GetTypeId() == TYPEID_PLAYER)
77857809
{
77867810
// cap damage of player AOE
7787-
uint32 targetAmount = m_UniqueTargetInfo.size();
7811+
int64 targetAmount = GetUnitTargetCountForEffect(spellEffectInfo.EffectIndex);
77887812
if (targetAmount > 10)
77897813
m_damage = m_damage * 10 / targetAmount;
77907814
}

src/server/game/Spells/Spell.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,10 @@ class TC_GAME_API Spell
466466

467467
void CallScriptOnResistAbsorbCalculateHandlers(DamageInfo const& damageInfo, uint32& resistAmount, int32& absorbAmount);
468468

469+
int64 GetUnitTargetCountForEffect(SpellEffIndex effect) const;
470+
int64 GetGameObjectTargetCountForEffect(SpellEffIndex effect) const;
471+
int64 GetItemTargetCountForEffect(SpellEffIndex effect) const;
472+
469473
protected:
470474
bool HasGlobalCooldown() const;
471475
void TriggerGlobalCooldown();

src/server/game/Spells/SpellEffects.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -332,18 +332,8 @@ void Spell::EffectSchoolDMG()
332332
// Meteor like spells (divided damage to targets)
333333
if (m_spellInfo->HasAttribute(SPELL_ATTR0_CU_SHARE_DAMAGE))
334334
{
335-
uint32 count = 0;
336-
for (auto ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
337-
{
338-
if (ihit->MissCondition != SPELL_MISS_NONE)
339-
continue;
340-
341-
if (ihit->EffectMask & (1 << effectInfo->EffectIndex))
342-
++count;
343-
}
344-
345335
// divide to all targets
346-
if (count)
336+
if (int64 count = GetUnitTargetCountForEffect(SpellEffIndex(effectInfo->EffectIndex)))
347337
damage /= count;
348338
}
349339

src/server/game/Spells/SpellScript.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,14 @@ bool SpellScript::IsInCheckCastHook() const
408408
{
409409
return m_currentScriptState == SPELL_SCRIPT_HOOK_CHECK_CAST;
410410
}
411+
412+
bool SpellScript::IsAfterTargetSelectionPhase() const
413+
{
414+
return IsInHitPhase()
415+
|| m_currentScriptState == SPELL_SCRIPT_HOOK_ON_CAST
416+
|| m_currentScriptState == SPELL_SCRIPT_HOOK_AFTER_CAST;
417+
}
418+
411419
bool SpellScript::IsInTargetHook() const
412420
{
413421
switch (m_currentScriptState)
@@ -509,6 +517,39 @@ Item* SpellScript::GetExplTargetItem() const
509517
return m_spell->m_targets.GetItemTarget();
510518
}
511519

520+
int64 SpellScript::GetUnitTargetCountForEffect(SpellEffIndex effect) const
521+
{
522+
if (!IsAfterTargetSelectionPhase())
523+
{
524+
TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u`: function SpellScript::GetUnitTargetCountForEffect was called, but function has no effect in current hook! (spell has not selected targets yet)",
525+
m_scriptName->c_str(), m_scriptSpellId);
526+
return 0;
527+
}
528+
return m_spell->GetUnitTargetCountForEffect(effect);
529+
}
530+
531+
int64 SpellScript::GetGameObjectTargetCountForEffect(SpellEffIndex effect) const
532+
{
533+
if (!IsAfterTargetSelectionPhase())
534+
{
535+
TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u`: function SpellScript::GetGameObjectTargetCountForEffect was called, but function has no effect in current hook! (spell has not selected targets yet)",
536+
m_scriptName->c_str(), m_scriptSpellId);
537+
return 0;
538+
}
539+
return m_spell->GetGameObjectTargetCountForEffect(effect);
540+
}
541+
542+
int64 SpellScript::GetItemTargetCountForEffect(SpellEffIndex effect) const
543+
{
544+
if (!IsAfterTargetSelectionPhase())
545+
{
546+
TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u`: function SpellScript::GetItemTargetCountForEffect was called, but function has no effect in current hook! (spell has not selected targets yet)",
547+
m_scriptName->c_str(), m_scriptSpellId);
548+
return 0;
549+
}
550+
return m_spell->GetItemTargetCountForEffect(effect);
551+
}
552+
512553
Unit* SpellScript::GetHitUnit() const
513554
{
514555
if (!IsInTargetHook())

src/server/game/Spells/SpellScript.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,6 @@ enum SpellScriptHookType
194194

195195
#define HOOK_SPELL_HIT_START SPELL_SCRIPT_HOOK_EFFECT_HIT
196196
#define HOOK_SPELL_HIT_END SPELL_SCRIPT_HOOK_AFTER_HIT + 1
197-
#define HOOK_SPELL_START SPELL_SCRIPT_HOOK_EFFECT
198-
#define HOOK_SPELL_END SPELL_SCRIPT_HOOK_CHECK_CAST + 1
199-
#define HOOK_SPELL_COUNT HOOK_SPELL_END - HOOK_SPELL_START
200197

201198
class TC_GAME_API SpellScript : public _SpellScript
202199
{
@@ -343,6 +340,7 @@ class TC_GAME_API SpellScript : public _SpellScript
343340
void _PrepareScriptCall(SpellScriptHookType hookType);
344341
void _FinishScriptCall();
345342
bool IsInCheckCastHook() const;
343+
bool IsAfterTargetSelectionPhase() const;
346344
bool IsInTargetHook() const;
347345
bool IsInModifiableHook() const;
348346
bool IsInHitPhase() const;
@@ -469,6 +467,11 @@ class TC_GAME_API SpellScript : public _SpellScript
469467
// returns: Item which was selected as an explicit spell target or NULL if there's no target
470468
Item* GetExplTargetItem() const;
471469

470+
// methods usable only after spell targets have been fully selected
471+
int64 GetUnitTargetCountForEffect(SpellEffIndex effect) const;
472+
int64 GetGameObjectTargetCountForEffect(SpellEffIndex effect) const;
473+
int64 GetItemTargetCountForEffect(SpellEffIndex effect) const;
474+
472475
// methods useable only during spell hit on target, or during spell launch on target:
473476
// returns: target of current effect if it was Unit otherwise NULL
474477
Unit* GetHitUnit() const;

src/server/scripts/EasternKingdoms/zone_eversong_woods.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,25 @@ enum Partygoer_Pather
2626
EVENT_RANDOM_ACTION_PATHER,
2727
EVENT_REMOVE_EQUIPMENT_PATHER,
2828
EVENT_STOP_DANCING_PATHER,
29-
30-
PATH_FIRST_PATH = 4755520,
31-
PATH_LAST_PATH = 4755552,
3229
};
3330

31+
static constexpr std::array<uint32, 5> PARTYGOER_PATHS = { 4755520, 4755528, 4755536, 4755544, 4755552 };
32+
3433
struct npc_partygoer_pather : public ScriptedAI
3534
{
36-
npc_partygoer_pather(Creature* creature) : ScriptedAI(creature), _path(PATH_FIRST_PATH) { }
35+
npc_partygoer_pather(Creature* creature) : ScriptedAI(creature), _path(PARTYGOER_PATHS.begin()) { }
3736

3837
void JustAppeared() override
3938
{
40-
_path = PATH_FIRST_PATH;
39+
_path = PARTYGOER_PATHS.begin();
4140
_events.ScheduleEvent(EVENT_RANDOM_ACTION_PATHER, 11s, 14s);
4241
}
4342

4443
void WaypointPathEnded(uint32 /*nodeId*/, uint32 /*pathId*/) override
4544
{
4645
++_path;
47-
if (_path > PATH_LAST_PATH)
48-
_path = PATH_FIRST_PATH;
46+
if (_path == PARTYGOER_PATHS.end())
47+
_path = PARTYGOER_PATHS.begin();
4948

5049
_events.ScheduleEvent(EVENT_RANDOM_ACTION_PATHER, 11s, 14s);
5150
}
@@ -59,7 +58,7 @@ struct npc_partygoer_pather : public ScriptedAI
5958
switch (eventId)
6059
{
6160
case EVENT_PATH:
62-
me->GetMotionMaster()->MovePath(_path, false);
61+
me->GetMotionMaster()->MovePath(*_path, false);
6362
break;
6463
case EVENT_RANDOM_ACTION_PATHER:
6564
{
@@ -110,7 +109,7 @@ struct npc_partygoer_pather : public ScriptedAI
110109

111110
private:
112111
EventMap _events;
113-
uint32 _path;
112+
std::array<uint32, 5>::const_iterator _path;
114113
};
115114

116115
enum Partygoer

0 commit comments

Comments
 (0)