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