Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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 @@ -442,6 +442,7 @@ This page lists all the individual contributions to the project by their author.
- Fix an issue where `OmniFire` was ineffective on buildings with `Turret=yes`
- Fix an issue where setting a production building as `Primary` could cause it to enter an unload state
- SkipMapSelect Enhancement
- Ares' `KeepAlive` adds global tags
- **NetsuNegi**:
- Forbidding parallel AI queues by type
- Jumpjet crash speed fix when crashing onto building
Expand Down
6 changes: 6 additions & 0 deletions docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
- `ProjectileRange` now has weapon range modifiers applied to it if greater than 0 and unless `ProjectileRange.ApplyModifiers` is set to false on the WeaponType.
- Allowed customizing the default value of `[Warhead] -> PreventScatter` via `[CombatDamage] -> Warhead.PreventScatter`.
- Allowed `SW.ShowCameo` and `SW.ManualFire` to work independently of `SW.AutoFire`.
- Ares' `KeepAlive` adds global tags.

## Newly added global settings

Expand Down Expand Up @@ -541,6 +542,11 @@ In `rulesmd.ini`:
```ini
[General]
DefaultToGuardArea=false ; boolean
KeepAlive.Buildings=true ; boolean
KeepAlive.Defenses=true ; boolean
KeepAlive.Infantry=false ; boolean
KeepAlive.Units=false ; boolean
KeepAlive.Aircraft=false ; boolean

[CombatDamage]
Warhead.PreventScatter=false ; boolean
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ HideShakeEffects=false ; boolean

#### Fixes / interactions with other extensions:
- Allowed `SW.ShowCameo` and `SW.ManualFire` to work independently of `SW.AutoFire` (by Noble_Fish)
- Ares' `KeepAlive` adds global tags (by FlyStar)

```

Expand Down
11 changes: 11 additions & 0 deletions src/Ext/Rules/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,12 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
this->ReadyToNextMission_MovingCheck.Read(exINI, GameStrings::General, "ReadyToNextMission.MovingCheck");

this->Warhead_PreventScatter.Read(exINI, GameStrings::CombatDamage, "Warhead.PreventScatter");

this->KeepAlive_Infantry.Read(exINI, GameStrings::General, "KeepAlive.Infantry");
this->KeepAlive_Units.Read(exINI, GameStrings::General, "KeepAlive.Units");
this->KeepAlive_Aircraft.Read(exINI, GameStrings::General, "KeepAlive.Aircraft");
this->KeepAlive_Buildings.Read(exINI, GameStrings::General, "KeepAlive.Buildings");
this->KeepAlive_Defenses.Read(exINI, GameStrings::General, "KeepAlive.Defenses");

this->ProjectileRange_ApplyModifiers.Read(exINI, GameStrings::CombatDamage, "ProjectileRange.ApplyModifiers");

Expand Down Expand Up @@ -1090,6 +1096,11 @@ void RulesExt::ExtData::Serialize(T& Stm)
.Process(this->ReadyToNextMission_MovingCheck)
.Process(this->Warhead_PreventScatter)
.Process(this->ProjectileRange_ApplyModifiers)
.Process(this->KeepAlive_Infantry)
.Process(this->KeepAlive_Units)
.Process(this->KeepAlive_Aircraft)
.Process(this->KeepAlive_Buildings)
.Process(this->KeepAlive_Defenses)
;
}

Expand Down
12 changes: 12 additions & 0 deletions src/Ext/Rules/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,12 @@ class RulesExt
Valueable<bool> NoAlphaImageOnBuildup;

Valueable<bool> Warhead_PreventScatter;

Valueable<bool> KeepAlive_Infantry;
Valueable<bool> KeepAlive_Units;
Valueable<bool> KeepAlive_Aircraft;
Valueable<bool> KeepAlive_Buildings;
Valueable<bool> KeepAlive_Defenses;

Valueable<bool> ProjectileRange_ApplyModifiers;

Expand Down Expand Up @@ -1009,6 +1015,12 @@ class RulesExt
, Warhead_PreventScatter { false }

, ProjectileRange_ApplyModifiers { true }

, KeepAlive_Infantry { false }
, KeepAlive_Units { false }
, KeepAlive_Aircraft { false }
, KeepAlive_Buildings { true }
, KeepAlive_Defenses { true }
{ }

virtual ~ExtData() = default;
Expand Down
2 changes: 2 additions & 0 deletions src/Ext/TechnoType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,7 @@ void TechnoTypeExt::LoadFromINIFile(CCINIClass* const pINI)

// Ares 3.0
this->Unsellable.Read(exINI, pSection, "Unsellable");
this->KeepAlive.Read(exINI, pSection, "KeepAlive");

