From 0b0f3da43d281b75cc04a9333332f2abc1eff0c7 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Wed, 22 Mar 2023 15:34:08 -0300 Subject: TProtocol: Add (and match) more command senders --- src/pso/TProtocol.cpp | 158 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) (limited to 'src') diff --git a/src/pso/TProtocol.cpp b/src/pso/TProtocol.cpp index 5638a4d..1a992e3 100644 --- a/src/pso/TProtocol.cpp +++ b/src/pso/TProtocol.cpp @@ -24,6 +24,163 @@ void copy_packet(struct packet *pkt) { } +void TProtocol::send_text_list() { + if (m_connected) { + packet_header tmp; + + tmp.command = 0x1F; + tmp.flags = 0; + tmp.size = sizeof(tmp); + + tmp.bswap(); + send(as(u8 *, &tmp), sizeof(tmp)); + } +} + +void TProtocol::send_game_list() { + if (m_connected) { + packet_header tmp; + + tmp.command = 0x08; + tmp.flags = 0; + tmp.size = sizeof(tmp); + + tmp.bswap(); + send(as(u8 *, &tmp), sizeof(tmp)); + } +} + +void TProtocol::send_info(TPlyGuildCardTag &tag) { + if (m_connected) { + TSendAction<0> tmp; + + tmp.header.command = 0x09; + tmp.header.flags = 0; + tmp.header.size = sizeof(tmp); + tmp.tag = tag; + + tmp.bswap(); + send(as(u8 *, &tmp), sizeof(tmp)); + } +} +void TProtocol::send_action(GameListEntry &selection, u8 flags, char *action_name, char *password) { + if (m_connected) { + switch (selection.flags & 3) { + case 0: { + TSendAction<0> action; + + action.header.command = 0x10; + action.header.flags = flags; + action.header.size = sizeof(action); + action.tag = selection.tag; + + action.bswap(); + send(as(u8 *, &action), sizeof(action)); + break; + } + case 1: { + TSendAction<1> action; + + action.header.command = 0x10; + action.header.flags = 1; + action.header.size = sizeof(action); + action.tag = selection.tag; + strncpy(action.name, action_name, sizeof(action.name)); + + action.bswap(); + send(as(u8 *, &action), sizeof(action)); + break; + } + case 2: { + TSendAction<2> action; + + action.header.command = 0x10; + action.header.flags = 2; + action.header.size = sizeof(action); + action.tag = selection.tag; + strncpy(action.password, password, sizeof(action.password)); + + action.bswap(); + send(as(u8 *, &action), sizeof(action)); + break; + } + case 3: { + TSendAction<3> action; + + action.header.command = 0x10; + action.header.flags = 3; + action.header.size = sizeof(action); + action.tag = selection.tag; + strncpy(action.name, action_name, sizeof(action.name)); + strncpy(action.password, password, sizeof(action.password)); + + action.bswap(); + send(as(u8 *, &action), sizeof(action)); + break; + } + } + } +} + +void TProtocol::send_action(GameListEntry &selection, char *action_name, char *password) { + if (m_connected) { + switch (selection.flags & 3) { + case 0: { + TSendAction<0> action; + + action.header.command = 0x10; + action.header.flags = 0; + action.header.size = sizeof(action); + action.tag = selection.tag; + + action.bswap(); + send(as(u8 *, &action), sizeof(action)); + break; + } + case 1: { + TSendAction<1> action; + + action.header.command = 0x10; + action.header.flags = 1; + action.header.size = sizeof(action); + action.tag = selection.tag; + strncpy(action.name, action_name, sizeof(action.name)); + + action.bswap(); + send(as(u8 *, &action), sizeof(action)); + break; + } + case 2: { + TSendAction<2> action; + + action.header.command = 0x10; + action.header.flags = 2; + action.header.size = sizeof(action); + action.tag = selection.tag; + strncpy(action.password, password, sizeof(action.password)); + + action.bswap(); + send(as(u8 *, &action), sizeof(action)); + break; + } + case 3: { + TSendAction<3> action; + + action.header.command = 0x10; + action.header.flags = 3; + action.header.size = sizeof(action); + action.tag = selection.tag; + strncpy(action.name, action_name, sizeof(action.name)); + strncpy(action.password, password, sizeof(action.password)); + + action.bswap(); + send(as(u8 *, &action), sizeof(action)); + break; + } + } + } +} + void TProtocol::send_chat(TPlyGuildCardTag &tag, char *mesg) { if (m_connected) { TMessageBox tmp; @@ -43,6 +200,7 @@ void TProtocol::send_chat(TPlyGuildCardTag &tag, char *mesg) { send(as(u8 *, &tmp), size); } } + void TProtocol::send_logout() { packet_header tmp; tmp.command = 0x05; -- cgit v1.2.3-13-gbd6f