feat: add CH5 cube renewal presentation, trade level UI, audit manifests, and test fixtures

This commit is contained in:
shen
2026-10-23 20:17:26 -07:00
parent c1de05dc98
commit d6617e01f7
96 changed files with 6059 additions and 106 deletions
+1 -1
View File
@@ -412,7 +412,7 @@ typedef struct TPlayerItemAttribute
typedef struct packet_item
{
DWORD vnum;
BYTE count;
DWORD count; // PORT: internal-only full count; classic wire structs remain BYTE.
DWORD flags;
DWORD anti_flags;
LONG alSockets[ITEM_SOCKET_SLOT_MAX_NUM]; // PORT: LONG, the 32-bit Win32 long
@@ -1595,7 +1595,7 @@ void initapp()
PyModule_AddIntConstant(poModule, "ENABLE_VIEW_TARGET_DECIMAL_HP", 1);
PyModule_AddIntConstant(poModule, "ENABLE_VIEW_TARGET_PLAYER_HP", 1);
PyModule_AddIntConstant(poModule, "ENABLE_WINDOW_SLIDE_EFFECT", 0);
// PORT: the Won exchange window binds the cheque slot, so it follows ENABLE_CHEQUE_SYSTEM (off).
// PORT: Won wallet/transactions are gated off; its dependent window must be off too.
PyModule_AddIntConstant(poModule, "ENABLE_WON_EXCHANGE_WINDOW", 0);
PyModule_AddIntConstant(poModule, "BL_MOVE_COSTUME_ATTR", 1);
PyModule_AddIntConstant(poModule, "DISABLE_CHEQUE_DROP", 0);
+6 -3
View File
@@ -23,12 +23,12 @@ char * CPythonExchange::GetNameFromTarget()
void CPythonExchange::SetSelfLevel(DWORD level)
{
m_self.level = level;
m_self.level = level >= 1 && level <= 255 ? level : 0;
}
void CPythonExchange::SetTargetLevel(DWORD level)
{
m_victim.level = level;
m_victim.level = level >= 1 && level <= 255 ? level : 0;
}
DWORD CPythonExchange::GetLevelFromSelf()
@@ -255,6 +255,9 @@ void CPythonExchange::Start()
void CPythonExchange::End()
{
m_isTrading = false;
// PORT: snapshots belong to this trade only, not a future partner/session.
m_self.level = 0;
m_victim.level = 0;
}
bool CPythonExchange::isTrading()
@@ -285,4 +288,4 @@ CPythonExchange::CPythonExchange()
}
CPythonExchange::~CPythonExchange()
{
}
}
@@ -1910,6 +1910,8 @@ bool CPythonNetworkStream::RecvExchangePacket()
CPythonExchange::Instance().Start();
CPythonExchange::Instance().SetSelfName(CPythonPlayer::Instance().GetName());
CPythonExchange::Instance().SetSelfLevel(CPythonPlayer::Instance().GetStatus(POINT_LEVEL));
// PORT: START.arg3 is the server's partner-level snapshot; zero means legacy/unknown.
CPythonExchange::Instance().SetTargetLevel(exchange_packet.arg3);
{
CInstanceBase * pCharacterInstance = CPythonCharacterManager::Instance().GetInstancePtr(exchange_packet.arg1);
@@ -1917,7 +1919,6 @@ bool CPythonNetworkStream::RecvExchangePacket()
if (pCharacterInstance)
{
CPythonExchange::Instance().SetTargetName(pCharacterInstance->GetNameString());
CPythonExchange::Instance().SetTargetLevel(pCharacterInstance->GetLevel());
}
}
@@ -4529,7 +4530,7 @@ bool CPythonNetworkStream::SendClientVersionPacket()
kVersionPacket.header = HEADER_CG_CLIENT_VERSION2;
strncpy(kVersionPacket.filename, filename.c_str(), sizeof(kVersionPacket.filename)-1);
// PORT: revision mt20261024 adds 64-bit shop prices, fixed offline records and 64-bit exchange/guild money; preserve the numeric prefix for atoi version checks.
strncpy(kVersionPacket.timestamp, "1215955205 mt20261024", sizeof(kVersionPacket.timestamp)-1); // # python time.time 앞자리
strncpy(kVersionPacket.timestamp, "1215955205 mt20261025", sizeof(kVersionPacket.timestamp)-1); // PORT: revision25 adds full-count and Cube presentation companions.
//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
@@ -4543,7 +4544,7 @@ bool CPythonNetworkStream::SendClientVersionPacket()
kVersionPacket.header = HEADER_CG_CLIENT_VERSION;
strncpy(kVersionPacket.filename, filename.c_str(), sizeof(kVersionPacket.filename)-1);
// PORT: 64-bit money protocol requires mt20261024; older AVA2 services retain their own revision gates.
strncpy(kVersionPacket.timestamp, "mt20261024", sizeof(kVersionPacket.timestamp)-1);
strncpy(kVersionPacket.timestamp, "mt20261025", sizeof(kVersionPacket.timestamp)-1); // PORT: revision25 is backward-compatible with revision24 money.
if (!Send(sizeof(kVersionPacket), &kVersionPacket))
Tracef("SendClientReportPacket Error");
@@ -4,6 +4,7 @@
#include <vector>
#include "PythonPlayer.h"
#include "PythonSafeBox.h"
#include "../common/CubePresentation.h"
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;
@@ -32,6 +33,25 @@ bool CPythonNetworkStream::RecvAva2ItemShop() {
if (!Recv(sizeof(p),&p) || p.size<sizeof(p)+1 || p.size>32768)return false;
std::vector<char> data(p.size-sizeof(p));
if (!Recv(data.size(),data.data()))return false;
if(uint8_t(data[0])==11) {
// PORT: full Cube presentation is validated before any player mutation.
PortCubeView::Frame frame;
if(!PortCubeView::Decode(std::string(data.begin(),data.end()),frame)||!CPythonPlayer::Instance().PORT_ApplyCubeView(frame))return false;
__RefreshInventoryWindow();__RefreshStatus();return true;
}
if(uint8_t(data[0])==12) {
// PORT: full count companion; classic byte-sized item packets stay intact.
if(data.size()!=83)return false;const std::string bytes(data.begin(),data.end());PortCubeView::Reader r{bytes};r.at=1;
const auto window=uint8_t(r.n(1));const auto cell=uint16_t(r.n(2));const auto vnum=uint32_t(r.n(4)),id=uint32_t(r.n(4));const auto count=uint16_t(r.n(2));
if(!r.ok||!vnum||!id||!count||count>2000)return false;PortItemExtra extra;std::memcpy(&extra,bytes.data()+r.at,69);
TItemData* target=nullptr;
if(window==SAFEBOX){if(!CPythonSafeBox::Instance().GetItemDataPtr(cell,&target))return false;}
else if(window==MALL){if(!CPythonSafeBox::Instance().GetMallItemDataPtr(cell,&target))return false;}
else {TItemPos pos(window,cell);if(!pos.IsValidCell())return false;target=const_cast<TItemData*>(CPythonPlayer::Instance().GetItemData(pos));}
if(!target||target->vnum!=vnum||(target->portId&&target->portId!=id))return true; // PORT: stale same-vnum companion cannot replace a newer identity.
target->count=count;target->portId=id;target->extra=extra;
if(window==SAFEBOX)__RefreshSafeboxWindow();else if(window==MALL)__RefreshMallWindow();else __RefreshInventoryWindow();return true;
}
if(uint8_t(data[0])==10) {
#pragma pack(push,1)
struct Extra {uint8_t op,window;uint16_t cell;uint32_t vnum,id;PortItemExtra extra;};
+7 -1
View File
@@ -5,6 +5,7 @@
#include "../EterBase/Timer.h"
#include "AbstractPlayer.h"
#include "../common/CubePresentation.h"
enum
{
@@ -21,6 +22,8 @@ enum
const DWORD POINT_MAGIC_NUMBER = 0xe73ac1da;
#include "PythonPlayerCubeView.inc"
void CPythonPlayer::SPlayerStatus::SetPoint(UINT ePoint, long lPoint)
{
m_alPoint[ePoint]=lPoint ^ POINT_MAGIC_NUMBER;
@@ -750,7 +753,9 @@ DWORD CPythonPlayer::GetItemID(TItemPos Cell)
const char* CPythonPlayer::GetItemNewName(TItemPos Cell)
{
const auto item=Cell.IsValidCell() ? GetItemData(Cell) : nullptr;
return item ? item->extra.name : "";
// PORT: keep all69 authoritative bytes; expose only the 24 display bytes.
static thread_local char name[25];std::memset(name,0,sizeof(name));
if(item)std::memcpy(name,item->extra.name,24);return name;
}
DWORD CPythonPlayer::GetItemMetinSocket(TItemPos Cell, DWORD dwMetinSocketIndex)
@@ -1754,6 +1759,7 @@ void CPythonPlayer::ClearSkillDict()
void CPythonPlayer::Clear()
{
m_portCubeViewEpoch=0;m_portCubeViewBytes.clear(); // PORT: character/session boundary.
memset(&m_playerStatus, 0, sizeof(m_playerStatus));
m_i64Gold = 0;
NEW_ClearSkillData(true);
+4
View File
@@ -5,6 +5,7 @@
#include "PythonSkill.h"
class CInstanceBase;
namespace PortCubeView {struct Frame;}
/*
* 메인 캐릭터 (자신이 조정하는 캐릭터) 가 가진 정보들을 관리한다.
@@ -286,6 +287,7 @@ class CPythonPlayer : public CSingleton<CPythonPlayer>, public IAbstractPlayer
void SetStatus(DWORD dwType, long lValue);
int GetStatus(DWORD dwType);
void SetGold64(int64_t gold);
bool PORT_ApplyCubeView(const PortCubeView::Frame&);
void ChangeGold64(int64_t amount);
int64_t GetGold64() const;
bool IsConqueror() const { return const_cast<CPythonPlayer*>(this)->GetStatus(POINT_CONQUEROR_LEVEL) >= 1; }
@@ -629,6 +631,8 @@ class CPythonPlayer : public CSingleton<CPythonPlayer>, public IAbstractPlayer
TPlayerStatus m_playerStatus;
int64_t m_i64Gold;
uint64_t m_portCubeViewEpoch=0; // PORT: presentation replay guard, reset on player Clear.
std::string m_portCubeViewBytes;
UINT m_iComboOld;
DWORD m_dwVIDReserved;
@@ -0,0 +1,34 @@
// PORT: one validated presentation commit; no Python callbacks while staging.
bool CPythonPlayer::PORT_ApplyCubeView(const PortCubeView::Frame& f)
{
static_assert(QUICKSLOT_MAX_NUM==PortCubeView::Quickslots,"Cube quickslot contract");
if(!PortCubeView::Valid(f))return false;
if(f.epoch<m_portCubeViewEpoch)return true; // PORT: never replay an older view over newer state.
auto canonical=PortCubeView::Encode(f);
if(f.epoch==m_portCubeViewEpoch)return canonical==m_portCubeViewBytes;
std::array<TItemData,PortCubeView::Slots> staged{};std::array<bool,PortCubeView::Slots> grid{};
for(const auto& row:f.items) {
CItemData* proto=nullptr;
if(!CItemManager::Instance().GetItemDataPointer(row.vnum,&proto)||!proto)return false;
const auto size=proto->GetSize();
if(size<1||size>3||(row.cell%45)/5+size>9||(!proto->IsFlag(CItemData::ITEM_FLAG_STACKABLE)&&row.count!=1))return false;
for(unsigned n=0;n<size;++n){const auto at=row.cell+5*n;if(at>=grid.size()||grid[at])return false;grid[at]=true;}
auto& item=staged[row.cell];item.vnum=row.vnum;item.count=row.count;item.portId=row.id;item.flags=row.flags;item.anti_flags=row.anti;
for(unsigned n=0;n<3;++n)item.alSockets[n]=row.sockets[n];
for(unsigned n=0;n<7;++n){item.aAttr[n].bType=row.types[n];item.aAttr[n].sValue=row.values[n];}
static_assert(sizeof(item.extra)==69,"complete presentation metadata");std::memcpy(&item.extra,row.extra,69);
}
for(const auto& slot:f.quickslots) {
if(slot.type==SLOT_TYPE_INVENTORY) {
bool valid=slot.cell<c_ItemSlot_Count;
#ifdef ENABLE_NEW_EQUIPMENT_SYSTEM
valid=valid||(slot.cell>=c_Belt_Inventory_Slot_Start&&slot.cell<c_Belt_Inventory_Slot_End);
#endif
if(!valid)return false;
if(slot.cell<PortCubeView::Slots&&!staged[slot.cell].vnum)return false;
} else if(slot.type==SLOT_TYPE_SKILL&&slot.cell>=SKILL_MAX_NUM)return false;
}
for(unsigned cell=0;cell<staged.size();++cell)m_playerStatus.aItem[cell]=staged[cell];
for(unsigned n=0;n<PortCubeView::Quickslots;++n){m_playerStatus.aQuickSlot[n].Type=f.quickslots[n].type;m_playerStatus.aQuickSlot[n].Position=f.quickslots[n].cell;}
SetGold64(int64_t(f.gold));m_portCubeViewEpoch=f.epoch;m_portCubeViewBytes=std::move(canonical);return true;
}
+1 -1
View File
@@ -181,7 +181,7 @@ PyObject * safeboxGetItemNewName(PyObject * poSelf, PyObject * poArgs)
if (!CPythonSafeBox::Instance().GetItemDataPtr(ipos, &pInstance))
return Py_BuildValue("s", "");
return Py_BuildValue("s", pInstance->extra.name);
return Py_BuildValue("s#", pInstance->extra.name,int(strnlen(pInstance->extra.name,24))); // PORT: raw metadata need not be NUL-terminated.
}
PyObject * safeboxGetItemCount(PyObject * poSelf, PyObject * poArgs)