From d86210574b68b5dbda129efdd8596a75bbd8e198 Mon Sep 17 00:00:00 2001 From: khang Date: Tue, 20 Feb 2024 23:48:41 -0500 Subject: [PATCH] bxt_enable_big_map: also big velocity --- BunnymodXT/modules/HwDLL.cpp | 7 +++++++ BunnymodXT/modules/ServerDLL.cpp | 18 ++++++++---------- BunnymodXT/shared.hpp | 1 + 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/BunnymodXT/modules/HwDLL.cpp b/BunnymodXT/modules/HwDLL.cpp index 0a80fa2f..73d7d519 100644 --- a/BunnymodXT/modules/HwDLL.cpp +++ b/BunnymodXT/modules/HwDLL.cpp @@ -5249,6 +5249,13 @@ void ChangeDeltaForBigMap(delta_s *delta) curr_description->significant_bits = (int) std::ceil(std::log(BIG_MAP_SIZE * 2.0f * curr_description->premultiply) / std::log(2)); } } + + if (!strncmp(curr_description->fieldName, "velocity", 8) || !strncmp(curr_description->fieldName, "basevelocity", 12)) { + auto curr_max_vel = (1 << curr_description->significant_bits) / curr_description->premultiply; + if (curr_max_vel < BIG_MAP_MAX_VELOCITY) { + curr_description->significant_bits = (int) std::ceil(std::log(BIG_MAP_MAX_VELOCITY * 2.0f * curr_description->premultiply) / std::log(2)); + } + } } } diff --git a/BunnymodXT/modules/ServerDLL.cpp b/BunnymodXT/modules/ServerDLL.cpp index 4097bd4c..77daca99 100644 --- a/BunnymodXT/modules/ServerDLL.cpp +++ b/BunnymodXT/modules/ServerDLL.cpp @@ -3276,10 +3276,8 @@ HOOK_DEF_1(ServerDLL, void, __fastcall, CBasePlayer__Jump, void*, thisptr) int ServerDLL::IsInWorld(Vector origin, Vector velocity, int map_size) // https://github.com/ValveSoftware/halflife/blob/c7240b965743a53a29491dd49320c88eecf6257b/dlls/cbase.cpp#L706 { - // Copy pasted from HLSDK, but origin value is changed - // Maybe in the future we should also make velocity check to use sv_maxvelocity value, - // but I don't see any side effect when going beyond it ever - + auto max_velocity = CVars::sv_maxvelocity.GetFloat(); + // position if (origin.x >= map_size) return 0; if (origin.y >= map_size) return 0; @@ -3288,12 +3286,12 @@ int ServerDLL::IsInWorld(Vector origin, Vector velocity, int map_size) // https: if (origin.y <= -map_size) return 0; if (origin.z <= -map_size) return 0; // speed - if (velocity.x >= 2000) return 0; - if (velocity.y >= 2000) return 0; - if (velocity.z >= 2000) return 0; - if (velocity.x <= -2000) return 0; - if (velocity.y <= -2000) return 0; - if (velocity.z <= -2000) return 0; + if (velocity.x >= max_velocity) return 0; + if (velocity.y >= max_velocity) return 0; + if (velocity.z >= max_velocity) return 0; + if (velocity.x <= -max_velocity) return 0; + if (velocity.y <= -max_velocity) return 0; + if (velocity.z <= -max_velocity) return 0; return 1; } diff --git a/BunnymodXT/shared.hpp b/BunnymodXT/shared.hpp index d3bbcfa6..71e485c2 100644 --- a/BunnymodXT/shared.hpp +++ b/BunnymodXT/shared.hpp @@ -20,5 +20,6 @@ enum class EventType : unsigned char { #define BUNNYSPLIT_PIPE_NAME "BunnymodXT-BunnySplit" #define BIG_MAP_SIZE 32768 // +-BIG_MAP_SIZE so 64k x 64k map should have value of 32k +#define BIG_MAP_MAX_VELOCITY 8192 // +-8192 #define BXT_FLAGS_BIG_MAP (1<<0) \ No newline at end of file