feat: integrate native AVA2 battle pass, wiki, drop finder and calendar

This commit is contained in:
shen
2026-10-18 23:36:35 -07:00
parent 62b61bafd0
commit 1359eab806
44 changed files with 7237 additions and 190 deletions
@@ -0,0 +1,8 @@
#pragma once
// AVA2 drop finder layout. Event manager uses free GC214 because classic GC39 is SHOP_SIGN.
#pragma pack(push,1)
struct TPacketCGAva2Drop {BYTE header,subheader;LONG vnum;};
struct TPacketGCAva2Drop {BYTE header,subheader;char name[100];DWORD vnum,prob;LONG count;};
struct TPacketGCAva2Events {BYTE header;DWORD size;};
#pragma pack(pop)
static_assert(sizeof(TPacketCGAva2Drop)==6 && sizeof(TPacketGCAva2Drop)==114 && sizeof(TPacketGCAva2Events)==5,"AVA2 query wire sizes");
+2 -2
View File
@@ -33,9 +33,9 @@ CRenderTarget::CRenderTarget(const DWORD width, const DWORD height) :
m_renderTargetTexture = std::move(pTex);
}
void CRenderTarget::RenderTexture() const
void CRenderTarget::RenderTexture(float left, float top, float right, float bottom) const
{
m_renderTargetTexture->Render();
m_renderTargetTexture->Render(left,top,right,bottom);
}
void CRenderTarget::SetRenderingRect(RECT* rect) const
+1 -1
View File
@@ -31,7 +31,7 @@ public:
void CreateTextures() const;
void ReleaseTextures() const;
void RenderTexture() const;
void RenderTexture(float left=0, float top=0, float right=0, float bottom=0) const;
bool CreateBackground(const char* imgPath, DWORD width, DWORD height);
void RenderBackground() const;
+2
View File
@@ -363,6 +363,8 @@ enum
HEADER_GC_RESPOND_CHANNELSTATUS = 210,
HEADER_GC_SASH = 215, // PORT: AVA2 sash
HEADER_GC_CHESTDROP = 66, // PORT: AVA2, DWORD dynamic length
HEADER_GC_AVA2_EVENTS = 214,
HEADER_GC_AVA2_DROP = 220,
HEADER_GC_SWITCHBOT = 171, // PORT: AVA2 switchbot, DYNAMIC_SIZE_PACKET
HEADER_GC_KEY_AGREEMENT_COMPLETED = 0xfa, // _IMPROVED_PACKET_ENCRYPTION_
+18 -1
View File
@@ -549,10 +549,27 @@ PyObject* itemLoadItemTable(PyObject* poSelf, PyObject* poArgs)
return Py_BuildNone();
}
// AVA2 encyclopedia: expose the already loaded classic proto fields.
static PyObject* itemGetRefineSet(PyObject*,PyObject*) {
auto* item=CItemManager::Instance().GetSelectedItemDataPointer();
return PyInt_FromLong(item?item->GetTable()->wRefineSet:0);
}
static PyObject* itemGetRefinedVnum(PyObject*,PyObject*) {
auto* item=CItemManager::Instance().GetSelectedItemDataPointer();
return PyInt_FromLong(item?item->GetTable()->dwRefinedVnum:0);
}
static PyObject* itemSelectItemWiki(PyObject*,PyObject* args) {
int vnum;if (!PyTuple_GetInteger(args,0,&vnum)) return Py_BadArgument();
return PyInt_FromLong(CItemManager::Instance().SelectItemData(vnum)?1:0);
}
void initItem()
{
static PyMethodDef s_methods[] =
{
{
{"GetRefineSet",itemGetRefineSet,METH_VARARGS},
{"GetRefinedVnum",itemGetRefinedVnum,METH_VARARGS},
{"SelectItemWiki",itemSelectItemWiki,METH_VARARGS},
{ "GetDropInfo", itemGetDropInfo, METH_VARARGS },
{ "ClearDropInfo", itemClearDropInfo, METH_VARARGS },
{ "SetUseSoundFileName", itemSetUseSoundFileName, METH_VARARGS },
@@ -1,4 +1,5 @@
#include "StdAfx.h"
#include "Ava2QueryPackets.h"
#include "../EterLib/NetPacketHeaderMap.h"
#include "PythonNetworkStream.h"
@@ -186,6 +187,8 @@ class CMainPacketHeaderMap : public CNetworkPacketHeaderMap
Set(HEADER_GC_DRAGON_SOUL_REFINE, CNetworkPacketHeaderMap::TPacketType(sizeof(TPacketGCDragonSoulRefine), STATIC_SIZE_PACKET));
Set(HEADER_GC_SASH, CNetworkPacketHeaderMap::TPacketType(sizeof(TPacketSash), STATIC_SIZE_PACKET)); // PORT: AVA2 sash
Set(HEADER_GC_CHESTDROP, CNetworkPacketHeaderMap::TPacketType(sizeof(TPacketGCChestDrop), DYNAMIC_SIZE_PACKET));
Set(HEADER_GC_AVA2_DROP,CNetworkPacketHeaderMap::TPacketType(sizeof(TPacketGCAva2Drop),STATIC_SIZE_PACKET));
Set(HEADER_GC_AVA2_EVENTS,CNetworkPacketHeaderMap::TPacketType(sizeof(TPacketGCAva2Events),DYNAMIC_SIZE_PACKET));
Set(HEADER_GC_SWITCHBOT, CNetworkPacketHeaderMap::TPacketType(sizeof(TPacketGCSwitchbot), DYNAMIC_SIZE_PACKET)); // PORT: AVA2 switchbot
}
+4 -1
View File
@@ -120,7 +120,8 @@ class CPythonNetworkStream : public CNetworkStream, public CSingleton<CPythonNet
bool IsSelectedEmpire();
// PORT: the touch host shows its joystick and skill buttons only in the game phase.
bool PORT_IsGamePhase() const { return m_strPhase == "Game"; }
bool SendAva2DropQuery(BYTE subheader,LONG vnum);
bool PORT_IsGamePhase() const { return m_strPhase == "Game"; }
void ToggleGameDebugInfo();
@@ -559,6 +560,8 @@ class CPythonNetworkStream : public CNetworkStream, public CSingleton<CPythonNet
// 용혼석 관련
bool RecvDragonSoulRefine();
bool RecvSashPacket(bool bReturn = false); // PORT: AVA2 sash
bool RecvAva2DropQuery();
bool RecvAva2Events();
bool RecvSwitchbotPacket(); // PORT: AVA2 switchbot
// MiniMap Info
@@ -1732,10 +1732,17 @@ PyObject* netRegisterErrorLog(PyObject* poSelf, PyObject* poArgs)
return Py_BuildNone();
}
static PyObject* netSendAva2DropQuery(PyObject*,PyObject* args) {
int sub,vnum;
if (!PyTuple_GetInteger(args,0,&sub) || !PyTuple_GetInteger(args,1,&vnum))return Py_BadArgument();
return PyInt_FromLong(CPythonNetworkStream::Instance().SendAva2DropQuery(BYTE(sub),vnum));
}
void initnet()
{
static PyMethodDef s_methods[] =
{
{"SendAva2DropQuery",netSendAva2DropQuery,METH_VARARGS},
{ "GetBettingGuildWarValue", netGetBettingGuildWarValue, METH_VARARGS },
{ "EnableChatInsultFilter", netEnableChatInsultFilter, METH_VARARGS },
{ "SetServerInfo", netSetServerInfo, METH_VARARGS },
@@ -637,7 +637,11 @@ void CPythonNetworkStream::GamePhase()
case HEADER_GC_CHESTDROP:
ret=RecvChestDrop(); break;
case HEADER_GC_SWITCHBOT: // PORT: AVA2 switchbot
case HEADER_GC_AVA2_DROP:
ret=RecvAva2DropQuery();break;
case HEADER_GC_AVA2_EVENTS:
ret=RecvAva2Events();break;
case HEADER_GC_SWITCHBOT: // PORT: AVA2 switchbot
ret = RecvSwitchbotPacket();
break;
@@ -4215,8 +4219,8 @@ bool CPythonNetworkStream::SendClientVersionPacket()
TPacketCGClientVersion2 kVersionPacket;
kVersionPacket.header = HEADER_CG_CLIENT_VERSION2;
strncpy(kVersionPacket.filename, filename.c_str(), sizeof(kVersionPacket.filename)-1);
// PORT: " mt20261016" enables the AVA2 switchbot on the server (port_switchbot.cpp); the version check uses atoi.
strncpy(kVersionPacket.timestamp, "1215955205 mt20261016", sizeof(kVersionPacket.timestamp)-1); // # python time.time 앞자리
// PORT: " mt20261019" enables the AVA2 switchbot on the server (port_switchbot.cpp); the version check uses atoi.
strncpy(kVersionPacket.timestamp, "1215955205 mt20261019", sizeof(kVersionPacket.timestamp)-1); // # python time.time 앞자리
//strncpy(kVersionPacket.timestamp, __TIMESTAMP__, sizeof(kVersionPacket.timestamp)-1); // old_string_ver
//strncpy(kVersionPacket.timestamp, "1218055205", sizeof(kVersionPacket.timestamp)-1); // new_future
//strncpy(kVersionPacket.timestamp, "1214055205", sizeof(kVersionPacket.timestamp)-1); // old_past
@@ -4230,8 +4234,8 @@ bool CPythonNetworkStream::SendClientVersionPacket()
kVersionPacket.header = HEADER_CG_CLIENT_VERSION;
strncpy(kVersionPacket.filename, filename.c_str(), sizeof(kVersionPacket.filename)-1);
// PORT: protocol date instead of __TIMESTAMP__; the server sends the AVA2 switchbot packets only from
// "mt20261016" on (metin2-server port_switchbot.h PORT_SWITCHBOT_CLIENT_VERSION).
strncpy(kVersionPacket.timestamp, "mt20261016", sizeof(kVersionPacket.timestamp)-1);
// "mt20261019" on (metin2-server port_switchbot.h PORT_SWITCHBOT_CLIENT_VERSION).
strncpy(kVersionPacket.timestamp, "mt20261019", sizeof(kVersionPacket.timestamp)-1);
if (!Send(sizeof(kVersionPacket), &kVersionPacket))
Tracef("SendClientReportPacket Error");
@@ -0,0 +1,25 @@
#include "StdAfx.h"
#include "PythonNetworkStream.h"
#include "Ava2QueryPackets.h"
#include <vector>
bool CPythonNetworkStream::SendAva2DropQuery(BYTE subheader,LONG vnum) {
if (!PORT_IsGamePhase() || (subheader!=0 && subheader!=1 && subheader!=6 && subheader!=7 && subheader!=8 && subheader!=9 && subheader!=10) || vnum<0)return false;
TPacketCGAva2Drop p={215,subheader,vnum};
return Send(sizeof(p),&p) && SendSequence();
}
bool CPythonNetworkStream::RecvAva2DropQuery() {
TPacketGCAva2Drop p;
if (!Recv(sizeof(p),&p) || p.count<0 || p.subheader<2 || p.subheader>6)return false;
char name[101];memcpy(name,p.name,100);name[100]=0;
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME],"BINARY_Ava2Drop",Py_BuildValue("(isIIi)",p.subheader,name,p.vnum,p.prob,p.count));
return true;
}
bool CPythonNetworkStream::RecvAva2Events() {
TPacketGCAva2Events p;
if (!Recv(sizeof(p),&p) || p.size<sizeof(p)+6 || p.size>32768)return false;
std::vector<char> data(p.size-sizeof(p));
if (!Recv(data.size(),data.data()))return false;
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME],"BINARY_Ava2Events",Py_BuildValue("(s#)",data.data(),int(data.size())));
return true;
}
@@ -87,10 +87,21 @@ PyObject * nonplayerLoadNonPlayerData(PyObject * poSelf, PyObject * poArgs)
return Py_BuildNone();
}
// AVA2 encyclopedia reads template values, not a live actor's final combat stats.
static PyObject* nonplayerGetWikiInfo(PyObject*,PyObject* args) {
int vnum;if (!PyTuple_GetInteger(args,0,&vnum)) return Py_BadArgument();
const auto* t=CPythonNonPlayer::Instance().GetTable(vnum);
if (!t) return Py_BuildValue("");
PyObject* resist=PyTuple_New(CPythonNonPlayer::MOB_RESISTS_MAX_NUM);
for (int i=0;i<CPythonNonPlayer::MOB_RESISTS_MAX_NUM;++i) PyTuple_SET_ITEM(resist,i,PyInt_FromLong(t->cResists[i]));
return Py_BuildValue("(iIIIIIIIN)",t->bLevel,t->dwMaxHP,t->dwDamageRange[0],t->dwDamageRange[1],t->dwExp,t->dwGoldMin,t->dwGoldMax,t->dwRaceFlag,resist);
}
void initNonPlayer()
{
static PyMethodDef s_methods[] =
{
{"GetWikiInfo",nonplayerGetWikiInfo,METH_VARARGS},
{ "GetEventType", nonplayerGetEventType, METH_VARARGS },
{ "GetEventTypeByVID", nonplayerGetEventTypeByVID, METH_VARARGS },
{ "GetLevelByVID", nonplayerGetLevelByVID, METH_VARARGS },
@@ -60,7 +60,9 @@ PyObject* renderTargetRenderTexture(PyObject* poSelf, PyObject* poArgs)
{
RECT rect = { l, t, r, b };
target->SetRenderingRect(&rect);
target->RenderTexture();
float clip[4]={};
if(PyTuple_Size(poArgs)>5)for(int i=0;i<4;++i)if(!PyTuple_GetFloat(poArgs,5+i,&clip[i]))return Py_BadArgument();
target->RenderTexture(clip[0],clip[1],clip[2],clip[3]);
}
return Py_BuildNone();
}
@@ -250,10 +252,30 @@ PyObject* renderTargetSetMotionIndex(PyObject* poSelf, PyObject* poArgs)
return Py_BuildValue("i", 0);
}
// AVA2 encyclopedia render controls.
static PyObject* renderSetModelRender(PyObject*,PyObject* args) {
bool status;if(!PyTuple_GetBoolean(args,1,&status))return Py_BadArgument();
const auto target=Target(args);if(target)target->SetModelStatus(status);
return Py_BuildNone();
}
static PyObject* renderSetAcce(PyObject*,PyObject* args) {
int sash;if(!Integer(args,1,&sash))return Py_BadArgument();
const auto target=Target(args);if(target && target->IsReady())target->GetModel()->SetSash(sash);
return Py_BuildNone();
}
static PyObject* renderSetZoomDistance(PyObject*,PyObject* args) {
float distance;if(!PyTuple_GetFloat(args,1,&distance) || distance<=0)return Py_BadArgument();
const auto target=Target(args);if(target)target->SetModelV3Eye(0,-distance,600);
return Py_BuildNone();
}
void initRenderTarget()
{
static PyMethodDef s_methods[] =
{
{"SetModelRender",renderSetModelRender,METH_VARARGS},
{"SetAcce",renderSetAcce,METH_VARARGS},
{"SetZoom",renderSetZoomDistance,METH_VARARGS},
{ "Create", renderTargetCreate, METH_VARARGS },
{ "Remove", renderTargetRemove, METH_VARARGS },
{ "Exists", renderTargetExists, METH_VARARGS },