Skip to content
Open
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
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,7 @@ This page lists all the individual contributions to the project by their author.
- Framework for dynamic sight
- Fix voxel projectile and animation lighting issues
- Export interface for external call
- Auto-remove earliest beacon
- **solar-III (凤九歌)**
- Target scanning delay customization (documentation)
- Skip target scanning function calling for unarmed technos (documentation)
Expand Down
2 changes: 1 addition & 1 deletion YRpp
11 changes: 11 additions & 0 deletions docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,17 @@ In `rulesmd.ini`:
AllowDeployControlledMCV=false ; boolean
```

### Auto-remove earliest beacon

- In vanilla, each player can place up to 3 beacons. When all 3 beacon slots are occupied, attempting to place a new beacon does nothing. Now you can make the game automatically remove the earliest-placed beacon to free up a slot for the new one.
- `[General] -> AutoRemoveEarliestBeacon` controls this behavior.

In `rulesmd.ini`:
```ini
[General]
AutoRemoveEarliestBeacon=no ; boolean
```

### Chrono sparkle animation customization & improvements

- It is now possible to customize the frame delay between instances of `[General] -> ChronoSparkle1` animations created on objects being warped by setting `[General] -> ChronoSparkleDisplayDelay`.
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ HideShakeEffects=false ; boolean
- [Customizable Berzerk mission](Fixed-or-Improved-Logics.md#enhanced-berzerk-behavior) (by TaranDahl)
- [Tank Bunker foundation and state update delay improvements](Fixed-or-Improved-Logics.md#tank-bunker-improvements) (by Starkku)
- [Custom cruise missiles](New-or-Enhanced-Logics.md#custom-cruise-missiles) (by Noble_Fish)
- [Auto-remove earliest beacon](Fixed-or-Improved-Logics.md#auto-remove-earliest-beacon) (by TaranDahl)
#### Vanilla fixes:
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)
Expand Down
3 changes: 3 additions & 0 deletions docs/locale/zh_CN/LC_MESSAGES/CREDITS.po
Original file line number Diff line number Diff line change
Expand Up @@ -2758,6 +2758,9 @@ msgstr "修复了 Voxel 抛射体和动画的光照问题"
msgid "Export interface for external call"
msgstr "用于外部调用的导出接口"

msgid "Auto-remove earliest beacon"
msgstr "自动移除最早的信标"

msgid "**solar-III (凤九歌)**"
msgstr "**solar-III(凤九歌)**"

Expand Down
13 changes: 13 additions & 0 deletions docs/locale/zh_CN/LC_MESSAGES/Fixed-or-Improved-Logics.po
Original file line number Diff line number Diff line change
Expand Up @@ -1935,6 +1935,19 @@ msgstr "在原版中你不能将一个被心灵控制的载具部署为 `Constru
msgid "In `rulesmd.ini`:"
msgstr "在 `rulesmd.ini`:"

msgid "Auto-remove earliest beacon"
msgstr "自动移除最早的信标"

msgid ""
"In vanilla, each player can place up to 3 beacons. When all 3 beacon slots "
"are occupied, attempting to place a new beacon does nothing. Now you can "
"make the game automatically remove the earliest-placed beacon to free up a "
"slot for the new one."
msgstr "在原版中,每个玩家最多可以放置 3 个信标。当 3 个信标槽位都被占用时,尝试放置新信标将不起作用。现在你可以让游戏自动移除最早放置的信标,为新信标腾出槽位。"

msgid "`[General] -> AutoRemoveEarliestBeacon` controls this behavior."
msgstr "`[General] -> AutoRemoveEarliestBeacon` 控制此行为。"

msgid "Chrono sparkle animation customization & improvements"
msgstr "超时空闪光动画的自定义与改进"

Expand Down
7 changes: 7 additions & 0 deletions docs/locale/zh_CN/LC_MESSAGES/Whats-New.po
Original file line number Diff line number Diff line change
Expand Up @@ -2052,6 +2052,13 @@ msgid ""
msgstr ""
"[坦克碉堡面积和状态更新间隔改进](Fixed-or-Improved-Logics.md#tank-bunker-improvements) (by Starkku)"

msgid ""
"[Auto-remove earliest beacon](Fixed-or-Improved-Logics.md#auto-remove-"
"earliest-beacon) (by TaranDahl)"
msgstr ""
"[自动移除最早的信标](Fixed-or-Improved-Logics.md#auto-remove-earliest-"
"beacon)(by TaranDahl)"

msgid "Vanilla fixes:"
msgstr "原版问题修复:"

Expand Down
1 change: 1 addition & 0 deletions src/Ext/House/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,7 @@ void HouseExt::ExtData::Serialize(T& Stm)
.Process(this->FreeRadar)
.Process(this->ForceRadar)
.Process(this->PlayerAutoRepair)
//.Process(this->BeaconsPlacedOrder) beacon is not saved, so this follows it.
;
}

Expand Down
5 changes: 5 additions & 0 deletions src/Ext/House/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <Utilities/Container.h>
#include <Utilities/TemplateDef.h>

#include <array>

