- gr2: BitKnit2 decompression, 64-bit LE files, compressed curves - net: remaining GamePhase handlers, generated GC packet table - python: event/chat/chr/minimap/guild/quest/messenger/shop-search and other native modules ported against the AVA2 Windows client - render: D3D8 fixed-function lighting in Gr2ModelRenderer, terrain without baked shade; cape/NPC equipment attachment - tests + audits updated; docs/PORT-PLAN.md and WINDOWS-PARITY.md Batch 4 (render pipeline: background.*, app.RenderGame/UpdateGame, camera bindings, main.cpp fake-content removal) is still in progress. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
51 lines
4.3 KiB
C++
51 lines
4.3 KiB
C++
#include "cube_renewal_state.h"
|
|
#include "python_runtime.h"
|
|
#include "eter_net/PythonNetworkStream.h"
|
|
#include <iostream>
|
|
#include <stdexcept>
|
|
using namespace ava2;
|
|
void require(bool ok,const char* why) { if(!ok)throw std::runtime_error(why); }
|
|
void u32(std::vector<uint8_t>& p,uint32_t value) { for(unsigned i=0;i<4;++i)p.push_back(uint8_t(value>>(i*8))); }
|
|
std::vector<uint8_t> recipe() {
|
|
std::vector<uint8_t> p{221,2};u32(p,20016);u32(p,99);u32(p,0x80000001);u32(p,uint32_t(-5));p.push_back(1);
|
|
for(unsigned i=1;i<=5;++i) { u32(p,100+i);u32(p,uint32_t(-int(i))); }
|
|
u32(p,uint32_t(-70));u32(p,100);p.resize(167,0);const char category[]="Equipment";
|
|
std::copy_n(category,9,p.begin()+67);return p;
|
|
}
|
|
void send(const std::vector<uint8_t>& data) {
|
|
auto& s=PythonNetworkStream::Instance();s.PushRecvData(data);s.ProcessRecvData();
|
|
}
|
|
std::vector<uint8_t> control(uint8_t sub) { std::vector<uint8_t> p(167);p[0]=221;p[1]=sub;return p; }
|
|
int main(int argc,char** argv) {
|
|
if(argc!=3)return 2;
|
|
try {
|
|
{
|
|
PythonRuntime python(argv[1],argv[2]);auto& s=PythonNetworkStream::Instance();s.ResetConnection();s.SetPhase(PHASE_GAME);
|
|
python.execute("import cube_renewal as cube, net, weakref, gc\nassert cube.CountDates()==0\nassert cube.GetDates() is None\nassert cube.GetDates(-1)==(0,)*15+('None',)\nassert cube.CubeRenewalMakeItem('x',1) is None\nassert cube.SetCubeRenewalHandler() is None\nclass Game:\n def __init__(self): self.opens=0\n def BINARY_CUBE_RENEWAL_OPEN(self): self.opens+=1\nclass Loader:\n def __init__(self): self.counts=[]\n def BINARY_CUBE_RENEWAL_LOADING(self): self.counts.append(cube.CountDates())\ngame=Game()\nloader=Loader()\nnet.SetPhaseWindow(net.PHASE_WINDOW_GAME,game)\ncube.SetCubeRenewalHandler(loader)\n");
|
|
auto p=recipe();require(p.size()==167,"literal recipe size");p.push_back(44);
|
|
s.PushRecvData(p.data(),166);s.ProcessRecvData();python.execute("assert cube.CountDates()==0\n");
|
|
s.PushRecvData(p.data()+166,2);s.ProcessRecvData();require(s.PopSendBytes()==std::vector<uint8_t>{254},"recipe lost following ping");
|
|
python.execute("expected=(-2147483647,-5,1,101,-1,102,-2,103,-3,104,-4,105,-5,-70,100,'Equipment')\nassert cube.GetDates(0)==expected\nassert cube.GetDates(0,'extra')==expected\nassert cube.GetDates(1)==(0,)*15+('None',)\n");
|
|
send(recipe());send(control(3));send(control(0));
|
|
python.execute("assert cube.CountDates()==2\nassert cube.GetDates(1)==expected\nassert loader.counts==[2]\nassert game.opens==1\n");
|
|
// Unknown subheaders are consumed as a whole fixed packet without changing recipes.
|
|
send(control(255));send(control(1));send(control(3));
|
|
python.execute("assert cube.CountDates()==0\nassert loader.counts==[2,0]\ncube.CubeRenewalMakeItem(2,3)\ncube.CubeRenewalClose()\n");
|
|
require(s.PopSendBytes().empty(),"craft without main actor sent");
|
|
SNetworkActorData actor{};actor.m_dwVID=1001;actor.m_dwRace=0;actor.m_stName="CubeFixture";
|
|
NetworkActorManager::Instance().AppendActor(actor);s.SetMainActorVID(1001);
|
|
auto instance=NetworkActorManager::Instance().GetActorInstance(1001);require(bool(instance),"missing native actor");
|
|
python.execute("cube.CubeRenewalMakeItem(-1,2147483649)\ncube.CubeRenewalClose()\n");
|
|
auto bytes=s.PopSendBytes();std::vector<uint8_t> expected{216,4,255,255,255,255,1,0,0,128,216,5,0,0,0,0,0,0,0,0};
|
|
require(bytes==expected,"cube request Win32 byte conversion");
|
|
instance->SetSleep(true);python.execute("cube.CubeRenewalMakeItem(1,2)\ncube.CubeRenewalClose()\n");
|
|
require(s.PopSendBytes().empty(),"controlled actor allowed cube request");instance->SetSleep(false);
|
|
python.execute("temporary=Loader()\nref=weakref.ref(temporary)\ncube.SetCubeRenewalHandler(temporary)\ndel temporary\ngc.collect()\nassert ref() is not None\n");
|
|
send(control(1));python.execute("assert ref() is not None\ncube.SetCubeRenewalHandler(None)\ngc.collect()\nassert ref() is None\n");
|
|
send(recipe());s.ResetConnection();NetworkActorManager::Instance().Clear();
|
|
}
|
|
{ PythonRuntime python(argv[1],argv[2]);python.execute("import cube_renewal as cube\nassert cube.CountDates()==0\n"); }
|
|
std::cout<<"AVA2 cube renewal state, wire and Python parity passed\n";
|
|
} catch(const std::exception& e) { std::cerr<<e.what()<<'\n';return 1; }
|
|
}
|