Skip to content

Commit 8a79fa4

Browse files
committed
Merge branch 'develop' into BalloonHoverPathingFix
2 parents 51f60a5 + 9afc212 commit 8a79fa4

File tree

9 files changed

+81
-75
lines changed

9 files changed

+81
-75
lines changed

CREDITS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ This page lists all the individual contributions to the project by their author.
356356
- `Set Force Enemy` Trigger Action
357357
- Fix the issue where computer players did not search for new enemies after defeating them or forming alliances with them
358358
- Customize the damage taken when falling from a bridge
359+
- `600 The shield of the attached object is broken` bug fix for the triggered event
359360
- **NetsuNegi**:
360361
- Forbidding parallel AI queues by type
361362
- Jumpjet crash speed fix when crashing onto building

docs/New-or-Enhanced-Logics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1661,7 +1661,7 @@ CombatAlert.Suppress= ; boolean
16611661

16621662
### Recount burst index
16631663

1664-
- You can now make technos recount their current burst index when they have changed the firing weapon or have maintained for a period of time without any targets. Defaults to `[General] -> RecountBurst`, which defaults to false.
1664+
- You can now make technos recount their current burst index when they have changed the firing weapon or have maintained for a period of time without any targets (take the larger value of last firing weapon's `ROF` and 30 frames). Defaults to `[General] -> RecountBurst`, which defaults to false.
16651665

16661666
In `rulesmd.ini`:
16671667
```ini

docs/Whats-New.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ Vanilla fixes:
398398
399399
Phobos fixes:
400400
- Fixed the bug that `AllowAirstrike=no` cannot completely prevent air strikes from being launched against it (by NetsuNegi)
401+
- `600 The shield of the attached object is broken` bug fix for the triggered event (by FlyStar)
401402
402403
Fixes / interactions with other extensions:
403404
- Allowed `AuxBuilding` and Ares' `SW.Aux/NegBuildings` to count building upgrades (by Ollerus)

docs/locale/zh_CN/LC_MESSAGES/New-or-Enhanced-Logics.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6310,7 +6310,7 @@ msgid ""
63106310
"without any targets. Defaults to `[General] -> RecountBurst`, which "
63116311
"defaults to false."
63126312
msgstr ""
6313-
"现在你可以让单位在更换了开火武器或一段时间内没有目标的情况下重置当前的连发索引。默认为 `[General] -> "
6313+
"现在你可以让单位在更换了开火武器或一段时间内没有目标(取上一次发射武器的 `ROF` 与 30 帧的较大值)的情况下重置当前的连发索引。默认为 `[General] -> "
63146314
"RecountBurst`,其默认为 false。"
63156315

63166316
#: ../../New-or-Enhanced-Logics.md:1669

src/Ext/TEvent/Body.cpp

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,18 @@ void TEventExt::ExtData::SaveToStream(PhobosStreamWriter& Stm)
3333
this->Serialize(Stm);
3434
}
3535

