49 lines
2.5 KiB
Python
49 lines
2.5 KiB
Python
"""Production micro cleanup cancels the physical spline without interrupting transit."""
|
|
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::ResetMicro(');b=s.index('bool AdventureBehaviorMgr::LocalMove(',a)
|
|
code=r'''
|
|
#include <cassert>
|
|
#include <cstdint>
|
|
#include <string>
|
|
using uint32=uint32_t;
|
|
constexpr int UNIT_NPC_EMOTESTATE=0,UNIT_STAND_STATE_STAND=0;
|
|
struct Guid{uint32 GetCounter(){return 26;}};
|
|
struct Player{
|
|
bool alive=true,transport=false,taxi=false,flying=false,teleport=false;
|
|
int stops=0,stands=0,emotes=0;
|
|
bool IsAlive(){return alive;}bool GetTransport(){return transport;}bool IsInFlight(){return taxi;}bool IsFlying(){return flying;}bool IsBeingTeleported(){return teleport;}
|
|
void SetStandState(int){++stands;}void SetUInt32Value(int,int){++emotes;}void StopMoving(){++stops;}
|
|
Guid GetGUID(){return {};}
|
|
};
|
|
bool busy=false;bool Busy(uint32){return busy;}
|
|
struct Travel{int cancels=0;void CancelTravel(uint32){++cancels;}} travel;auto sClientlessTravelMgr=&travel;
|
|
struct ObjectGuid{void Clear(){}};
|
|
struct SocialScene{};
|
|
struct AdventureSocialActions{static void Reset(Player*,SocialScene&){}};
|
|
class AdventureBehaviorMgr{public:
|
|
struct RecoveryScene{bool Active=false;};
|
|
struct Record{SocialScene Social;RecoveryScene Recovery;std::string Micro="explore";int MicroTimer=100,GestureTimer=100;ObjectGuid WorkObject;int WorkEmote=0;bool WorkPending=false;};
|
|
void ResetLeisure(Player*,Record&){}
|
|
void ResetMicro(Player*,Record&);
|
|
};
|
|
'''
|
|
code+=s[a:b]+r'''
|
|
int main(){
|
|
AdventureBehaviorMgr mgr;AdventureBehaviorMgr::Record r;Player p;
|
|
r.Recovery.Active=true;
|
|
mgr.ResetMicro(&p,r);assert(p.stops==1&&travel.cancels==1&&r.Micro.empty()&&!r.Recovery.Active);
|
|
r.Micro="drink";p.transport=true;mgr.ResetMicro(&p,r);assert(p.stops==1&&travel.cancels==1);
|
|
p.transport=false;p.flying=true;r.Micro="look";mgr.ResetMicro(&p,r);assert(p.stops==1);
|
|
p.flying=false;busy=true;r.Micro="look";mgr.ResetMicro(&p,r);assert(p.stops==1);
|
|
busy=false;p.alive=false;r.Micro="rest";int stands=p.stands;mgr.ResetMicro(&p,r);assert(p.stands==stands);
|
|
}
|
|
'''
|
|
with tempfile.TemporaryDirectory(prefix='vcore-micro-reset-') as folder:
|
|
cpp=Path(folder)/'test.cpp';binary=Path(folder)/'test';cpp.write_text(code)
|
|
subprocess.run(['c++','-std=c++17',str(cpp),'-o',str(binary)],check=True)
|
|
subprocess.run([str(binary)],check=True)
|
|
print('Micro cleanup ends physical local movement, preserves transit and does not stand up dead players.')
|