Core/Object: Range check vol. 2

Port From (https://github.com/TrinityCore/TrinityCore/commit/a13a765610d964a3aa1bab1b41331c05e24a1f78)
This commit is contained in:
hondacrx
2021-12-07 13:53:35 -05:00
parent eb8535b7b2
commit 2ded315eaa
7 changed files with 78 additions and 65 deletions
+3 -3
View File
@@ -47,7 +47,7 @@ namespace Game
GameObject go = player.GetMap().GetGameObject(lguid);
// not check distance for GO in case owned GO (fishing bobber case, for example) or Fishing hole GO
if (!go || ((go.GetOwnerGUID() != player.GetGUID() && go.GetGoType() != GameObjectTypes.FishingHole) && !go.IsWithinDistInMap(player, SharedConst.InteractionDistance)))
if (!go || ((go.GetOwnerGUID() != player.GetGUID() && go.GetGoType() != GameObjectTypes.FishingHole) && !go.IsWithinDistInMap(player)))
{
player.SendLootRelease(lguid);
continue;
@@ -129,7 +129,7 @@ namespace Game
GameObject go = player.GetMap().GetGameObject(guid);
// do not check distance for GO if player is the owner of it (ex. fishing bobber)
if (go && ((go.GetOwnerGUID() == player.GetGUID() || go.IsWithinDistInMap(player, SharedConst.InteractionDistance))))
if (go && (go.GetOwnerGUID() == player.GetGUID() || go.IsWithinDistInMap(player)))
loot = go.loot;
break;
@@ -331,7 +331,7 @@ namespace Game
GameObject go = player.GetMap().GetGameObject(lguid);
// not check distance for GO in case owned GO (fishing bobber case, for example) or Fishing hole GO
if (!go || ((go.GetOwnerGUID() != player.GetGUID() && go.GetGoType() != GameObjectTypes.FishingHole) && !go.IsWithinDistInMap(player, SharedConst.InteractionDistance)))
if (!go || ((go.GetOwnerGUID() != player.GetGUID() && go.GetGoType() != GameObjectTypes.FishingHole) && !go.IsWithinDistInMap(player)))
return;
loot = go.loot;
+29 -5
View File
@@ -297,9 +297,36 @@ namespace Game
caster = GetPlayer();
}
TriggerCastFlags triggerFlag = TriggerCastFlags.None;
// client provided targets
SpellCastTargets targets = new(caster, cast.Cast);
// check known spell or raid marker spell (which not requires player to know it)
if (caster.IsTypeId(TypeId.Player) && !caster.ToPlayer().HasActiveSpell(spellInfo.Id) && !spellInfo.HasEffect(SpellEffectName.ChangeRaidMarker) && !spellInfo.HasAttribute(SpellAttr8.RaidMarker))
return;
{
bool allow = false;
// allow casting of unknown spells for special lock cases
GameObject go = targets.GetGOTarget();
if (go != null)
if (go.GetSpellForLock(caster.ToPlayer()) == spellInfo)
allow = true;
// TODO: Preparation for #23204
// allow casting of spells triggered by clientside periodic trigger auras
/*
if (caster->HasAuraTypeWithTriggerSpell(SPELL_AURA_PERIODIC_TRIGGER_SPELL_FROM_CLIENT, spellId))
{
allow = true;
triggerFlag = TRIGGERED_FULL_MASK;
}
*/
if (!allow)
return;
}
// Check possible spell cast overrides
spellInfo = caster.GetCastSpellInfo(spellInfo);
@@ -308,9 +335,6 @@ namespace Game
if (GetPlayer().IsPossessing())
return;
// client provided targets
SpellCastTargets targets = new(caster, cast.Cast);
// Client is resending autoshot cast opcode when other spell is cast during shoot rotation
// Skip it to prevent "interrupt" message
// Also check targets! target may have changed and we need to interrupt current spell
@@ -335,7 +359,7 @@ namespace Game
if (cast.Cast.MoveUpdate.HasValue)
HandleMovementOpcode(ClientOpcodes.MoveStop, cast.Cast.MoveUpdate.Value);
Spell spell = new(caster, spellInfo, TriggerCastFlags.None);
Spell spell = new(caster, spellInfo, triggerFlag);
SpellPrepare spellPrepare = new();
spellPrepare.ClientCastID = cast.Cast.CastID;