diff --git a/mc2hook/mc2hook/handlers/LevelExtentsHandler.cpp b/mc2hook/mc2hook/handlers/LevelExtentsHandler.cpp new file mode 100644 index 0000000..e51c073 --- /dev/null +++ b/mc2hook/mc2hook/handlers/LevelExtentsHandler.cpp @@ -0,0 +1,26 @@ +#include "LevelExtentsHandler.h" +#include + +void LevelExtentsHandler::InitRoomsHook(const Vector3& a2, const Vector3& a3, const float& a4) +{ + float worldMinX = HookConfig::GetFloat("Physics", "WorldExtentMinX", -2000.0f); + float worldMaxX = HookConfig::GetFloat("Physics", "WorldExtentMaxX", 2000.0f); + + float worldMinZ = HookConfig::GetFloat("Physics", "WorldExtentMinZ", -2000.0f); + float worldMaxZ = HookConfig::GetFloat("Physics", "WorldExtentMaxZ", 2000.0f); + + Vector3 worldMin = Vector3(worldMinX, a2.Y, worldMinZ); + Vector3 worldMax = Vector3(worldMaxX, a3.Y, worldMaxZ); + + hook::Thunk<0x587850>::Call(this, &worldMin, &worldMax, &a4); // Call original +} + +void LevelExtentsHandler::Install() +{ + InstallCallback("Level Extents Handler", "Level Extents SetRoomConfig hook.", + &InitRoomsHook, { + cb::call(0x40B156), + cb::call(0x589239) + } + ); +} diff --git a/mc2hook/mc2hook/handlers/LevelExtentsHandler.h b/mc2hook/mc2hook/handlers/LevelExtentsHandler.h new file mode 100644 index 0000000..19daaf0 --- /dev/null +++ b/mc2hook/mc2hook/handlers/LevelExtentsHandler.h @@ -0,0 +1,10 @@ +#pragma once +#include +#include + +class LevelExtentsHandler +{ +public: + void InitRoomsHook(const Vector3& a2, const Vector3& a3, const float& a4); + static void Install(); +}; diff --git a/mc2hook/mc2hook/handlers/handlers.h b/mc2hook/mc2hook/handlers/handlers.h index ea7a661..8d33c52 100644 --- a/mc2hook/mc2hook/handlers/handlers.h +++ b/mc2hook/mc2hook/handlers/handlers.h @@ -17,6 +17,7 @@ #include #include #include +#include #include @@ -50,6 +51,7 @@ static void InstallMainHandlers() InstallHandler("Chat Handler"); InstallHandler("Game Init Handler"); InstallHandler("Reflection Fidelity Handller"); + InstallHandler("Level Extents Handler"); InstallHandler("SRH"); } \ No newline at end of file diff --git a/mc2hook/mc2hook/mc2hook.vcxproj b/mc2hook/mc2hook/mc2hook.vcxproj index 056702b..346a70c 100644 --- a/mc2hook/mc2hook/mc2hook.vcxproj +++ b/mc2hook/mc2hook/mc2hook.vcxproj @@ -195,6 +195,7 @@ + @@ -247,6 +248,7 @@ + diff --git a/mc2hook/mc2hook/mc2hook.vcxproj.filters b/mc2hook/mc2hook/mc2hook.vcxproj.filters index 027b650..34b3ff9 100644 --- a/mc2hook/mc2hook/mc2hook.vcxproj.filters +++ b/mc2hook/mc2hook/mc2hook.vcxproj.filters @@ -219,6 +219,9 @@ Header Files + + Header Files + @@ -341,5 +344,8 @@ Source Files + + Source Files + \ No newline at end of file