Skip to content

Commit

Permalink
Allows to detect disguise units with Psychic Sensor in Ra2Mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Belonit committed Nov 25, 2023
1 parent 4556702 commit 65bbf3f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/Spawner/Ra2Mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <Spawner/Spawner.h>
#include <Utilities/Macro.h>
#include <BuildingClass.h>
#include <CellClass.h>
#include <HouseClass.h>
#include <LoadOptionsClass.h>

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
{
Expand Down
8 changes: 8 additions & 0 deletions src/Spawner/Ra2Mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/

#pragma once
class CellClass;

class Ra2Mode
{
static bool Enabled;
Expand All @@ -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);
};
};

0 comments on commit 65bbf3f

Please sign in to comment.