36-
bool TEventExt::Execute(TEventClass* pThis, int iEvent, HouseClass* pHouse, ObjectClass* pObject,
37-
CDTimerClass* pTimer, bool* isPersitant, TechnoClass* pSource, bool& bHandled)
36+
std::optional<bool> TEventExt::Execute(TEventClass* pThis, int iEvent, HouseClass* pHouse,
37+
ObjectClass* pObject, CDTimerClass* pTimer, bool* isPersitant, TechnoClass* pSource)
3838
{
39-
bHandled = true;
40-
switch (static_cast<PhobosTriggerEvent>(pThis->EventKind))
39+
const auto eventKind = static_cast<PhobosTriggerEvent>(pThis->EventKind);
40+
41+
// They must be the same, but for other triggers to take effect normally, this cannot be judged outside case.
42+
auto isSameEvent = [&]() { return eventKind == static_cast<PhobosTriggerEvent>(iEvent); };
43+
44+
switch (eventKind)
4145
{
46+
// The triggering conditions that need to be checked at any time are written here
47+
4248
// helper struct
4349
struct and_with { bool operator()(int a, int b) { return a & b; } };
4450

@@ -117,8 +123,6 @@ bool TEventExt::Execute(TEventClass* pThis, int iEvent, HouseClass* pHouse, Obje
117123
case PhobosTriggerEvent::GlobalVariableAndIsTrueGlobalVariable:
118124
return TEventExt::VariableCheckBinary<true, true, and_with>(pThis);
119125

120-
case PhobosTriggerEvent::ShieldBroken:
121-
return ShieldClass::ShieldIsBrokenTEvent(pObject);
122126
case PhobosTriggerEvent::HouseOwnsTechnoType:
123127
return TEventExt::HouseOwnsTechnoTypeTEvent(pThis);
124128
case PhobosTriggerEvent::HouseDoesntOwnTechnoType:
@@ -128,9 +132,20 @@ bool TEventExt::Execute(TEventClass* pThis, int iEvent, HouseClass* pHouse, Obje
128132
case PhobosTriggerEvent::CellHasAnyTechnoTypeFromList:
129133
return TEventExt::CellHasAnyTechnoTypeFromListTEvent(pThis, pObject, pHouse);
130134

135+
136+
// If it requires an additional object as like mapping events 7 or 48, please fill it in here.
137+
138+
// SomeTriggerAttachedToObject needs to be restricted to situations where ...
139+
// case PhobosTriggerEvent::SomeTriggerAttachedToObject:
140+
// return isSameEvent() && ...::ThisAttachedToObjectTEvent(pObject, ...);
141+
142+
// ShieldBroken needs to be restricted to situations where the shield is being attacked.
143+
case PhobosTriggerEvent::ShieldBroken:
144+
return isSameEvent() && ShieldClass::ShieldIsBrokenTEvent(pObject);
145+
146+
131147
default:
132-
bHandled = false;
133-
return true;
148+
return std::nullopt;
134149
};
135150
}
136151

src/Ext/TEvent/Body.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
#include <Utilities/Container.h>
44
#include <Utilities/Template.h>
5-
65
#include <Helpers/Template.h>
76

7+
#include <optional>
8+
89
#include <TEventClass.h>
910

1011
class HouseClass;
@@ -82,8 +83,8 @@ class TEventExt
8283
void Serialize(T& Stm);
8384
};
8485

85-
static bool Execute(TEventClass* pThis, int iEvent, HouseClass* pHouse, ObjectClass* pObject,
86-
CDTimerClass* pTimer, bool* isPersitant, TechnoClass* pSource, bool& bHandled);
86+
static std::optional<bool> Execute(TEventClass* pThis, int iEvent, HouseClass* pHouse,
87+
ObjectClass* pObject, CDTimerClass* pTimer, bool* isPersitant, TechnoClass* pSource);
8788

8889
template<bool IsGlobal, typename _Pr>
8990
static bool VariableCheck(TEventClass* pThis);

src/Ext/TEvent/Hooks.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ DEFINE_HOOK(0x71E940, TEventClass_Execute, 0x5)
2020
GET_STACK(bool*, isPersitant, 0x14);
2121
GET_STACK(TechnoClass*, pSource, 0x18);
2222

23-
bool handled;
23+
const auto result = TEventExt::Execute(pThis, iEvent, pHouse, pObject, pTimer, isPersitant, pSource);
2424

25-
R->AL(TEventExt::Execute(pThis, iEvent, pHouse, pObject, pTimer, isPersitant, pSource, handled));
25+
if (!result.has_value())
26+
return 0;
2627

27-
return handled ? 0x71EA2D : 0;
28+
R->AL(result.value());
29+
return 0x71EA2D;
2830
}
2931

3032
DEFINE_HOOK(0x7271F9, TEventClass_GetFlags, 0x5)

src/Ext/Techno/Hooks.Airstrike.cpp

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ DEFINE_HOOK(0x6F348F, TechnoClass_WhatWeaponShouldIUse_Airstrike, 0x7)
1717
return Primary;
1818

