From 7d0722cfffb6d001dd8851865e60ed2d922a20a2 Mon Sep 17 00:00:00 2001 From: Starkku Date: Tue, 2 Apr 2024 17:31:16 +0300 Subject: [PATCH] Simplify a TerrainType passability hook --- src/Ext/TerrainType/Hooks.Passable.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/Ext/TerrainType/Hooks.Passable.cpp b/src/Ext/TerrainType/Hooks.Passable.cpp index aad2fe8902..9dffa82953 100644 --- a/src/Ext/TerrainType/Hooks.Passable.cpp +++ b/src/Ext/TerrainType/Hooks.Passable.cpp @@ -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(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.