class HouseExt
{
public:
Expand Down Expand Up @@ -69,6 +71,8 @@ class HouseExt

bool PlayerAutoRepair;

std::array<int, 3> BeaconsPlacedOrder;

ExtData(HouseClass* OwnerObject) : Extension<HouseClass>(OwnerObject)
, PowerPlantEnhancers {}
, OwnedLimboDeliveredBuildings {}
Expand Down Expand Up @@ -103,6 +107,7 @@ class HouseExt
, FreeRadar(false)
, ForceRadar(false)
, PlayerAutoRepair(true)
, BeaconsPlacedOrder { 0, 0, 0 }
{ }

bool OwnsLimboDeliveredBuilding(BuildingClass* pBuilding) const;
Expand Down
73 changes: 73 additions & 0 deletions src/Ext/House/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
#include "Ext/Building/Body.h"
#include <Ext/Event/Body.h>

#include <BeaconManagerClass.h>

#include <unordered_map>
#include <algorithm>
#include <utility>

// Trigger power recalculation on gain/loss of any techno, not just buildings.
DEFINE_HOOK_AGAIN(0x5025F0, HouseClass_RegisterGain, 0x5) // RegisterLoss
Expand Down Expand Up @@ -681,3 +685,72 @@ DEFINE_HOOK(0x45063F, BuildingClass_UpdateRepairSell_PlayerAutoRepair, 0x6)
}

#pragma endregion

#pragma region BeaconOrder

DEFINE_HOOK(0x43131B, BeaconManagerClass_DeleteBeacon_RecordOrder, 0x5)
{
GET(int, beaconIdx, EBX);
GET(int, houseIdx, ECX);

const auto pHouse = HouseClass::Array.GetItem(houseIdx);
const auto pExt = HouseExt::ExtMap.Find(pHouse);

const int oldValue = std::exchange(pExt->BeaconsPlacedOrder[beaconIdx], 0);

if (oldValue != 0)
{
for (int i = 0; i < 3; ++i)
{
if (i != beaconIdx && pExt->BeaconsPlacedOrder[i] > oldValue)
--pExt->BeaconsPlacedOrder[i];
}
}

return 0;
}

DEFINE_HOOK_AGAIN(0x430E5D, BeaconManagerClass_PlaceBeacon_RecordOrder, 0x5)
DEFINE_HOOK(0x430C64, BeaconManagerClass_PlaceBeacon_RecordOrder, 0x5)
{
GET(int, beaconIdx, EAX);
GET(int, houseIdx, EBX);

const auto pHouse = HouseClass::Array.GetItem(houseIdx);
const auto pExt = HouseExt::ExtMap.Find(pHouse);

const int maxVal = std::max({ pExt->BeaconsPlacedOrder[0], pExt->BeaconsPlacedOrder[1], pExt->BeaconsPlacedOrder[2] });
pExt->BeaconsPlacedOrder[beaconIdx] = maxVal + 1;

return 0;
}

DEFINE_HOOK(0x4AC9B2, MouseClass_ToggleBeaconMode_AllUsed, 0x6)
{
GET(bool, canPlace, EAX);

if (canPlace)
return 0x4AC9B8;

const auto pHouse = HouseClass::CurrentPlayer;
const auto pExt = HouseExt::ExtMap.Find(pHouse);

for (int i = 0; i < 3; ++i)
{
if (pExt->BeaconsPlacedOrder[i] == 1)
{
auto pManager = &BeaconManagerClass::Instance;
auto pBeacon = pManager->Beacons[pHouse->ArrayIndex][i];
// Select and delete beacon.
// If you don't select the beacon, the game will not send the IPX packet.
MapClass::UnselectAll();
pBeacon->Bitfield |= 2;
pManager->DeleteBeacon(-1, -1);
break;
}
}

return 0x4AC9B8;
}

#pragma endregion
2 changes: 2 additions & 0 deletions src/Ext/Rules/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
this->BerzerkMission.Read(exINI, GameStrings::CombatDamage, "BerzerkMission");

this->BunkerStateUpdateDelay.Read(exINI, GameStrings::General, "BunkerStateUpdateDelay");
this->AutoRemoveEarliestBeacon.Read(exINI, GameStrings::General, "AutoRemoveEarliestBeacon");

// Section AITargetTypes
int itemsCount = pINI->GetKeyCount("AITargetTypes");
Expand Down Expand Up @@ -790,6 +791,7 @@ void RulesExt::ExtData::Serialize(T& Stm)
.Process(this->TeamDelays_Count)
.Process(this->BerzerkMission)
.Process(this->BunkerStateUpdateDelay)
.Process(this->AutoRemoveEarliestBeacon)
;
}

Expand Down
3 changes: 3 additions & 0 deletions src/Ext/Rules/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,8 @@ class RulesExt

Valueable<int> BunkerStateUpdateDelay;

Valueable<bool> AutoRemoveEarliestBeacon;

ExtData(RulesClass* OwnerObject) : Extension<RulesClass>(OwnerObject)
, Storage_TiberiumIndex { -1 }
, HarvesterDumpAmount { 0.0f }
Expand Down Expand Up @@ -690,6 +692,7 @@ class RulesExt
, BerzerkMission { Mission::Hunt }

, BunkerStateUpdateDelay { 15 }
, AutoRemoveEarliestBeacon { false }
{ }

virtual ~ExtData() = default;
Expand Down
Loading