Skip to content

Commit 71e2a9d

Browse files
authored
[Vanilla Fix] Fix incorrect damage area logic (#1707)
Fixed the issue that the widespread damage caused by detonation on the bridge/ground cannot affect objects on the ground/bridge who are in the opposite case. --- - Perhaps WW wants to do some optimization, but obviously this is not reasonable.
1 parent 094b10a commit 71e2a9d

File tree

4 files changed

+129
-0
lines changed

4 files changed

+129
-0
lines changed

CREDITS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ This page lists all the individual contributions to the project by their author.
485485
- Amphibious access vehicle
486486
- Fix an issue that spawned `Strafe` aircraft on aircraft carriers may not be able to return normally if aircraft carriers moved a short distance when the aircraft is landing
487487
- Exclusive SuperWeapon Sidebar
488+
- Fix an issue that the widespread damage caused by detonation on the bridge/ground cannot affect objects on the ground/bridge who are in the opposite case
488489
- **Ollerus**:
489490
- Build limit group enhancement
490491
- Customizable rocker amplitude

docs/Fixed-or-Improved-Logics.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
230230
- Fixed the bug that uncontrolled scatter when elite techno attacked by aircraft or some unit try crush it.
231231
- Second weapon with `ElectricAssault=yes` will not unconditionally attack your building with `Overpowerable=yes`.
232232
- Infantry support `IsGattling=yes`.
233+
- Fixed the issue that the widespread damage caused by detonation on the bridge/ground cannot affect objects on the ground/bridge who are in the opposite case.
233234

234235
## Fixes / interactions with other extensions
235236

docs/Whats-New.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ Vanilla fixes:
413413
- Fixed an issue where airstrike flare line drawn to target at lower elevation would clip (by Starkku)
414414
- Fixed the bug that uncontrolled scatter when elite techno attacked by aircraft or some unit try crush it (by NetsuNegi)
415415
- Second weapon with `ElectricAssault=yes` will not unconditionally attack your building with `Overpowerable=yes` (by FlyStar)
416+
- Fixed the issue that the widespread damage caused by detonation on the bridge/ground cannot affect objects on the ground/bridge who are in the opposite case (by CrimRecya)
416417
417418
Phobos fixes:
418419
- Fixed the bug that `AllowAirstrike=no` cannot completely prevent air strikes from being launched against it (by NetsuNegi)

src/Misc/Hooks.BugFixes.cpp

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2041,3 +2041,129 @@ DEFINE_HOOK(0x4D6FE1, FootClass_ElectricAssultFix2, 0x7) // Mission_AreaGuard
20412041
}
20422042

