|
11 | 11 | #include "Features/FovChanger.hpp" |
12 | 12 | #include "Features/GroundFramesCounter.hpp" |
13 | 13 | #include "Features/Hud/InputHud.hpp" |
| 14 | +#include "Features/Hud/RhythmGame.hpp" |
14 | 15 | #include "Features/Hud/ScrollSpeed.hpp" |
15 | 16 | #include "Features/Hud/StrafeHud.hpp" |
16 | | -#include "Features/Hud/RhythmGame.hpp" |
17 | 17 | #include "Features/Hud/StrafeQuality.hpp" |
18 | 18 | #include "Features/NetMessage.hpp" |
19 | 19 | #include "Features/OverlayRender.hpp" |
@@ -84,8 +84,8 @@ Variable sar_patch_minor_angle_decay("sar_patch_minor_angle_decay", "0", "Patche |
84 | 84 | Variable sar_unlocked_chapters("sar_unlocked_chapters", "-1", "Max unlocked chapter.\n"); |
85 | 85 |
|
86 | 86 | Variable sar_portalcolor_enable("sar_portalcolor_enable", "0", "Enable custom portal colors.\n"); |
87 | | -Variable sar_portalcolor_sp_1("sar_portalcolor_sp_1", "64 160 255", "Portal color for Chell's left portal.\n"); |
88 | | -Variable sar_portalcolor_sp_2("sar_portalcolor_sp_2", "255 160 32", "Portal color for Chell's right portal.\n"); |
| 87 | +Variable sar_portalcolor_sp_1("sar_portalcolor_sp_1", "64 160 255", "Portal color for Chell's left portal. r_portal_fastpath 0 required.\n"); |
| 88 | +Variable sar_portalcolor_sp_2("sar_portalcolor_sp_2", "255 160 32", "Portal color for Chell's right portal. r_portal_fastpath 0 required.\n"); |
89 | 89 | Variable sar_portalcolor_mp1_1("sar_portalcolor_mp1_1", "31 127 210", "Portal color for Atlas (blue)'s left portal.\n"); |
90 | 90 | Variable sar_portalcolor_mp1_2("sar_portalcolor_mp1_2", "19 0 210", "Portal color for Atlas (blue)'s right portal.\n"); |
91 | 91 | Variable sar_portalcolor_mp2_1("sar_portalcolor_mp2_1", "255 179 31", "Portal color for P-Body (orange)'s left portal.\n"); |
@@ -124,6 +124,7 @@ REDECL(Client::OnCommand); |
124 | 124 | REDECL(Client::ApplyMouse_Mid); |
125 | 125 | REDECL(Client::ApplyMouse_Mid_Continue); |
126 | 126 | #endif |
| 127 | +REDECL(Client::DrawPortal); |
127 | 128 | REDECL(Client::GetChapterProgress); |
128 | 129 |
|
129 | 130 |
|
@@ -330,12 +331,44 @@ DETOUR_COMMAND(Client::openleaderboard) { |
330 | 331 | } |
331 | 332 | } |
332 | 333 |
|
| 334 | +Memory::Patch *g_drawPortalPatch; |
| 335 | +Memory::Patch *g_drawPortalGhostPatch; |
| 336 | +// C_Prop_Portal::DrawPortal |
| 337 | +extern Hook g_DrawPortalHook; |
| 338 | +DETOUR(Client::DrawPortal, void *pRenderContext) { |
| 339 | + if (sar_portalcolor_enable.GetBool()) { |
| 340 | + g_drawPortalPatch->Execute(); |
| 341 | + } else { |
| 342 | + g_drawPortalPatch->Restore(); |
| 343 | + } |
| 344 | + g_DrawPortalHook.Disable(); |
| 345 | + auto ret = Client::DrawPortal(thisptr, pRenderContext); |
| 346 | + g_DrawPortalHook.Enable(); |
| 347 | + return ret; |
| 348 | +} |
| 349 | +Hook g_DrawPortalHook(&Client::DrawPortal_Hook); |
| 350 | + |
| 351 | +static void (*g_DrawPortalGhost)(void *pRenderContext); |
| 352 | + |
| 353 | +// C_Prop_Portal::DrawPortalGhostLocations |
| 354 | +extern Hook g_DrawPortalGhostHook; |
| 355 | +static void DrawPortalGhost_Hook(void *pRenderContext) { |
| 356 | + if (sar_portalcolor_enable.GetBool()) { |
| 357 | + g_drawPortalGhostPatch->Execute(); |
| 358 | + } else { |
| 359 | + g_drawPortalGhostPatch->Restore(); |
| 360 | + } |
| 361 | + g_DrawPortalGhostHook.Disable(); |
| 362 | + g_DrawPortalGhost(pRenderContext); |
| 363 | + g_DrawPortalGhostHook.Enable(); |
| 364 | + return; |
| 365 | +} |
| 366 | +Hook g_DrawPortalGhostHook(&DrawPortalGhost_Hook); |
| 367 | + |
| 368 | + |
333 | 369 | static SourceColor (*UTIL_Portal_Color)(int iPortal, int iTeamNumber); |
334 | 370 | extern Hook UTIL_Portal_Color_Hook; |
335 | 371 | static SourceColor UTIL_Portal_Color_Detour(int iPortal, int iTeamNumber) { |
336 | | - // FIXME: SP portal rendering does not use this but rather the |
337 | | - // texture's color itself. This does however work on the color |
338 | | - // of the SP *crosshair* and particles. |
339 | 372 | UTIL_Portal_Color_Hook.Disable(); |
340 | 373 | SourceColor ret = UTIL_Portal_Color(iPortal, iTeamNumber); |
341 | 374 | UTIL_Portal_Color_Hook.Enable(); |
@@ -992,13 +1025,45 @@ bool Client::Init() { |
992 | 1025 |
|
993 | 1026 | #ifdef _WIN32 |
994 | 1027 | auto ApplyMouse_Mid_addr = (uintptr_t)(Client::ApplyMouse) + Offsets::ApplyMouse_Mid; |
995 | | - g_ApplyMouseMidHook.SetFunc(ApplyMouse_Mid_addr); |
996 | | - g_ApplyMouseMidHook.Disable(); |
| 1028 | + g_ApplyMouseMidHook.SetFunc(ApplyMouse_Mid_addr, false); |
997 | 1029 | Client::ApplyMouse_Mid_Continue = ApplyMouse_Mid_addr + 0x5; |
998 | 1030 | #endif |
999 | 1031 | MatrixBuildRotationAboutAxis = (decltype(MatrixBuildRotationAboutAxis))Memory::Scan(client->Name(), Offsets::MatrixBuildRotationAboutAxis); |
1000 | | - MatrixBuildRotationAboutAxisHook.SetFunc(MatrixBuildRotationAboutAxis); |
1001 | | - MatrixBuildRotationAboutAxisHook.Disable(); // only during ApplyMouse |
| 1032 | + MatrixBuildRotationAboutAxisHook.SetFunc(MatrixBuildRotationAboutAxis, false); // only during ApplyMouse |
| 1033 | + |
| 1034 | + auto drawPortalSpBranch = Memory::Scan(client->Name(), Offsets::DrawPortalSpBranch); |
| 1035 | + auto drawPortalGhostSpBranch = Memory::Scan(client->Name(), Offsets::DrawPortalGhostSpBranch); |
| 1036 | + |
| 1037 | + Client::DrawPortal = (decltype(Client::DrawPortal))Memory::Scan(client->Name(), Offsets::DrawPortal); |
| 1038 | + g_DrawPortalGhost = (decltype(g_DrawPortalGhost))Memory::Scan(client->Name(), Offsets::DrawPortalGhost); |
| 1039 | + |
| 1040 | + g_DrawPortalHook.SetFunc(Client::DrawPortal); |
| 1041 | + g_DrawPortalGhostHook.SetFunc(g_DrawPortalGhost); |
| 1042 | + |
| 1043 | + g_drawPortalPatch = new Memory::Patch(); |
| 1044 | + g_drawPortalGhostPatch = new Memory::Patch(); |
| 1045 | + |
| 1046 | + unsigned char drawPortalGhostByte = 0x80; |
| 1047 | + if (drawPortalSpBranch && drawPortalGhostSpBranch) { |
| 1048 | +#ifndef _WIN32 |
| 1049 | + unsigned char drawPortalBytes[5]; |
| 1050 | + |
| 1051 | + *(int32_t *)(drawPortalBytes + 1) = *(int32_t *)(drawPortalSpBranch + 2) + Offsets::DrawPortalSpBranchOff; |
| 1052 | + drawPortalBytes[0] = 0x81; |
| 1053 | + |
| 1054 | + g_drawPortalPatch->Execute(drawPortalSpBranch + 1, drawPortalBytes, 5); |
| 1055 | + g_drawPortalGhostPatch->Execute(drawPortalGhostSpBranch + 1, &drawPortalGhostByte, 1); |
| 1056 | + |
| 1057 | +#else |
| 1058 | + unsigned char drawPortalBytes[2]; |
| 1059 | + |
| 1060 | + drawPortalBytes[0] = 0xEB; |
| 1061 | + drawPortalBytes[1] = Offsets::DrawPortalSpBranchOff; |
| 1062 | + |
| 1063 | + g_drawPortalPatch->Execute(drawPortalSpBranch, drawPortalBytes, 2); |
| 1064 | + g_drawPortalGhostPatch->Execute(drawPortalGhostSpBranch + 1, &drawPortalGhostByte, 1); |
| 1065 | +#endif |
| 1066 | + } |
1002 | 1067 |
|
1003 | 1068 | in_forceuser = Variable("in_forceuser"); |
1004 | 1069 | if (!!in_forceuser && this->g_Input) { |
@@ -1057,8 +1122,8 @@ bool Client::Init() { |
1057 | 1122 |
|
1058 | 1123 | g_AddShadowToReceiverHook.SetFunc(Client::AddShadowToReceiver); |
1059 | 1124 |
|
1060 | | - UTIL_Portal_Color = (decltype (UTIL_Portal_Color))Memory::Scan(client->Name(), Offsets::UTIL_Portal_Color); |
1061 | | - UTIL_Portal_Color_Particles = (decltype (UTIL_Portal_Color_Particles))Memory::Scan(client->Name(), Offsets::UTIL_Portal_Color_Particles); |
| 1125 | + UTIL_Portal_Color = (decltype(UTIL_Portal_Color))Memory::Scan(client->Name(), Offsets::UTIL_Portal_Color); |
| 1126 | + UTIL_Portal_Color_Particles = (decltype(UTIL_Portal_Color_Particles))Memory::Scan(client->Name(), Offsets::UTIL_Portal_Color_Particles); |
1062 | 1127 | UTIL_Portal_Color_Hook.SetFunc(UTIL_Portal_Color); |
1063 | 1128 | UTIL_Portal_Color_Particles_Hook.SetFunc(UTIL_Portal_Color_Particles); |
1064 | 1129 |
|
|
0 commit comments