Skip to content

Commit

Permalink
Simplify a TerrainType passability hook
Browse files Browse the repository at this point in the history
  • Loading branch information
Starkku committed Apr 2, 2024
1 parent 5143aa1 commit 7d0722c
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions src/Ext/TerrainType/Hooks.Passable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,23 @@ DEFINE_HOOK(0x7002E9, TechnoClass_WhatAction_PassableTerrain, 0x5)
}

// Passable TerrainTypes Hook #3 - Count passable TerrainTypes as completely passable.
DEFINE_HOOK(0x483D87, CellClass_CheckPassability_PassableTerrain, 0x5)
DEFINE_HOOK(0x483DDF, CellClass_CheckPassability_PassableTerrain, 0x6)
{
enum { SkipToNextObject = 0x483DCD, ReturnFromFunction = 0x483E25, BreakFromLoop = 0x483DDF };
enum { ReturnFromFunction = 0x483E25 };

GET(CellClass*, pThis, EDI);
GET(ObjectClass*, pObject, ESI);
GET(TerrainClass*, pTerrain, ESI);

if (auto const pTerrain = abstract_cast<TerrainClass*>(pObject))
if (auto const pTypeExt = TerrainTypeExt::ExtMap.Find(pTerrain->Type))
{
if (auto const pTypeExt = TerrainTypeExt::ExtMap.Find(pTerrain->Type))
if (pTypeExt->IsPassable)
{
if (pTypeExt->IsPassable)
{
pThis->Passability = PassabilityType::Passable;
return ReturnFromFunction;
}
pThis->Passability = PassabilityType::Passable;
return ReturnFromFunction;
}

return BreakFromLoop;
}

return SkipToNextObject;
return 0;
}

// Passable TerrainTypes Hook #4 - Make passable for vehicles.
Expand Down

0 comments on commit 7d0722c

Please sign in to comment.