#include "guild_state.h" #include "python_runtime.h" #include "python_net.h" #include "python_gameplay_modules.h" #include "eter_net/PythonNetworkStream.h" #include #include #include using namespace ava2; using Bytes=std::vector; void require(bool ok,const char* why) {if(!ok)throw std::runtime_error(why);} void u32(Bytes& b,uint32_t v) {for(int i=0;i<4;++i)b.push_back(uint8_t(v>>(8*i)));} void u16(Bytes& b,uint16_t v) {b.push_back(uint8_t(v));b.push_back(uint8_t(v>>8));} void str(Bytes& b,const std::string& value,size_t width) {for(size_t i=0;i>(8*i));}; put(offsetof(TPacketGCCharacterUpdate,dwVID),123);put(offsetof(TPacketGCCharacterUpdate,dwGuildID),7); net.PushRecvData(actorUpdate);net.ProcessRecvData(); python.execute("assert net.GetGuildID()==7\nassert net.GetAccountCharacterSlotDataInteger(0,12)==7\nassert net.GetAccountCharacterSlotDataString(0,13)=='Seven'\n"); send(5,pid(11)); python.execute(R"PY(assert guild.IsGuildEnable()==0 and guild.GetGuildID()==0 and net.GetGuildID()==0 assert net.GetAccountCharacterSlotDataInteger(0,12)==0 and net.GetAccountCharacterSlotDataString(0,13)=='' assert guild.GetGuildBoardCommentCount()==1 and guild.GetGuildExperienceSummary()==800 assert guild.GetSkillIndex(3)==7 assert h.events==[('DeleteGuild',),('OnRemoveAllList',1),('RefreshTargetBoard',),('RefreshCharacter',),('RefreshMessenger',)] guild.Destroy() assert guild.GetSkillIndex(3)==0 assert guild.GetGuildBoardCommentCount()==1 and guild.GetGuildExperienceSummary()==800 h.events=[] )PY"); // Original ADD/unknown subheaders do not consume their payload. send(4,{44});require(net.PopSendBytes()==Bytes{254},"unknown guild subheader handling changed"); // Reject a truncated member record without reading into the next frame. auto bad=frame(2,{1});bad.push_back(44);net.PushRecvData(bad);net.ProcessRecvData();require(net.PopSendBytes().empty(),"bad guild list consumed next frame"); python.execute("assert guild.GetMemberCount()==0 and h.events==[]\n"); auto& g=GetGuildState();for(uint32_t i=1;i<=7;++i)g.StartWar(i);require(g.enemies[5]==6,"six enemy slot cap changed");g.EndWar(2);g.StartWar(8);require(g.enemies[1]==8 && g.enemies[2]==3,"enemy slot reuse compacted list"); net.ResetConnection(); } {PythonRuntime python(argv[1],argv[2]);python.execute("import guild\nassert guild.GetGuildBoardCommentCount()==0 and guild.GetGuildExperienceSummary()==0\nassert guild.GetMemberCount()==0\n");} std::cout<<"AVA2 guild state, wire and Python parity passed\n"; }catch(const std::exception& e){std::cerr<