feat(network): align ping/pong and observer packets with Windows reference (pass30)
This commit is contained in:
@@ -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},
|
||||
|
||||
@@ -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]; };
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+14
-13
@@ -1,4 +1,5 @@
|
||||
#include "protocol.h"
|
||||
#include "eter_net/Packet.h"
|
||||
#include <stdexcept>
|
||||
#include <cstring>
|
||||
|
||||
@@ -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<std::uint32_t>(x));
|
||||
u32(out, static_cast<std::uint32_t>(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<std::uint16_t>(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<std::uint16_t>(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<std::uint32_t>(x));
|
||||
u32(out, static_cast<std::uint32_t>(y));
|
||||
|
||||
Reference in New Issue
Block a user