diff --git a/CREDITS.md b/CREDITS.md index 0e52901bd1..bc1b537c6c 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -446,6 +446,7 @@ This page lists all the individual contributions to the project by their author. - SkipMapSelect Enhancement - Add a global default value for `KeepAlive` - Customized transport plane for teams + - Customize the country displayed in `Sight` - **NetsuNegi**: - Forbidding parallel AI queues by type - Jumpjet crash speed fix when crashing onto building diff --git a/docs/New-or-Enhanced-Logics.md b/docs/New-or-Enhanced-Logics.md index 91d2474500..a70c8b9032 100644 --- a/docs/New-or-Enhanced-Logics.md +++ b/docs/New-or-Enhanced-Logics.md @@ -680,6 +680,21 @@ In `artmd.ini`: DetachedReport= ; Sound entry ``` +## Country + +### Customize the country displayed in `Sight` + +- You can now customize which countries the `Sight` unit for that nation provides map visibility to. + +In `rulesmd.ini`: +```ini +[AudioVisual] +RevealHouses=team ; Affected House Enumeration (none|owner/self|allies/ally|team|enemies/enemy|neutral|all) + +[SOMECOUNTRY] ; Country +RevealHouses= ; Affected House Enumeration (none|owner/self|allies/ally|team|enemies/enemy|neutral|all), defaults to [AudioVisual] -> RevealHouses +``` + ## Buildings ### Build area customizations diff --git a/docs/Whats-New.md b/docs/Whats-New.md index f7e461381a..ffad72be4a 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -441,6 +441,7 @@ HideShakeEffects=false ; boolean - [Attached animation draw offset customizations](Fixed-or-Improved-Logics.md#draw-offset-customization) (by Starkku) - [Draw offset rules for AttachEffect animations](New-or-Enhanced-Logics.md#attached-effects) (by Starkku) - [Allowed customize that whether `Temporal=yes` warhead will cause target building animation poweroff](Fixed-or-Improved-Logics.md#allow-customize-that-whether-temporal-yes-warhead-will-cause-target-building-animation-poweroff) (by NetsuNegi) +- Customize the country displayed in `Sight` (by FlyStar) #### Vanilla fixes: - Fixed the bug where a building with `Factory=BuildingType` owned by the AI did not play `ProductionAnim` when placing a produced building (by Noble_Fish) diff --git a/src/Ext/HouseType/Body.cpp b/src/Ext/HouseType/Body.cpp index 08c0adfd4e..d52d80561f 100644 --- a/src/Ext/HouseType/Body.cpp +++ b/src/Ext/HouseType/Body.cpp @@ -18,6 +18,7 @@ void HouseTypeExt::LoadFromINIFile(CCINIClass* pINI) INI_EX exINI(pINI); this->EVATag.Read(pINI, pSection, "EVA.Tag"); + this->RevealHouses.Read(exINI, pSection, "RevealHouses"); } template @@ -25,6 +26,7 @@ void HouseTypeExt::Serialize(T& Stm) { Stm .Process(this->EVATag) + .Process(this->RevealHouses) ; } diff --git a/src/Ext/HouseType/Body.h b/src/Ext/HouseType/Body.h index c843286266..f6d336c65c 100644 --- a/src/Ext/HouseType/Body.h +++ b/src/Ext/HouseType/Body.h @@ -26,9 +26,11 @@ class HouseTypeExt final : public AbstractTypeExt } EVAType EVATag; + Nullable RevealHouses; HouseTypeExt(HouseTypeClass* OwnerObject) : AbstractTypeExt(OwnerObject) , EVATag { -2 } + , RevealHouses {} { } virtual ~HouseTypeExt() = default; diff --git a/src/Ext/HouseType/Hooks.cpp b/src/Ext/HouseType/Hooks.cpp index 605bf0bbf7..c40abbc10e 100644 --- a/src/Ext/HouseType/Hooks.cpp +++ b/src/Ext/HouseType/Hooks.cpp @@ -35,3 +35,32 @@ DEFINE_HOOK(0x68AD0C, ScenarioClass_ReadMap_SetEVAIndex, 0x7) return 0; } + +DEFINE_HOOK_AGAIN(0x70B1F2, TechnoClass_RevealHouses, 0x6) // TechnoClass::vt_entry_48C +DEFINE_HOOK_AGAIN(0x70B15A, TechnoClass_RevealHouses, 0x6) // TechnoClass::UpdateSight +DEFINE_HOOK(0x70AF22, TechnoClass_RevealHouses, 0x6) // TechnoClass::See +{ + const DWORD address = R->Origin(); + auto const pTechno = address == 0x70B1F2 ? R->ECX() : R->ESI(); + + auto const pPlayer = HouseClass::CurrentPlayer; + auto const pHouse = pTechno->Owner; + const bool canShow = pPlayer ? EnumFunctions::CanTargetHouse( + HouseTypeExt::ExtMap.Find(pHouse->Type)->RevealHouses.Get(RulesExt::Global()->RevealHouses), pHouse, pPlayer) + : false; + + switch (address) + { + case 0x70B1F2: + R->ESI(canShow ? pPlayer : nullptr); + break; + case 0x70B15A: + R->EDX(canShow ? pPlayer : nullptr); + return 0x70B160; + default: + R->EDX(canShow ? pPlayer : nullptr); + return 0x70AF28; + } + + return 0; +} diff --git a/src/Ext/Rules/Body.cpp b/src/Ext/Rules/Body.cpp index c0319d97ba..afc55bd155 100644 --- a/src/Ext/Rules/Body.cpp +++ b/src/Ext/Rules/Body.cpp @@ -684,6 +684,7 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI) this->CustomSequenceNormalized[i] = normalized ? 1 : 0; } + this->RevealHouses.Read(exINI, GameStrings::AudioVisual, "RevealHouses"); } // this should load everything that TypeData is not dependant on @@ -1140,6 +1141,7 @@ void RulesExt::ExtData::Serialize(T& Stm) .Process(this->Cloak_KickOutParasite) .Process(this->CustomSequenceRates) .Process(this->CustomSequenceNormalized) + .Process(this->RevealHouses) ; } diff --git a/src/Ext/Rules/Body.h b/src/Ext/Rules/Body.h index 9603b2570c..3051ddd23c 100644 --- a/src/Ext/Rules/Body.h +++ b/src/Ext/Rules/Body.h @@ -559,6 +559,8 @@ class RulesExt // Global default per-sequence game-speed normalization flags for infantry std::vector CustomSequenceNormalized; + Valueable RevealHouses; + ExtData(RulesClass* OwnerObject) : Extension(OwnerObject) , Storage_TiberiumIndex { -1 } , HarvesterDumpAmount { 0.0f } @@ -1051,6 +1053,8 @@ class RulesExt , CustomSequenceRates(42, -1) , CustomSequenceNormalized(42, -1) + + , RevealHouses { AffectedHouse::Team } { } virtual ~ExtData() = default;