Skip to content

Commit

Permalink
bxt_enable_big_map: also big velocity
Browse files Browse the repository at this point in the history
  • Loading branch information
khanghugo committed Feb 21, 2024
1 parent a0cc469 commit d862105
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
7 changes: 7 additions & 0 deletions BunnymodXT/modules/HwDLL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}
}

Expand Down
18 changes: 8 additions & 10 deletions BunnymodXT/modules/ServerDLL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions BunnymodXT/shared.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit d862105

Please sign in to comment.