"""Exercise shared Wintergrasp mount permission with actual manager method.""" from pathlib import Path import subprocess,tempfile root=Path(__file__).resolve().parents[2] s=(root/"src/server/game/Battlefield/BattlefieldMgr.cpp").read_text() a=s.index("bool BattlefieldMgr::IsWintergraspFlightAllowed(") b=s.index("\nvoid BattlefieldMgr::UpdateWintergraspFlight",a) code=r''' #include #include #include #include using uint32=unsigned; struct DBCManager{static bool IsInArea(unsigned a,unsigned z){return a==z||(z==4197&&a==4538);}}; struct Map{unsigned id=571;unsigned GetId()const{return id;}}; struct Battlefield{bool enabled=true,war=false;unsigned zone=4197;unsigned GetZoneId()const{return zone;}bool IsEnabled()const{return enabled;}bool CanFlyIn()const{return !war;}}; struct BattlefieldMgr{std::map>> _battlefieldsByMap;bool IsWintergraspFlightAllowed(uint32,uint32)const;}; '''+s[a:b]+r''' int main(){BattlefieldMgr m;Map map;assert(m.IsWintergraspFlightAllowed(571,4197));assert(m.IsWintergraspFlightAllowed(571,4538));assert(!m.IsWintergraspFlightAllowed(0,4197));assert(!m.IsWintergraspFlightAllowed(571,210));auto bf=std::make_unique();auto p=bf.get();m._battlefieldsByMap[&map].push_back(std::move(bf));assert(m.IsWintergraspFlightAllowed(571,4538));p->war=true;assert(!m.IsWintergraspFlightAllowed(571,4197));assert(!m.IsWintergraspFlightAllowed(571,4538));p->enabled=false;assert(m.IsWintergraspFlightAllowed(571,4538));p->enabled=true;p->war=false;assert(m.IsWintergraspFlightAllowed(571,4197));} ''' with tempfile.TemporaryDirectory(prefix="vcore-wg-flight-") as d: p=Path(d);(p/"test.cpp").write_text(code) subprocess.run(["c++","-std=c++17",str(p/"test.cpp"),"-o",str(p/"test")],check=True) subprocess.run([str(p/"test")],check=True) print("WG main/subarea: absent, disabled, peace, war, end and unrelated areas PASS")