46 lines
3.2 KiB
C++
46 lines
3.2 KiB
C++
#include "aura_translation.hpp"
|
|
#include "gateway/aura_definition_profile.hpp"
|
|
#include "gateway/roster_translation.hpp"
|
|
#include "gateway/turtle_entity_profile.hpp"
|
|
#include <iostream>
|
|
#include <utility>
|
|
using namespace gateway;
|
|
namespace F=gateway::turtle_entity_fields;
|
|
static void check(bool ok,const char* message){if(!ok)throw Error(message);}
|
|
int main(){try{
|
|
const uint64_t creature=0xf130000001000001ULL;
|
|
const auto target=forever_creature_guid(creature,1,70,1);
|
|
// Thunder Clap's native and source aura types differ, but both holders use effect index 1.
|
|
constexpr std::pair<uint32_t,uint32_t> harmful_holders[] = {
|
|
{1715,2}, {7372,2}, {7373,2}, {12809,1}, {20549,1}, {11581,2}
|
|
};
|
|
for(const auto& [spell,mask] : harmful_holders){
|
|
check(aura_definition_profile::mask(spell)==mask,"staged source index not preserved");
|
|
NativeAuraTranslation state;LegacyObjectUpdate create;create.kind=2;create.type=3;create.guid=creature;
|
|
create.fields={{F::UNIT_FIELD_AURA+32,spell},{F::UNIT_FIELD_AURAFLAGS+4,8},{F::UNIT_FIELD_AURALEVELS+8,60}};
|
|
state.consume({create});auto output=state.flush({{creature,target}});
|
|
check(output.size()==1 && output[0].opcode==0x690011,"source harmful holder not queued");
|
|
check(output[0].body==forever_aura_update({target,true,{{32,AuraSlotData{spell,mask,16,60,1}}}}),"source harmful holder serialization differs");
|
|
check(state.units.at(creature).shown[32],"source harmful holder not marked presented");
|
|
LegacyObjectUpdate clear;clear.guid=creature;clear.fields={{F::UNIT_FIELD_AURA+32,0}};
|
|
state.consume({clear});output=state.flush({{creature,target}});
|
|
check(output.size()==1 && output[0].body==forever_aura_update({target,false,{{32,std::nullopt}}}),"source removal not queued");
|
|
}
|
|
const auto player=forever_player_guid(4509,70);NativeAuraTranslation state;
|
|
LegacyObjectUpdate create;create.kind=2;create.type=4;create.guid=4509;
|
|
create.fields={{F::UNIT_FIELD_AURA,20007},{F::UNIT_FIELD_AURAFLAGS,5},{F::UNIT_FIELD_AURALEVELS,60}};
|
|
state.consume({create});auto output=state.flush({{4509,player}});
|
|
check(output.size()==1 && output[0].body==forever_aura_update({player,true,{{0,AuraSlotData{20007,1,2,60,1}}}}),"genuine Crusader holder not translated");
|
|
check(!state.units.at(4509).self_cast[0],"unobserved Crusader cast context fabricated");
|
|
// Plainsrunning installs auras at indexes 0 and 1. Spell 379 has mismatched
|
|
// native/source aura indexes and must remain absent even with a source holder.
|
|
LegacyObjectUpdate change;change.guid=4509;
|
|
change.fields={{F::UNIT_FIELD_AURA,12566},{F::UNIT_FIELD_AURA+1,379},
|
|
{F::UNIT_FIELD_AURAFLAGS,0x55},{F::UNIT_FIELD_AURALEVELS,0x3c3c}};
|
|
state.consume({change});output=state.flush({{4509,player}});
|
|
check(output.size()==1 && output[0].body==forever_aura_update({player,false,{{0,AuraSlotData{12566,3,2,60,1}}}}),
|
|
"Plainsrunning holder or mismatched-index exclusion differs");
|
|
check(!state.units.at(4509).shown[1],"mismatched-index holder presented");
|
|
std::cout<<"Aura companion holders, effect-index masks and removals PASS.\n";
|
|
}catch(const std::exception& error){std::cerr<<error.what()<<'\n';return 1;}}
|