91 lines
5.0 KiB
C++
91 lines
5.0 KiB
C++
#pragma once
|
|
#include "gateway/auras.hpp"
|
|
#include "gateway/object_updates.hpp"
|
|
#include "gateway/legacy_stream.hpp"
|
|
#include <array>
|
|
#include <bitset>
|
|
#include <map>
|
|
#include <set>
|
|
struct NativeAuraTranslation {
|
|
struct Duration {
|
|
std::optional<uint32_t> remaining_ms;
|
|
uint64_t received_ms=0;
|
|
bool awaiting_field=false;
|
|
};
|
|
struct EquipCandidate {
|
|
uint32_t spell=0;
|
|
gateway::AuraSelfCastContext context;
|
|
bool ambiguous=false;
|
|
};
|
|
// Field-level aura changes on already visible units (not creations), for the built-in boss mods.
|
|
struct Transition {uint64_t unit=0;uint32_t spell=0;uint8_t kind=0;uint32_t stacks=1;}; // kind 0 applied, 1 removed, 2 dose up, 3 dose down
|
|
std::vector<Transition> transitions;
|
|
std::vector<Transition> take_transitions(){auto out=std::move(transitions);transitions.clear();return out;}
|
|
struct Unit {
|
|
std::array<uint32_t,48> spells{};
|
|
std::array<uint32_t,6> flags{};
|
|
std::array<uint32_t,12> levels{},applications{};
|
|
std::bitset<48> dirty,shown;
|
|
bool initial=true;
|
|
uint8_t source_type=0;
|
|
uint32_t mount_display=0;
|
|
uint32_t active_mask(uint32_t spell) const;
|
|
uint16_t presented_realm=0;
|
|
std::optional<EquipCandidate> equip_candidate={};
|
|
std::array<std::optional<gateway::AuraSelfCastContext>,48> self_cast{};
|
|
std::array<std::optional<gateway::Guid128>,48> server_self_cast{};
|
|
// Source caster unit observed from the applying SPELL_GO; reset with the slot.
|
|
std::array<uint64_t,48> caster{};
|
|
// Minted CastID for an aura from another caster (pet, player, NPC): the client starts aura
|
|
// state kits (Sacrifice/PW:S bubbles) only for an aura that names its cast.
|
|
std::array<std::optional<gateway::Guid128>,48> caster_cast{};
|
|
};
|
|
// Source SPELL_GO hits awaiting the aura field: (holder, spell) -> caster unit.
|
|
struct PendingCaster {uint64_t caster=0,expires_ms=0;bool ambiguous=false;};
|
|
std::map<std::pair<uint64_t,uint32_t>,PendingCaster> pending_casters;
|
|
// Modern identity of a SPELL_GO caster, kept for the aura's CastUnit after the caster is destroyed
|
|
// (Sacrifice 7812: the Voidwalker dies with the cast, its absorb aura on the master names it).
|
|
std::map<uint64_t,gateway::Guid128> caster_identity;
|
|
void remember_caster(uint64_t caster,const gateway::Guid128& identity);
|
|
// Every source SPELL_GO: remember which unit's cast hit which targets.
|
|
void observe_go(uint64_t caster,uint32_t spell,const std::vector<uint64_t>& hits,uint64_t now_ms=clock_ms());
|
|
// Holder-is-caster slots (self-only spells, or an observed self GO) get the
|
|
// native self-cast context (CastID+NOCASTER), as native AuraApplication sends.
|
|
// A withheld initial owner must wait for its pending equipment provenance.
|
|
unsigned bind_casters(uint32_t realm,uint32_t map,uint64_t& counter,uint64_t deferred_owner=0);
|
|
struct PendingSelfHit {
|
|
uint64_t unit, expires_ms;
|
|
gateway::Guid128 cast;
|
|
uint32_t realm;
|
|
bool ambiguous;
|
|
};
|
|
// Only reviewed caster-only speed auras, on the selected character.
|
|
std::map<uint32_t,PendingSelfHit> pending_self_hits;
|
|
std::map<uint64_t,Unit> units;
|
|
// Source0x137 is player-local and identifies a slot, not a spell/caster.
|
|
// It may precede the corresponding object field, including initial create.
|
|
std::map<uint64_t,std::array<Duration,48>> durations;
|
|
std::set<uint64_t> dirty;
|
|
uint32_t updates_sent=0,unsupported=0;
|
|
// Called only after a genuine direct self on-equip GO. A candidate is not
|
|
// applied state: the very next source update for that existing player must
|
|
// confirm exactly one fresh matching slot, otherwise correlation expires.
|
|
bool observe_equip_cast(uint64_t,uint32_t,const gateway::Guid128&,const gateway::Guid128&);
|
|
// Login ordering may deliver a genuine self equip GO before presentation
|
|
// of the initial source holder. Caller establishes that exact equip chain;
|
|
// only enrich its one existing slot, before the initial aura flush.
|
|
bool bind_initial_equip_cast(uint64_t,uint32_t,const gateway::Guid128&,const gateway::Guid128&,uint32_t);
|
|
bool bind_server_self_cast(uint64_t,uint32_t,const gateway::Guid128&,uint32_t);
|
|
// Reviewed self-applied source holders (no source cast event) receive the
|
|
// native self-cast presentation identity. Returns the number bound; the
|
|
// caller-owned counter advances once per bound slot. Never creates auras.
|
|
unsigned bind_self_applied(uint64_t,uint32_t realm,uint32_t map,uint64_t& counter);
|
|
void observe_speed_aura_hit(uint64_t unit,uint32_t spell,const gateway::Guid128& cast,uint32_t realm);
|
|
void consume(const std::vector<gateway::LegacyObjectUpdate>&);
|
|
static uint64_t clock_ms();
|
|
void consume_duration(uint64_t,std::span<const uint8_t>,uint64_t now_ms=clock_ms());
|
|
void forget(uint64_t);
|
|
gateway::Bytes snapshot(uint64_t) const;
|
|
std::vector<gateway::LegacyPacket> flush(const std::map<uint64_t,gateway::Guid128>&,uint64_t now_ms=clock_ms());
|
|
};
|