Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 11 additions & 0 deletions src/Ext/House/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1076,3 +1076,14 @@ bool HouseExt::ReachedBuildLimit(const HouseClass* pHouse, const TechnoTypeClass
return false;
}
#pragma endregion

bool HouseExt::CanSelectOwner(HouseClass* pThis, HouseClass* pPlayer)
{
if (!pThis || !pPlayer)
return false;

return pThis == pPlayer ||
pPlayer->IsCurrentPlayerObserver() ||
(pThis->IsAlliedWith(pPlayer) &&
pPlayer->IsAlliedWith(pThis));
}
2 changes: 2 additions & 0 deletions src/Ext/House/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,6 @@ class HouseExt

static CanBuildResult BuildLimitGroupCheck(const HouseClass* pThis, const TechnoTypeClass* pItem, bool buildLimitOnly, bool includeQueued);
static bool ReachedBuildLimit(const HouseClass* pHouse, const TechnoTypeClass* pType, bool ignoreQueued);

static bool CanSelectOwner(HouseClass* pThis, HouseClass* pPlayer);
};
55 changes: 55 additions & 0 deletions src/Ext/Techno/Hooks.Cloak.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "Body.h"
#include <Ext/House/Body.h>

namespace CloakTemp
{
Expand Down Expand Up @@ -148,3 +149,57 @@ DEFINE_HOOK(0x4579A5, BuildingClass_ShouldNotCloak_Sensors, 0x6)

return Continue;
}

// When a friendly unit goes cloaked, UIName can be displayed normally when hovering the mouse.
DEFINE_HOOK(0x4AE616, DisplayClass_GetToolTip_PlayControl, 0x6)
{
GET(TechnoClass*, pThis, ECX);
enum { SkipGameCode = 0x4AE654 };

R->ESI(pThis);

return HouseExt::CanSelectOwner(pThis->Owner, HouseClass::CurrentPlayer()) ?
SkipGameCode : 0;
}

// When a friendly unit goes cloaked, the DrawExtra() function can be triggered normally on mouse hover.
DEFINE_HOOK(0x69252D, DisplayClass_ProcessClickCoords_PlayControl, 0x6)
{
GET(TechnoClass*, pThis, ESI);
enum { SkipGameCode = 0x692585 };

return HouseExt::CanSelectOwner(pThis->Owner, HouseClass::CurrentPlayer()) ?
SkipGameCode : 0;
}

// When a friendly unit goes cloaked, the mouse pointer will change.
DEFINE_HOOK(0x692686, DisplayClass_DecideAction_PlayControl, 0x6)
{
GET(TechnoClass*, pThis, EDI);
enum { SkipGameCode = 0x6926DB };

return HouseExt::CanSelectOwner(pThis->Owner, HouseClass::CurrentPlayer()) ?
SkipGameCode : 0;
}

// Block out Deselect() when a friendly unit goes cloakd.
DEFINE_HOOK(0x6F4F10, TechnoClass_Sensed_DisableDSelect, 0x5)
{
GET(TechnoClass* const, pThis, ESI);
enum { SkipGameCode = 0x6F4F3A, Continue = 0x6F4F21 };

R->EAX(HouseClass::CurrentPlayer());

return HouseExt::CanSelectOwner(pThis->Owner, HouseClass::CurrentPlayer()) ?
SkipGameCode : 0;
}

// Block out Deselect() when a friendly unit goes cloakd.
DEFINE_HOOK(0x703819, TechnoClass_Cloak_DisableDSelect, 0x6)
{
GET(TechnoClass* const, pThis, ESI);
enum { SkipGameCode = 0x70383C, Continue = 0x703828 };

return HouseExt::CanSelectOwner(pThis->Owner, HouseClass::CurrentPlayer()) ?
SkipGameCode : 0;
}