49 lines
3.6 KiB
Python
49 lines
3.6 KiB
Python
"""Entrance visits use ordinary location travel, retaining the local MMAP leg."""
|
|
from pathlib import Path
|
|
import subprocess,tempfile
|
|
root=Path(__file__).resolve().parents[2]
|
|
s=(root/'src/server/game/World/AdventureBehaviorMgr.cpp').read_text()
|
|
a=s.index('void AdventureBehaviorMgr::Begin(');b=s.index('\nvoid AdventureBehaviorMgr::Fallback(',a)
|
|
code=r'''
|
|
#include "AdventureGroupPolicy.h"
|
|
#include <cassert>
|
|
#include <string>
|
|
#include <unordered_map>
|
|
#include <unordered_set>
|
|
#define TC_LOG_INFO(...) ((void)0)
|
|
struct Player{struct Guid{int GetCounter(){return 26;}};Guid GetGUID(){return {};}};
|
|
struct ClientlessIntent{std::string Name;std::unordered_map<std::string,std::string> Parameters;};
|
|
struct Location{unsigned ZoneId=1519,AreaId=1519;bool IsArea=false;std::string BaseKey;}location;
|
|
struct Store{bool exists=true;Location* Find(std::string const&){return exists?&location:nullptr;}}store;auto sAdventureLocationMgr=&store;
|
|
struct Manager{void ClearIntent(int){}void SetIntent(int,ClientlessIntent){}}manager;auto sClientlessPlayerMgr=&manager;
|
|
struct Groups{bool complete=false;unsigned queues=0,cancels=0;bool Complete(Player*){return complete;}void QueueBrowser(Player*,std::string const&){++queues;}void CancelBrowser(Player*){++cancels;}}groups;auto sAdventureGroupMgr=&groups;
|
|
struct AdventureBehaviorMgr{
|
|
enum class Phase{Idle,Travel,WaitingGroup};
|
|
struct Record{long Deadline=0;bool Dirty=true,Enabled=true,Publishing=false,Queued=false,ExpeditionStarted=false;std::string Intent,Location,WantedIntent="instance",WantedLocation="instance_visit_at_101",Detail;Phase State=Phase::Idle;std::unordered_set<std::string>Tried;};
|
|
bool mapped=true,allowed=true;int fallback=0;std::string action,parameter,target;bool hard=false;
|
|
void Begin(Player*,Record&);
|
|
void LatchGroupTravel(Player*,Record&r){r.ExpeditionStarted=true;}
|
|
bool Allowed(Player*,Location const&,std::string const&){return allowed;}
|
|
void Fallback(Player*,Record&){++fallback;}
|
|
bool ResolveInstance(Player*,Record&){return mapped;}
|
|
std::string AreaNode(Player*,Location const&){return "reachable";}
|
|
void Queue(Player*,Record&r,std::string const&a,std::string const&p,std::string const&t,bool h=false){action=a;parameter=p;target=t;hard=h;r.Queued=true;}
|
|
};
|
|
'''+s[a:b]+r'''
|
|
int main(){Player p;AdventureBehaviorMgr mgr;AdventureBehaviorMgr::Record r;
|
|
mgr.Begin(&p,r);assert(r.State==AdventureBehaviorMgr::Phase::WaitingGroup&&mgr.action.empty()&&groups.queues==1&&!r.ExpeditionStarted);
|
|
groups.complete=true;mgr.Begin(&p,r);assert(r.ExpeditionStarted);
|
|
groups.complete=false;mgr.Begin(&p,r);assert(mgr.action=="travel_to_location"&&mgr.parameter=="id"&&mgr.target=="instance_visit_at_101"&&mgr.hard);
|
|
assert(r.State==AdventureBehaviorMgr::Phase::Travel&&!r.Dirty);
|
|
location.BaseKey="instance_visit_at_101";r.WantedLocation="instance_visit_at_101_d1";mgr.Begin(&p,r);assert(mgr.target==location.BaseKey&&r.Location==r.WantedLocation);
|
|
mgr.mapped=false;mgr.Begin(&p,r);assert(mgr.fallback==1);
|
|
mgr.mapped=true;r.WantedIntent="social";mgr.Begin(&p,r);assert(mgr.action=="travel_to_location"&&!mgr.hard);
|
|
location.IsArea=true;mgr.Begin(&p,r);assert(mgr.action=="travel_to_node"&&mgr.target=="reachable"&&mgr.hard);
|
|
}
|
|
'''
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
src=Path(tmp)/'begin.cpp';exe=Path(tmp)/'begin';src.write_text(code)
|
|
subprocess.run(['g++','-include',str(Path(__file__).with_name('telemetry_test_stub.h')),'-std=c++17','-I'+str(root/'src/server/game/World'),str(src),'-o',str(exe)],check=True)
|
|
subprocess.run([str(exe)],check=True)
|
|
print('Production entrance travel uses the existing location planner, requires mapping and retains normal social/area travel.')
|