if (pThis->Gunner)
{
Expand Down Expand Up @@ -1804,6 +1805,7 @@ void TechnoTypeExt::Serialize(T& Stm)
.Process(this->JumpjetClimbIgnoreBuilding)

.Process(this->Unsellable)
.Process(this->KeepAlive)

.Process(this->ExtraThreat_Enabled)
.Process(this->ExtraThreat_IsThreat)
Expand Down
4 changes: 3 additions & 1 deletion src/Ext/TechnoType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,8 @@ class TechnoTypeExt : public ObjectTypeExt
Valueable<double> Convert_Health_BelowPercent;
Nullable<TechnoTypeClass*> Convert_Health;

Nullable<bool> Unsellable; // Ares 3.0
Nullable<bool> Unsellable; // Ares 3.0
Nullable<bool> KeepAlive; // Ares 3.0

TechnoTypeExt(TechnoTypeClass* OwnerObject) : ObjectTypeExt(OwnerObject)
, HealthBar_Hide { false }
Expand Down Expand Up @@ -814,6 +815,7 @@ class TechnoTypeExt : public ObjectTypeExt
, JumpjetClimbIgnoreBuilding {}

, Unsellable {}
, KeepAlive {}

, ExtraThreat_Enabled { false }
, ExtraThreat_IsThreat {}
Expand Down
65 changes: 65 additions & 0 deletions src/Misc/Hooks.Ares.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,65 @@

#pragma endregion

#pragma region AresKeepAlive

struct AresHouseExt
{
char _[0x18];
int KeepAliveTechnos;
int KeepAliveBuildings;
};

static bool __fastcall AresHouseExt_UpdateKeepAlive(AresHouseExt* pExt_Ares, void*, TechnoClass* const pTechno, const AbstractType rtti, const bool add)
{
bool keepAlive = false;
bool result = false;
auto const pTypeExt = TechnoExt::Fetch(pTechno)->TypeExtData;
auto const pType = pTypeExt->OwnerObject();

if (!pType->Insignificant && !pType->DontScore)
{
switch (rtti)
{
case AbstractType::Infantry:
keepAlive = RulesExt::Global()->KeepAlive_Infantry;
break;
case AbstractType::Unit:
keepAlive = RulesExt::Global()->KeepAlive_Units;
break;
case AbstractType::Aircraft:
keepAlive = RulesExt::Global()->KeepAlive_Aircraft;
break;
case AbstractType::Building:
auto const pBuildingType = static_cast<BuildingTypeClass*>(pType);

if (pBuildingType->BuildCat == BuildCat::Combat)
keepAlive = RulesExt::Global()->KeepAlive_Defenses;
else
keepAlive = RulesExt::Global()->KeepAlive_Buildings;

break;
default:

Check failure on line 218 in src/Misc/Hooks.Ares.cpp

View workflow job for this annotation

GitHub Actions / build

initialization of 'pBuildingType' is skipped by 'default' label [D:\a\Phobos\Phobos\Phobos.vcxproj]
break;
}

result = true;
}

if (pTypeExt->KeepAlive.Get(keepAlive))
{
const int number = add ? 1 : -1;
pExt_Ares->KeepAliveTechnos += number;

if (rtti == AbstractType::Building)
pExt_Ares->KeepAliveBuildings += number;
}

return result;
}

#pragma endregion

DEFINE_HOOK(0x440580, BuildingClass_Unlimbo_UnitDeliveryFix, 0x5)
{
if (UnitDeliveryTemp::Placing)
Expand Down Expand Up @@ -312,6 +371,9 @@
Patch::Apply_LJMP(AresHelper::AresBaseAddress + 0x39635, AresHelper::AresBaseAddress + 0x39664);
// Decouple SW.ManualFire from SW.AutoFire - Ares' SidebarClass_ProcessCameoClick_SuperWeapons
Patch::Apply_LJMP(AresHelper::AresBaseAddress + 0x34DD0, AresHelper::AresBaseAddress + 0x34DD9);

// Ares' `KeepAlive` adds global tags.
Patch::Apply_LJMP(AresHelper::AresBaseAddress + 0x21F70, GET_OFFSET(AresHouseExt_UpdateKeepAlive));
}

void Apply_Ares3_0p1_Patches()
Expand Down Expand Up @@ -430,4 +492,7 @@
Patch::Apply_LJMP(AresHelper::AresBaseAddress + 0x3A0B5, AresHelper::AresBaseAddress + 0x3A0E4);
// Decouple SW.ManualFire from SW.AutoFire - Ares' SidebarClass_ProcessCameoClick_SuperWeapons
Patch::Apply_LJMP(AresHelper::AresBaseAddress + 0x35810, AresHelper::AresBaseAddress + 0x35819);

// Ares' `KeepAlive` adds global tags.
Patch::Apply_LJMP(AresHelper::AresBaseAddress + 0x229F0, GET_OFFSET(AresHouseExt_UpdateKeepAlive));
}
Loading