diff --git a/components/game_mod/dllmain.cpp b/components/game_mod/dllmain.cpp index 844e94bd..e8fb9652 100644 --- a/components/game_mod/dllmain.cpp +++ b/components/game_mod/dllmain.cpp @@ -379,6 +379,11 @@ BOOL GameMod_Init() // Detours::X86::DetourFunction((PBYTE)0x006D98F0, (PBYTE)&hk_R_Cinematic_BinkOpen); + // Ray + // Add support for mod specific frontend levels (needs to be tested if coop lobbies work!) + // + Mod_Frontend_Init(); + // // Enable Custom / Updated Commands // @@ -643,4 +648,4 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv } return TRUE; -} \ No newline at end of file +} diff --git a/components/game_mod/game_mod.vcxproj b/components/game_mod/game_mod.vcxproj index a0d75170..8e715071 100644 --- a/components/game_mod/game_mod.vcxproj +++ b/components/game_mod/game_mod.vcxproj @@ -132,6 +132,7 @@ + @@ -212,6 +213,7 @@ + diff --git a/components/game_mod/mod_frontend.cpp b/components/game_mod/mod_frontend.cpp new file mode 100644 index 00000000..422762de --- /dev/null +++ b/components/game_mod/mod_frontend.cpp @@ -0,0 +1,77 @@ +#include "stdafx.h" + +void Com_RunFrontend() +{ + int v0; // esi@2 + char v1; // al@9 + int localClientNum; // esi@9 + int controllerIndex; // eax@11 + XZoneInfo zoneInfo; // [sp+408h] [bp-Ch]@6 + // 0x38789A0 - xblive_matchEndingSoon + Dvar_SetBool((dvar_s *)0x38789A0, false); + int desiredMenu = GetDesiredMenu(); + char desiredMenuStr[8]; + char falseStr[] = "0"; + itoa(desiredMenu, desiredMenuStr, 10); + Dvar_SetFromStringByName("com_desiredMenu", desiredMenuStr); + Dvar_SetFromStringByName("systemlink_warning", falseStr); + Dvar_SetFromStringByName("onlinegame", falseStr); + Dvar_SetFromStringByName("zombiemode", falseStr); + Dvar_SetFromStringByName("zombietron", falseStr); + Dvar_SetFromStringByName("blackopsmode", falseStr); + Dvar_SetFromStringByName("spmode", falseStr); + Dvar_SetFromStringByName("arcademode", falseStr); + func_41FEE0(); + + char *currentMapname = (char *)Dvar_GetString("mapname"); + localClientNum = GetLocalClientNum(); + controllerIndex = UI_UIContext_GetInfo(localClientNum); + + Com_Printf(1, "Checking for mod_frontend\n"); + if (PartyClient_CheckMapExists("mod_frontend") && I_strcmp(currentMapname, "mod_frontend") != 0) + { + Com_Printf(1, "mod_frontend exists. Loading mod_frontend...\n"); + //Cmd_ExecuteSingleCommandInternal(localClientNum, controllerIndex, NULL, "map mod_frontend", false); // doing this until I find a better alternative + Cbuf_ExecuteBuffer(localClientNum, controllerIndex, "map mod_frontend\n"); + } + else if (!PartyClient_CheckMapExists("mod_frontend") && I_strcmp(currentMapname, "frontend") != 0) + { + Com_Printf(1, "Loading frontend...\n"); + //Cmd_ExecuteSingleCommandInternal(localClientNum, controllerIndex, NULL, "map frontend", false); // doing this until I find a better alternative + Cbuf_ExecuteBuffer(localClientNum, controllerIndex, "map frontend\n"); + } +} + +void UI_RunMod_HandleFrontend() +{ + int localClientNum; // esi@9 + int controllerIndex; // eax@11 + Com_Printf(1, "Getting GetLocalClientNum value\nsub_5BEE40() = "); + localClientNum = GetLocalClientNum(); // why is localClientNum being this huge, I dont get it + // 1703388 + Com_Printf(1, "%d\nGetting UIContext Info\nUI_UIContext_GetInfo() = "); + controllerIndex = UI_UIContext_GetInfo(localClientNum); + Cmd_ExecuteSingleCommandInternal(localClientNum, controllerIndex, NULL, "vid_restart_complete", false); + Cmd_ExecuteSingleCommandInternal(localClientNum, controllerIndex, NULL, "wait", false); + if (PartyClient_CheckMapExists("mod_frontend")) + { + Com_Printf(1, "mod_frontend exists. Loading mod_frontend...\n"); + Cmd_ExecuteSingleCommandInternal(localClientNum, controllerIndex, NULL, "map mod_frontend", false); // doing this until I find a better alternative + //Cbuf_ExecuteBuffer(localClientNum, controllerIndex, "map mod_frontend\n"); + } + else + { + Com_Printf(1, "Loading frontend...\n"); + Cmd_ExecuteSingleCommandInternal(localClientNum, controllerIndex, NULL, "map frontend", false); // doing this until I find a better alternative + //Cbuf_ExecuteBuffer(localClientNum, controllerIndex, "map frontend\n"); + } +} + +void Mod_Frontend_Init() +{ + Detours::X86::DetourFunction((PBYTE)0x00406B32, (PBYTE)&Com_RunFrontend, Detours::X86Option::USE_CALL); + Detours::X86::DetourFunction((PBYTE)0x005A6C32, (PBYTE)&Com_RunFrontend, Detours::X86Option::USE_JUMP); + Detours::X86::DetourFunction((PBYTE)0x00679018, (PBYTE)&Com_RunFrontend, Detours::X86Option::USE_JUMP); + + Detours::X86::DetourFunction((PBYTE)&UI_RunMod_HandleFrontend, (PBYTE)0x45CD7D, Detours::X86Option::USE_CALL); +} diff --git a/components/game_mod/mod_frontend.h b/components/game_mod/mod_frontend.h new file mode 100644 index 00000000..df0baa89 --- /dev/null +++ b/components/game_mod/mod_frontend.h @@ -0,0 +1,27 @@ +#pragma once + +typedef void __cdecl voidFunc(); +typedef void __cdecl voidFunc2(int a1, float a2); + +typedef int __cdecl UI_UIContext_GetInfo_t(int localClientNum); +static UI_UIContext_GetInfo_t *UI_UIContext_GetInfo = (UI_UIContext_GetInfo_t *)0x4F3C70; + +static voidFunc *func_41FEE0 = (voidFunc *)0x41FEE0; + +typedef int __cdecl sub_5BEE40_t(); +static sub_5BEE40_t *GetLocalClientNum = (sub_5BEE40_t *)0x5BEE40; + +VANILLA_FUNC(GetDesiredMenu, int(__cdecl*)(), 0x569EE0); + +// XREFS +// call at 406B32 +// jmp at 5A6C32 +// jmp at 679018 +void Com_RunFrontend(); + +// XREFS +// replace the Cbuf_AddText call in UI_RunMenuScript +// call at 45CD7D +void UI_RunMod_HandleFrontend(); + +void Mod_Frontend_Init(); diff --git a/components/game_mod/stdafx.h b/components/game_mod/stdafx.h index 22e99808..fbb8621a 100644 --- a/components/game_mod/stdafx.h +++ b/components/game_mod/stdafx.h @@ -111,4 +111,8 @@ #include "reshade.h" -#define GM_NET_VERSION 0x01 \ No newline at end of file +#include "mod_frontend.h" + +#define GM_NET_VERSION 0x01 + +#define _USE_LEVEL_DEPENDENCIES 1