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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Credits
- **secsome (SEC-SOME)** - debug info dump hotkey, refactoring & porting of Ares helper code, introducing more Ares-derived stuff, disguise removal warhead, Mind Control removal warhead, Mind Control enhancement, shields, AnimList.PickRandom, MoveToCell fix, unlimited waypoints, Build At trigger action buildup anim fix, Undeploy building into a unit plays `EVA_NewRallyPointEstablished` fix, custom ore gathering anim, TemporaryClass related crash, Retry dialog on mission failure, Default disguise for individual InfantryTypes, PowerPlant Enhancer, SaveGame Trigger Action, QuickSave command, Numeric variables, Custom gravity for projectiles, Retint map actions bugfix
- **Otamaa (Fahroni, BoredEXE)** - help with CellSpread, ported and fixed custom RadType code, togglable ElectricBolt bolts, customizable Chrono Locomotor properties per TechnoClass, DebrisMaximums fixes, Anim-to-Unit, NotHuman anim sequences improvements, Customizable OpenTopped Properties, hooks for ScriptType Actions 92 & 93, ore stage threshold for `HideIfNoOre`, occupied building `MuzzleFlashX` bugfix,`EnemyUIName=` for other TechnoTypes, TerrainType `DestroyAnim` & `DestroySound`
- **E1 Elite** - TileSet 255 and above bridge repair fix
- **FS-21** - Dump Object Info enhancements, Powered.KillSpawns, Spawner.LimitRange, ScriptType Actions 71 to 113, MC deployer fixes, help with docs, Automatic Passenger Deletion
- **FS-21** - Dump Object Info enhancements, Powered.KillSpawns, Spawner.LimitRange, ScriptType Actions 71 to 113, MC deployer fixes, help with docs, Automatic Passenger Deletion, Customize resource storage
- **AutoGavy** - interceptor logic, warhead critical damage system
- **ChrisLv_CN** - interceptor logic, LaserTrails, laser fixes, general assistance (work relicensed under [following permission](images/ChrisLv-relicense.png))
- **Xkein** - general assistance, YRpp edits
Expand Down
11 changes: 11 additions & 0 deletions docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,17 @@ In `rulesmd.ini`:
Powered.KillSpawns=no ; boolean
```

### Customize resource storage

- Now Ares `Storage` feature can set which Tiberium type from `[Tiberiums]` list should be used for storing resources in structures with `Refinery.UseStorage=yes` and `Storage` > 0.
- This tag can not be used without Ares.

In `rulesmd.ini`:
```ini
[General]
Storage.TiberiumIndex=-1 ; integer, [Tiberiums] list index
```

### Customizable unit image in art

- `Image` tag in art INI is no longer limited to AnimationTypes and BuildingTypes, and can be applied to all TechnoTypes (InfantryTypes, VehicleTypes, AircraftTypes, BuildingTypes).
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ New:
- Added Production and Money to Dump Object Info command (by FS-21)
- `EnemyUIName=` Now also works for other TechnoTypes (by Otamaa)
- `DestroyAnim` & `DestroySound` for TerrainTypes (by Otamaa)
- `Storage.TiberiumIndex` for customizing resource storage in structures (by FS-21)

Vanilla fixes:
- Fixed laser drawing code to allow for thicker lasers in house color draw mode (by Kerbiter, ChrisLv_CN)
Expand Down
23 changes: 23 additions & 0 deletions src/Ext/Building/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,29 @@
template<> const DWORD Extension<BuildingClass>::Canary = 0x87654321;
BuildingExt::ExtContainer BuildingExt::ExtMap;

void BuildingExt::StoreTiberium(BuildingClass* pThis, float amount, int idxTiberiumType, int idxStorageTiberiumType)
{
auto const pDepositableTiberium = TiberiumClass::Array->GetItem(idxStorageTiberiumType);
float depositableTiberiumAmount = 0.0f; // Number of 'bails' that will be stored.
auto const pTiberium = TiberiumClass::Array->GetItem(idxTiberiumType);

if (amount > 0.0)
{
if (auto pBuildingType = pThis->Type)
{
if (auto const pExt = BuildingTypeExt::ExtMap.Find(pBuildingType))
{
if (pExt->Refinery_UseStorage)
{
// Store Tiberium in structures
depositableTiberiumAmount = (amount * pTiberium->Value) / pDepositableTiberium->Value;
pThis->Owner->GiveTiberium(depositableTiberiumAmount, idxStorageTiberiumType);
}
}
}
}
}

// =============================
// load / save

Expand Down
5 changes: 5 additions & 0 deletions src/Ext/Building/Body.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#pragma once
#include <BuildingClass.h>
#include <HouseClass.h>
#include <TiberiumClass.h>

#include <Helpers/Macro.h>
#include <Utilities/Container.h>
#include <Utilities/TemplateDef.h>

#include <Ext/TechnoType/Body.h>
#include <Ext/BuildingType/Body.h>

class BuildingExt
{
Expand Down Expand Up @@ -49,4 +52,6 @@ class BuildingExt

static bool LoadGlobals(PhobosStreamReader& Stm);
static bool SaveGlobals(PhobosStreamWriter& Stm);

static void StoreTiberium(BuildingClass* pThis, float amount, int idxTiberiumType, int idxStorageTiberiumType);
};
2 changes: 2 additions & 0 deletions src/Ext/BuildingType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ void BuildingTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
}
}

this->Refinery_UseStorage.Read(exINI, pSection, "Refinery.UseStorage");
}

void BuildingTypeExt::ExtData::CompleteInitialization()
Expand All @@ -151,6 +152,7 @@ void BuildingTypeExt::ExtData::Serialize(T& Stm)
.Process(this->PowerPlantEnhancer_Factor)
.Process(this->SuperWeapons)
.Process(this->OccupierMuzzleFlashes)
.Process(this->Refinery_UseStorage)
;
}

Expand Down
3 changes: 3 additions & 0 deletions src/Ext/BuildingType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@ class BuildingTypeExt

DynamicVectorClass<Point2D> OccupierMuzzleFlashes;

Valueable<bool> Refinery_UseStorage;

ExtData(BuildingTypeClass* OwnerObject) : Extension<BuildingTypeClass>(OwnerObject)
, PowersUp_Owner { AffectedHouse::Owner }
, PowersUp_Buildings {}
, PowerPlantEnhancer_Buildings {}
, PowerPlantEnhancer_Amount {}
, PowerPlantEnhancer_Factor {}
, OccupierMuzzleFlashes()
, Refinery_UseStorage { false }
{ }

virtual ~ExtData() = default;
Expand Down
28 changes: 27 additions & 1 deletion src/Ext/House/Hooks.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "Body.h"

#include "../Techno/Body.h"
#include "../Building/Body.h"
#include <unordered_map>

DEFINE_HOOK(0x508C30, HouseClass_UpdatePower_UpdateCounter, 0x5)
Expand Down Expand Up @@ -36,4 +38,28 @@ DEFINE_HOOK(0x508CF2, HouseClass_UpdatePower_PowerOutput, 0x7)
pThis->PowerOutput += BuildingTypeExt::GetEnhancedPower(pBld, pThis);

return 0x508D07;
}
}

DEFINE_HOOK(0x73E474, UnitClass_Unload_Storage, 0x6)
{
GET(BuildingClass* const, pBuilding, EDI);
GET(int const, idxTiberium, EBP);
REF_STACK(float, amount, 0x1C);

auto pTypeExt = BuildingTypeExt::ExtMap.Find(pBuilding->Type);
if (!pTypeExt)
return 0;

if (!pBuilding->Owner)
return 0;

auto storageTiberiumIndex = RulesExt::Global()->Storage_TiberiumIndex;

if (pTypeExt->Refinery_UseStorage && storageTiberiumIndex >= 0)
{
BuildingExt::StoreTiberium(pBuilding, amount, idxTiberium, storageTiberiumIndex);
amount = 0.0f;
}

return 0;
}
2 changes: 2 additions & 0 deletions src/Ext/Rules/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)

INI_EX exINI(pINI);

this->Storage_TiberiumIndex.Read(exINI, GENERAL_SECTION, "Storage.TiberiumIndex");
this->RadApplicationDelay_Building.Read(exINI, "Radiation", "RadApplicationDelay.Building");
this->Pips_Shield.Read(exINI, "AudioVisual", "Pips.Shield");
this->Pips_Shield_Buildings.Read(exINI, "AudioVisual", "Pips.Shield.Building");
Expand Down Expand Up @@ -165,6 +166,7 @@ void RulesExt::ExtData::Serialize(T& Stm)
.Process(this->JumpjetAllowLayerDeviation)
.Process(this->AITargetTypesLists)
.Process(this->AIScriptsLists)
.Process(this->Storage_TiberiumIndex)
;
}

Expand Down
2 changes: 2 additions & 0 deletions src/Ext/Rules/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class RulesExt
Valueable<double> JumpjetCrash;
Valueable<bool> JumpjetNoWobbles;
Valueable<bool> JumpjetAllowLayerDeviation;
Valueable<int> Storage_TiberiumIndex;

ExtData(RulesClass* OwnerObject) : Extension<RulesClass>(OwnerObject)
, Pips_Shield { { -1,-1,-1 } }
Expand All @@ -43,6 +44,7 @@ class RulesExt
, JumpjetCrash { 5.0 }
, JumpjetNoWobbles { false }
, JumpjetAllowLayerDeviation { true }
, Storage_TiberiumIndex { -1 }
{ }

virtual ~ExtData() = default;
Expand Down