1919
GET(WarheadTypeClass*, pSecondaryWH, ECX);
20+
2021
const auto pWHExt = WarheadTypeExt::ExtMap.Find(pSecondaryWH);
2122

2223
if (!EnumFunctions::IsTechnoEligible(pTargetTechno, pWHExt->AirstrikeTargets))
@@ -27,10 +28,12 @@ DEFINE_HOOK(0x6F348F, TechnoClass_WhatWeaponShouldIUse_Airstrike, 0x7)
2728
if (pTargetTechno->AbstractFlags & AbstractFlags::Foot)
2829
{
2930
const auto pTargetTypeExt = TechnoTypeExt::ExtMap.Find(pTargetType);
31+
3032
return pTargetTypeExt->AllowAirstrike.Get(true) ? Secondary : Primary;
3133
}
3234

3335
const auto pTargetTypeExt = TechnoTypeExt::ExtMap.Find(pTargetType);
36+
3437
return pTargetTypeExt->AllowAirstrike.Get(static_cast<BuildingTypeClass*>(pTargetType)->CanC4) && (!pTargetType->ResourceDestination || !pTargetType->ResourceGatherer) ? Secondary : Primary;
3538
}
3639

@@ -40,8 +43,8 @@ DEFINE_HOOK(0x41D97B, AirstrikeClass_Fire_SetAirstrike, 0x7)
4043

4144
GET(AirstrikeClass*, pThis, EDI);
4245
GET(TechnoClass*, pTarget, ESI);
43-
const auto pTargetExt = TechnoExt::ExtMap.Find(pTarget);
44-
pTargetExt->AirstrikeTargetingMe = pThis;
46+
47+
TechnoExt::ExtMap.Find(pTarget)->AirstrikeTargetingMe = pThis;
4548
pTarget->StartAirstrikeTimer(100000);
4649

4750
return pTarget->WhatAmI() == AbstractType::Building ? ContinueIn : Skip;
@@ -70,8 +73,8 @@ DEFINE_HOOK(0x41DAA4, AirstrikeClass_ResetTarget_ResetForOldTarget, 0xA)
7073
enum { SkipGameCode = 0x41DAAE };
7174

7275
GET(TechnoClass*, pTargetTechno, EDI);
73-
const auto pTargetExt = TechnoExt::ExtMap.Find(pTargetTechno);
74-
pTargetExt->AirstrikeTargetingMe = nullptr;
76+
77+
TechnoExt::ExtMap.Find(pTargetTechno)->AirstrikeTargetingMe = nullptr;
7578

7679
return SkipGameCode;
7780
}
@@ -82,8 +85,8 @@ DEFINE_HOOK(0x41DAD4, AirstrikeClass_ResetTarget_ResetForNewTarget, 0x6)
8285

8386
GET(AirstrikeClass*, pThis, EBP);
8487
GET(TechnoClass*, pTargetTechno, ESI);
85-
const auto pTargetExt = TechnoExt::ExtMap.Find(pTargetTechno);
86-
pTargetExt->AirstrikeTargetingMe = pThis;
88+
89+
TechnoExt::ExtMap.Find(pTargetTechno)->AirstrikeTargetingMe = pThis;
8790

8891
return SkipGameCode;
8992
}
@@ -111,8 +114,7 @@ DEFINE_HOOK(0x41DBD4, AirstrikeClass_Stop_ResetForTarget, 0x7)
111114
}
112115
}
113116

114-
const auto pTargetExt = TechnoExt::ExtMap.Find(pTargetTechno);
115-
pTargetExt->AirstrikeTargetingMe = pLastTargetingMe;
117+
TechnoExt::ExtMap.Find(pTargetTechno)->AirstrikeTargetingMe = pLastTargetingMe;
116118

117119
if (!pLastTargetingMe && Game::IsActive)
118120
pTarget->Mark(MarkType::Change);
@@ -127,8 +129,8 @@ DEFINE_HOOK(0x41D604, AirstrikeClass_PointerGotInvalid_ResetForTarget, 0x6)
127129

