From a7c1c85f716c70487d31190380744f0ca9628241 Mon Sep 17 00:00:00 2001 From: KimLS Date: Fri, 18 Oct 2024 17:18:37 -0700 Subject: [PATCH] Initial --- common/CMakeLists.txt | 14 +++- common/emu_versions.h | 3 +- common/patches/larion.cpp | 129 +++++++++++++++++++++++++++++++ common/patches/larion.h | 55 +++++++++++++ common/patches/larion_limits.cpp | 18 +++++ common/patches/larion_limits.h | 31 ++++++++ common/patches/larion_ops.h | 6 ++ common/patches/larion_structs.h | 33 ++++++++ common/patches/patches.cpp | 4 +- 9 files changed, 290 insertions(+), 3 deletions(-) create mode 100644 common/patches/larion.cpp create mode 100644 common/patches/larion.h create mode 100644 common/patches/larion_limits.cpp create mode 100644 common/patches/larion_limits.h create mode 100644 common/patches/larion_ops.h create mode 100644 common/patches/larion_structs.h diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 3b06c0e1f..dcc778bf2 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -111,6 +111,8 @@ SET(common_sources net/websocket_server.cpp net/websocket_server_connection.cpp patches/patches.cpp + patches/larion.cpp + patches/larion_limits.cpp patches/sod.cpp patches/sod_limits.cpp patches/sof.cpp @@ -653,7 +655,11 @@ SET(common_headers net/websocket_server.h net/websocket_server_connection.h patches/patches.h - patches/sod.h + patches/larion.h + patches/larion_limits.h + patches/larion_ops.h + patches/larion_structs.h + patches/sod.h patches/sod_limits.h patches/sod_ops.h patches/sod_structs.h @@ -739,6 +745,10 @@ SOURCE_GROUP(Net FILES SOURCE_GROUP(Patches FILES patches/patches.h + patches/larion.h + patches/larion_limits.h + patches/larion_ops.h + patches/larion_structs.h patches/sod.h patches/sod_limits.h patches/sod_ops.h @@ -767,6 +777,8 @@ SOURCE_GROUP(Patches FILES patches/uf_ops.h patches/uf_structs.h patches/patches.cpp + patches/larion.cpp + patches/larion_limits.cpp patches/sod.cpp patches/sod_limits.cpp patches/sof.cpp diff --git a/common/emu_versions.h b/common/emu_versions.h index 75f6808c3..16315cf3f 100644 --- a/common/emu_versions.h +++ b/common/emu_versions.h @@ -36,7 +36,8 @@ namespace EQ SoD, // Build: 'Dec 19 2008 15:22:49' UF, // Build: 'Jun 8 2010 16:44:32' RoF, // Build: 'Dec 10 2012 17:35:44' - RoF2 // Build: 'May 10 2013 23:30:08' + RoF2, // Build: 'May 10 2013 23:30:08' + Larion }; enum ClientVersionBitmask : uint32 { diff --git a/common/patches/larion.cpp b/common/patches/larion.cpp new file mode 100644 index 000000000..460d0d1b5 --- /dev/null +++ b/common/patches/larion.cpp @@ -0,0 +1,129 @@ +/* EQEMu: Everquest Server Emulator + + Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY except by those people which sell it, which + are required to give you total support for your newly bought product; + without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "../global_define.h" +#include "../eqemu_config.h" +#include "../eqemu_logsys.h" +#include "larion.h" +#include "../opcodemgr.h" + +#include "../eq_stream_ident.h" +#include "../crc32.h" + +#include "../eq_packet_structs.h" +#include "../misc_functions.h" +#include "../strings.h" +#include "../inventory_profile.h" +#include "larion_structs.h" +#include "../rulesys.h" +#include "../path_manager.h" +#include "../classes.h" +#include "../races.h" +#include "../raid.h" + +#include +#include +#include +#include +#include + +namespace Larion +{ + static const char* name = "Larion"; + static OpcodeManager* opcodes = nullptr; + static Strategy struct_strategy; + + void Register(EQStreamIdentifier& into) + { + //create our opcode manager if we havent already + if (opcodes == nullptr) { + + std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name); + + //load up the opcode manager. + //TODO: figure out how to support shared memory with multiple patches... + opcodes = new RegularOpcodeManager(); + if (!opcodes->LoadOpcodes(opfile.c_str())) { + LogNetcode("[OPCODES] Error loading opcodes file [{}]. Not registering patch [{}]", opfile.c_str(), name); + return; + } + } + + //ok, now we have what we need to register. + + EQStreamInterface::Signature signature; + std::string pname; + + //register our world signature. + pname = std::string(name) + "_world"; + signature.ignore_eq_opcode = 0; + signature.first_length = sizeof(structs::LoginInfo_Struct); + signature.first_eq_opcode = opcodes->EmuToEQ(OP_SendLoginInfo); + into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy); + + //register our zone signature. + pname = std::string(name) + "_zone"; + signature.ignore_eq_opcode = opcodes->EmuToEQ(OP_AckPacket); + signature.first_length = sizeof(structs::ClientZoneEntry_Struct); + signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry); + into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy); + LogNetcode("[StreamIdentify] Registered patch [{}]", name); + } + + void Reload() + { + //we have a big problem to solve here when we switch back to shared memory + //opcode managers because we need to change the manager pointer, which means + //we need to go to every stream and replace it's manager. + + if (opcodes != nullptr) { + std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name); + if (!opcodes->ReloadOpcodes(opfile.c_str())) { + LogNetcode("[OPCODES] Error reloading opcodes file [{}] for patch [{}]", opfile.c_str(), name); + return; + } + LogNetcode("[OPCODES] Reloaded opcodes for patch [{}]", name); + } + } + + Strategy::Strategy() : StructStrategy() + { + //all opcodes default to passthrough. +#include "ss_register.h" +#include "larion_ops.h" + } + + std::string Strategy::Describe() const + { + std::string r; + r += "Patch "; + r += name; + return(r); + } + + const EQ::versions::ClientVersion Strategy::ClientVersion() const + { + return EQ::versions::ClientVersion::Larion; + } + +#include "ss_define.h" + + // ENCODE methods + // DECODE methods +} /*Larion*/ diff --git a/common/patches/larion.h b/common/patches/larion.h new file mode 100644 index 000000000..7d7b83e32 --- /dev/null +++ b/common/patches/larion.h @@ -0,0 +1,55 @@ +/* EQEMu: Everquest Server Emulator + + Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY except by those people which sell it, which + are required to give you total support for your newly bought product; + without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef COMMON_LARION_H +#define COMMON_LARION_H + +#include "../struct_strategy.h" + +class EQStreamIdentifier; + +namespace Larion +{ + + //these are the only public member of this namespace. + extern void Register(EQStreamIdentifier& into); + extern void Reload(); + + + + //you should not directly access anything below.. + //I just dont feel like making a seperate header for it. + + class Strategy : public StructStrategy { + public: + Strategy(); + + protected: + + virtual std::string Describe() const; + virtual const EQ::versions::ClientVersion ClientVersion() const; + + //magic macro to declare our opcode processors +#include "ss_declare.h" +#include "larion_ops.h" + }; + +}; /*Larion*/ + +#endif /*COMMON_LARION_H*/ diff --git a/common/patches/larion_limits.cpp b/common/patches/larion_limits.cpp new file mode 100644 index 000000000..273e74a5c --- /dev/null +++ b/common/patches/larion_limits.cpp @@ -0,0 +1,18 @@ +/* EQEMu: Everquest Server Emulator + + Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY except by those people which sell it, which + are required to give you total support for your newly bought product; + without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ diff --git a/common/patches/larion_limits.h b/common/patches/larion_limits.h new file mode 100644 index 000000000..2ac784c91 --- /dev/null +++ b/common/patches/larion_limits.h @@ -0,0 +1,31 @@ +/* EQEMu: Everquest Server Emulator + + Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY except by those people which sell it, which + are required to give you total support for your newly bought product; + without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef COMMON_LARION_LIMITS_H +#define COMMON_LARION_LIMITS_H + + +namespace Larion +{ + + // put constants here and #include appropriately + +}; /* Larion */ + +#endif /*COMMON_LARION_LIMITS_H*/ diff --git a/common/patches/larion_ops.h b/common/patches/larion_ops.h new file mode 100644 index 000000000..4ef87be2b --- /dev/null +++ b/common/patches/larion_ops.h @@ -0,0 +1,6 @@ + +//list of packets we need to encode on the way out: +//list of packets we need to decode on the way in: + +#undef E +#undef D diff --git a/common/patches/larion_structs.h b/common/patches/larion_structs.h new file mode 100644 index 000000000..cd81f7915 --- /dev/null +++ b/common/patches/larion_structs.h @@ -0,0 +1,33 @@ +#ifndef LARION_STRUCTS_H_ +#define LARION_STRUCTS_H_ + +namespace Larion { + namespace structs { + struct LoginInfo_Struct { + /*000*/ char login_info[64]; + /*064*/ uint8 unknown064[124]; + /*188*/ uint8 zoning; // 01 if zoning, 00 if not + /*189*/ uint8 unknown189[275]; + /*488*/ + }; + + struct ClientZoneEntry_Struct { + /*00*/ uint32 unknown00; // ***Placeholder + /*04*/ char char_name[64]; // Player firstname [32] + /*68*/ uint32 unknown68; + /*72*/ uint32 unknown72; + }; + }; //end namespace structs +}; //end namespace larion + +#endif /*LARION_STRUCTS_H_*/ + + + + + + + + + + diff --git a/common/patches/patches.cpp b/common/patches/patches.cpp index 775e4e3dc..3a1a0fb6e 100644 --- a/common/patches/patches.cpp +++ b/common/patches/patches.cpp @@ -26,7 +26,7 @@ #include "sod.h" #include "rof.h" #include "rof2.h" - +#include "larion.h" void RegisterAllPatches(EQStreamIdentifier &into) { @@ -36,6 +36,7 @@ void RegisterAllPatches(EQStreamIdentifier &into) UF::Register(into); RoF::Register(into); RoF2::Register(into); + Larion::Register(into); } void ReloadAllPatches() @@ -46,4 +47,5 @@ void ReloadAllPatches() UF::Reload(); RoF::Reload(); RoF2::Reload(); + Larion::Reload(); }