From 79c8858ec85d08a5d0345ee7e187f347286f89a7 Mon Sep 17 00:00:00 2001 From: JJ <3617814+joligario@users.noreply.github.com> Date: Fri, 1 Mar 2024 19:46:00 -0800 Subject: [PATCH] [Bug Fix] Use std::clamp for Mob::ChangeSize (#4140) Helper template was not deducing float for lower/upper values allowing invalid sizes Limit to sane values of 1-255 unrestricted and 3-15 for clients and pets --- zone/mob.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/zone/mob.cpp b/zone/mob.cpp index 73e861342..9780e5e0b 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -4384,17 +4384,15 @@ void Mob::SendWearChangeAndLighting(int8 last_texture) { void Mob::ChangeSize(float in_size = 0, bool unrestricted) { + size = std::clamp(in_size, 1.0f, 255.0f); + if (!unrestricted) { if (IsClient() || petid != 0) { - EQ::Clamp(in_size, 3.0f, 15.0f); + size = std::clamp(in_size, 3.0f, 15.0f); } } - EQ::Clamp(in_size, 1.0f, 255.0f); - - size = in_size; - - SendAppearancePacket(AppearanceType::Size, static_cast(in_size)); + SendAppearancePacket(AppearanceType::Size, static_cast(size)); } Mob* Mob::GetOwnerOrSelf()