From 6fb9e8004aa919464b0bdaeb3c032b1111f3ba8d Mon Sep 17 00:00:00 2001
From: Amos <48657826+Mauler125@users.noreply.github.com>
Date: Sun, 24 Oct 2021 12:50:23 -0700
Subject: [PATCH] Additional patches for dedicated

New patches disabling extra stuff
Improve code readability
---
 r5dedicated/opcodes.cpp | 349 ++++++++++++++++------------------------
 r5dedicated/opcodes.h   |  35 ++--
 2 files changed, 157 insertions(+), 227 deletions(-)

diff --git a/r5dedicated/opcodes.cpp b/r5dedicated/opcodes.cpp
index 738f28ba..2c63753f 100644
--- a/r5dedicated/opcodes.cpp
+++ b/r5dedicated/opcodes.cpp
@@ -8,218 +8,168 @@
  * _opcodes.cpp
  *-----------------------------------------------------------------------------*/
 
-void DisableRenderer()
-{
-	//-------------------------------------------------------------------------
-	// FUN --> RET | Called from CEngineClient and CEngineVGUI (Init()?).
-	r0.Patch({ 0xC3 }); // This patch is likely not required if client.dll isn't initialized.
-	//-------------------------------------------------------------------------
-	// FUN --> RET | Skip ShaderSetup(). CShaderGlue.
-	r1.Patch({ 0xC3 });
-	//-------------------------------------------------------------------------
-	// FUN --> RET | Skip Matsync. Called from CMaterialSystem.
-	r2.Patch({ 0xC3 });
-	//-------------------------------------------------------------------------
-	// JE  --> JMP | Matsys mode init (CMaterialSystem).
-	r3.Offset(0x22).Patch({ 0xEB, 0x66 });
-	//-------------------------------------------------------------------------
-	// FUN --> RET | Clear render buffer? Called from CMatRenderContext and CTexture.
-	r4.Patch({ 0xC3 });
-	//-------------------------------------------------------------------------
-	// FUN --> RET | Heavy render stuff. Called from CMatRenderContext.
-	r5.Patch({ 0xC3 });
-	//-------------------------------------------------------------------------
-	// FUN --> RET | Set shader resource.
-	r6.Patch({ 0xC3 });
-	//-------------------------------------------------------------------------
-	// FUN --> RET | Begin.
-	r7.Patch({ 0xC3, 0x90, 0x90, 0x90, 0x90 });
-	//-------------------------------------------------------------------------
-	// FUN --> RET | End.
-	r8.Patch({ 0xC3, 0x90, 0x90, 0x90, 0x90, 0x90 });
-}
-
-void DisableClient()
-{
-	//Sleep(2500);
-	//-------------------------------------------------------------------------
-	// JNZ --> JMP | Prevent EbisuSDK from initializing on the engine and server.
-	Origin_Init.Offset(0x0B).Patch({ 0xE9, 0x63, 0x02, 0x00, 0x00, 0x00 });
-	Origin_SetState.Offset(0x0E).Patch({ 0xE9, 0xCB, 0x03, 0x00, 0x00 });
-	//-------------------------------------------------------------------------
-	// JE  --> JMP | Skip CreateGameWindow initialization code.
-	//CreateGameWindow.Offset(0x3DD).Patch({ 0xEB, 0x6D });
-	//-------------------------------------------------------------------------
-	// JNZ --> JMP | Skip CreateGameWindow validation code.
-	CreateGameWindow.Offset(0x44C).Patch({ 0xEB, 0x49 });
-	//-------------------------------------------------------------------------
-	// PUS --> XOR | Prevent ShowWindow and CreateGameWindow from being initialized.
-	c1.Offset(0x2C).Patch({ 0xE9, 0x9A, 0x00, 0x00, 0x00 });
-	//-------------------------------------------------------------------------
-	// JNE --> NOP | TODO: NOP 'particle_script' instead.
-	c2.Offset(0x23C).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 });
-	//-------------------------------------------------------------------------
-	// MOV --> NOP | TODO: NOP 'particle_script' instead.
-	c2.Offset(0x2BD).Patch({ 0x90, 0x90, 0x90 });
-	//-------------------------------------------------------------------------
-	// MOV --> NOP | TODO: NOP 'highlight_system' instead.
-	c3.Offset(0xA9).Patch({ 0x90, 0x90, 0x90, 0x90 });
-
-	//-------------------------------------------------------------------------
-	// FUN --> RET | 
-	c4.Patch({ 0xC3 });
-	c5.Patch({ 0xC3 });
-	c7.Patch({ 0xC3 });
-
-	//-------------------------------------------------------------------------
-	// JE  --> JMP | Render?
-	//gHost_Init_2.Offset(0x5D8).Patch({ 0xEB, 0x05 });
-
-	//-------------------------------------------------------------------------
-	// FUN --> RET | Disable particle effects precaching on the server.
-	ParticleEffect_Init.Patch({ 0xC3 });
-
-	//-------------------------------------------------------------------------
-	// JNE --> JMP | 
-	c6.Offset(0x23).Patch({ 0xEB, 0x23 });
-}
-
-void DisableVGUI()
-{
-	//-------------------------------------------------------------------------
-	// CMP --> XOR | Skip VGUI initialization jumptable.
-	v0.Patch({ 0x48, 0x33, 0xC0, 0xC3, 0x90, 0x90, 0x90 });
-	//-------------------------------------------------------------------------
-	// JNE --> JMP | Skip call to VGUI loadscreen func.
-	SCR_BeginLoadingPlaque.Offset(0x427).Patch({ 0xEB, 0x09 });
-}
-
 void Hooks::DedicatedPatch()
 {
-	//Sleep(10000);
-	// for future reference 14171A9B4 - matsys mode
-
 	*(uintptr_t*)0x14D415040 = 0x1417304E8;
 	*(uintptr_t*)0x14B37C3C0 = 0x141F10CA0;
-
 	*(uintptr_t*)0x14B3800D7 = 0x1; // bDedicated
 
-	DisableRenderer();
-	DisableClient();
-	DisableVGUI();
+	//-------------------------------------------------------------------------
+	// RESEARCH FOR IMPROVEMENT!
+	//-------------------------------------------------------------------------
+	e10.Patch({ 0xC3 }); // FUN --> RET | RET early to prevent '' code execution.
+	e8.Offset(0x44).Patch({ 0xE9, 0x41, 0x04, 0x00, 0x00 });                        // FUN --> RET | Return early in 'RenderFrame?' (Called from VGUI and Host_Init).
+	gInitMaterialSystem.Offset(0x7D).Patch({ 0xC3 });                               // JMP --> RET | Return early to prevent 'InitDebugMaterials' from being executed.
+	e3.Offset(0xFB0).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 });                       // CAL --> NOP | NOP call to unused VGUI code to prevent crash at SIGNONSTATE_PRESPAWN.
+	addr_CEngine_Frame.Offset(0x410).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | CHLClient call inside eng->frame.
+	FairFight_Init.Offset(0x61).Patch({ 0xE9, 0xED, 0x00, 0x00, 0x00, 0x00 });      // JA  --> JMP | Prevent FairFight anti-cheat from initializing on the server.
+	s1.Offset(0x1023).Patch({ 0x90, 0x90, 0x90 });                                  // CAL --> NOP | NOP NULL call as client is never initialized.
+	s2.Offset(0xF).Patch({ 0xE9, 0x22, 0x01, 0x00, 0x00 });                         // JS  --> JMP | Skip ListenServer HeartBeat.
+	e1.Offset(0x213).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 });                 // JNE --> NOP | Skip settings field loading for client texture assets.
+	e9.Offset(0x6).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 });                         // CAL --> NOP | NOP call to prevent texture creation.
+	gShaderCreate.Patch({ 0xC3 });                                                  // FUN --> RET | RET early to prevent 'ShaderCreate' code execution.
+	gTextureCreate.Patch({ 0xC3 });                                                 // FUN --> RET | RET early to prevent 'TextureCreate' code execution.
+	c2.Offset(0x23C).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 });                 // JNE --> NOP | TODO: NOP 'particle_script' instead.
+	c2.Offset(0x2BD).Patch({ 0x90, 0x90, 0x90 });                                   // MOV --> NOP | TODO: NOP 'particle_script' instead.
+	c3.Offset(0xA9).Patch({ 0x90, 0x90, 0x90, 0x90 });                              // MOV --> NOP | TODO: NOP 'highlight_system' instead.
 
 	//-------------------------------------------------------------------------
