From 53d6e449c258a6423a13ebc6e361a42e12d20f20 Mon Sep 17 00:00:00 2001 From: Alex King <89047260+Kinglykrab@users.noreply.github.com> Date: Fri, 12 Jan 2024 02:51:02 -0500 Subject: [PATCH] [Cleanup] Cleanup ChangeSize() (#3959) # Notes - Use `EQ::Clamp()` for logic instead of basic comparsions. - Rename restriction parameter to `unrestricted`. --- zone/lua_mob.cpp | 4 ++-- zone/lua_mob.h | 2 +- zone/mob.cpp | 28 +++++++++------------------- zone/mob.h | 2 +- zone/perl_mob.cpp | 4 ++-- 5 files changed, 15 insertions(+), 25 deletions(-) diff --git a/zone/lua_mob.cpp b/zone/lua_mob.cpp index adafa5b17..719db3d41 100644 --- a/zone/lua_mob.cpp +++ b/zone/lua_mob.cpp @@ -270,9 +270,9 @@ void Lua_Mob::ChangeSize(double in_size) { self->ChangeSize(static_cast(in_size)); } -void Lua_Mob::ChangeSize(double in_size, bool no_restriction) { +void Lua_Mob::ChangeSize(double in_size, bool unrestricted) { Lua_Safe_Call_Void(); - self->ChangeSize(static_cast(in_size), no_restriction); + self->ChangeSize(static_cast(in_size), unrestricted); } void Lua_Mob::GMMove(double x, double y, double z) { diff --git a/zone/lua_mob.h b/zone/lua_mob.h index 1da48c548..13fb14cac 100644 --- a/zone/lua_mob.h +++ b/zone/lua_mob.h @@ -74,7 +74,7 @@ public: void DoAnim(int animation_id, int animation_speed, bool ackreq); void DoAnim(int animation_id, int animation_speed, bool ackreq, int filter); void ChangeSize(double in_size); - void ChangeSize(double in_size, bool no_restriction); + void ChangeSize(double in_size, bool unrestricted); bool RandomizeFeatures(); bool RandomizeFeatures(bool send_illusion); bool RandomizeFeatures(bool send_illusion, bool save_variables); diff --git a/zone/mob.cpp b/zone/mob.cpp index dac775cb8..9461c6c3b 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -4358,29 +4358,19 @@ void Mob::SendWearChangeAndLighting(int8 last_texture) { } -void Mob::ChangeSize(float in_size = 0, bool bNoRestriction) { - // Size Code - if (!bNoRestriction) - { - if (IsClient() || petid != 0) - if (in_size < 3.0) - in_size = 3.0; - - - if (IsClient() || petid != 0) - if (in_size > 15.0) - in_size = 15.0; +void Mob::ChangeSize(float in_size = 0, bool unrestricted) +{ + if (!unrestricted) { + if (IsClient() || petid != 0) { + EQ::Clamp(in_size, 3.0f, 15.0f); + } } + EQ::Clamp(in_size, 1.0f, 255.0f); - if (in_size < 1.0) - in_size = 1.0; - - if (in_size > 255.0) - in_size = 255.0; - //End of Size Code size = in_size; - SendAppearancePacket(AppearanceType::Size, (uint32) in_size); + + SendAppearancePacket(AppearanceType::Size, static_cast(in_size)); } Mob* Mob::GetOwnerOrSelf() { diff --git a/zone/mob.h b/zone/mob.h index 0c6b7b8cb..0829f58bd 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -330,7 +330,7 @@ public: virtual void SetSlotTint(uint8 material_slot, uint8 red_tint, uint8 green_tint, uint8 blue_tint); virtual void WearChange(uint8 material_slot, uint32 texture, uint32 color = 0, uint32 hero_forge_model = 0); - void ChangeSize(float in_size, bool bNoRestriction = false); + void ChangeSize(float in_size, bool unrestricted = false); void DoAnim(const int animation_id, int animation_speed = 0, bool ackreq = true, eqFilterType filter = FilterNone); void ProjectileAnimation(Mob* to, int item_id, bool IsArrow = false, float speed = 0, float angle = 0, float tilt = 0, float arc = 0, const char *IDFile = nullptr, EQ::skills::SkillType skillInUse = EQ::skills::SkillArchery); void SendAppearanceEffect(uint32 parm1, uint32 parm2, uint32 parm3, uint32 parm4, uint32 parm5, Client *specific_target=nullptr, uint32 value1slot = 1, uint32 value1ground = 1, uint32 value2slot = 1, uint32 value2ground = 1, diff --git a/zone/perl_mob.cpp b/zone/perl_mob.cpp index b7dec6bcc..1d86e2363 100644 --- a/zone/perl_mob.cpp +++ b/zone/perl_mob.cpp @@ -311,9 +311,9 @@ void Perl_Mob_ChangeSize(Mob* self, float in_size) // @categories Script Utility self->ChangeSize(in_size); } -void Perl_Mob_ChangeSize(Mob* self, float in_size, bool no_restriction) // @categories Script Utility +void Perl_Mob_ChangeSize(Mob* self, float in_size, bool unrestricted) // @categories Script Utility { - self->ChangeSize(in_size, no_restriction); + self->ChangeSize(in_size, unrestricted); } void Perl_Mob_GMMove(Mob* self, float x, float y, float z) // @categories Script Utility