[Cleanup] Cleanup ChangeSize() (#3959)

# Notes
- Use `EQ::Clamp()` for logic instead of basic comparsions.
- Rename restriction parameter to `unrestricted`.
This commit is contained in:
Alex King 2024-01-12 02:51:02 -05:00 committed by GitHub
parent b61649a2a0
commit 53d6e449c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 25 deletions

View File

@ -270,9 +270,9 @@ void Lua_Mob::ChangeSize(double in_size) {
self->ChangeSize(static_cast<float>(in_size)); self->ChangeSize(static_cast<float>(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(); Lua_Safe_Call_Void();
self->ChangeSize(static_cast<float>(in_size), no_restriction); self->ChangeSize(static_cast<float>(in_size), unrestricted);
} }
void Lua_Mob::GMMove(double x, double y, double z) { void Lua_Mob::GMMove(double x, double y, double z) {

View File

@ -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);
void DoAnim(int animation_id, int animation_speed, bool ackreq, int filter); void DoAnim(int animation_id, int animation_speed, bool ackreq, int filter);
void ChangeSize(double in_size); 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 RandomizeFeatures(bool send_illusion); bool RandomizeFeatures(bool send_illusion);
bool RandomizeFeatures(bool send_illusion, bool save_variables); bool RandomizeFeatures(bool send_illusion, bool save_variables);

View File

@ -4358,29 +4358,19 @@ void Mob::SendWearChangeAndLighting(int8 last_texture) {
} }
void Mob::ChangeSize(float in_size = 0, bool bNoRestriction) { void Mob::ChangeSize(float in_size = 0, bool unrestricted)
// Size Code {
if (!bNoRestriction) if (!unrestricted) {
{ if (IsClient() || petid != 0) {
if (IsClient() || petid != 0) EQ::Clamp(in_size, 3.0f, 15.0f);
if (in_size < 3.0) }
in_size = 3.0;
if (IsClient() || petid != 0)
if (in_size > 15.0)
in_size = 15.0;
} }
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; size = in_size;
SendAppearancePacket(AppearanceType::Size, (uint32) in_size);
SendAppearancePacket(AppearanceType::Size, static_cast<uint32>(in_size));
} }
Mob* Mob::GetOwnerOrSelf() { Mob* Mob::GetOwnerOrSelf() {

View File

@ -330,7 +330,7 @@ public:
virtual void SetSlotTint(uint8 material_slot, uint8 red_tint, uint8 green_tint, uint8 blue_tint); 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); 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 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 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, 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,

View File

@ -311,9 +311,9 @@ void Perl_Mob_ChangeSize(Mob* self, float in_size) // @categories Script Utility
self->ChangeSize(in_size); 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 void Perl_Mob_GMMove(Mob* self, float x, float y, float z) // @categories Script Utility