49 lines
2.8 KiB
Python
49 lines
2.8 KiB
Python
"""Run the real temporary trace lifecycle and its per-bot log budget."""
|
|
from pathlib import Path
|
|
import subprocess,tempfile,re
|
|
root=Path(__file__).resolve().parents[2]
|
|
s=(root/'src/server/game/World/ClientlessTravelTelemetry.h').read_text()
|
|
assert 'Remove before development completion' in s
|
|
s=re.sub(r'#include "[^\n]+"\n','',s)
|
|
code=r'''
|
|
#include <string>
|
|
#include <cstdint>
|
|
#include <ctime>
|
|
using uint64=uint64_t;using uint32=unsigned;
|
|
namespace GameTime{time_t now=100;time_t GetGameTime(){return now;}}
|
|
unsigned logs=0;
|
|
#define TC_LOG_INFO(...) (++logs)
|
|
constexpr int SKILL_RIDING=1;
|
|
struct Guid{unsigned id;unsigned GetCounter()const{return id;}};
|
|
struct Group{Guid GetGUID()const{return {1};}Guid GetLeaderGUID()const{return {26};}};
|
|
struct Player{unsigned guid=26;Guid GetGUID()const{return {guid};}Group*GetGroup()const{return nullptr;}
|
|
unsigned GetMapId()const{return 0;}float GetPositionX()const{return 1;}float GetPositionY()const{return 2;}float GetPositionZ()const{return 3;}
|
|
unsigned getLevel()const{return 60;}unsigned GetAreaId()const{return 12;}unsigned GetZoneId()const{return 12;}
|
|
bool IsAlive()const{return true;}bool IsOutdoors()const{return true;}bool IsInWater()const{return false;}bool IsFalling()const{return false;}
|
|
bool IsInCombat()const{return false;}bool IsInFlight()const{return false;}void*GetTransport()const{return nullptr;}
|
|
bool IsBeingTeleported()const{return false;}bool IsMounted()const{return false;}bool CanFly()const{return false;}
|
|
unsigned GetSkillValue(int)const{return 225;}bool HasSpell(int)const{return true;}};
|
|
'''+s+r'''
|
|
#include <cassert>
|
|
int main(){using namespace ClientlessTravelTelemetry;Player p;
|
|
Note(&p,"route","no journey");assert(logs==0&&Traces().empty());
|
|
Begin(&p,"adventure","Elwynn",200);assert(logs==0&&Traces().empty());
|
|
Begin(&p,"instance","Deadmines",200);assert(logs==1);
|
|
auto id=Traces().at(26).Id;Begin(&p,"instance","Deadmines",200);assert(logs==1&&Traces().at(26).Id==id);
|
|
Note(&p,"route","same");Note(&p,"route","same");assert(logs==2);
|
|
for(unsigned i=0;i<100;++i)Note(&p,"route",std::to_string(i));assert(logs==40);
|
|
for(unsigned i=0;i<100;++i)Begin(&p,"raid",std::to_string(i),200);assert(logs==40);
|
|
GameTime::now+=60;Note(&p,"route","new minute");assert(logs==41);
|
|
Tick(&p);assert(logs==42);Tick(&p);assert(logs==42);
|
|
GameTime::now+=20;Tick(&p); // unchanged full state is deduplicated, too
|
|
assert(logs==42);
|
|
Begin(&p,"rest","inn",300);assert(Traces().empty());
|
|
Begin(&p,"raid","Karazhan",400);assert(!Traces().empty());Clear(&p);assert(Traces().empty());
|
|
}
|
|
'''
|
|
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('Temporary travel traces: instance/raid scope, stable journey ID, deduplication, 40/min budget across goal changes and logout cleanup.')
|