From 1b51d25c65b6a4b3264be76107fb6148ff7dd4b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20Costa?= <54484196+claudiodfc@users.noreply.github.com> Date: Fri, 3 Dec 2021 11:17:59 +0000 Subject: [PATCH] fix(Script/Commands): cs_modify crash fix (#9471) --- src/server/scripts/Commands/cs_modify.cpp | 27 +++++------------------ 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/src/server/scripts/Commands/cs_modify.cpp b/src/server/scripts/Commands/cs_modify.cpp index e2103f511..bc805d7c5 100644 --- a/src/server/scripts/Commands/cs_modify.cpp +++ b/src/server/scripts/Commands/cs_modify.cpp @@ -485,14 +485,8 @@ public: return false; } - static bool CheckModifySpeed(ChatHandler* handler, char const* args, Unit* target, float& speed, float minimumBound, float maximumBound, bool checkInFlight = true) + static bool CheckModifySpeed(ChatHandler* handler, float& speed, Unit* target, float minimumBound, float maximumBound, bool checkInFlight = true) { - if (!*args) - { - return false; - } - - speed = Acore::StringTo(args).value(); if (speed > maximumBound || speed < minimumBound) { @@ -802,20 +796,10 @@ public: return false; } - char const* mount_cstr = strtok(const_cast(args), " "); - char const* speed_cstr = strtok(nullptr, " "); + char* token = strtok((char*)args, " "); + int mount = atoi(token); + float speed = atof(strtok(nullptr, " ")); - if (!mount_cstr) - { - return false; - } - - if (!speed_cstr) - { - speed_cstr = "1"; - } - - uint32 mount = Acore::StringTo(mount_cstr).value(); if (!sCreatureDisplayInfoStore.LookupEntry(mount)) { handler->SendSysMessage(LANG_NO_MOUNT); @@ -837,8 +821,7 @@ public: return false; } - float speed = 0.f; - if (!CheckModifySpeed(handler, speed_cstr, target, speed, 0.1f, 50.0f)) + if (!CheckModifySpeed(handler, speed, target, 0.1f, 50.0f)) { return false; }