Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion components/game_mod/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand Down Expand Up @@ -643,4 +648,4 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
}

return TRUE;
}
}
2 changes: 2 additions & 0 deletions components/game_mod/game_mod.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
<ClCompile Include="g_utils_mp.cpp" />
<ClCompile Include="live_steam_client.cpp" />
<ClCompile Include="live_win.cpp" />
<ClCompile Include="mod_frontend.cpp" />
<ClCompile Include="netfield.cpp" />
<ClCompile Include="patch_common.cpp" />
<ClCompile Include="patch_demo.cpp" />
Expand Down Expand Up @@ -212,6 +213,7 @@
<ClInclude Include="g_utils_mp.h" />
<ClInclude Include="live_steam_client.h" />
<ClInclude Include="live_win.h" />
<ClInclude Include="mod_frontend.h" />
<ClInclude Include="msg_mp.h" />
<ClInclude Include="netfield.h" />
<ClInclude Include="patch_common.h" />
Expand Down
77 changes: 77 additions & 0 deletions components/game_mod/mod_frontend.cpp
Original file line number Diff line number Diff line change
@@ -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);
}
27 changes: 27 additions & 0 deletions components/game_mod/mod_frontend.h
Original file line number Diff line number Diff line change
@@ -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();
6 changes: 5 additions & 1 deletion components/game_mod/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,8 @@

#include "reshade.h"

#define GM_NET_VERSION 0x01
#include "mod_frontend.h"

#define GM_NET_VERSION 0x01

#define _USE_LEVEL_DEPENDENCIES 1