-	// CAL --> NOP | HLClient call inside eng->frame.
-	addr_CEngine_Frame.Offset(0x410).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 });
+	// CENGINEAPI
+	//-------------------------------------------------------------------------
+	gCEngineAPI__Init.Offset(0xB7).Patch({ 0xE9, 0xC7, 0x00, 0x00, 0x00 });           // JNE --> JNP | Skip Video Mode validation code.
+	gCEngineAPI__OnStartup.Offset(0x5E).Patch({ 0xE9, 0xC6, 0x01, 0x00, 0x00 });      // JNE --> JNP | Skip Video Mode initialization code.
+	gCEngineAPI__Connect.Offset(0xDD).Patch({ 0x90, 0x90, 0x90 });                    // CAL --> NOP | NOP call to texture and material preloading.
+	gCEngineAPI__Connect.Offset(0xF1).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 });  // CAL --> NOP | NOP call to texture and material preloading.
+	gCEngineAPI__Connect.Offset(0x1C6).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90});        // CAL --> NOP | NOP call to texture and material preloading.
+	//gCEngineAPI__ModInit.Offset(0x3DD).Patch({ 0xE9, 0xB5, 0x00, 0x00, 0x00, 0x00 }); // JNE --> JNP | Skip CreateWindow Initialization code.
+	gCEngineAPI__ModInit.Offset(0x44C).Patch({ 0xEB, 0x49 });                        // JNZ --> JMP | Skip CreateGameWindow validation code.
+	//gCEngineAPI__ModInit.Offset(0x3DD).Patch({ 0xEB, 0x6D });                        // JE  --> JMP | Skip CreateGameWindow initialization code.
+
+	//-------------------------------------------------------------------------
+	// CENGINEVGUI
+	//-------------------------------------------------------------------------
+	gCEngineVGui__Init.Patch({ 0x48, 0x33, 0xC0, 0xC3, 0x90, 0x90, 0x90 }); // CMP --> XOR | Skip VGUI initialization jumptable.
+	gCEngineVGui__OnLevelLoadingStarted.Patch({ 0xC3 });                    // FUN --> RET | 
+
+	//-------------------------------------------------------------------------
+	// CGAME
+	//-------------------------------------------------------------------------
+	gCGame__CreateGameWindow.Offset(0x2C).Patch({ 0xE9, 0x9A, 0x00, 0x00, 0x00 }); // PUS --> XOR | Prevent ShowWindow and CreateGameWindow from being initialized.
+
+	//-------------------------------------------------------------------------
+	// CHLClIENT
+	//-------------------------------------------------------------------------
+	gCHLClient__1000.Patch({ 0xC3 });      // FUN --> RET | Return early in 'gCHLClient::unnamed' to prevent infinite loop.
+	gCHLClient__HudMessage.Patch({ 0xC3 }); // FUN --> RET | Return early from 'CHudMessage' call.
+
+	//-------------------------------------------------------------------------
+	// CSOURCEAPPSYSTEMGROUP
+	//-------------------------------------------------------------------------
+	gCSourceAppSystemGroup__Create.Offset(0x35D).Patch({ 0x90, 0x90, 0x90 }); // CAL --> NOP | joystickInit?
+	//gCSourceAppSystemGroup__Create.Offset(0x384).Patch({ 0x90, 0x90, 0x90 }); // CAL --> NOP | PrecacheMaterial.
+	gCSourceAppSystemGroup__Create.Offset(0x39E).Patch({ 0x90, 0x90, 0x90 }); // CAL --> NOP | binkBlankTexture.
+
+	//-------------------------------------------------------------------------
+	// CVIDEOMODE_COMMON
+	//-------------------------------------------------------------------------
+	gCVideoMode_Common__DrawStartupGraphic.Patch({ 0xC3 }); // FUN --> RET | Return early in 'CVideoMode_Common::DrawStartupGraphic'.
+
+	//-------------------------------------------------------------------------
+	// CMATERIALSYSTEM
+	//-------------------------------------------------------------------------
+	gCMaterialSystem__MatsysMode_Init.Offset(0x22).Patch({ 0xEB, 0x66 }); // JE  --> JMP | Matsys mode init (CMaterialSystem).
+
+	//-------------------------------------------------------------------------
+	// CSHADERSYSTEM
+	//-------------------------------------------------------------------------
+	//gCShaderSystem_Init.Patch({ 0xC3 });                                  // FUN --> RET | Return early in 'CShaderSystem::Init' to prevent initialization.
+	gCShaderSystem__9.Offset(0x3).Patch({ 0xE9, 0x95, 0x03, 0x00, 0x00 }); // Unnecessary CShaderSystem call?
+
+	//-------------------------------------------------------------------------
+	// CSHADERGLUE
+	//-------------------------------------------------------------------------
+	gCShaderGlue__Init.Patch({ 0xC3 }); // FUN --> RET | Skip ShaderSetup(). CShaderGlue.
+
+	//-------------------------------------------------------------------------
+	// RUNTIME: HOST_INIT
+	//-------------------------------------------------------------------------
+	gHost_Init_0.Offset(0xC2).Patch({ 0xEB, 0x34 });                    // CAL --> NOP | Disable 'vpk/client_common.bsp' loading.
+	gHost_Init_0.Offset(0x182).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> JMP | Disable UI material asset initialization.
+	gHost_Init_0.Offset(0x859).Patch({ 0xE9, 0x19, 0x04, 0x00, 0x00 }); // LEA --> RET | Disable 'client.dll' library initialization.
+	gHost_Init_0.Offset(0xC77).Patch({ 0xE8, 0x44, 0xCF, 0xFF, 0xFF }); // CAL --> CAL | Disable user config loading and call entitlements.rson initialization instead.
+	gHost_Init_1.Offset(0x19).Patch({ 0xEB, 0x6E });                    // JNE --> JMP | Take dedicated initialization routine instead.
+	gHost_Init_1.Offset(0x609).Patch({ 0xEB, 0x2B });                   // JE  --> JMP | Skip client.dll Init_PostVideo() validation code.
+	gHost_Init_1.Offset(0x621).Patch({ 0xEB, 0x0C });                   // JNE --> JMP | Skip client.dll Init_PostVideo() validation code.
+	gHost_Init_1.Offset(0x658).Patch({ 0xE9, 0x8C, 0x00, 0x00, 0x00 }); // JE  --> JMP | Skip NULL call as client is never initialized.
+	gHost_Init_1.Offset(0x6E9).Patch({ 0xE9, 0xB0, 0x00, 0x00, 0x00 }); // JNE --> JMP | Skip shader preloading as cvar can't be checked due to client being NULL.
+	//gHost_Init_2.Offset(0x5D8).Patch({ 0xEB, 0x05 });                  // JE  --> JMP | Render?
+
+	//-------------------------------------------------------------------------
+	// RUNTIME: _HOST_RUNFRAME
+	//-------------------------------------------------------------------------
+	//s1.Offset(0x1C6).Patch({ 0xE9, 0xAD, 0x11, 0x00, 0x00 }); // JNE --> JMP | Return early in _Host_RunFrame() for debugging perposes.
+	//s1.Offset(0x1010).Patch({ 0xEB, 0x14 });                  // JNE --> JMP | Return early in _Host_RunFrame() for debugging perposes.
+
+	//-------------------------------------------------------------------------
+	// RUNTIME: EBISUSDK
+	//-------------------------------------------------------------------------
+	Origin_Init.Offset(0x0B).Patch({ 0xE9, 0x63, 0x02, 0x00, 0x00, 0x00 }); // JNZ --> JMP | Prevent EbisuSDK from initializing on the engine and server.
+	Origin_SetState.Offset(0x0E).Patch({ 0xE9, 0xCB, 0x03, 0x00, 0x00 });   // JNZ --> JMP | Prevent EbisuSDK from initializing on the engine and server.
+
+	//-------------------------------------------------------------------------
+	// RUNTIME: FAIRFIGHT
 	//-------------------------------------------------------------------------
