summaryrefslogtreecommitdiff
path: root/src/pso
diff options
context:
space:
mode:
Diffstat (limited to 'src/pso')
-rw-r--r--src/pso/TProtocol.cpp151
1 files changed, 147 insertions, 4 deletions
diff --git a/src/pso/TProtocol.cpp b/src/pso/TProtocol.cpp
index 3b7cbd3..3c410aa 100644
--- a/src/pso/TProtocol.cpp
+++ b/src/pso/TProtocol.cpp
@@ -24,6 +24,149 @@ void copy_packet(struct packet *pkt) {
}
+void TProtocol::send_create_game(char *name, char *password, u8 difficulty, u8 battle_mode, u8 challenge_mode, u8 episode) {
+ if (m_connected) {
+ TCreateGame tmp;
+ tmp.header.command = 0xC1;
+ tmp.header.flags = 3;
+ tmp.header.size = sizeof(tmp);
+ tmp.tag = TPlyGuildCardTag(0, 0);
+ tmp.difficulty = difficulty;
+ tmp.battle_mode = battle_mode;
+ tmp.challenge_mode = challenge_mode;
+ tmp.episode = episode;
+ strncpy(tmp.name, name, sizeof(tmp.name));
+ strncpy(tmp.password, password, sizeof(tmp.password));
+ tmp.bswap();
+ send(as(u8 *, &tmp), sizeof(tmp));
+ }
+}
+
+void TProtocol::send_find_user(TPlyGuildCardTag &tag, u32 gc_num) {
+ if (m_connected) {
+ TFindUser tmp;
+ memset(&tmp, 0, sizeof(tmp));
+ tmp.header.command = 0x40;
+ tmp.header.size = sizeof(tmp);
+ tmp.tag = tag;
+ tmp.target_gc = gc_num;
+ tmp.bswap();
+ send(as(u8 *, &tmp), sizeof(tmp));
+ }
+}
+
+void TProtocol::send_room_change(int idx) {
+ if (m_connected) {
+ TRoomChange tmp;
+ tmp.header.command = 0x84;
+ tmp.header.flags = 0;
+ tmp.header.size = sizeof(tmp);
+ tmp.tag = m_lobby_entries[idx].tag;
+ tmp.bswap();
+ send(as(u8 *, &tmp), sizeof(tmp));
+ }
+}
+
+void TProtocol::send_pso_data_long2(char flags, long_game_command &packet, size_t size) {
+ const int header_size = sizeof(packet_header);
+ const int command_size = sizeof(long_game_command);
+ if (m_connected) {
+ TRecvPsoDataLong *tmp = new TRecvPsoDataLong;
+ u8 *pkt = as(u8 *, tmp);
+ int packet_size;
+ int cmd_count;
+ int leftover;
+ int offset;
+
+ memcpy(tmp->data.bytes, &packet, size);
+ tmp->header.command = 0x6d;
+ tmp->header.flags = flags;
+ tmp->header.size = size + header_size;
+ tmp->bswap();
+
+ packet_size = (int)size + header_size;
+ cmd_count = packet_size/command_size;
+ leftover = packet_size - (cmd_count * command_size);
+
+ for (offset = 0; cmd_count > 0; --cmd_count, offset += command_size) {
+ if (test_connection()) {
+ goto end;
+ } else {
+ send(&pkt[offset], command_size);
+ }
+ }
+
+ if (!test_connection() && leftover > 0) {
+ send(&pkt[offset], leftover);
+ }
+
+ end:
+ delete tmp;
+ }
+}
+
+void TProtocol::send_pso_data2(u32 flags, game_command &packet, u32 size) {
+ char tmp_str[128];
+ sprintf(tmp_str, "SndPsoData2 %d %d %d", packet.header.command, size, flags);
+ if (m_connected) {
+ TRecvPsoData tmp;
+ int packet_size;
+ packet_size = (u16)(size + sizeof(packet_header));
+ tmp.header.command = 0x62;
+ tmp.header.flags = flags;
+ packet_size = (u16)(size + sizeof(packet_header));
+ tmp.header.size = packet_size;
+ memcpy(&tmp.data, &packet, size);
+ tmp.bswap();
+ send(as(u8 *, &tmp), packet_size);
+ }
+}
+
+void TProtocol::send_pso_data(game_command &packet, u32 size) {
+ char tmp_str[128];
+ sprintf(tmp_str, "SndPsoData %d %d", packet.header.command, size);
+ if (m_connected) {
+ TRecvPsoData tmp;
+ int packet_size;
+ tmp.header.command = 0x60;
+ tmp.header.flags = 0;
+ packet_size = (u16)(size + sizeof(packet_header));
+ tmp.header.size = packet_size;
+ memcpy(&tmp.data, &packet, (u32)size);
+ tmp.bswap();
+ send(as(u8 *, &tmp), packet_size);
+ }
+}
+
+void TProtocol::send_update_chara_data_v2(TPlyCharData &char_data, TPlyChallenge &challenge, TPlyChoiceSearchConfig &choice_search_config, TBlockedSenders &blocked_senders, TPlyText<512> &auto_reply, char *info_board) {
+ if (m_connected) {
+ char_data.m_disp_data.m_disp_part2.is_valid();
+ m_character_data = char_data;
+ TPlyJoinData tmp;
+ memset(&tmp, 0, sizeof(tmp));
+
+
+ tmp.header.command = 0x98;
+ tmp.header.flags = 3;
+ tmp.header.size = sizeof(tmp);
+ tmp.char_data = m_character_data;
+ tmp.challenge = challenge;
+ tmp.choice_search_config = choice_search_config;
+ strncpy(tmp.info_board, info_board, sizeof(tmp.info_board));
+ for (int i = 0; i < blocked_senders.header.flags; ++i) {
+ tmp.blocked_senders[i] = blocked_senders.blocked_senders[i];
+ }
+ tmp.auto_reply_enabled = auto_reply.header.flags;
+ strncpy(tmp.auto_reply, auto_reply.text, sizeof(tmp.auto_reply)-1);
+ const int packet_size = strlen(tmp.auto_reply) + offsetof(TPlyJoinData, auto_reply) + sizeof(packet_header);
+
+ tmp.header.size = packet_size & ~3;
+ tmp.char_data.some_stub();
+ tmp.bswap();
+ send(as(u8 *, &tmp), packet_size & ~3);
+ }
+}
+
void TProtocol::send_chara_data_v2(TPlyCharData &char_data, TPlyChallenge &challenge, TPlyChoiceSearchConfig &choice_search_config, TBlockedSenders &blocked_senders, TPlyText<512> &auto_reply, char *info_board) {
if (m_connected) {
char_data.m_disp_data.m_disp_part2.is_valid();
@@ -399,15 +542,15 @@ void TProtocol::recv_generate_id(packet &pkt) {
};
void TProtocol::recv_pso_data_long(packet &pkt) {
- TRecvPsoData &tmp = as(TRecvPsoData &, pkt);
- pkt.pkt.bswap();
- tmp.data.recv_pso_data_buf(tmp.header.size - 4);
+ TRecvPsoDataLong &tmp = as(TRecvPsoDataLong &, pkt);
+ tmp.bswap();
+ tmp.data.recv_pso_data_buf(tmp.header.size - sizeof(packet_header));
};
void TProtocol::recv_pso_data(packet &pkt) {
TRecvPsoData tmp = as(TRecvPsoData &, pkt);
tmp.bswap();
- tmp.data.recv_pso_data_buf(tmp.header.size - 4);
+ tmp.data.recv_pso_data_buf(tmp.header.size - sizeof(packet_header));
};
void TProtocol::recv_system_file(packet &pkt) {};