20432043
#pragma endregion
2044+
2045+
#pragma region DamageAreaItemsFix
2046+
// Obviously, it is unreasonable for a large-scale damage like a nuke to only cause damage to units
2047+
// located on or under the bridge that are in the same position as the damage center point
2048+
namespace DamageAreaTemp
2049+
{
2050+
const CellClass* CheckingCell = nullptr;
2051+
bool CheckingCellAlt = false;
2052+
}
2053+
// Skip useless alt check, so it will only start checking from the cell's FirstObject
2054+
// Note: Ares hook at 0x489562(0x6) and return 0
2055+
DEFINE_JUMP(LJMP, 0x489568, 0x489592);
2056+
2057+
DEFINE_HOOK(0x4896BF, DamageArea_DamageItemsFix1, 0x6)
2058+
{
2059+
enum { CheckNextCell = 0x4899BE, CheckThisObject = 0x4896DD };
2060+
// Record the current cell for linked list getting
2061+
GET(const CellClass* const, pCell, EBX);
2062+
DamageAreaTemp::CheckingCell = pCell;
2063+
// First, check the FirstObject linked list
2064+
auto pObject = pCell->FirstObject;
2065+
// Check if there are objects in the linked list
2066+
if (pObject)
2067+
{
2068+
// When it exists, start the vanilla processing
2069+
R->ESI(pObject);
2070+
return CheckThisObject;
2071+
}
2072+
// When it does not exist, check AltObject linked list
2073+
pObject = pCell->AltObject;
2074+
// If there is also no object in the linked list, return directly to check the next cell
2075+
if (!pObject)
2076+
return CheckNextCell;
2077+
// If there is an object, record the flag
2078+
DamageAreaTemp::CheckingCellAlt = true;
2079+
// Then return and continue with the original execution
2080+
R->ESI(pObject);
2081+
return CheckThisObject;
2082+
}
2083+
2084+
DEFINE_HOOK(0x4899B3, DamageArea_DamageItemsFix2, 0x5)
2085+
{
2086+
enum { CheckNextCell = 0x4899BE, CheckThisObject = 0x4896DD };
2087+
// When there are no units in the FirstObject linked list, it will not enter this hook
2088+
GET(const ObjectClass*, pObject, ESI);
2089+
// As vanilla, first look at the next object in the linked list
2090+
pObject = pObject->NextObject;
2091+
// Check if there are still objects in the linked list
2092+
if (pObject)
2093+
{
2094+
// When it exists, return to continue the vanilla processing
2095+
R->ESI(pObject);
2096+
return CheckThisObject;
2097+
}
2098+
// When it does not exist, check which linked list it is currently in
2099+
if (DamageAreaTemp::CheckingCellAlt)
2100+
{
2101+
// If it is already in the AltObject linked list, reset the flag and return to check the next cell
2102+
DamageAreaTemp::CheckingCellAlt = false;
2103+
return CheckNextCell;
2104+
}
2105+
// If it is still in the FirstObject linked list, take the first object in the AltObject linked list and continue checking
2106+
pObject = DamageAreaTemp::CheckingCell->AltObject;
2107+
// If there is no object in the AltObject linked list, return directly to check the next cell
2108+
if (!pObject)
2109+
return CheckNextCell;
2110+
// If there is an object, record the flag
2111+
DamageAreaTemp::CheckingCellAlt = true;
2112+
// Then return and continue with the original execution
2113+
R->ESI(pObject);
2114+
return CheckThisObject;
2115+
}
2116+
2117+
DEFINE_HOOK(0x489BDB, DamageArea_RockerItemsFix1, 0x6)
2118+
{
2119+
enum { SkipGameCode = 0x489C29 };
2120+
// Get cell coordinates
2121+
GET(const short, cellX, ESI);
2122+
GET(const short, cellY, EBX);
2123+
// Record the current cell for linked list getting
2124+
const auto pCell = MapClass::Instance.GetCellAt(CellStruct { cellX, cellY });
2125+
DamageAreaTemp::CheckingCell = pCell;
2126+
// First, check the FirstObject linked list
2127+
auto pObject = pCell->FirstObject;
2128+
// Check if there are objects in the linked list
2129+
if (pObject)
2130+
{
2131+
// When it exists, start the vanilla processing
2132+
R->EAX(pObject);
2133+
return SkipGameCode;
2134+
}
2135+
// When it does not exist, check AltObject linked list
2136+
pObject = pCell->AltObject;
2137+
// If there is an object, record the flag
2138+
if (pObject)
2139+
DamageAreaTemp::CheckingCellAlt = true;
2140+
// Return the original check
2141+
R->EAX(pObject);
2142+
return SkipGameCode;
2143+
}
2144+
2145+
DEFINE_HOOK(0x489E47, DamageArea_RockerItemsFix2, 0x6)
2146+
{
2147+
// Prior to this, there was already pObject = pCell->FirstObject;
2148+
GET(const ObjectClass*, pObject, EDI);
2149+
// As vanilla, first look at the next object in the linked list
2150+
if (pObject)
2151+
return 0;
2152+
// When it does not exist, check which linked list it is currently in
2153+
if (DamageAreaTemp::CheckingCellAlt)
2154+
{
2155+
// If it is already in the AltObject linked list, reset the flag and return the original check
2156+
DamageAreaTemp::CheckingCellAlt = false;
2157+
return 0;
2158+
}
2159+
// If it is still in the FirstObject linked list, take the first object in the AltObject linked list and continue checking
2160+
pObject = DamageAreaTemp::CheckingCell->AltObject;
2161+
// If there is an object, record the flag
2162+
if (pObject)
2163+
DamageAreaTemp::CheckingCellAlt = true;
2164+
// Return the original check
2165+
R->EDI(pObject);
2166+
return 0;
2167+
}
2168+
2169+
#pragma region

0 commit comments

Comments
 (0)