128130
GET(ObjectClass*, pTarget, EAX);
129131

130-
if (const auto pTargetTechno = abstract_cast<TechnoClass*>(pTarget))
131-
TechnoExt::ExtMap.Find(pTargetTechno)->AirstrikeTargetingMe = nullptr;
132+
if (const auto pTargetTechnoExt = TechnoExt::ExtMap.Find(abstract_cast<TechnoClass*>(pTarget)))
133+
pTargetTechnoExt->AirstrikeTargetingMe = nullptr;
132134

133135
return SkipGameCode;
134136
}
@@ -138,6 +140,7 @@ DEFINE_HOOK(0x65E97F, HouseClass_CreateAirstrike_SetTaretForUnit, 0x6)
138140
enum { SkipGameCode = 0x65E992 };
139141

140142
GET_STACK(AirstrikeClass*, pThis, STACK_OFFSET(0x38, 0x1C));
143+
141144
const auto pOwner = pThis->Owner;
142145

143146
if (!pOwner || !pOwner->Target)
@@ -146,7 +149,9 @@ DEFINE_HOOK(0x65E97F, HouseClass_CreateAirstrike_SetTaretForUnit, 0x6)
146149
if (const auto pTarget = abstract_cast<TechnoClass*>(pOwner->Target))
147150
{
148151
GET(AircraftClass*, pFirer, ESI);
152+
149153
pFirer->SetTarget(pTarget);
154+
150155
return SkipGameCode;
151156
}
152157

@@ -166,6 +171,7 @@ DEFINE_HOOK(0x51EAE0, TechnoClass_WhatAction_AllowAirstrike, 0x7)
166171
if (const auto pBuilding = abstract_cast<BuildingClass*>(pTechno))
167172
{
168173
const auto pBuildingType = pBuilding->Type;
174+
169175
return pTypeExt->AllowAirstrike.Get(pBuildingType->CanC4) && !pBuildingType->InvisibleInGame ? CanAirstrike : Cannot;
170176
}
171177
else
@@ -181,9 +187,9 @@ DEFINE_HOOK(0x70782D, TechnoClass_PointerGotInvalid_Airstrike, 0x6)
181187
{
182188
GET(TechnoClass*, pThis, ESI);
183189
GET(AbstractClass*, pAbstract, EBP);
184-
const auto pExt = TechnoExt::ExtMap.Find(pThis);
185190

186-
AnnounceInvalidPointer(pExt->AirstrikeTargetingMe, pAbstract);
191+
if (const auto pExt = TechnoExt::ExtMap.Find(pThis)) // It's necessary
192+
AnnounceInvalidPointer(pExt->AirstrikeTargetingMe, pAbstract);
187193

188194
return 0;
189195
}
@@ -195,19 +201,17 @@ DEFINE_HOOK(0x70E92F, TechnoClass_UpdateAirstrikeTint, 0x5)
195201
enum { ContinueIn = 0x70E96E, Skip = 0x70EC9F };
196202

197203
GET(TechnoClass*, pThis, ESI);
198-
const auto pExt = TechnoExt::ExtMap.Find(pThis);
199204

200-
return pExt->AirstrikeTargetingMe ? ContinueIn : Skip;
205+
return TechnoExt::ExtMap.Find(pThis)->AirstrikeTargetingMe ? ContinueIn : Skip;
201206
}
202207

