diff --git a/YRpp b/YRpp index 5af96790ce..5cd30376e7 160000 --- a/YRpp +++ b/YRpp @@ -1 +1 @@ -Subproject commit 5af96790ce73e4ea068a390c60c124dccbc220e1 +Subproject commit 5cd30376e723e65be5aa5e8741be8d1e55accad8 diff --git a/docs/New-or-Enhanced-Logics.md b/docs/New-or-Enhanced-Logics.md index fea18811b5..f5b39738b0 100644 --- a/docs/New-or-Enhanced-Logics.md +++ b/docs/New-or-Enhanced-Logics.md @@ -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 diff --git a/src/Ext/Techno/Hooks.Misc.cpp b/src/Ext/Techno/Hooks.Misc.cpp index c4344c0c79..c1c04d92cc 100644 --- a/src/Ext/Techno/Hooks.Misc.cpp +++ b/src/Ext/Techno/Hooks.Misc.cpp @@ -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(pThis); - if (duration > 0 && pThis->GetOwningHouse()->IsControlledByCurrentPlayer()) - pThis->Flash(duration); + if (pFlashTarget && pFlashTarget->Owner->IsControlledByCurrentPlayer()) + pFlashTarget->Flash(duration); + } + } return 0; } diff --git a/src/Ext/Techno/Hooks.TechnoAttachment.cpp b/src/Ext/Techno/Hooks.TechnoAttachment.cpp index 09c7bfea0a..36a5248614 100644 --- a/src/Ext/Techno/Hooks.TechnoAttachment.cpp +++ b/src/Ext/Techno/Hooks.TechnoAttachment.cpp @@ -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 }; diff --git a/src/New/Entity/AttachmentClass.cpp b/src/New/Entity/AttachmentClass.cpp index 391cda8d3c..7bc94f7bd0 100644 --- a/src/New/Entity/AttachmentClass.cpp +++ b/src/New/Entity/AttachmentClass.cpp @@ -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; diff --git a/src/New/Type/AttachmentTypeClass.cpp b/src/New/Type/AttachmentTypeClass.cpp index 793a81e361..4165f89bb2 100644 --- a/src/New/Type/AttachmentTypeClass.cpp +++ b/src/New/Type/AttachmentTypeClass.cpp @@ -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"); @@ -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) diff --git a/src/New/Type/AttachmentTypeClass.h b/src/New/Type/AttachmentTypeClass.h index 838413530c..eb519e8d4d 100644 --- a/src/New/Type/AttachmentTypeClass.h +++ b/src/New/Type/AttachmentTypeClass.h @@ -20,6 +20,7 @@ class AttachmentTypeClass final : public Enumerable Valueable InheritHeightStatus; Valueable OccupiesCell; Valueable LowSelectionPriority; + Valueable PassSelection; Valueable TransparentToMouse; Valueable YSortPosition; Nullable DestructionWeapon_Child; @@ -39,6 +40,7 @@ class AttachmentTypeClass final : public Enumerable , InheritDestruction { true } , InheritHeightStatus { true } , LowSelectionPriority { true } + , PassSelection { true } , TransparentToMouse { false } , YSortPosition { AttachmentYSortPosition::Default } , DestructionWeapon_Child { }