diff --git a/docs/AVA2-PACKET-CONSTANTS.json b/docs/AVA2-PACKET-CONSTANTS.json index 4186ec17..81245ed4 100644 --- a/docs/AVA2-PACKET-CONSTANTS.json +++ b/docs/AVA2-PACKET-CONSTANTS.json @@ -1,6 +1,6 @@ { "reference": "upstream/ava2-client/UserInterface/Packet.h preprocessed with AVA2 Windows feature headers", - "checked": 229, + "checked": 233, "mismatches": [], "unmatched": [] } diff --git a/docs/WINDOWS-PARITY.md b/docs/WINDOWS-PARITY.md index 7c40a572..446b235c 100644 --- a/docs/WINDOWS-PARITY.md +++ b/docs/WINDOWS-PARITY.md @@ -673,10 +673,28 @@ Validation: macOS build and Android arm64 libmain.so pass. Five targeted CTests - Eliminated Clang `constexpr switch` warnings in `nonplayer_value` template specialization (`src/python_native_modules.cpp`). - **Portable Asset Loading**: - Replaced developer absolute paths in `src/main.cpp` for `height.raw`, `tile.raw`, `attr.atr`, `metin2_map1.txt`, `property`, `water.wtr`, and `minimap.dds` with portable relative paths and safe fallbacks. -- **Results:** +- Results: - `python3 tools/audit_windows_parity.py`: **0 placeholder bindings**! - `python3 tools/audit_ava2_python_interfaces.py`: **46 Windows modules compared; 0 missing methods; 0 overlapping placeholder methods**! - CTest suite: **41/41 tests passed (100%)** including `ava2.render_3d`. - Android arm64 `libmain.so`: builds cleanly with 0 warnings. - macOS arm64 `ava2_client`: builds cleanly and runs 60fps game phase. +## 2026-10-07 pass30 — network protocol & observer stream alignment +- **Ping/Pong Protocol**: + - Replaced literal 44/254 handling in `src/eter_net/PythonNetworkStream.cpp` with `HEADER_GC_PING` and `HEADER_CG_PONG`. + - Added `TPacketGCPing` and `TPacketCGPong` wire structures in `src/eter_net/Packet.h`. + - Implemented `PythonNetworkStream::RecvPingPacket()` in `src/eter_net/PythonNetworkStreamPhaseGameRecv.cpp`. +- **Observer Packet Handlers**: + - Added `HEADER_GC_OBSERVER_ADD` (96), `HEADER_GC_OBSERVER_REMOVE` (97), and `HEADER_GC_OBSERVER_MOVE` (98) to `EPacketGC` in `src/eter_net/Packet.h`. + - Defined `TPacketGCObserverAdd`, `TPacketGCObserverMove`, and `TPacketGCObserverRemove` packed wire structures. + - Implemented `RecvObserverAddPacket()`, `RecvObserverRemovePacket()`, and `RecvObserverMovePacket()` in `PythonNetworkStreamPhaseGameRecv.cpp`, routing coordinates and VIDs directly to `CPythonMiniMap::Instance().{AddObserver, MoveObserver, RemoveObserver}`. + - Updated `src/eter_net/Ava2GcPacketTable.inc` entries for 96, 97, and 98 to valid mapped packets. +- **Wire Protocol Constants Clean-up**: + - Refactored `src/protocol.cpp` to use named `HEADER_CG_*` constants instead of magic numbers. +- **Results**: + - Checked packet constants increased to **233**, 0 mismatches, 0 unmatched. + - `python3 tools/audit_windows_parity.py`: **0 placeholder bindings**. + - `python3 tools/audit_ava2_python_interfaces.py`: **46 Windows modules compared; 0 missing methods; 0 overlapping placeholder methods**. + - CTest suite: **41/41 tests passed (100%)**. + - Android arm64 `libmain.so` builds cleanly. diff --git a/src/eter_net/Ava2GcPacketTable.inc b/src/eter_net/Ava2GcPacketTable.inc index 1563a28e..d0f4377f 100644 --- a/src/eter_net/Ava2GcPacketTable.inc +++ b/src/eter_net/Ava2GcPacketTable.inc @@ -76,9 +76,9 @@ {92, 9, 0, 1, 1}, {93, 5, 1, 1, 1}, {95, 65, 0, 1, 1}, - {96, 0, 0, 0, 1}, - {97, 0, 0, 0, 1}, - {98, 0, 0, 0, 1}, + {96, 9, 0, 1, 1}, + {97, 9, 0, 1, 1}, + {98, 9, 0, 1, 1}, {99, 3397, 0, 1, 1}, {106, 5, 0, 1, 1}, {107, 30, 0, 1, 0}, diff --git a/src/eter_net/Packet.h b/src/eter_net/Packet.h index ba843e0f..e0105044 100644 --- a/src/eter_net/Packet.h +++ b/src/eter_net/Packet.h @@ -202,6 +202,7 @@ enum EPacketGC { HEADER_GC_EVENT_MANAGER = 39, HEADER_GC_PVP = 41, HEADER_GC_CHARACTER_POSITION = 43, + HEADER_GC_PING = 44, HEADER_GC_SCRIPT = 45, HEADER_GC_QUEST_CONFIRM = 46, HEADER_GC_OFFLINE_SHOP_SIGN = 48, @@ -221,6 +222,9 @@ enum EPacketGC { HEADER_GC_PARTY_LINK = 91, HEADER_GC_PARTY_UNLINK = 92, HEADER_GC_REFINE_INFORMATION = 95, + HEADER_GC_OBSERVER_ADD = 96, + HEADER_GC_OBSERVER_REMOVE = 97, + HEADER_GC_OBSERVER_MOVE = 98, HEADER_GC_VIEW_EQUIP = 99, HEADER_GC_DUNGEON = 110, HEADER_GC_WALK_MODE = 111, @@ -337,6 +341,10 @@ struct TQuickSlot { // ── Client to Server Wire Packets ── +struct TPacketCGPong { + uint8_t bHeader = HEADER_CG_PONG; +}; + struct TPacketCGAttack { uint8_t header; uint8_t bType; @@ -457,6 +465,29 @@ struct TPacketGCPhase { uint8_t phase; }; +struct TPacketGCPing { + uint8_t header = HEADER_GC_PING; +}; + +struct TPacketGCObserverAdd { + uint8_t header = HEADER_GC_OBSERVER_ADD; + uint32_t vid = 0; + uint16_t x = 0; + uint16_t y = 0; +}; + +struct TPacketGCObserverMove { + uint8_t header = HEADER_GC_OBSERVER_MOVE; + uint32_t vid = 0; + uint16_t x = 0; + uint16_t y = 0; +}; + +struct TPacketGCObserverRemove { + uint8_t header = HEADER_GC_OBSERVER_REMOVE; + uint32_t vid = 0; +}; + struct TPacketGCTime { uint8_t bHeader;int32_t time; }; struct TPacketGCPoints { uint8_t header;int64_t points[255]; }; diff --git a/src/eter_net/PythonNetworkStream.cpp b/src/eter_net/PythonNetworkStream.cpp index 9ca3287f..a929e402 100644 --- a/src/eter_net/PythonNetworkStream.cpp +++ b/src/eter_net/PythonNetworkStream.cpp @@ -262,7 +262,8 @@ bool PythonNetworkStream::DispatchGamePhasePacket(uint8_t header,bool& ret) { bool PythonNetworkStream::DispatchPortedGamePhasePacket(uint8_t header) { switch (header) { - case 44: { uint8_t ping;if(!Read(1,&ping)) return false;const uint8_t pong=254;Send(&pong,1);return true; } + case HEADER_GC_PING: + return RecvPingPacket(); case HEADER_GC_PHASE: return RecvPhasePacket(); case HEADER_GC_SHOP: return RecvShopPacket(); @@ -335,6 +336,12 @@ bool PythonNetworkStream::DispatchPortedGamePhasePacket(uint8_t header) { return RecvCreateFlyPacket(); case HEADER_GC_WARP: return RecvWarpPacket(); + case HEADER_GC_OBSERVER_ADD: + return RecvObserverAddPacket(); + case HEADER_GC_OBSERVER_REMOVE: + return RecvObserverRemovePacket(); + case HEADER_GC_OBSERVER_MOVE: + return RecvObserverMovePacket(); case HEADER_GC_EXCHANGE: return RecvExchangePacket(); case HEADER_GC_SAFEBOX_SET: diff --git a/src/eter_net/PythonNetworkStream.h b/src/eter_net/PythonNetworkStream.h index 5bf522a8..d9b187fe 100644 --- a/src/eter_net/PythonNetworkStream.h +++ b/src/eter_net/PythonNetworkStream.h @@ -252,6 +252,10 @@ private: bool RecvQuickSlotMovePacket(); bool RecvCreateFlyPacket(); bool RecvWarpPacket(); + bool RecvPingPacket(); + bool RecvObserverAddPacket(); + bool RecvObserverRemovePacket(); + bool RecvObserverMovePacket(); bool RecvExchangePacket(); bool RecvShopPacket(); bool RecvOfflineShopPacket(); diff --git a/src/eter_net/PythonNetworkStreamPhaseGameRecv.cpp b/src/eter_net/PythonNetworkStreamPhaseGameRecv.cpp index 39b84579..064b282d 100644 --- a/src/eter_net/PythonNetworkStreamPhaseGameRecv.cpp +++ b/src/eter_net/PythonNetworkStreamPhaseGameRecv.cpp @@ -1352,4 +1352,35 @@ bool PythonNetworkStream::RecvOfflineShopPacket() { } call("RefreshOfflineShop",Py_BuildValue("()"));return true; } + +bool PythonNetworkStream::RecvPingPacket() { + TPacketGCPing packet; + if (!Read(sizeof(packet), &packet)) return false; + TPacketCGPong pong; + pong.bHeader = HEADER_CG_PONG; + Send(&pong, sizeof(pong)); + return true; } + +bool PythonNetworkStream::RecvObserverAddPacket() { + TPacketGCObserverAdd packet; + if (!Read(sizeof(packet), &packet)) return false; + CPythonMiniMap::Instance().AddObserver(packet.vid, packet.x * 100.0f, packet.y * 100.0f); + return true; +} + +bool PythonNetworkStream::RecvObserverRemovePacket() { + TPacketGCObserverAdd packet; + if (!Read(sizeof(packet), &packet)) return false; + CPythonMiniMap::Instance().RemoveObserver(packet.vid); + return true; +} + +bool PythonNetworkStream::RecvObserverMovePacket() { + TPacketGCObserverMove packet; + if (!Read(sizeof(packet), &packet)) return false; + CPythonMiniMap::Instance().MoveObserver(packet.vid, packet.x * 100.0f, packet.y * 100.0f); + return true; +} +} + diff --git a/src/protocol.cpp b/src/protocol.cpp index 711db635..16b7cd52 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -1,4 +1,5 @@ #include "protocol.h" +#include "eter_net/Packet.h" #include #include @@ -15,11 +16,11 @@ void u32(Bytes& out, std::uint32_t v) { Bytes select_character(std::uint8_t slot) { if (slot >= 5) throw std::out_of_range("AVA2 character slot must be 0..4"); - return {6, slot}; + return {HEADER_CG_CHARACTER_SELECT, slot}; } Bytes attack(std::uint8_t type, std::uint32_t victim, std::uint8_t process_crc, std::uint8_t file_crc) { - Bytes out{225, type}; + Bytes out{HEADER_CG_ATTACK, type}; u32(out, victim); out.push_back(process_crc); out.push_back(file_crc); @@ -27,13 +28,13 @@ Bytes attack(std::uint8_t type, std::uint32_t victim, std::uint8_t process_crc, } Bytes pickup(std::uint32_t vid) { - Bytes out{15}; + Bytes out{HEADER_CG_ITEM_PICKUP}; u32(out, vid); return out; } Bytes character_move(std::uint8_t func, std::uint8_t arg, std::uint8_t rot, std::int32_t x, std::int32_t y, std::uint32_t time) { - Bytes out{7, func, arg, rot}; + Bytes out{HEADER_CG_MOVE, func, arg, rot}; u32(out, static_cast(x)); u32(out, static_cast(y)); u32(out, time); @@ -41,13 +42,13 @@ Bytes character_move(std::uint8_t func, std::uint8_t arg, std::uint8_t rot, std: } Bytes item_use(std::uint8_t window_type, std::uint16_t cell) { - Bytes out{11, window_type}; + Bytes out{HEADER_CG_ITEM_USE, window_type}; u16(out, cell); return out; } Bytes item_move(std::uint8_t src_window, std::uint16_t src_cell, std::uint8_t dst_window, std::uint16_t dst_cell, std::uint32_t count) { - Bytes out{13, src_window}; + Bytes out{HEADER_CG_ITEM_MOVE, src_window}; u16(out, src_cell); out.push_back(dst_window); u16(out, dst_cell); @@ -56,7 +57,7 @@ Bytes item_move(std::uint8_t src_window, std::uint16_t src_cell, std::uint8_t ds } Bytes item_drop(std::uint8_t window_type, std::uint16_t cell, std::uint32_t count) { - Bytes out{224, window_type}; + Bytes out{HEADER_CG_ITEM_DROP, window_type}; u16(out, cell); u32(out, count); return out; @@ -64,7 +65,7 @@ Bytes item_drop(std::uint8_t window_type, std::uint16_t cell, std::uint32_t coun Bytes chat(const std::string& text, std::uint8_t type) { if(text.empty() || text.size()>=512) return {}; - Bytes out{231}; + Bytes out{HEADER_CG_CHAT}; std::uint16_t size = static_cast(5 + text.size()); u16(out, size); out.push_back(type); @@ -75,7 +76,7 @@ Bytes chat(const std::string& text, std::uint8_t type) { Bytes whisper(const std::string& name, const std::string& text) { if(text.size()>=255) return {}; - Bytes out{19}; + Bytes out{HEADER_CG_WHISPER}; std::uint16_t size = static_cast(3 + 25 + text.size() + 1); u16(out, size); char nameBuf[25] = {0}; @@ -87,21 +88,21 @@ Bytes whisper(const std::string& name, const std::string& text) { } Bytes entergame(std::uint8_t language) { - return {10,language}; + return {HEADER_CG_ENTERGAME, language}; } Bytes on_click(std::uint32_t vid) { - Bytes out{26}; + Bytes out{HEADER_CG_ON_CLICK}; u32(out, vid); return out; } Bytes warp() { - return {65}; + return {HEADER_CG_WARP}; } Bytes fly_targeting(std::uint32_t target_vid, std::int32_t x, std::int32_t y) { - Bytes out{51}; + Bytes out{HEADER_CG_FLY_TARGETING}; u32(out, target_vid); u32(out, static_cast(x)); u32(out, static_cast(y));