From ef572f27f756dcb60d5c7d1792a128a7e4d2b8b4 Mon Sep 17 00:00:00 2001 From: m Date: Thu, 26 Jan 2023 23:47:42 -0600 Subject: [PATCH] fix slow motion killcams --- src/client/component/slowmotion.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/client/component/slowmotion.cpp b/src/client/component/slowmotion.cpp index e70911fb..86dfb7ee 100644 --- a/src/client/component/slowmotion.cpp +++ b/src/client/component/slowmotion.cpp @@ -10,6 +10,20 @@ namespace slowmotion { + namespace + { + template + T get_timescale_safe(const scripting::value_wrap& arg) + { + if (arg.is()) + { + return arg.as(); + } + + return static_cast(arg.as()); + } + } + class component final : public component_interface { public: @@ -28,8 +42,8 @@ namespace slowmotion } const auto start = args[0].as(); - const auto end = (args.size() > 0 ? args[1].as() : 1.0f); - const auto duration = (args.size() > 1 ? args[2].as() : 1) * 1000; + const auto end = (args.size() > 0 ? get_timescale_safe(args[1]) : 1.0f); + const auto duration = (args.size() > 1 ? get_timescale_safe(args[2]) : 1) * 1000; game::SV_SetConfigstring(10, utils::string::va("%i %i %g %g", *game::mp::gameTime, duration, start, end)); game::Com_SetSlowMotion(start, end, duration);