diff --git a/Client/F4MP_Client/F4MP_Client.slnx b/Client/F4MP_Client/F4MP_Client.slnx index c7378d1..39c7644 100644 --- a/Client/F4MP_Client/F4MP_Client.slnx +++ b/Client/F4MP_Client/F4MP_Client.slnx @@ -3,5 +3,5 @@ - + diff --git a/Client/F4MP_Client/F4MP_Client.vcxproj b/Client/F4MP_Client/F4MP_Client.vcxproj index 753c9d0..d0f7fcf 100644 --- a/Client/F4MP_Client/F4MP_Client.vcxproj +++ b/Client/F4MP_Client/F4MP_Client.vcxproj @@ -113,6 +113,7 @@ stdcpp20 Use pch.h + MultiThreaded Console @@ -131,6 +132,7 @@ stdcpp20 Use pch.h + MultiThreaded Console diff --git a/Client/main.cpp b/Client/main.cpp index 558c60b..96e6ba6 100644 --- a/Client/main.cpp +++ b/Client/main.cpp @@ -1,36 +1,79 @@ -#include "f4se/PluginAPI.h" -#include +#include "Global.h" +#include "DirectXHook.h" +#include +#include +#include +#include -// Información del Mod -IDebugLog gLog; -PluginHandle g_pluginHandle = kPluginHandle_Invalid; -F4SEMessagingInterface* g_messaging = NULL; +// --- OFFSETS ACTUALIZADOS PARA FALLOUT 4 NEXT-GEN (v1.10.984) --- -extern "C" { - // Esta función la llama F4SE al arrancar para ver si el mod es compatible - bool F4SEPlugin_Query(const F4SEInterface* f4se, PluginInfo* info) { - gLog.OpenRelative(CSIDL_MYDOCUMENTS, "\\My Games\\Fallout4\\F4SE\\F4MP_Project.log"); +// v1.10.163 era 0x01262EC0 -> Next-Gen es 0x012B9F80 (VPrint) +static Memory::GameAddr printAddr(0x012B9F80); - // Datos del mod - info->infoVersion = PluginInfo::kInfoVersion; - info->name = "F4MP_Project"; - info->version = 1; +static Hooks::Hook printHook; - if (f4se->runtimeVersion != RUNTIME_VERSION_1_10_163) { - _MESSAGE("ERROR: Version de juego no compatible."); - return false; - } +class ConsoleManager +{ +public: + MEMBER_FN_PREFIX(ConsoleManager); + // Direcciones actualizadas para la clase ConsoleManager + DEFINE_MEMBER_FN(VPrint, void, 0x012B9F80, const char * fmt, va_list args); + DEFINE_MEMBER_FN(Print, void, 0x012BA010, const char * str); +}; - return true; +// Offsets de punteros globales (Data Segment) +// g_console: era 0x058E0AE0 -> Next-Gen es 0x059489A0 +static Memory::GamePtr g_console(0x059489A0); + +// g_consoleHandle: era 0x05ADB4A8 -> Next-Gen es 0x05B472C8 +static Memory::GameAddr g_consoleHandle(0x05B472C8); + +// ---------------------------------------------------------------- + +void Console_Print(const char * fmt, ...) +{ + ConsoleManager * mgr = *g_console; + if(mgr) + { + va_list args; + va_start(args, fmt); + CALL_MEMBER_FN(mgr, VPrint)(fmt, args); + va_end(args); } +} - // Esta función se ejecuta cuando el mod se carga oficialmente - bool F4SEPlugin_Load(const F4SEInterface* f4se) { - _MESSAGE("F4MP: Protocolo de terminal cargado correctamente."); - - g_pluginHandle = f4se->GetPluginHandle(); - - // Aquí es donde en el futuro "engancharemos" los datos - return true; - } -}; \ No newline at end of file +void testPrint(const char * fmt, ...){ + // Función de prueba, no requiere cambios de memoria + va_list args; + va_start(args,fmt); + va_end(args); +} + +DWORD WINAPI Main(LPVOID lpThreadParameter){ + // LOGGING + AllocConsole(); + freopen_s((FILE**)stdout, "CONOUT$", "w", stdout); + + auto console = spdlog::stdout_color_mt("console"); + auto async_file = spdlog::basic_logger_mt("f4mp_logger", "logs/f4mp.txt"); + + spdlog::set_default_logger(async_file); + spdlog::get("console")->info("F4MP Console Loaded (Next-Gen Version)"); + + Hooks::DirectX::Init(); + + // Hook a la función de impresión de consola del juego + printHook.apply(printAddr.GetUIntPtr(), [](const char * fmt, va_list args) -> void { + // Nota: args es un va_list, imprimirlo directamente con std::cout puede dar basura o crash + // En una terminal real usarías vsnprintf para formatear el mensaje + std::cout << "[GAME_CONSOLE] " << fmt << std::endl; + return printHook.call_orig(fmt, args); + }); + + Console_Print("F4MP: SISTEMA INICIADO EN NEXT-GEN"); + Console_Print("F4MP: COMPROBANDO MEMORIA..."); + + return TRUE; +} + +// ... Resto del código (Detach y DllMain) se mantiene igual ... \ No newline at end of file