From cb40b0808a639fa0de330cb2b88574a0e8b4d2d5 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Sat, 4 Mar 2023 17:49:03 -0400 Subject: TProtocol: Match ctor The reason for the large change is because I was trying to figure out why `TTcpSocket`'s ctor was so disjointed from the rest of the functions. Turns out, it's inlined, and inlining was turned off. Most likely, the whole codebase has inlining turned off. oof, press f `TArray`. --- src/pso/TPlyGuildCardTag.cpp | 5 ++ src/pso/TProtocol.cpp | 109 +++++++++++++++++++++++++++++++++++++++---- src/pso/TTcpSocket.cpp | 5 -- 3 files changed, 106 insertions(+), 13 deletions(-) (limited to 'src/pso') diff --git a/src/pso/TPlyGuildCardTag.cpp b/src/pso/TPlyGuildCardTag.cpp index 2626adc..021c644 100644 --- a/src/pso/TPlyGuildCardTag.cpp +++ b/src/pso/TPlyGuildCardTag.cpp @@ -16,6 +16,11 @@ void TPlyGuildCardTag::bswap() { bswap_16(&m_tag.tag2); } +TPlyGuildCardTag &TPlyGuildCardTag::operator=(const TPlyGuildCardTag &src) { + _assign(src); + return *this; +} + void TPlyGuildCardTag::assign(const TPlyGuildCardTag &src) { _assign(src); } diff --git a/src/pso/TProtocol.cpp b/src/pso/TProtocol.cpp index 41986d1..b0be8ee 100644 --- a/src/pso/TProtocol.cpp +++ b/src/pso/TProtocol.cpp @@ -11,26 +11,119 @@ #include "pso/TObject.h" #include "pso/TProtocol.h" #include "pso/TSocket.h" -#include "pso/TTcpSocket.h" +OBJECT_NAME(TProtocol); +void TProtocol::run_task() { -TProtocol::TProtocol(TObject *parent, u16 sub_version, int language, char *serial_number, char *access_key, char *password) : TTcpSocket(parent) { +} +int TProtocol::send(u8 *data, size_t size) { + return TTcpSocket::send(data, size); } -TProtocol::~TProtocol() { +int handle_command(packet *pkt) { } -void TProtocol::run_task() { +TProtocol::~TProtocol() { } -int TProtocol::send(u8 *data, size_t size) { - return TTcpSocket::send(data, size); -} +#define fill_with(name, value) memset(&m_##name, value, sizeof(m_##name)) +#define copy(name) strncpy(m_##name.m_data, name, sizeof(m_##name.m_data)) -int handle_command(packet *pkt) { +#pragma dont_inline on +TProtocol::TProtocol(TObject *parent, u16 sub_version, int language, char *serial_number, char *access_key, char *password) : TTcpSocket(parent) { + u8 thing[6]; + m_name = TProtocol_name; + memset(thing, 0, sizeof(thing)); + { + int i = 0; + int j = 0; + m_smth.m_smth.m_data[i++] = 0; + m_smth.m_smth.m_data[i++] = 0; + m_smth.m_smth.m_data[i++] = thing[j++]; + m_smth.m_smth.m_data[i++] = thing[j++]; + i = 0; + m_smth.m_smth1.m_data[i++] = thing[j++]; + m_smth.m_smth1.m_data[i++] = thing[j++]; + m_smth.m_smth1.m_data[i++] = thing[j++]; + m_smth.m_smth1.m_data[i++] = thing[j++]; + } + m_guildcard_tag = TPlyGuildCardTag(-1, -1); + m_login_response_state = 0; + m_connected = 0; + m_joined_game = 0; + m_has_meet_user_settings = 0; + m_buffer_ready = 0; + m_entry_count = 0; + m_unused = 0; + m_lobby_list_count = 0; + m_unused5.m_data[0] = 0; + m_unused2 = 0; + m_udp_disabled = 0; + m_packet_offset = 0; + m_packet_size = 0; + m_sub_version = sub_version; + m_language = language; + fill_with(serial_number, 0); + fill_with(access_key, 0); + fill_with(password, 0); + + copy(serial_number); + copy(access_key); + copy(password); + + fill_with(client_config, 0); + + m_recv_handlers.m_data[0] = nullptr; + m_recv_handlers.m_data[1] = nullptr; + m_recv_handlers.m_data[2] = nullptr; + m_recv_handlers.m_data[3] = nullptr; + m_recv_handlers.m_data[4] = nullptr; + m_recv_handlers.m_data[6] = nullptr; + m_recv_handlers.m_data[7] = nullptr; + m_recv_handlers.m_data[8] = nullptr; + m_recv_handlers.m_data[10] = nullptr; + m_recv_handlers.m_data[11] = nullptr; + m_recv_handlers.m_data[12] = nullptr; + m_recv_handlers.m_data[13] = nullptr; + m_recv_handlers.m_data[14] = nullptr; + m_recv_handlers.m_data[36] = nullptr; + m_recv_handlers.m_data[15] = nullptr; + m_recv_handlers.m_data[16] = nullptr; + m_recv_handlers.m_data[17] = nullptr; + m_recv_handlers.m_data[18] = nullptr; + m_recv_handlers.m_data[19] = nullptr; + m_recv_handlers.m_data[20] = nullptr; + m_recv_handlers.m_data[22] = nullptr; + m_recv_handlers.m_data[23] = nullptr; + m_recv_handlers.m_data[25] = nullptr; + m_recv_handlers.m_data[26] = nullptr; + m_recv_handlers.m_data[33] = nullptr; + m_recv_handlers.m_data[34] = nullptr; + m_recv_handlers.m_data[35] = nullptr; + m_recv_handlers.m_data[36] = nullptr; + m_recv_handlers.m_data[37] = nullptr; + m_recv_handlers.m_data[38] = nullptr; + m_recv_handlers.m_data[41] = nullptr; + m_recv_handlers.m_data[28] = nullptr; + m_recv_handlers.m_data[43] = nullptr; + m_recv_handlers.m_data[42] = nullptr; + m_recv_handlers.m_data[44] = nullptr; + m_recv_handlers.m_data[45] = nullptr; + m_recv_handlers.m_data[46] = nullptr; + m_recv_handlers.m_data[49] = nullptr; + m_recv_handlers.m_data[50] = nullptr; + m_recv_handlers.m_data[51] = nullptr; + m_recv_handlers.m_data[32] = nullptr; + m_recv_handlers.m_data[47] = nullptr; + m_recv_handlers.m_data[48] = nullptr; } + +void dummy(); +#pragma dont_inline off +#undef fill_with +#undef copy diff --git a/src/pso/TTcpSocket.cpp b/src/pso/TTcpSocket.cpp index 7244ad6..f105298 100644 --- a/src/pso/TTcpSocket.cpp +++ b/src/pso/TTcpSocket.cpp @@ -61,11 +61,6 @@ short tcp_receive(short nh, void (*notify)(short size, short sock_fd), short len int get_link_status(); char *get_sock_status_name(short code); - -WEAK_FUNC TTcpSocket::TTcpSocket(TObject *parent) : TSocket(parent) { - set_name(TTcpSocket_name); -} - TTcpSocket::~TTcpSocket() { close(); } -- cgit v1.2.3-13-gbd6f