-	// JA  --> JMP | Prevent FairFight anti-cheat from initializing on the server.
-	// TODO: fix and re-enable this.
 	FairFight_Init.Offset(0x61).Patch({ 0xE9, 0xED, 0x00, 0x00, 0x00, 0x00 });
-	//-------------------------------------------------------------------------
-	// JNE --> JMP | Take dedicated initialization routine instead.
-	gHost_Init_1.Offset(0x19).Patch({ 0xEB, 0x6E });
-	//-------------------------------------------------------------------------
-	// JE  --> JMP | Skip client.dll Init_PostVideo() validation code.
-	gHost_Init_1.Offset(0x609).Patch({ 0xEB, 0x2B });
-	//-------------------------------------------------------------------------
-	// JNE --> JMP | Skip client.dll Init_PostVideo() validation code.
-	gHost_Init_1.Offset(0x621).Patch({ 0xEB, 0x0C });
-	//-------------------------------------------------------------------------
-	// JE  --> JMP | Skip NULL call as client is never initialized.
-	gHost_Init_1.Offset(0x658).Patch({ 0xE9, 0x8C, 0x00, 0x00, 0x00 });
-	//-------------------------------------------------------------------------
-	// JNE --> JMP | Skip shader preloading as cvar can't be checked due to client being NULL.
-	gHost_Init_1.Offset(0x6E9).Patch({ 0xE9, 0xB0, 0x00, 0x00, 0x00 });
-	//-------------------------------------------------------------------------
-	// JNE --> JMP | Return early in _Host_RunFrame() for debugging perposes.
-	//s1.Offset(0x1C6).Patch({ 0xE9, 0xAD, 0x11, 0x00, 0x00 }); // <-- this one was only used to debug.
-	//-------------------------------------------------------------------------
-	// JNE --> JMP | Return early in _Host_RunFrame() for debugging perposes.
-	//s1.Offset(0x1010).Patch({ 0xEB, 0x14 });
-	//-------------------------------------------------------------------------
-	// CAL --> NOP | NOP NULL call as client is never initialized.
-	s1.Offset(0x1023).Patch({ 0x90, 0x90, 0x90 });
-	//-------------------------------------------------------------------------
-	// JS  --> JMP | Skip ListenServer HeartBeat.
-	s2.Offset(0xF).Patch({ 0xE9, 0x22, 0x01, 0x00, 0x00 });
 
 	//-------------------------------------------------------------------------
