From 65bbf3f1262b31eabdfb0827f130692b4057cce6 Mon Sep 17 00:00:00 2001 From: Belonit <54427022+Belonit@users.noreply.github.com> Date: Sat, 25 Nov 2023 09:51:21 +0300 Subject: [PATCH] Allows to detect disguise units with Psychic Sensor in Ra2Mode --- src/Spawner/Ra2Mode.cpp | 24 ++++++++++++++++++++++++ src/Spawner/Ra2Mode.h | 8 ++++++++ 2 files changed, 32 insertions(+) diff --git a/src/Spawner/Ra2Mode.cpp b/src/Spawner/Ra2Mode.cpp index 33de7bf0..515b9adc 100644 --- a/src/Spawner/Ra2Mode.cpp +++ b/src/Spawner/Ra2Mode.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -56,6 +57,11 @@ void Ra2Mode::Apply() // Don't show minimap on Load screen Patch::Apply_LJMP(0x553686, 0x553686 + 6); + { // Allows to detect disguise units with Psychic Sensor + Patch::Apply_CALL(0x45591E, GET_OFFSET(DetectDisguiseHack::Sensors_AddOfHouse)); + Patch::Apply_CALL(0x4557B7, GET_OFFSET(DetectDisguiseHack::Sensors_RemOfHouse)); + } + { // Use classic border style for UI items // GroupBoxCtrl Patch::Apply_LJMP(0x61EC64, 0x61EC75); @@ -137,6 +143,24 @@ bool Ra2Mode::CheckSaveGameID(const char* saveGameName) return false; } +// Allows to detect disguise units with Psychic Sensor +#pragma region DetectDisguiseHack + +// This is a very dirty hack that changes the behavior of the SensorArray logic re-implemented in Ares +// The SensorArray logic works with the SensorsOfHouses array, and here we additionally process the DisguiseSensorsOfHouses array +void __fastcall Ra2Mode::DetectDisguiseHack::Sensors_AddOfHouse(CellClass* pThis, void*, unsigned int idx) +{ + pThis->Sensors_AddOfHouse(idx); + pThis->DisguiseSensors_AddOfHouse(idx); +} + +void __fastcall Ra2Mode::DetectDisguiseHack::Sensors_RemOfHouse(CellClass* pThis, void*, unsigned int idx) +{ + pThis->Sensors_RemOfHouse(idx); + pThis->DisguiseSensors_RemOfHouse(idx); +} +#pragma endregion DetectDisguiseHack + // Allow allies to repair on service depot DEFINE_HOOK(0x700594, TechnoClass_WhatAction__AllowAlliesRepair, 0x5) { diff --git a/src/Spawner/Ra2Mode.h b/src/Spawner/Ra2Mode.h index a82b241b..bd070396 100644 --- a/src/Spawner/Ra2Mode.h +++ b/src/Spawner/Ra2Mode.h @@ -18,6 +18,8 @@ */ #pragma once +class CellClass; + class Ra2Mode { static bool Enabled; @@ -30,4 +32,10 @@ class Ra2Mode static void Apply(); static bool IsNeedToApply(); static bool CheckSaveGameID(const char* saveGameName); + + struct DetectDisguiseHack + { + static void __fastcall Sensors_AddOfHouse(CellClass* pThis, void*, unsigned int idx); + static void __fastcall Sensors_RemOfHouse(CellClass* pThis, void*, unsigned int idx); + }; };