Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix] Select allied country units that have been cloaked #1389

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ This page lists all the individual contributions to the project by their author.
- **FlyStar**
- Campaign load screen PCX support
- New condition for automatic self-destruction logic when TechnoTypes exist/don't exist
- Fix for friendly units that have been cloaked not being able to be selected
- **NetsuNegi**
- Forbidding parallel AI queues by type
- Jumpjet crash speed fix when crashing onto building
Expand Down
1 change: 1 addition & 0 deletions docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
- Fixed `Temporal=true` Warheads potentially crashing game if used to attack `Slaved=true` infantry.
- Fixed some locomotors (Tunnel, Walk, Mech) getting stuck when moving too fast.
- Animations with `MakeInfantry` and `UseNormalLight=false` that are drawn in unit palette will now have cell lighting changes applied on them (by Starkku)
- Fix for friendly units that have been cloaked not being able to be selected.

## Fixes / interactions with other extensions

Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@ Phobos fixes:
- Fixed Phobos Warhead effects not reliably being applied on damage area as opposed to full weapon-based Warhead detonation (by Starkku)
- Fix `LimboKill` not working reliably (by CrimRecya)
- Fixed `SelfHealGainType=none` not working (changed to `noheal`) (by Starkku)
- Fix for friendly units that have been cloaked not being able to be selected (by Fly-Star)

Fixes / interactions with other extensions:
- `IsSimpleDeployer` units with Hover locomotor and `DeployToLand` no longer get stuck after deploying or play their move sound indefinitely (by Starkku)
Expand Down
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::CanBeSelectedBy(HouseClass* pOwner, HouseClass* pSelectingPlayer)
{
if (!pOwner || !pSelectingPlayer)
return false;

return pOwner == pSelectingPlayer ||
pSelectingPlayer->IsCurrentPlayerObserver() ||
(pOwner->IsAlliedWith(pSelectingPlayer) &&
pSelectingPlayer->IsAlliedWith(pOwner));
}
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 CanBeSelectedBy(HouseClass* pOwner, HouseClass* pSelectingPlayer);
};
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::CanBeSelectedBy(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::CanBeSelectedBy(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::CanBeSelectedBy(pThis->Owner, HouseClass::CurrentPlayer()) ?
SkipGameCode : 0;
}

// Do not forcibly deselect when a friendly unit goes cloaked.
DEFINE_HOOK(0x6F4F10, TechnoClass_Sensed_DisableDSelect, 0x5)
{
GET(TechnoClass* const, pThis, ESI);
enum { SkipGameCode = 0x6F4F3A };

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

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

// Do not forcibly deselect when a friendly unit goes cloaked.
DEFINE_HOOK(0x703819, TechnoClass_Cloak_DisableDSelect, 0x6)
{
GET(TechnoClass* const, pThis, ESI);
enum { SkipGameCode = 0x70383C };

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