-	// CAL --> NOP | NOP call to UI texture asset preloading.
-	gHost_Init_0.Offset(0x182).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 });
+	// RUNTIME: BSP_LUMP
 	//-------------------------------------------------------------------------
-	// JNE --> JNP | Skip client.dll library initialization.
-	gHost_Init_0.Offset(0xA7D).Patch({ 0xE9, 0xF0, 0x01, 0x00, 0x00 });
-	//-------------------------------------------------------------------------
-	// JNE --> NOP | Skip settings field loading for client texture assets.
-	// TODO: this is also used by server.dll library.
-	e1.Offset(0x213).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 });
-	//-------------------------------------------------------------------------
-	// CAL --> NOP | NOP call to unused VGUI code to prevent crash at SIGNONSTATE_PRESPAWN.
-	e3.Offset(0xFB0).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 });
+	gBSP_LUMP_INIT.Offset(0x41).Patch({ 0xE9, 0x4F, 0x04, 0x00, 0x00 });  // JNE --> NOP | SKYLIGHTS.
+	gBSP_LUMP_INIT.Offset(0x974).Patch({ 0x90, 0x90 });                   // JE  --> NOP | VERTNORMALS.
+	gBSP_LUMP_INIT.Offset(0xA55).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | MATERIALSORTS.
+	gBSP_LUMP_INIT.Offset(0xA62).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | MESHBOUNDS.
+	gBSP_LUMP_INIT.Offset(0xA83).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | MESHVERTS.
+	gBSP_LUMP_INIT.Offset(0xAC0).Patch({ 0x90, 0x90 });                   // JE  --> NOP | INDICES.
+	gBSP_LUMP_INIT.Offset(0xBF2).Patch({ 0x90, 0x90 });                   // JE  --> NOP | WORLDLIGHTS.
+	gBSP_LUMP_INIT.Offset(0xDA9).Patch({ 0x90, 0x90 });                   // JE  --> NOP | TWEAKLIGHTS.
+	gBSP_LUMP_INIT.Offset(0xEEB).Patch({ 0xE9, 0x3D, 0x01, 0x00, 0x00 });
+	//gBSP_LUMP_INIT.Offset(0x61B).Patch({ 0xE9, 0xE2, 0x02, 0x00, 0x00 });
 
 	//-------------------------------------------------------------------------
