From c77e65c07dfd91d78995c8ea2c448530dcd9752e Mon Sep 17 00:00:00 2001 From: KimLS Date: Sat, 19 Nov 2016 15:50:22 -0800 Subject: [PATCH] More HC work, almost fully logs in --- common/net/daybreak_connection.cpp | 2 + common/net/daybreak_connection.h | 2 +- hc/eq.cpp | 70 +++++++++++++++++------------- hc/eq.h | 3 ++ ucs/clientlist.cpp | 1 + 5 files changed, 47 insertions(+), 31 deletions(-) diff --git a/common/net/daybreak_connection.cpp b/common/net/daybreak_connection.cpp index ddf578ef9..2a8784b39 100644 --- a/common/net/daybreak_connection.cpp +++ b/common/net/daybreak_connection.cpp @@ -731,6 +731,8 @@ void EQ::Net::DaybreakConnection::ProcessDecodedPacket(const Packet &p) InternalSend(out); break; } + case OP_SessionStatResponse: + break; default: Log.OutF(Logs::Detail, Logs::Netcode, "Unhandled opcode {0:#x}", p.GetInt8(1)); break; diff --git a/common/net/daybreak_connection.h b/common/net/daybreak_connection.h index f5f349860..c9d01e473 100644 --- a/common/net/daybreak_connection.h +++ b/common/net/daybreak_connection.h @@ -222,7 +222,7 @@ namespace EQ resend_delay_factor = 1.5; stats_delay_ms = 9000; connect_delay_ms = 250; - stale_connection_ms = 30000; + stale_connection_ms = 60000; connect_stale_ms = 5000; crc_length = 2; max_packet_size = 512; diff --git a/hc/eq.cpp b/hc/eq.cpp index 4531ffbf7..aab481e82 100644 --- a/hc/eq.cpp +++ b/hc/eq.cpp @@ -287,41 +287,14 @@ void EverQuest::WorldOnStatusChangeReconnectDisabled(std::shared_ptr conn, const EQ::Net::Packet & p) { - Log.OutF(Logs::General, Logs::Headless_Client, "Packet in:\n{0}", p.ToString()); auto opcode = p.GetUInt16(0); switch (opcode) { - case 0x7499: - Log.OutF(Logs::General, Logs::Headless_Client, "OP_ApproveWorld"); - break; - case 0x7ceb: - Log.OutF(Logs::General, Logs::Headless_Client, "OP_LogServer"); - break; - case 0x578f: - Log.OutF(Logs::General, Logs::Headless_Client, "OP_EnterWorld"); - break; - case 0x6259: - Log.OutF(Logs::General, Logs::Headless_Client, "OP_PostEnterWorld"); - break; - case 0x590d: - Log.OutF(Logs::General, Logs::Headless_Client, "OP_ExpansionInfo"); - break; - case 0x507a: - Log.OutF(Logs::General, Logs::Headless_Client, "OP_GuildsList"); - break; - case 0x5475: - Log.OutF(Logs::General, Logs::Headless_Client, "OP_SendMaxCharacters"); - break; - case 0x7acc: - Log.OutF(Logs::General, Logs::Headless_Client, "OP_SendMembership"); - break; - case 0x057b: - Log.OutF(Logs::General, Logs::Headless_Client, "OP_SendMembershipDetails"); - break; case 0x00d2: - Log.OutF(Logs::General, Logs::Headless_Client, "OP_SendCharInfo"); + WorldProcessCharacterSelect(p); break; default: - Log.OutF(Logs::General, Logs::Headless_Client, "Ignored packet: {0:#x}", opcode); + Log.OutF(Logs::General, Logs::Headless_Client, "Unhandled opcode: {0:#x}", opcode); + break; } } @@ -338,3 +311,40 @@ void EverQuest::WorldSendClientAuth() m_world_connection->QueuePacket(p); } + +void EverQuest::WorldSendEnterWorld(const std::string &character) +{ + EQ::Net::DynamicPacket p; + p.PutUInt16(0, 0x578f); + p.PutString(2, character); + p.PutUInt32(66, 0); + p.PutUInt32(70, 0); + + m_world_connection->QueuePacket(p); +} + +void EverQuest::WorldProcessCharacterSelect(const EQ::Net::Packet &p) +{ + auto char_count = p.GetUInt32(2); + size_t idx = 6; + + //Log.OutF(Logs::General, Logs::Headless_Client, "{0} characters", char_count); + for (uint32_t i = 0; i < char_count; ++i) { + auto name = p.GetCString(idx); + idx += name.length() + 1; + + auto pclass = p.GetUInt8(idx); + auto prace = p.GetUInt32(idx + 1); + auto plevel = p.GetUInt8(idx + 5); + + idx += 274; + if (m_character.compare(name) == 0) { + Log.OutF(Logs::General, Logs::Headless_Client, "Found {0}, would attempt to login here.", m_character); + WorldSendEnterWorld(m_character); + return; + } + } + + Log.OutF(Logs::General, Logs::Headless_Client, "Could not find {0}, cannot continue to login.", m_character); +} + \ No newline at end of file diff --git a/hc/eq.h b/hc/eq.h index c47b094ac..7cdbfe1cd 100644 --- a/hc/eq.h +++ b/hc/eq.h @@ -54,6 +54,9 @@ private: void WorldOnPacketRecv(std::shared_ptr conn, const EQ::Net::Packet &p); void WorldSendClientAuth(); + void WorldSendEnterWorld(const std::string &character); + + void WorldProcessCharacterSelect(const EQ::Net::Packet &p); std::unique_ptr m_world_connection_manager; std::shared_ptr m_world_connection; diff --git a/ucs/clientlist.cpp b/ucs/clientlist.cpp index feb1c8992..df812e8c0 100644 --- a/ucs/clientlist.cpp +++ b/ucs/clientlist.cpp @@ -469,6 +469,7 @@ static void ProcessCommandIgnore(Client *c, std::string Ignoree) { Clientlist::Clientlist(int ChatPort) { EQ::Net::EQStreamManagerOptions chat_opts(ChatPort, false, false); chat_opts.opcode_size = 1; + chat_opts.daybreak_options.stale_connection_ms = 300000; chatsf = new EQ::Net::EQStreamManager(chat_opts); ChatOpMgr = new RegularOpcodeManager;