Skip to content
Merged
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
2 changes: 1 addition & 1 deletion YRpp
Submodule YRpp updated 2 files
+2 −0 BuildingClass.h
+3 −0 TechnoClass.h
1 change: 1 addition & 0 deletions docs/New-or-Enhanced-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ InheritCommands=true ; boolean
InheritCommands.StopCommand=true ; boolean
InheritCommands.DeployCommand=true ; boolean
LowSelectionPriority=true ; boolean, whether the child is low priority while attached
PassSelection=true ; boolean, whether the child selection propagates to parent
TransparentToMouse=false ; boolean, can't click on attached techno if set
YSortPosition=default ; Attachment YSort position enumeration - default|underparent|overparent
InheritDestruction=true ; boolean
Expand Down
16 changes: 10 additions & 6 deletions src/Ext/Techno/Hooks.Misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -721,16 +721,20 @@ DEFINE_HOOK_AGAIN(0x5F4718, ObjectClass_Select, 0x7)
DEFINE_HOOK(0x5F46AE, ObjectClass_Select, 0x7)
{
GET(ObjectClass*, pThis, ESI);

pThis->IsSelected = true;

if (!Phobos::Config::ShowFlashOnSelecting)
return 0;
if (Phobos::Config::ShowFlashOnSelecting)
{
const int duration = RulesExt::Global()->SelectionFlashDuration;

auto const duration = RulesExt::Global()->SelectionFlashDuration;
if (duration > 0)
{
const auto pFlashTarget = abstract_cast<TechnoClass*>(pThis);

if (duration > 0 && pThis->GetOwningHouse()->IsControlledByCurrentPlayer())
pThis->Flash(duration);
if (pFlashTarget && pFlashTarget->Owner->IsControlledByCurrentPlayer())
pFlashTarget->Flash(duration);
}
}

return 0;
}
Expand Down
47 changes: 47 additions & 0 deletions src/Ext/Techno/Hooks.TechnoAttachment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,53 @@ DEFINE_FUNCTION_JUMP(VTABLE, 0x7EB0D4, TechnoClass_IsSurfaced);

#pragma endregion

#pragma region Select & Flash

bool __fastcall TechnoClass_Select(TechnoClass* pThis)
{
const auto pExt = TechnoExt::ExtMap.Find(pThis);
const auto pAttachment = pExt->ParentAttachment;
return pAttachment && pAttachment->GetType()->PassSelection
? pAttachment->Parent->Select()
: pThis->TechnoClass::Select();
}
DEFINE_FUNCTION_JUMP(VTABLE, 0x7F5DBC, TechnoClass_Select) // UnitClass
DEFINE_FUNCTION_JUMP(VTABLE, 0x7EB1A4, TechnoClass_Select) // InfantryClass
DEFINE_FUNCTION_JUMP(VTABLE, 0x7E4008, TechnoClass_Select) // BuildingClass
DEFINE_FUNCTION_JUMP(VTABLE, 0x7E23F0, TechnoClass_Select) // AircraftClass

void __fastcall TechnoClass_Flash(TechnoClass* pThis, void*, int duration)
{
const auto pExt = TechnoExt::ExtMap.Find(pThis);

for (const auto& pAttachment : pExt->ChildAttachments)
{
if (pAttachment->GetType()->InheritStateEffects && pAttachment->Child)
pAttachment->Child->Flash(duration);
}

return pThis->TechnoClass::Flash(duration);
}
DEFINE_FUNCTION_JUMP(VTABLE, 0x7F5DB8, TechnoClass_Flash) // UnitClass
DEFINE_FUNCTION_JUMP(VTABLE, 0x7EB1A0, TechnoClass_Flash) // InfantryClass
DEFINE_FUNCTION_JUMP(VTABLE, 0x7E23EC, TechnoClass_Flash) // AircraftClass

void __fastcall BuildingClass_Flash(BuildingClass* pThis, void*, int duration)
{
const auto pExt = TechnoExt::ExtMap.Find(pThis);

for (const auto& pAttachment : pExt->ChildAttachments)
{
if (pAttachment->GetType()->InheritStateEffects && pAttachment->Child)
pAttachment->Child->Flash(duration);
}

return pThis->BuildingClass::Flash(duration);
}
DEFINE_FUNCTION_JUMP(VTABLE, 0x7E4004, BuildingClass_Flash) // BuildingClass

#pragma endregion

DEFINE_HOOK(0x6CC763, SuperClass_Place_ChronoWarp_SkipChildren, 0x6)
{
enum { Skip = 0x6CCCCA, Continue = 0 };
Expand Down
2 changes: 1 addition & 1 deletion src/New/Entity/AttachmentClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void AttachmentClass::AI()
this->Child->unknown_280 = this->Parent->unknown_280; // sth related to teleport
this->Child->BeingWarpedOut = this->Parent->BeingWarpedOut;
this->Child->Deactivated = this->Parent->Deactivated;
this->Child->Flash(this->Parent->Flashing.DurationRemaining);
//this->Child->Flash(this->Parent->Flashing.DurationRemaining);

this->Child->IronCurtainTimer = this->Parent->IronCurtainTimer;
this->Child->IdleActionTimer = this->Parent->IdleActionTimer;
Expand Down
2 changes: 2 additions & 0 deletions src/New/Type/AttachmentTypeClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ void AttachmentTypeClass::LoadFromINI(CCINIClass* pINI)
this->InheritHeightStatus.Read(exINI, section, "InheritHeightStatus");
this->OccupiesCell.Read(exINI, section, "OccupiesCell");
this->LowSelectionPriority.Read(exINI, section, "LowSelectionPriority");
this->PassSelection.Read(exINI, section, "PassSelection");
this->TransparentToMouse.Read(exINI, section, "TransparentToMouse");
this->YSortPosition.Read(exINI, section, "YSortPosition");
this->DestructionWeapon_Child.Read(exINI, section, "DestructionWeapon.Child");
Expand All @@ -47,6 +48,7 @@ void AttachmentTypeClass::Serialize(T& Stm)
.Process(this->InheritHeightStatus)
.Process(this->OccupiesCell)
.Process(this->LowSelectionPriority)
.Process(this->PassSelection)
.Process(this->TransparentToMouse)
.Process(this->YSortPosition)
.Process(this->DestructionWeapon_Child)
Expand Down
2 changes: 2 additions & 0 deletions src/New/Type/AttachmentTypeClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class AttachmentTypeClass final : public Enumerable<AttachmentTypeClass>
Valueable<bool> InheritHeightStatus;
Valueable<bool> OccupiesCell;
Valueable<bool> LowSelectionPriority;
Valueable<bool> PassSelection;
Valueable<bool> TransparentToMouse;
Valueable<AttachmentYSortPosition> YSortPosition;
Nullable<WeaponTypeClass*> DestructionWeapon_Child;
Expand All @@ -39,6 +40,7 @@ class AttachmentTypeClass final : public Enumerable<AttachmentTypeClass>
, InheritDestruction { true }
, InheritHeightStatus { true }
, LowSelectionPriority { true }
, PassSelection { true }
, TransparentToMouse { false }
, YSortPosition { AttachmentYSortPosition::Default }
, DestructionWeapon_Child { }
Expand Down
Loading