-	// JNE --> JNP | Skip Video Mode initialization code.
-	gCEngineAPI_OnStartup.Offset(0x5E).Patch({ 0xE9, 0xC6, 0x01, 0x00, 0x00 });
+	// RUNTIME: RENDERING
 	//-------------------------------------------------------------------------
-	// JNE --> JNP | Skip Video Mode validation code.
-	gCEngineAPI_Init.Offset(0xB7).Patch({ 0xE9, 0xC7, 0x00, 0x00, 0x00 });
+	r0.Patch({ 0xC3 });                                       // FUN --> RET | Called from CEngineClient and CEngineVGUI (Init()?).
+	gMatSync.Patch({ 0xC3 });                                 // FUN --> RET | Skip Matsync. Called from CMaterialSystem. TODO: Return in root caller.
+	r4.Patch({ 0xC3 });                                       // FUN --> RET | Clear render buffer? Called from CMatRenderContext and CTexture.
+	r5.Patch({ 0xC3 });                                       // FUN --> RET | Heavy render stuff. Called from CMatRenderContext.
+	r6.Patch({ 0xC3 });                                       // FUN --> RET | Set shader resource.
+	r7.Patch({ 0xC3, 0x90, 0x90, 0x90, 0x90 });               // FUN --> RET | Return early in lightmap and post processing code.
+	r8.Patch({ 0xC3, 0x90, 0x90, 0x90, 0x90, 0x90 });         // FUN --> RET | Return early.
+	e9.Offset(0x4AB).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | NOP call to prevent texture creation.
+	e9.Offset(0x4B5).Patch({ 0xC3 });                         // JMP --> RET | RET early to prevent 'PIXVIS' code execution.
+
 	//-------------------------------------------------------------------------
