Skip to content

Commit 303e3e9

Browse files
committed
Fix functions that return structs to return structs, not pointers
1 parent 2592d1d commit 303e3e9

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

src/Ext/Building/Body.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,7 @@ void BuildingExt::KickOutStuckUnits(BuildingClass* pThis)
364364
}
365365
}
366366

367-
auto buffer = CoordStruct::Empty;
368-
auto pCell = MapClass::Instance.GetCellAt(*pThis->GetExitCoords(&buffer, 0));
367+
auto pCell = MapClass::Instance.GetCellAt(pThis->GetExitCoords(0));
369368
int i = 0;
370369

371370
while (true)

src/Ext/Building/Hooks.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,11 @@ DEFINE_HOOK(0x44CEEC, BuildingClass_Mission_Missile_EMPulseSelectWeapon, 0x6)
172172
return SkipGameCode;
173173
}
174174

175-
CoordStruct* __fastcall BuildingClass_GetFireCoords_Wrapper(BuildingClass* pThis, void* _, CoordStruct* pCrd, int weaponIndex)
175+
CoordStruct* __fastcall BuildingClass_GetFireCoords_Wrapper(BuildingClass* pThis, CoordStruct* buffer, CoordStruct* pCrd, int weaponIndex)
176176
{
177177
auto coords = MapClass::Instance.GetCellAt(pThis->Owner->EMPTarget)->GetCellCoords();
178-
pCrd = pThis->GetFLH(&coords, EMPulseCannonTemp::weaponIndex, *pCrd);
179-
return pCrd;
178+
*buffer = pThis->GetFLH(EMPulseCannonTemp::weaponIndex, coords);
179+
return buffer;
180180
}
181181

182182
DEFINE_FUNCTION_JUMP(CALL6, 0x44D1F9, BuildingClass_GetFireCoords_Wrapper);

src/Ext/Unit/Hooks.Harvester.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,11 @@ DEFINE_HOOK(0x73E730, UnitClass_MissionHarvest_HarvesterScanAfterUnload, 0x5)
4343
// Focus is set when the harvester is fully loaded and go home.
4444
if (pFocus && !pType->Weeder && TechnoTypeExt::ExtMap.Find(pType)->HarvesterScanAfterUnload.Get(RulesExt::Global()->HarvesterScanAfterUnload))
4545
{
46-
auto cellBuffer = CellStruct::Empty;
47-
const auto pCellStru = pThis->ScanForTiberium(&cellBuffer, RulesClass::Instance->TiberiumLongScan / Unsorted::LeptonsPerCell, 0);
46+
const auto pCellStru = pThis->ScanForTiberium(RulesClass::Instance->TiberiumLongScan / Unsorted::LeptonsPerCell, 0);
4847

49-
if (*pCellStru != CellStruct::Empty)
48+
if (pCellStru != CellStruct::Empty)
5049
{
51-
const auto pCell = MapClass::Instance.TryGetCellAt(*pCellStru);
50+
const auto pCell = MapClass::Instance.TryGetCellAt(pCellStru);
5251
const auto distFromTiberium = pCell ? pThis->DistanceFrom(pCell) : -1;
5352
const auto distFromFocus = pThis->DistanceFrom(pFocus);
5453

src/Misc/Hooks.BugFixes.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,7 +1528,8 @@ DEFINE_HOOK(0x446BF4, BuildingClass_Place_FreeUnit_NearByLocation, 0x6)
15281528
const auto movementZone = pFreeUnit->Type->MovementZone;
15291529
const auto currentZone = MapClass::Instance.GetMovementZoneType(mapCoords, movementZone, false);
15301530

1531-
R->EAX(MapClass::Instance.NearByLocation(*outBuffer, mapCoords, pFreeUnit->Type->SpeedType, currentZone, movementZone, false, 1, 1, true, true, false, false, CellStruct::Empty, false, false));
1531+
*outBuffer = MapClass::Instance.NearByLocation(mapCoords, pFreeUnit->Type->SpeedType, currentZone, movementZone, false, 1, 1, true, true, false, false, CellStruct::Empty, false, false);
1532+
R->EAX(outBuffer);
15321533
return SkipGameCode;
15331534
}
15341535

@@ -1543,7 +1544,8 @@ DEFINE_HOOK(0x446D42, BuildingClass_Place_FreeUnit_NearByLocation2, 0x6)
15431544
const auto movementZone = pFreeUnit->Type->MovementZone;
15441545
const auto currentZone = MapClass::Instance.GetMovementZoneType(mapCoords, movementZone, false);
15451546

1546-
R->EAX(MapClass::Instance.NearByLocation(*outBuffer, mapCoords, pFreeUnit->Type->SpeedType, currentZone, movementZone, false, 1, 1, false, true, false, false, CellStruct::Empty, false, false));
1547+
*outBuffer = MapClass::Instance.NearByLocation(mapCoords, pFreeUnit->Type->SpeedType, currentZone, movementZone, false, 1, 1, false, true, false, false, CellStruct::Empty, false, false);
1548+
R->EAX(outBuffer);
15471549
return SkipGameCode;
15481550
}
15491551

0 commit comments

Comments
 (0)