"""Compile the real destination eligibility method with native-level fixtures.""" from pathlib import Path import subprocess,tempfile root=Path(__file__).resolve().parents[2] s=(root/'src/server/game/World/AdventureLocationMgr.cpp').read_text() a=s.index('bool AdventureLocationMgr::LevelEligible(');b=s.index('\nbool AdventureLocationMgr::IsWorkstation',a) code=r''' #include "AdventureGroupPolicy.h" #include #include #include using uint64=unsigned long long; struct Player{unsigned level=60;unsigned getLevel()const{return level;}}; struct AdventureLocation{unsigned InstanceMap=0,AreaId=0,ZoneId=0,InstanceDifficulty=0;}; struct Area{bool KnownLevel=true;unsigned MinLevel=1;}; struct Areas{auto Area(unsigned id)->::Area{return {id!=0,id==3483?58:id};}}areas;auto sAdventureAreaMgr=&areas; struct AdventureLocationMgr{ struct Band{unsigned Min,Max;};std::unordered_map_instanceBands{{533ull<<8,{80,80}},{36ull<<8,{15,21}},{(36ull<<8)|1,{85,85}},{33ull<<8,{16,26}},{(33ull<<8)|1,{85,85}},{34ull<<8,{20,30}}}; bool LevelEligible(Player const*,AdventureLocation const&,std::string const&,bool strictArea=false)const; }; '''+s[a:b]+r''' int main(){ AdventureLocationMgr mgr;Player p;AdventureLocation naxx{533,0,0}; assert(!mgr.LevelEligible(&p,naxx,"raid"));p.level=79;assert(!mgr.LevelEligible(&p,naxx,"raid")); p.level=80;assert(mgr.LevelEligible(&p,naxx,"raid")); AdventureLocation deadmines{36,0,0};p.level=14;assert(!mgr.LevelEligible(&p,deadmines,"instance")); p.level=15;assert(mgr.LevelEligible(&p,deadmines,"instance")); p.level=26;assert(mgr.LevelEligible(&p,deadmines,"instance"));p.level=27;assert(!mgr.LevelEligible(&p,deadmines,"instance")); AdventureLocation stockade{34};for(auto level:{49,57,85}){p.level=level;assert(!mgr.LevelEligible(&p,stockade,"instance"));} for(unsigned map:{33,36}){AdventureLocation normal{map},heroic{map,0,0,1};p.level=85; assert(!mgr.LevelEligible(&p,normal,"instance"));assert(mgr.LevelEligible(&p,heroic,"instance")); p.level=84;assert(!mgr.LevelEligible(&p,heroic,"instance"));} p.level=85;assert(mgr.LevelEligible(&p,naxx,"raid")); AdventureLocation unknown{999,0,0};assert(!mgr.LevelEligible(&p,unknown,"raid")); AdventureLocation zone{0,60,60};p.level=59; assert(mgr.LevelEligible(&p,zone,"adventure")); // own area policy retains its separate tolerance assert(!mgr.LevelEligible(&p,zone,"adventure",true)); p.level=60;assert(mgr.LevelEligible(&p,zone,"adventure",true)); AdventureLocation worldPvp{0,3483,3483};p.level=57; assert(!mgr.LevelEligible(&p,worldPvp,"pvp"));p.level=58; assert(mgr.LevelEligible(&p,worldPvp,"pvp")); assert(!mgr.LevelEligible(nullptr,zone,"adventure",true)); } ''' with tempfile.TemporaryDirectory()as d: p=Path(d);(p/'test.cpp').write_text(code) subprocess.run(['c++','-std=c++17','-I'+str(root/'src/server/game/World'),str(p/'test.cpp'),'-o',str(p/'test')],check=True) subprocess.run([str(p/'test')],check=True) print('Native dungeon/raid minimum levels, unknown destinations and strict adventure invitation levels passed')