-	// JNE --> JNP | Skip CreateWindow Initialization code.
-	//gCEngineAPI_ModInit.Offset(0x3DD).Patch({ 0xE9, 0xB5, 0x00, 0x00, 0x00, 0x00 });
+	// RUNTIME: USERINTERFACE
 	//-------------------------------------------------------------------------
-	// CAL --> NOP | NOP call to texture and material preloading.
-	gCEngineAPI_Connect.Offset(0xDD).Patch({ 0x90, 0x90, 0x90 });
-	gCEngineAPI_Connect.Offset(0xF1).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 });
-	gCEngineAPI_Connect.Offset(0x1C6).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90});
+	SCR_BeginLoadingPlaque.Offset(0x427).Patch({ 0xEB, 0x09 }); // JNE --> JMP | Skip call to VGUI 'SCR_BeginLoadingPlaque'.
+
 	//-------------------------------------------------------------------------
-	// CAL --> NOP | NOP call to texture and material preloading.
-	gCSourceAppSystemGroup_Create.Offset(0x35D).Patch({ 0x90, 0x90, 0x90 }); // joystickInit?
-	//gCSourceAppSystemGroup_Create.Offset(0x384).Patch({ 0x90, 0x90, 0x90 }); // PrecacheMaterial
-	gCSourceAppSystemGroup_Create.Offset(0x39E).Patch({ 0x90, 0x90, 0x90 }); // binkBlankTexture
+	// RUNTIME: RPAK_DISPATCH
 	//-------------------------------------------------------------------------
-	// FUN --> RET | Return early in 'CVideoMode_Common::DrawStartupGraphic'.
-	gCVideoMode_Common__DrawStartupGraphic.Patch({ 0xC3 });
-	//-------------------------------------------------------------------------
-	// FUN --> RET | Return early in 'CShaderSystem::Init' to prevent initialization.
-	//gCShaderSystem_Init.Patch({ 0xC3 });
-	//-------------------------------------------------------------------------
-	// JMP --> RET | Return early to prevent 'InitDebugMaterials' from being executed.
-	gInitMaterialSystem.Offset(0x7D).Patch({ 0xC3 });
-	//-------------------------------------------------------------------------
-	// FUN --> RET | Return early in 'RenderFrame?' (Called from VGUI and Host_Init).
-	e8.Offset(0x44).Patch({ 0xE9, 0x41, 0x04, 0x00, 0x00 });
-	//-------------------------------------------------------------------------
-	// CAL --> NOP | NOP call to prevent texture creation.
-	e9.Offset(0x6).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 });
-	//-------------------------------------------------------------------------
-	// CAL --> NOP | NOP call to prevent texture creation.
-	e9.Offset(0x4AB).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 });
-	//-------------------------------------------------------------------------
-	// JMP --> RET | RET early to prevent 'PIXVIS' code execution.
-	e9.Offset(0x4B5).Patch({ 0xC3 });
-	//-------------------------------------------------------------------------
-	// FUN --> RET | RET early to prevent '' code execution.
-	e10.Patch({ 0xC3 });
-	//-------------------------------------------------------------------------
-	// CAL --> NOP | Prevent memory allocation and population for shader assets.
 	//gShaderDispatch.Offset(0x25).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 });