203208
DEFINE_HOOK(0x43FDD6, BuildingClass_AI_Airstrike, 0x6)
204209
{
205210
enum { SkipGameCode = 0x43FDF1 };
206211

207212
GET(BuildingClass*, pThis, ESI);
208-
const auto pExt = TechnoExt::ExtMap.Find(pThis);
209213

210-
if (pExt->AirstrikeTargetingMe)
214+
if (TechnoExt::ExtMap.Find(pThis)->AirstrikeTargetingMe)
211215
pThis->Mark(MarkType::Change);
212216

213217
return SkipGameCode;
@@ -218,59 +222,53 @@ DEFINE_HOOK(0x43F9E0, BuildingClass_Mark_Airstrike, 0x6)
218222
enum { ContinueTintIntensity = 0x43FA0F, NonAirstrike = 0x43FA19 };
219223

220224
GET(BuildingClass*, pThis, EDI);
221-
const auto pExt = TechnoExt::ExtMap.Find(pThis);
222225

223-
return pExt->AirstrikeTargetingMe ? ContinueTintIntensity : NonAirstrike;
226+
return TechnoExt::ExtMap.Find(pThis)->AirstrikeTargetingMe ? ContinueTintIntensity : NonAirstrike;
224227
}
225228

226229
DEFINE_HOOK(0x448DF1, BuildingClass_SetOwningHouse_Airstrike, 0x6)
227230
{
228231
enum { ContinueTintIntensity = 0x448E0D, NonAirstrike = 0x448E17 };
229232

230233
GET(BuildingClass*, pThis, ESI);
231-
const auto pExt = TechnoExt::ExtMap.Find(pThis);
232234

233-
return pExt->AirstrikeTargetingMe ? ContinueTintIntensity : NonAirstrike;
235+
return TechnoExt::ExtMap.Find(pThis)->AirstrikeTargetingMe ? ContinueTintIntensity : NonAirstrike;
234236
}
235237

236238
DEFINE_HOOK(0x451ABC, BuildingClass_PlayAnim_Airstrike, 0x6)
237239
{
238240
enum { ContinueTintIntensity = 0x451AEB, NonAirstrike = 0x451AF5 };
239241

240242
GET(BuildingClass*, pThis, ESI);
241-
const auto pExt = TechnoExt::ExtMap.Find(pThis);
242243

243-
return pExt->AirstrikeTargetingMe ? ContinueTintIntensity : NonAirstrike;
244+
return TechnoExt::ExtMap.Find(pThis)->AirstrikeTargetingMe ? ContinueTintIntensity : NonAirstrike;
244245
}
245246

246247
DEFINE_HOOK(0x452041, BuildingClass_452000_Airstrike, 0x6)
247248
{
248249
enum { ContinueTintIntensity = 0x452070, NonAirstrike = 0x45207A };
249250

250251
GET(BuildingClass*, pThis, ESI);
251-
const auto pExt = TechnoExt::ExtMap.Find(pThis);
252252

253-
return pExt->AirstrikeTargetingMe ? ContinueTintIntensity : NonAirstrike;
253+
return TechnoExt::ExtMap.Find(pThis)->AirstrikeTargetingMe ? ContinueTintIntensity : NonAirstrike;
254254
}
255255

256256
DEFINE_HOOK(0x456E5A, BuildingClass_Flash_Airstrike, 0x6)
257257
{
258258
enum { ContinueTintIntensity = 0x456E89, NonAirstrike = 0x456E93 };
259259

260260
GET(BuildingClass*, pThis, ESI);
261-
const auto pExt = TechnoExt::ExtMap.Find(pThis);
262261

263-
return pExt->AirstrikeTargetingMe ? ContinueTintIntensity : NonAirstrike;
262+
return TechnoExt::ExtMap.Find(pThis)->AirstrikeTargetingMe ? ContinueTintIntensity : NonAirstrike;
264263
}
265264

266265
DEFINE_HOOK(0x456FD3, BuildingClass_GetEffectTintIntensity_Airstrike, 0x6)
267266
{
268267
enum { ContinueTintIntensity = 0x457002, NonAirstrike = 0x45700F };
269268

270269
GET(BuildingClass*, pThis, ESI);
271-
const auto pExt = TechnoExt::ExtMap.Find(pThis);
272270

273-
return pExt->AirstrikeTargetingMe ? ContinueTintIntensity : NonAirstrike;
271+
return TechnoExt::ExtMap.Find(pThis)->AirstrikeTargetingMe ? ContinueTintIntensity : NonAirstrike;
274272
}
275273

276274
#pragma endregion

0 commit comments

Comments
 (0)