Skip to content

Fix functions that return structs to return structs, not pointers #1710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 1 addition & 2 deletions src/Ext/Building/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,7 @@ void BuildingExt::KickOutStuckUnits(BuildingClass* pThis)
}
}

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

while (true)
Expand Down
6 changes: 3 additions & 3 deletions src/Ext/Building/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,11 @@ DEFINE_HOOK(0x44CEEC, BuildingClass_Mission_Missile_EMPulseSelectWeapon, 0x6)
return SkipGameCode;
}

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

DEFINE_FUNCTION_JUMP(CALL6, 0x44D1F9, BuildingClass_GetFireCoords_Wrapper);
Expand Down
7 changes: 3 additions & 4 deletions src/Ext/Unit/Hooks.Harvester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,11 @@ DEFINE_HOOK(0x73E730, UnitClass_MissionHarvest_HarvesterScanAfterUnload, 0x5)
// Focus is set when the harvester is fully loaded and go home.
if (pFocus && !pType->Weeder && TechnoTypeExt::ExtMap.Find(pType)->HarvesterScanAfterUnload.Get(RulesExt::Global()->HarvesterScanAfterUnload))
{
auto cellBuffer = CellStruct::Empty;
const auto pCellStru = pThis->ScanForTiberium(&cellBuffer, RulesClass::Instance->TiberiumLongScan / Unsorted::LeptonsPerCell, 0);
const auto pCellStru = pThis->ScanForTiberium(RulesClass::Instance->TiberiumLongScan / Unsorted::LeptonsPerCell, 0);

if (*pCellStru != CellStruct::Empty)
if (pCellStru != CellStruct::Empty)
{
const auto pCell = MapClass::Instance.TryGetCellAt(*pCellStru);
const auto pCell = MapClass::Instance.TryGetCellAt(pCellStru);
const auto distFromTiberium = pCell ? pThis->DistanceFrom(pCell) : -1;
const auto distFromFocus = pThis->DistanceFrom(pFocus);

Expand Down
6 changes: 4 additions & 2 deletions src/Misc/Hooks.BugFixes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,8 @@ DEFINE_HOOK(0x446BF4, BuildingClass_Place_FreeUnit_NearByLocation, 0x6)
const auto movementZone = pFreeUnit->Type->MovementZone;
const auto currentZone = MapClass::Instance.GetMovementZoneType(mapCoords, movementZone, false);

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

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

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

Expand Down
Loading