-	gShaderDispatch.Offset(0x3C).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 });
-	gShaderDispatch.Offset(0x48).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 });
-	gShaderDispatch.Offset(0x56).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 });
-	gShaderDispatch.Offset(0x62).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 });
-	//-------------------------------------------------------------------------
-	// FUN --> RET | RET early to prevent 'ShaderCreate' code execution.
-	gShaderCreate.Patch({ 0xC3 });
-	//-------------------------------------------------------------------------
-	// FUN --> RET | RET early to prevent 'TextureCreate' code execution.
-	gTextureCreate.Patch({ 0xC3 });
-
-	OnLevelLoadingStarted.Patch({ 0xC3 });
+	gShaderDispatch.Offset(0x3C).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | Prevent memory allocation and population for shader assets.
+	gShaderDispatch.Offset(0x48).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | Prevent memory allocation and population for shader assets.
+	gShaderDispatch.Offset(0x56).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | Prevent memory allocation and population for shader assets.
+	gShaderDispatch.Offset(0x62).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | Prevent memory allocation and population for shader assets.
 
+	// UNKNOWN ----------------------------------------------------------------
+	MemoryAddress t8 = 0x00000001403C0480;
+	t8.Patch({ 0xC3 }); // Return from unknown call during ChangeLevel. [LATE]
+	MemoryAddress t9 = 0x00000001403EE420;
+	t9.Patch({ 0xC3 }); // Return from unknown call during ChangeLevel. [EARLY]
 	//-------------------------------------------------------------------------
-	// START TESTING BLOCK
+	// RUNTIME BLOCK
 	//-------------------------------------------------------------------------
-
 	MemoryAddress t0 = 0x00000001401D71E0;
 	t0.Patch({ 0xC3 });
 	MemoryAddress t1 = 0x0000000140456B50;
@@ -232,29 +182,8 @@ void Hooks::DedicatedPatch()
 	//t4.Offset(0xB3).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 });
 	MemoryAddress t5 = 0x00000001403BBFD0;
 	t5.Offset(0x7D8).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 });
-
-
-	// BSP --------------------------------------------------------------------
-	MemoryAddress t6 = 0x00000001402546F0; // BSP.
-	t6.Offset(0x200).Patch({ 0xEB, 0xA9 }); // Skip SKYLIGHTS.
-	t6.Offset(0x352).Patch({ 0xEB, 0xA5 }); // Skip LUMP_LIGHTMAP.
-	t6.Offset(0xBF2).Patch({ 0x90, 0x90 }); // Skip WORLDLIGHTS
-	t6.Offset(0xDA9).Patch({ 0x90, 0x90 }); // Skip TWEAKLIGHTS
-	t6.Offset(0xEEB).Patch({ 0xE9, 0x3D, 0x01, 0x00, 0x00 });
-	//t6.Offset(0x61B).Patch({ 0xE9, 0xE2, 0x02, 0x00, 0x00 });
-
-	// CSHADERSYSTEM ----------------------------------------------------------
-	MemoryAddress t7 = 0x00000001403DFC30; // Unnecessary CShaderSystem call?
-	t7.Offset(0x3).Patch({ 0xE9, 0x95, 0x03, 0x00, 0x00 });
-
-	// UNKNOWN ----------------------------------------------------------------
-	MemoryAddress t8 = 0x00000001403C0480;
-	t8.Patch({ 0xC3 }); // Return from unknown call during ChangeLevel. (LATE)
-	MemoryAddress t9 = 0x00000001403EE420;
-	t9.Patch({ 0xC3 }); // Return from unknown call during ChangeLevel. (EARLY)
-
 	//-------------------------------------------------------------------------
-	// END TESTING BLOCK
+	// END RUNTIME BLOCK
 	//-------------------------------------------------------------------------
 }
 
diff --git a/r5dedicated/opcodes.h b/r5dedicated/opcodes.h
index 98cc9c1c..e19636d9 100644
--- a/r5dedicated/opcodes.h
+++ b/r5dedicated/opcodes.h
@@ -40,9 +40,9 @@ namespace
 	// TODO: create patterns instead and rename to function names.
 	// Renderer
 	MemoryAddress r0 = 0x00000001402FE280; //
