27 lines
1.7 KiB
Python
27 lines
1.7 KiB
Python
"""Run the actual logout eligibility gate, without a live server."""
|
|
from pathlib import Path
|
|
import subprocess,tempfile
|
|
root=Path(__file__).resolve().parents[2];s=(root/'src/server/scripts/Custom/viano_bot_commands.cpp').read_text()
|
|
a=s.index('bool Ready(Player const* player)',s.index('std::unordered_map<uint32,bool> Pending;'));b=s.index('\nbool Command(',a)
|
|
code=r'''
|
|
#include <cassert>
|
|
#include <initializer_list>
|
|
constexpr int UNIT_STATE_CASTING=1;
|
|
struct Player{bool world=true,alive=true,combat=false,transport=false,taxi=false,flying=false,falling=false,teleport=false,casting=false,spline=false;
|
|
bool IsInWorld()const{return world;}bool IsAlive()const{return alive;}bool IsInCombat()const{return combat;}bool GetTransport()const{return transport;}
|
|
bool IsInFlight()const{return taxi;}bool IsFlying()const{return flying;}bool IsFalling()const{return falling;}bool IsBeingTeleported()const{return teleport;}
|
|
bool HasUnitState(int)const{return casting;}bool IsSplineEnabled()const{return spline;}};
|
|
'''+s[a:b]+r'''
|
|
int main(){Player p;assert(Ready(&p)&&!Ready(nullptr));
|
|
for(auto field:{&Player::combat,&Player::transport,&Player::taxi,&Player::flying,&Player::falling,&Player::teleport,&Player::casting,&Player::spline}){
|
|
p.*field=true;assert(!Ready(&p));p.*field=false;assert(Ready(&p));
|
|
}
|
|
p.world=false;assert(!Ready(&p));p.world=true;p.alive=false;assert(!Ready(&p));
|
|
}
|
|
'''
|
|
with tempfile.TemporaryDirectory()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('Native safe logout gate waits for combat, casting, movement, transport, taxi, flight, falling, teleport and resurrection.')
|