From aa8705a1245a4e41da3cb0045aa34498c25297cf Mon Sep 17 00:00:00 2001 From: pongo1231 Date: Thu, 6 Feb 2025 20:04:24 +0100 Subject: [PATCH] ChaosMod: Enable (almost) all warnings for GCC/Clang & treat all of them (#3708) Also: - Decrease the warning level of MSVC to W2 and mark all warnings as errors for all compilers. - Use this ooportunity to finally raise the cmake version. --- ChaosMod/CMakeLists.txt | 8 +- ChaosMod/Components/CrossingChallenge.cpp | 30 +++---- ChaosMod/Components/DebugMenu.cpp | 20 ++--- ChaosMod/Components/DebugMenu.h | 11 ++- ChaosMod/Components/EffectDispatchTimer.cpp | 13 +-- ChaosMod/Components/EffectDispatcher.cpp | 14 ++- ChaosMod/Components/EffectDispatcher.h | 4 +- ChaosMod/Components/LuaScripts.cpp | 19 ++-- ChaosMod/Components/Voting.cpp | 2 +- ChaosMod/Components/Workshop.cpp | 8 +- ChaosMod/Effects/Condition/EffectCondition.h | 8 +- ChaosMod/Effects/EffectConfig.h | 12 +-- ChaosMod/Effects/EffectData.h | 4 +- ChaosMod/Effects/EnabledEffects.h | 2 +- ChaosMod/Effects/Register/RegisterEffect.h | 8 +- ChaosMod/Effects/db/Misc/MiscAirstrike.cpp | 6 +- ChaosMod/Effects/db/Misc/MiscFireworks.cpp | 8 +- ChaosMod/Effects/db/Misc/MiscFpsLimit.cpp | 2 +- ChaosMod/Effects/db/Misc/MiscGhostWorld.cpp | 2 +- ChaosMod/Effects/db/Misc/MiscHighPitch.cpp | 4 +- ChaosMod/Effects/db/Misc/MiscLag.cpp | 4 +- ChaosMod/Effects/db/Misc/MiscLowPitch.cpp | 4 +- ChaosMod/Effects/db/Misc/MiscNewsTeam.cpp | 88 +++++++------------ ChaosMod/Effects/db/Misc/MiscPayRespects.cpp | 13 ++- ChaosMod/Effects/db/Misc/MiscRollCredits.cpp | 6 +- .../Effects/db/Misc/MiscSpawnOrangeBall.cpp | 26 +++--- ChaosMod/Effects/db/Misc/MiscWeirdPitch.cpp | 2 +- ChaosMod/Effects/db/Misc/MiscWhaleRain.cpp | 3 +- .../Effects/db/Misc/MiscWitnessProtection.cpp | 2 +- ChaosMod/Effects/db/Peds/PedsHotCougars.cpp | 12 +-- ChaosMod/Effects/db/Peds/PedsInTheHood.cpp | 2 +- ChaosMod/Effects/db/Peds/PedsKillerClowns.cpp | 2 +- ChaosMod/Effects/db/Peds/PedsMercenaries.cpp | 8 +- ChaosMod/Effects/db/Peds/PedsNotMenendez.cpp | 16 ++-- ChaosMod/Effects/db/Peds/PedsSmokeTrails.cpp | 5 +- .../Effects/db/Peds/PedsSpawnDancingApes.cpp | 2 +- .../db/Peds/PedsSpawnRoastingLamar.cpp | 4 +- ChaosMod/Effects/db/Peds/PedsTPGuns.cpp | 2 +- ChaosMod/Effects/db/Player/PlayerBees.cpp | 2 +- ChaosMod/Effects/db/Player/PlayerDeadEye.cpp | 2 +- .../Effects/db/Player/PlayerFakeDeath.cpp | 14 +-- .../Effects/db/Player/PlayerHeavyRecoil.cpp | 2 +- .../Effects/db/Player/PlayerLagCamera.cpp | 14 +-- .../db/Player/PlayerRandomStuntJump.cpp | 60 ++++++------- ChaosMod/Effects/db/Player/PlayerRocket.cpp | 6 +- .../db/Player/PlayerSetIntoClosestVeh.cpp | 6 +- .../db/Player/PlayerSetIntoRandomVeh.cpp | 8 +- .../Effects/db/Player/PlayerSimeonSays.cpp | 8 +- ChaosMod/Effects/db/Player/PlayerSuicide.cpp | 2 +- .../Effects/db/Player/PlayerTpController.cpp | 4 +- .../db/Screen/ScreenRealFirstPerson.cpp | 2 +- ChaosMod/Effects/db/Vehs/Vehs30mphLimit.cpp | 2 +- .../Effects/db/Vehs/VehsColorController.cpp | 12 +-- .../Effects/db/Vehs/VehsPlayerVehExplode.cpp | 14 +-- ChaosMod/Effects/db/Vehs/VehsRepossession.cpp | 4 +- ChaosMod/Effects/db/Vehs/VehsSpawner.cpp | 2 +- ChaosMod/Effects/db/Vehs/VehsWeapons.cpp | 2 +- ChaosMod/Main.h | 2 +- ChaosMod/Memory/Hooks/AudioPitchHook.cpp | 8 +- ChaosMod/Memory/Hooks/AudioPitchHook.h | 4 +- ChaosMod/Memory/Hooks/Hook.h | 11 +-- ChaosMod/Memory/Hooks/MiscHooks.cpp | 4 +- ChaosMod/Memory/PedModels.h | 2 +- ChaosMod/Memory/Script.h | 4 +- ChaosMod/Memory/Vehicle.h | 16 ++-- ChaosMod/Util/MacroConcat.h | 4 +- ChaosMod/Util/OptionDefaults.h | 2 +- ChaosMod/Util/OptionsFile.h | 10 +-- ChaosMod/Util/ScriptText.h | 2 +- ChaosMod/Util/TryParse.h | 2 +- ChaosMod/Util/Vehicle.h | 10 +-- 71 files changed, 305 insertions(+), 328 deletions(-) diff --git a/ChaosMod/CMakeLists.txt b/ChaosMod/CMakeLists.txt index 0ca1c7c4b..b1082af82 100644 --- a/ChaosMod/CMakeLists.txt +++ b/ChaosMod/CMakeLists.txt @@ -1,5 +1,4 @@ -cmake_minimum_required(VERSION 3.13) - +cmake_minimum_required(VERSION 3.31) project(ChaosMod) file(GLOB ROOT_SRC ${PROJECT_SOURCE_DIR}/*.cpp) @@ -12,6 +11,7 @@ target_precompile_headers(ChaosMod PUBLIC stdafx.cpp) set_target_properties(ChaosMod PROPERTIES SUFFIX ".asi") set_target_properties(ChaosMod PROPERTIES CXX_STANDARD 20) +set_target_properties(ChaosMod PROPERTIES CXX_SCAN_FOR_MODULES OFF) target_compile_definitions(ChaosMod PUBLIC $<$:CHAOSDEBUG>) target_compile_definitions(ChaosMod PUBLIC NDEBUG) @@ -37,9 +37,9 @@ target_link_directories(ChaosMod PUBLIC ${PROJECT_SOURCE_DIR}/../vendor/lua) target_link_libraries(ChaosMod PUBLIC ${link_libs}) if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") - target_compile_options(ChaosMod PUBLIC -DUNICODE -D_UNICODE -DNOMINMAX /Zi /GT) + target_compile_options(ChaosMod PUBLIC /Zi /GT /W2 /WX -DUNICODE -D_UNICODE -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS) target_link_options(ChaosMod PUBLIC /DEBUG /OPT:REF /OPT:ICF) else() - target_compile_options(ChaosMod PUBLIC -municode) + target_compile_options(ChaosMod PUBLIC -municode -flarge-source-files -Werror -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unused-variable -Wno-maybe-uninitialized -Wno-array-bounds -Wno-unused-but-set-variable) target_link_options(ChaosMod PUBLIC -static) endif() \ No newline at end of file diff --git a/ChaosMod/Components/CrossingChallenge.cpp b/ChaosMod/Components/CrossingChallenge.cpp index 0f16d8a83..048978832 100644 --- a/ChaosMod/Components/CrossingChallenge.cpp +++ b/ChaosMod/Components/CrossingChallenge.cpp @@ -4,8 +4,8 @@ #include "Components/EffectDispatchTimer.h" #include "Main.h" #include "Memory/WeaponPool.h" -#include "Util/ScriptText.h" #include "Util/OptionsManager.h" +#include "Util/ScriptText.h" void CrossingChallenge::SetStartParams() { @@ -14,8 +14,8 @@ void CrossingChallenge::SetStartParams() if (m_StartVehicleHash) { LoadModel(m_StartVehicleHash); - Vehicle vehicle = CREATE_VEHICLE(m_StartVehicleHash, m_StartLocation.x, m_StartLocation.y, - m_StartLocation.z, m_StartHeading, true, false, false); + Vehicle vehicle = CREATE_VEHICLE(m_StartVehicleHash, m_StartLocation.x, m_StartLocation.y, m_StartLocation.z, + m_StartHeading, true, false, false); SET_PED_INTO_VEHICLE(player, vehicle, -1); } @@ -59,8 +59,8 @@ void CrossingChallenge::ControlRespawn() SET_TIME_SCALE(1.f); ANIMPOSTFX_STOP_ALL(); NETWORK_REQUEST_CONTROL_OF_ENTITY(player); - NETWORK_RESURRECT_LOCAL_PLAYER(m_StartLocation.x, m_StartLocation.y, m_StartLocation.z, m_StartHeading, - false, false, false); + NETWORK_RESURRECT_LOCAL_PLAYER(m_StartLocation.x, m_StartLocation.y, m_StartLocation.z, m_StartHeading, false, + false, false); WAIT(2000); if (vehicle) { @@ -86,7 +86,7 @@ void CrossingChallenge::ControlRespawn() DISPLAY_HUD(true); FREEZE_ENTITY_POSITION(player, false); - m_TickCount = 0; + m_TickCount = 0; m_EffectsCount = 0; m_TimerStarted = false; } @@ -94,7 +94,7 @@ void CrossingChallenge::ControlRespawn() static bool LoadScaleform(int &handle, bool &loading, const std::string &name) { - if (!handle || !loading && !HAS_SCALEFORM_MOVIE_LOADED(handle)) + if (!handle || (!loading && !HAS_SCALEFORM_MOVIE_LOADED(handle))) { handle = REQUEST_SCALEFORM_MOVIE(name.c_str()); loading = true; @@ -200,12 +200,12 @@ void CrossingChallenge::SaveConfig() m_ConfigFile.SetValue("StartLocationX", m_StartLocation.x); m_ConfigFile.SetValue("StartLocationY", m_StartLocation.y); m_ConfigFile.SetValue("StartLocationZ", m_StartLocation.z); - m_ConfigFile.SetValue("StartVehicle", m_StartVehicleHash); - m_ConfigFile.SetValue("StartHeading", m_StartHeading); + m_ConfigFile.SetValue("StartVehicle", m_StartVehicleHash); + m_ConfigFile.SetValue("StartHeading", m_StartHeading); m_ConfigFile.SetValue("StartCameraHeading", m_StartCameraHeading); - m_ConfigFile.SetValue("StartWeather1", m_StartWeatherType1); + m_ConfigFile.SetValue("StartWeather1", m_StartWeatherType1); m_ConfigFile.SetValue("StartWeather2", m_StartWeatherType2); - m_ConfigFile.SetValue("StartWeatherPercent", m_StartWeatherPercent); + m_ConfigFile.SetValue("StartWeatherPercent", m_StartWeatherPercent); m_ConfigFile.SetValue("StartHours", m_ClockHours); m_ConfigFile.SetValue("StartMinutes", m_ClockMinutes); m_ConfigFile.SetValue("StartSeconds", m_ClockSeconds); @@ -224,7 +224,7 @@ void CrossingChallenge::SaveConfig() void CrossingChallenge::CaptureStart() { - Ped player = PLAYER_PED_ID(); + Ped player = PLAYER_PED_ID(); m_StartEnabled = true; m_StartLocation = GET_ENTITY_COORDS(player, false); @@ -413,7 +413,7 @@ void CrossingChallenge::ShowHelpButtons() DRAW_SCALEFORM_MOVIE_FULLSCREEN(m_ButtonsScaleformHandle, 255, 255, 255, 255, 0); } -static void HandleBlip(Blip& blip, Vector3 coords, int color, const std::string &name) +static void HandleBlip(Blip &blip, Vector3 coords, int color, const std::string &name) { if (!blip || !DOES_BLIP_EXIST(blip)) { @@ -524,7 +524,7 @@ void CrossingChallenge::OnRun() GetComponent()->SetTimerEnabled(true); } - m_TickCount = 0; + m_TickCount = 0; m_EffectsCount = 0; m_TimerStarted = false; @@ -553,7 +553,7 @@ void CrossingChallenge::OnRun() ControlPassed(); int deltaTicks = GetTickCount64() - m_LastTick; - m_LastTick = GetTickCount64(); + m_LastTick = GetTickCount64(); if (m_TimerStarted && deltaTicks < 1000) m_TickCount += deltaTicks; diff --git a/ChaosMod/Components/DebugMenu.cpp b/ChaosMod/Components/DebugMenu.cpp index 9525b64d7..cf2a9b481 100644 --- a/ChaosMod/Components/DebugMenu.cpp +++ b/ChaosMod/Components/DebugMenu.cpp @@ -32,7 +32,7 @@ DebugMenu::DebugMenu() : Component() std::sort(m_Effects.begin(), m_Effects.end(), [](const DebugEffect &a, const DebugEffect &b) { - for (int idx = 0;; idx++) + for (size_t idx = 0;; idx++) { if (idx >= a.EffectName.size()) return false; @@ -83,16 +83,16 @@ void DebugMenu::OnRun() GetComponent()->DispatchEffect(m_Effects[m_SelectedIdx].Id); } - float y = .1f; - WORD remainingDrawItems = MAX_VIS_ITEMS; + float y = .1f; + size_t remainingDrawItems = MAX_VIS_ITEMS; - for (int i = 0; remainingDrawItems > 0; i++) + for (int64_t i = 0; remainingDrawItems > 0; i++) { - short overflow = MAX_VIS_ITEMS / 2 - (m_Effects.size() - 1 - m_SelectedIdx); + int64_t bias = MAX_VIS_ITEMS / 2 - (m_Effects.size() - 1 - m_SelectedIdx); - if (i < 0 || i < m_SelectedIdx - remainingDrawItems / 2 - (overflow > 0 ? overflow : 0)) + if (i < static_cast(m_SelectedIdx - remainingDrawItems / 2 - (bias > 0 ? bias : 0))) continue; - else if (i >= m_Effects.size()) + else if (i >= static_cast(m_Effects.size())) break; BEGIN_TEXT_COMMAND_DISPLAY_TEXT("STRING"); @@ -153,7 +153,7 @@ void DebugMenu::OnKeyInput(DWORD key, bool repeated, bool isUpNow, bool isCtrlPr break; case VK_DOWN: - if (++m_SelectedIdx >= m_Effects.size()) + if (static_cast(++m_SelectedIdx) >= m_Effects.size()) m_SelectedIdx = 0; break; @@ -167,7 +167,7 @@ void DebugMenu::OnKeyInput(DWORD key, bool repeated, bool isUpNow, bool isCtrlPr if (searchChar++ == SCHAR_MAX) searchChar = SCHAR_MIN; - for (int idx = 0; idx < m_Effects.size(); idx++) + for (size_t idx = 0; idx < m_Effects.size(); idx++) { if (std::tolower(m_Effects[idx].EffectName[0]) == searchChar) { @@ -192,7 +192,7 @@ void DebugMenu::OnKeyInput(DWORD key, bool repeated, bool isUpNow, bool isCtrlPr if (searchChar-- == SCHAR_MIN) searchChar = SCHAR_MAX; - for (int idx = 0; idx < m_Effects.size(); idx++) + for (size_t idx = 0; idx < m_Effects.size(); idx++) { if (std::tolower(m_Effects[idx].EffectName[0]) == searchChar) { diff --git a/ChaosMod/Components/DebugMenu.h b/ChaosMod/Components/DebugMenu.h index 84dea7458..f2afa5268 100644 --- a/ChaosMod/Components/DebugMenu.h +++ b/ChaosMod/Components/DebugMenu.h @@ -4,10 +4,9 @@ #include "Effects/EffectIdentifier.h" +#include #include -using DWORD = unsigned long; - class DebugMenu : public Component { struct DebugEffect @@ -25,11 +24,11 @@ class DebugMenu : public Component bool m_IsEnabled; - int m_SelectedIdx = 0; - bool m_Visible = false; + int64_t m_SelectedIdx = 0; + bool m_Visible = false; - DWORD m_RepeatTime = 0; - bool m_DispatchEffect = false; + std::uint32_t m_RepeatTime = 0; + bool m_DispatchEffect = false; public: DebugMenu(); diff --git a/ChaosMod/Components/EffectDispatchTimer.cpp b/ChaosMod/Components/EffectDispatchTimer.cpp index 2ad15a9a6..21c92a96a 100644 --- a/ChaosMod/Components/EffectDispatchTimer.cpp +++ b/ChaosMod/Components/EffectDispatchTimer.cpp @@ -16,7 +16,7 @@ EffectDispatchTimer::EffectDispatchTimer(const std::array &timerColor) m_DistanceChaosState.EnableDistanceBasedEffectDispatch = g_OptionsManager.GetConfigValue( { "EnableDistanceBasedEffectDispatch" }, OPTION_DEFAULT_DISTANCE_BASED_DISPATCH_ENABLED); m_DistanceChaosState.DistanceToActivateEffect = - g_OptionsManager.GetConfigValue({ "DistanceToActivateEffect" }, OPTION_DEFAULT_EFFECT_SPAWN_DISTANCE); + g_OptionsManager.GetConfigValue({ "DistanceToActivateEffect" }, OPTION_DEFAULT_EFFECT_SPAWN_DISTANCE); m_DistanceChaosState.DistanceType = static_cast( g_OptionsManager.GetConfigValue({ "DistanceType" }, OPTION_DEFAULT_DISTANCE_TYPE)); } @@ -128,16 +128,17 @@ std::uint64_t EffectDispatchTimer::GetTimer() const void EffectDispatchTimer::ResetTimer() { - m_TimerPercentage = 0.f; - m_Timer = GetTickCount64(); + m_TimerPercentage = 0.f; + m_Timer = GetTickCount64(); m_DistanceChaosState.SavedPosition = GET_ENTITY_COORDS(PLAYER_PED_ID(), false); } int EffectDispatchTimer::GetRemainingTimerTime() const { - return std::ceil(m_EffectSpawnTime - / (!ComponentExists() ? 1.f : GetComponent()->TimerSpeedModifier) - * (1.f - m_TimerPercentage)); + return static_cast( + std::ceil(m_EffectSpawnTime + / (!ComponentExists() ? 1.f : GetComponent()->TimerSpeedModifier) + * (1.f - m_TimerPercentage))); } bool EffectDispatchTimer::ShouldDispatchEffectNow() const diff --git a/ChaosMod/Components/EffectDispatcher.cpp b/ChaosMod/Components/EffectDispatcher.cpp index b5ba6fced..c05994589 100644 --- a/ChaosMod/Components/EffectDispatcher.cpp +++ b/ChaosMod/Components/EffectDispatcher.cpp @@ -45,9 +45,7 @@ static void _DispatchEffect(EffectDispatcher *effectDispatcher, const EffectDisp // Reset weight of this effect (or every effect in group) to reduce chance of same effect (group) happening multiple // times in a row if (effectData.GroupType.empty()) - { effectData.Weight = effectData.WeightMult; - } else { for (auto &effectData : filteredEffects) @@ -132,7 +130,7 @@ static void _DispatchEffect(EffectDispatcher *effectDispatcher, const EffectDisp if (!entry.Suffix.empty()) effectName << " " << entry.Suffix; - int effectDuration = 0; + float effectDuration = 0; switch (effectData.TimedType) { case EffectTimedType::NotTimed: @@ -199,15 +197,15 @@ static void _OnRunEffects(LPVOID data) while (true) { auto curTime = GetTickCount64(); - int deltaTime = + float deltaTime = !ComponentExists() ? 0 : (curTime - lastTime) * (ComponentExists() ? GetComponent()->EffectDurationModifier : 1.f); // The game was paused - if (deltaTime > 1000) - deltaTime = 0; + if (deltaTime > 1000.f) + deltaTime = 0.f; lastTime = curTime; @@ -279,7 +277,7 @@ void EffectDispatcher::OnRun() DrawEffectTexts(); } -void EffectDispatcher::UpdateEffects(int deltaTime) +void EffectDispatcher::UpdateEffects(float deltaTime) { if (m_ClearEffectsState != ClearEffectsState::None) { @@ -396,7 +394,7 @@ void EffectDispatcher::UpdateEffects(int deltaTime) } } -void EffectDispatcher::UpdateMetaEffects(int deltaTime) +void EffectDispatcher::UpdateMetaEffects(float deltaTime) { if (!SharedState.MetaEffectsEnabled) return; diff --git a/ChaosMod/Components/EffectDispatcher.h b/ChaosMod/Components/EffectDispatcher.h index ae0e1d046..1f3008b0a 100644 --- a/ChaosMod/Components/EffectDispatcher.h +++ b/ChaosMod/Components/EffectDispatcher.h @@ -116,8 +116,8 @@ class EffectDispatcher : public Component void DispatchRandomEffect(DispatchEffectFlags dispatchEffectFlags = DispatchEffectFlag_None, const std::string &suffix = {}); - void UpdateEffects(int deltaTime); - void UpdateMetaEffects(int deltaTime); + void UpdateEffects(float deltaTime); + void UpdateMetaEffects(float deltaTime); void ClearEffect(const EffectIdentifier &effectId); enum ClearEffectsFlags diff --git a/ChaosMod/Components/LuaScripts.cpp b/ChaosMod/Components/LuaScripts.cpp index c765a534f..75ab72d9d 100644 --- a/ChaosMod/Components/LuaScripts.cpp +++ b/ChaosMod/Components/LuaScripts.cpp @@ -173,6 +173,9 @@ class LuaHolder return _TryParseVector3(&m_Data, x, y, z) ? LuaVector3(x, y, z) : LuaVector3(); } +#if defined(__clang__) || defined(__GNUC__) +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif return *reinterpret_cast(&m_Data); } @@ -804,7 +807,7 @@ LuaScripts::ParseScript(std::string scriptName, const std::string &script, Parse else { effectData.TimedType = EffectTimedType::Custom; - effectData.CustomTime = (std::max)(1, *durationOpt); + effectData.CustomTime = static_cast(std::max(1, *durationOpt)); } } else @@ -817,7 +820,7 @@ LuaScripts::ParseScript(std::string scriptName, const std::string &script, Parse { effectData.TimedType = static_cast(settingOverrides["TimedType"]); } - catch (nlohmann::json::exception) + catch (nlohmann::json::exception &) { } try @@ -826,21 +829,21 @@ LuaScripts::ParseScript(std::string scriptName, const std::string &script, Parse if (effectData.CustomTime > 0) effectData.TimedType = EffectTimedType::Custom; } - catch (nlohmann::json::exception) + catch (nlohmann::json::exception &) { } const sol::optional &weightMultOpt = effectInfo["WeightMultiplier"]; if (weightMultOpt) { - effectData.WeightMult = (std::max)(1, *weightMultOpt); + effectData.WeightMult = static_cast(std::max(1, *weightMultOpt)); effectData.Weight = effectData.WeightMult; } try { effectData.WeightMult = settingOverrides["WeightMult"]; } - catch (nlohmann::json::exception) + catch (nlohmann::json::exception &) { } @@ -855,7 +858,7 @@ LuaScripts::ParseScript(std::string scriptName, const std::string &script, Parse { effectData.SetAttribute(EffectAttributes::ExcludedFromVoting, settingOverrides["ExcludedFromVoting"]); } - catch (nlohmann::json::exception) + catch (nlohmann::json::exception &) { } @@ -914,7 +917,7 @@ LuaScripts::ParseScript(std::string scriptName, const std::string &script, Parse { effectData.ShortcutKeycode = settingOverrides["ShortcutKeycode"]; } - catch (nlohmann::json::exception) + catch (nlohmann::json::exception &) { } @@ -924,7 +927,7 @@ LuaScripts::ParseScript(std::string scriptName, const std::string &script, Parse if (!name.empty()) effectData.CustomName = name; } - catch (nlohmann::json::exception) + catch (nlohmann::json::exception &) { } diff --git a/ChaosMod/Components/Voting.cpp b/ChaosMod/Components/Voting.cpp index 968d5e663..08c6ee609 100644 --- a/ChaosMod/Components/Voting.cpp +++ b/ChaosMod/Components/Voting.cpp @@ -142,7 +142,7 @@ void Voting::HandleMsg(std::string_view message) std::vector options = receivedJSON["Votes"]; if (options.size() == m_EffectChoices.size()) { - for (int idx = 0; idx < options.size(); idx++) + for (size_t idx = 0; idx < options.size(); idx++) { int votes = options[idx]; m_EffectChoices[idx]->ChanceVotes = votes; diff --git a/ChaosMod/Components/Workshop.cpp b/ChaosMod/Components/Workshop.cpp index a1824eaf7..f28a9f83c 100644 --- a/ChaosMod/Components/Workshop.cpp +++ b/ChaosMod/Components/Workshop.cpp @@ -19,7 +19,7 @@ nlohmann::json Workshop::GetSubmissionSettingJson(const std::string &submissionP { m_CachedSubmissionSettings[submissionPath] = nlohmann::json::parse(buffer.str()); } - catch (nlohmann::json::exception) + catch (nlohmann::json::exception &) { m_CachedSubmissionSettings[submissionPath] = {}; } @@ -34,10 +34,10 @@ std::vector Workshop::GetSubmissionBlacklistedFiles(const std::stri auto json = GetSubmissionSettingJson(submissionPath); try { - for (const std::string &file : json["disabled_files"]) + for (std::string file : json["disabled_files"]) blacklistedFiles.push_back(file); } - catch (nlohmann::json::exception) + catch (nlohmann::json::exception &) { } @@ -79,7 +79,7 @@ std::unordered_map Workshop::GetSubmissionScriptSet scriptSettings[key] = value; } } - catch (nlohmann::json::exception) + catch (nlohmann::json::exception &) { } diff --git a/ChaosMod/Effects/Condition/EffectCondition.h b/ChaosMod/Effects/Condition/EffectCondition.h index a0e14ac79..d1a044cc6 100644 --- a/ChaosMod/Effects/Condition/EffectCondition.h +++ b/ChaosMod/Effects/Condition/EffectCondition.h @@ -10,10 +10,10 @@ enum class EffectConditionType ProportionalVotingEnabled }; -#define REGISTER_EFFECT_CONDITION(conditionType, condition) \ - namespace \ - { \ - EffectCondition CONCAT(_effectCondition, __LINE__)(conditionType, condition); \ +#define REGISTER_EFFECT_CONDITION(conditionType, condition) \ + namespace \ + { \ + EffectCondition CHAOSCONCAT(_effectCondition, __LINE__)(conditionType, condition); \ } class EffectCondition; diff --git a/ChaosMod/Effects/EffectConfig.h b/ChaosMod/Effects/EffectConfig.h index f640b78cc..7f6fc4054 100644 --- a/ChaosMod/Effects/EffectConfig.h +++ b/ChaosMod/Effects/EffectConfig.h @@ -11,7 +11,7 @@ #include enum EffectType : int; -struct EffectData; +class EffectData; namespace EffectConfig { @@ -43,12 +43,12 @@ namespace EffectConfig { alignas(int) bool Enabled = true; alignas(int) EffectTimedType TimedType = EffectTimedType::NotTimed; - alignas(int) int CustomTime = 0; - alignas(int) int WeightMult = 0; + alignas(int) uint CustomTime = 0; + alignas(int) uint WeightMult = 0; alignas(int) bool Permanent = false; alignas(int) bool ExcludedFromVoting = false; alignas(int) char Placeholder; - alignas(int) int ShortcutKeycode = 0; + alignas(int) uint ShortcutKeycode = 0; }; union { @@ -106,7 +106,7 @@ namespace EffectConfig else if (configValues.Values.CustomTime > 0) { effectData.TimedType = EffectTimedType::Custom; - effectData.CustomTime = configValues.Values.CustomTime; + effectData.CustomTime = static_cast(configValues.Values.CustomTime); } else { @@ -117,7 +117,7 @@ namespace EffectConfig } if (configValues.Values.WeightMult > 0) - effectData.WeightMult = configValues.Values.WeightMult; + effectData.WeightMult = static_cast(configValues.Values.WeightMult); effectData.Weight = effectData.WeightMult; // Set initial effect weight to WeightMult effectData.SetAttribute(EffectAttributes::ExcludedFromVoting, configValues.Values.ExcludedFromVoting); effectData.SetAttribute(EffectAttributes::IsMeta, diff --git a/ChaosMod/Effects/EffectData.h b/ChaosMod/Effects/EffectData.h index 2408da4d6..f54d6b645 100644 --- a/ChaosMod/Effects/EffectData.h +++ b/ChaosMod/Effects/EffectData.h @@ -22,8 +22,8 @@ class EffectData std::string GroupType; std::set IncompatibleIds; float Weight = 5.f; - int CustomTime = -1; - int WeightMult = 5; + float WeightMult = 5.f; + float CustomTime = -1.f; int ShortcutKeycode = 0; EffectTimedType TimedType = EffectTimedType::NotTimed; EffectCategory Category = EffectCategory::None; diff --git a/ChaosMod/Effects/EnabledEffects.h b/ChaosMod/Effects/EnabledEffects.h index 061a4274a..750038f8c 100644 --- a/ChaosMod/Effects/EnabledEffects.h +++ b/ChaosMod/Effects/EnabledEffects.h @@ -10,7 +10,7 @@ using size_t = unsigned long long; -struct EffectData; +class EffectData; class EffectsIdentifierHasher { diff --git a/ChaosMod/Effects/Register/RegisterEffect.h b/ChaosMod/Effects/Register/RegisterEffect.h index edb4098b0..e017c0b53 100644 --- a/ChaosMod/Effects/Register/RegisterEffect.h +++ b/ChaosMod/Effects/Register/RegisterEffect.h @@ -9,10 +9,10 @@ #define CHAOS_VAR static thread_local -#define REGISTER_EFFECT(start, stop, tick, ...) \ - namespace \ - { \ - RegisterEffect CONCAT(_effect, __LINE__)(start, stop, tick, __VA_ARGS__); \ +#define REGISTER_EFFECT(start, stop, tick, ...) \ + namespace \ + { \ + RegisterEffect CHAOSCONCAT(_effect, __LINE__)(start, stop, tick, __VA_ARGS__); \ } class RegisterEffect diff --git a/ChaosMod/Effects/db/Misc/MiscAirstrike.cpp b/ChaosMod/Effects/db/Misc/MiscAirstrike.cpp index 5bc42e254..83091c724 100644 --- a/ChaosMod/Effects/db/Misc/MiscAirstrike.cpp +++ b/ChaosMod/Effects/db/Misc/MiscAirstrike.cpp @@ -21,9 +21,9 @@ static void OnStop() static Vector3 getRandomOffsetCoord(Vector3 startCoord, float maxOffset) { - return Vector3::Init(startCoord.x + g_Random.GetRandomInt(-maxOffset, maxOffset), - startCoord.y + g_Random.GetRandomInt(-maxOffset, maxOffset), - startCoord.z + g_Random.GetRandomInt(-maxOffset, maxOffset)); + return Vector3::Init(startCoord.x + g_Random.GetRandomFloat(-maxOffset, maxOffset), + startCoord.y + g_Random.GetRandomFloat(-maxOffset, maxOffset), + startCoord.z + g_Random.GetRandomFloat(-maxOffset, maxOffset)); } static void OnTick() diff --git a/ChaosMod/Effects/db/Misc/MiscFireworks.cpp b/ChaosMod/Effects/db/Misc/MiscFireworks.cpp index 318749ede..5e9ac663a 100644 --- a/ChaosMod/Effects/db/Misc/MiscFireworks.cpp +++ b/ChaosMod/Effects/db/Misc/MiscFireworks.cpp @@ -33,12 +33,12 @@ static void OnTick() WAIT(0); USE_PARTICLE_FX_ASSET("proj_indep_firework_v2"); - int x = pos.x + g_Random.GetRandomInt(-220, 220); - int y = pos.y + g_Random.GetRandomInt(-220, 220); - int z = pos.z + g_Random.GetRandomInt(50, 150); + float x = pos.x + g_Random.GetRandomFloat(-220.f, 220.f); + float y = pos.y + g_Random.GetRandomFloat(-220.f, 220.f); + float z = pos.z + g_Random.GetRandomFloat(50.f, 150.f); START_PARTICLE_FX_NON_LOOPED_AT_COORD(g_Random.GetRandomInt(0, 1) == 0 ? "scr_firework_indep_ring_burst_rwb" : "scr_firework_indep_spiral_burst_rwb", - x, y, z, 0.0f, 0.0f, 0.0f, 2.0f, true, true, true); + x, y, z, 0.f, .0f, .0f, 2.0f, true, true, true); // Spawn an explosion to make an explosion sound and a screen shake (explosionType 38 = fireworks) ADD_EXPLOSION(x, y, z, 38, 1.0f, true, false, 1.0f, false); } diff --git a/ChaosMod/Effects/db/Misc/MiscFpsLimit.cpp b/ChaosMod/Effects/db/Misc/MiscFpsLimit.cpp index fb6787413..1e0d26a99 100644 --- a/ChaosMod/Effects/db/Misc/MiscFpsLimit.cpp +++ b/ChaosMod/Effects/db/Misc/MiscFpsLimit.cpp @@ -9,7 +9,7 @@ static void OnTick() { static const int lagTimeDelay = 1000 / 25; - int lastUpdateTick = GetTickCount64(); + auto lastUpdateTick = GetTickCount64(); while (lastUpdateTick > GetTickCount64() - lagTimeDelay) { // Create Lag diff --git a/ChaosMod/Effects/db/Misc/MiscGhostWorld.cpp b/ChaosMod/Effects/db/Misc/MiscGhostWorld.cpp index 4fd9bbe8b..cb281128d 100644 --- a/ChaosMod/Effects/db/Misc/MiscGhostWorld.cpp +++ b/ChaosMod/Effects/db/Misc/MiscGhostWorld.cpp @@ -8,7 +8,7 @@ static int GetAlphaForEntity(Entity entity) { - return ((sin((entity * 20) + (GET_GAME_TIMER() / 125)) + 1) / 2) * 255; + return static_cast(std::floor(((std::sin((entity * 20) + (GET_GAME_TIMER() / 125)) + 1) / 2) * 255)); } static void OnTick() diff --git a/ChaosMod/Effects/db/Misc/MiscHighPitch.cpp b/ChaosMod/Effects/db/Misc/MiscHighPitch.cpp index 25964d82f..e3441b05f 100644 --- a/ChaosMod/Effects/db/Misc/MiscHighPitch.cpp +++ b/ChaosMod/Effects/db/Misc/MiscHighPitch.cpp @@ -3,11 +3,11 @@ #include "Effects/Register/RegisterEffect.h" #include "Memory/Hooks/AudioPitchHook.h" -CHAOS_VAR int ms_TargetPitch; +CHAOS_VAR float ms_TargetPitch; static void OnStart() { - ms_TargetPitch = g_Random.GetRandomInt(750, 2000); + ms_TargetPitch = g_Random.GetRandomFloat(750.f, 2000.f); } static void OnStop() diff --git a/ChaosMod/Effects/db/Misc/MiscLag.cpp b/ChaosMod/Effects/db/Misc/MiscLag.cpp index 1ede8057e..df802754c 100644 --- a/ChaosMod/Effects/db/Misc/MiscLag.cpp +++ b/ChaosMod/Effects/db/Misc/MiscLag.cpp @@ -15,8 +15,8 @@ static void OnStart() static void OnTickLag() { - static DWORD64 lastTick = 0; - auto curTick = GET_GAME_TIMER(); + static int lastTick = 0; + auto curTick = GET_GAME_TIMER(); if (curTick > lastTick + 500) { diff --git a/ChaosMod/Effects/db/Misc/MiscLowPitch.cpp b/ChaosMod/Effects/db/Misc/MiscLowPitch.cpp index f092f2cf0..9b9ebab81 100644 --- a/ChaosMod/Effects/db/Misc/MiscLowPitch.cpp +++ b/ChaosMod/Effects/db/Misc/MiscLowPitch.cpp @@ -5,11 +5,11 @@ // Effect by ProfessorBiddle, but the code is pretty much copied and pasted -CHAOS_VAR int ms_TargetPitch; +CHAOS_VAR float ms_TargetPitch; static void OnStart() { - ms_TargetPitch = g_Random.GetRandomInt(-900, -300); + ms_TargetPitch = g_Random.GetRandomFloat(-900.f, -300.f); } static void OnStop() diff --git a/ChaosMod/Effects/db/Misc/MiscNewsTeam.cpp b/ChaosMod/Effects/db/Misc/MiscNewsTeam.cpp index fe8928bc0..fdeae1608 100644 --- a/ChaosMod/Effects/db/Misc/MiscNewsTeam.cpp +++ b/ChaosMod/Effects/db/Misc/MiscNewsTeam.cpp @@ -10,8 +10,8 @@ static Vector3 GetCoordsAround(Vector3 pos, float radius) { int randOffset = g_Random.GetRandomInt(0, 360); Vector3 res; - res.x = pos.x + (COS(randOffset) * radius); - res.y = pos.y + (SIN(randOffset) * radius); + res.x = pos.x + (std::cos(randOffset) * radius); + res.y = pos.y + (std::sin(randOffset) * radius); res.z = pos.z + 50; return res; } @@ -23,56 +23,36 @@ CHAOS_VAR int lastPositionGoal = 0; CHAOS_VAR int scaleForm = 0; CHAOS_VAR Vector3 targetCoords; -CHAOS_VAR const char *ms_TextPairs[] = { "Chaos Mod Player Trying To Survive", - "\"He won't survive\", Mod Contributors Say", - - "Crazy Lunatic Going On A Rampage", - "This Report Was Brought To You By eCola", - - "The Aftermath Of An Experiment Gone Wrong", - "THE NEXT HEADLINE WILL TOTALLY SHOCK YOU!", - - "Wow Look At This", - "Crazy Ain't It?", - - "An Example Of Our Average Law-Abiding Citizen", - "\"Video Games cause violence\" Officials Say", - - "Holy Shit Wow Omg", - "LULW WTFFF xDDDDDDDD", - - "What Bad RNG Looks Like", - "Researchers Estimate The Chances Being Close To Millions To One", - - "A Speedrunner In Action", - "Criticizers Claim Mods Might Be At Play", - - "An Ongoing Riot All Over San Andreas", - "A War Ensued Between The So Claimed \"Bus Bois\" And \"Scooter Brothers\"", - - "Hey You're On Camera", - "Come On Do Something Cool!", - - "Look Up And Smile", - "It's The LSPD", - - "This Is A Nice Scaleform", - "Wow Is This Self-Aware?", - - "This Is Why We Can't Have Nice Things", - "SMH", - - "IS THAT A SUPRA???", - ":o", - - "Don't Mind Us", - "Just Getting Some Footage For The Trailer Of Expanded & Enhanced 2", - - "HMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM", - "HMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM", +struct TextPair +{ + const std::string_view Title; + const std::string_view Subtitle; - "Just Imagine All The Stuff I Could Put In Here", - "Oh Wait..." }; + TextPair(std::string_view title, std::string_view subtitle) : Title(title), Subtitle(subtitle) + { + } +}; +CHAOS_VAR const std::vector ms_TextPairs = { + { "Chaos Mod Player Trying To Survive", "\"He won't survive\", Mod Contributors Say" }, + { "Crazy Lunatic Going On A Rampage", "This Report Was Brought To You By eCola" }, + { "The Aftermath Of An Experiment Gone Wrong", "THE NEXT HEADLINE WILL TOTALLY SHOCK YOU!" }, + { "Wow Look At This", "Crazy Ain't It?" }, + { "An Example Of Our Average Law-Abiding Citizen", "\"Video Games cause violence\" Officials Say" }, + { "Holy Shit Wow Omg", "LULW WTFFF xDDDDDDDD" }, + { "What Bad RNG Looks Like", "Researchers Estimate The Chances Being Close To Millions To One" }, + { "A Speedrunner In Action", "Criticizers Claim Mods Might Be At Play" }, + { "An Ongoing Riot All Over San Andreas", + "A War Ensued Between The So Claimed \"Bus Bois\" And \"Scooter Brothers\"" }, + { "Hey You're On Camera", "Come On Do Something Cool!" }, + { "Look Up And Smile", "It's The LSPD" }, + { "This Is A Nice Scaleform", "Wow Is This Self-Aware?" }, + { "This Is Why We Can't Have Nice Things", "SMH" }, + { "IS THAT A SUPRA???", ":o" }, + { "Don't Mind Us", "Just Getting Some Footage For The Trailer Of Expanded & Enhanced 2" }, + { "HMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM", + "HMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM" }, + { "Just Imagine All The Stuff I Could Put In Here", "Oh Wait..." }, +}; static void OnStart() { @@ -124,10 +104,10 @@ static void OnStart() while (!HAS_SCALEFORM_MOVIE_LOADED(scaleForm)) WAIT(0); - int chosenIndex = g_Random.GetRandomInt(0, sizeof(ms_TextPairs) / sizeof(ms_TextPairs[0]) * .5f - 1) * 2; + const auto &chosenTextPair = ms_TextPairs[g_Random.GetRandomInt(0, ms_TextPairs.size() - 1)]; BEGIN_SCALEFORM_MOVIE_METHOD(scaleForm, "SET_TEXT"); - SCALEFORM_MOVIE_METHOD_ADD_PARAM_PLAYER_NAME_STRING(ms_TextPairs[chosenIndex]); - SCALEFORM_MOVIE_METHOD_ADD_PARAM_PLAYER_NAME_STRING(ms_TextPairs[chosenIndex + 1]); + SCALEFORM_MOVIE_METHOD_ADD_PARAM_PLAYER_NAME_STRING(chosenTextPair.Title.data()); + SCALEFORM_MOVIE_METHOD_ADD_PARAM_PLAYER_NAME_STRING(chosenTextPair.Subtitle.data()); END_SCALEFORM_MOVIE_METHOD(); } diff --git a/ChaosMod/Effects/db/Misc/MiscPayRespects.cpp b/ChaosMod/Effects/db/Misc/MiscPayRespects.cpp index 475de4283..89c77205d 100644 --- a/ChaosMod/Effects/db/Misc/MiscPayRespects.cpp +++ b/ChaosMod/Effects/db/Misc/MiscPayRespects.cpp @@ -6,7 +6,6 @@ #include "Effects/Register/RegisterEffect.h" #include -#include #define WAIT_TIME 10000 // ms @@ -14,8 +13,8 @@ CHAOS_VAR int ms_Overlay = 0; CHAOS_VAR const int ms_MaxPressInterval = 1000; CHAOS_VAR int ms_LastPressTick = 0; -CHAOS_VAR DWORD64 ms_TimeReserve; -CHAOS_VAR DWORD64 ms_LastTick = 0; +CHAOS_VAR int ms_TimeReserve; +CHAOS_VAR int ms_LastTick = 0; static inline bool Beepable(DWORD64 reserveValue) { @@ -25,13 +24,13 @@ static inline bool Beepable(DWORD64 reserveValue) static void OnTick() { Ped playerPed = PLAYER_PED_ID(); - Vector3 pos = GET_ENTITY_COORDS(playerPed, true); + auto pos = GET_ENTITY_COORDS(playerPed, true); if (!IS_PED_DEAD_OR_DYING(playerPed, false)) { - DWORD64 currentTick = GET_GAME_TIMER(); - DWORD64 tickDelta = currentTick - ms_LastTick; - int overlaycolor = 0; + int currentTick = GET_GAME_TIMER(); + int tickDelta = currentTick - ms_LastTick; + int overlaycolor = 0; if (IS_CONTROL_JUST_PRESSED(0, 23)) ms_LastPressTick = currentTick; diff --git a/ChaosMod/Effects/db/Misc/MiscRollCredits.cpp b/ChaosMod/Effects/db/Misc/MiscRollCredits.cpp index 748e69c9f..c62227297 100644 --- a/ChaosMod/Effects/db/Misc/MiscRollCredits.cpp +++ b/ChaosMod/Effects/db/Misc/MiscRollCredits.cpp @@ -44,8 +44,10 @@ static void OnTick() SET_USER_RADIO_CONTROL_ENABLED(false); - DRAW_RECT(.5f, .5f, 1.f, 1.f, 0, 0, 0, - std::lerp(0, 255, std::min(CurrentEffect::GetEffectCompletionPercentage(), 1.f)), false); + DRAW_RECT( + .5f, .5f, 1.f, 1.f, 0, 0, 0, + static_cast(std::floor(std::lerp(0, 255, std::min(CurrentEffect::GetEffectCompletionPercentage(), 1.f)))), + false); } // clang-format off diff --git a/ChaosMod/Effects/db/Misc/MiscSpawnOrangeBall.cpp b/ChaosMod/Effects/db/Misc/MiscSpawnOrangeBall.cpp index 63deef483..99b50d132 100644 --- a/ChaosMod/Effects/db/Misc/MiscSpawnOrangeBall.cpp +++ b/ChaosMod/Effects/db/Misc/MiscSpawnOrangeBall.cpp @@ -8,26 +8,26 @@ static void OnStart() { - static const Hash ballHash = "prop_juicestand"_hash; - static const Hash weaponHash = "weapon_specialcarbine"_hash; - static const int minDistance = 2; - static const int maxDistance = 7; - static const int maxSpeedCheck = 40; - Ped player = PLAYER_PED_ID(); - Vector3 pos = GET_ENTITY_COORDS(player, false); + static const Hash ballHash = "prop_juicestand"_hash; + static const Hash weaponHash = "weapon_specialcarbine"_hash; + static const float minDistance = 2.f; + static const float maxDistance = 7.f; + static const float maxSpeedCheck = 40.f; + Ped player = PLAYER_PED_ID(); + Vector3 pos = GET_ENTITY_COORDS(player, false); // Make distance to player dependent on players speed - float playerSpeed = std::min(std::max(0, static_cast(GET_ENTITY_SPEED(player))), maxSpeedCheck); - float fixedDistance = ((playerSpeed / maxSpeedCheck) * (maxDistance - minDistance)) + minDistance; - Vector3 spawnPos = GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(player, 0, fixedDistance, 0); - Object ball = CreatePoolProp(ballHash, spawnPos.x, spawnPos.y, spawnPos.z - 0.2, true); + float playerSpeed = std::min(std::max(0.f, GET_ENTITY_SPEED(player)), maxSpeedCheck); + float fixedDistance = ((playerSpeed / maxSpeedCheck) * (maxDistance - minDistance)) + minDistance; + Vector3 spawnPos = GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(player, 0, fixedDistance, 0); + Object ball = CreatePoolProp(ballHash, spawnPos.x, spawnPos.y, spawnPos.z - 0.2, true); // Randomize weight - float weight = g_Random.GetRandomFloat(1, 100); + float weight = g_Random.GetRandomFloat(1, 100); SET_OBJECT_PHYSICS_PARAMS(ball, weight, 1.f, 1.f, 0.f, 0.f, .5f, 0.f, 0.f, 0.f, 0.f, 0.f); // Ball needs to be shot at to be dynamic, otherwise it will be frozen Vector3 min, max; GET_MODEL_DIMENSIONS(ballHash, &min, &max); SHOOT_SINGLE_BULLET_BETWEEN_COORDS(spawnPos.x, spawnPos.y, spawnPos.z + max.z - min.z, spawnPos.x, spawnPos.y, - spawnPos.z, 0, true, weaponHash, 0, false, true, 0.01); + spawnPos.z, 0, true, weaponHash, 0, false, true, 0.01f); } // clang-format off diff --git a/ChaosMod/Effects/db/Misc/MiscWeirdPitch.cpp b/ChaosMod/Effects/db/Misc/MiscWeirdPitch.cpp index a09e00d26..1a299aaa7 100644 --- a/ChaosMod/Effects/db/Misc/MiscWeirdPitch.cpp +++ b/ChaosMod/Effects/db/Misc/MiscWeirdPitch.cpp @@ -10,7 +10,7 @@ static void OnStop() static void OnTick() { - Hooks::SetAudioPitch(g_Random.GetRandomInt(-900, 2000)); + Hooks::SetAudioPitch(g_Random.GetRandomFloat(-900.f, 2000.f)); } // clang-format off diff --git a/ChaosMod/Effects/db/Misc/MiscWhaleRain.cpp b/ChaosMod/Effects/db/Misc/MiscWhaleRain.cpp index 60c368927..34c0050a1 100644 --- a/ChaosMod/Effects/db/Misc/MiscWhaleRain.cpp +++ b/ChaosMod/Effects/db/Misc/MiscWhaleRain.cpp @@ -27,7 +27,8 @@ static void OnTick() LoadModel(WHALE_MODEL); - Ped whale = CreatePoolPed(28, WHALE_MODEL, spawnPos.x, spawnPos.y, spawnPos.z, g_Random.GetRandomInt(0, 359)); + Ped whale = + CreatePoolPed(28, WHALE_MODEL, spawnPos.x, spawnPos.y, spawnPos.z, g_Random.GetRandomFloat(0.f, 359.f)); whaleAmount++; for (int i = 0; i < MAX_WHALES; i++) diff --git a/ChaosMod/Effects/db/Misc/MiscWitnessProtection.cpp b/ChaosMod/Effects/db/Misc/MiscWitnessProtection.cpp index c52960902..b874ce65d 100644 --- a/ChaosMod/Effects/db/Misc/MiscWitnessProtection.cpp +++ b/ChaosMod/Effects/db/Misc/MiscWitnessProtection.cpp @@ -37,7 +37,7 @@ static void OnTick() SET_PED_CAN_RAGDOLL(ped, false); SET_ENTITY_COLLISION(ped, false, true); SET_PED_CAN_BE_TARGETTED_BY_PLAYER(ped, player, false); - float offset = (360 / pedCount) * i; + float offset = (360.f / pedCount) * i; OrbitPed orbPed = { ped, offset }; orbitingPeds.push_back(orbPed); if (--count == 0) diff --git a/ChaosMod/Effects/db/Peds/PedsHotCougars.cpp b/ChaosMod/Effects/db/Peds/PedsHotCougars.cpp index 8d35dc283..0d6a30a30 100644 --- a/ChaosMod/Effects/db/Peds/PedsHotCougars.cpp +++ b/ChaosMod/Effects/db/Peds/PedsHotCougars.cpp @@ -11,7 +11,7 @@ CHAOS_VAR std::list cougarEnemies; CHAOS_VAR int spawnTimer = -1; CHAOS_VAR Hash relationshipGroup; -CHAOS_VAR int maxCougarsToSpawn = 5; +CHAOS_VAR size_t maxCougarsToSpawn = 5; static void OnStop() { @@ -29,11 +29,11 @@ static void OnTick() while (!HAS_NAMED_PTFX_ASSET_LOADED("des_trailerpark")) WAIT(0); - Ped playerPed = PLAYER_PED_ID(); - Vector3 playerPos = GET_ENTITY_COORDS(playerPed, false); - int current_time = GET_GAME_TIMER(); + Ped playerPed = PLAYER_PED_ID(); + Vector3 playerPos = GET_ENTITY_COORDS(playerPed, false); + int current_time = GET_GAME_TIMER(); - static DWORD64 lastTick = GET_GAME_TIMER(); + static int lastTick = GET_GAME_TIMER(); if (lastTick < current_time - 100) { @@ -72,7 +72,7 @@ static void OnTick() if (cougarEnemies.size() < maxCougarsToSpawn && current_time > spawnTimer + 2000) { spawnTimer = current_time; - Vector3 spawnPos = GetCoordAround(playerPed, g_Random.GetRandomInt(0, 360), 10, 0, true); + Vector3 spawnPos = GetCoordAround(playerPed, g_Random.GetRandomFloat(0.f, 360.f), 10.f, 0.f, true); USE_PARTICLE_FX_ASSET("core"); START_PARTICLE_FX_NON_LOOPED_AT_COORD("exp_air_molotov", spawnPos.x, spawnPos.y, spawnPos.z, 0, 0, 0, 2, true, true, true); diff --git a/ChaosMod/Effects/db/Peds/PedsInTheHood.cpp b/ChaosMod/Effects/db/Peds/PedsInTheHood.cpp index 511a91cfc..2bcbd06d2 100644 --- a/ChaosMod/Effects/db/Peds/PedsInTheHood.cpp +++ b/ChaosMod/Effects/db/Peds/PedsInTheHood.cpp @@ -28,7 +28,7 @@ static void OnTick() if (!IS_ENTITY_PLAYING_ANIM(ped, "missfbi3_sniping", "dance_m_default", 3) && !IS_PED_A_PLAYER(ped) && (!IS_ENTITY_A_MISSION_ENTITY(ped) || rel == 4 || rel == 5)) { - TASK_PLAY_ANIM(ped, "missfbi3_sniping", "dance_m_default", 4.0f, -4.0f, -1.f, 1, 0.f, false, false, false); + TASK_PLAY_ANIM(ped, "missfbi3_sniping", "dance_m_default", 4.0f, -4.0f, -1, 1, 0.f, false, false, false); SET_PED_KEEP_TASK(ped, true); SET_BLOCKING_OF_NON_TEMPORARY_EVENTS(ped, true); } diff --git a/ChaosMod/Effects/db/Peds/PedsKillerClowns.cpp b/ChaosMod/Effects/db/Peds/PedsKillerClowns.cpp index 6466b3c4d..8c10488f2 100644 --- a/ChaosMod/Effects/db/Peds/PedsKillerClowns.cpp +++ b/ChaosMod/Effects/db/Peds/PedsKillerClowns.cpp @@ -9,7 +9,7 @@ CHAOS_VAR std::list clownEnemies; CHAOS_VAR int spawnTimer = -1; CHAOS_VAR Hash relationshipGroup; -CHAOS_VAR int maxClownsToSpawn = 3; +CHAOS_VAR size_t maxClownsToSpawn = 3; static Vector3 getRandomOffsetCoord(Vector3 startCoord, int minOffset, int maxOffset) { diff --git a/ChaosMod/Effects/db/Peds/PedsMercenaries.cpp b/ChaosMod/Effects/db/Peds/PedsMercenaries.cpp index 55b7c6d8e..cdb00ca37 100644 --- a/ChaosMod/Effects/db/Peds/PedsMercenaries.cpp +++ b/ChaosMod/Effects/db/Peds/PedsMercenaries.cpp @@ -22,13 +22,13 @@ static Vector3 getRandomOffsetCoord(Vector3 startCoord, float minOffset, float m { Vector3 randomCoord; if (g_Random.GetRandomInt(0, 1) % 2 == 0) - randomCoord.x = startCoord.x + g_Random.GetRandomInt(minOffset, maxOffset); + randomCoord.x = startCoord.x + g_Random.GetRandomFloat(minOffset, maxOffset); else - randomCoord.x = startCoord.x - g_Random.GetRandomInt(minOffset, maxOffset); + randomCoord.x = startCoord.x - g_Random.GetRandomFloat(minOffset, maxOffset); if (g_Random.GetRandomInt(0, 1) % 2 == 0) - randomCoord.y = startCoord.y + g_Random.GetRandomInt(minOffset, maxOffset); + randomCoord.y = startCoord.y + g_Random.GetRandomFloat(minOffset, maxOffset); else - randomCoord.y = startCoord.y - g_Random.GetRandomInt(minOffset, maxOffset); + randomCoord.y = startCoord.y - g_Random.GetRandomFloat(minOffset, maxOffset); randomCoord.z = startCoord.z; return randomCoord; } diff --git a/ChaosMod/Effects/db/Peds/PedsNotMenendez.cpp b/ChaosMod/Effects/db/Peds/PedsNotMenendez.cpp index dddbff589..84a3e8183 100644 --- a/ChaosMod/Effects/db/Peds/PedsNotMenendez.cpp +++ b/ChaosMod/Effects/db/Peds/PedsNotMenendez.cpp @@ -10,6 +10,11 @@ CHAOS_VAR std::set deadPeds; +static void OnStart() +{ + deadPeds = {}; +} + static void OnTick() { static DWORD64 lastTick = GetTickCount64(); @@ -35,17 +40,8 @@ static void OnTick() } } -static void OnStart() -{ - deadPeds = {}; - - for (Ped ped : GetAllPeds()) - if (IS_ENTITY_DEAD(ped, false)) - deadPeds.insert(ped); -} - // clang-format off -REGISTER_EFFECT(nullptr, nullptr, OnTick, +REGISTER_EFFECT(OnStart, nullptr, OnTick, { .Name = "Not Menendez!", .Id = "peds_not_menendez", diff --git a/ChaosMod/Effects/db/Peds/PedsSmokeTrails.cpp b/ChaosMod/Effects/db/Peds/PedsSmokeTrails.cpp index c1ef7f9f0..9cc58bafe 100644 --- a/ChaosMod/Effects/db/Peds/PedsSmokeTrails.cpp +++ b/ChaosMod/Effects/db/Peds/PedsSmokeTrails.cpp @@ -20,7 +20,7 @@ static void OnStart() static void OnStop() { - for (int i = 0; i < peds.size(); i++) + for (size_t i = 0; i < peds.size(); i++) { REMOVE_PARTICLE_FX_FROM_ENTITY(peds.at(i)); peds.erase(peds.begin() + i); @@ -36,7 +36,8 @@ static void OnTick() { USE_PARTICLE_FX_ASSET(ptfxDict); - int ptfx = START_PARTICLE_FX_LOOPED_ON_ENTITY(ptfxName, ped, 0, -0.1, 0, 0, 0, 0, 0.5, false, false, false); + int ptfx = + START_PARTICLE_FX_LOOPED_ON_ENTITY(ptfxName, ped, 0, -0.1f, 0, 0, 0, 0, 0.5f, false, false, false); SET_PARTICLE_FX_LOOPED_COLOUR(ptfx, g_Random.GetRandomFloat(0, 1), g_Random.GetRandomFloat(0, 1), g_Random.GetRandomFloat(0, 1), false); diff --git a/ChaosMod/Effects/db/Peds/PedsSpawnDancingApes.cpp b/ChaosMod/Effects/db/Peds/PedsSpawnDancingApes.cpp index 22587317b..2e2f4d237 100644 --- a/ChaosMod/Effects/db/Peds/PedsSpawnDancingApes.cpp +++ b/ChaosMod/Effects/db/Peds/PedsSpawnDancingApes.cpp @@ -29,7 +29,7 @@ static void OnStart() SET_PED_CAN_RAGDOLL(ped, false); SET_PED_SUFFERS_CRITICAL_HITS(ped, false); - TASK_PLAY_ANIM(ped, "missfbi3_sniping", "dance_m_default", 4.0f, -4.0f, -1.f, 1, 0.f, false, false, false); + TASK_PLAY_ANIM(ped, "missfbi3_sniping", "dance_m_default", 4.0f, -4.0f, -1, 1, 0.f, false, false, false); WAIT(0); SET_PED_CONFIG_FLAG(ped, 292, true); diff --git a/ChaosMod/Effects/db/Peds/PedsSpawnRoastingLamar.cpp b/ChaosMod/Effects/db/Peds/PedsSpawnRoastingLamar.cpp index c5bb6c245..a443f3407 100644 --- a/ChaosMod/Effects/db/Peds/PedsSpawnRoastingLamar.cpp +++ b/ChaosMod/Effects/db/Peds/PedsSpawnRoastingLamar.cpp @@ -53,8 +53,8 @@ static void OnStop() TASK_LOOK_AT_ENTITY(lamarPed, playerPed, 1000, 2048, 3); WAIT(1000); - TASK_PLAY_ANIM(lamarPed, "mp_player_int_upperfinger", "mp_player_int_finger_02", 8.0f, -1.0f, 1000.f, 1, - 0.f, false, false, false); + TASK_PLAY_ANIM(lamarPed, "mp_player_int_upperfinger", "mp_player_int_finger_02", 8.0f, -1.0f, 1000, 1, 0.f, + false, false, false); WAIT(2000); PLAY_PED_AMBIENT_SPEECH_NATIVE(playerPed, "GENERIC_SHOCKED_MED", "SPEECH_PARAMS_FORCE_SHOUTED", 1); diff --git a/ChaosMod/Effects/db/Peds/PedsTPGuns.cpp b/ChaosMod/Effects/db/Peds/PedsTPGuns.cpp index 5e1c4a87f..686460260 100644 --- a/ChaosMod/Effects/db/Peds/PedsTPGuns.cpp +++ b/ChaosMod/Effects/db/Peds/PedsTPGuns.cpp @@ -79,7 +79,7 @@ static void OnTick() } // clang-format off -REGISTER_EFFECT(nullptr, nullptr, OnTick, +REGISTER_EFFECT(OnStart, nullptr, OnTick, { .Name = "Portal Guns", .Id = "peds_portal_gun", diff --git a/ChaosMod/Effects/db/Player/PlayerBees.cpp b/ChaosMod/Effects/db/Player/PlayerBees.cpp index f29781c53..049286244 100644 --- a/ChaosMod/Effects/db/Player/PlayerBees.cpp +++ b/ChaosMod/Effects/db/Player/PlayerBees.cpp @@ -18,7 +18,7 @@ static void OnStart() USE_PARTICLE_FX_ASSET("core"); ms_ParticleId = - START_PARTICLE_FX_LOOPED_ON_ENTITY("ent_amb_fly_swarm", player, 0, 0, 0, 0, 0, 0, 1.1, false, false, false); + START_PARTICLE_FX_LOOPED_ON_ENTITY("ent_amb_fly_swarm", player, 0, 0, 0, 0, 0, 0, 1.1f, false, false, false); } static void ApplyVig() diff --git a/ChaosMod/Effects/db/Player/PlayerDeadEye.cpp b/ChaosMod/Effects/db/Player/PlayerDeadEye.cpp index 5e71dffb2..9775fc3c3 100644 --- a/ChaosMod/Effects/db/Player/PlayerDeadEye.cpp +++ b/ChaosMod/Effects/db/Player/PlayerDeadEye.cpp @@ -127,7 +127,7 @@ static void OnTick() if (DOES_ENTITY_EXIST(info.pedHandle)) { Vector3 destOffset = GET_PED_BONE_COORDS(info.pedHandle, info.boneIdx, 0, 0, 0); - float boxSize = 0.1; + float boxSize = 0.1f; DRAW_BOX(destOffset.x - boxSize, destOffset.y - boxSize, destOffset.z - boxSize, destOffset.x + boxSize, destOffset.y + boxSize, destOffset.z + boxSize, 255, 0, 0, 100); } diff --git a/ChaosMod/Effects/db/Player/PlayerFakeDeath.cpp b/ChaosMod/Effects/db/Player/PlayerFakeDeath.cpp index 9a48963f0..7d3a9d863 100644 --- a/ChaosMod/Effects/db/Player/PlayerFakeDeath.cpp +++ b/ChaosMod/Effects/db/Player/PlayerFakeDeath.cpp @@ -93,7 +93,7 @@ static void OnStart() WAIT(0); Hash pistolHash = "WEAPON_PISTOL"_hash; GIVE_WEAPON_TO_PED(playerPed, pistolHash, 1, true, true); - TASK_PLAY_ANIM(playerPed, "mp_suicide", "pistol", 8.0f, -1.0f, 1150.f, 1, 0.f, false, false, + TASK_PLAY_ANIM(playerPed, "mp_suicide", "pistol", 8.0f, -1.0f, 1150, 1, 0.f, false, false, false); nextModeTime = 750; break; @@ -104,14 +104,14 @@ static void OnStart() // Set the fake name accordingly CurrentEffect::OverrideEffectNameFromId("playerveh_explode"); - Vehicle veh = GET_VEHICLE_PED_IS_IN(playerPed, false); + Vehicle veh = GET_VEHICLE_PED_IS_IN(playerPed, false); - int lastTimestamp = GET_GAME_TIMER(); + int lastTimestamp = GET_GAME_TIMER(); - int seats = GET_VEHICLE_MODEL_NUMBER_OF_SEATS(GET_ENTITY_MODEL(veh)); + int seats = GET_VEHICLE_MODEL_NUMBER_OF_SEATS(GET_ENTITY_MODEL(veh)); - int detonateTimer = 5000; - int beepTimer = 5000; + float detonateTimer = 5000.f; + float beepTimer = 5000.f; while (DOES_ENTITY_EXIST(veh)) { WAIT(0); @@ -138,7 +138,7 @@ static void OnStart() } } - if (detonateTimer <= 0) + if (detonateTimer <= 0.f) { for (int i = 0; i < 6; i++) SET_VEHICLE_DOOR_BROKEN(veh, i, false); diff --git a/ChaosMod/Effects/db/Player/PlayerHeavyRecoil.cpp b/ChaosMod/Effects/db/Player/PlayerHeavyRecoil.cpp index b62c58909..6bf34d7a0 100644 --- a/ChaosMod/Effects/db/Player/PlayerHeavyRecoil.cpp +++ b/ChaosMod/Effects/db/Player/PlayerHeavyRecoil.cpp @@ -15,7 +15,7 @@ static void OnTick() Hash weaponHash; if (GET_CURRENT_PED_WEAPON(player, &weaponHash, 1) && GET_WEAPON_DAMAGE_TYPE(weaponHash) == 3) { - float horizontalRecoil = g_Random.GetRandomInt(-100, 100); + float horizontalRecoil = g_Random.GetRandomFloat(-100.f, 100.f); horizontalRecoil = horizontalRecoil / 10; for (int i = 0; i < 10; i++) { diff --git a/ChaosMod/Effects/db/Player/PlayerLagCamera.cpp b/ChaosMod/Effects/db/Player/PlayerLagCamera.cpp index fb0e6a17b..55fa2797e 100644 --- a/ChaosMod/Effects/db/Player/PlayerLagCamera.cpp +++ b/ChaosMod/Effects/db/Player/PlayerLagCamera.cpp @@ -6,10 +6,10 @@ #include "Effects/Register/RegisterEffect.h" -CHAOS_VAR int constexpr CAM_DELAY_NORMAL = 250; -CHAOS_VAR int constexpr CAM_DELAY_VEHICLE = 1000; +#define CAM_DELAY_NORMAL 250.f +#define CAM_DELAY_VEHICLE 1000.f -static int GetTargetCamDelay() +static float GetTargetCamDelay() { return IS_PED_IN_ANY_VEHICLE(PLAYER_PED_ID(), true) ? CAM_DELAY_VEHICLE : CAM_DELAY_NORMAL; } @@ -33,8 +33,8 @@ struct CameraSnapshot CHAOS_VAR std::vector cameraSnapshots; -CHAOS_VAR int currentCamDelay; -CHAOS_VAR int targetCamDelay; +CHAOS_VAR float currentCamDelay; +CHAOS_VAR float targetCamDelay; CHAOS_VAR Cam camera; static void TakeCameraSnapshot() @@ -51,7 +51,7 @@ static void OnStart() CAM::RENDER_SCRIPT_CAMS(true, true, 700, 1, 1, 1); cameraSnapshots = {}; - currentCamDelay = 0; + currentCamDelay = 0.f; } static void OnTick() @@ -77,7 +77,7 @@ static void OnTick() if (currentCamDelay != targetCamDelay) { int direction = currentCamDelay < targetCamDelay ? 1 : -1; - currentCamDelay += 300 * direction * GET_FRAME_TIME(); + currentCamDelay += 300.f * direction * GET_FRAME_TIME(); // If the step this frame overshot the target, snap back to it if ((direction == 1 && currentCamDelay > targetCamDelay) diff --git a/ChaosMod/Effects/db/Player/PlayerRandomStuntJump.cpp b/ChaosMod/Effects/db/Player/PlayerRandomStuntJump.cpp index 080ea787b..952cd83f3 100644 --- a/ChaosMod/Effects/db/Player/PlayerRandomStuntJump.cpp +++ b/ChaosMod/Effects/db/Player/PlayerRandomStuntJump.cpp @@ -18,36 +18,36 @@ struct Location }; CHAOS_VAR std::vector allPossibleJumps = { - { { 46.101, 6530.031, 30.713 }, 137.332, 40.f }, // 1 - { { -186.248, 6554.466, 10.446 }, 314.389, 30.f }, // 2 - { { 490.106, 4309.650, 54.884 }, 54.039, 45.f }, // 3 - { { -953.295, 4166.992, 136.374 }, 51.525, 30.f }, // 4 - { { 3335.163, 5148.697, 17.637 }, 276.721, 45.f }, // 5 - { { 1684.881, 3141.746, 42.871 }, 24.974, 45.f }, // 6 - { { 1680.338, 2316.249, 74.705 }, 357.364, 43.f }, // 7 - { { 1780.440, 2056.524, 65.945 }, 195.309, 60.f }, // 8 - { { 2001.575, 1920.334, 91.608 }, 57.712, 45.f }, // 9 - { { -2.917, 1699.827, 226.620 }, 325.440, 45.f }, // 10 - { { -1447.177, 412.317, 109.067 }, 191.007, 55.f }, // 11 - { { -1081.151, 11.979, 50.056 }, 257.962, 22.f }, // 12 - { { -713.306, -49.739, 37.063 }, 110.136, 42.f }, // 13 - { { -588.852, -92.791, 41.684 }, 153.347, 30.f }, // 14 - { { -1589.183, -748.284, 20.791 }, 79.817, 48.f }, // 15 - { { 46.478, -780.456, 43.524 }, 249.806, 30.f }, // 16 - { { 303.248, -618.176, 42.797 }, 249.437, 40.f }, // 17 - { { 563.992, -583.787, 43.544 }, 187.271, 45.f }, // 18 - { { -285.071, -763.947, 52.595 }, 241.151, 45.f }, // 19 - { { -873.079, -848.673, 18.503 }, 106.121, 40.f }, // 20 - { { -617.539, -1074.971, 21.727 }, 74.128, 40.f }, // 21 - { { 2.338, -1038.557, 37.502 }, 70.644, 35.f }, // 22 - { { -440.262, -1178.323, 52.588 }, 175.859, 50.f }, // 23 - { { -533.043, -1480.427, 11.122 }, 248.903, 45.f }, // 24 - { { -453.039, -1380.261, 29.779 }, 180.118, 45.f }, // 25 - { { -570.175, -1533.781, 0.603 }, 72.475, 50.f }, // 26 - { { -423.742, -1564.256, 24.752 }, 350.530, 45.f }, // 27 - { { -980.685, -2491.565, 13.898 }, 151.314, 60.f }, // 28 - { { -860.708, -2566.927, 13.785 }, 331.449, 60.f }, // 29 - { { -958.207, -2766.583, 13.693 }, 151.829, 45.f } // 30 + { { 46.101f, 6530.031f, 30.713f }, 137.332f, 40.f }, // 1 + { { -186.248f, 6554.466f, 10.446f }, 314.389f, 30.f }, // 2 + { { 490.106f, 4309.650f, 54.884f }, 54.039f, 45.f }, // 3 + { { -953.295f, 4166.992f, 136.374f }, 51.525f, 30.f }, // 4 + { { 3335.163f, 5148.697f, 17.637f }, 276.721f, 45.f }, // 5 + { { 1684.881f, 3141.746f, 42.871f }, 24.974f, 45.f }, // 6 + { { 1680.338f, 2316.249f, 74.705f }, 357.364f, 43.f }, // 7 + { { 1780.440f, 2056.524f, 65.945f }, 195.309f, 60.f }, // 8 + { { 2001.575f, 1920.334f, 91.608f }, 57.712f, 45.f }, // 9 + { { -2.917f, 1699.827f, 226.620f }, 325.440f, 45.f }, // 10 + { { -1447.177f, 412.317f, 109.067f }, 191.007f, 55.f }, // 11 + { { -1081.151f, 11.979f, 50.056f }, 257.962f, 22.f }, // 12 + { { -713.306f, -49.739f, 37.063f }, 110.136f, 42.f }, // 13 + { { -588.852f, -92.791f, 41.684f }, 153.347f, 30.f }, // 14 + { { -1589.183f, -748.284f, 20.791f }, 79.817f, 48.f }, // 15 + { { 46.478f, -780.456f, 43.524f }, 249.806f, 30.f }, // 16 + { { 303.248f, -618.176f, 42.797f }, 249.437f, 40.f }, // 17 + { { 563.992f, -583.787f, 43.544f }, 187.271f, 45.f }, // 18 + { { -285.071f, -763.947f, 52.595f }, 241.151f, 45.f }, // 19 + { { -873.079f, -848.673f, 18.503f }, 106.121f, 40.f }, // 20 + { { -617.539f, -1074.971f, 21.727f }, 74.128f, 40.f }, // 21 + { { 2.338f, -1038.557f, 37.502f }, 70.644f, 35.f }, // 22 + { { -440.262f, -1178.323f, 52.588f }, 175.859f, 50.f }, // 23 + { { -533.043f, -1480.427f, 11.122f }, 248.903f, 45.f }, // 24 + { { -453.039f, -1380.261f, 29.779f }, 180.118f, 45.f }, // 25 + { { -570.175f, -1533.781f, 0.603f }, 72.475f, 50.f }, // 26 + { { -423.742f, -1564.256f, 24.752f }, 350.530f, 45.f }, // 27 + { { -980.685f, -2491.565f, 13.898f }, 151.314f, 60.f }, // 28 + { { -860.708f, -2566.927f, 13.785f }, 331.449f, 60.f }, // 29 + { { -958.207f, -2766.583f, 13.693f }, 151.829f, 45.f } // 30 }; void OnStartMakeRandomStuntJump() diff --git a/ChaosMod/Effects/db/Player/PlayerRocket.cpp b/ChaosMod/Effects/db/Player/PlayerRocket.cpp index 53ad1b480..9ffdd5394 100644 --- a/ChaosMod/Effects/db/Player/PlayerRocket.cpp +++ b/ChaosMod/Effects/db/Player/PlayerRocket.cpp @@ -20,8 +20,8 @@ static void OnStart() // REQUEST_NAMED_PTFX_ASSET("core"); Doesn't seem to be necessary int lastTimestamp = GET_GAME_TIMER(); - int launchTimer = LAUNCH_TIMER; - int beepTimer = LAUNCH_TIMER; + float launchTimer = LAUNCH_TIMER; + float beepTimer = LAUNCH_TIMER; while (true) { SET_ENTITY_INVINCIBLE(playerPed, true); @@ -39,7 +39,7 @@ static void OnStart() SET_ENTITY_VELOCITY(playerPed, 0.f, 0.f, 5.f); } - if (launchTimer <= 0) + if (launchTimer <= 0.f) { USE_PARTICLE_FX_ASSET("core"); START_PARTICLE_FX_LOOPED_ON_ENTITY("exp_air_rpg", playerPed, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 2.f, false, diff --git a/ChaosMod/Effects/db/Player/PlayerSetIntoClosestVeh.cpp b/ChaosMod/Effects/db/Player/PlayerSetIntoClosestVeh.cpp index 8081e9241..fc41ddfc1 100644 --- a/ChaosMod/Effects/db/Player/PlayerSetIntoClosestVeh.cpp +++ b/ChaosMod/Effects/db/Player/PlayerSetIntoClosestVeh.cpp @@ -50,10 +50,10 @@ static void OnStart() } } - Hash closestVehModel = GET_ENTITY_MODEL(closestVeh); - int closestVehMaxSeats = GET_VEHICLE_MODEL_NUMBER_OF_SEATS(closestVehModel); + Hash closestVehModel = GET_ENTITY_MODEL(closestVeh); + size_t closestVehMaxSeats = GET_VEHICLE_MODEL_NUMBER_OF_SEATS(closestVehModel); - for (int i = 0; i < teleportPeds.size(); i++) + for (size_t i = 0; i < teleportPeds.size(); i++) { if (i >= closestVehMaxSeats) break; diff --git a/ChaosMod/Effects/db/Player/PlayerSetIntoRandomVeh.cpp b/ChaosMod/Effects/db/Player/PlayerSetIntoRandomVeh.cpp index 5f17aaf44..12cd3e1fd 100644 --- a/ChaosMod/Effects/db/Player/PlayerSetIntoRandomVeh.cpp +++ b/ChaosMod/Effects/db/Player/PlayerSetIntoRandomVeh.cpp @@ -45,12 +45,12 @@ static void OnStart() } } - Vehicle targetVeh = vehs[g_Random.GetRandomInt(0, vehs.size() - 1)]; + Vehicle targetVeh = vehs[g_Random.GetRandomInt(0, vehs.size() - 1)]; - Hash targetVehModel = GET_ENTITY_MODEL(targetVeh); - int targetVehMaxSeats = GET_VEHICLE_MODEL_NUMBER_OF_SEATS(targetVehModel); + Hash targetVehModel = GET_ENTITY_MODEL(targetVeh); + size_t targetVehMaxSeats = GET_VEHICLE_MODEL_NUMBER_OF_SEATS(targetVehModel); - for (int i = 0; i < teleportPeds.size(); i++) + for (size_t i = 0; i < teleportPeds.size(); i++) { if (i >= targetVehMaxSeats) break; diff --git a/ChaosMod/Effects/db/Player/PlayerSimeonSays.cpp b/ChaosMod/Effects/db/Player/PlayerSimeonSays.cpp index e0e9a7109..04c2475bf 100644 --- a/ChaosMod/Effects/db/Player/PlayerSimeonSays.cpp +++ b/ChaosMod/Effects/db/Player/PlayerSimeonSays.cpp @@ -31,10 +31,10 @@ CHAOS_VAR std::map> actionKeys = { }; // clang-format on -CHAOS_VAR int scaleForm = 0; -CHAOS_VAR int lastTime = 0; -CHAOS_VAR int waitTime = 2000; -CHAOS_VAR bool dead = false; +CHAOS_VAR int scaleForm = 0; +CHAOS_VAR std::uint64_t lastTime = 0; +CHAOS_VAR std::uint64_t waitTime = 2000; +CHAOS_VAR bool dead = false; CHAOS_VAR std::string action; diff --git a/ChaosMod/Effects/db/Player/PlayerSuicide.cpp b/ChaosMod/Effects/db/Player/PlayerSuicide.cpp index 909a9d1c6..7303038c6 100644 --- a/ChaosMod/Effects/db/Player/PlayerSuicide.cpp +++ b/ChaosMod/Effects/db/Player/PlayerSuicide.cpp @@ -13,7 +13,7 @@ static void OnStart() WAIT(0); Hash pistolHash = "WEAPON_PISTOL"_hash; GIVE_WEAPON_TO_PED(playerPed, pistolHash, 9999, true, true); - TASK_PLAY_ANIM(playerPed, "mp_suicide", "pistol", 8.0f, -1.0f, 800.f, 1, 0.f, false, false, false); + TASK_PLAY_ANIM(playerPed, "mp_suicide", "pistol", 8.0f, -1.0f, 800, 1, 0.f, false, false, false); WAIT(750); SET_PED_SHOOTS_AT_COORD(playerPed, 0, 0, 0, true); REMOVE_ANIM_DICT("mp_suicide"); diff --git a/ChaosMod/Effects/db/Player/PlayerTpController.cpp b/ChaosMod/Effects/db/Player/PlayerTpController.cpp index c083486de..aec93431a 100644 --- a/ChaosMod/Effects/db/Player/PlayerTpController.cpp +++ b/ChaosMod/Effects/db/Player/PlayerTpController.cpp @@ -223,8 +223,8 @@ static void OnStartRandom() float x, y, z = playerPos.z, _; do { - x = g_Random.GetRandomInt(-3747.f, 4500.f); - y = g_Random.GetRandomInt(-4400.f, 8022.f); + x = g_Random.GetRandomFloat(-3747.f, 4500.f); + y = g_Random.GetRandomFloat(-4400.f, 8022.f); } while (TEST_VERTICAL_PROBE_AGAINST_ALL_WATER(x, y, z, 0, &_)); diff --git a/ChaosMod/Effects/db/Screen/ScreenRealFirstPerson.cpp b/ChaosMod/Effects/db/Screen/ScreenRealFirstPerson.cpp index 62f7d7e8e..25db1cedb 100644 --- a/ChaosMod/Effects/db/Screen/ScreenRealFirstPerson.cpp +++ b/ChaosMod/Effects/db/Screen/ScreenRealFirstPerson.cpp @@ -45,7 +45,7 @@ static void SetupCamera() false, 2); ATTACH_CAM_TO_PED_BONE(eCamera, playerPed, 31086, 0, 0, 0, 0); - SET_CAM_NEAR_CLIP(eCamera, 0.2); + SET_CAM_NEAR_CLIP(eCamera, .2f); SET_CAM_AFFECTS_AIMING(eCamera, false); } diff --git a/ChaosMod/Effects/db/Vehs/Vehs30mphLimit.cpp b/ChaosMod/Effects/db/Vehs/Vehs30mphLimit.cpp index 7d61f46ed..1bafef28f 100644 --- a/ChaosMod/Effects/db/Vehs/Vehs30mphLimit.cpp +++ b/ChaosMod/Effects/db/Vehs/Vehs30mphLimit.cpp @@ -9,7 +9,7 @@ static void OnTick() { for (Vehicle veh : GetAllVehs()) - _SET_VEHICLE_MAX_SPEED(veh, 13.41); // 13.41 Meters Per Second = 30 MPH~ + _SET_VEHICLE_MAX_SPEED(veh, 13.41f); // 13.41 Meters Per Second = 30 MPH~ } static void OnStop() diff --git a/ChaosMod/Effects/db/Vehs/VehsColorController.cpp b/ChaosMod/Effects/db/Vehs/VehsColorController.cpp index 28ff81e74..dae604b6f 100644 --- a/ChaosMod/Effects/db/Vehs/VehsColorController.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsColorController.cpp @@ -194,9 +194,9 @@ static void OnTickRainbow() for (Vehicle veh : GetAllVehs()) { - int r = std::sin(veh + freq * cnt) * 127 + 128; - int g = std::sin(veh + freq * cnt + 2) * 127 + 128; - int b = std::sin(veh + freq * cnt + 4) * 127 + 128; + int r = std::lround(std::sin(veh + freq * cnt) * 127 + 128); + int g = std::lround(std::sin(veh + freq * cnt + 2) * 127 + 128); + int b = std::lround(std::sin(veh + freq * cnt + 4) * 127 + 128); SET_VEHICLE_CUSTOM_PRIMARY_COLOUR(veh, r, g, b); SET_VEHICLE_CUSTOM_SECONDARY_COLOUR(veh, g, b, r); @@ -221,9 +221,9 @@ static void OnTickRainbow() // Headlight color switcher - int r = std::sin(freq * cnt) * 127 + 128; - int g = std::sin(freq * cnt + 2) * 127 + 128; - int b = std::sin(freq * cnt + 4) * 127 + 128; + int r = std::lround(std::sin(freq * cnt) * 127 + 128); + int g = std::lround(std::sin(freq * cnt + 2) * 127 + 128); + int b = std::lround(std::sin(freq * cnt + 4) * 127 + 128); for (int i = 0; i < 13; i++) Memory::OverrideVehicleHeadlightColor(i, true, r, g, b); diff --git a/ChaosMod/Effects/db/Vehs/VehsPlayerVehExplode.cpp b/ChaosMod/Effects/db/Vehs/VehsPlayerVehExplode.cpp index 4e4108bed..346ef19ee 100644 --- a/ChaosMod/Effects/db/Vehs/VehsPlayerVehExplode.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsPlayerVehExplode.cpp @@ -2,7 +2,7 @@ #include "Effects/Register/RegisterEffect.h" -#define DETONATE_TIMER 5000 +#define DETONATE_TIMER 5000.f static void OnStart() { @@ -11,14 +11,14 @@ static void OnStart() if (!IS_PED_IN_ANY_VEHICLE(playerPed, false)) return; - Vehicle veh = GET_VEHICLE_PED_IS_IN(playerPed, false); + Vehicle veh = GET_VEHICLE_PED_IS_IN(playerPed, false); - int lastTimestamp = GET_GAME_TIMER(); + int lastTimestamp = GET_GAME_TIMER(); - int seats = GET_VEHICLE_MODEL_NUMBER_OF_SEATS(GET_ENTITY_MODEL(veh)); + int seats = GET_VEHICLE_MODEL_NUMBER_OF_SEATS(GET_ENTITY_MODEL(veh)); - int detonateTimer = DETONATE_TIMER; - int beepTimer = DETONATE_TIMER; + float detonateTimer = DETONATE_TIMER; + float beepTimer = DETONATE_TIMER; while (DOES_ENTITY_EXIST(veh)) { WAIT(0); @@ -45,7 +45,7 @@ static void OnStart() } } - if (detonateTimer <= 0) + if (detonateTimer <= 0.f) { EXPLODE_VEHICLE(veh, true, false); diff --git a/ChaosMod/Effects/db/Vehs/VehsRepossession.cpp b/ChaosMod/Effects/db/Vehs/VehsRepossession.cpp index 212d3f58d..c19fbe710 100644 --- a/ChaosMod/Effects/db/Vehs/VehsRepossession.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsRepossession.cpp @@ -28,7 +28,7 @@ static void OnStart() Vector3 coords; coords.x = -52; - coords.y = -1106.88; + coords.y = -1106.88f; coords.z = 26; // Probably a really bad way of doing this, but im lazy as fuck. TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGE(FranklinDrive, veh, coords.x, coords.y, coords.z, 9999.f, 262668, 0.f); @@ -60,7 +60,7 @@ static void OnStart() Vector3 coords; coords.x = -52; - coords.y = -1106.88; + coords.y = -1106.88f; coords.z = 26; // Probably a really bad way of doing this, but im lazy as fuck. TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGE(FranklinDrive, veh, coords.x, coords.y, coords.z, 9999.f, 262668, 0.f); diff --git a/ChaosMod/Effects/db/Vehs/VehsSpawner.cpp b/ChaosMod/Effects/db/Vehs/VehsSpawner.cpp index d50a38800..5c6cd1fad 100644 --- a/ChaosMod/Effects/db/Vehs/VehsSpawner.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsSpawner.cpp @@ -322,7 +322,7 @@ static void OnStartWizardBroom() SET_ENTITY_VISIBLE(veh, false, false); Object broom = CREATE_OBJECT(broomHash, playerPos.x, playerPos.y + 2, playerPos.z, true, false, false); - ATTACH_ENTITY_TO_ENTITY(broom, veh, 0, 0, 0, 0.3, -80.0, 0, 0, true, false, false, false, 0, true); + ATTACH_ENTITY_TO_ENTITY(broom, veh, 0, 0, 0, .3f, -80.f, 0, 0, true, false, false, false, 0, true); } // clang-format off diff --git a/ChaosMod/Effects/db/Vehs/VehsWeapons.cpp b/ChaosMod/Effects/db/Vehs/VehsWeapons.cpp index da2ac0ef1..e2f231056 100644 --- a/ChaosMod/Effects/db/Vehs/VehsWeapons.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsWeapons.cpp @@ -37,7 +37,7 @@ static void OnTick() } Vehicle veh = GET_VEHICLE_PED_IS_IN(player, false); Vector3 vehPos = GET_ENTITY_COORDS(veh, false); - float zOffset = 0.35; + float zOffset = 0.35f; Vector3 leftWeaponStart = GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(veh, -1.5, 0.5, zOffset); Vector3 leftWeaponEnd = GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(veh, -1.5, 100, zOffset); SHOOT_SINGLE_BULLET_BETWEEN_COORDS(leftWeaponStart.x, leftWeaponStart.y, leftWeaponStart.z, diff --git a/ChaosMod/Main.h b/ChaosMod/Main.h index 1ac015565..236d21174 100644 --- a/ChaosMod/Main.h +++ b/ChaosMod/Main.h @@ -5,7 +5,7 @@ using WORD = unsigned short; using BYTE = unsigned char; using BOOL = int; // wtf? -class IDXGISwapChain; +struct IDXGISwapChain; namespace Main { diff --git a/ChaosMod/Memory/Hooks/AudioPitchHook.cpp b/ChaosMod/Memory/Hooks/AudioPitchHook.cpp index 20bcc6cbe..18341b1d9 100644 --- a/ChaosMod/Memory/Hooks/AudioPitchHook.cpp +++ b/ChaosMod/Memory/Hooks/AudioPitchHook.cpp @@ -7,8 +7,8 @@ static bool ms_EnabledHook = false; static float ms_TargetPitch = 0; -__int64 (*_OG_rage__audRequestedSettings__SetPitch)(__int64, int); -__int64 _HK_rage__audRequestedSettings__SetPitch(__int64 _this, int pitch) +void *(*_OG_rage__audRequestedSettings__SetPitch)(void *, float); +void *_HK_rage__audRequestedSettings__SetPitch(void *_this, float pitch) { return _OG_rage__audRequestedSettings__SetPitch(_this, ms_EnabledHook ? ms_TargetPitch : pitch); } @@ -30,13 +30,13 @@ static RegisterHook registerHook(OnHook, nullptr, "rage::audRequestedSettings::S namespace Hooks { - void SetAudioPitch(int pitch) + void SetAudioPitch(float pitch) { ms_EnabledHook = true; ms_TargetPitch = pitch; } - int GetTargetAudioPitch() + float GetTargetAudioPitch() { return !ms_EnabledHook ? 0.f : ms_TargetPitch; } diff --git a/ChaosMod/Memory/Hooks/AudioPitchHook.h b/ChaosMod/Memory/Hooks/AudioPitchHook.h index 92915bcc1..792fa37ad 100644 --- a/ChaosMod/Memory/Hooks/AudioPitchHook.h +++ b/ChaosMod/Memory/Hooks/AudioPitchHook.h @@ -2,7 +2,7 @@ namespace Hooks { - void SetAudioPitch(int pitch); - int GetTargetAudioPitch(); + void SetAudioPitch(float pitch); + float GetTargetAudioPitch(); void ResetAudioPitch(); } \ No newline at end of file diff --git a/ChaosMod/Memory/Hooks/Hook.h b/ChaosMod/Memory/Hooks/Hook.h index 2c80a356d..0012627e2 100644 --- a/ChaosMod/Memory/Hooks/Hook.h +++ b/ChaosMod/Memory/Hooks/Hook.h @@ -14,14 +14,15 @@ namespace Memory { private: std::string m_Name; + std::function m_HookFunc; + std::function m_CleanupFunc; RegisteredHook *m_Next = nullptr; - bool (*m_HookFunc)(); - void (*m_CleanupFunc)(); - bool m_IsLateHook = false; + bool m_IsLateHook = false; public: - RegisteredHook(bool (*hookFunc)(), void (*cleanupFunc)(), const std::string &name, bool isLateHook) - : m_HookFunc(hookFunc), m_CleanupFunc(cleanupFunc), m_Name(name), m_IsLateHook(isLateHook) + RegisteredHook(std::function hookFunc, std::function cleanupFunc, const std::string &name, + bool isLateHook) + : m_Name(name), m_HookFunc(hookFunc), m_CleanupFunc(cleanupFunc), m_IsLateHook(isLateHook) { if (g_pRegisteredHooks) m_Next = g_pRegisteredHooks; diff --git a/ChaosMod/Memory/Hooks/MiscHooks.cpp b/ChaosMod/Memory/Hooks/MiscHooks.cpp index ef75a8b77..1f345c345 100644 --- a/ChaosMod/Memory/Hooks/MiscHooks.cpp +++ b/ChaosMod/Memory/Hooks/MiscHooks.cpp @@ -4,8 +4,8 @@ // Work around crash related to SET_PED_SHOOTS_AT_COORD // Thanks to Rainbomizer! -void (*OG_crSkeleton_GetGlobalMtx)(__int64, unsigned int, void *); -void HK_crSkeleton_GetGlobalMtx(__int64 skeleton, unsigned int id, void *matrix) +void (*OG_crSkeleton_GetGlobalMtx)(__int64, int, void *); +void HK_crSkeleton_GetGlobalMtx(__int64 skeleton, int id, void *matrix) { if (!skeleton) return; diff --git a/ChaosMod/Memory/PedModels.h b/ChaosMod/Memory/PedModels.h index d2d48c6ee..95dc86f0d 100644 --- a/ChaosMod/Memory/PedModels.h +++ b/ChaosMod/Memory/PedModels.h @@ -59,7 +59,7 @@ namespace Memory DWORD64 v5 = *reinterpret_cast(model + 4); LONG v6; // IDA copy paste ftw - if (static_cast(v5) < dword_7FF69DB37ED8 + if (static_cast(v5) < dword_7FF69DB37ED8 && (v6 = *reinterpret_cast(qword_7FF69DB37F00 + 4 * (v5 >> 5)), _bittest(&v6, v5 & 0x1F))) { diff --git a/ChaosMod/Memory/Script.h b/ChaosMod/Memory/Script.h index ae85106e7..53188eadb 100644 --- a/ChaosMod/Memory/Script.h +++ b/ChaosMod/Memory/Script.h @@ -53,8 +53,8 @@ namespace Memory inline Handle FindScriptPattern(const std::string &pattern, rage::scrProgram *program) { - DWORD codeBlocksSize = (program->m_CodeSize + 0x3FFF) >> 14; - for (int i = 0; i < codeBlocksSize; i++) + std::uint32_t codeBlocksSize = (program->m_CodeSize + 0x3FFF) >> 14; + for (std::uint32_t i = 0; i < codeBlocksSize; i++) { auto handle = Memory::FindPattern( pattern, diff --git a/ChaosMod/Memory/Vehicle.h b/ChaosMod/Memory/Vehicle.h index 7af623898..0eeb5773c 100644 --- a/ChaosMod/Memory/Vehicle.h +++ b/ChaosMod/Memory/Vehicle.h @@ -81,7 +81,7 @@ namespace Memory return 0; } - return handle.At(8).Value(); + return handle.At(8).Value(); }(); if (!outOfControlStateOffset) @@ -90,17 +90,17 @@ namespace Memory auto result = GetScriptHandleBaseAddress(vehicle); if (result) { - *reinterpret_cast(result + outOfControlStateOffset) &= 0xFEu; - *reinterpret_cast(result + outOfControlStateOffset) |= state; + *reinterpret_cast(result + outOfControlStateOffset) &= 0xFEu; + *reinterpret_cast(result + outOfControlStateOffset) |= state; } } inline void OverrideVehicleHeadlightColor(int idx, bool overrideColor, int r, int g, int b) { - static DWORD64 *qword_7FF69E1E8E88 = nullptr; + static std::uint64_t *qword_7FF69E1E8E88 = nullptr; - static const int maxColors = 13; - static DWORD origColors[maxColors] = {}; + static const int maxColors = 13; + static DWORD origColors[maxColors] = {}; if (idx >= maxColors) return; @@ -114,7 +114,7 @@ namespace Memory if (!handle.IsValid()) return; - qword_7FF69E1E8E88 = handle.At(2).Into().Get(); + qword_7FF69E1E8E88 = handle.At(2).Into().Get(); } auto colors = *reinterpret_cast(*qword_7FF69E1E8E88 + 328); @@ -144,7 +144,7 @@ namespace Memory return 0; } - return handle.At(4).Value(); + return handle.At(4).Value(); }(); auto result = GetScriptHandleBaseAddress(vehicle); diff --git a/ChaosMod/Util/MacroConcat.h b/ChaosMod/Util/MacroConcat.h index ef2b93f4e..73d9e5436 100644 --- a/ChaosMod/Util/MacroConcat.h +++ b/ChaosMod/Util/MacroConcat.h @@ -1,4 +1,4 @@ #pragma once -#define _CONCAT(a, b) a##b -#define CONCAT(a, b) _CONCAT(a, b) \ No newline at end of file +#define _CHAOSCONCAT(a, b) a##b +#define CHAOSCONCAT(a, b) _CHAOSCONCAT(a, b) \ No newline at end of file diff --git a/ChaosMod/Util/OptionDefaults.h b/ChaosMod/Util/OptionDefaults.h index 0748e7526..e0e3eed83 100644 --- a/ChaosMod/Util/OptionDefaults.h +++ b/ChaosMod/Util/OptionDefaults.h @@ -10,7 +10,7 @@ #define OPTION_DEFAULT_MAX_RUNNING_PARALLEL_EFFECTS 99 #define OPTION_DEFAULT_DISTANCE_BASED_DISPATCH_ENABLED false -#define OPTION_DEFAULT_EFFECT_SPAWN_DISTANCE 250 +#define OPTION_DEFAULT_EFFECT_SPAWN_DISTANCE 250.f #define OPTION_DEFAULT_DISTANCE_TYPE 0 #define OPTION_DEFAULT_TWITCH_VOTING_ENABLED false diff --git a/ChaosMod/Util/OptionsFile.h b/ChaosMod/Util/OptionsFile.h index d7574d71d..76812b71f 100644 --- a/ChaosMod/Util/OptionsFile.h +++ b/ChaosMod/Util/OptionsFile.h @@ -19,7 +19,7 @@ class OptionsFile public: OptionsFile(const char *fileName, std::vector compatFileNames = {}) - : m_FileName(fileName), m_CompatFileNames(compatFileNames), m_FoundFileName("") + : m_FileName(fileName), m_FoundFileName(""), m_CompatFileNames(compatFileNames) { Reset(); } @@ -115,18 +115,14 @@ class OptionsFile return defaultValue; } - inline void SetValueString(const std::string& key, const std::string& value) + inline void SetValueString(const std::string &key, const std::string &value) { if (m_Options.contains(key)) - { m_Options[key] = value; - } else - { m_Options.emplace(key, value); - } } - template inline void SetValue(const std::string& key, T value) + template inline void SetValue(const std::string &key, T value) { SetValueString(key, std::to_string(value)); } diff --git a/ChaosMod/Util/ScriptText.h b/ChaosMod/Util/ScriptText.h index 50ec8fb00..027a1ae81 100644 --- a/ChaosMod/Util/ScriptText.h +++ b/ChaosMod/Util/ScriptText.h @@ -63,7 +63,7 @@ inline void DrawScreenText(const std::string &text, const ScreenTextVector &text { float width = GetScreenTextWidth(text, scale); float height = scale / 10; - float additionalWidth = 0.02; + float additionalWidth = 0.02f; DRAW_RECT(textPos.X - (width * 0.5f), textPos.Y + 0.015, width + additionalWidth, height, 0, 0, 0, 127, true); } } \ No newline at end of file diff --git a/ChaosMod/Util/TryParse.h b/ChaosMod/Util/TryParse.h index 450403d64..81993f0a8 100644 --- a/ChaosMod/Util/TryParse.h +++ b/ChaosMod/Util/TryParse.h @@ -13,7 +13,7 @@ namespace Util long lParseResult; if constexpr (std::is_same()) - lParseResult = std::strtof(text.data(), &cEnd); + lParseResult = std::lround(std::strtof(text.data(), &cEnd)); else lParseResult = std::strtol(text.data(), &cEnd, radix); diff --git a/ChaosMod/Util/Vehicle.h b/ChaosMod/Util/Vehicle.h index 51be410fc..63101bc64 100644 --- a/ChaosMod/Util/Vehicle.h +++ b/ChaosMod/Util/Vehicle.h @@ -39,7 +39,7 @@ inline Vehicle CreateTempVehicleOnPlayerPos(Hash model, float heading) return veh; } -inline void SetSurroundingPedsInVehicles(Hash vehicleHash, int maxDistance) +inline void SetSurroundingPedsInVehicles(Hash vehicleHash, float maxDistance) { Ped playerPed = PLAYER_PED_ID(); Vector3 playerPos = GET_ENTITY_COORDS(playerPed, true); @@ -97,8 +97,8 @@ inline Vehicle CreateRandomVehicleWithPeds(Vehicle oldHandle, const std::vector< do { newVehModel = vehicleModels[g_RandomNoDeterm.GetRandomInt(0, vehicleModels.size() - 1)]; - } while (GET_VEHICLE_MODEL_NUMBER_OF_SEATS(newVehModel) < seatPeds.size() || IS_THIS_MODEL_A_TRAIN(newVehModel) - || GET_VEHICLE_MODEL_ACCELERATION(newVehModel) <= 0); + } while (static_cast(GET_VEHICLE_MODEL_NUMBER_OF_SEATS(newVehModel)) < seatPeds.size() + || IS_THIS_MODEL_A_TRAIN(newVehModel) || GET_VEHICLE_MODEL_ACCELERATION(newVehModel) <= 0); if (!newVehModel) return oldHandle; @@ -108,7 +108,7 @@ inline Vehicle CreateRandomVehicleWithPeds(Vehicle oldHandle, const std::vector< Vehicle newVehicle; if (addToPool) { - for (int i = 0; i < seatPeds.size(); i++) + for (size_t i = 0; i < seatPeds.size(); i++) { Ped seatPed = seatPeds[i].Ped; SET_ENTITY_COORDS(seatPed, coords.x, coords.y, coords.z + 5.f, 0, 0, 0, 0); @@ -127,7 +127,7 @@ inline Vehicle CreateRandomVehicleWithPeds(Vehicle oldHandle, const std::vector< SET_ENTITY_AS_MISSION_ENTITY(newVehicle, false, true); } - for (int i = 0; i < seatPeds.size(); i++) + for (size_t i = 0; i < seatPeds.size(); i++) { SeatPed seatPed = seatPeds.at(i); int seatIndex = seatPed.SeatIndex;