-	MemoryAddress r1 = 0x00000001403B3A50; //
-	MemoryAddress r2 = 0x00000001403DEE90; //
-	MemoryAddress r3 = 0x00000001403BD120; //
+	MemoryAddress gCShaderGlue__Init = 0x00000001403B3A50; //
+	MemoryAddress gMatSync = 0x00000001403DEE90; //
+	MemoryAddress gCMaterialSystem__MatsysMode_Init = 0x00000001403BD120; //
 	MemoryAddress r4 = 0x0000000140404380; //
 	MemoryAddress r5 = 0x000000014040D850; //
 	MemoryAddress r6 = 0x0000000140413260; //
@@ -60,18 +60,21 @@ namespace
 	MemoryAddress e6 = 0x0000000140DBE610;
 	MemoryAddress e7 = 0x000000014044AFA0;
 	MemoryAddress e8 = 0x000000014027EC50; // RenderFrame?
-	MemoryAddress gCEngineAPI_Init = 0x0000000140342FB0; //
-	MemoryAddress gCEngineAPI_ModInit = 0x0000000140343DE0; //
-	MemoryAddress gCEngineAPI_Connect = 0x0000000140342BA0; //
-	MemoryAddress gCEngineAPI_OnStartup = 0x0000000140343860; //
-	MemoryAddress gCSourceAppSystemGroup_Create = 0x000000014044AFA0; //
-	MemoryAddress gCShaderSystem_Init = 0x00000001403DF870; //
+	MemoryAddress gCEngineAPI__Init = 0x0000000140342FB0; //
+	MemoryAddress gCEngineAPI__ModInit = 0x0000000140343DE0; //
+	MemoryAddress gCEngineAPI__Connect = 0x0000000140342BA0; //
+	MemoryAddress gCEngineAPI__OnStartup = 0x0000000140343860; //
+	MemoryAddress gCSourceAppSystemGroup__Create = 0x000000014044AFA0; //
+	MemoryAddress gCShaderSystem__Init = 0x00000001403DF870; //
 	MemoryAddress gInitMaterialSystem = 0x000000014024B390; //
 	MemoryAddress gCVideoMode_Common__DrawStartupGraphic = 0x000000014027F0F0; //
 	MemoryAddress gShaderDispatch = 0x00000001403EE5C0;
 	MemoryAddress gShaderCreate = 0x00000001403ECD00; //
 	MemoryAddress gTextureCreate = 0x00000001403EDCD0;
 
+	MemoryAddress gCShaderSystem__9 = 0x00000001403DFC30;
+	MemoryAddress gBSP_LUMP_INIT = 0x00000001402546F0; // BSP.
+
 
 	MemoryAddress e9 = 0x00000001404066E0;
 	MemoryAddress e10 = 0x00000001403B49E0; // CMaterialGlue?
@@ -84,19 +87,17 @@ namespace
 
 	// CLIENT
 	MemoryAddress gHost_Init_2 = 0x0000000140236640; // client Host_Init()?
-	MemoryAddress c1 = 0x0000000140299100; // CreateGameWindowInit()?
+	MemoryAddress gCGame__CreateGameWindow = 0x0000000140299100; //
 	MemoryAddress c2 = 0x00000001403F4360; // 1403DF870 --> 1403F4360
 	MemoryAddress c3 = 0x00000001403F8A80; // 1403DF870 --> 1403F8A40
-	MemoryAddress c4 = 0x00000001405C27B0; // CHLClient + 1000
-	MemoryAddress c5 = 0x00000001405BAC00; // CHudMessage
+	MemoryAddress gCHLClient__1000 = 0x00000001405C27B0; // CHLClient + 1000
+	MemoryAddress gCHLClient__HudMessage = 0x00000001405BAC00; // CHudMessage
 	MemoryAddress c6 = 0x00000001403CA2D0; //
-	MemoryAddress c7 = 0x00000001403CC750; // LightmapsInit
-	MemoryAddress ParticleEffect_Init = 0x0000000140235F30;
-	MemoryAddress CreateGameWindow = 0x0000000140343DE0;
+	MemoryAddress gCEngineAPI__ModInit = 0x0000000140343DE0;
 
 	// VGUI
-	MemoryAddress v0 = 0x0000000140282E40; // jumptable
-	MemoryAddress OnLevelLoadingStarted = 0x00000001402830D0;
+	MemoryAddress gCEngineVGui__Init = 0x0000000140282E40; // jumptable
+	MemoryAddress gCEngineVGui__OnLevelLoadingStarted = 0x00000001402830D0;
 	MemoryAddress SCR_BeginLoadingPlaque = 0x000000014023E870;