diff --git a/.editorconfig b/.editorconfig index 91105e5cf..a93fe9ce4 100644 --- a/.editorconfig +++ b/.editorconfig @@ -98,4 +98,6 @@ csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion csharp_style_pattern_matching_over_as_with_null_check = true:suggestion csharp_style_inlined_variable_declaration = true:none csharp_style_throw_expression = true:none -csharp_style_conditional_delegate_call = true:suggestion \ No newline at end of file +csharp_style_conditional_delegate_call = true:suggestion + +csharp_prefer_braces = false \ No newline at end of file diff --git a/ChaosMod/.clang-format b/ChaosMod/.clang-format index 014413051..b1698bf55 100644 --- a/ChaosMod/.clang-format +++ b/ChaosMod/.clang-format @@ -70,6 +70,7 @@ PenaltyReturnTypeOnItsOwnLine: 60 PenaltyIndentedWhitespace: 0 PointerAlignment: Right ReflowComments: true +RemoveBracesLLVM: true SortIncludes: true SortUsingDeclarations: true SpaceAfterCStyleCast: false diff --git a/ChaosMod/Components/DebugMenu.cpp b/ChaosMod/Components/DebugMenu.cpp index bae6581c9..3b532c233 100644 --- a/ChaosMod/Components/DebugMenu.cpp +++ b/ChaosMod/Components/DebugMenu.cpp @@ -12,9 +12,7 @@ DebugMenu::DebugMenu() : Component() { m_IsEnabled = g_OptionsManager.GetConfigValue({ "EnableDebugMenu" }, OPTION_DEFAULT_DEBUG_MENU); if (!m_IsEnabled) - { return; - } for (const auto &pair : g_EnabledEffects) { @@ -38,27 +36,19 @@ DebugMenu::DebugMenu() : Component() [](const DebugEffect &a, const DebugEffect &b) { for (int idx = 0;; idx++) - { if (idx >= a.EffectName.size() || std::toupper(a.EffectName[idx]) < std::toupper(b.EffectName[idx])) - { return true; - } else if (idx >= b.EffectName.size() || std::toupper(b.EffectName[idx]) < std::toupper(a.EffectName[idx])) - { return false; - } - } }); } void DebugMenu::OnRun() { if (!m_IsEnabled || !m_Visible) - { return; - } // Arrow Up DISABLE_CONTROL_ACTION(1, 27, true); @@ -88,9 +78,7 @@ void DebugMenu::OnRun() m_DispatchEffect = false; if (ComponentExists()) - { GetComponent()->DispatchEffect(m_Effects[m_SelectedIdx].Identifier); - } } float y = .1f; @@ -101,13 +89,9 @@ void DebugMenu::OnRun() short overflow = MAX_VIS_ITEMS / 2 - (m_Effects.size() - 1 - m_SelectedIdx); if (i < 0 || i < m_SelectedIdx - remainingDrawItems / 2 - (overflow > 0 ? overflow : 0)) - { continue; - } else if (i >= m_Effects.size()) - { break; - } BEGIN_TEXT_COMMAND_DISPLAY_TEXT("STRING"); ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME(m_Effects[i].EffectName.c_str()); @@ -145,18 +129,14 @@ void DebugMenu::OnKeyInput(DWORD key, bool repeated, bool isUpNow, bool isCtrlPr bool isAltPressed) { if (!m_IsEnabled || !m_Visible) - { return; - } if (repeated) { auto curTime = GetTickCount64(); if (key == VK_RETURN || m_RepeatTime > curTime - 250) - { return; - } } else { @@ -167,16 +147,12 @@ void DebugMenu::OnKeyInput(DWORD key, bool repeated, bool isUpNow, bool isCtrlPr { case VK_UP: if (--m_SelectedIdx < 0) - { m_SelectedIdx = m_Effects.size() - 1; - } break; case VK_DOWN: if (++m_SelectedIdx >= m_Effects.size()) - { m_SelectedIdx = 0; - } break; case VK_RIGHT: @@ -187,9 +163,7 @@ void DebugMenu::OnKeyInput(DWORD key, bool repeated, bool isUpNow, bool isCtrlPr while (!found) { if (searchChar++ == SCHAR_MAX) - { searchChar = SCHAR_MIN; - } for (int idx = 0; idx < m_Effects.size(); idx++) { @@ -214,9 +188,7 @@ void DebugMenu::OnKeyInput(DWORD key, bool repeated, bool isUpNow, bool isCtrlPr while (!found) { if (searchChar-- == SCHAR_MIN) - { searchChar = SCHAR_MAX; - } for (int idx = 0; idx < m_Effects.size(); idx++) { @@ -235,9 +207,7 @@ void DebugMenu::OnKeyInput(DWORD key, bool repeated, bool isUpNow, bool isCtrlPr } case VK_RETURN: if (!m_Effects[m_SelectedIdx].Identifier.GetEffectId().empty()) - { m_DispatchEffect = true; - } break; case VK_BACK: diff --git a/ChaosMod/Components/DebugSocket.cpp b/ChaosMod/Components/DebugSocket.cpp index ac2804603..9c74ed488 100644 --- a/ChaosMod/Components/DebugSocket.cpp +++ b/ChaosMod/Components/DebugSocket.cpp @@ -32,9 +32,7 @@ static void OnFetchEffects(DebugSocket *debugSocket, std::shared_ptr()) - { return; - } if (!payloadJson.contains("effect_id") || !payloadJson["effect_id"].is_string()) - { return; - } auto targetEffectId = payloadJson["effect_id"].get(); if (targetEffectId.empty()) - { return; - } QueueDelegate(debugSocket, [targetEffectId]() { auto result = g_EnabledEffects.find(targetEffectId); if (result != g_EnabledEffects.end()) - { GetComponent()->DispatchEffect(result->first); - } }); } @@ -80,28 +70,20 @@ static void OnExecScript(DebugSocket *debugSocket, std::shared_ptr()) - { return; - } if (!payloadJson.contains("script_raw") || !payloadJson["script_raw"].is_string()) - { return; - } auto script = payloadJson["script_raw"].get(); if (script.empty()) - { return; - } // Generate random hex value for script name std::string scriptName; scriptName.resize(8); for (int i = 0; i < 8; i++) - { sprintf(scriptName.data() + i, "%x", g_RandomNoDeterm.GetRandomInt(0, 16)); - } json json; json["command"] = "result_exec_script"; @@ -112,9 +94,7 @@ static void OnExecScript(DebugSocket *debugSocket, std::shared_ptr()) - { GetComponent()->RegisterScriptRawTemporary(scriptName, payloadJson["script_raw"]); - } }); } @@ -122,9 +102,7 @@ static void OnSetProfileState(DebugSocket *debugSocket, std::shared_ptrm_EffectTraceStats) { if (traceStats.TotalExecTime == 0) - { continue; - } json profileJson; profileJson["total_exec_time"] = traceStats.TotalExecTime; profileJson["max_exec_time"] = traceStats.MaxExecTime; for (const auto &execTrace : traceStats.ExecTraces) - { profileJson["exec_times"].push_back(execTrace.ExecTime); - } resultJson["profiles"][effectId] = profileJson; } @@ -187,9 +161,7 @@ static void OnMessage(DebugSocket *debugSocket, std::shared_ptrtype != ix::WebSocketMessageType::Message) - { return; - } auto payload = msg->str; @@ -205,9 +177,7 @@ static void OnMessage(DebugSocket *debugSocket, std::shared_ptr(); #define SET_HANDLER(cmd, handler) \ @@ -242,15 +212,11 @@ static void EventOnPreRunEffect(DebugSocket *debugSocket, const EffectIdentifier static void EventOnPostRunEffect(DebugSocket *debugSocket, const EffectIdentifier &identifier) { if (!debugSocket->m_IsProfiling) - { return; - } const auto &effectId = identifier.GetEffectId(); if (!debugSocket->m_EffectTraceStats.contains(effectId)) - { return; - } auto &traceStats = debugSocket->m_EffectTraceStats.at(effectId); @@ -272,9 +238,7 @@ static void EventOnPostRunEffect(DebugSocket *debugSocket, const EffectIdentifie } if (execTime > traceStats.MaxExecTime) - { traceStats.MaxExecTime = execTime; - } } DebugSocket::DebugSocket() @@ -316,9 +280,7 @@ void DebugSocket::Close() void DebugSocket::ScriptLog(std::string_view scriptName, std::string_view text) { if (!m_Server) - { return; - } json json; json["command"] = "script_log"; @@ -326,9 +288,7 @@ void DebugSocket::ScriptLog(std::string_view scriptName, std::string_view text) json["text"] = text; for (auto client : m_Server->getClients()) - { client->send(json.dump()); - } } void DebugSocket::OnModPauseCleanup() diff --git a/ChaosMod/Components/EffectDispatchTimer.cpp b/ChaosMod/Components/EffectDispatchTimer.cpp index f4b77ab08..0216d80a5 100644 --- a/ChaosMod/Components/EffectDispatchTimer.cpp +++ b/ChaosMod/Components/EffectDispatchTimer.cpp @@ -24,9 +24,7 @@ EffectDispatchTimer::EffectDispatchTimer(const std::array &timerColor) void EffectDispatchTimer::UpdateTimer(int deltaTime) { if (!m_EnableTimer || (ComponentExists() && GetComponent()->DisableChaos)) - { return; - } m_TimerPercentage += deltaTime * (ComponentExists() ? GetComponent()->TimerSpeedModifier : 1.f) @@ -37,12 +35,8 @@ void EffectDispatchTimer::UpdateTimer(int deltaTime) GetComponent()->DispatchRandomEffect(); if (ComponentExists()) - { for (std::uint8_t i = 0; i < GetComponent()->AdditionalEffectsToDispatch; i++) - { GetComponent()->DispatchRandomEffect(); - } - } m_TimerPercentage = 0.f; } @@ -86,12 +80,8 @@ void EffectDispatchTimer::UpdateTravelledDistance() GetComponent()->DispatchRandomEffect(); if (ComponentExists()) - { for (std::uint8_t i = 0; i < GetComponent()->AdditionalEffectsToDispatch; i++) - { GetComponent()->DispatchRandomEffect(); - } - } } m_DistanceChaosState.SavedPosition = position; @@ -113,12 +103,8 @@ void EffectDispatchTimer::UpdateTravelledDistance() GetComponent()->DispatchRandomEffect(); if (ComponentExists()) - { for (std::uint8_t i = 0; i < GetComponent()->AdditionalEffectsToDispatch; i++) - { GetComponent()->DispatchRandomEffect(); - } - } m_TimerPercentage = 0; } @@ -204,20 +190,14 @@ void EffectDispatchTimer::OnRun() // the game was paused if (deltaTime > 1000) - { deltaTime = 0; - } if (!m_PauseTimer) { if (m_DistanceChaosState.EnableDistanceBasedEffectDispatch) - { UpdateTravelledDistance(); - } else - { UpdateTimer(deltaTime); - } } m_Timer = currentUpdateTime; diff --git a/ChaosMod/Components/EffectDispatcher.cpp b/ChaosMod/Components/EffectDispatcher.cpp index 52f9a2a74..dead9aa48 100644 --- a/ChaosMod/Components/EffectDispatcher.cpp +++ b/ChaosMod/Components/EffectDispatcher.cpp @@ -21,25 +21,17 @@ static void _DispatchEffect(EffectDispatcher *effectDispatcher, const EffectDisp auto &effectData = g_EnabledEffects.at(entry.Identifier); if (effectData.TimedType == EffectTimedType::Permanent) - { return; - } if (!effectDispatcher->OnPreDispatchEffect.Fire(entry.Identifier)) - { return; - } LOG("Dispatching effect \"" << effectData.Name << "\""); // Increase weight for all effects first for (auto &[effectId, effectData] : g_EnabledEffects) - { if (!effectData.IsMeta()) - { effectData.Weight += effectData.WeightMult; - } - } // Reset weight of this effect (or every effect in group) to reduce chance of same effect (group) happening multiple // times in a row @@ -50,12 +42,8 @@ static void _DispatchEffect(EffectDispatcher *effectDispatcher, const EffectDisp else { for (auto &[effectId, effectData] : g_EnabledEffects) - { if (effectData.GroupType == effectData.GroupType) - { effectData.Weight = effectData.WeightMult; - } - } } auto playEffectDispatchSound = [&](EffectDispatcher::ActiveEffect &activeEffect) @@ -66,9 +54,7 @@ static void _DispatchEffect(EffectDispatcher *effectDispatcher, const EffectDisp // Play global sound (if one exists) // HACK: Force no global sound for "Fake Crash" if (entry.Identifier.GetEffectId() != "misc_fakecrash") - { GetComponent()->PlaySoundFile("global_effectdispatch"); - } // Play a sound if corresponding .mp3 file exists activeEffect.SoundId = GetComponent()->PlaySoundFile(effectData.Id); @@ -104,9 +90,7 @@ static void _DispatchEffect(EffectDispatcher *effectDispatcher, const EffectDisp bool isIncompatible = false; if (effectData.IncompatibleIds.contains(activeEffectData.Id)) - { isIncompatible = true; - } // Check if current effect is either the same effect category or marked as incompatible in active effect if (!isIncompatible) @@ -138,9 +122,7 @@ static void _DispatchEffect(EffectDispatcher *effectDispatcher, const EffectDisp effectName << (effectData.HasCustomName() ? effectData.CustomName : effectData.Name); if (!entry.Suffix.empty()) - { effectName << " " << entry.Suffix; - } int effectDuration; switch (effectData.TimedType) @@ -195,9 +177,7 @@ static void _OnRunEffects(LPVOID data) // the game was paused if (deltaTime > 1000) - { deltaTime = 0; - } while (!effectDispatcher->EffectDispatchQueue.empty()) { @@ -208,9 +188,7 @@ static void _OnRunEffects(LPVOID data) effectDispatcher->UpdateEffects(deltaTime); if (!ComponentExists() || GetComponent()->IsTimerEnabled()) - { effectDispatcher->UpdateMetaEffects(deltaTime); - } SwitchToFiber(g_MainThread); } @@ -252,9 +230,7 @@ EffectDispatcher::EffectDispatcher(const std::array &textColor, const s } if (g_EffectDispatcherThread) - { DeleteFiber(g_EffectDispatcherThread); - } g_EffectDispatcherThread = CreateFiber(0, _OnRunEffects, this); } @@ -266,9 +242,7 @@ void EffectDispatcher::OnModPauseCleanup() void EffectDispatcher::OnRun() { if (g_EffectDispatcherThread) - { SwitchToFiber(g_EffectDispatcherThread); - } DrawEffectTexts(); } @@ -290,17 +264,13 @@ void EffectDispatcher::UpdateEffects(int deltaTime) POP_TIMECYCLE_MODIFIER(); if (m_ClearEffectsState == ClearEffectsState::AllRestartPermanent) - { RegisterPermanentEffects(); - } m_ClearEffectsState = ClearEffectsState::None; } for (auto threadId : m_PermanentEffects) - { EffectThreads::RunThread(threadId); - } float adjustedDeltaTime = (float)deltaTime / 1000; @@ -333,15 +303,11 @@ void EffectDispatcher::UpdateEffects(int deltaTime) OnPostRunEffect.Fire(activeEffect.Identifier); if (!activeEffect.IsMeta) - { activeEffects++; - } } if (activeEffect.HideEffectName && EffectThreads::HasThreadOnStartExecuted(activeEffect.ThreadId)) - { activeEffect.HideEffectName = false; - } if (ComponentExists() && activeEffect.SoundId && !activeEffect.HasSetSoundOptions) { @@ -349,9 +315,7 @@ void EffectDispatcher::UpdateEffects(int deltaTime) auto effectSoundPlayOptions = EffectThreads::GetThreadEffectSoundPlayOptions(activeEffect.ThreadId); if (effectSoundPlayOptions) - { GetComponent()->SetSoundOptions(activeEffect.SoundId, *effectSoundPlayOptions); - } } if (activeEffect.MaxTime > 0.f) @@ -397,9 +361,7 @@ void EffectDispatcher::UpdateEffects(int deltaTime) void EffectDispatcher::UpdateMetaEffects(int deltaTime) { if (!SharedState.MetaEffectsEnabled) - { return; - } SharedState.MetaEffectTimerPercentage += (float)deltaTime / SharedState.MetaEffectSpawnTime / 1000; @@ -435,9 +397,7 @@ void EffectDispatcher::UpdateMetaEffects(int deltaTime) effectData->Weight += effectData->WeightMult; if (!targetEffectIdentifier && chosen <= totalWeight) - { targetEffectIdentifier = &effectIdentifier; - } } if (targetEffectIdentifier) @@ -458,9 +418,7 @@ void EffectDispatcher::UpdateMetaEffects(int deltaTime) void EffectDispatcher::DrawEffectTexts() { if (m_DisableDrawEffectTexts) - { return; - } float y = GetEffectTopSpace(); float effectSpacing = EFFECT_TEXT_INNER_SPACING_MAX; @@ -475,9 +433,7 @@ void EffectDispatcher::DrawEffectTexts() for (const ActiveEffect &effect : SharedState.ActiveEffects) { if (effect.IsStopping) - { continue; - } const bool hasFake = !effect.FakeName.empty(); @@ -496,9 +452,7 @@ void EffectDispatcher::DrawEffectTexts() auto effectName = effect.Name; if (effect.HideEffectName && hasFake) - { effectName = effect.FakeName; - } if (ComponentExists() && GetComponent()->FlipChaosUI) { @@ -540,24 +494,16 @@ void EffectDispatcher::DispatchEffect(const EffectIdentifier &effectIdentifier, void EffectDispatcher::DispatchRandomEffect(DispatchEffectFlags dispatchEffectFlags, const std::string &suffix) { if (!m_EnableNormalEffectDispatch) - { return; - } std::unordered_map choosableEffects; for (const auto &[effectIdentifier, effectData] : g_EnabledEffects) - { if (!effectData.IsMeta() && !effectData.IsUtility() && !effectData.IsHidden()) - { choosableEffects.emplace(effectIdentifier, effectData); - } - } float totalWeight = 0.f; for (const auto &[effectIdentifier, effectData] : choosableEffects) - { totalWeight += effectData.GetEffectWeight(); - } float chosen = g_Random.GetRandomFloat(0.f, totalWeight); @@ -577,9 +523,7 @@ void EffectDispatcher::DispatchRandomEffect(DispatchEffectFlags dispatchEffectFl } if (targetEffectIdentifier) - { DispatchEffect(*targetEffectIdentifier, dispatchEffectFlags, suffix); - } } void EffectDispatcher::ClearEffect(const EffectIdentifier &effectId) @@ -587,9 +531,7 @@ void EffectDispatcher::ClearEffect(const EffectIdentifier &effectId) auto result = std::find_if(SharedState.ActiveEffects.begin(), SharedState.ActiveEffects.end(), [effectId](auto &activeEffect) { return activeEffect.Identifier == effectId; }); if (result == SharedState.ActiveEffects.end()) - { return; - } EffectThreads::StopThread(result->ThreadId); result->IsStopping = true; @@ -609,9 +551,7 @@ void EffectDispatcher::ClearActiveEffects() auto &effect = *it; if (effect.IsMeta || effect.Timer <= 0.f) - { continue; - } EffectThreads::StopThread(effect.ThreadId); effect.IsStopping = true; @@ -625,9 +565,7 @@ void EffectDispatcher::ClearMostRecentEffect() auto &effect = *it; if (effect.IsMeta || effect.Timer <= 0.f) - { continue; - } EffectThreads::StopThread(effect.ThreadId); effect.IsStopping = true; @@ -682,9 +620,7 @@ void EffectDispatcher::RegisterPermanentEffects() }; if (g_OptionsManager.GetConfigValue({ "Australia" }, false)) - { registerEffect({ "player_flip_camera" }); - } for (const auto &[effectIdentifier, effectData] : g_EnabledEffects) { @@ -700,12 +636,8 @@ void EffectDispatcher::RegisterPermanentEffects() void EffectDispatcher::OverrideEffectName(std::string_view effectId, const std::string &overrideName) { for (auto &effect : SharedState.ActiveEffects) - { if (effect.Identifier.GetEffectId() == effectId) - { effect.FakeName = overrideName; - } - } } // (kolyaventuri): Forces the name of the provided effect to change, using the defined name of another effect @@ -726,9 +658,7 @@ void EffectDispatcher::OverrideEffectNameId(std::string_view effectId, std::stri { auto result = g_EffectsMap.find(fakeEffectId); if (result != g_EffectsMap.end()) - { effect.FakeName = result->second.Name; - } } } } diff --git a/ChaosMod/Components/EffectShortcuts.cpp b/ChaosMod/Components/EffectShortcuts.cpp index be55089b2..30ad15871 100644 --- a/ChaosMod/Components/EffectShortcuts.cpp +++ b/ChaosMod/Components/EffectShortcuts.cpp @@ -7,12 +7,8 @@ EffectShortcuts::EffectShortcuts() : Component() { for (const auto &[effectId, effectData] : g_EnabledEffects) - { if (effectData.ShortcutKeycode > 0 && !effectData.IsHidden()) - { m_AvailableShortcuts[effectData.ShortcutKeycode].push_back(effectId); - } - } } void EffectShortcuts::OnRun() @@ -25,9 +21,7 @@ void EffectShortcuts::OnRun() auto &identifier = m_EffectQueue.front(); if (ComponentExists()) - { GetComponent()->DispatchEffect(identifier); - } m_EffectQueue.pop(); } @@ -38,9 +32,7 @@ void EffectShortcuts::OnKeyInput(DWORD key, bool repeated, bool isUpNow, bool is bool isAltPressed) { if (repeated) - { return; - } key += (isCtrlPressed << 10) + (isShiftPressed << 9) + (isAltPressed << 8); @@ -48,8 +40,6 @@ void EffectShortcuts::OnKeyInput(DWORD key, bool repeated, bool isUpNow, bool is { std::lock_guard lock(m_EffectQueueMtx); for (auto &effectId : m_AvailableShortcuts.at(key)) - { m_EffectQueue.push(effectId); - } } } diff --git a/ChaosMod/Components/EffectSound/EffectSound3D.cpp b/ChaosMod/Components/EffectSound/EffectSound3D.cpp index 6b89b1e89..bd95d09ba 100644 --- a/ChaosMod/Components/EffectSound/EffectSound3D.cpp +++ b/ChaosMod/Components/EffectSound/EffectSound3D.cpp @@ -32,9 +32,7 @@ void EffectSound3D::OnModPauseCleanup() void EffectSound3D::OnRun() { if (m_Sounds.empty()) - { return; - } auto playerPed = PLAYER_PED_ID(); diff --git a/ChaosMod/Components/EffectSound/EffectSoundManager.cpp b/ChaosMod/Components/EffectSound/EffectSoundManager.cpp index 06508a79c..584fbcb45 100644 --- a/ChaosMod/Components/EffectSound/EffectSoundManager.cpp +++ b/ChaosMod/Components/EffectSound/EffectSoundManager.cpp @@ -11,18 +11,14 @@ void EffectSoundManager::HandleDirectory(const std::string &dir, const std::stri { auto soundRootDirName = dir + "\\sounds\\"; if (!DoesFileExist(soundRootDirName)) - { return; - } auto soundDirPath = soundRootDirName + soundName; auto soundFilePath = soundDirPath + ".mp3"; std::vector blacklistedFiles; if (dir.starts_with(CHAOS_SOUNDFILES_WORKSHOP_DIR) && ComponentExists()) - { blacklistedFiles = GetComponent()->GetSubmissionBlacklistedFiles(dir); - } auto &soundFiles = m_EffectSoundFileNamesCache[soundName]; @@ -51,12 +47,8 @@ DWORD64 EffectSoundManager::PlaySoundFile(const std::string &soundFileName) if (DoesFileExist(CHAOS_SOUNDFILES_WORKSHOP_DIR)) { for (const auto &entry : std::filesystem::directory_iterator(CHAOS_SOUNDFILES_WORKSHOP_DIR)) - { if (entry.is_directory() && DoesFileExist(entry.path().string() + "\\sounds")) - { HandleDirectory(entry.path().string(), soundFileName); - } - } } } diff --git a/ChaosMod/Components/Failsafe.cpp b/ChaosMod/Components/Failsafe.cpp index 1ab39db30..dc3ac75a3 100644 --- a/ChaosMod/Components/Failsafe.cpp +++ b/ChaosMod/Components/Failsafe.cpp @@ -36,13 +36,9 @@ Failsafe::Failsafe() : Component() Handle handle; if (getGameVersion() < VER_1_0_2802_0) - { handle = Memory::FindScriptPattern("2D ? ? 00 00 25 0D 60 ? ? ? 6D 5E", program); - } else - { handle = Memory::FindScriptPattern("2D ? ? 00 00 25 0D 63 ? ? ? 70 61", program); - } if (!handle.IsValid()) { @@ -64,14 +60,10 @@ Failsafe::Failsafe() : Component() void Failsafe::OnRun() { if (!m_Enabled || !ms_StateGlobalIdx || !ComponentExists()) - { return; - } if (!m_StateGlobal) - { m_StateGlobal = reinterpret_cast(Memory::GetGlobalPtr(ms_StateGlobalIdx)); - } if (!*m_StateGlobal && m_LastState) { @@ -79,9 +71,7 @@ void Failsafe::OnRun() int curTimestamp = GET_GAME_TIMER(); if (m_FailTimestamp < curTimestamp - 10000) - { m_FailCounts = 0; - } switch (++m_FailCounts) { diff --git a/ChaosMod/Components/HelpTextQueue.cpp b/ChaosMod/Components/HelpTextQueue.cpp index fa50c410b..b7c27c040 100644 --- a/ChaosMod/Components/HelpTextQueue.cpp +++ b/ChaosMod/Components/HelpTextQueue.cpp @@ -7,9 +7,7 @@ void HelpTextQueue::DisplayLabel(std::string_view label, std::uint8_t durationSecs) { if (durationSecs == 0) - { return; - } m_HelpTextQueue.emplace(label, durationSecs / 1000.f); } @@ -22,9 +20,7 @@ void HelpTextQueue::OnModPauseCleanup() void HelpTextQueue::OnRun() { if (m_HelpTextQueue.empty() || IS_HELP_MESSAGE_BEING_DISPLAYED()) - { return; - } auto &helpText = m_HelpTextQueue.front(); @@ -32,7 +28,5 @@ void HelpTextQueue::OnRun() END_TEXT_COMMAND_DISPLAY_HELP(0, false, false, 0); if ((helpText.TimerSecs -= GET_FRAME_TIME()) < 0.f) - { m_HelpTextQueue.pop(); - } } \ No newline at end of file diff --git a/ChaosMod/Components/LuaScripts.cpp b/ChaosMod/Components/LuaScripts.cpp index a758ff66c..f015ec675 100644 --- a/ChaosMod/Components/LuaScripts.cpp +++ b/ChaosMod/Components/LuaScripts.cpp @@ -92,9 +92,7 @@ _LUAFUNC void LuaPrint(const std::string &name, const std::string &text) #ifdef WITH_DEBUG_PANEL_SUPPORT if (ComponentExists()) - { GetComponent()->ScriptLog(name, text); - } #endif } @@ -165,9 +163,7 @@ class LuaHolder ~LuaHolder() { if (m_Obj.valid()) - { m_Obj.abandon(); - } } template __forceinline T As() @@ -271,9 +267,7 @@ _LUAFUNC sol::object LuaInvoke(const std::string &scriptName, const sol::this_st { LuaVector3 vector3; if (_TryParseVector3(returned, vector3.X, vector3.Y, vector3.Z)) - { return sol::make_object(lua, vector3); - } } break; default: @@ -336,9 +330,7 @@ LuaScripts::LuaScripts() auto currentThread = std::this_thread::get_id(); int parseScriptFlags = ParseScriptFlag_None; if (currentThread != mainThread) - { parseScriptFlags |= ParseScriptFlag_IsAlienThread; - } std::unordered_map userEffectSettings; if (pathStr.starts_with("chaosmod\\workshop") && ComponentExists()) @@ -372,9 +364,7 @@ LuaScripts::LuaScripts() for (auto &workerThread : workerThreadPool) { if (workerThread) - { continue; - } workerThread = std::make_unique(); workerThread->Thread = std::thread( @@ -385,14 +375,10 @@ LuaScripts::LuaScripts() while (!isDone || !entryQueue.empty()) { if (entryQueue.empty()) - { continue; - } std::unique_lock lock(entryQueueMutex); if (entryQueue.empty()) - { continue; - } auto entry = entryQueue.front(); entryQueue.pop(); @@ -408,17 +394,13 @@ LuaScripts::LuaScripts() } if (!foundNewThread) - { entryQueue.push(entry); - } }; for (auto dir : ms_ScriptDirs) { if (!DoesFileExist(dir)) - { continue; - } if (!strcmp(dir, "chaosmod\\workshop")) { @@ -437,21 +419,15 @@ LuaScripts::LuaScripts() else { for (const auto &entry : GetFiles(dir, ".lua", true)) - { parseScriptThreaded(entry); - } } } isDone = true; for (auto &workerThread : workerThreadPool) - { if (workerThread && workerThread->Thread.joinable()) - { workerThread->Thread.join(); - } - } while (!threadUnsafeEntryQueue.empty()) { @@ -465,29 +441,19 @@ void LuaScripts::OnModPauseCleanup() { // Clean up all registered script effects for (auto it = g_RegisteredEffects.begin(); it != g_RegisteredEffects.end();) - { if (it->IsScript()) - { it = g_RegisteredEffects.erase(it); - } else - { it++; - } - } // Clean up all effect groups registered by scripts for (auto it = g_EffectGroups.begin(); it != g_EffectGroups.end();) { const auto &[groupName, groupData] = *it; if (groupData.WasRegisteredByScript) - { it = g_EffectGroups.erase(it); - } else - { it++; - } } } @@ -541,9 +507,7 @@ LuaScripts::ParseScriptRaw(std::string scriptName, std::string_view script, Pars } if (!ms_NativesDefCache.empty()) - { lua.unsafe_script(ms_NativesDefCache); - } lua["GetTickCount"] = GetTickCount64; lua["GET_HASH_KEY"] = GET_HASH_KEY; @@ -591,9 +555,7 @@ LuaScripts::ParseScriptRaw(std::string scriptName, std::string_view script, Pars [](unsigned char key) { if (ComponentExists()) - { return GetComponent()->IsKeyPressed(key); - } return false; }), @@ -601,9 +563,7 @@ LuaScripts::ParseScriptRaw(std::string scriptName, std::string_view script, Pars [](unsigned char key) { if (ComponentExists()) - { return GetComponent()->IsKeyJustPressed(key); - } return false; }), @@ -707,17 +667,11 @@ LuaScripts::ParseScriptRaw(std::string scriptName, std::string_view script, Pars } if (threadUnsafeFuncCalled) - { return ParseScriptReturnReason::Error_ThreadUnsafe; - } if (flags & ParseScriptFlag_IsAlienThread) - { for (auto exposable : exposables) - { exposable(lua); - } - } static std::mutex effectGroupMutex; const sol::optional &effectGroupInfoOpt = lua["EffectGroupInfo"]; @@ -769,9 +723,7 @@ LuaScripts::ParseScriptRaw(std::string scriptName, std::string_view script, Pars // Backwards compatibility effectInfoOpt = lua["ScriptInfo"].get>(); if (!effectInfoOpt) - { return ParseScriptReturnReason::Error; - } } const auto &effectInfo = *effectInfoOpt; @@ -820,9 +772,7 @@ LuaScripts::ParseScriptRaw(std::string scriptName, std::string_view script, Pars /* Replace existing temporary effect with this one */ if (ComponentExists()) - { GetComponent()->ClearEffect(effectId); - } RemoveScriptEntry(effectId); @@ -855,16 +805,12 @@ LuaScripts::ParseScriptRaw(std::string scriptName, std::string_view script, Pars lua["OverrideEffectName"] = [effectId](const sol::this_state &lua, const std::string &name) { if (ComponentExists()) - { GetComponent()->OverrideEffectName(effectId, name); - } }; lua["OverrideEffectNameById"] = [effectId](const sol::this_state &lua, const std::string &overrideId) { if (ComponentExists()) - { GetComponent()->OverrideEffectNameId(effectId, overrideId); - } }; EffectData effectData; @@ -933,9 +879,7 @@ LuaScripts::ParseScriptRaw(std::string scriptName, std::string_view script, Pars { effectData.CustomTime = settingOverrides["CustomTime"]; if (effectData.CustomTime > 0) - { effectData.TimedType = EffectTimedType::Custom; - } } catch (nlohmann::json::exception) { @@ -957,15 +901,11 @@ LuaScripts::ParseScriptRaw(std::string scriptName, std::string_view script, Pars const sol::optional &isMetaOpt = effectInfo["IsMeta"]; if (isMetaOpt) - { effectData.SetAttribute(EffectAttributes::IsMeta, *isMetaOpt); - } const sol::optional &excludeFromVotingOpt = effectInfo["ExcludeFromVoting"]; if (excludeFromVotingOpt) - { effectData.SetAttribute(EffectAttributes::ExcludedFromVoting, *excludeFromVotingOpt); - } try { effectData.SetAttribute(EffectAttributes::ExcludedFromVoting, settingOverrides["ExcludedFromVoting"]); @@ -976,27 +916,19 @@ LuaScripts::ParseScriptRaw(std::string scriptName, std::string_view script, Pars const sol::optional &isUtilityOpt = effectInfo["IsUtility"]; if (isUtilityOpt) - { effectData.SetAttribute(EffectAttributes::IsUtility, *isUtilityOpt); - } const sol::optional &hideRealNameOnStartOpt = effectInfo["HideRealNameOnStart"]; if (hideRealNameOnStartOpt) - { effectData.SetAttribute(EffectAttributes::HideRealNameOnStart, *hideRealNameOnStartOpt); - } const sol::optional &incompatibleIdsOpt = effectInfo["IncompatibleIds"]; if (incompatibleIdsOpt) { const auto &incompatibleIds = *incompatibleIdsOpt; for (const auto &entry : incompatibleIds) - { if (entry.second.valid() && entry.second.is()) - { effectData.IncompatibleIds.insert(entry.second.as()); - } - } } const sol::optional &effectCategoryOpt = effectInfo["EffectCategory"]; @@ -1005,9 +937,7 @@ LuaScripts::ParseScriptRaw(std::string scriptName, std::string_view script, Pars const auto &effectCategoryStr = *effectCategoryOpt; auto effectCategoryIt = g_NameToEffectCategory.find(effectCategoryStr); if (effectCategoryIt != g_NameToEffectCategory.end()) - { effectData.EffectCategory = effectCategoryIt->second; - } } const sol::optional &effectGroupOpt = effectInfo["EffectGroup"]; @@ -1019,9 +949,7 @@ LuaScripts::ParseScriptRaw(std::string scriptName, std::string_view script, Pars std::lock_guard lock(effectGroupMutex); if (!g_EffectGroups.contains(effectGroup)) - { g_EffectGroups[effectGroup] = { .IsPlaceholder = true, .WasRegisteredByScript = true }; - } g_EffectGroups[effectGroup].MemberCount++; } @@ -1051,9 +979,7 @@ LuaScripts::ParseScriptRaw(std::string scriptName, std::string_view script, Pars { std::string name = StringTrim(settingOverrides["CustomName"]); if (!name.empty()) - { effectData.CustomName = name; - } } catch (nlohmann::json::exception) { @@ -1073,9 +999,7 @@ LuaScripts::ParseScriptRaw(std::string scriptName, std::string_view script, Pars { // Immediately dispatch it too if (ComponentExists()) - { GetComponent()->DispatchEffect(effectId, EffectDispatcher::DispatchEffectFlag_NoAddToLog); - } } else { @@ -1092,9 +1016,7 @@ void LuaScripts::RemoveScriptEntry(const std::string &effectId) auto result = std::find(g_RegisteredEffects.begin(), g_RegisteredEffects.end(), effectId); if (result != g_RegisteredEffects.end()) - { g_RegisteredEffects.erase(result); - } } void LuaScripts::Execute(const std::string &effectId, ExecuteFuncType funcType) @@ -1111,9 +1033,7 @@ void LuaScripts::Execute(const std::string &effectId, ExecuteFuncType funcType) // Yes, OnStop also gets called on non-timed effects if (script.IsTemporary()) - { RemoveScriptEntry(effectId); - } break; case ExecuteFuncType::Tick: diff --git a/ChaosMod/Components/LuaScripts.h b/ChaosMod/Components/LuaScripts.h index be98dc592..215915502 100644 --- a/ChaosMod/Components/LuaScripts.h +++ b/ChaosMod/Components/LuaScripts.h @@ -60,9 +60,7 @@ class LuaScripts : public Component { const sol::protected_function &func = m_Lua[funcName]; if (!func.valid()) - { return; - } const sol::protected_function_result &result = func(); if (!result.valid()) diff --git a/ChaosMod/Components/SplashTexts.cpp b/ChaosMod/Components/SplashTexts.cpp index 07d45feaa..b17d10a38 100644 --- a/ChaosMod/Components/SplashTexts.cpp +++ b/ChaosMod/Components/SplashTexts.cpp @@ -14,9 +14,7 @@ SplashTexts::SplashTexts() g_OptionsManager.GetConfigValue({ "EnableModSplashTexts" }, OPTION_DEFAULT_ENABLE_SPLASH_TEXTS); if (ms_InitalSplashShown) - { return; - } ShowSplash("Chaos Mod v" MOD_VERSION "\n\nSee credits.txt for a list of contributors", { .2f, .3f }, .65f, { 60, 245, 190 }); @@ -42,13 +40,9 @@ void SplashTexts::OnRun() it->Time -= frameTime; if (it->Time <= 0) - { it = m_ActiveSplashes.erase(it); - } else - { it++; - } } } @@ -56,9 +50,7 @@ void SplashTexts::ShowSplash(const std::string &text, const ScreenTextVector &te ScreenTextColor textColor, std::uint8_t time) { if (!m_EnableSplashTexts) - { return; - } m_ActiveSplashes.emplace_back(text, textPos, scale, textColor, time); } diff --git a/ChaosMod/Components/Voting.cpp b/ChaosMod/Components/Voting.cpp index af308c694..9514d9a64 100644 --- a/ChaosMod/Components/Voting.cpp +++ b/ChaosMod/Components/Voting.cpp @@ -65,9 +65,7 @@ bool Voting::Init() #ifdef _DEBUG DWORD attributes = NULL; if (DoesFeatureFlagExist("forcenovotingconsole")) - { attributes = CREATE_NO_WINDOW; - } bool result = CreateProcess(NULL, str, NULL, NULL, TRUE, attributes, NULL, NULL, &startupInfo, &procInfo); #else @@ -105,9 +103,7 @@ void Voting::HandleMsg(std::string_view message) LOG("Received hello from voting pipe"); if (ComponentExists()) - { GetComponent()->SetShouldDispatchEffects(false); - } SendToPipe("hello_back"); } @@ -179,9 +175,7 @@ void Voting::ErrorOutWithMsg(std::string_view message) m_PipeHandle = INVALID_HANDLE_VALUE; if (ComponentExists()) - { GetComponent()->SetShouldDispatchEffects(true); - } m_EnableVoting = false; } @@ -201,25 +195,19 @@ void Voting::OnModPauseCleanup() void Voting::OnRun() { if (!m_EnableVoting || !ComponentExists() || !ComponentExists()) - { return; - } if (!m_HasInitializedVoting) { // Only initialize voting proxy after we are fully loaded in, otherwise some weird behaviour can occur from the // voting proxy, e.g. OnFailureToReceiveJoinConfirmation being raised for whatever reason if (GET_IS_LOADING_SCREEN_ACTIVE()) - { return; - } m_HasInitializedVoting = true; if (!Init()) - { return; - } m_PipeHandle = CreateNamedPipe(L"\\\\.\\pipe\\ChaosModVVotingPipe", PIPE_ACCESS_DUPLEX, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_NOWAIT, 1, BUFFER_SIZE, @@ -245,9 +233,7 @@ void Voting::OnRun() } if (ComponentExists()) - { GetComponent()->ShowVotingSplash(); - } } return; @@ -284,22 +270,14 @@ void Voting::OnRun() char buffer[BUFFER_SIZE]; DWORD bytesRead; if (!ReadFile(m_PipeHandle, buffer, BUFFER_SIZE, &bytesRead, NULL)) - { while (GetLastError() == ERROR_IO_PENDING) - { WAIT(0); - } - } if (bytesRead > 0) - { HandleMsg(buffer); - } if (!m_ReceivedHello) - { return; - } if (GetComponent()->GetRemainingTimerTime() <= 1 && !m_HasReceivedResult) { @@ -318,22 +296,14 @@ void Voting::OnRun() // Should be random effect voteable, so just dispatch random effect if (m_ChosenEffectIdentifier->GetEffectId().empty()) - { GetComponent()->DispatchRandomEffect(); - } else - { GetComponent()->DispatchEffect(*m_ChosenEffectIdentifier); - } GetComponent()->ResetTimer(); if (ComponentExists()) - { for (int i = 0; i < GetComponent()->AdditionalEffectsToDispatch; i++) - { GetComponent()->DispatchRandomEffect(); - } - } m_IsVotingRoundDone = true; } @@ -423,9 +393,7 @@ void Voting::OnRun() std::vector effectNames; for (const auto &pChoosableEffect : m_EffectChoices) - { effectNames.push_back(pChoosableEffect->m_EffectName); - } SendToPipe("vote", effectNames); diff --git a/ChaosMod/Components/Workshop.cpp b/ChaosMod/Components/Workshop.cpp index 972391559..a1824eaf7 100644 --- a/ChaosMod/Components/Workshop.cpp +++ b/ChaosMod/Components/Workshop.cpp @@ -5,15 +5,11 @@ nlohmann::json Workshop::GetSubmissionSettingJson(const std::string &submissionPath) { if (m_CachedSubmissionSettings.contains(submissionPath)) - { return m_CachedSubmissionSettings.at(submissionPath); - } auto submissionSettingsFile = submissionPath + ".json"; if (!DoesFileExist(submissionSettingsFile)) - { return {}; - } std::ifstream file(submissionSettingsFile); std::stringstream buffer; @@ -39,9 +35,7 @@ std::vector Workshop::GetSubmissionBlacklistedFiles(const std::stri try { for (const std::string &file : json["disabled_files"]) - { blacklistedFiles.push_back(file); - } } catch (nlohmann::json::exception) { diff --git a/ChaosMod/Effects/Effect.h b/ChaosMod/Effects/Effect.h index 8c49129cc..9a374d727 100644 --- a/ChaosMod/Effects/Effect.h +++ b/ChaosMod/Effects/Effect.h @@ -148,9 +148,7 @@ class RegisterEffect }(); if (disableEffectRegistration) - { return; - } m_RegisteredEffect = { effectInfo.Id, onStart, onStop, onTick }; diff --git a/ChaosMod/Effects/EffectConfig.h b/ChaosMod/Effects/EffectConfig.h index 94a72667a..2554c5f49 100644 --- a/ChaosMod/Effects/EffectConfig.h +++ b/ChaosMod/Effects/EffectConfig.h @@ -23,16 +23,10 @@ namespace EffectConfig if (input.length() > 0) { for (size_t i = 0; i < input.length(); i++) - { if (input[i] == '\"') - { isInQuotes = !isInQuotes; - } else if (!isInQuotes && input[i] == ',') - { return i; - } - } } return -1; } @@ -79,14 +73,10 @@ namespace EffectConfig auto split = value.substr(0, splitIndex); // Trim surrounding quotations if (split.length() >= 2 && split[0] == '\"' && split[split.length() - 1] == '\"') - { split = split.substr(1, split.size() - 2); - } // Names can't be "0" to support older configs if (!split.empty() && split != "0") - { valueEffectName = split; - } } else { @@ -96,9 +86,7 @@ namespace EffectConfig } if (splitIndex == value.npos) - { break; - } value = value.substr(splitIndex + 1); splitIndex = GetNextDelimiterOffset(value); @@ -106,9 +94,7 @@ namespace EffectConfig } if (!configValues.Values.Enabled) - { continue; - } EffectData effectData; if (!effectInfo.IsTimed) @@ -133,9 +119,7 @@ namespace EffectConfig } if (configValues.Values.WeightMult > 0) - { effectData.WeightMult = configValues.Values.WeightMult; - } effectData.Weight = effectData.WeightMult; // Set initial effect weight to WeightMult effectData.SetAttribute(EffectAttributes::ExcludedFromVoting, configValues.Values.ExcludedFromVoting); effectData.SetAttribute(EffectAttributes::IsMeta, effectInfo.ExecutionType == EffectExecutionType::Meta); @@ -148,16 +132,12 @@ namespace EffectConfig effectData.ShortcutKeycode = configValues.Values.ShortcutKeycode; #endif if (!valueEffectName.empty()) - { effectData.CustomName = valueEffectName; - } effectData.Id = effectInfo.Id; effectData.EffectCategory = effectInfo.EffectCategory; for (auto effectType : effectInfo.IncompatibleWith) - { effectData.IncompatibleIds.insert(g_EffectsMap.at(effectType).Id); - } if (effectInfo.EffectGroupType != EffectGroupType::None) { diff --git a/ChaosMod/Effects/EffectData.h b/ChaosMod/Effects/EffectData.h index 9c91f5774..33a35fa44 100644 --- a/ChaosMod/Effects/EffectData.h +++ b/ChaosMod/Effects/EffectData.h @@ -32,13 +32,9 @@ struct EffectData inline void SetAttribute(EffectAttributes attribute, bool state) { if (state) - { Attributes |= attribute; - } else - { Attributes &= ~attribute; - } } inline bool IsExcludedFromVoting() const diff --git a/ChaosMod/Effects/EffectThreads.cpp b/ChaosMod/Effects/EffectThreads.cpp index 5d59e24bc..c0dd52372 100644 --- a/ChaosMod/Effects/EffectThreads.cpp +++ b/ChaosMod/Effects/EffectThreads.cpp @@ -38,50 +38,38 @@ namespace EffectThreads void StopThread(LPVOID threadId) { if (m_Threads.contains(threadId)) - { m_Threads.at(threadId)->Stop(); - } } void StopThreadImmediately(LPVOID threadId) { if (m_Threads.contains(threadId)) - { _StopThreadImmediately(m_Threads.find(threadId)); - } } void StopThreads() { for (auto &[threadId, thread] : m_Threads) - { thread->Stop(); - } } void StopThreadsImmediately() { for (auto it = m_Threads.begin(); it != m_Threads.end();) - { it = _StopThreadImmediately(it); - } } void PauseThisThread(DWORD timeMs) { auto fiber = GetCurrentFiber(); if (m_Threads.contains(fiber)) - { m_Threads.at(fiber)->PauseTimestamp = GetTickCount64() + timeMs; - } } bool IsThreadPaused(LPVOID threadId) { if (!m_Threads.contains(threadId)) - { return true; - } return m_Threads.at(threadId)->PauseTimestamp > GetTickCount64(); } @@ -97,9 +85,7 @@ namespace EffectThreads } if (GetTickCount64() >= thread->PauseTimestamp) - { thread->OnRun(); - } it++; } @@ -107,18 +93,14 @@ namespace EffectThreads void RunThreads() { for (auto it = m_Threads.begin(); it != m_Threads.end();) - { _RunThread(it); - } } void RunThread(LPVOID threadId) { auto result = m_Threads.find(threadId); if (result != m_Threads.end()) - { _RunThread(result); - } } bool DoesThreadExist(LPVOID threadId) @@ -129,9 +111,7 @@ namespace EffectThreads bool HasThreadOnStartExecuted(LPVOID threadId) { if (!m_Threads.contains(threadId)) - { return true; - } return m_Threads.at(threadId)->HasOnStartExecuted(); } @@ -144,9 +124,7 @@ namespace EffectThreads EffectSoundPlayOptions *GetThreadEffectSoundPlayOptions(LPVOID threadId) { if (!DoesThreadExist(threadId)) - { return nullptr; - } return &m_Threads.at(threadId)->ThreadData.EffectSoundPlayOptions; } @@ -159,9 +137,7 @@ namespace CurrentEffect auto threadId = GetCurrentFiber(); auto targetSoundPlayOptions = EffectThreads::GetThreadEffectSoundPlayOptions(threadId); if (!targetSoundPlayOptions) - { return; - } *targetSoundPlayOptions = soundPlayOptions; } } \ No newline at end of file diff --git a/ChaosMod/Effects/db/Meta/MetaAdditionalEffects.cpp b/ChaosMod/Effects/db/Meta/MetaAdditionalEffects.cpp index 4366fc5d8..fb78bb08c 100644 --- a/ChaosMod/Effects/db/Meta/MetaAdditionalEffects.cpp +++ b/ChaosMod/Effects/db/Meta/MetaAdditionalEffects.cpp @@ -9,17 +9,13 @@ static void OnStop() { if (ComponentExists()) - { GetComponent()->AdditionalEffectsToDispatch = 0; - } } static void OnTick() { if (ComponentExists()) - { GetComponent()->AdditionalEffectsToDispatch = 2; - } } // clang-format off diff --git a/ChaosMod/Effects/db/Meta/MetaEffectDuration.cpp b/ChaosMod/Effects/db/Meta/MetaEffectDuration.cpp index f1b05d3c5..b4da959a0 100644 --- a/ChaosMod/Effects/db/Meta/MetaEffectDuration.cpp +++ b/ChaosMod/Effects/db/Meta/MetaEffectDuration.cpp @@ -9,17 +9,13 @@ static void OnStop() { if (ComponentExists()) - { GetComponent()->EffectDurationModifier = 1.f; - } } static void OnTick_0_5x() { if (ComponentExists()) - { GetComponent()->EffectDurationModifier = .5f; - } } // clang-format off @@ -37,9 +33,7 @@ REGISTER_EFFECT(nullptr, OnStop, OnTick_0_5x, EffectInfo static void OnTick_2x() { if (ComponentExists()) - { GetComponent()->EffectDurationModifier = 2.f; - } } // clang-format off diff --git a/ChaosMod/Effects/db/Meta/MetaHideChaosUI.cpp b/ChaosMod/Effects/db/Meta/MetaHideChaosUI.cpp index 15c5c3f7e..821645a64 100644 --- a/ChaosMod/Effects/db/Meta/MetaHideChaosUI.cpp +++ b/ChaosMod/Effects/db/Meta/MetaHideChaosUI.cpp @@ -9,17 +9,13 @@ static void OnStop() { if (ComponentExists()) - { GetComponent()->HideChaosUI = false; - } } static void OnTick() { if (ComponentExists()) - { GetComponent()->HideChaosUI = true; - } } // clang-format off diff --git a/ChaosMod/Effects/db/Meta/MetaNoChaos.cpp b/ChaosMod/Effects/db/Meta/MetaNoChaos.cpp index db314760b..6176ae9eb 100644 --- a/ChaosMod/Effects/db/Meta/MetaNoChaos.cpp +++ b/ChaosMod/Effects/db/Meta/MetaNoChaos.cpp @@ -8,25 +8,19 @@ static void OnStart() ClearEntityPool(); if (ComponentExists()) - { GetComponent()->ClearActiveEffects(); - } } static void OnStop() { if (ComponentExists()) - { GetComponent()->DisableChaos = false; - } } static void OnTick() { if (ComponentExists()) - { GetComponent()->DisableChaos = true; - } } // clang-format off diff --git a/ChaosMod/Effects/db/Meta/MetaReInvoke.cpp b/ChaosMod/Effects/db/Meta/MetaReInvoke.cpp index 722066e3f..f92b65d11 100644 --- a/ChaosMod/Effects/db/Meta/MetaReInvoke.cpp +++ b/ChaosMod/Effects/db/Meta/MetaReInvoke.cpp @@ -9,16 +9,12 @@ static void OnStart() { if (!ComponentExists()) - { return; - } auto disp = GetComponent(); const auto &eff = disp->GetRecentEffects(5, "meta_re_invoke"); for (RegisteredEffect *effect : eff) - { disp->DispatchEffect(effect->GetIndentifier(), EffectDispatcher::DispatchEffectFlag_NoAddToLog); - } } // clang-format off diff --git a/ChaosMod/Effects/db/Meta/MetaTimerSpeed.cpp b/ChaosMod/Effects/db/Meta/MetaTimerSpeed.cpp index af7a233ef..bdf018b7e 100644 --- a/ChaosMod/Effects/db/Meta/MetaTimerSpeed.cpp +++ b/ChaosMod/Effects/db/Meta/MetaTimerSpeed.cpp @@ -9,17 +9,13 @@ static void OnStop() { if (ComponentExists()) - { GetComponent()->TimerSpeedModifier = 1.f; - } } static void OnTick_0_5x() { if (ComponentExists()) - { GetComponent()->TimerSpeedModifier = .5f; - } } // clang-format off @@ -37,9 +33,7 @@ REGISTER_EFFECT(nullptr, OnStop, OnTick_0_5x, EffectInfo static void OnTick_2x() { if (ComponentExists()) - { GetComponent()->TimerSpeedModifier = 2.f; - } } // clang-format off @@ -57,9 +51,7 @@ REGISTER_EFFECT(nullptr, OnStop, OnTick_2x, EffectInfo static void OnTick_5x() { if (ComponentExists()) - { GetComponent()->TimerSpeedModifier = 5.f; - } } // clang-format off diff --git a/ChaosMod/Effects/db/Misc/MiscAirstrike.cpp b/ChaosMod/Effects/db/Misc/MiscAirstrike.cpp index f11bf7948..7bdb31209 100644 --- a/ChaosMod/Effects/db/Misc/MiscAirstrike.cpp +++ b/ChaosMod/Effects/db/Misc/MiscAirstrike.cpp @@ -28,9 +28,7 @@ static void OnTick() { REQUEST_WEAPON_ASSET(airstrikeHash, 31, 0); while (!HAS_WEAPON_ASSET_LOADED(airstrikeHash)) - { WAIT(0); - } int current_time = GET_GAME_TIMER(); if (current_time - lastAirStrike > 1000) { diff --git a/ChaosMod/Effects/db/Misc/MiscBlackHole.cpp b/ChaosMod/Effects/db/Misc/MiscBlackHole.cpp index 93479ab5d..4dd3ddcf2 100644 --- a/ChaosMod/Effects/db/Misc/MiscBlackHole.cpp +++ b/ChaosMod/Effects/db/Misc/MiscBlackHole.cpp @@ -25,34 +25,24 @@ static void OnTick() XInput::SetAllControllersRumble(40000, 40000); if (ms_CurRadius < 200.f) - { ms_CurRadius += 0.2f + GET_FRAME_TIME(); - } _DRAW_SPHERE(ms_BlackHolePos.x, ms_BlackHolePos.y, ms_BlackHolePos.z, ms_CurRadius, 0, 0, 0, 1.f); SHAKE_GAMEPLAY_CAM("LARGE_EXPLOSION_SHAKE", 0.1f * ms_CurRadius / 200.f); std::list entities; for (auto ped : GetAllPeds()) - { entities.push_back(ped); - } for (auto veh : GetAllVehs()) - { entities.push_back(veh); - } for (auto prop : GetAllProps()) - { entities.push_back(prop); - } auto playerVeh = GET_VEHICLE_PED_IS_IN(PLAYER_PED_ID(), false); for (auto entity : entities) { if (!DOES_ENTITY_EXIST(entity)) - { continue; - } auto pos = GET_ENTITY_COORDS(entity, false); @@ -71,18 +61,12 @@ static void OnTick() if (pos.DistanceTo(ms_BlackHolePos) < ms_CurRadius) { if (IS_ENTITY_A_PED(entity)) - { SET_ENTITY_HEALTH(entity, 0, 0); - } else if (IS_ENTITY_A_VEHICLE(entity)) - { EXPLODE_VEHICLE(entity, true, false); - } if (!IS_ENTITY_A_MISSION_ENTITY(entity)) - { DELETE_ENTITY(&entity); - } } } } diff --git a/ChaosMod/Effects/db/Misc/MiscBoostVelocity.cpp b/ChaosMod/Effects/db/Misc/MiscBoostVelocity.cpp index 3d32da755..5127a7d61 100644 --- a/ChaosMod/Effects/db/Misc/MiscBoostVelocity.cpp +++ b/ChaosMod/Effects/db/Misc/MiscBoostVelocity.cpp @@ -9,19 +9,13 @@ static void OnStart() std::vector entities; for (Ped ped : GetAllPeds()) - { entities.push_back(ped); - } for (Vehicle veh : GetAllVehs()) - { entities.push_back(veh); - } for (Object prop : GetAllProps()) - { entities.push_back(prop); - } for (Entity ent : entities) { diff --git a/ChaosMod/Effects/db/Misc/MiscCloneOnDeath.cpp b/ChaosMod/Effects/db/Misc/MiscCloneOnDeath.cpp index 1e16bd261..ccc5ac56a 100644 --- a/ChaosMod/Effects/db/Misc/MiscCloneOnDeath.cpp +++ b/ChaosMod/Effects/db/Misc/MiscCloneOnDeath.cpp @@ -26,20 +26,12 @@ static void OnStart() excludeEntities = {}; for (Ped ped : GetAllPeds()) - { if (!DOES_ENTITY_EXIST(ped) || IS_ENTITY_DEAD(ped, 0)) - { excludeEntities.push_back(ped); - } - } for (Vehicle veh : GetAllVehs()) - { if (!DOES_ENTITY_EXIST(veh) || IS_ENTITY_DEAD(veh, 0)) - { excludeEntities.push_back(veh); - } - } temporarilyInvincibleEntities = {}; } @@ -94,17 +86,11 @@ static void OnTick() int maxSeats = GET_VEHICLE_MODEL_NUMBER_OF_SEATS(GET_ENTITY_MODEL(veh)); for (int i = -1; i < maxSeats; i++) - { if (!IS_VEHICLE_SEAT_FREE(veh, i, false)) - { SET_PED_INTO_VEHICLE(GET_PED_IN_VEHICLE_SEAT(veh, i, 0), cloneVeh, i); - } - } if (GET_IS_VEHICLE_ENGINE_RUNNING(veh)) - { SET_VEHICLE_ENGINE_ON(cloneVeh, true, true, false); - } // Prevent vehicle from blowing up instantly on spawn, creating an infinite feedback loop of spawning and // exploding vehicles @@ -120,9 +106,7 @@ static void OnTick() if (!DOES_ENTITY_EXIST(invincibleEntity.entity) || GET_GAME_TIMER() >= invincibleEntity.endInvincibilityTick) { if (DOES_ENTITY_EXIST(invincibleEntity.entity)) - { SET_ENTITY_INVINCIBLE(invincibleEntity.entity, false); - } it = temporarilyInvincibleEntities.erase(it); } diff --git a/ChaosMod/Effects/db/Misc/MiscCocktail.cpp b/ChaosMod/Effects/db/Misc/MiscCocktail.cpp index 37399061b..bce78d42a 100644 --- a/ChaosMod/Effects/db/Misc/MiscCocktail.cpp +++ b/ChaosMod/Effects/db/Misc/MiscCocktail.cpp @@ -31,14 +31,10 @@ static void OnTick() } for (auto object : GetAllProps()) - { Memory::ApplyForceToEntityCenterOfMass(object, 1, y, x, 0, false, false, true, false); - } for (auto veh : GetAllVehs()) - { Memory::ApplyForceToEntityCenterOfMass(veh, 1, y, x, 0, false, false, true, false); - } } // clang-format off diff --git a/ChaosMod/Effects/db/Misc/MiscEarthquake.cpp b/ChaosMod/Effects/db/Misc/MiscEarthquake.cpp index 928ee20e6..833924b1e 100644 --- a/ChaosMod/Effects/db/Misc/MiscEarthquake.cpp +++ b/ChaosMod/Effects/db/Misc/MiscEarthquake.cpp @@ -28,25 +28,17 @@ static void OnTick() Hash model = GET_ENTITY_MODEL(veh); if (!IS_THIS_MODEL_A_HELI(model) && !IS_THIS_MODEL_A_PLANE(model)) - { entities.push_back(veh); - } } for (Object prop : GetAllProps()) - { entities.push_back(prop); - } for (Ped ped : GetAllPeds()) - { entities.push_back(ped); - } for (Entity entity : entities) - { Memory::ApplyForceToEntity(entity, 1, 0, 0, shook, .0f, .0f, .0f, 0, true, true, true, false, true); - } } // clang-format off diff --git a/ChaosMod/Effects/db/Misc/MiscFakeCrash.cpp b/ChaosMod/Effects/db/Misc/MiscFakeCrash.cpp index 7fcacd488..9dbfb48aa 100644 --- a/ChaosMod/Effects/db/Misc/MiscFakeCrash.cpp +++ b/ChaosMod/Effects/db/Misc/MiscFakeCrash.cpp @@ -30,9 +30,7 @@ static void SleepAllThreads(DWORD ms) } while (Thread32Next(handle, &threadEntry)); for (HANDLE thread : threads) - { SuspendThread(thread); - } Sleep(ms); @@ -53,9 +51,7 @@ static void OnStart() if (fakeTimer) { if (ComponentExists()) - { GetComponent()->SetFakeTimerPercentage(g_Random.GetRandomFloat(0.f, 1.f)); - } WAIT(0); } @@ -75,9 +71,7 @@ static void OnStart() SleepAllThreads(g_Random.GetRandomInt(3000, 10000)); if (fakeTimer && ComponentExists()) - { GetComponent()->ResetFakeTimerPercentage(); - } } // clang-format off diff --git a/ChaosMod/Effects/db/Misc/MiscFireworks.cpp b/ChaosMod/Effects/db/Misc/MiscFireworks.cpp index 46b7cd3c6..ac2a25fa8 100644 --- a/ChaosMod/Effects/db/Misc/MiscFireworks.cpp +++ b/ChaosMod/Effects/db/Misc/MiscFireworks.cpp @@ -13,9 +13,7 @@ static void OnStart() Hash weaponHash = "weapon_firework"_hash; for (Ped pd : GetAllPeds()) - { GIVE_WEAPON_TO_PED(pd, weaponHash, 9999, true, true); - } } static void OnTick() @@ -30,9 +28,7 @@ static void OnTick() Vector3 pos = ENTITY::GET_ENTITY_COORDS(PLAYER::PLAYER_PED_ID(), 1); REQUEST_NAMED_PTFX_ASSET("proj_indep_firework_v2"); while (!HAS_NAMED_PTFX_ASSET_LOADED("proj_indep_firework_v2")) - { WAIT(0); - } USE_PARTICLE_FX_ASSET("proj_indep_firework_v2"); int x = pos.x + g_Random.GetRandomInt(-220, 220); diff --git a/ChaosMod/Effects/db/Misc/MiscFlamethrower.cpp b/ChaosMod/Effects/db/Misc/MiscFlamethrower.cpp index 3c8301065..8dfc9258e 100644 --- a/ChaosMod/Effects/db/Misc/MiscFlamethrower.cpp +++ b/ChaosMod/Effects/db/Misc/MiscFlamethrower.cpp @@ -25,9 +25,7 @@ static void OnTick() { REQUEST_NAMED_PTFX_ASSET("core"); while (!HAS_NAMED_PTFX_ASSET_LOADED("core")) - { WAIT(0); - } std::vector firingPeds; for (Ped ped : GetAllPeds()) @@ -36,9 +34,7 @@ static void OnTick() { Entity weapon = GET_SELECTED_PED_WEAPON(ped); if (GET_WEAPON_DAMAGE_TYPE(weapon) == 3) - { firingPeds.push_back(ped); - } } } diff --git a/ChaosMod/Effects/db/Misc/MiscGhostWorld.cpp b/ChaosMod/Effects/db/Misc/MiscGhostWorld.cpp index 6378f9707..a61084b6e 100644 --- a/ChaosMod/Effects/db/Misc/MiscGhostWorld.cpp +++ b/ChaosMod/Effects/db/Misc/MiscGhostWorld.cpp @@ -12,37 +12,25 @@ static int GetAlphaForEntity(Entity entity) static void OnTick() { for (Ped ped : GetAllPeds()) - { SET_ENTITY_ALPHA(ped, GetAlphaForEntity(ped), false); - } for (Vehicle veh : GetAllVehs()) - { SET_ENTITY_ALPHA(veh, GetAlphaForEntity(veh), false); - } for (Entity prop : GetAllProps()) - { SET_ENTITY_ALPHA(prop, GetAlphaForEntity(prop), false); - } } static void OnStop() { for (Ped ped : GetAllPeds()) - { RESET_ENTITY_ALPHA(ped); - } for (Vehicle veh : GetAllVehs()) - { RESET_ENTITY_ALPHA(veh); - } for (Entity prop : GetAllProps()) - { RESET_ENTITY_ALPHA(prop); - } } // clang-format off diff --git a/ChaosMod/Effects/db/Misc/MiscGravityController.cpp b/ChaosMod/Effects/db/Misc/MiscGravityController.cpp index 7313775b7..231d6ad00 100644 --- a/ChaosMod/Effects/db/Misc/MiscGravityController.cpp +++ b/ChaosMod/Effects/db/Misc/MiscGravityController.cpp @@ -8,14 +8,10 @@ static void OnStop() SET_GRAVITY_LEVEL(0); for (auto ped : GetAllPeds()) - { SET_ENTITY_INVINCIBLE(ped, false); - } for (auto veh : GetAllVehs()) - { SET_ENTITY_INVINCIBLE(veh, false); - } } static void OnTickLow() @@ -67,9 +63,7 @@ static void OnTickInsane() } for (auto object : GetAllProps()) - { Memory::ApplyForceToEntityCenterOfMass(object, 0, 0, 0, -200.f, false, false, true, false); - } } // clang-format off @@ -104,9 +98,7 @@ static void OnTickInvert() } for (auto object : GetAllProps()) - { Memory::ApplyForceToEntityCenterOfMass(object, 0, 0, 0, 100.f, false, false, true, false); - } } // clang-format off diff --git a/ChaosMod/Effects/db/Misc/MiscInvertVelocity.cpp b/ChaosMod/Effects/db/Misc/MiscInvertVelocity.cpp index 54eb0d98c..83c9f4555 100644 --- a/ChaosMod/Effects/db/Misc/MiscInvertVelocity.cpp +++ b/ChaosMod/Effects/db/Misc/MiscInvertVelocity.cpp @@ -5,19 +5,13 @@ static void OnStart() std::vector entities; for (auto ped : GetAllPeds()) - { entities.push_back(ped); - } for (auto veh : GetAllVehs()) - { entities.push_back(veh); - } for (auto prop : GetAllProps()) - { entities.push_back(prop); - } for (auto entity : entities) { diff --git a/ChaosMod/Effects/db/Misc/MiscJumpyProps.cpp b/ChaosMod/Effects/db/Misc/MiscJumpyProps.cpp index c7b38f22c..f9ad8d8f3 100644 --- a/ChaosMod/Effects/db/Misc/MiscJumpyProps.cpp +++ b/ChaosMod/Effects/db/Misc/MiscJumpyProps.cpp @@ -19,9 +19,7 @@ static void OnTick() Vector3 coords = GET_ENTITY_COORDS(prop, 0); if (!propDataMap.contains(prop)) - { propDataMap[prop] = PropData { coords.z, GET_GAME_TIMER() + prop }; - } PropData data = propDataMap[prop]; diff --git a/ChaosMod/Effects/db/Misc/MiscLag.cpp b/ChaosMod/Effects/db/Misc/MiscLag.cpp index 04770fc25..484f518f6 100644 --- a/ChaosMod/Effects/db/Misc/MiscLag.cpp +++ b/ChaosMod/Effects/db/Misc/MiscLag.cpp @@ -21,9 +21,7 @@ static void OnTickLag() lastTick = curTick; if (++ms_State == 4) - { ms_State = 0; - } if (ms_State == 2) { @@ -59,9 +57,7 @@ static void OnTickLag() // if the vehicle is reversing use a negative forward speed if (GET_ENTITY_SPEED_VECTOR(veh, true).y < 0) - { forwardSpeed *= -1; - } const Vector3 &tpPos = pair.second; diff --git a/ChaosMod/Effects/db/Misc/MiscLowPoly.cpp b/ChaosMod/Effects/db/Misc/MiscLowPoly.cpp index 2a9be28b8..cb40b7608 100644 --- a/ChaosMod/Effects/db/Misc/MiscLowPoly.cpp +++ b/ChaosMod/Effects/db/Misc/MiscLowPoly.cpp @@ -11,12 +11,8 @@ static void OnTick() // By Juhana for (Ped ped : GetAllPeds()) - { if (!IS_PED_A_PLAYER(ped) && !IS_ENTITY_A_MISSION_ENTITY(ped)) - { FORCE_PED_MOTION_STATE(ped, 0xbac0f10b, 0, 0, 0); // 0xbac0f10b is "nothing" according to Script Hook V - } - } } // clang-format off diff --git a/ChaosMod/Effects/db/Misc/MiscMeteorRain.cpp b/ChaosMod/Effects/db/Misc/MiscMeteorRain.cpp index 0145e46f1..f438c737b 100644 --- a/ChaosMod/Effects/db/Misc/MiscMeteorRain.cpp +++ b/ChaosMod/Effects/db/Misc/MiscMeteorRain.cpp @@ -65,9 +65,7 @@ static void OnTick() if (HAS_ENTITY_COLLIDED_WITH_ANYTHING(prop)) { if (lastTick2 < curTick - 1000) - { meteorDespawnTime[i]--; - } } continue; } @@ -82,9 +80,7 @@ static void OnTick() } if (lastTick2 < curTick - 1000) - { lastTick2 = curTick; - } } // clang-format off diff --git a/ChaosMod/Effects/db/Misc/MiscNewsTeam.cpp b/ChaosMod/Effects/db/Misc/MiscNewsTeam.cpp index f83c19543..44d413930 100644 --- a/ChaosMod/Effects/db/Misc/MiscNewsTeam.cpp +++ b/ChaosMod/Effects/db/Misc/MiscNewsTeam.cpp @@ -120,9 +120,7 @@ static void OnStart() RENDER_SCRIPT_CAMS(true, true, 1000, true, true, true); scaleForm = REQUEST_SCALEFORM_MOVIE("breaking_news"); while (!HAS_SCALEFORM_MOVIE_LOADED(scaleForm)) - { WAIT(0); - } int chosenIndex = g_Random.GetRandomInt(0, sizeof(ms_TextPairs) / sizeof(ms_TextPairs[0]) * .5f - 1) * 2; BEGIN_SCALEFORM_MOVIE_METHOD(scaleForm, "SET_TEXT"); @@ -158,9 +156,7 @@ static void OnTick() SET_PED_KEEP_TASK(pilot, true); } if (scaleForm > 0) - { DRAW_SCALEFORM_MOVIE_FULLSCREEN(scaleForm, 255, 255, 255, 255, 0); - } } // clang-format off diff --git a/ChaosMod/Effects/db/Misc/MiscNoPhone.cpp b/ChaosMod/Effects/db/Misc/MiscNoPhone.cpp index 115c8393e..090d2f410 100644 --- a/ChaosMod/Effects/db/Misc/MiscNoPhone.cpp +++ b/ChaosMod/Effects/db/Misc/MiscNoPhone.cpp @@ -5,9 +5,7 @@ static void OnStop() REQUEST_SCRIPT("cellphone_controller"); while (!HAS_SCRIPT_LOADED("cellphone_controller")) - { WAIT(0); - } START_NEW_SCRIPT("cellphone_controller", 1424); diff --git a/ChaosMod/Effects/db/Misc/MiscNoWater.cpp b/ChaosMod/Effects/db/Misc/MiscNoWater.cpp index 4f44a1295..fb42311f1 100644 --- a/ChaosMod/Effects/db/Misc/MiscNoWater.cpp +++ b/ChaosMod/Effects/db/Misc/MiscNoWater.cpp @@ -26,9 +26,7 @@ static CWaterQuad *GetWaterQuads() { static Handle handle = Memory::FindPattern("? 6B C9 1C ? 03 0D ? ? ? ? 66 ? 03 C5 66 89 05 ? ? ? ?"); if (handle.IsValid()) - { return *handle.At(6).Into().Get(); - } return nullptr; } @@ -49,11 +47,9 @@ static void OnStop() { if (WaterQuads) { - for (int i = 0; i < 821; i++) // 821 = Max Water Items - { + for (int i = 0; i < 821; i++) // 821 = Max Water Items WaterQuads[i].Z = WaterHeights.at(i); // Restore Water - } - WaterHeights.clear(); // Clear Storage Vector + WaterHeights.clear(); // Clear Storage Vector } } diff --git a/ChaosMod/Effects/db/Misc/MiscNothing.cpp b/ChaosMod/Effects/db/Misc/MiscNothing.cpp index c38726f4f..d8640dfbd 100644 --- a/ChaosMod/Effects/db/Misc/MiscNothing.cpp +++ b/ChaosMod/Effects/db/Misc/MiscNothing.cpp @@ -29,9 +29,7 @@ static void OnStart() const auto &effectOverride = options[g_Random.GetRandomInt(0, options.size() - 1)]; if (ComponentExists()) - { GetComponent()->OverrideEffectName("nothing", effectOverride); - } WAIT(25000); } diff --git a/ChaosMod/Effects/db/Misc/MiscOilLeaks.cpp b/ChaosMod/Effects/db/Misc/MiscOilLeaks.cpp index 6dd444009..b5b187eea 100644 --- a/ChaosMod/Effects/db/Misc/MiscOilLeaks.cpp +++ b/ChaosMod/Effects/db/Misc/MiscOilLeaks.cpp @@ -31,15 +31,11 @@ static void OnTick() for (Entity entity : entities) { if (!DOES_ENTITY_EXIST(entity)) - { continue; - } Vector3 entityPos = GET_ENTITY_COORDS(entity, false); float groundZ = 0; if (GET_GROUND_Z_FOR_3D_COORD(entityPos.x, entityPos.y, entityPos.z, &groundZ, false, false)) - { ADD_PETROL_DECAL(entityPos.x, entityPos.y, groundZ, 2, 2, 1); - } if (--count == 0) { diff --git a/ChaosMod/Effects/db/Misc/MiscPayRespects.cpp b/ChaosMod/Effects/db/Misc/MiscPayRespects.cpp index d928426f7..c52dcbde2 100644 --- a/ChaosMod/Effects/db/Misc/MiscPayRespects.cpp +++ b/ChaosMod/Effects/db/Misc/MiscPayRespects.cpp @@ -33,9 +33,7 @@ static void OnTick() int overlaycolor = 0; if (IS_CONTROL_JUST_PRESSED(0, 23)) - { ms_LastPressTick = currentTick; - } if (ms_LastPressTick < currentTick - ms_MaxPressInterval) { @@ -48,9 +46,7 @@ static void OnTick() } if (Beepable(ms_TimeReserve - tickDelta) && !Beepable(ms_TimeReserve)) - { PLAY_SOUND_FRONTEND(-1, "Beep_Red", "DLC_HEIST_HACKING_SNAKE_SOUNDS", true); - } ms_TimeReserve -= tickDelta; } @@ -59,9 +55,7 @@ static void OnTick() overlaycolor = 25; ms_TimeReserve += tickDelta / 2; // slows down regaining time if (ms_TimeReserve > WAIT_TIME) - { ms_TimeReserve = WAIT_TIME; - } } ms_LastTick = currentTick; @@ -70,17 +64,11 @@ static void OnTick() SCALEFORM_MOVIE_METHOD_ADD_PARAM_PLAYER_NAME_STRING("PAY RESPECTS"); char charBuf[64]; if (ms_TimeReserve != WAIT_TIME && ms_LastPressTick < currentTick - ms_MaxPressInterval) - { sprintf_s(charBuf, "Press F\nFailure In: %.1fs", float(ms_TimeReserve) / 1000); - } else if (ms_TimeReserve != WAIT_TIME && ms_LastPressTick >= currentTick - ms_MaxPressInterval) - { sprintf_s(charBuf, "Press F\nFailure In: %.1fs (Recovering)", float(ms_TimeReserve) / 1000); - } else - { sprintf_s(charBuf, "Press F"); - } SCALEFORM_MOVIE_METHOD_ADD_PARAM_PLAYER_NAME_STRING(charBuf); SCALEFORM_MOVIE_METHOD_ADD_PARAM_INT(overlaycolor); END_SCALEFORM_MOVIE_METHOD(); @@ -92,9 +80,7 @@ static void OnStart() { ms_Overlay = REQUEST_SCALEFORM_MOVIE("MP_BIG_MESSAGE_FREEMODE"); while (!HAS_SCALEFORM_MOVIE_LOADED(ms_Overlay)) - { WAIT(0); - } ms_LastTick = GET_GAME_TIMER(); ms_TimeReserve = WAIT_TIME; } diff --git a/ChaosMod/Effects/db/Misc/MiscPortraitMode.cpp b/ChaosMod/Effects/db/Misc/MiscPortraitMode.cpp index d8f3ac7ac..d1b04eed0 100644 --- a/ChaosMod/Effects/db/Misc/MiscPortraitMode.cpp +++ b/ChaosMod/Effects/db/Misc/MiscPortraitMode.cpp @@ -17,9 +17,7 @@ static void OnTick() DRAW_RECT((currentBoxWidth / 2), 0.5, currentBoxWidth, 1, 0, 0, 0, 255, false); // Left bar DRAW_RECT(1 - (currentBoxWidth / 2), 0.5, currentBoxWidth, 1, 0, 0, 0, 255, false); // Right bar if (currentBoxWidth < maxBoxWidth) - { currentBoxWidth += 0.01; - } } // clang-format off diff --git a/ChaosMod/Effects/db/Misc/MiscQuickSprunkStop.cpp b/ChaosMod/Effects/db/Misc/MiscQuickSprunkStop.cpp index eb1390784..8baa82552 100644 --- a/ChaosMod/Effects/db/Misc/MiscQuickSprunkStop.cpp +++ b/ChaosMod/Effects/db/Misc/MiscQuickSprunkStop.cpp @@ -17,9 +17,7 @@ static void OnStart() REQUEST_SCRIPT(scriptName); while (!HAS_SCRIPT_LOADED(scriptName)) - { WAIT(0); - } START_NEW_SCRIPT_WITH_ARGS(scriptName, (Any *)&obj, 1, 512); } diff --git a/ChaosMod/Effects/db/Misc/MiscRainbowWeps.cpp b/ChaosMod/Effects/db/Misc/MiscRainbowWeps.cpp index 6672d8702..8036c4cc5 100644 --- a/ChaosMod/Effects/db/Misc/MiscRainbowWeps.cpp +++ b/ChaosMod/Effects/db/Misc/MiscRainbowWeps.cpp @@ -17,12 +17,8 @@ static void OnTick() } for (auto prop : GetAllProps()) - { if (IS_PICKUP_WEAPON_OBJECT_VALID(prop)) - { SET_WEAPON_OBJECT_TINT_INDEX(prop, g_Random.GetRandomInt(1, 7)); - } - } } } diff --git a/ChaosMod/Effects/db/Misc/MiscRampJam.cpp b/ChaosMod/Effects/db/Misc/MiscRampJam.cpp index 3c2d2c921..1bb10e9b8 100644 --- a/ChaosMod/Effects/db/Misc/MiscRampJam.cpp +++ b/ChaosMod/Effects/db/Misc/MiscRampJam.cpp @@ -13,9 +13,7 @@ static void OnTick() auto playerPed = PLAYER_PED_ID(); auto veh = GET_VEHICLE_PED_IS_IN(playerPed, false); if (!IS_PED_IN_ANY_VEHICLE(playerPed, false) || !IS_VEHICLE_ON_ALL_WHEELS(veh)) - { return; - } DisplayHelpText("Press ~INPUT_JUMP~ to do a sick ramp jump in your vehicle."); diff --git a/ChaosMod/Effects/db/Misc/MiscRollCredits.cpp b/ChaosMod/Effects/db/Misc/MiscRollCredits.cpp index 4795c2bd7..a3a4d7a9f 100644 --- a/ChaosMod/Effects/db/Misc/MiscRollCredits.cpp +++ b/ChaosMod/Effects/db/Misc/MiscRollCredits.cpp @@ -14,9 +14,7 @@ static void OnStart() REQUEST_ADDITIONAL_TEXT("CREDIT", 0); while (!HAS_ADDITIONAL_TEXT_LOADED(0)) - { WAIT(0); - } PLAY_END_CREDITS_MUSIC(true); SET_CREDITS_ACTIVE(true); @@ -24,17 +22,11 @@ static void OnStart() int song = g_Random.GetRandomInt(0, 2); if (song == 0) - { SET_CUSTOM_RADIO_TRACK_LIST("RADIO_16_SILVERLAKE", "END_CREDITS_SAVE_MICHAEL_TREVOR", 1); - } else if (song == 1) - { SET_CUSTOM_RADIO_TRACK_LIST("RADIO_16_SILVERLAKE", "END_CREDITS_KILL_MICHAEL", 1); - } else - { SET_CUSTOM_RADIO_TRACK_LIST("RADIO_16_SILVERLAKE", "END_CREDITS_KILL_TREVOR", 1); - } } static void OnStop() diff --git a/ChaosMod/Effects/db/Misc/MiscSolidProps.cpp b/ChaosMod/Effects/db/Misc/MiscSolidProps.cpp index c09801635..e2f916464 100644 --- a/ChaosMod/Effects/db/Misc/MiscSolidProps.cpp +++ b/ChaosMod/Effects/db/Misc/MiscSolidProps.cpp @@ -7,17 +7,13 @@ static void OnTick() { for (Entity prop : GetAllProps()) - { SET_DISABLE_BREAKING(prop, true); - } } static void OnStop() { for (Entity prop : GetAllProps()) - { SET_DISABLE_BREAKING(prop, false); - } } // clang-format off diff --git a/ChaosMod/Effects/db/Misc/MiscStuffGuns.cpp b/ChaosMod/Effects/db/Misc/MiscStuffGuns.cpp index d4cdca928..a3fb45b30 100644 --- a/ChaosMod/Effects/db/Misc/MiscStuffGuns.cpp +++ b/ChaosMod/Effects/db/Misc/MiscStuffGuns.cpp @@ -36,15 +36,11 @@ static void OnTick() for (int i = 0; i < thingCount; i++) { if (i > 0) - { WAIT(0); - } Vector3 spawnPos = spawnBasePos; if (isShotgun) - { spawnPos.z = spawnBasePos.z - .25f + i * .25f; - } int objType = GET_RANDOM_INT_IN_RANGE(0, 3); @@ -58,9 +54,7 @@ static void OnTick() { case 0: for (Entity prop : GetAllProps()) - { props.push_back(prop); - } if (!props.empty()) { Entity thingProp = props[g_Random.GetRandomInt(0, props.size() - 1)]; @@ -69,9 +63,7 @@ static void OnTick() break; case 1: for (Ped ped : GetAllPeds()) - { peds.push_back(ped); - } if (!peds.empty()) { Ped thingPed = peds[g_Random.GetRandomInt(0, peds.size() - 1)]; @@ -81,9 +73,7 @@ static void OnTick() case 2: std::vector vehs; for (Vehicle veh : GetAllVehs()) - { vehs.push_back(veh); - } if (!vehs.empty()) { Vehicle thingVeh = vehs[g_Random.GetRandomInt(0, vehs.size() - 1)]; diff --git a/ChaosMod/Effects/db/Misc/MiscTotalChaos.cpp b/ChaosMod/Effects/db/Misc/MiscTotalChaos.cpp index 12f2fa464..d22d445ca 100644 --- a/ChaosMod/Effects/db/Misc/MiscTotalChaos.cpp +++ b/ChaosMod/Effects/db/Misc/MiscTotalChaos.cpp @@ -29,17 +29,11 @@ static void OnTick() Vehicle playerVeh = GET_VEHICLE_PED_IS_IN(playerPed, false); for (Vehicle veh : GetAllVehs()) - { if (veh != playerVeh) - { Memory::ApplyForceToEntity(veh, 3, 10.f, .1f, .1f, 0, 0, 0, 0, true, true, true, false, true); - } - } for (Object prop : GetAllProps()) - { Memory::ApplyForceToEntity(prop, 3, 10.f, 5.f, .1f, 0, 0, 0, 0, true, true, true, false, true); - } DWORD64 curTick = GET_GAME_TIMER(); @@ -53,27 +47,21 @@ static void OnTick() // Make sure weather is always set to thunder after the transition if (ms_AnchorTick < curTick - 2000) - { SET_WEATHER_TYPE_NOW("THUNDER"); - } // Random right / left steering if (IS_PED_IN_ANY_VEHICLE(playerPed, false)) { Vehicle playerVeh = GET_VEHICLE_PED_IS_IN(playerPed, false); if (GET_PED_IN_VEHICLE_SEAT(playerVeh, -1, 0) != playerPed) - { return; - } static DWORD64 timeUntilSteer = GET_GAME_TIMER(); static bool enableDrunkSteering = false; static float steering; if (enableDrunkSteering) - { SET_VEHICLE_STEER_BIAS(playerVeh, steering); - } DWORD64 curTick = GET_GAME_TIMER(); diff --git a/ChaosMod/Effects/db/Misc/MiscUTurn.cpp b/ChaosMod/Effects/db/Misc/MiscUTurn.cpp index acd24b02d..74975ffe4 100644 --- a/ChaosMod/Effects/db/Misc/MiscUTurn.cpp +++ b/ChaosMod/Effects/db/Misc/MiscUTurn.cpp @@ -12,19 +12,13 @@ static void OnStart() float camHeading = GET_GAMEPLAY_CAM_RELATIVE_HEADING(); for (auto ped : GetAllPeds()) - { entities.push_back(ped); - } for (auto veh : GetAllVehs()) - { entities.push_back(veh); - } for (auto prop : GetAllProps()) - { entities.push_back(prop); - } for (auto veh : entities) { @@ -45,9 +39,7 @@ static void OnStartFake() OnStart(); if (ComponentExists()) - { GetComponent()->OverrideEffectNameId("misc_fakeuturn", "misc_uturn"); - } WAIT(g_Random.GetRandomInt(6000, 9000)); diff --git a/ChaosMod/Effects/db/Misc/MiscWhaleRain.cpp b/ChaosMod/Effects/db/Misc/MiscWhaleRain.cpp index f0228d2fc..57dd2fcdf 100644 --- a/ChaosMod/Effects/db/Misc/MiscWhaleRain.cpp +++ b/ChaosMod/Effects/db/Misc/MiscWhaleRain.cpp @@ -64,9 +64,7 @@ static void OnTick() if (HAS_ENTITY_COLLIDED_WITH_ANYTHING(whale)) { if (lastTick2 < curTick - 1000) - { whaleDespawnTime[i]--; - } } continue; } @@ -81,9 +79,7 @@ static void OnTick() } if (lastTick2 < curTick - 1000) - { lastTick2 = curTick; - } } // clang-format off diff --git a/ChaosMod/Effects/db/Misc/MiscWitnessProtection.cpp b/ChaosMod/Effects/db/Misc/MiscWitnessProtection.cpp index 0daf3c775..7226aef9c 100644 --- a/ChaosMod/Effects/db/Misc/MiscWitnessProtection.cpp +++ b/ChaosMod/Effects/db/Misc/MiscWitnessProtection.cpp @@ -48,9 +48,7 @@ static void OnTick() } Entity entityToCircle = player; if (IS_PED_IN_ANY_VEHICLE(player, false)) - { entityToCircle = GET_VEHICLE_PED_IS_IN(player, false); - } Vector3 pos = GET_ENTITY_COORDS(entityToCircle, false); Vector3 min; Vector3 max; diff --git a/ChaosMod/Effects/db/Peds/Peds2xAnimationSpeed.cpp b/ChaosMod/Effects/db/Peds/Peds2xAnimationSpeed.cpp index 7277cf688..0abd2a1d9 100644 --- a/ChaosMod/Effects/db/Peds/Peds2xAnimationSpeed.cpp +++ b/ChaosMod/Effects/db/Peds/Peds2xAnimationSpeed.cpp @@ -7,9 +7,7 @@ static void OnTick() { for (Ped ped : GetAllPeds()) - { SET_PED_RESET_FLAG(ped, 50, true); - } } // clang-format off diff --git a/ChaosMod/Effects/db/Peds/PedsAttackPlayer.cpp b/ChaosMod/Effects/db/Peds/PedsAttackPlayer.cpp index aafcf205b..1f1afba1a 100644 --- a/ChaosMod/Effects/db/Peds/PedsAttackPlayer.cpp +++ b/ChaosMod/Effects/db/Peds/PedsAttackPlayer.cpp @@ -23,9 +23,7 @@ static void OnTick() if (!IS_PED_A_PLAYER(ped)) { if (IS_PED_IN_GROUP(ped) && GET_PED_GROUP_INDEX(ped) == playerGroup) - { REMOVE_PED_FROM_GROUP(ped); - } SET_PED_RELATIONSHIP_GROUP_HASH(ped, enemyGroupHash); diff --git a/ChaosMod/Effects/db/Peds/PedsCatGuns.cpp b/ChaosMod/Effects/db/Peds/PedsCatGuns.cpp index a4bdab7da..cc3c4461e 100644 --- a/ChaosMod/Effects/db/Peds/PedsCatGuns.cpp +++ b/ChaosMod/Effects/db/Peds/PedsCatGuns.cpp @@ -39,15 +39,11 @@ static void OnTick() for (int i = 0; i < catCount; i++) { if (i > 0) - { WAIT(0); - } Vector3 spawnPos = spawnBasePos; if (isShotgun) - { spawnPos.z = spawnBasePos.z - .25f + i * .25f; - } Ped cat = CREATE_PED(28, catHash, spawnPos.x, spawnPos.y, spawnPos.z, .0f, true, false); SET_ENTITY_ROTATION(cat, spawnRot.x, spawnRot.y, spawnRot.z, 2, true); diff --git a/ChaosMod/Effects/db/Peds/PedsCops.cpp b/ChaosMod/Effects/db/Peds/PedsCops.cpp index f7eef6295..129fd67df 100644 --- a/ChaosMod/Effects/db/Peds/PedsCops.cpp +++ b/ChaosMod/Effects/db/Peds/PedsCops.cpp @@ -7,9 +7,7 @@ static void OnTick() Ped pedType = GET_PED_TYPE(ped); if (!IS_PED_A_PLAYER(ped) && pedType != 0 && pedType != 1 && pedType != 2) - { SET_PED_AS_COP(ped, true); - } } } diff --git a/ChaosMod/Effects/db/Peds/PedsEternalScreams.cpp b/ChaosMod/Effects/db/Peds/PedsEternalScreams.cpp index 332f61164..0e61b3de2 100644 --- a/ChaosMod/Effects/db/Peds/PedsEternalScreams.cpp +++ b/ChaosMod/Effects/db/Peds/PedsEternalScreams.cpp @@ -7,9 +7,7 @@ static void OnTick() { for (Ped ped : GetAllPeds()) - { PLAY_PAIN(ped, 8, 0, 0); - } } // clang-format off diff --git a/ChaosMod/Effects/db/Peds/PedsExplosiveCombat.cpp b/ChaosMod/Effects/db/Peds/PedsExplosiveCombat.cpp index 80ba252e7..d17dbc9bb 100644 --- a/ChaosMod/Effects/db/Peds/PedsExplosiveCombat.cpp +++ b/ChaosMod/Effects/db/Peds/PedsExplosiveCombat.cpp @@ -10,12 +10,8 @@ static void OnTick() Vector3 impactCoords; for (Ped ped : GetAllPeds()) - { if (GET_PED_LAST_WEAPON_IMPACT_COORD(ped, &impactCoords)) - { ADD_EXPLOSION(impactCoords.x, impactCoords.y, impactCoords.z, 4, 9999.f, true, false, 1.f, false); - } - } } // clang-format off diff --git a/ChaosMod/Effects/db/Peds/PedsFollowPlayer.cpp b/ChaosMod/Effects/db/Peds/PedsFollowPlayer.cpp index 110d5c742..a44655079 100644 --- a/ChaosMod/Effects/db/Peds/PedsFollowPlayer.cpp +++ b/ChaosMod/Effects/db/Peds/PedsFollowPlayer.cpp @@ -10,12 +10,8 @@ static void OnStart() static void OnStop() { for (Ped ped : GetAllPeds()) - { if (!IS_PED_A_PLAYER(ped)) - { SET_BLOCKING_OF_NON_TEMPORARY_EVENTS(ped, false); - } - } } static void OnTick() @@ -25,9 +21,7 @@ static void OnTick() Vehicle playerVeh = GET_VEHICLE_PED_IS_IN(playerPed, false); if (isPlayerInAnyVeh) - { ms_SavedPlayerVeh = playerVeh; - } static DWORD64 lastTick = GET_GAME_TIMER(); DWORD64 curTick = GET_GAME_TIMER(); @@ -56,9 +50,7 @@ static void OnTick() || (isPedGettingInAnyVeh && pedTargetVeh == ms_SavedPlayerVeh)) { if (GET_PED_IN_VEHICLE_SEAT(ms_SavedPlayerVeh, -1, 0) == ped) - { TASK_VEHICLE_DRIVE_WANDER(ped, ms_SavedPlayerVeh, 9999.f, 10); - } } else { diff --git a/ChaosMod/Effects/db/Peds/PedsFrozen.cpp b/ChaosMod/Effects/db/Peds/PedsFrozen.cpp index 05d30b283..447414aa9 100644 --- a/ChaosMod/Effects/db/Peds/PedsFrozen.cpp +++ b/ChaosMod/Effects/db/Peds/PedsFrozen.cpp @@ -3,9 +3,7 @@ static void OnStop() { for (Ped ped : GetAllPeds()) - { SET_PED_CONFIG_FLAG(ped, 292, false); - } } static void OnTick() @@ -54,9 +52,7 @@ static void OnTick() > 50.f) { if (pedExists) - { SET_PED_CONFIG_FLAG(ped, 292, false); - } it = wentThroughPeds.erase(it); } diff --git a/ChaosMod/Effects/db/Peds/PedsGiveProps.cpp b/ChaosMod/Effects/db/Peds/PedsGiveProps.cpp index a6cbf0b5b..202d4ecf6 100644 --- a/ChaosMod/Effects/db/Peds/PedsGiveProps.cpp +++ b/ChaosMod/Effects/db/Peds/PedsGiveProps.cpp @@ -18,17 +18,13 @@ static void OnStart() GET_MODEL_DIMENSIONS(model, &min, &max); float modelSize = (max - min).Length(); if (modelSize > 0.3f && modelSize <= 6.f) - { models.push_back(model); - } } for (Ped ped : GetAllPeds()) { if (count >= maxCount) - { break; - } Hash selectedModel = models.at(g_Random.GetRandomInt(0, models.size() - 1)); Object obj = CreatePoolPropAttachedToPed(selectedModel, ped, GET_PED_BONE_INDEX(ped, 0xDEAD), 0, 0, 0, 0, 0, 0, false, false, true); diff --git a/ChaosMod/Effects/db/Peds/PedsGrappleGuns.cpp b/ChaosMod/Effects/db/Peds/PedsGrappleGuns.cpp index d8642ffd7..c690e8d5c 100644 --- a/ChaosMod/Effects/db/Peds/PedsGrappleGuns.cpp +++ b/ChaosMod/Effects/db/Peds/PedsGrappleGuns.cpp @@ -7,19 +7,13 @@ static void OnStart() { for (Ped ped : GetAllPeds()) - { CLEAR_ENTITY_LAST_WEAPON_DAMAGE(ped); - } for (Vehicle veh : GetAllVehs()) - { CLEAR_ENTITY_LAST_WEAPON_DAMAGE(veh); - } for (Entity prop : GetAllProps()) - { CLEAR_ENTITY_LAST_WEAPON_DAMAGE(prop); - } } static Entity GetLastEntityShotBy(Ped attacker) @@ -82,9 +76,7 @@ static void OnTick() if (entity && DOES_ENTITY_EXIST(entity)) { if (IS_ENTITY_A_PED(entity) && !IS_PED_A_PLAYER(entity) && !IS_PED_IN_ANY_VEHICLE(entity, false)) - { SET_PED_TO_RAGDOLL(entity, 500, 500, 0, false, false, false); - } Vector3 entityVelocity = GET_ENTITY_VELOCITY(entity); diff --git a/ChaosMod/Effects/db/Peds/PedsGunsmoke.cpp b/ChaosMod/Effects/db/Peds/PedsGunsmoke.cpp index 9e7b59678..d9f478618 100644 --- a/ChaosMod/Effects/db/Peds/PedsGunsmoke.cpp +++ b/ChaosMod/Effects/db/Peds/PedsGunsmoke.cpp @@ -8,9 +8,7 @@ static void OnTick() { REQUEST_NAMED_PTFX_ASSET("scr_sr_tr"); while (!HAS_NAMED_PTFX_ASSET_LOADED("scr_sr_tr")) - { WAIT(0); - } for (Ped ped : GetAllPeds()) { if (IS_PED_SHOOTING(ped)) diff --git a/ChaosMod/Effects/db/Peds/PedsHeadless.cpp b/ChaosMod/Effects/db/Peds/PedsHeadless.cpp index d11ebb4f6..1740fb6a2 100644 --- a/ChaosMod/Effects/db/Peds/PedsHeadless.cpp +++ b/ChaosMod/Effects/db/Peds/PedsHeadless.cpp @@ -7,9 +7,7 @@ static void OnTick() { for (Ped ped : GetAllPeds()) - { SET_PED_RESET_FLAG(ped, 166, true); - } } // clang-format off diff --git a/ChaosMod/Effects/db/Peds/PedsHotCougars.cpp b/ChaosMod/Effects/db/Peds/PedsHotCougars.cpp index 56008ecd1..7141c6f17 100644 --- a/ChaosMod/Effects/db/Peds/PedsHotCougars.cpp +++ b/ChaosMod/Effects/db/Peds/PedsHotCougars.cpp @@ -17,9 +17,7 @@ static void OnStop() REMOVE_NAMED_PTFX_ASSET("des_trailerpark"); for (Ped ped : cougarEnemies) - { SET_PED_AS_NO_LONGER_NEEDED(&ped); - } cougarEnemies.clear(); } @@ -28,9 +26,7 @@ static void OnTick() { REQUEST_NAMED_PTFX_ASSET("des_trailerpark"); while (!HAS_NAMED_PTFX_ASSET_LOADED("des_trailerpark")) - { WAIT(0); - } Ped playerPed = PLAYER_PED_ID(); Vector3 playerPos = GET_ENTITY_COORDS(playerPed, false); @@ -63,13 +59,9 @@ static void OnTick() it++; if (IS_PED_IN_ANY_VEHICLE(playerPed, true)) - { TASK_ENTER_VEHICLE(cougar, GET_VEHICLE_PED_IS_IN(playerPed, false), -1, -2, 2.f, 1, 0); - } else - { TASK_COMBAT_PED(cougar, playerPed, 0, 16); - } SET_BLOCKING_OF_NON_TEMPORARY_EVENTS(cougar, true); } diff --git a/ChaosMod/Effects/db/Peds/PedsIgniteNearby.cpp b/ChaosMod/Effects/db/Peds/PedsIgniteNearby.cpp index 6a4863ce1..49302bc5f 100644 --- a/ChaosMod/Effects/db/Peds/PedsIgniteNearby.cpp +++ b/ChaosMod/Effects/db/Peds/PedsIgniteNearby.cpp @@ -3,12 +3,8 @@ static void OnStart() { for (Ped ped : GetAllPeds()) - { if (!IS_PED_A_PLAYER(ped)) - { START_ENTITY_FIRE(ped); - } - } } // clang-format off diff --git a/ChaosMod/Effects/db/Peds/PedsIntoRandomVehs.cpp b/ChaosMod/Effects/db/Peds/PedsIntoRandomVehs.cpp index 2c0df5283..563c9eeb8 100644 --- a/ChaosMod/Effects/db/Peds/PedsIntoRandomVehs.cpp +++ b/ChaosMod/Effects/db/Peds/PedsIntoRandomVehs.cpp @@ -7,9 +7,7 @@ static void OnStart() WAIT(0); if (!IS_PED_IN_ANY_VEHICLE(ped, true)) - { continue; - } Vector3 pedPos = GET_ENTITY_COORDS(ped, false); SET_ENTITY_COORDS(ped, pedPos.x, pedPos.y, pedPos.z + 5.f, false, false, false, false); @@ -22,9 +20,7 @@ static void OnStart() // May crash, if you try to put a whale into the driver seat + ped may not be valid anymore after several // "WAIT"s if (!DOES_ENTITY_EXIST(ped) || !IS_PED_HUMAN(ped)) - { continue; - } std::vector vehs; for (Vehicle veh : GetAllVehs()) @@ -37,9 +33,7 @@ static void OnStart() } if (vehs.empty()) - { return; - } Vehicle targetVeh = vehs[g_Random.GetRandomInt(0, vehs.size() - 1)]; Hash targetVehModel = GET_ENTITY_MODEL(targetVeh); diff --git a/ChaosMod/Effects/db/Peds/PedsInvinciblePeds.cpp b/ChaosMod/Effects/db/Peds/PedsInvinciblePeds.cpp index d064a105e..3b9070bfc 100644 --- a/ChaosMod/Effects/db/Peds/PedsInvinciblePeds.cpp +++ b/ChaosMod/Effects/db/Peds/PedsInvinciblePeds.cpp @@ -3,17 +3,13 @@ static void OnStop() { for (auto ped : GetAllPeds()) - { SET_ENTITY_INVINCIBLE(ped, false); - } } static void OnTick() { for (auto ped : GetAllPeds()) - { SET_ENTITY_INVINCIBLE(ped, true); - } } // clang-format off diff --git a/ChaosMod/Effects/db/Peds/PedsInvisiblePeds.cpp b/ChaosMod/Effects/db/Peds/PedsInvisiblePeds.cpp index da17d24c0..a9d1b1189 100644 --- a/ChaosMod/Effects/db/Peds/PedsInvisiblePeds.cpp +++ b/ChaosMod/Effects/db/Peds/PedsInvisiblePeds.cpp @@ -3,17 +3,13 @@ static void OnStop() { for (auto ped : GetAllPeds()) - { RESET_ENTITY_ALPHA(ped); - } } static void OnTick() { for (auto ped : GetAllPeds()) - { SET_ENTITY_ALPHA(ped, 0, 0); - } } // clang-format off diff --git a/ChaosMod/Effects/db/Peds/PedsJumpy.cpp b/ChaosMod/Effects/db/Peds/PedsJumpy.cpp index e29b15e44..5b6ca17b7 100644 --- a/ChaosMod/Effects/db/Peds/PedsJumpy.cpp +++ b/ChaosMod/Effects/db/Peds/PedsJumpy.cpp @@ -3,12 +3,8 @@ static void OnTick() { for (Ped ped : GetAllPeds()) - { if (!IS_PED_IN_ANY_VEHICLE(ped, false) && !IS_PED_A_PLAYER(ped) && !IS_ENTITY_A_MISSION_ENTITY(ped)) - { TASK_JUMP(ped, false, false, false); - } - } } // clang-format off diff --git a/ChaosMod/Effects/db/Peds/PedsKillerClowns.cpp b/ChaosMod/Effects/db/Peds/PedsKillerClowns.cpp index 0fe9b9e15..5e8741485 100644 --- a/ChaosMod/Effects/db/Peds/PedsKillerClowns.cpp +++ b/ChaosMod/Effects/db/Peds/PedsKillerClowns.cpp @@ -17,21 +17,13 @@ static Vector3 getRandomOffsetCoord(Vector3 startCoord, int minOffset, int maxOf for (int i = 0; i < 10; i++) { if (g_Random.GetRandomInt(0, 1) % 2 == 0) - { randomCoord.x = startCoord.x + g_Random.GetRandomInt(minOffset, maxOffset); - } else - { randomCoord.x = startCoord.x - g_Random.GetRandomInt(minOffset, maxOffset); - } if (g_Random.GetRandomInt(0, 1) % 2 == 0) - { randomCoord.y = startCoord.y + g_Random.GetRandomInt(minOffset, maxOffset); - } else - { randomCoord.y = startCoord.y - g_Random.GetRandomInt(minOffset, maxOffset); - } randomCoord.z = startCoord.z; if (GET_GROUND_Z_FOR_3D_COORD(randomCoord.x, randomCoord.y, randomCoord.z, &groundZ, false, false)) { @@ -47,9 +39,7 @@ static void OnStop() REMOVE_NAMED_PTFX_ASSET("scr_rcbarry2"); for (Ped ped : clownEnemies) - { SET_PED_AS_NO_LONGER_NEEDED(&ped); - } clownEnemies.clear(); } @@ -67,9 +57,7 @@ static void OnTick() { REQUEST_NAMED_PTFX_ASSET("scr_rcbarry2"); while (!HAS_NAMED_PTFX_ASSET_LOADED("scr_rcbarry2")) - { WAIT(0); - } Ped playerPed = PLAYER_PED_ID(); Vector3 playerPos = GET_ENTITY_COORDS(playerPed, false); diff --git a/ChaosMod/Effects/db/Peds/PedsLooseTrigger.cpp b/ChaosMod/Effects/db/Peds/PedsLooseTrigger.cpp index 6614ec322..999634547 100644 --- a/ChaosMod/Effects/db/Peds/PedsLooseTrigger.cpp +++ b/ChaosMod/Effects/db/Peds/PedsLooseTrigger.cpp @@ -7,9 +7,7 @@ static void OnStop() { for (Ped ped : GetAllPeds()) - { SET_PED_INFINITE_AMMO_CLIP(ped, false); - } } static void OnTick() diff --git a/ChaosMod/Effects/db/Peds/PedsMercenaries.cpp b/ChaosMod/Effects/db/Peds/PedsMercenaries.cpp index 743cda25c..7370af66e 100644 --- a/ChaosMod/Effects/db/Peds/PedsMercenaries.cpp +++ b/ChaosMod/Effects/db/Peds/PedsMercenaries.cpp @@ -20,21 +20,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); - } else - { randomCoord.x = startCoord.x - g_Random.GetRandomInt(minOffset, maxOffset); - } if (g_Random.GetRandomInt(0, 1) % 2 == 0) - { randomCoord.y = startCoord.y + g_Random.GetRandomInt(minOffset, maxOffset); - } else - { randomCoord.y = startCoord.y - g_Random.GetRandomInt(minOffset, maxOffset); - } randomCoord.z = startCoord.z; return randomCoord; } @@ -101,9 +93,7 @@ static void spawnMesa() spawnPoint = getRandomOffsetCoord(playerPos, 50, 50); float groundZ; if (GET_GROUND_Z_FOR_3D_COORD(spawnPoint.x, spawnPoint.y, spawnPoint.z, &groundZ, false, false)) - { spawnPoint.z = groundZ; - } } float xDiff = playerPos.x - spawnPoint.x; float yDiff = playerPos.y - spawnPoint.y; @@ -142,14 +132,10 @@ static void OnStop() { SET_VEHICLE_AS_NO_LONGER_NEEDED(&helicopterGroup.vehicle); for (Ped ped : helicopterGroup.peds) - { SET_PED_AS_NO_LONGER_NEEDED(&ped); - } SET_VEHICLE_AS_NO_LONGER_NEEDED(&mesaGroup.vehicle); for (Ped ped : mesaGroup.peds) - { SET_PED_AS_NO_LONGER_NEEDED(&ped); - } } static bool checkPedsAlive(std::vector pedList) diff --git a/ChaosMod/Effects/db/Peds/PedsMinions.cpp b/ChaosMod/Effects/db/Peds/PedsMinions.cpp index 799dfd271..c2a639edd 100644 --- a/ChaosMod/Effects/db/Peds/PedsMinions.cpp +++ b/ChaosMod/Effects/db/Peds/PedsMinions.cpp @@ -11,12 +11,8 @@ static void OnStop() Hooks::ResetAudioPitch(); for (Ped pd : GetAllPeds()) - { if (GET_PED_CONFIG_FLAG(pd, 223, true)) - { SET_PED_CONFIG_FLAG(pd, 223, false); - } - } } static void OnTick() @@ -24,12 +20,8 @@ static void OnTick() Hooks::SetAudioPitch(300); for (Ped pd : GetAllPeds()) - { if (!GET_PED_CONFIG_FLAG(pd, 223, true)) - { SET_PED_CONFIG_FLAG(pd, 223, true); - } - } } // clang-format off diff --git a/ChaosMod/Effects/db/Peds/PedsNailguns.cpp b/ChaosMod/Effects/db/Peds/PedsNailguns.cpp index 4052377bf..e074f8438 100644 --- a/ChaosMod/Effects/db/Peds/PedsNailguns.cpp +++ b/ChaosMod/Effects/db/Peds/PedsNailguns.cpp @@ -61,29 +61,21 @@ static void OnTick() } if (HAS_ENTITY_BEEN_DAMAGED_BY_ANY_PED(ped) && !isFrozen(ped)) - { frozenPeds.push_back(ped); - } if (isFrozen(ped)) - { FREEZE_ENTITY_POSITION(ped, true); - } } } static void OnStop() { for (const Ped ped : frozenPeds) - { FREEZE_ENTITY_POSITION(ped, false); - } // (kolyaventuri): Reshow weapons for (std::map::iterator it = heldWeapons.begin(); it != heldWeapons.end(); ++it) - { SET_ENTITY_VISIBLE(it->second, true, 0); - } // (kolyaventuri): Remove weapons for (std::map::iterator it = pedGuns.begin(); it != pedGuns.end(); ++it) diff --git a/ChaosMod/Effects/db/Peds/PedsNoRagdoll.cpp b/ChaosMod/Effects/db/Peds/PedsNoRagdoll.cpp index 4cebd4cb7..4c513b4dd 100644 --- a/ChaosMod/Effects/db/Peds/PedsNoRagdoll.cpp +++ b/ChaosMod/Effects/db/Peds/PedsNoRagdoll.cpp @@ -3,17 +3,13 @@ static void OnStop() { for (auto ped : GetAllPeds()) - { SET_PED_CAN_RAGDOLL(ped, true); - } } static void OnTick() { for (auto ped : GetAllPeds()) - { SET_PED_CAN_RAGDOLL(ped, false); - } } // clang-format off diff --git a/ChaosMod/Effects/db/Peds/PedsNotMenendez.cpp b/ChaosMod/Effects/db/Peds/PedsNotMenendez.cpp index 3da4f00d1..b21babac2 100644 --- a/ChaosMod/Effects/db/Peds/PedsNotMenendez.cpp +++ b/ChaosMod/Effects/db/Peds/PedsNotMenendez.cpp @@ -39,12 +39,8 @@ static void OnStart() deadPeds = {}; for (Ped ped : GetAllPeds()) - { if (IS_ENTITY_DEAD(ped, false)) - { deadPeds.insert(ped); - } - } } // clang-format off diff --git a/ChaosMod/Effects/db/Peds/PedsOHKO.cpp b/ChaosMod/Effects/db/Peds/PedsOHKO.cpp index 27fe325e3..8dd11dbed 100644 --- a/ChaosMod/Effects/db/Peds/PedsOHKO.cpp +++ b/ChaosMod/Effects/db/Peds/PedsOHKO.cpp @@ -5,12 +5,8 @@ static void OnStop() SET_PLAYER_HEALTH_RECHARGE_MULTIPLIER(PLAYER_ID(), 1.f); for (Ped ped : GetAllPeds()) - { if (!IS_PED_DEAD_OR_DYING(ped, true)) - { SET_ENTITY_HEALTH(ped, GET_PED_MAX_HEALTH(ped), 0); - } - } } static void OnTick() @@ -18,9 +14,7 @@ static void OnTick() Hash playerHash = GET_ENTITY_MODEL(PLAYER_PED_ID()); // trevor if (playerHash == 2608926626) - { _SET_SPECIAL_ABILITY(PLAYER_ID(), 0, 0); - } SET_PLAYER_HEALTH_RECHARGE_MULTIPLIER(PLAYER_ID(), .0f); diff --git a/ChaosMod/Effects/db/Peds/PedsPhones.cpp b/ChaosMod/Effects/db/Peds/PedsPhones.cpp index 1296f4af0..8a0ec79e2 100644 --- a/ChaosMod/Effects/db/Peds/PedsPhones.cpp +++ b/ChaosMod/Effects/db/Peds/PedsPhones.cpp @@ -7,20 +7,14 @@ static void OnTick() { for (auto ped : GetAllPeds()) - { if (!IS_PED_RINGTONE_PLAYING(ped)) - { PLAY_PED_RINGTONE("Remote_Ring", ped, 1); - } - } } static void OnStop() { for (auto ped : GetAllPeds()) - { STOP_PED_RINGTONE(ped); - } } // clang-format off diff --git a/ChaosMod/Effects/db/Peds/PedsPropHunt.cpp b/ChaosMod/Effects/db/Peds/PedsPropHunt.cpp index 3b52c5e0c..a50cf6c35 100644 --- a/ChaosMod/Effects/db/Peds/PedsPropHunt.cpp +++ b/ChaosMod/Effects/db/Peds/PedsPropHunt.cpp @@ -35,9 +35,7 @@ static void OnTick() // Don't include models that are either very small or very large if (modelSize > 0.3f && modelSize <= 6.f) - { availablePropModels.push_back(model); - } } } @@ -90,9 +88,7 @@ static void OnTick() if (!DOES_ENTITY_EXIST(ped)) { if (DOES_ENTITY_EXIST(prop)) - { DELETE_OBJECT(&prop); - } it = pedPropsMap.erase(it); } @@ -102,9 +98,7 @@ static void OnTick() SET_ENTITY_VISIBLE(ped, true, 0); if (DOES_ENTITY_EXIST(prop)) - { DELETE_OBJECT(&prop); - } it = pedPropsMap.erase(it); } @@ -147,14 +141,10 @@ static void OnStop() Object prop = it.second; if (DOES_ENTITY_EXIST(ped)) - { SET_ENTITY_VISIBLE(ped, true, 0); - } if (DOES_ENTITY_EXIST(prop)) - { DELETE_OBJECT(&prop); - } } pedPropsMap.clear(); diff --git a/ChaosMod/Effects/db/Peds/PedsRagdollOnTouch.cpp b/ChaosMod/Effects/db/Peds/PedsRagdollOnTouch.cpp index dcf7b872c..4df32acfc 100644 --- a/ChaosMod/Effects/db/Peds/PedsRagdollOnTouch.cpp +++ b/ChaosMod/Effects/db/Peds/PedsRagdollOnTouch.cpp @@ -3,17 +3,13 @@ static void OnStop() { for (auto ped : GetAllPeds()) - { SET_PED_RAGDOLL_ON_COLLISION(ped, false); - } } static void OnTick() { for (auto ped : GetAllPeds()) - { SET_PED_RAGDOLL_ON_COLLISION(ped, true); - } } // clang-format off diff --git a/ChaosMod/Effects/db/Peds/PedsReflectiveDamage.cpp b/ChaosMod/Effects/db/Peds/PedsReflectiveDamage.cpp index d92cd98fb..364a5ce38 100644 --- a/ChaosMod/Effects/db/Peds/PedsReflectiveDamage.cpp +++ b/ChaosMod/Effects/db/Peds/PedsReflectiveDamage.cpp @@ -84,9 +84,7 @@ static void OnTick() } if (IS_ENTITY_DEAD(ped, false)) - { it = mappedPeds.erase(it); - } it++; } diff --git a/ChaosMod/Effects/db/Peds/PedsReviveNearby.cpp b/ChaosMod/Effects/db/Peds/PedsReviveNearby.cpp index 48bbe62e7..105db95ab 100644 --- a/ChaosMod/Effects/db/Peds/PedsReviveNearby.cpp +++ b/ChaosMod/Effects/db/Peds/PedsReviveNearby.cpp @@ -25,13 +25,9 @@ static void OnStart() Ped clone; if (isMissionEntityCorpse) - { clone = CreatePoolPed(pedType, pedModel, .0f, .0f, .0f, .0f); - } else - { clone = CREATE_PED(pedType, pedModel, .0f, .0f, .0f, .0f, true, false); - } CLONE_PED_TO_TARGET(ped, clone); @@ -68,13 +64,9 @@ static void OnStart() DELETE_PED(&ped); if (targetVeh) - { SET_PED_INTO_VEHICLE(clone, targetVeh, targetSeat); - } else - { SET_ENTITY_COORDS(clone, pedPos.x, pedPos.y, pedPos.z, false, false, false, false); - } SET_PED_RELATIONSHIP_GROUP_HASH(clone, relationshipGroup); SET_PED_HEARING_RANGE(clone, 9999.f); @@ -92,9 +84,7 @@ static void OnStart() SET_PED_FIRING_PATTERN(clone, 0xC6EE6B4C); if (!isMissionEntityCorpse) - { SET_PED_AS_NO_LONGER_NEEDED(&clone); - } } } } diff --git a/ChaosMod/Effects/db/Peds/PedsRiot.cpp b/ChaosMod/Effects/db/Peds/PedsRiot.cpp index 4ddcaf01c..d3692b0b7 100644 --- a/ChaosMod/Effects/db/Peds/PedsRiot.cpp +++ b/ChaosMod/Effects/db/Peds/PedsRiot.cpp @@ -49,16 +49,10 @@ static void OnTick() } for (std::list::iterator it = goneThroughPeds.begin(); it != goneThroughPeds.end();) - { if (!DOES_ENTITY_EXIST(*it)) - { it = goneThroughPeds.erase(it); - } else - { it++; - } - } } // clang-format off diff --git a/ChaosMod/Effects/db/Peds/PedsSlipperyPeds.cpp b/ChaosMod/Effects/db/Peds/PedsSlipperyPeds.cpp index aace594b8..81e63d730 100644 --- a/ChaosMod/Effects/db/Peds/PedsSlipperyPeds.cpp +++ b/ChaosMod/Effects/db/Peds/PedsSlipperyPeds.cpp @@ -7,12 +7,8 @@ static void OnTick() { for (Ped pd : GetAllPeds()) - { if (GET_ENTITY_SPEED(pd) > 5.2) - { SET_PED_TO_RAGDOLL(pd, 3000, 3000, 0, true, true, false); - } - } } // clang-format off diff --git a/ChaosMod/Effects/db/Peds/PedsSmokeTrails.cpp b/ChaosMod/Effects/db/Peds/PedsSmokeTrails.cpp index 0820ed987..9b685bd9a 100644 --- a/ChaosMod/Effects/db/Peds/PedsSmokeTrails.cpp +++ b/ChaosMod/Effects/db/Peds/PedsSmokeTrails.cpp @@ -13,9 +13,7 @@ static void OnStart() { REQUEST_NAMED_PTFX_ASSET(ptfxDict); while (!HAS_NAMED_PTFX_ASSET_LOADED(ptfxDict)) - { WAIT(0); - } } static void OnStop() diff --git a/ChaosMod/Effects/db/Peds/PedsSpawnAngryAlien.cpp b/ChaosMod/Effects/db/Peds/PedsSpawnAngryAlien.cpp index 80b064ade..a8246176f 100644 --- a/ChaosMod/Effects/db/Peds/PedsSpawnAngryAlien.cpp +++ b/ChaosMod/Effects/db/Peds/PedsSpawnAngryAlien.cpp @@ -36,9 +36,7 @@ static void OnStart() SET_ENTITY_HEALTH(ped, 500, 0); SET_PED_ARMOUR(ped, 500); if (IS_PED_IN_ANY_VEHICLE(playerPed, false)) - { SET_PED_INTO_VEHICLE(ped, GET_VEHICLE_PED_IS_IN(playerPed, false), -2); - } SET_PED_COMBAT_ATTRIBUTES(ped, 5, true); SET_PED_COMBAT_ATTRIBUTES(ped, 46, true); diff --git a/ChaosMod/Effects/db/Peds/PedsSpawnAngryJesus.cpp b/ChaosMod/Effects/db/Peds/PedsSpawnAngryJesus.cpp index 628fe1070..20d86d7f0 100644 --- a/ChaosMod/Effects/db/Peds/PedsSpawnAngryJesus.cpp +++ b/ChaosMod/Effects/db/Peds/PedsSpawnAngryJesus.cpp @@ -20,9 +20,7 @@ static void OnStart() auto ped = CreatePoolPed(4, modelHash, playerPos.x, playerPos.y, playerPos.z, 0.f); CurrentEffect::SetEffectSoundPlayOptions({ .PlayType = EffectSoundPlayType::FollowEntity, .Entity = ped }); if (IS_PED_IN_ANY_VEHICLE(playerPed, false)) - { SET_PED_INTO_VEHICLE(ped, GET_VEHICLE_PED_IS_IN(playerPed, false), -2); - } SET_PED_RELATIONSHIP_GROUP_HASH(ped, relationshipGroup); SET_PED_HEARING_RANGE(ped, 9999.f); diff --git a/ChaosMod/Effects/db/Peds/PedsSpawnAngryJimmy.cpp b/ChaosMod/Effects/db/Peds/PedsSpawnAngryJimmy.cpp index 1ee239828..9f0ca27c3 100644 --- a/ChaosMod/Effects/db/Peds/PedsSpawnAngryJimmy.cpp +++ b/ChaosMod/Effects/db/Peds/PedsSpawnAngryJimmy.cpp @@ -23,9 +23,7 @@ static void OnStart() Ped ped = CreatePoolPed(4, modelHash, playerPos.x, playerPos.y, playerPos.z, 0.f); if (IS_PED_IN_ANY_VEHICLE(playerPed, false)) - { SET_PED_INTO_VEHICLE(ped, GET_VEHICLE_PED_IS_IN(playerPed, false), -2); - } SET_PED_RELATIONSHIP_GROUP_HASH(ped, relationshipGroup); SET_PED_HEARING_RANGE(ped, 9999.f); diff --git a/ChaosMod/Effects/db/Peds/PedsSpawnBallaSquad.cpp b/ChaosMod/Effects/db/Peds/PedsSpawnBallaSquad.cpp index 041ec651b..22d627778 100644 --- a/ChaosMod/Effects/db/Peds/PedsSpawnBallaSquad.cpp +++ b/ChaosMod/Effects/db/Peds/PedsSpawnBallaSquad.cpp @@ -33,13 +33,9 @@ static void OnStart() Ped ped = CreatePoolPed(4, choosenPropHash, playerPos.x, playerPos.y, playerPos.z, GET_ENTITY_HEADING(playerPed)); if (i == 0) - { SET_PED_INTO_VEHICLE(ped, veh, -1); - } else - { SET_PED_INTO_VEHICLE(ped, veh, -2); - } SET_PED_COMBAT_ATTRIBUTES(ped, 3, false); SET_BLOCKING_OF_NON_TEMPORARY_EVENTS(ped, true); SET_PED_RELATIONSHIP_GROUP_HASH(ped, relationshipGroup); diff --git a/ChaosMod/Effects/db/Peds/PedsSpawnCompanionBrad.cpp b/ChaosMod/Effects/db/Peds/PedsSpawnCompanionBrad.cpp index ed95a3526..9b91eebb2 100644 --- a/ChaosMod/Effects/db/Peds/PedsSpawnCompanionBrad.cpp +++ b/ChaosMod/Effects/db/Peds/PedsSpawnCompanionBrad.cpp @@ -14,9 +14,7 @@ static void OnStart() Ped ped = CreatePoolPed(4, model, playerPos.x, playerPos.y, playerPos.z, GET_ENTITY_HEADING(playerPed)); if (IS_PED_IN_ANY_VEHICLE(playerPed, false)) - { SET_PED_INTO_VEHICLE(ped, GET_VEHICLE_PED_IS_IN(playerPed, false), -2); - } SET_PED_SUFFERS_CRITICAL_HITS(ped, false); diff --git a/ChaosMod/Effects/db/Peds/PedsSpawnCompanionChimp.cpp b/ChaosMod/Effects/db/Peds/PedsSpawnCompanionChimp.cpp index 142bdea4e..19d292432 100644 --- a/ChaosMod/Effects/db/Peds/PedsSpawnCompanionChimp.cpp +++ b/ChaosMod/Effects/db/Peds/PedsSpawnCompanionChimp.cpp @@ -14,9 +14,7 @@ static void OnStart() Ped ped = CreatePoolPed(28, modelHash, playerPos.x, playerPos.y, playerPos.z, GET_ENTITY_HEADING(playerPed)); if (IS_PED_IN_ANY_VEHICLE(playerPed, false)) - { SET_PED_INTO_VEHICLE(ped, GET_VEHICLE_PED_IS_IN(playerPed, false), -2); - } SET_PED_SUFFERS_CRITICAL_HITS(ped, false); diff --git a/ChaosMod/Effects/db/Peds/PedsSpawnCompanionRandom.cpp b/ChaosMod/Effects/db/Peds/PedsSpawnCompanionRandom.cpp index 0c0e95133..7034df330 100644 --- a/ChaosMod/Effects/db/Peds/PedsSpawnCompanionRandom.cpp +++ b/ChaosMod/Effects/db/Peds/PedsSpawnCompanionRandom.cpp @@ -12,9 +12,7 @@ static void OnStart() Ped ped = CreateRandomPoolPed(playerPos.x, playerPos.y, playerPos.z, GET_ENTITY_HEADING(playerPed)); if (IS_PED_IN_ANY_VEHICLE(playerPed, false)) - { SET_PED_INTO_VEHICLE(ped, GET_VEHICLE_PED_IS_IN(playerPed, false), -2); - } SET_PED_SUFFERS_CRITICAL_HITS(ped, false); diff --git a/ChaosMod/Effects/db/Peds/PedsSpawnDancingApes.cpp b/ChaosMod/Effects/db/Peds/PedsSpawnDancingApes.cpp index 1c89b5ba4..78d2847e3 100644 --- a/ChaosMod/Effects/db/Peds/PedsSpawnDancingApes.cpp +++ b/ChaosMod/Effects/db/Peds/PedsSpawnDancingApes.cpp @@ -22,9 +22,7 @@ static void OnStart() SET_PED_RELATIONSHIP_GROUP_HASH(ped, relationshipGroup); if (IS_PED_IN_ANY_VEHICLE(playerPed, false)) - { SET_PED_INTO_VEHICLE(ped, GET_VEHICLE_PED_IS_IN(playerPed, false), -2); - } SET_PED_CAN_RAGDOLL(ped, false); SET_PED_SUFFERS_CRITICAL_HITS(ped, false); diff --git a/ChaosMod/Effects/db/Peds/PedsSpawnHostileRandom.cpp b/ChaosMod/Effects/db/Peds/PedsSpawnHostileRandom.cpp index e4ef80de6..e99e96b0f 100644 --- a/ChaosMod/Effects/db/Peds/PedsSpawnHostileRandom.cpp +++ b/ChaosMod/Effects/db/Peds/PedsSpawnHostileRandom.cpp @@ -17,9 +17,7 @@ static void OnStart() Ped ped = CreateRandomPoolPed(playerPos.x, playerPos.y, playerPos.z, GET_ENTITY_HEADING(playerPed)); if (IS_PED_IN_ANY_VEHICLE(playerPed, false)) - { SET_PED_INTO_VEHICLE(ped, GET_VEHICLE_PED_IS_IN(playerPed, false), -2); - } SET_PED_RELATIONSHIP_GROUP_HASH(ped, relationshipGroup); SET_PED_HEARING_RANGE(ped, 9999.f); diff --git a/ChaosMod/Effects/db/Peds/PedsSpawnImpotentRage.cpp b/ChaosMod/Effects/db/Peds/PedsSpawnImpotentRage.cpp index 802ea16b4..cd3c21cea 100644 --- a/ChaosMod/Effects/db/Peds/PedsSpawnImpotentRage.cpp +++ b/ChaosMod/Effects/db/Peds/PedsSpawnImpotentRage.cpp @@ -36,9 +36,7 @@ static void OnStart() SET_PED_FIRING_PATTERN(ped, 0xC6EE6B4C); if (IS_PED_IN_ANY_VEHICLE(playerPed, false)) - { SET_PED_INTO_VEHICLE(ped, GET_VEHICLE_PED_IS_IN(playerPed, false), -2); - } DWORD64 lastTick = GET_GAME_TIMER(); @@ -47,17 +45,13 @@ static void OnStart() DWORD64 curTick = GET_GAME_TIMER(); if (lastTick < curTick - 500) - { break; - } WAIT(0); } for (int i = 0; i < 3; i++) - { PLAY_SOUND_FRONTEND(-1, "impotent_rage", "dlc_vw_hidden_collectible_sounds", false); - } RELEASE_NAMED_SCRIPT_AUDIO_BANK("DLC_VINEWOOD/DLC_VW_HIDDEN_COLLECTIBLES"); } diff --git a/ChaosMod/Effects/db/Peds/PedsSpawnRoastingLamar.cpp b/ChaosMod/Effects/db/Peds/PedsSpawnRoastingLamar.cpp index 4b8fbd1df..aedcc02cd 100644 --- a/ChaosMod/Effects/db/Peds/PedsSpawnRoastingLamar.cpp +++ b/ChaosMod/Effects/db/Peds/PedsSpawnRoastingLamar.cpp @@ -24,9 +24,7 @@ static void OnStart() SET_MODEL_AS_NO_LONGER_NEEDED(lamarModel); if (IS_PED_IN_ANY_VEHICLE(playerPed, false)) - { SET_PED_INTO_VEHICLE(lamarPed, GET_VEHICLE_PED_IS_IN(playerPed, false), -2); - } SET_PED_RELATIONSHIP_GROUP_HASH(lamarPed, relationshipGroup); SET_PED_AS_GROUP_MEMBER(lamarPed, GET_PLAYER_GROUP(PLAYER_ID())); @@ -80,9 +78,7 @@ static void OnTick() lastTick = curTick; if (DOES_ENTITY_EXIST(lamarPed)) - { PLAY_PED_AMBIENT_SPEECH_NATIVE(lamarPed, "GENERIC_INSULT_MED", "SPEECH_PARAMS_FORCE_SHOUTED", 1); - } } } diff --git a/ChaosMod/Effects/db/Peds/PedsSpeechController.cpp b/ChaosMod/Effects/db/Peds/PedsSpeechController.cpp index 2349a0994..0f87d0092 100644 --- a/ChaosMod/Effects/db/Peds/PedsSpeechController.cpp +++ b/ChaosMod/Effects/db/Peds/PedsSpeechController.cpp @@ -75,12 +75,8 @@ static void OnTickKifflom() lastTick = curTick; for (Ped ped : GetAllPeds()) - { if (!IS_PED_A_PLAYER(ped) && IS_PED_HUMAN(ped)) - { PLAY_PED_AMBIENT_SPEECH_NATIVE(ped, "KIFFLOM_GREET", "SPEECH_PARAMS_FORCE_SHOUTED", 1); - } - } } } diff --git a/ChaosMod/Effects/db/Peds/PedsStripWeapons.cpp b/ChaosMod/Effects/db/Peds/PedsStripWeapons.cpp index d1644b326..18db579f3 100644 --- a/ChaosMod/Effects/db/Peds/PedsStripWeapons.cpp +++ b/ChaosMod/Effects/db/Peds/PedsStripWeapons.cpp @@ -3,9 +3,7 @@ static void OnStart() { for (Ped ped : GetAllPeds()) - { REMOVE_ALL_PED_WEAPONS(ped, false); - } } // clang-format off diff --git a/ChaosMod/Effects/db/Peds/PedsTPGuns.cpp b/ChaosMod/Effects/db/Peds/PedsTPGuns.cpp index 6a06da63c..125bbfdb8 100644 --- a/ChaosMod/Effects/db/Peds/PedsTPGuns.cpp +++ b/ChaosMod/Effects/db/Peds/PedsTPGuns.cpp @@ -7,9 +7,7 @@ static void OnStart() { for (Vehicle veh : GetAllVehs()) - { CLEAR_ENTITY_LAST_WEAPON_DAMAGE(veh); - } } static void OnTick() @@ -62,9 +60,7 @@ static void OnTick() Entity toTeleport = ped; if (IS_PED_IN_ANY_VEHICLE(ped, false)) - { toTeleport = GET_VEHICLE_PED_IS_IN(ped, false); - } float heading = GET_ENTITY_HEADING(toTeleport); Vector3 vel = GET_ENTITY_VELOCITY(toTeleport); @@ -74,9 +70,7 @@ static void OnTick() SET_ENTITY_VELOCITY(toTeleport, vel.x, vel.y, vel.z); if (IS_ENTITY_A_VEHICLE(toTeleport)) - { SET_VEHICLE_FORWARD_SPEED(toTeleport, forward); - } } } } diff --git a/ChaosMod/Effects/db/Peds/PedsToast.cpp b/ChaosMod/Effects/db/Peds/PedsToast.cpp index d810d9cbf..5794e0dd6 100644 --- a/ChaosMod/Effects/db/Peds/PedsToast.cpp +++ b/ChaosMod/Effects/db/Peds/PedsToast.cpp @@ -16,9 +16,7 @@ static Hash toastModels[TOAST_MODEL_COUNT] = { "v_res_fa_bread01"_hash, "v_res_f static void RemoveHead() { for (Ped ped : GetAllPeds()) - { SET_PED_RESET_FLAG(ped, 166, true); - } } static void OnStart() @@ -76,9 +74,7 @@ static void OnTick() if (!DOES_ENTITY_EXIST(ped)) { if (DOES_ENTITY_EXIST(prop)) - { DELETE_OBJECT(&prop); - } it = pedPropsMap.erase(it); } @@ -114,17 +110,13 @@ static void OnStop() Object prop = it.second; if (DOES_ENTITY_EXIST(prop)) - { DELETE_OBJECT(&prop); - } } pedPropsMap.clear(); for (int i = 0; i < TOAST_MODEL_COUNT; ++i) - { availablePropModels[i] = 0; - } } // clang-format off diff --git a/ChaosMod/Effects/db/Peds/PedsTpRandomPedsPlayerVeh.cpp b/ChaosMod/Effects/db/Peds/PedsTpRandomPedsPlayerVeh.cpp index c23146ab7..7b23bd268 100644 --- a/ChaosMod/Effects/db/Peds/PedsTpRandomPedsPlayerVeh.cpp +++ b/ChaosMod/Effects/db/Peds/PedsTpRandomPedsPlayerVeh.cpp @@ -12,19 +12,13 @@ static void OnStart() std::vector pedPool; for (Ped ped : GetAllPeds()) - { if (!IS_PED_A_PLAYER(ped) && IS_PED_HUMAN(ped)) - { pedPool.push_back(ped); - } - } for (int i = -1; i < seats; i++) { if (pedPool.empty()) - { break; - } if (IS_VEHICLE_SEAT_FREE(playerVeh, i, false)) { int randomIndex = g_Random.GetRandomInt(0, pedPool.size() - 1); diff --git a/ChaosMod/Effects/db/Peds/PedsZombies.cpp b/ChaosMod/Effects/db/Peds/PedsZombies.cpp index ddfcf5f8c..e728aba1e 100644 --- a/ChaosMod/Effects/db/Peds/PedsZombies.cpp +++ b/ChaosMod/Effects/db/Peds/PedsZombies.cpp @@ -20,12 +20,8 @@ static void OnStart() static void OnStop() { for (Ped ped : ms_Zombies) - { if (DOES_ENTITY_EXIST(ped)) - { SET_PED_AS_NO_LONGER_NEEDED(&ped); - } - } } static void OnTick() diff --git a/ChaosMod/Effects/db/Player/PlayerAimbot.cpp b/ChaosMod/Effects/db/Player/PlayerAimbot.cpp index 4ad57d313..173ebbb4d 100644 --- a/ChaosMod/Effects/db/Player/PlayerAimbot.cpp +++ b/ChaosMod/Effects/db/Player/PlayerAimbot.cpp @@ -33,9 +33,7 @@ static void OnTick() SET_PED_SHOOTS_AT_COORD(playerPed, headVector.x, headVector.y, headVector.z, true); // Only 5 shots per Tick if (--count <= 0) - { break; - } } } } diff --git a/ChaosMod/Effects/db/Player/PlayerAutopilot.cpp b/ChaosMod/Effects/db/Player/PlayerAutopilot.cpp index f9e370d36..d4a845b1d 100644 --- a/ChaosMod/Effects/db/Player/PlayerAutopilot.cpp +++ b/ChaosMod/Effects/db/Player/PlayerAutopilot.cpp @@ -41,9 +41,7 @@ static void OnStop() CLEAR_PED_TASKS(playerPed); if (!IS_PED_IN_ANY_VEHICLE(playerPed, false)) - { CLEAR_PED_TASKS_IMMEDIATELY(playerPed); - } } static void OnTick() @@ -61,9 +59,7 @@ static void OnTick() SET_PLAYER_CONTROL(player, false, 7001); if (playerDead) - { return; - } } #ifdef _DEBUG @@ -93,9 +89,7 @@ static void OnTick() static DWORD64 lastTick = GET_GAME_TIMER(); DWORD64 curTick = GET_GAME_TIMER(); if (lastTick > curTick - 300) - { return; - } lastTick = curTick; // Try to fetch waypoint coords (if waypoint exists) @@ -115,9 +109,7 @@ static void OnTick() ms_CustomWaypoint = true; if (ms_State != STATE_ROAMING && !VectorEqualRoughZ(ms_WaypointCoords, lastWaypointCoords)) - { ms_State = STATE_NONE; - } } else { @@ -148,9 +140,7 @@ static void OnTick() ms_CustomWaypoint = true; if (ms_State != STATE_ROAMING && !VectorEqualRoughZ(ms_WaypointCoords, lastWaypointCoords)) - { ms_State = STATE_NONE; - } } } @@ -201,15 +191,11 @@ static void OnTick() if (targetBlip) { if (GET_BLIP_INFO_ID_ENTITY_INDEX(targetBlip) == playerVeh) - { isTargetThisVehicle = true; - } } if (!vehDrivable || (!isTargetThisVehicle && GET_IS_VEHICLE_ENGINE_RUNNING(playerVeh))) - { TASK_LEAVE_ANY_VEHICLE(playerPed, 0, 0); - } ms_State = STATE_NONE; } @@ -232,9 +218,7 @@ static void OnTick() _GET_ENTITY_PROOFS(ped, &bulletproof, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy); if (bulletproof) - { continue; - } int rel = GET_RELATIONSHIP_BETWEEN_PEDS(playerPed, ped); int pedType = GET_PED_TYPE(ped); diff --git a/ChaosMod/Effects/db/Player/PlayerBees.cpp b/ChaosMod/Effects/db/Player/PlayerBees.cpp index 4727df9e2..c0209e00f 100644 --- a/ChaosMod/Effects/db/Player/PlayerBees.cpp +++ b/ChaosMod/Effects/db/Player/PlayerBees.cpp @@ -10,9 +10,7 @@ static void OnStart() { REQUEST_NAMED_PTFX_ASSET("core"); while (!HAS_NAMED_PTFX_ASSET_LOADED("core")) - { WAIT(0); - } Ped player = PLAYER_PED_ID(); USE_PARTICLE_FX_ASSET("core"); @@ -24,9 +22,7 @@ static void OnStart() static void ApplyVig() { if (GET_TIMECYCLE_TRANSITION_MODIFIER_INDEX() == -1 && GET_TIMECYCLE_MODIFIER_INDEX() == -1) - { SET_TRANSITION_TIMECYCLE_MODIFIER("fp_vig_red", 0.25f); - } } // (kolyaventuri) There's gotta be a better way of doing this... diff --git a/ChaosMod/Effects/db/Player/PlayerBlimpStrats.cpp b/ChaosMod/Effects/db/Player/PlayerBlimpStrats.cpp index 661bfc972..a9ec19dc4 100644 --- a/ChaosMod/Effects/db/Player/PlayerBlimpStrats.cpp +++ b/ChaosMod/Effects/db/Player/PlayerBlimpStrats.cpp @@ -17,9 +17,7 @@ static void OnStart() LoadModel(blimpHash); if (!cutscenePlaying) - { REQUEST_CUTSCENE("fbi_1_int", 8); - } Vehicle veh = CREATE_VEHICLE(blimpHash, -370.490f, 1029.085f, 345.090f, 53.824f, true, false, false); SET_VEHICLE_ENGINE_ON(veh, true, true, false); @@ -44,9 +42,7 @@ static void OnStart() REQUEST_MODEL(daveHash); while (!HAS_CUTSCENE_LOADED()) // for proper cutscene play - { WAIT(0); - } REGISTER_ENTITY_FOR_CUTSCENE(player, "MICHAEL", 0, 0, 64); diff --git a/ChaosMod/Effects/db/Player/PlayerClone.cpp b/ChaosMod/Effects/db/Player/PlayerClone.cpp index 79ac2cb22..8933b01b2 100644 --- a/ChaosMod/Effects/db/Player/PlayerClone.cpp +++ b/ChaosMod/Effects/db/Player/PlayerClone.cpp @@ -22,13 +22,9 @@ static void OnStart() Ped ped = CreatePoolClonePed(playerPed); if (IS_PED_IN_ANY_VEHICLE(playerPed, false)) - { SET_PED_INTO_VEHICLE(ped, GET_VEHICLE_PED_IS_IN(playerPed, false), -2); - } else - { SET_ENTITY_HEADING(ped, GET_ENTITY_HEADING(playerPed)); - } SET_PED_SUFFERS_CRITICAL_HITS(ped, false); SET_PED_HEARING_RANGE(ped, 9999.f); @@ -39,9 +35,7 @@ static void OnStart() SET_PED_RELATIONSHIP_GROUP_HASH(ped, relationshipGroup); if (friendly) - { SET_PED_AS_GROUP_MEMBER(ped, GET_PLAYER_GROUP(PLAYER_ID())); - } SET_PED_COMBAT_ATTRIBUTES(ped, 5, true); SET_PED_COMBAT_ATTRIBUTES(ped, 46, true); diff --git a/ChaosMod/Effects/db/Player/PlayerCopyForce.cpp b/ChaosMod/Effects/db/Player/PlayerCopyForce.cpp index 30c293bc5..034d8cfc8 100644 --- a/ChaosMod/Effects/db/Player/PlayerCopyForce.cpp +++ b/ChaosMod/Effects/db/Player/PlayerCopyForce.cpp @@ -11,13 +11,9 @@ static void OnStart() Ped playerPed = PLAYER_PED_ID(); if (IS_PED_IN_ANY_VEHICLE(playerPed, false)) - { playerVelocity = GET_ENTITY_VELOCITY(GET_VEHICLE_PED_IS_IN(playerPed, false)); - } else - { playerVelocity = GET_ENTITY_VELOCITY(playerPed); - } } static void OnTick() @@ -26,37 +22,23 @@ static void OnTick() Vector3 newVelocity; if (IS_PED_IN_ANY_VEHICLE(playerPed, false)) - { newVelocity = GET_ENTITY_VELOCITY(GET_VEHICLE_PED_IS_IN(playerPed, false)); - } else - { newVelocity = GET_ENTITY_VELOCITY(playerPed); - } Vector3 newForce = newVelocity - playerVelocity; playerVelocity = newVelocity; std::vector entities; for (Ped ped : GetAllPeds()) - { if (ped != playerPed && !IS_PED_IN_ANY_VEHICLE(ped, false)) - { entities.push_back(ped); - } - } for (Vehicle veh : GetAllVehs()) - { if (!IS_PED_IN_VEHICLE(playerPed, veh, false)) - { entities.push_back(veh); - } - } for (Entity prop : GetAllProps()) - { entities.push_back(prop); - } Vector3 playerCoord = GET_ENTITY_COORDS(playerPed, false); for (Entity entity : entities) diff --git a/ChaosMod/Effects/db/Player/PlayerDeadEye.cpp b/ChaosMod/Effects/db/Player/PlayerDeadEye.cpp index 84441a58c..7cd003312 100644 --- a/ChaosMod/Effects/db/Player/PlayerDeadEye.cpp +++ b/ChaosMod/Effects/db/Player/PlayerDeadEye.cpp @@ -35,9 +35,7 @@ static void OnTick() } // Exclude non working weapons (minigun, hellbringer) if (weaponHash == 0x42BF8A85 || weaponHash == 0xB62D1F67) - { return; - } // Check if player is aiming if (IS_CONTROL_PRESSED(0, 25)) { diff --git a/ChaosMod/Effects/db/Player/PlayerDrunk.cpp b/ChaosMod/Effects/db/Player/PlayerDrunk.cpp index 8f90db7df..6b74e3370 100644 --- a/ChaosMod/Effects/db/Player/PlayerDrunk.cpp +++ b/ChaosMod/Effects/db/Player/PlayerDrunk.cpp @@ -19,9 +19,7 @@ static void OnStop() static void OnTick() { if (!IS_GAMEPLAY_CAM_SHAKING()) - { SHAKE_GAMEPLAY_CAM("DRUNK_SHAKE", 2.f); - } Ped playerPed = PLAYER_PED_ID(); @@ -41,18 +39,14 @@ static void OnTick() { Vehicle playerVeh = GET_VEHICLE_PED_IS_IN(playerPed, false); if (GET_PED_IN_VEHICLE_SEAT(playerVeh, -1, 0) != playerPed) - { return; - } static DWORD64 timeUntilSteer = GET_GAME_TIMER(); static bool enableDrunkSteering = false; static float steering; if (enableDrunkSteering) - { SET_VEHICLE_STEER_BIAS(playerVeh, steering); - } DWORD64 curTick = GET_GAME_TIMER(); diff --git a/ChaosMod/Effects/db/Player/PlayerFakeDeath.cpp b/ChaosMod/Effects/db/Player/PlayerFakeDeath.cpp index ee8663c8e..bd6a81fdb 100644 --- a/ChaosMod/Effects/db/Player/PlayerFakeDeath.cpp +++ b/ChaosMod/Effects/db/Player/PlayerFakeDeath.cpp @@ -53,14 +53,10 @@ static void OnStart() WAIT(0); if (currentMode > FakeDeathState::animation) - { HIDE_HUD_AND_RADAR_THIS_FRAME(); - } if (scaleForm > 0) - { DRAW_SCALEFORM_MOVIE_FULLSCREEN(scaleForm, 255, 255, 255, 255, 0); - } int current_time = GetTickCount64(); if (current_time - lastModeTime > nextModeTime) @@ -77,9 +73,7 @@ static void OnStart() Ped playerPed = PLAYER_PED_ID(); if (currentMode != FakeDeathState::cleanup) - { SET_PLAYER_INVINCIBLE(playerPed, true); - } switch (currentMode) { @@ -99,9 +93,7 @@ static void OnStart() // Fake suicide REQUEST_ANIM_DICT("mp_suicide"); while (!HAS_ANIM_DICT_LOADED("mp_suicide")) - { 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, @@ -146,9 +138,7 @@ static void OnStart() Ped ped = GET_PED_IN_VEHICLE_SEAT(veh, i, false); if (!ped) - { continue; - } TASK_LEAVE_VEHICLE(ped, veh, 4160); } @@ -157,9 +147,7 @@ static void OnStart() if (detonateTimer <= 0) { for (int i = 0; i < 6; i++) - { SET_VEHICLE_DOOR_BROKEN(veh, i, false); - } Vector3 vehCoords = GET_ENTITY_COORDS(veh, false); Vector3 plrCoords = GET_ENTITY_COORDS(playerPed, false); if (GET_DISTANCE_BETWEEN_COORDS(vehCoords.x, vehCoords.y, vehCoords.z, plrCoords.x, diff --git a/ChaosMod/Effects/db/Player/PlayerForcefield.cpp b/ChaosMod/Effects/db/Player/PlayerForcefield.cpp index 66b5fb16a..1aed64291 100644 --- a/ChaosMod/Effects/db/Player/PlayerForcefield.cpp +++ b/ChaosMod/Effects/db/Player/PlayerForcefield.cpp @@ -12,25 +12,15 @@ static void OnTick() std::vector entities; for (Ped ped : GetAllPeds()) - { if (ped != player) - { entities.push_back(ped); - } - } for (Vehicle veh : GetAllVehs()) - { if (!IS_PED_IN_VEHICLE(player, veh, false)) - { entities.push_back(veh); - } - } for (Entity prop : GetAllProps()) - { entities.push_back(prop); - } Vector3 playerCoord = GET_ENTITY_COORDS(player, false); for (Entity entity : entities) @@ -44,9 +34,7 @@ static void OnTick() if (distance < startDistance) { if (IS_ENTITY_A_PED(entity) && !IS_PED_RAGDOLL(entity)) - { SET_PED_TO_RAGDOLL(entity, 5000, 5000, 0, true, true, false); - } float forceDistance = std::min(std::max(0.f, (startDistance - distance)), maxForceDistance); float force = (forceDistance / maxForceDistance) * maxForce; Memory::ApplyForceToEntity(entity, 3, entityCoord.x - playerCoord.x, entityCoord.y - playerCoord.y, diff --git a/ChaosMod/Effects/db/Player/PlayerGravitySphere.cpp b/ChaosMod/Effects/db/Player/PlayerGravitySphere.cpp index 10e06c460..6c9ca7a09 100644 --- a/ChaosMod/Effects/db/Player/PlayerGravitySphere.cpp +++ b/ChaosMod/Effects/db/Player/PlayerGravitySphere.cpp @@ -14,25 +14,15 @@ static void OnTick() std::vector entities; for (Ped ped : GetAllPeds()) - { if (ped != player) - { entities.push_back(ped); - } - } for (Vehicle veh : GetAllVehs()) - { if (!IS_PED_IN_VEHICLE(player, veh, false)) - { entities.push_back(veh); - } - } for (Entity prop : GetAllProps()) - { entities.push_back(prop); - } Vector3 playerCoord = GET_ENTITY_COORDS(player, false); Vector3 playerSpeed = GET_ENTITY_VELOCITY(player); @@ -58,9 +48,7 @@ static void OnTick() if (distance < startDistance) { if (IS_ENTITY_A_PED(entity) && !IS_PED_RAGDOLL(entity)) - { SET_PED_TO_RAGDOLL(entity, 5000, 5000, 0, true, true, false); - } if (distance < sphereRadius * .9) // entity is inside the sphere { diff --git a/ChaosMod/Effects/db/Player/PlayerHacking.cpp b/ChaosMod/Effects/db/Player/PlayerHacking.cpp index 6ad4dcdc5..5d7c3056a 100644 --- a/ChaosMod/Effects/db/Player/PlayerHacking.cpp +++ b/ChaosMod/Effects/db/Player/PlayerHacking.cpp @@ -132,9 +132,7 @@ static void OnStart() scaleform = GRAPHICS::_REQUEST_SCALEFORM_MOVIE_INTERACTIVE("Hacking_PC"); while (!GRAPHICS::HAS_SCALEFORM_MOVIE_LOADED(scaleform)) - { WAIT(0); - } GRAPHICS::BEGIN_SCALEFORM_MOVIE_METHOD(scaleform, "SET_BACKGROUND"); GRAPHICS::SCALEFORM_MOVIE_METHOD_ADD_PARAM_INT(0); @@ -227,9 +225,7 @@ static void OnStart() } if (!IS_SCREEN_FADED_IN()) - { act = TimerAction::REMOVE; - } if (act != TimerAction::NONE && MISC::GET_GAME_TIMER() >= timer) { diff --git a/ChaosMod/Effects/db/Player/PlayerHasGravity.cpp b/ChaosMod/Effects/db/Player/PlayerHasGravity.cpp index e489ed603..b8bce04e6 100644 --- a/ChaosMod/Effects/db/Player/PlayerHasGravity.cpp +++ b/ChaosMod/Effects/db/Player/PlayerHasGravity.cpp @@ -17,23 +17,13 @@ static void OnTick() // get all moveable entities for (Ped ped : GetAllPeds()) - { if (ped != playerPed) - { entities.push_back(ped); - } - } for (Vehicle veh : GetAllVehs()) - { if (!IS_PED_IN_VEHICLE(playerPed, veh, false)) - { entities.push_back(veh); - } - } for (Entity prop : GetAllProps()) - { entities.push_back(prop); - } Vector3 playerCoord = GET_ENTITY_COORDS(playerPed, false); int count = 10; @@ -51,9 +41,7 @@ static void OnTick() if (distance < startDistance) { if (IS_ENTITY_A_PED(entity) && !IS_PED_RAGDOLL(entity)) - { SET_PED_TO_RAGDOLL(entity, 5000, 5000, 0, true, true, false); - } float forceDistance = std::min(std::max(0.f, (startDistance - distance)), maxForceDistance); float force = (forceDistance / maxForceDistance) * maxForce; Memory::ApplyForceToEntity(entity, 3, (entityCoord.x - playerCoord.x) * -1.f, @@ -61,9 +49,7 @@ static void OnTick() 0, 0, 0, false, false, true, true, false, true); if (IS_ENTITY_A_MISSION_ENTITY(entity)) - { SET_ENTITY_INVINCIBLE(entity, true); - } if (--count <= 0) { @@ -81,14 +67,10 @@ static void OnStop() SET_PLAYER_INVINCIBLE(player, false); for (Ped ped : GetAllPeds()) - { SET_ENTITY_INVINCIBLE(ped, false); - } for (Vehicle veh : GetAllVehs()) - { SET_ENTITY_INVINCIBLE(veh, false); - } } // clang-format off diff --git a/ChaosMod/Effects/db/Player/PlayerIllegalInnocence.cpp b/ChaosMod/Effects/db/Player/PlayerIllegalInnocence.cpp index 9854ed65e..0e691a6f8 100644 --- a/ChaosMod/Effects/db/Player/PlayerIllegalInnocence.cpp +++ b/ChaosMod/Effects/db/Player/PlayerIllegalInnocence.cpp @@ -51,9 +51,7 @@ static void OnTick() if (ms_LastPlayerKills >= 0 && allPlayerKills > ms_LastPlayerKills) { if (ms_LastWantedLevel > 0) - { ms_LastWantedLevel = ms_LastWantedLevel - 1; - } SET_PLAYER_WANTED_LEVEL(player, ms_LastWantedLevel, false); SET_PLAYER_WANTED_LEVEL_NOW(player, true); ms_TimeReserve = WAIT_TIME; diff --git a/ChaosMod/Effects/db/Player/PlayerImTired.cpp b/ChaosMod/Effects/db/Player/PlayerImTired.cpp index 85a4c0d1d..a6514c8c5 100644 --- a/ChaosMod/Effects/db/Player/PlayerImTired.cpp +++ b/ChaosMod/Effects/db/Player/PlayerImTired.cpp @@ -71,22 +71,16 @@ static void OnTick() alpha += closingIterator; // Chance for player who's on foot to ragdoll halfway through blinking if (alpha >= 127 && alpha - closingIterator < 127 && g_Random.GetRandomFloat(0.f, 1.f) < .25f) - { RagdollOnFoot(); - } // Fall asleep at the wheel near the end of blinking if (alpha > 200) - { SteerVehicle(); - } if (alpha >= 255) { currentMode = TiredMode::openingEyes; nextTimestamp = GET_GAME_TIMER() + ((20 - closingIterator) * 20); if (closingIterator > 1) - { closingIterator = std::max(1, closingIterator - 2); - } } break; case TiredMode::openingEyes: diff --git a/ChaosMod/Effects/db/Player/PlayerLockCamera.cpp b/ChaosMod/Effects/db/Player/PlayerLockCamera.cpp index 46a37eb3e..1d25cdb8f 100644 --- a/ChaosMod/Effects/db/Player/PlayerLockCamera.cpp +++ b/ChaosMod/Effects/db/Player/PlayerLockCamera.cpp @@ -9,14 +9,10 @@ static void OnTick() _SET_GAMEPLAY_CAM_RELATIVE_ROTATION(0, 0, 0); if (!IS_PED_IN_ANY_VEHICLE(PLAYER_PED_ID(), false)) - { DISABLE_CONTROL_ACTION(0, 2, true); // Look UD - } if (!IS_PLAYER_FREE_AIMING(PLAYER_ID())) - { DISABLE_CONTROL_ACTION(0, 1, true); // Look LR - } } // clang-format off diff --git a/ChaosMod/Effects/db/Player/PlayerNoMovRandom.cpp b/ChaosMod/Effects/db/Player/PlayerNoMovRandom.cpp index c1b626655..48c3fa499 100644 --- a/ChaosMod/Effects/db/Player/PlayerNoMovRandom.cpp +++ b/ChaosMod/Effects/db/Player/PlayerNoMovRandom.cpp @@ -16,21 +16,13 @@ static void OnTick() if (rand_key == 0) // Disable Up { if (IS_CONTROL_PRESSED(0, 32)) - { DISABLE_CONTROL_ACTION(0, 31, true); - } if (IS_CONTROL_PRESSED(0, 61)) - { DISABLE_CONTROL_ACTION(0, 60, true); - } if (IS_CONTROL_PRESSED(0, 127)) - { DISABLE_CONTROL_ACTION(0, 126, true); - } if (IS_CONTROL_PRESSED(0, 150)) - { DISABLE_CONTROL_ACTION(0, 149, true); - } DISABLE_CONTROL_ACTION(0, 71, true); DISABLE_CONTROL_ACTION(0, 87, true); DISABLE_CONTROL_ACTION(0, 129, true); @@ -41,21 +33,13 @@ static void OnTick() else if (rand_key == 1) // Disable Down { if (IS_CONTROL_PRESSED(0, 33)) - { DISABLE_CONTROL_ACTION(0, 31, true); - } if (IS_CONTROL_PRESSED(0, 62)) - { DISABLE_CONTROL_ACTION(0, 60, true); - } if (IS_CONTROL_PRESSED(0, 128)) - { DISABLE_CONTROL_ACTION(0, 126, true); - } if (IS_CONTROL_PRESSED(0, 151)) - { DISABLE_CONTROL_ACTION(0, 149, true); - } DISABLE_CONTROL_ACTION(0, 72, true); DISABLE_CONTROL_ACTION(0, 88, true); DISABLE_CONTROL_ACTION(0, 130, true); @@ -66,21 +50,13 @@ static void OnTick() else if (rand_key == 2) // Disable Left { if (IS_CONTROL_PRESSED(0, 34)) - { DISABLE_CONTROL_ACTION(0, 30, true); - } if (IS_CONTROL_PRESSED(0, 63)) - { DISABLE_CONTROL_ACTION(0, 59, true); - } if (IS_CONTROL_PRESSED(0, 124)) - { DISABLE_CONTROL_ACTION(0, 123, true); - } if (IS_CONTROL_PRESSED(0, 147)) - { DISABLE_CONTROL_ACTION(0, 146, true); - } DISABLE_CONTROL_ACTION(0, 89, true); DISABLE_CONTROL_ACTION(0, 133, true); DISABLE_CONTROL_ACTION(0, 152, true); @@ -90,21 +66,13 @@ static void OnTick() else // Disable Right { if (IS_CONTROL_PRESSED(0, 35)) - { DISABLE_CONTROL_ACTION(0, 30, true); - } if (IS_CONTROL_PRESSED(0, 64)) - { DISABLE_CONTROL_ACTION(0, 59, true); - } if (IS_CONTROL_PRESSED(0, 125)) - { DISABLE_CONTROL_ACTION(0, 123, true); - } if (IS_CONTROL_PRESSED(0, 148)) - { DISABLE_CONTROL_ACTION(0, 146, true); - } DISABLE_CONTROL_ACTION(0, 90, true); DISABLE_CONTROL_ACTION(0, 134, true); DISABLE_CONTROL_ACTION(0, 153, true); diff --git a/ChaosMod/Effects/db/Player/PlayerRagdollOnShot.cpp b/ChaosMod/Effects/db/Player/PlayerRagdollOnShot.cpp index 1b52ff00d..ee86db8e2 100644 --- a/ChaosMod/Effects/db/Player/PlayerRagdollOnShot.cpp +++ b/ChaosMod/Effects/db/Player/PlayerRagdollOnShot.cpp @@ -14,9 +14,7 @@ static void OnTick() if (timeSinceDmg && curTime - timeSinceDmg < 200) { if (IS_PED_IN_ANY_VEHICLE(playerPed, false)) - { CLEAR_PED_TASKS_IMMEDIATELY(playerPed); - } SET_PED_TO_RAGDOLL(playerPed, 500, 1000, 0, true, true, false); diff --git a/ChaosMod/Effects/db/Player/PlayerRandomVehSeat.cpp b/ChaosMod/Effects/db/Player/PlayerRandomVehSeat.cpp index 59ce19d65..1b3222c81 100644 --- a/ChaosMod/Effects/db/Player/PlayerRandomVehSeat.cpp +++ b/ChaosMod/Effects/db/Player/PlayerRandomVehSeat.cpp @@ -60,12 +60,8 @@ static void OnStart() { std::vector choosableSeats; for (int i = -1; i < maxSeats - 1; i++) - { if (IS_VEHICLE_SEAT_FREE(veh, i, false) || GET_PED_IN_VEHICLE_SEAT(veh, i, false) != playerPed) - { choosableSeats.push_back(i); - } - } int seat = choosableSeats[g_Random.GetRandomInt(0, choosableSeats.size() - 1)]; if (!IS_VEHICLE_SEAT_FREE(veh, seat, false)) diff --git a/ChaosMod/Effects/db/Player/PlayerRapidFire.cpp b/ChaosMod/Effects/db/Player/PlayerRapidFire.cpp index db683a177..12bf160df 100644 --- a/ChaosMod/Effects/db/Player/PlayerRapidFire.cpp +++ b/ChaosMod/Effects/db/Player/PlayerRapidFire.cpp @@ -11,14 +11,10 @@ static void OnTick() Player playerPed = PLAYER_PED_ID(); Hash weaponHash; if (!GET_CURRENT_PED_WEAPON(playerPed, &weaponHash, true) || GET_WEAPONTYPE_GROUP(weaponHash) == 0xD49321D4) - { return; - } // Exclude non working weapons (minigun, hellbringer) if (weaponHash == 0x42BF8A85 || weaponHash == 0xB62D1F67) - { return; - } DISABLE_CONTROL_ACTION(0, 24, true); DISABLE_CONTROL_ACTION(0, 68, true); DISABLE_CONTROL_ACTION(0, 69, true); diff --git a/ChaosMod/Effects/db/Player/PlayerSetIntoClosestVeh.cpp b/ChaosMod/Effects/db/Player/PlayerSetIntoClosestVeh.cpp index a48c4bc17..a485bb9ff 100644 --- a/ChaosMod/Effects/db/Player/PlayerSetIntoClosestVeh.cpp +++ b/ChaosMod/Effects/db/Player/PlayerSetIntoClosestVeh.cpp @@ -12,9 +12,7 @@ static void OnStart() for (Vehicle veh : GetAllVehs()) { if (veh == playerVeh) - { continue; - } Vector3 coords = GET_ENTITY_COORDS(veh, false); float dist = @@ -45,9 +43,7 @@ static void OnStart() Ped seatPed = GET_PED_IN_VEHICLE_SEAT(playerVeh, i, false); if (seatPed != playerPed) - { teleportPeds.push_back(seatPed); - } } } } @@ -58,9 +54,7 @@ static void OnStart() for (int i = 0; i < teleportPeds.size(); i++) { if (i >= closestVehMaxSeats) - { break; - } Ped ped = teleportPeds[i]; diff --git a/ChaosMod/Effects/db/Player/PlayerSetIntoRandomVeh.cpp b/ChaosMod/Effects/db/Player/PlayerSetIntoRandomVeh.cpp index fccfa4e28..88bfbae0d 100644 --- a/ChaosMod/Effects/db/Player/PlayerSetIntoRandomVeh.cpp +++ b/ChaosMod/Effects/db/Player/PlayerSetIntoRandomVeh.cpp @@ -38,9 +38,7 @@ static void OnStart() Ped seatPed = GET_PED_IN_VEHICLE_SEAT(playerVeh, i, false); if (seatPed != playerPed) - { teleportPeds.push_back(seatPed); - } } } } @@ -53,9 +51,7 @@ static void OnStart() for (int i = 0; i < teleportPeds.size(); i++) { if (i >= targetVehMaxSeats) - { break; - } Ped ped = teleportPeds[i]; diff --git a/ChaosMod/Effects/db/Player/PlayerSimeonSays.cpp b/ChaosMod/Effects/db/Player/PlayerSimeonSays.cpp index 6bc6be02b..de5e2982d 100644 --- a/ChaosMod/Effects/db/Player/PlayerSimeonSays.cpp +++ b/ChaosMod/Effects/db/Player/PlayerSimeonSays.cpp @@ -44,35 +44,20 @@ static void ShowPopup() std::string message; if (opposite) - { if (g_Random.GetRandomInt(0, 1) == 0) - { message = "Simeon Says: Don't "; - } else - { message = ""; - } - } + else if (g_Random.GetRandomInt(0, 1) == 0) + message = "Don't "; else - { - if (g_Random.GetRandomInt(0, 1) == 0) - { - message = "Don't "; - } - else - { - message = "Simeon Says: "; - } - } + message = "Simeon Says: "; message.append(action); scaleForm = REQUEST_SCALEFORM_MOVIE("MP_BIG_MESSAGE_FREEMODE"); while (!HAS_SCALEFORM_MOVIE_LOADED(scaleForm)) - { WAIT(0); - } lastTime = GetTickCount64(); waitTime = 2000; SET_TIME_SCALE(0.1f); @@ -95,13 +80,9 @@ static void OnStart() int rand_int = g_Random.GetRandomInt(0, 1); if (rand_int == 0) - { opposite = false; - } else - { opposite = true; - } lastTime = 0; dead = false; @@ -117,28 +98,18 @@ static void OnTick() if (!opposite) { if (_IS_PLAYER_CAM_CONTROL_DISABLED()) - { return; - } kill = true; for (int key : actionKeys[action]) - { if (IS_CONTROL_PRESSED(0, key) || IS_CONTROL_JUST_PRESSED(0, key)) - { kill = false; - } - } } else { for (int key : actionKeys[action]) - { if (IS_CONTROL_PRESSED(0, key) || IS_CONTROL_JUST_RELEASED(0, key)) - { kill = true; - } - } } if (IS_PED_DEAD_OR_DYING(playerPed, false) || !IS_SCREEN_FADED_IN()) diff --git a/ChaosMod/Effects/db/Player/PlayerSuicide.cpp b/ChaosMod/Effects/db/Player/PlayerSuicide.cpp index 485e73e81..ae8567590 100644 --- a/ChaosMod/Effects/db/Player/PlayerSuicide.cpp +++ b/ChaosMod/Effects/db/Player/PlayerSuicide.cpp @@ -8,9 +8,7 @@ static void OnStart() { REQUEST_ANIM_DICT("mp_suicide"); while (!HAS_ANIM_DICT_LOADED("mp_suicide")) - { 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); diff --git a/ChaosMod/Effects/db/Player/PlayerTpController.cpp b/ChaosMod/Effects/db/Player/PlayerTpController.cpp index ac6e82502..208f69ff9 100644 --- a/ChaosMod/Effects/db/Player/PlayerTpController.cpp +++ b/ChaosMod/Effects/db/Player/PlayerTpController.cpp @@ -39,13 +39,9 @@ REGISTER_EFFECT(OnStartMazeTower, nullptr, nullptr, EffectInfo static void OnStartFortZancudo() { if (!IS_PED_IN_ANY_VEHICLE(PLAYER_PED_ID(), false)) - { TeleportPlayer(-2360.3f, 3244.83f, 92.9f); - } else - { TeleportPlayer(-2267.89f, 3121.04f, 32.5f); - } } // clang-format off @@ -61,13 +57,9 @@ REGISTER_EFFECT(OnStartFortZancudo, nullptr, nullptr, EffectInfo static void OnStartMountChilliad() { if (!IS_PED_IN_ANY_VEHICLE(PLAYER_PED_ID(), false)) - { TeleportPlayer(501.77f, 5604.85f, 797.91f); - } else - { TeleportPlayer(503.33f, 5531.91f, 777.45f); - } } // clang-format off @@ -139,15 +131,11 @@ static void OnStartWaypoint() TeleportPlayer(coords.x, coords.y, testZ); if (i % 5 == 0) - { WAIT(0); - } useGroundZ = GET_GROUND_Z_FOR_3D_COORD(coords.x, coords.y, testZ, &groundZ, false, false); if (useGroundZ) - { break; - } } if (useGroundZ) @@ -215,15 +203,11 @@ static void OnStartRandom() TeleportPlayer(x, y, testZ); if (i % 5 == 0) - { WAIT(0); - } useGroundZ = GET_GROUND_Z_FOR_3D_COORD(x, y, testZ, &groundZ, false, false); if (useGroundZ) - { break; - } } TeleportPlayer(x, y, useGroundZ ? groundZ : z); @@ -270,9 +254,7 @@ static void OnStartMission() int color = GET_BLIP_COLOUR(nextBlip); // Filter out missions for other players (ignore Trevor- and Franklin-Blips for Michael) if (std::find(excludedColors.begin(), excludedColors.end(), color) == excludedColors.end()) - { validBlips.push_back(nextBlip); - } nextBlip = GET_NEXT_BLIP_INFO_ID(i); } } @@ -311,13 +293,9 @@ static const std::vector tpLocations = { static int GetFakeWantedLevel(std::string_view effect) { if (effect == "tp_lsairport") - { return 3; - } else if (effect == "tp_fortzancudo") - { return 4; - } return 0; } @@ -328,9 +306,7 @@ static void OnStartFakeTp() auto overrideId = selectedLocationInfo.type; if (ComponentExists()) - { GetComponent()->OverrideEffectNameId("tp_fake", overrideId); - } Player player = PLAYER_ID(); Ped playerPed = PLAYER_PED_ID(); @@ -345,18 +321,14 @@ static void OnStartFakeTp() if (playerVeh) { if (!selectedLocationInfo.vehiclePos.IsDefault()) - { destinationPos = selectedLocationInfo.vehiclePos; - } SET_ENTITY_INVINCIBLE(playerVeh, true); } int currentWanted = GET_PLAYER_WANTED_LEVEL(player); int wanted = GetFakeWantedLevel(selectedLocationInfo.type); if (wanted == 0 || wanted < currentWanted) - { wanted = currentWanted; - } SET_PLAYER_WANTED_LEVEL(player, 0, false); SET_PLAYER_WANTED_LEVEL_NOW(player, false); @@ -372,9 +344,7 @@ static void OnStartFakeTp() SET_ENTITY_INVINCIBLE(playerPed, false); if (playerVeh) - { SET_ENTITY_INVINCIBLE(playerVeh, false); - } SET_FAKE_WANTED_LEVEL(0); SET_MAX_WANTED_LEVEL(5); @@ -400,9 +370,7 @@ static void OnStartFakeFakeTp() auto overrideId = selectedLocationInfo.type; if (ComponentExists()) - { GetComponent()->OverrideEffectNameId("tp_fakex2", overrideId); - } Player player = PLAYER_ID(); Ped playerPed = PLAYER_PED_ID(); @@ -417,18 +385,14 @@ static void OnStartFakeFakeTp() if (playerVeh) { if (!selectedLocationInfo.vehiclePos.IsDefault()) - { destinationPos = selectedLocationInfo.vehiclePos; - } SET_ENTITY_INVINCIBLE(playerVeh, true); } int currentWanted = GET_PLAYER_WANTED_LEVEL(player); int wanted = GetFakeWantedLevel(selectedLocationInfo.type); if (wanted == 0 || wanted < currentWanted) - { wanted = currentWanted; - } SET_PLAYER_WANTED_LEVEL(player, 0, false); SET_PLAYER_WANTED_LEVEL_NOW(player, false); @@ -444,9 +408,7 @@ static void OnStartFakeFakeTp() SET_ENTITY_INVINCIBLE(playerPed, false); if (playerVeh) - { SET_ENTITY_INVINCIBLE(playerVeh, false); - } SET_FAKE_WANTED_LEVEL(0); SET_MAX_WANTED_LEVEL(5); @@ -454,9 +416,7 @@ static void OnStartFakeFakeTp() SET_PLAYER_WANTED_LEVEL_NOW(player, false); if (ComponentExists()) - { GetComponent()->OverrideEffectNameId("tp_fakex2", "tp_fake"); - } WAIT(g_Random.GetRandomInt(3500, 6000)); diff --git a/ChaosMod/Effects/db/Player/PlayerTpEverything.cpp b/ChaosMod/Effects/db/Player/PlayerTpEverything.cpp index b15d60fc1..16b1bf412 100644 --- a/ChaosMod/Effects/db/Player/PlayerTpEverything.cpp +++ b/ChaosMod/Effects/db/Player/PlayerTpEverything.cpp @@ -8,9 +8,7 @@ static void OnStart() for (auto ped : GetAllPeds()) { if (maxEntities == 10) - { break; - } maxEntities--; @@ -26,9 +24,7 @@ static void OnStart() for (auto veh : GetAllVehs()) { if (maxEntities == 0) - { break; - } maxEntities--; @@ -43,9 +39,7 @@ static void OnStart() auto playerPos = GET_ENTITY_COORDS(playerPed, false); for (auto entity : entities) - { SET_ENTITY_COORDS(entity, playerPos.x, playerPos.y, playerPos.z, false, false, false, false); - } WAIT(0); diff --git a/ChaosMod/Effects/db/Player/PlayerTpToEverything.cpp b/ChaosMod/Effects/db/Player/PlayerTpToEverything.cpp index 3ec16f5c7..44eee4cb4 100644 --- a/ChaosMod/Effects/db/Player/PlayerTpToEverything.cpp +++ b/ChaosMod/Effects/db/Player/PlayerTpToEverything.cpp @@ -26,27 +26,17 @@ static void OnTick() std::vector allEntities = {}; for (Ped ped : GetAllPeds()) - { if (!IS_PED_A_PLAYER(ped)) - { allEntities.push_back(ped); - } - } Vehicle playerVeh = IS_PED_IN_ANY_VEHICLE(PLAYER_PED_ID(), false) ? GET_VEHICLE_PED_IS_IN(PLAYER_PED_ID(), false) : 0; for (Vehicle veh : GetAllVehs()) - { if (!playerVeh || veh != playerVeh) - { allEntities.push_back(veh); - } - } for (Object prop : GetAllProps()) - { allEntities.push_back(prop); - } if (!allEntities.empty()) { diff --git a/ChaosMod/Effects/db/Player/PlayerVR.cpp b/ChaosMod/Effects/db/Player/PlayerVR.cpp index a1e95ba42..e6bf3c3a5 100644 --- a/ChaosMod/Effects/db/Player/PlayerVR.cpp +++ b/ChaosMod/Effects/db/Player/PlayerVR.cpp @@ -75,9 +75,7 @@ static void OnTick() { // (kolyaventuri): Apply camera effects if (GET_TIMECYCLE_TRANSITION_MODIFIER_INDEX() == -1 && GET_TIMECYCLE_MODIFIER_INDEX() == -1) - { SET_TRANSITION_TIMECYCLE_MODIFIER("secret_camera", 1.5f); - } Ped player = PLAYER_PED_ID(); diff --git a/ChaosMod/Effects/db/Player/PlayerWalkOnWater.cpp b/ChaosMod/Effects/db/Player/PlayerWalkOnWater.cpp index f311286fe..215c8eb69 100644 --- a/ChaosMod/Effects/db/Player/PlayerWalkOnWater.cpp +++ b/ChaosMod/Effects/db/Player/PlayerWalkOnWater.cpp @@ -50,9 +50,7 @@ static void OnTick() static void OnStop() { if (DOES_ENTITY_EXIST(waterObj)) - { DELETE_OBJECT(&waterObj); - } } // clang-format off diff --git a/ChaosMod/Effects/db/Player/PlayerWantedController.cpp b/ChaosMod/Effects/db/Player/PlayerWantedController.cpp index a9d137817..30149c72a 100644 --- a/ChaosMod/Effects/db/Player/PlayerWantedController.cpp +++ b/ChaosMod/Effects/db/Player/PlayerWantedController.cpp @@ -124,9 +124,7 @@ static void OnStartFake() Hooks::EnableScriptThreadBlock(); if (ComponentExists()) - { GetComponent()->OverrideEffectName("player_fakestars", selectedInfo.Name); - } Player player = PLAYER_ID(); int lastLevel = GET_PLAYER_WANTED_LEVEL(player); diff --git a/ChaosMod/Effects/db/Player/PlayerWeaponGiver.cpp b/ChaosMod/Effects/db/Player/PlayerWeaponGiver.cpp index 2aac2b65d..b25e2ef0b 100644 --- a/ChaosMod/Effects/db/Player/PlayerWeaponGiver.cpp +++ b/ChaosMod/Effects/db/Player/PlayerWeaponGiver.cpp @@ -7,9 +7,7 @@ static void OnStartAll() Ped playerPed = PLAYER_PED_ID(); for (Hash weapon : Memory::GetAllWeapons()) - { GIVE_WEAPON_TO_PED(playerPed, weapon, 9999, true, false); - } } // clang-format off diff --git a/ChaosMod/Effects/db/Screen/ScreenBouncyRadar.cpp b/ChaosMod/Effects/db/Screen/ScreenBouncyRadar.cpp index 64a86eb14..7de06dcb0 100644 --- a/ChaosMod/Effects/db/Screen/ScreenBouncyRadar.cpp +++ b/ChaosMod/Effects/db/Screen/ScreenBouncyRadar.cpp @@ -15,13 +15,9 @@ static void OnStart() float multiplier = ((float)screenWidth / (float)screenHeight) * (9.f / 16); if (multiplier > 1) - { xMin = -0.005f * safezoneSize * multiplier - (multiplier - 1) / 2; - } else - { xMin = -0.005f * safezoneSize * multiplier; - } xMax = multiplier - 0.14f + xMin; yMax = 0.005f * safezoneSize; yMin = yMax - 0.825f; @@ -36,14 +32,10 @@ static void OnStart() static void OnTick() { if (xOffset < xMin || xOffset > xMax) - { xVelocity *= -1; - } if (yOffset < yMin || yOffset > yMax) - { yVelocity *= -1; - } auto mult = GET_FRAME_TIME() * BOUNCE_SPEED_MULT; diff --git a/ChaosMod/Effects/db/Screen/ScreenDVDScreensaver.cpp b/ChaosMod/Effects/db/Screen/ScreenDVDScreensaver.cpp index c21e1103a..5a985b38b 100644 --- a/ChaosMod/Effects/db/Screen/ScreenDVDScreensaver.cpp +++ b/ChaosMod/Effects/db/Screen/ScreenDVDScreensaver.cpp @@ -28,33 +28,25 @@ static void OnTick() { offsetX += SPEED; if (offsetX + boxWidth >= 1) - { goingRight = false; - } } else { offsetX -= SPEED; if (offsetX <= 0) - { goingRight = true; - } } if (goingDown) { offsetY += SPEED; if (offsetY + boxHeight >= 1) - { goingDown = false; - } } else { offsetY -= SPEED; if (offsetY <= 0) - { goingDown = true; - } } DRAW_RECT(0.5, offsetY / 2, 1, offsetY, 0, 0, 0, 255, false); // Top bar double lowerHeight = (1 - offsetY - boxHeight); diff --git a/ChaosMod/Effects/db/Screen/ScreenFlipUI.cpp b/ChaosMod/Effects/db/Screen/ScreenFlipUI.cpp index f370949a1..e4c788336 100644 --- a/ChaosMod/Effects/db/Screen/ScreenFlipUI.cpp +++ b/ChaosMod/Effects/db/Screen/ScreenFlipUI.cpp @@ -33,12 +33,8 @@ static std::map hudComponentXValues = { static void OnStart() { for (int i = 0; i < NUM_HUD_COMPONENTS; i++) - { if (hudComponentXValues.contains(i)) - { originalHudComponentX[i] = GET_HUD_COMPONENT_POSITION(i).x; - } - } Vector3 originalMobilePhonePos; GET_MOBILE_PHONE_POSITION(&originalMobilePhonePos); @@ -48,9 +44,7 @@ static void OnStart() static void OnTick() { if (ComponentExists()) - { GetComponent()->FlipChaosUI = true; - } for (int i = 0; i < NUM_HUD_COMPONENTS; i++) { @@ -73,17 +67,11 @@ static void OnTick() static void OnStop() { if (ComponentExists()) - { GetComponent()->FlipChaosUI = false; - } for (int i = 0; i < NUM_HUD_COMPONENTS; i++) - { if (hudComponentXValues.contains(i)) - { SET_HUD_COMPONENT_POSITION(i, originalHudComponentX[i], GET_HUD_COMPONENT_POSITION(i).y); - } - } Vector3 mobilePos; GET_MOBILE_PHONE_POSITION(&mobilePos); diff --git a/ChaosMod/Effects/db/Screen/ScreenSickCam.cpp b/ChaosMod/Effects/db/Screen/ScreenSickCam.cpp index 1c0d70e39..4d18c7996 100644 --- a/ChaosMod/Effects/db/Screen/ScreenSickCam.cpp +++ b/ChaosMod/Effects/db/Screen/ScreenSickCam.cpp @@ -42,21 +42,15 @@ static void OnTick() lastTick = curTick; if (camZoom < 60 || camZoom > 100) - { camZoomRate = camZoomRate * -1; - } camZoom += camZoomRate; if (camRotX < -25 || camRotX > 25) - { camRotXRate = camRotXRate * -1; - } camRotX += camRotXRate; if (camRotY < -35 || camRotY > 35) - { camRotYRate = camRotYRate * -1; - } camRotY += camRotYRate; } diff --git a/ChaosMod/Effects/db/Screen/ScreenTimecycModifierController.cpp b/ChaosMod/Effects/db/Screen/ScreenTimecycModifierController.cpp index 789b5f2ca..aa6deec7d 100644 --- a/ChaosMod/Effects/db/Screen/ScreenTimecycModifierController.cpp +++ b/ChaosMod/Effects/db/Screen/ScreenTimecycModifierController.cpp @@ -119,9 +119,7 @@ static void OnStopLSD() static void OnTickLSD() { if (!ANIMPOSTFX_IS_RUNNING("DrugsDrivingIn")) - { ANIMPOSTFX_PLAY("DrugsDrivingIn", -1, true); - } StartTransitionTimecycle("ArenaEMP"); @@ -139,9 +137,7 @@ static void OnTickLSD() { Vehicle playerVeh = GET_VEHICLE_PED_IS_IN(playerPed, false); if (GET_PED_IN_VEHICLE_SEAT(playerVeh, -1, 0) != playerPed) - { return; - } static DWORD64 timeUntilSteer = GET_GAME_TIMER(); ; @@ -149,9 +145,7 @@ static void OnTickLSD() static float steering; if (enableDrunkSteering) - { SET_VEHICLE_STEER_BIAS(playerVeh, steering); - } DWORD64 curTick = GET_GAME_TIMER(); diff --git a/ChaosMod/Effects/db/Screen/Shaders/ScreenShaderFoldedScreen.cpp b/ChaosMod/Effects/db/Screen/Shaders/ScreenShaderFoldedScreen.cpp index 402ece133..822ca4d76 100644 --- a/ChaosMod/Effects/db/Screen/Shaders/ScreenShaderFoldedScreen.cpp +++ b/ChaosMod/Effects/db/Screen/Shaders/ScreenShaderFoldedScreen.cpp @@ -42,9 +42,7 @@ static void OnStart() } if (!shaderSrcSuffix.empty()) - { Hooks::OverrideShader(OverrideShaderType::LensDistortion, ms_ShaderSrcPrefix + shaderSrcSuffix); - } } static void OnStop() diff --git a/ChaosMod/Effects/db/Screen/Shaders/ScreenShaderSwappedColors.cpp b/ChaosMod/Effects/db/Screen/Shaders/ScreenShaderSwappedColors.cpp index b02ab03b1..1d88686c4 100644 --- a/ChaosMod/Effects/db/Screen/Shaders/ScreenShaderSwappedColors.cpp +++ b/ChaosMod/Effects/db/Screen/Shaders/ScreenShaderSwappedColors.cpp @@ -40,9 +40,7 @@ static void OnStart() } if (!shaderSrcSuffix.empty()) - { Hooks::OverrideShader(OverrideShaderType::LensDistortion, ms_ShaderSrcPrefix + shaderSrcSuffix); - } } static void OnStop() diff --git a/ChaosMod/Effects/db/Vehs/Vehs30mphLimit.cpp b/ChaosMod/Effects/db/Vehs/Vehs30mphLimit.cpp index 220982a52..0e3eededb 100644 --- a/ChaosMod/Effects/db/Vehs/Vehs30mphLimit.cpp +++ b/ChaosMod/Effects/db/Vehs/Vehs30mphLimit.cpp @@ -7,17 +7,13 @@ static void OnTick() { for (Vehicle veh : GetAllVehs()) - { _SET_VEHICLE_MAX_SPEED(veh, 13.41); // 13.41 Meters Per Second = 30 MPH~ - } } static void OnStop() { for (Vehicle veh : GetAllVehs()) - { _SET_VEHICLE_MAX_SPEED(veh, GET_VEHICLE_MODEL_ESTIMATED_MAX_SPEED(GET_ENTITY_MODEL(veh))); - } } // clang-format off diff --git a/ChaosMod/Effects/db/Vehs/VehsAllHorn.cpp b/ChaosMod/Effects/db/Vehs/VehsAllHorn.cpp index f9ef47e77..c0e732a12 100644 --- a/ChaosMod/Effects/db/Vehs/VehsAllHorn.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsAllHorn.cpp @@ -3,9 +3,7 @@ static void OnTick() { for (auto veh : GetAllVehs()) - { SET_HORN_PERMANENTLY_ON(veh); - } } // clang-format off diff --git a/ChaosMod/Effects/db/Vehs/VehsBouncy.cpp b/ChaosMod/Effects/db/Vehs/VehsBouncy.cpp index 5d62ebefe..e347e35e5 100644 --- a/ChaosMod/Effects/db/Vehs/VehsBouncy.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsBouncy.cpp @@ -17,13 +17,9 @@ static void OnTick() { Vector3 vel = GET_ENTITY_VELOCITY(veh); if ((vel.x < 10) && (vel.y < 10) && (vel.z < 10)) - { velFactor = 300.f; - } else - { velFactor = 60.f; - } Memory::ApplyForceToEntity(veh, 0, vel.x * -velFactor, vel.y * -velFactor, vel.z * -velFactor, .0f, .0f, .0f, 0, true, true, true, false, true); } @@ -33,9 +29,7 @@ static void OnTick() static void OnStop() { for (auto veh : GetAllVehs()) - { SET_ENTITY_INVINCIBLE(veh, false); - } } // clang-format off diff --git a/ChaosMod/Effects/db/Vehs/VehsBrakeBoosting.cpp b/ChaosMod/Effects/db/Vehs/VehsBrakeBoosting.cpp index bf2a6ccfe..33116bf74 100644 --- a/ChaosMod/Effects/db/Vehs/VehsBrakeBoosting.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsBrakeBoosting.cpp @@ -15,9 +15,7 @@ static void OnTick() // Exclude helis since the "braking" flag seems to be always set for those // Also manually exclude blimps since those don't seem to be categorized as either of those if (vehClass != 15 && vehModel != blimpHash && Memory::IsVehicleBraking(veh)) - { Memory::ApplyForceToEntity(veh, 0, .0f, 50.f, .0f, .0f, .0f, .0f, 0, true, true, true, false, true); - } } } diff --git a/ChaosMod/Effects/db/Vehs/VehsColorController.cpp b/ChaosMod/Effects/db/Vehs/VehsColorController.cpp index f058616f5..ea2bf1691 100644 --- a/ChaosMod/Effects/db/Vehs/VehsColorController.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsColorController.cpp @@ -127,9 +127,7 @@ static void OnTickPink() { REQUEST_NAMED_PTFX_ASSET("des_trailerpark"); while (!HAS_NAMED_PTFX_ASSET_LOADED("des_trailerpark")) - { WAIT(0); - } for (auto it = flameByCar.cbegin(); it != flameByCar.cend();) { Vehicle veh = it->first; @@ -180,9 +178,7 @@ REGISTER_EFFECT(nullptr, OnStopPink, OnTickPink, EffectInfo static void OnStopRainbow() { for (int i = 0; i < 13; i++) - { Memory::OverrideVehicleHeadlightColor(i, false, 0, 0, 0); - } } static void OnTickRainbow() @@ -193,9 +189,7 @@ static void OnTickRainbow() static const float freq = .1f; if (++cnt >= (ULONG)-1) - { cnt = 0; - } for (Vehicle veh : GetAllVehs()) { @@ -210,9 +204,7 @@ static void OnTickRainbow() _SET_VEHICLE_NEON_LIGHTS_COLOUR(veh, r, g, b); for (int i = 0; i < 4; i++) - { _SET_VEHICLE_NEON_LIGHT_ENABLED(veh, i, true); - } // Headlights too @@ -233,9 +225,7 @@ static void OnTickRainbow() int b = std::sin(freq * cnt + 4) * 127 + 128; for (int i = 0; i < 13; i++) - { Memory::OverrideVehicleHeadlightColor(i, true, r, g, b); - } } // clang-format off diff --git a/ChaosMod/Effects/db/Vehs/VehsDetachWheel.cpp b/ChaosMod/Effects/db/Vehs/VehsDetachWheel.cpp index 7286b0b02..9cd81a675 100644 --- a/ChaosMod/Effects/db/Vehs/VehsDetachWheel.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsDetachWheel.cpp @@ -21,15 +21,11 @@ static void OnStart() { int index = GET_ENTITY_BONE_INDEX_BY_NAME(veh, wheel); if (index != -1) - { presentWheels.push_back(index); - } } if (!presentWheels.empty()) - { Memory::DetachBone(veh, presentWheels[g_Random.GetRandomInt(0, presentWheels.size() - 1)]); - } } } diff --git a/ChaosMod/Effects/db/Vehs/VehsFlyingCar.cpp b/ChaosMod/Effects/db/Vehs/VehsFlyingCar.cpp index 958b7f549..e4fb1bc95 100644 --- a/ChaosMod/Effects/db/Vehs/VehsFlyingCar.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsFlyingCar.cpp @@ -12,51 +12,33 @@ static void OnTick() Vehicle veh = GET_VEHICLE_PED_IS_IN(player, 0); int vehClass = GET_VEHICLE_CLASS(veh); if (vehClass == 15 || vehClass == 16) - { return; - } float currentSpeed = GET_ENTITY_SPEED(veh); float maxSpeed = GET_VEHICLE_MODEL_ESTIMATED_MAX_SPEED(GET_ENTITY_MODEL(veh)); if (currentSpeed < maxSpeed * 0.6) - { return; - } if (IS_CONTROL_PRESSED(0, 71)) // Forward - { SET_VEHICLE_FORWARD_SPEED(veh, std::min(maxSpeed * 3.f, currentSpeed + 0.3f)); - } if (vehClass == 14 || !IS_VEHICLE_ON_ALL_WHEELS(veh)) // Allow Steering if not "on ground" or boat in water { Vector3 rot = GET_ENTITY_ROTATION(veh, 2); if (IS_CONTROL_PRESSED(0, 63)) // Turn Left - { rot.z += 1.0; - } if (IS_CONTROL_PRESSED(0, 64)) // Turn Right - { rot.z -= 1.0; - } if (IS_CONTROL_PRESSED(0, 108)) // Roll Left - { rot.y -= 1.0; - } if (IS_CONTROL_PRESSED(0, 109)) // Roll Right - { rot.y += 1.0; - } if (IS_CONTROL_PRESSED(0, 111)) // Tilt Down - { rot.x -= 1.0; - } if (IS_CONTROL_PRESSED(0, 112)) // Tilt Up - { rot.x += 1.0; - } SET_ENTITY_ROTATION(veh, rot.x, rot.y, rot.z, 2, 1); } } diff --git a/ChaosMod/Effects/db/Vehs/VehsGTAOTraffic.cpp b/ChaosMod/Effects/db/Vehs/VehsGTAOTraffic.cpp index aa0ae12b4..7ad381915 100644 --- a/ChaosMod/Effects/db/Vehs/VehsGTAOTraffic.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsGTAOTraffic.cpp @@ -25,16 +25,10 @@ static void OnTick() std::vector::iterator it; for (it = goneThrough.begin(); it != goneThrough.end();) - { if (!DOES_ENTITY_EXIST(*it)) - { it = goneThrough.erase(it); - } else - { it++; - } - } } // clang-format off diff --git a/ChaosMod/Effects/db/Vehs/VehsHonkBoosting.cpp b/ChaosMod/Effects/db/Vehs/VehsHonkBoosting.cpp index 1826ede09..a6ca372a6 100644 --- a/ChaosMod/Effects/db/Vehs/VehsHonkBoosting.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsHonkBoosting.cpp @@ -5,12 +5,8 @@ static void OnTick() { for (auto veh : GetAllVehs()) - { if (IS_HORN_ACTIVE(veh)) - { Memory::ApplyForceToEntity(veh, 0, .0f, 50.f, .0f, .0f, .0f, .0f, 0, true, true, true, false, true); - } - } } // clang-format off diff --git a/ChaosMod/Effects/db/Vehs/VehsInvincible.cpp b/ChaosMod/Effects/db/Vehs/VehsInvincible.cpp index f17dbab1d..f89b229d8 100644 --- a/ChaosMod/Effects/db/Vehs/VehsInvincible.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsInvincible.cpp @@ -3,17 +3,13 @@ static void OnStop() { for (auto veh : GetAllVehs()) - { SET_ENTITY_INVINCIBLE(veh, false); - } } static void OnTick() { for (auto veh : GetAllVehs()) - { SET_ENTITY_INVINCIBLE(veh, true); - } } // clang-format off diff --git a/ChaosMod/Effects/db/Vehs/VehsInvisible.cpp b/ChaosMod/Effects/db/Vehs/VehsInvisible.cpp index 8452418d8..9e5ee5de3 100644 --- a/ChaosMod/Effects/db/Vehs/VehsInvisible.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsInvisible.cpp @@ -3,17 +3,13 @@ static void OnStop() { for (auto veh : GetAllVehs()) - { RESET_ENTITY_ALPHA(veh); - } } static void OnTick() { for (auto veh : GetAllVehs()) - { SET_ENTITY_ALPHA(veh, 0, 0); - } } // clang-format off diff --git a/ChaosMod/Effects/db/Vehs/VehsJesusTakeTheWheel.cpp b/ChaosMod/Effects/db/Vehs/VehsJesusTakeTheWheel.cpp index ceae6c9ee..6f4137bd4 100644 --- a/ChaosMod/Effects/db/Vehs/VehsJesusTakeTheWheel.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsJesusTakeTheWheel.cpp @@ -58,13 +58,9 @@ static void OnStart() } if (found) - { TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGE(jesus, veh, coords.x, coords.y, coords.z, 9999.f, 262668, 0.f); - } else - { TASK_VEHICLE_DRIVE_WANDER(jesus, veh, 9999.f, 4176732); - } SET_PED_KEEP_TASK(jesus, true); SET_BLOCKING_OF_NON_TEMPORARY_EVENTS(jesus, true); diff --git a/ChaosMod/Effects/db/Vehs/VehsJumpy.cpp b/ChaosMod/Effects/db/Vehs/VehsJumpy.cpp index ed50bbb70..80bbd010d 100644 --- a/ChaosMod/Effects/db/Vehs/VehsJumpy.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsJumpy.cpp @@ -13,12 +13,8 @@ static void OnTick() lastTick = curTick; for (Vehicle veh : GetAllVehs()) - { if (veh != playerVeh && !IS_ENTITY_IN_AIR(veh)) - { Memory::ApplyForceToEntityCenterOfMass(veh, 0, .0f, .0f, 500.f, true, false, true, true); - } - } } } diff --git a/ChaosMod/Effects/db/Vehs/VehsKillEngine.cpp b/ChaosMod/Effects/db/Vehs/VehsKillEngine.cpp index e48115caa..09f877d58 100644 --- a/ChaosMod/Effects/db/Vehs/VehsKillEngine.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsKillEngine.cpp @@ -3,9 +3,7 @@ static void OnStart() { for (Vehicle veh : GetAllVehs()) - { SET_VEHICLE_ENGINE_HEALTH(veh, 0.f); - } } // clang-format off diff --git a/ChaosMod/Effects/db/Vehs/VehsLockAll.cpp b/ChaosMod/Effects/db/Vehs/VehsLockAll.cpp index 0b9f7a7f3..e904c6186 100644 --- a/ChaosMod/Effects/db/Vehs/VehsLockAll.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsLockAll.cpp @@ -3,9 +3,7 @@ static void OnStart() { for (Vehicle veh : GetAllVehs()) - { SET_VEHICLE_DOORS_LOCKED(veh, 2); - } } // clang-format off diff --git a/ChaosMod/Effects/db/Vehs/VehsNoGrav.cpp b/ChaosMod/Effects/db/Vehs/VehsNoGrav.cpp index ae4089276..6dc647e1e 100644 --- a/ChaosMod/Effects/db/Vehs/VehsNoGrav.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsNoGrav.cpp @@ -3,17 +3,13 @@ static void OnStop() { for (auto veh : GetAllVehs()) - { SET_VEHICLE_GRAVITY(veh, true); - } } static void OnTick() { for (auto veh : GetAllVehs()) - { SET_VEHICLE_GRAVITY(veh, false); - } } // clang-format off diff --git a/ChaosMod/Effects/db/Vehs/VehsOneHitKO.cpp b/ChaosMod/Effects/db/Vehs/VehsOneHitKO.cpp index fb99efcdd..756298477 100644 --- a/ChaosMod/Effects/db/Vehs/VehsOneHitKO.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsOneHitKO.cpp @@ -9,9 +9,7 @@ static void OnStop() { for (Vehicle veh : GetAllVehs()) - { Memory::SetVehicleOutOfControl(veh, false); - } } static void OnTick() @@ -24,9 +22,7 @@ static void OnTick() lastTick = curTick; for (Vehicle veh : GetAllVehs()) - { Memory::SetVehicleOutOfControl(veh, true); - } } } diff --git a/ChaosMod/Effects/db/Vehs/VehsPlayerVehDespawn.cpp b/ChaosMod/Effects/db/Vehs/VehsPlayerVehDespawn.cpp index bf4f25364..977cb65ec 100644 --- a/ChaosMod/Effects/db/Vehs/VehsPlayerVehDespawn.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsPlayerVehDespawn.cpp @@ -15,9 +15,7 @@ static void OnStart() for (int i = -1; i < maxSeats - 1; i++) { if (IS_VEHICLE_SEAT_FREE(playerVeh, i, false)) - { continue; - } Ped ped = GET_PED_IN_VEHICLE_SEAT(playerVeh, i, false); @@ -36,9 +34,7 @@ static void OnStart() WAIT(0); for (Ped ped : vehPeds) - { SET_ENTITY_VELOCITY(ped, vehVel.x, vehVel.y, vehVel.z); - } } } diff --git a/ChaosMod/Effects/db/Vehs/VehsPlayerVehExplode.cpp b/ChaosMod/Effects/db/Vehs/VehsPlayerVehExplode.cpp index 23c66d90c..2abacdec5 100644 --- a/ChaosMod/Effects/db/Vehs/VehsPlayerVehExplode.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsPlayerVehExplode.cpp @@ -7,9 +7,7 @@ static void OnStart() Ped playerPed = PLAYER_PED_ID(); if (!IS_PED_IN_ANY_VEHICLE(playerPed, false)) - { return; - } Vehicle veh = GET_VEHICLE_PED_IS_IN(playerPed, false); @@ -39,9 +37,7 @@ static void OnStart() Ped ped = GET_PED_IN_VEHICLE_SEAT(veh, i, false); if (!ped) - { continue; - } TASK_LEAVE_VEHICLE(ped, veh, 4160); } diff --git a/ChaosMod/Effects/db/Vehs/VehsPlayerVehLock.cpp b/ChaosMod/Effects/db/Vehs/VehsPlayerVehLock.cpp index 6ac56a041..b73b777b5 100644 --- a/ChaosMod/Effects/db/Vehs/VehsPlayerVehLock.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsPlayerVehLock.cpp @@ -3,9 +3,7 @@ static void OnStop() { for (Vehicle veh : GetAllVehs()) - { SET_VEHICLE_DOORS_LOCKED(veh, 1); - } } static void OnTick() diff --git a/ChaosMod/Effects/db/Vehs/VehsPropModels.cpp b/ChaosMod/Effects/db/Vehs/VehsPropModels.cpp index dc6b99cb0..3c4fa8ec8 100644 --- a/ChaosMod/Effects/db/Vehs/VehsPropModels.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsPropModels.cpp @@ -47,9 +47,7 @@ static void OnTick() // Don't include models that are either very small or very large if (modelSize > 0.75f && modelSize < 6.f) - { availablePropModels.push_back(model); - } } } @@ -94,9 +92,7 @@ static void OnTick() if (!DOES_ENTITY_EXIST(veh)) { if (DOES_ENTITY_EXIST(prop)) - { DELETE_OBJECT(&prop); - } it = vehPropsMap.erase(it); } @@ -128,14 +124,10 @@ static void OnStop() Object prop = it.second; if (DOES_ENTITY_EXIST(veh)) - { RESET_ENTITY_ALPHA(veh); - } if (DOES_ENTITY_EXIST(prop)) - { DELETE_OBJECT(&prop); - } } vehPropsMap.clear(); diff --git a/ChaosMod/Effects/db/Vehs/VehsRandomTraffic.cpp b/ChaosMod/Effects/db/Vehs/VehsRandomTraffic.cpp index 2a1717409..7146541b5 100644 --- a/ChaosMod/Effects/db/Vehs/VehsRandomTraffic.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsRandomTraffic.cpp @@ -20,9 +20,7 @@ static void OnTick() Ped driver = GET_PED_IN_VEHICLE_SEAT(newVeh, -1, 0); if (driver && DOES_ENTITY_EXIST(driver) && !IS_PED_A_PLAYER(driver)) - { TASK_VEHICLE_DRIVE_WANDER(driver, newVeh, 40, 786603); - } WAIT(0); } diff --git a/ChaosMod/Effects/db/Vehs/VehsRotAll.cpp b/ChaosMod/Effects/db/Vehs/VehsRotAll.cpp index da46874eb..79e4d58d9 100644 --- a/ChaosMod/Effects/db/Vehs/VehsRotAll.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsRotAll.cpp @@ -12,26 +12,18 @@ static void OnStart() // Horizontal flip if (rot.x < 180.f) - { SET_ENTITY_ROTATION(veh, rot.x + 180.f, rot.y, rot.z, 2, true); - } else - { SET_ENTITY_ROTATION(veh, rot.x - 180.f, rot.y, rot.z, 2, true); - } } else { // Vertical flip if (rot.y < 180.f) - { SET_ENTITY_ROTATION(veh, rot.x, rot.y + 180.f, rot.z, 2, true); - } else - { SET_ENTITY_ROTATION(veh, rot.x, rot.y - 180.f, rot.z, 2, true); - } } SET_ENTITY_VELOCITY(veh, vel.x, vel.y, vel.z); diff --git a/ChaosMod/Effects/db/Vehs/VehsSlipperyVehs.cpp b/ChaosMod/Effects/db/Vehs/VehsSlipperyVehs.cpp index 65b5f090a..d0113add4 100644 --- a/ChaosMod/Effects/db/Vehs/VehsSlipperyVehs.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsSlipperyVehs.cpp @@ -3,9 +3,7 @@ static void OnStop() { for (auto veh : GetAllVehs()) - { SET_VEHICLE_REDUCE_GRIP(veh, false); - } } static void OnTick() diff --git a/ChaosMod/Effects/db/Vehs/VehsSpamDoors.cpp b/ChaosMod/Effects/db/Vehs/VehsSpamDoors.cpp index b807eb207..07416d0eb 100644 --- a/ChaosMod/Effects/db/Vehs/VehsSpamDoors.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsSpamDoors.cpp @@ -25,21 +25,15 @@ static void OnTick() { lastTick = currentTick; for (auto veh : GetAllVehs()) - { SET_VEHICLE_DOORS_SHUT(veh, false); // Closes ALL doors of vehicle - } } } static void OnStop() { for (auto veh : GetAllVehs()) - { for (int i = 0; i < 7; i++) - { _SET_VEHICLE_DOOR_CAN_BREAK(veh, i, true); - } - } } // clang-format off diff --git a/ChaosMod/Effects/db/Vehs/VehsSpawner.cpp b/ChaosMod/Effects/db/Vehs/VehsSpawner.cpp index 77db19ce8..69161661a 100644 --- a/ChaosMod/Effects/db/Vehs/VehsSpawner.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsSpawner.cpp @@ -233,9 +233,7 @@ static void OnStartRandom() { int max = GET_NUM_VEHICLE_MODS(veh, i); if (max > 0) - { SET_VEHICLE_MOD(veh, i, g_Random.GetRandomInt(0, max - 1), g_Random.GetRandomInt(0, 1)); - } TOGGLE_VEHICLE_MOD(veh, i, g_Random.GetRandomInt(0, 1)); } @@ -251,9 +249,7 @@ static void OnStartRandom() _SET_VEHICLE_NEON_LIGHTS_COLOUR(veh, g_Random.GetRandomInt(0, 255), g_Random.GetRandomInt(0, 255), g_Random.GetRandomInt(0, 255)); for (int i = 0; i < 4; i++) - { _SET_VEHICLE_NEON_LIGHT_ENABLED(veh, i, true); - } _SET_VEHICLE_XENON_LIGHTS_COLOR(veh, g_Random.GetRandomInt(0, 12)); } diff --git a/ChaosMod/Effects/db/Vehs/VehsSpeedMin.cpp b/ChaosMod/Effects/db/Vehs/VehsSpeedMin.cpp index dc54e6899..2a1700ca9 100644 --- a/ChaosMod/Effects/db/Vehs/VehsSpeedMin.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsSpeedMin.cpp @@ -81,9 +81,7 @@ static void OnTick() } if (Beepable(ms_TimeReserve - tickDelta) && !Beepable(ms_TimeReserve)) - { PLAY_SOUND_FRONTEND(-1, "Beep_Red", "DLC_HEIST_HACKING_SNAKE_SOUNDS", true); - } ms_TimeReserve -= tickDelta; } @@ -92,9 +90,7 @@ static void OnTick() overlaycolor = 25; ms_TimeReserve += tickDelta / 2; // slows down regaining time if (ms_TimeReserve > WAIT_TIME) - { ms_TimeReserve = WAIT_TIME; - } } ms_LastTick = currentTick; @@ -136,9 +132,7 @@ static void OnStart() { ms_Overlay = REQUEST_SCALEFORM_MOVIE("MP_BIG_MESSAGE_FREEMODE"); while (!HAS_SCALEFORM_MOVIE_LOADED(ms_Overlay)) - { WAIT(0); - } ms_EnteredVehicle = false; ms_LastTick = GET_GAME_TIMER(); ms_LastVeh = 0; diff --git a/ChaosMod/Effects/db/Vehs/VehsTiny.cpp b/ChaosMod/Effects/db/Vehs/VehsTiny.cpp index 84a3118ba..c65cc68d4 100644 --- a/ChaosMod/Effects/db/Vehs/VehsTiny.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsTiny.cpp @@ -28,14 +28,10 @@ static void OnTick() Vector3 vehicleSize = Vector3(rightVector.Length(), forwardVector.Length(), upVector.Length()); if (!vehicleDefaultSizes.contains(veh)) - { vehicleDefaultSizes[veh] = vehicleSize; - } if (VectorEquals(vehicleDefaultSizes[veh], vehicleSize)) - { Memory::SetVehicleScale(veh, 0.5f); - } } } } diff --git a/ChaosMod/Effects/db/Vehs/VehsTirePoppin.cpp b/ChaosMod/Effects/db/Vehs/VehsTirePoppin.cpp index 3036b714a..f7b9920c6 100644 --- a/ChaosMod/Effects/db/Vehs/VehsTirePoppin.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsTirePoppin.cpp @@ -3,12 +3,8 @@ static void OnStop() { for (Vehicle veh : GetAllVehs()) - { for (int i = 0; i < 47; i++) - { SET_VEHICLE_TYRE_FIXED(veh, i); - } - } } static void OnTick() diff --git a/ChaosMod/Effects/db/Vehs/VehsTriggerAlarm.cpp b/ChaosMod/Effects/db/Vehs/VehsTriggerAlarm.cpp index dbc5c49db..4b1453fac 100644 --- a/ChaosMod/Effects/db/Vehs/VehsTriggerAlarm.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsTriggerAlarm.cpp @@ -20,9 +20,7 @@ static void OnTick() static void OnStop() { for (auto veh : GetAllVehs()) - { SET_VEHICLE_ALARM(veh, false); - } } // clang-format off diff --git a/ChaosMod/Effects/db/Vehs/VehsUpgradeController.cpp b/ChaosMod/Effects/db/Vehs/VehsUpgradeController.cpp index b65e264a3..bcd00675c 100644 --- a/ChaosMod/Effects/db/Vehs/VehsUpgradeController.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsUpgradeController.cpp @@ -9,9 +9,7 @@ static void OnStartMaxUpgrades() { int max = GET_NUM_VEHICLE_MODS(veh, i); if (max > 0) - { SET_VEHICLE_MOD(veh, i, max - 1, true); - } TOGGLE_VEHICLE_MOD(veh, i, true); } @@ -27,9 +25,7 @@ static void OnStartMaxUpgrades() _SET_VEHICLE_NEON_LIGHTS_COLOUR(veh, g_Random.GetRandomInt(0, 255), g_Random.GetRandomInt(0, 255), g_Random.GetRandomInt(0, 255)); for (int i = 0; i < 4; i++) - { _SET_VEHICLE_NEON_LIGHT_ENABLED(veh, i, true); - } _SET_VEHICLE_XENON_LIGHTS_COLOR(veh, g_Random.GetRandomInt(0, 12)); @@ -58,9 +54,7 @@ static void OnStartRandomUpgrades() { int max = GET_NUM_VEHICLE_MODS(veh, i); if (max > 0) - { SET_VEHICLE_MOD(veh, i, g_Random.GetRandomInt(0, max - 1), g_Random.GetRandomInt(0, 1)); - } TOGGLE_VEHICLE_MOD(veh, i, g_Random.GetRandomInt(0, 1)); } @@ -76,9 +70,7 @@ static void OnStartRandomUpgrades() _SET_VEHICLE_NEON_LIGHTS_COLOUR(veh, g_Random.GetRandomInt(0, 255), g_Random.GetRandomInt(0, 255), g_Random.GetRandomInt(0, 255)); for (int i = 0; i < 4; i++) - { _SET_VEHICLE_NEON_LIGHT_ENABLED(veh, i, true); - } _SET_VEHICLE_XENON_LIGHTS_COLOR(veh, g_Random.GetRandomInt(0, 12)); diff --git a/ChaosMod/Effects/db/Vehs/VehsWeapons.cpp b/ChaosMod/Effects/db/Vehs/VehsWeapons.cpp index fc74d2323..97bb7627c 100644 --- a/ChaosMod/Effects/db/Vehs/VehsWeapons.cpp +++ b/ChaosMod/Effects/db/Vehs/VehsWeapons.cpp @@ -32,9 +32,7 @@ static void OnTick() { REQUEST_WEAPON_ASSET(weaponHash, 31, 0); while (!HAS_WEAPON_ASSET_LOADED(weaponHash)) - { WAIT(0); - } } Vehicle veh = GET_VEHICLE_PED_IS_IN(player, false); Vector3 vehPos = GET_ENTITY_COORDS(veh, false); diff --git a/ChaosMod/Main.cpp b/ChaosMod/Main.cpp index acd76f0aa..391879d25 100644 --- a/ChaosMod/Main.cpp +++ b/ChaosMod/Main.cpp @@ -48,9 +48,7 @@ static std::array ParseConfigColorString(const std::string &colorText) int j = 0; for (int i = 3; i < 9; i += 2) - { Util::TryParse(colorText.substr(i, 2), colors[j++], 16); - } return colors; } @@ -70,9 +68,7 @@ static void Init() { auto gameBuild = Memory::GetGameBuild(); if (gameBuild.empty()) - { gameBuild = "Unknown"; - } LOG("Game Build: " << gameBuild); @@ -156,9 +152,7 @@ static void Init() std::string line; line.resize(64); while (file.getline(line.data(), 64)) - { blacklistedComponentNames.insert(StringTrim(line.substr(0, line.find("\n")))); - } } } @@ -216,9 +210,7 @@ static void Init() #ifdef WITH_DEBUG_PANEL_SUPPORT if (DoesFeatureFlagExist("enabledebugsocket")) - { INIT_COMPONENT("DebugSocket", "Debug Websocket", DebugSocket); - } #endif #undef INIT_COMPONENT @@ -283,9 +275,7 @@ static void MainRun() ClearEntityPool(); for (auto component : g_Components) - { component->OnModPauseCleanup(); - } } else { @@ -305,9 +295,7 @@ static void MainRun() } if (isDisabled) - { continue; - } if (ms_Flags.ClearAllEffects) { @@ -338,9 +326,7 @@ static void MainRun() } for (auto component : g_Components) - { component->OnRun(); - } } } @@ -380,9 +366,7 @@ namespace Main ms_Flags.ClearAllEffects = true; if (ComponentExists()) - { GetComponent()->ShowClearEffectsSplash(); - } } } else if (key == VK_OEM_PERIOD) @@ -396,29 +380,21 @@ namespace Main else if (key == VK_OEM_COMMA) { if (ComponentExists() && GetComponent()->IsEnabled()) - { GetComponent()->SetVisible(!GetComponent()->IsVisible()); - } } else if (key == 0x4B) // K { if (ms_Flags.AntiSoftlockShortcutEnabled && isShiftPressed) - { ms_Flags.RunAntiSoftlock = true; - } } else if (key == 0x4C) // L { if (ms_Flags.ToggleModShortcutEnabled) - { ms_Flags.ToggleModState = true; - } } } for (auto component : g_Components) - { component->OnKeyInput(key, wasDownBefore, isUpNow, isCtrlPressed, isShiftPressed, isWithAlt); - } } } diff --git a/ChaosMod/Memory/Audio.h b/ChaosMod/Memory/Audio.h index 9e09d2913..ccaf0236f 100644 --- a/ChaosMod/Memory/Audio.h +++ b/ChaosMod/Memory/Audio.h @@ -25,15 +25,11 @@ namespace Memory Handle initHandle = Memory::FindPattern("48 89 5C 24 08 57 48 83 EC 40 F3 41 0F 10 00"); if (!initHandle.IsValid()) - { return Handle(); - } Handle handle2 = initHandle.At(0x63).Into(); if (!handle2.IsValid()) - { return Handle(); - } getHashKeyFunc = handle2.At(0x20).Into().Get(); playAmbientSpeechFunc = handle2.At(0x6E).Into().Get(); @@ -41,9 +37,7 @@ namespace Memory }(); if (!handle.IsValid()) - { return; - } uintptr_t globalPtr = handle.At(0x53).Into().Addr(); diff --git a/ChaosMod/Memory/EntityFragments.h b/ChaosMod/Memory/EntityFragments.h index a7212262e..ca804ae3e 100644 --- a/ChaosMod/Memory/EntityFragments.h +++ b/ChaosMod/Memory/EntityFragments.h @@ -111,13 +111,9 @@ namespace Memory auto unkType = fragInst->unkType; if (unkType < 2) - { return fragPhysicsLODAddresses[unkType]; - } else - { return fragPhysicsLODAddresses[0]; - } } inline int GetFragmentGroupCount(FragInst *fragInst) @@ -138,9 +134,7 @@ namespace Memory unsigned short id = fragTypeChildArr[i]->boneId; if (boneIndex == GetBoneIndexByBoneId(crSkeletonData, id)) - { return i; - } } return -1; @@ -152,9 +146,7 @@ namespace Memory Memory::FindPattern("0F BE 5E 06 48 8B CF FF 50 ?? 8B D3 48 8B C8 E8 ?? ?? ?? ?? 8B 4E ??"); if (!handle.IsValid()) - { return false; - } getFragInstVFuncOffset = handle.At(9).Value(); detachFragmentPartByIndexFunc = handle.At(15).Into().Get(); @@ -165,9 +157,7 @@ namespace Memory inline FragInst *GetFragInst(Entity entity) { if (!InitBones()) - { return nullptr; - } DWORD64 address = GetScriptHandleBaseAddress(entity); return (*(FragInst * (__fastcall **)(DWORD64))(*reinterpret_cast(address) @@ -180,9 +170,7 @@ namespace Memory { EntityFragment::FragInst *fragInst = EntityFragment::GetFragInst(entity); if (!fragInst || index < 0 || index >= GetFragmentGroupCount(fragInst)) - { return -1; - } auto fragPhysicsLOD = GetFragPhysicsLOD(fragInst); auto crSkeletonData = GetSkeletonData(fragInst); @@ -196,9 +184,7 @@ namespace Memory { EntityFragment::FragInst *fragInst = EntityFragment::GetFragInst(entity); if (!fragInst) - { return 0; - } return GetFragmentGroupCount(fragInst); } @@ -207,25 +193,17 @@ namespace Memory { EntityFragment::FragInst *fragInst = EntityFragment::GetFragInst(entity); if (!fragInst) - { return; - } if (!IsFreeToActivatePhysics()) - { return; - } int fragIndex = GetFragIndexByBoneIndex(fragInst, boneIndex); if (fragIndex == -1) - { return; - } if (fragIndex < GetFragmentGroupCount(fragInst)) - { EntityFragment::detachFragmentPartByIndexFunc(fragInst, fragIndex); - } } } \ No newline at end of file diff --git a/ChaosMod/Memory/Gravity.h b/ChaosMod/Memory/Gravity.h index 97a854b47..2642f50e3 100644 --- a/ChaosMod/Memory/Gravity.h +++ b/ChaosMod/Memory/Gravity.h @@ -16,9 +16,7 @@ namespace Memory { auto handle = FindPattern("E8 ? ? ? ? 48 8D 0D ? ? ? ? BA ? ? ? ? E8 ? ? ? ? 89 05 ? ? ? ? 48 83 C4 28 C3"); if (!handle.IsValid()) - { return; - } handle = handle.Into().At(24); gravAddr = handle.At(3).Into().Get(); diff --git a/ChaosMod/Memory/Hooks/ApplyChangeSetEntryHook.cpp b/ChaosMod/Memory/Hooks/ApplyChangeSetEntryHook.cpp index 3f34a2f5b..b319010bc 100644 --- a/ChaosMod/Memory/Hooks/ApplyChangeSetEntryHook.cpp +++ b/ChaosMod/Memory/Hooks/ApplyChangeSetEntryHook.cpp @@ -66,9 +66,7 @@ void HK_ApplyChangeSetEntryStub(ChangeSetEntry *entry) }; if (entry->type == 6 || entry->type == 7 || !entry->dataFile || !badFiles.contains(entry->dataFile->name)) - { OG_ApplyChangeSetEntryStub(entry); - } } static bool OnHook() @@ -77,9 +75,7 @@ static bool OnHook() handle = Memory::FindPattern("48 8D 0C 40 48 8D 0C CE E8 ? ? ? ? FF C3"); if (!handle.IsValid()) - { return false; - } Memory::AddHook(handle.At(8).Into().Get(), HK_ApplyChangeSetEntryStub, &OG_ApplyChangeSetEntryStub); diff --git a/ChaosMod/Memory/Hooks/AudioClearnessHook.cpp b/ChaosMod/Memory/Hooks/AudioClearnessHook.cpp index 70e50567d..a96507fb2 100644 --- a/ChaosMod/Memory/Hooks/AudioClearnessHook.cpp +++ b/ChaosMod/Memory/Hooks/AudioClearnessHook.cpp @@ -17,9 +17,7 @@ static bool OnHook() { Handle handle = Memory::FindPattern("E8 ? ? ? ? 83 64 24 ? ? 49 8B 8C 36 ? ? ? ? 45 33 C9"); if (!handle.IsValid()) - { return false; - } Memory::AddHook(handle.Into().Get(), _HK_rage__audRequestedSettings__SetClearness, &_OG_rage__audRequestedSettings__SetClearness); diff --git a/ChaosMod/Memory/Hooks/AudioPitchHook.cpp b/ChaosMod/Memory/Hooks/AudioPitchHook.cpp index c99ad6aea..25f32e14e 100644 --- a/ChaosMod/Memory/Hooks/AudioPitchHook.cpp +++ b/ChaosMod/Memory/Hooks/AudioPitchHook.cpp @@ -18,9 +18,7 @@ static bool OnHook() auto handle = Memory::FindPattern("E8 ? ? ? ? 49 8B 8F 00 31 00 00 0F B6 81 80 00 00 00 3D FF 00 00 00 74 25 0F AF 05"); if (!handle.IsValid()) - { return false; - } Memory::AddHook(handle.Into().Get(), _HK_rage__audRequestedSettings__SetPitch, &_OG_rage__audRequestedSettings__SetPitch); diff --git a/ChaosMod/Memory/Hooks/GetLabelTextHook.cpp b/ChaosMod/Memory/Hooks/GetLabelTextHook.cpp index d55111e0b..499b2883e 100644 --- a/ChaosMod/Memory/Hooks/GetLabelTextHook.cpp +++ b/ChaosMod/Memory/Hooks/GetLabelTextHook.cpp @@ -14,9 +14,7 @@ const char *HK_GetLabelText(void *text, Hash hash) { const auto &result = ms_CustomLabels.find(hash); if (result != ms_CustomLabels.end()) - { return result->second.data(); - } return OG_GetLabelText(text, hash); } @@ -25,9 +23,7 @@ static bool OnHook() { auto handle = Memory::FindPattern("48 8B CB 8B D0 E8 ? ? ? ? 48 85 C0 0F 95 C0"); if (!handle.IsValid()) - { return false; - } Memory::AddHook(handle.At(5).Into().Get(), HK_GetLabelText, &OG_GetLabelText); @@ -43,9 +39,7 @@ namespace Hooks auto hash = GET_HASH_KEY(label.data()); if (ms_CustomLabels.contains(hash)) - { return; - } ms_CustomLabels[hash] = text; ms_CustomLabelHashes.push(hash); diff --git a/ChaosMod/Memory/Hooks/HandleToEntityStructHook.cpp b/ChaosMod/Memory/Hooks/HandleToEntityStructHook.cpp index 01a45c211..23ba4d72c 100644 --- a/ChaosMod/Memory/Hooks/HandleToEntityStructHook.cpp +++ b/ChaosMod/Memory/Hooks/HandleToEntityStructHook.cpp @@ -10,17 +10,13 @@ __int64 (*_OG_HandleToEntityStruct)(Entity entity); __int64 _HK_HandleToEntityStruct(Entity entity) { if (entity <= 0) - { return 0; - } Entity vehToContinue = entity; while (ms_VehicleMap.count(vehToContinue) > 0) { vehToContinue = ms_VehicleMap[vehToContinue]; if (vehToContinue <= 0) - { return 0; - } } return _OG_HandleToEntityStruct(vehToContinue); } @@ -29,9 +25,7 @@ static bool OnHook() { Handle handle = Memory::FindPattern("83 F9 FF 74 31 4C 8B 0D"); if (!handle.IsValid()) - { return false; - } Memory::AddHook(handle.Get(), _HK_HandleToEntityStruct, &_OG_HandleToEntityStruct); diff --git a/ChaosMod/Memory/Hooks/Hook.h b/ChaosMod/Memory/Hooks/Hook.h index 482d4507c..2c80a356d 100644 --- a/ChaosMod/Memory/Hooks/Hook.h +++ b/ChaosMod/Memory/Hooks/Hook.h @@ -24,9 +24,7 @@ namespace Memory : m_HookFunc(hookFunc), m_CleanupFunc(cleanupFunc), m_Name(name), m_IsLateHook(isLateHook) { if (g_pRegisteredHooks) - { m_Next = g_pRegisteredHooks; - } g_pRegisteredHooks = this; } @@ -43,9 +41,7 @@ namespace Memory inline void RunCleanup() { if (m_CleanupFunc) - { m_CleanupFunc(); - } } inline const std::string &GetName() const diff --git a/ChaosMod/Memory/Hooks/MiscHooks.cpp b/ChaosMod/Memory/Hooks/MiscHooks.cpp index 2005839a2..5e9f19aba 100644 --- a/ChaosMod/Memory/Hooks/MiscHooks.cpp +++ b/ChaosMod/Memory/Hooks/MiscHooks.cpp @@ -8,14 +8,10 @@ void (*OG_crSkeleton_GetGlobalMtx)(__int64, unsigned int, void *); void HK_crSkeleton_GetGlobalMtx(__int64 skeleton, unsigned int id, void *matrix) { if (!skeleton) - { return; - } if (id == -1) - { id = 0; - } OG_crSkeleton_GetGlobalMtx(skeleton, id, matrix); } @@ -26,13 +22,9 @@ static bool OnHook() handle = Memory::FindPattern("E8 ? ? ? ? 4D 03 F5"); if (!handle.IsValid()) - { LOG("crSkeleton::GetGlobalMtx not found!"); - } else - { Memory::AddHook(handle.Into().Get(), HK_crSkeleton_GetGlobalMtx, &OG_crSkeleton_GetGlobalMtx); - } return true; } diff --git a/ChaosMod/Memory/Hooks/PresentHook.cpp b/ChaosMod/Memory/Hooks/PresentHook.cpp index 7550267ef..286e96f96 100644 --- a/ChaosMod/Memory/Hooks/PresentHook.cpp +++ b/ChaosMod/Memory/Hooks/PresentHook.cpp @@ -11,9 +11,7 @@ HRESULT (*OG_IDXGISwapChain_Present)(IDXGISwapChain *, UINT, UINT); HRESULT HK_IDXGISwapChain_Present(IDXGISwapChain *swapChain, UINT syncInterval, UINT flags) { if (!(flags & DXGI_PRESENT_TEST)) - { Hooks::OnPresent.Fire(); - } return OG_IDXGISwapChain_Present(swapChain, syncInterval, flags); } @@ -24,9 +22,7 @@ static bool OnHook() handle = Memory::FindPattern("80 7E 10 00 48 8B"); if (!handle.IsValid()) - { return false; - } // IDXGISwapChain handle = *handle.At(6).Into().Value(); @@ -42,9 +38,7 @@ static void OnCleanup() { // Only reset vftable entries if address still points to our retour if (ms_PresentAddr && *ms_PresentAddr == HK_IDXGISwapChain_Present) - { Memory::Write(ms_PresentAddr, reinterpret_cast(OG_IDXGISwapChain_Present)); - } } static RegisterHook registerHook(OnHook, OnCleanup, "IDXGISwapChain::Present", true); \ No newline at end of file diff --git a/ChaosMod/Memory/Hooks/ScriptThreadRunHook.cpp b/ChaosMod/Memory/Hooks/ScriptThreadRunHook.cpp index 395ed834d..f9b42129b 100644 --- a/ChaosMod/Memory/Hooks/ScriptThreadRunHook.cpp +++ b/ChaosMod/Memory/Hooks/ScriptThreadRunHook.cpp @@ -22,9 +22,7 @@ __int64 (*OG_rage__scrThread__Run)(rage::scrThread *); __int64 HK_rage__scrThread__Run(rage::scrThread *thread) { if (!Hooks::OnScriptThreadRun.Fire(thread)) - { return 0; - } if (!strcmp(thread->GetName(), "shop_controller")) { @@ -67,9 +65,7 @@ __int64 HK_rage__scrThread__Run(rage::scrThread *thread) // Scripthook (most likely) relies on these to run our script thread // We don't want to block ourselves of course :p if (strcmp(scriptName, "main") && strcmp(scriptName, "main_persistent") && strcmp(scriptName, "control_thread")) - { return 0; - } } return OG_rage__scrThread__Run(thread); @@ -82,9 +78,7 @@ static bool OnHook() handle = Memory::FindPattern( "48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 41 56 41 57 48 83 EC 20 48 8D 81 ? 00 00 00"); if (!handle.IsValid()) - { return false; - } Memory::AddHook(handle.Get(), HK_rage__scrThread__Run, &OG_rage__scrThread__Run); diff --git a/ChaosMod/Memory/Hooks/ShaderHook.cpp b/ChaosMod/Memory/Hooks/ShaderHook.cpp index f15d76d27..d7f72a50c 100644 --- a/ChaosMod/Memory/Hooks/ShaderHook.cpp +++ b/ChaosMod/Memory/Hooks/ShaderHook.cpp @@ -33,9 +33,7 @@ void *HK_rage__CreateShader(const char *name, BYTE *data, DWORD size, DWORD type } if (nameFilter && std::string_view(name).find(nameFilter) != std::string_view::npos) - { return OG_rage__CreateShader(name, ms_ShaderBytecode.data(), ms_ShaderBytecode.size(), type, out); - } } return OG_rage__CreateShader(name, data, size, type, out); @@ -61,9 +59,7 @@ static bool OnHook() handle = Memory::FindPattern("E8 ? ? ? ? 48 89 83 28 02 00 00 8B 44 24 30 89 83 30 02 00 00 EB 0F"); if (!handle.IsValid()) - { return false; - } Memory::AddHook(handle.Into().Get(), HK_rage__CreateShader, &OG_rage__CreateShader); @@ -99,9 +95,7 @@ namespace Hooks std::copy(ptr, ptr + shader->GetBufferSize(), std::back_inserter(shaderBytecode)); if (shaderCache.size() > SHADER_CACHE_MAX_ENTRIES) - { shaderCache.erase(shaderCache.begin()); - } shaderCache[hash] = shaderBytecode; result = shaderCache.find(hash); @@ -124,9 +118,7 @@ namespace Hooks using namespace std::chrono_literals; while (future.wait_for(0ms) != std::future_status::ready) - { WAIT(0); - } } if (result != shaderCache.end()) diff --git a/ChaosMod/Memory/Memory.cpp b/ChaosMod/Memory/Memory.cpp index 6e7aa3e48..3b4e35f1b 100644 --- a/ChaosMod/Memory/Memory.cpp +++ b/ChaosMod/Memory/Memory.cpp @@ -81,9 +81,7 @@ namespace Memory std::string line; line.resize(64); while (file.getline(line.data(), 64)) - { ms_BlacklistedHookNames.insert(StringTrim(line.substr(0, line.find("\n")))); - } } } @@ -95,9 +93,7 @@ namespace Memory registeredHook = registeredHook->GetNext()) { if (registeredHook->IsLateHook()) - { continue; - } const auto &hookName = registeredHook->GetName(); @@ -110,9 +106,7 @@ namespace Memory LOG("Running " << hookName << " hook"); if (!registeredHook->RunHook()) - { LOG(hookName << " hook failed!"); - } } MH_EnableHook(MH_ALL_HOOKS); @@ -128,9 +122,7 @@ namespace Memory const auto &hookName = registeredHook->GetName(); if (ms_BlacklistedHookNames.contains(hookName)) - { continue; - } LOG("Running " << hookName << " hook cleanup"); @@ -153,9 +145,7 @@ namespace Memory registeredHook = registeredHook->GetNext()) { if (!registeredHook->IsLateHook()) - { continue; - } const auto &hookName = registeredHook->GetName(); @@ -168,9 +158,7 @@ namespace Memory LOG("Running " << hookName << " hook"); if (!registeredHook->RunHook()) - { LOG(hookName << " hook failed!"); - } } MH_EnableHook(MH_ALL_HOOKS); @@ -192,17 +180,13 @@ namespace Memory { auto copy = pattern; for (size_t pos = copy.find("??"); pos != std::string::npos; pos = copy.find("??", pos + 1)) - { copy.replace(pos, 2, "?"); - } auto thePattern = scanRange.StartAddr == 0 && scanRange.EndAddr == 0 ? hook::pattern(copy) : hook::pattern(scanRange.StartAddr, scanRange.EndAddr, copy); if (!thePattern.size()) - { return Handle(); - } return Handle(uintptr_t(thePattern.get_first())); }; @@ -215,9 +199,7 @@ namespace Memory using namespace std::chrono_literals; while (future.wait_for(0ms) != std::future_status::ready) - { WAIT(0); - } return handle; } @@ -240,9 +222,7 @@ namespace Memory { auto typeDesc = ms_BaseAddr + rva; if (typeDesc) - { return reinterpret_cast(typeDesc + 16); - } } } } @@ -257,9 +237,7 @@ namespace Memory { auto handle = FindPattern("4C 8D 05 ? ? ? ? 4D 8B 08 4D 85 C9 74 11"); if (!handle.IsValid()) - { return nullptr; - } return handle.At(2).Into().Get(); }(); @@ -298,9 +276,7 @@ namespace Memory } if (fallbackToSHV) - { LOG("Warning: FiveM (non-sp) detected, features such as Failsafe will not work!"); - } return fallbackToSHV; }(); @@ -314,21 +290,15 @@ namespace Memory { auto handle = Memory::FindPattern("33 DB 38 1D ? ? ? ? 89 5C 24 38"); if (!handle.IsValid()) - { return {}; - } std::string buildStr = handle.At(3).Into().Get(); if (buildStr.empty()) - { return {}; - } auto splitIndex = buildStr.find("-dev"); if (splitIndex == buildStr.npos) - { return {}; - } return buildStr.substr(0, splitIndex); }(); diff --git a/ChaosMod/Memory/Memory.h b/ChaosMod/Memory/Memory.h index 40aec181f..1852ca590 100644 --- a/ChaosMod/Memory/Memory.h +++ b/ChaosMod/Memory/Memory.h @@ -35,9 +35,7 @@ namespace Memory auto result = MH_CreateHook(target, reinterpret_cast(detour), reinterpret_cast(orig)); if (result == MH_OK) - { MH_EnableHook(target); - } return result; } @@ -48,9 +46,7 @@ namespace Memory VirtualProtect(addr, sizeof(T) * count, PAGE_EXECUTE_READWRITE, &oldProtect); for (int i = 0; i < count; i++) - { addr[i] = value; - } VirtualProtect(addr, sizeof(T) * count, oldProtect, &oldProtect); } diff --git a/ChaosMod/Memory/Misc.h b/ChaosMod/Memory/Misc.h index 7c72c7870..39e59a85d 100644 --- a/ChaosMod/Memory/Misc.h +++ b/ChaosMod/Memory/Misc.h @@ -21,9 +21,7 @@ namespace Memory { Handle handle = FindPattern("E8 ? ? ? ? C6 05 ? ? ? ? ? 48 83 C4 58"); if (!handle.IsValid()) - { return; - } patchByte = handle.Into().Get(); } diff --git a/ChaosMod/Memory/PedModels.h b/ChaosMod/Memory/PedModels.h index 26ac30965..d2d48c6ee 100644 --- a/ChaosMod/Memory/PedModels.h +++ b/ChaosMod/Memory/PedModels.h @@ -23,9 +23,7 @@ namespace Memory handle = FindPattern("41 F7 F0 48 8B 05 ? ? ? 00 4C"); if (!handle.IsValid()) - { return pedModels; - } DWORD64 qword_7FF69DB37F30 = handle.At(5).Into().Value(); @@ -33,18 +31,14 @@ namespace Memory handle = FindPattern("73 17 4C 0F AF 05"); if (!handle.IsValid()) - { return pedModels; - } DWORD64 qword_7FF69DB37EE8 = handle.At(5).Into().Value(); DWORD64 qword_7FF69DB37ED0 = handle.At(12).Into().Value(); handle = FindPattern("3B 05 ? ? ? 00 7D 35"); if (!handle.IsValid()) - { return pedModels; - } DWORD dword_7FF69DB37ED8 = handle.At(1).Into().Value(); DWORD64 qword_7FF69DB37F00 = handle.At(18).Into().Value(); @@ -53,9 +47,7 @@ namespace Memory { auto model = *reinterpret_cast(qword_7FF69DB37F30 + 8 * i); if (!model) - { continue; - } // These will crash the game, avoid at all costs !!!! static const Hash badModels[] = { 0x2D7030F3, 0x3F039CBA, 0x856CFB02 }; @@ -77,9 +69,7 @@ namespace Memory } if (v2 && (*reinterpret_cast(v2 + 157) & 31) == 6) // is a ped model - { pedModels.push_back(*model); - } } } } diff --git a/ChaosMod/Memory/Physics.h b/ChaosMod/Memory/Physics.h index b445d78e1..4934fa01c 100644 --- a/ChaosMod/Memory/Physics.h +++ b/ChaosMod/Memory/Physics.h @@ -21,9 +21,7 @@ namespace Memory { Handle handle = FindPattern("? 85 C0 74 ? ? 3B ? ? ? ? ? 75 ? ? 8B CF E8 ? ? ? ? ? 8D"); if (handle.IsValid()) - { return handle.At(17).Into().Get(); - } LOG("CEntity::GetColliderNonConst not found"); return nullptr; @@ -39,9 +37,7 @@ namespace Memory { Handle handle = FindPattern("? 8B 0D ? ? ? ? ? 83 64 ? ? 00 ? 0F B7 D1 ? 33 C9 E8"); if (handle.IsValid()) - { return handle.At(2).Into().Addr(); - } LOG("phSimulator::sm_Instance not found"); return 0ull; @@ -95,8 +91,6 @@ namespace Memory BOOL isDirectionRel, BOOL isForceRel, BOOL p8) { if (IsFreeToActivatePhysics() || DoesEntityHaveCollider(entity)) - { invoke(0x18FF00FC7EFF559E, entity, forceType, x, y, z, p5, isDirectionRel, isForceRel, p8); - } } } diff --git a/ChaosMod/Memory/Script.h b/ChaosMod/Memory/Script.h index 5c3b62527..ae85106e7 100644 --- a/ChaosMod/Memory/Script.h +++ b/ChaosMod/Memory/Script.h @@ -15,9 +15,7 @@ namespace Memory inline rage::scrProgram *ScriptThreadToProgram(rage::scrThread *thread) { if (!thread) - { return nullptr; - } static const Handle sharedHandle = [] { @@ -34,9 +32,7 @@ namespace Memory static auto scrProgramRegistry__FindProgramByHash = []() -> rage::scrProgram *(*)(DWORD64, Hash) { if (!sharedHandle.IsValid()) - { return nullptr; - } return sharedHandle.At(14).Into().Get(); }(); @@ -44,17 +40,13 @@ namespace Memory static auto scrProgramDirectory = []() -> DWORD64 { if (!sharedHandle.IsValid()) - { return 0; - } return sharedHandle.At(7).At(sharedHandle.At(3).Value()).Addr(); }(); if (!sharedHandle.IsValid()) - { return nullptr; - } return scrProgramRegistry__FindProgramByHash(scrProgramDirectory, thread->GetHash()); } @@ -69,9 +61,7 @@ namespace Memory { program->m_CodeBlocks[i], program->m_CodeBlocks[i] + (i == codeBlocksSize - 1 ? program->m_CodeSize : program->PAGE_SIZE) }); if (handle.IsValid()) - { return handle; - } } return Handle(); diff --git a/ChaosMod/Memory/Shader.h b/ChaosMod/Memory/Shader.h index 13f2ba190..c1fee6487 100644 --- a/ChaosMod/Memory/Shader.h +++ b/ChaosMod/Memory/Shader.h @@ -63,9 +63,7 @@ namespace Memory { auto shader = rage_sgaShader_ResolveShader(hash); if (shader) - { rage_sgaShader_destructor(shader); - } } reloadShaders(); diff --git a/ChaosMod/Memory/Snow.h b/ChaosMod/Memory/Snow.h index 871583780..5f8ff629d 100644 --- a/ChaosMod/Memory/Snow.h +++ b/ChaosMod/Memory/Snow.h @@ -17,31 +17,23 @@ namespace Memory static auto handle = FindPattern("80 3D ?? ?? ?? ?? 00 74 25 B9 40 00 00 00"); if (!handle.IsValid()) - { return; - } static auto addr1 = handle.Addr(); static BYTE orig1[13]; if (!init && addr1) - { memcpy(orig1, reinterpret_cast(addr1), 13); - } static auto handle2 = FindPattern("44 38 3D ?? ?? ?? ?? 74 1D B9 40 00 00 00"); if (!handle2.IsValid()) - { return; - } static auto addr2 = handle2.Addr(); static BYTE orig2[14]; if (!init && addr2) - { memcpy(orig2, reinterpret_cast(addr2), 14); - } init = true; @@ -70,14 +62,10 @@ namespace Memory else { if (addr1) - { memcpy(reinterpret_cast(addr1), orig1, 13); - } if (addr2) - { memcpy(reinterpret_cast(addr2), orig2, 14); - } } } } \ No newline at end of file diff --git a/ChaosMod/Memory/UI.h b/ChaosMod/Memory/UI.h index 8b3c93901..d24e4ad3a 100644 --- a/ChaosMod/Memory/UI.h +++ b/ChaosMod/Memory/UI.h @@ -20,9 +20,7 @@ namespace Memory { Handle handle = Memory::FindPattern("?? 89 5C ?? ?? 57 ?? 83 EC ?? ?? 8D 3D ?? ?? ?? ?? ?? 8D ?? ?? ?? E8"); if (!handle.IsValid()) - { return nullptr; - } return handle.Get(); } @@ -37,15 +35,11 @@ namespace Memory "?? 8D 15 ?? ?? ?? ?? ?? 6B C9 78 8B 44 ?? ?? 89 03 8B 44 ?? ?? 89 43 04 8A 4C ?? ??"); handle = handle.At(2).Into(); if (!handle.IsValid()) - { return nullptr; - } auto minimapData = handle.Get(); for (size_t i = 0; i < 3; i++) - { defaultMinimap[i] = minimapData[i]; - } refreshMinimapFunc = GetRefreshMinimapFunc(); @@ -53,14 +47,10 @@ namespace Memory }(); if (!minimapData || !refreshMinimapFunc) - { return; - } for (size_t i = 0; i < 3; i++) - { proceed(minimapData[i], defaultMinimap[i]); - } refreshMinimapFunc(); } diff --git a/ChaosMod/Memory/Vehicle.h b/ChaosMod/Memory/Vehicle.h index 730ef5a75..7af623898 100644 --- a/ChaosMod/Memory/Vehicle.h +++ b/ChaosMod/Memory/Vehicle.h @@ -28,18 +28,14 @@ namespace Memory handle = FindPattern("48 8B 05 ?? ?? ?? ?? 48 8B 14 D0 EB 0D 44 3B 12"); if (!handle.IsValid()) - { return vehModels; - } handle = handle.At(2).Into(); auto modelList = handle.Value(); handle = FindPattern("0F B7 05 ?? ?? ?? ?? 44 8B 49 18 45 33 D2 48 8B F1"); if (!handle.IsValid()) - { return vehModels; - } handle = handle.At(2).Into(); auto maxModels = handle.Value(); @@ -53,16 +49,12 @@ namespace Memory { auto entry = *reinterpret_cast(modelList + 8 * i); if (!entry) - { continue; - } auto model = *reinterpret_cast(entry); if (IS_MODEL_VALID(model) && IS_MODEL_A_VEHICLE(model) && !blacklistedModels.contains(model)) - { vehModels.push_back(model); - } } } @@ -93,9 +85,7 @@ namespace Memory }(); if (!outOfControlStateOffset) - { return; - } auto result = GetScriptHandleBaseAddress(vehicle); if (result) @@ -113,9 +103,7 @@ namespace Memory static DWORD origColors[maxColors] = {}; if (idx >= maxColors) - { return; - } if (!qword_7FF69E1E8E88) { @@ -124,9 +112,7 @@ namespace Memory handle = FindPattern("48 89 0D ? ? ? ? E8 ? ? ? ? 48 8D 4D C8 E8 ? ? ? ? 48 8D 15 ? ? ? ? 48 8D 4D C8 45 " "33 C0 E8 ? ? ? ? 4C 8D 0D"); if (!handle.IsValid()) - { return; - } qword_7FF69E1E8E88 = handle.At(2).Into().Get(); } @@ -138,9 +124,7 @@ namespace Memory // Orig colors not backed up yet, do it now for (int i = 0; i < maxColors; i++) - { origColors[i] = colors[i * 4]; - } } DWORD newColor = ((((r << 24) | (g << 16)) | b << 8) | 0xFF); @@ -185,9 +169,7 @@ namespace Memory { auto baseAddr = GetScriptHandleBaseAddress(veh); if (!baseAddr) - { return; - } auto passengerMatrixAddress = baseAddr + 0x60; Vector3 passengerForwardVec = Memory::GetVector3(passengerMatrixAddress + 0x00); diff --git a/ChaosMod/Memory/WeaponPool.h b/ChaosMod/Memory/WeaponPool.h index 85e27426e..3a6a1eb07 100644 --- a/ChaosMod/Memory/WeaponPool.h +++ b/ChaosMod/Memory/WeaponPool.h @@ -22,9 +22,7 @@ namespace Memory handle = Memory::FindPattern("74 42 0F B7 15 ? ? ? 01"); if (!handle.IsValid()) - { return weapons; - } WORD *dword_7FF6D9EF9748 = handle.At(4).Into().Get(); DWORD64 *qword_7FF6D9EF9740 = handle.At(18).Into().Get(); @@ -32,9 +30,7 @@ namespace Memory // Get address of CWeaponInfo's vftable and store it handle = Memory::FindPattern("48 8D 05 ? ? ? ? 4C 89 71 08 4C 89 71 10"); if (!handle.IsValid()) - { return weapons; - } auto CWeaponInfo_vftable = handle.At(2).Into().Addr(); @@ -50,9 +46,7 @@ namespace Memory // Only include actual ped weapons by checking if vftable pointed to is CWeaponInfo's if (*reinterpret_cast(vftableAddrPtr) != CWeaponInfo_vftable) - { continue; - } // Check if weapon has valid model & slot if (*reinterpret_cast(vftableAddrPtr + 20) && *reinterpret_cast(vftableAddrPtr + 28)) diff --git a/ChaosMod/Memory/WorldToScreen.h b/ChaosMod/Memory/WorldToScreen.h index b2e07ceb2..f51121262 100644 --- a/ChaosMod/Memory/WorldToScreen.h +++ b/ChaosMod/Memory/WorldToScreen.h @@ -10,17 +10,13 @@ namespace Memory { Handle handle = Memory::FindPattern("48 89 5C 24 ? 55 56 57 48 83 EC 70 65 4C 8B 0C 25"); if (!handle.IsValid()) - { return false; - } WorldToScreen = handle.Get(); } if (WorldToScreen(worldPosition, &screenPosition->x, &screenPosition->y)) - { return true; - } return false; } diff --git a/ChaosMod/README.md b/ChaosMod/README.md index 0b1facf83..68d78847e 100644 --- a/ChaosMod/README.md +++ b/ChaosMod/README.md @@ -35,7 +35,6 @@ This is where the source code for the actual mod resides in. Note that the compi ## Coding conventions - This project provides a custom .clang-format file for use with clang-format. Please make sure to format your source code before contributing, there should be support for just about every IDE / editor out there - either officially or using an extension. -- Always use brackets for if, for and while expressions. - This project uses precompiled headers; make sure to add `#include ` as the first line in source files. If you include other headers as well separate those two using an empty line to prevent clang-format from reshuffling the stdafx.h include. - Naming: - Private member variables: `m_Foo` diff --git a/ChaosMod/Util/CrashHandler.h b/ChaosMod/Util/CrashHandler.h index 89a9f1c09..3084e0099 100644 --- a/ChaosMod/Util/CrashHandler.h +++ b/ChaosMod/Util/CrashHandler.h @@ -12,9 +12,7 @@ inline LONG WINAPI CrashHandler(_EXCEPTION_POINTERS *exceptionInfo) { if (DoesFeatureFlagExist("nodumps")) - { return EXCEPTION_CONTINUE_SEARCH; - } SYSTEMTIME systemTime; GetSystemTime(&systemTime); diff --git a/ChaosMod/Util/EntityIterator.h b/ChaosMod/Util/EntityIterator.h index 9b22df276..be02e2881 100644 --- a/ChaosMod/Util/EntityIterator.h +++ b/ChaosMod/Util/EntityIterator.h @@ -25,12 +25,8 @@ template class PoolIterator PoolIterator &operator++() { for (Index++; Index < Pool->m_Size; Index++) - { if (Pool->IsValid(Index)) - { return *this; - } - } Index = Pool->m_Size; return *this; @@ -63,9 +59,7 @@ template class PoolUtils { std::vector arr; for (auto entity : *static_cast(this)) - { arr.push_back(entity); - } return arr; } diff --git a/ChaosMod/Util/Events.h b/ChaosMod/Util/Events.h index 8dbc8f886..7d5b8f22b 100644 --- a/ChaosMod/Util/Events.h +++ b/ChaosMod/Util/Events.h @@ -36,9 +36,7 @@ template class ChaosBaseEvent : public _ChaosBaseEvent virtual ~ChaosBaseEvent() { for (auto &listener : m_Listeners) - { listener->IsEventStillValid = false; - } } void RegisterListener(Listener *listener) @@ -63,9 +61,7 @@ template class ChaosEvent : public ChaosBaseEventCallback(args...); - } } }; @@ -76,12 +72,8 @@ template class ChaosCancellableEvent : public ChaosBaseEvent< { bool result = true; for (const auto &listener : ChaosCancellableEvent::m_Listeners) - { if (!listener->Callback(args...)) - { result = false; - } - } return result; } @@ -103,12 +95,8 @@ class ChaosEventListener ~ChaosEventListener() { for (auto &event : m_Events) - { if (event.Listener.IsEventStillValid) - { event.Event->RemoveListener(&event.Listener); - } - } } void Register(ChaosEventType &event, typename ChaosEventType::CallbackType callback) diff --git a/ChaosMod/Util/File.h b/ChaosMod/Util/File.h index f9c830398..c55f7eca4 100644 --- a/ChaosMod/Util/File.h +++ b/ChaosMod/Util/File.h @@ -39,26 +39,16 @@ inline std::vector GetFiles(std::string path, } if (addFile) - { entries.push_back(entry); - } } }; if (recursive) - { for (const auto &entry : std::filesystem::recursive_directory_iterator(path)) - { handleEntry(entry); - } - } else - { for (const auto &entry : std::filesystem::directory_iterator(path)) - { handleEntry(entry); - } - } return entries; } \ No newline at end of file diff --git a/ChaosMod/Util/Model.h b/ChaosMod/Util/Model.h index 5491fffff..990ce846a 100644 --- a/ChaosMod/Util/Model.h +++ b/ChaosMod/Util/Model.h @@ -10,8 +10,6 @@ inline void LoadModel(Hash model) { REQUEST_MODEL(model); while (!HAS_MODEL_LOADED(model)) - { WAIT(0); - } } } \ No newline at end of file diff --git a/ChaosMod/Util/OptionsFile.h b/ChaosMod/Util/OptionsFile.h index f57e96283..28eeabf41 100644 --- a/ChaosMod/Util/OptionsFile.h +++ b/ChaosMod/Util/OptionsFile.h @@ -31,9 +31,7 @@ class OptionsFile { std::ifstream file(fileName); if (file.fail()) - { return false; - } std::string line; line.resize(128); @@ -43,9 +41,7 @@ class OptionsFile // Ignore line if there's no "=" if (line == key) - { continue; - } const auto &value = StringTrim( line.substr(line.find("=") + 1).substr(0, line.find('\n'))); // Also do trimming of newline @@ -60,17 +56,11 @@ class OptionsFile { bool dataRead = false; for (auto compatFileName : m_CompatFileNames) - { if ((dataRead = readData(compatFileName))) - { break; - } - } if (!dataRead) - { LOG("Config file " << m_FileName << " not found!"); - } } } @@ -84,9 +74,7 @@ class OptionsFile { T parsedResult; if (Util::TryParse(result->second, parsedResult)) - { return parsedResult; - } } } @@ -100,9 +88,7 @@ class OptionsFile const auto &result = m_Options.find(key); if (result != m_Options.end()) - { return result->second; - } } return defaultValue; diff --git a/ChaosMod/Util/Peds.h b/ChaosMod/Util/Peds.h index 1e8d47119..d39e0a2b4 100644 --- a/ChaosMod/Util/Peds.h +++ b/ChaosMod/Util/Peds.h @@ -33,9 +33,7 @@ inline Ped CreateHostilePed(Hash modelHash, Hash weaponHash, Vector3 *location = LoadModel(modelHash); Ped ped = CreatePoolPed(4, modelHash, spawnLocation.x, spawnLocation.y, spawnLocation.z, 0.f); if (spawnInVehicleIfNeeded && IS_PED_IN_ANY_VEHICLE(playerPed, false)) - { SET_PED_INTO_VEHICLE(ped, GET_VEHICLE_PED_IS_IN(playerPed, false), -2); - } SET_PED_RELATIONSHIP_GROUP_HASH(ped, relationshipGroup); SET_PED_HEARING_RANGE(ped, 9999.f); @@ -51,9 +49,7 @@ inline Ped CreateHostilePed(Hash modelHash, Hash weaponHash, Vector3 *location = SET_PED_SUFFERS_CRITICAL_HITS(ped, false); if (weaponHash) - { GIVE_WEAPON_TO_PED(ped, weaponHash, 9999, true, true); - } TASK_COMBAT_PED(ped, playerPed, 0, 16); SET_PED_FIRING_PATTERN(ped, 0xC6EE6B4C); diff --git a/ChaosMod/Util/Player.h b/ChaosMod/Util/Player.h index bc8a2abe5..bcc538b3f 100644 --- a/ChaosMod/Util/Player.h +++ b/ChaosMod/Util/Player.h @@ -13,9 +13,7 @@ inline void TeleportPlayer(float x, float y, float z, bool noOffset = false) float groundHeight = GET_ENTITY_HEIGHT_ABOVE_GROUND(playerVeh); float forwardSpeed; if (isInVeh) - { forwardSpeed = GET_ENTITY_SPEED(playerVeh); - } if (noOffset) { @@ -32,9 +30,7 @@ inline void TeleportPlayer(float x, float y, float z, bool noOffset = false) SET_ENTITY_VELOCITY(isInVeh ? playerVeh : playerPed, vel.x, vel.y, vel.z); if (isInVeh) - { SET_VEHICLE_FORWARD_SPEED(playerVeh, forwardSpeed); - } } inline void TeleportPlayer(const Vector3 &coords, bool noOffset = false) diff --git a/ChaosMod/Util/PoolSpawner.cpp b/ChaosMod/Util/PoolSpawner.cpp index 0dcb7dd1c..a695486d8 100644 --- a/ChaosMod/Util/PoolSpawner.cpp +++ b/ChaosMod/Util/PoolSpawner.cpp @@ -14,16 +14,10 @@ static void HandleEntity(Entity entity) // Clean up entities which don't exist anymore first for (auto it = m_Entities.begin(); it != m_Entities.end();) - { if (!DOES_ENTITY_EXIST(*it)) - { it = m_Entities.erase(it); - } else - { it++; - } - } // Delete front entity if size above limit if (m_Entities.size() > ENTITY_POOL_MAX) @@ -31,9 +25,7 @@ static void HandleEntity(Entity entity) auto frontEntity = m_Entities.front(); if (DOES_ENTITY_EXIST(frontEntity)) - { SET_ENTITY_AS_NO_LONGER_NEEDED(&frontEntity); - } m_Entities.pop_front(); } @@ -87,32 +79,22 @@ Ped CreatePoolClonePed(Ped pedToClone) CLONE_PED_TO_TARGET(pedToClone, clone); for (int i = 0; i < 411; i++) - { SET_PED_CONFIG_FLAG(clone, i, GET_PED_CONFIG_FLAG(pedToClone, i, 1)); - } for (int i = 0; i < 300; i++) - { SET_PED_RESET_FLAG(clone, i, GET_PED_RESET_FLAG(pedToClone, i)); - } SET_PED_RELATIONSHIP_GROUP_HASH(clone, GET_PED_RELATIONSHIP_GROUP_HASH(pedToClone)); int groupIndex = GET_PED_GROUP_INDEX(pedToClone); if (GET_PED_AS_GROUP_LEADER(groupIndex) == pedToClone) - { SET_PED_AS_GROUP_LEADER(clone, groupIndex); - } else - { SET_PED_AS_GROUP_MEMBER(clone, groupIndex); - } Hash weaponHash; if (GET_CURRENT_PED_WEAPON(pedToClone, &weaponHash, 0)) - { GIVE_WEAPON_TO_PED(clone, weaponHash, 9999, false, true); - } SET_PED_ACCURACY(clone, GET_PED_ACCURACY(pedToClone)); SET_PED_FIRING_PATTERN(clone, 0xC6EE6B4C); diff --git a/ChaosMod/Util/Random.h b/ChaosMod/Util/Random.h index ac0c17c78..96de0fb4c 100644 --- a/ChaosMod/Util/Random.h +++ b/ChaosMod/Util/Random.h @@ -12,9 +12,7 @@ class Random inline void SetSeed(int seed) { if (seed > 0) - { m_Random.seed(seed); - } } inline int GetRandomInt(int lower, int upper) diff --git a/ChaosMod/Util/Script.h b/ChaosMod/Util/Script.h index f6623704a..4377f2849 100644 --- a/ChaosMod/Util/Script.h +++ b/ChaosMod/Util/Script.h @@ -21,12 +21,8 @@ inline void WAIT(DWORD timeMs) EffectThreads::PauseThisThread(timeMs); if (g_EffectDispatcherThread) - { SwitchToFiber(g_EffectDispatcherThread); - } else - { SwitchToFiber(g_MainThread); - } } } \ No newline at end of file diff --git a/ChaosMod/Util/ScriptText.h b/ChaosMod/Util/ScriptText.h index 9d9e84db1..50ec8fb00 100644 --- a/ChaosMod/Util/ScriptText.h +++ b/ChaosMod/Util/ScriptText.h @@ -53,9 +53,7 @@ inline void DrawScreenText(const std::string &text, const ScreenTextVector &text SET_TEXT_COLOUR(textColor.R, textColor.G, textColor.B, 255); if (outline) - { SET_TEXT_OUTLINE(); - } SET_TEXT_JUSTIFICATION(static_cast(textAdjust)); SET_TEXT_WRAP(textWrap.X, textWrap.Y); diff --git a/ChaosMod/Util/Text.h b/ChaosMod/Util/Text.h index 9595c60eb..8c1e9d52f 100644 --- a/ChaosMod/Util/Text.h +++ b/ChaosMod/Util/Text.h @@ -3,9 +3,7 @@ inline std::string StringTrim(std::string str) { if (str.find_first_not_of(' ') == str.npos) - { return ""; - } str = str.substr(str.find_first_not_of(' ')); str = str.substr(0, str.find_first_of('\0')); diff --git a/ChaosMod/Util/TryParse.h b/ChaosMod/Util/TryParse.h index 7ef243dbf..450403d64 100644 --- a/ChaosMod/Util/TryParse.h +++ b/ChaosMod/Util/TryParse.h @@ -13,19 +13,13 @@ namespace Util long lParseResult; if constexpr (std::is_same()) - { lParseResult = std::strtof(text.data(), &cEnd); - } else - { lParseResult = std::strtol(text.data(), &cEnd, radix); - } bool parsed = *cEnd == '\0'; if (parsed) - { result = static_cast(lParseResult); - } return parsed; } diff --git a/ChaosMod/Util/Vehicle.h b/ChaosMod/Util/Vehicle.h index 93b76d928..51be410fc 100644 --- a/ChaosMod/Util/Vehicle.h +++ b/ChaosMod/Util/Vehicle.h @@ -57,9 +57,7 @@ inline void SetSurroundingPedsInVehicles(Hash vehicleHash, int maxDistance) Vehicle veh = GET_VEHICLE_PED_IS_IN(ped, false); if (GET_ENTITY_MODEL(veh) == vehicleHash) - { continue; - } } float pedHeading = GET_ENTITY_HEADING(ped); @@ -134,17 +132,13 @@ inline Vehicle CreateRandomVehicleWithPeds(Vehicle oldHandle, const std::vector< SeatPed seatPed = seatPeds.at(i); int seatIndex = seatPed.SeatIndex; if (seatIndex >= numberOfSeats || !IS_VEHICLE_SEAT_FREE(newVehicle, seatIndex, 0)) - { seatIndex = -2; - } SET_PED_INTO_VEHICLE(seatPed.Ped, newVehicle, seatIndex); } if (engineRunning) - { SET_VEHICLE_ENGINE_ON(newVehicle, true, true, false); - } SET_ENTITY_VELOCITY(newVehicle, velocity.x, velocity.y, velocity.z); SET_VEHICLE_FORWARD_SPEED(newVehicle, forwardSpeed); @@ -156,9 +150,7 @@ inline Vehicle CreateRandomVehicleWithPeds(Vehicle oldHandle, const std::vector< SET_ENTITY_AS_MISSION_ENTITY(copy, true, true); if (shouldUseHook) - { Hooks::EnableScriptThreadBlock(); - } DELETE_VEHICLE(©); if (shouldUseHook) { @@ -195,9 +187,7 @@ inline Vehicle CreateRandomVehicleWithPeds(Vehicle oldHandle, const std::vector< _SET_VEHICLE_NEON_LIGHTS_COLOUR(newVehicle, g_RandomNoDeterm.GetRandomInt(0, 255), g_RandomNoDeterm.GetRandomInt(0, 255), g_RandomNoDeterm.GetRandomInt(0, 255)); for (int i = 0; i < 4; i++) - { _SET_VEHICLE_NEON_LIGHT_ENABLED(newVehicle, i, true); - } _SET_VEHICLE_XENON_LIGHTS_COLOR(newVehicle, g_RandomNoDeterm.GetRandomInt(0, 12)); diff --git a/ChaosMod/Util/Weapon.h b/ChaosMod/Util/Weapon.h index 779950224..127eb9416 100644 --- a/ChaosMod/Util/Weapon.h +++ b/ChaosMod/Util/Weapon.h @@ -12,9 +12,7 @@ namespace Util static const Hash shotgunGroup = "GROUP_SHOTGUN"_hash; if (const auto result = cachedResults.find(weaponHash); result != cachedResults.end()) - { return result->second; - } return cachedResults.emplace(weaponHash, (GET_WEAPONTYPE_GROUP(weaponHash) == shotgunGroup)).first->second; } diff --git a/ChaosMod/Util/XInput.h b/ChaosMod/Util/XInput.h index c951914a6..b4b76f1b2 100644 --- a/ChaosMod/Util/XInput.h +++ b/ChaosMod/Util/XInput.h @@ -24,9 +24,7 @@ namespace XInput inline void SetAllControllersRumble(int leftMotorSpeed, int rightMotorSpeed) { for (DWORD i = 0; i < XUSER_MAX_COUNT; i++) - { SetControllerRumble(i, leftMotorSpeed, rightMotorSpeed); - } } inline void StopControllerRumble(DWORD controllerId) @@ -45,8 +43,6 @@ namespace XInput inline void StopAllControllersRumble() { for (DWORD i = 0; i < XUSER_MAX_COUNT; i++) - { StopControllerRumble(i); - } } } diff --git a/ConfigApp/EffectConfig.xaml.cs b/ConfigApp/EffectConfig.xaml.cs index 4faed211f..a8220773b 100644 --- a/ConfigApp/EffectConfig.xaml.cs +++ b/ConfigApp/EffectConfig.xaml.cs @@ -72,12 +72,10 @@ public EffectConfig(string? effectId, EffectData? effectData, EffectInfo effectI effectconf_effect_custom_name.TextChanged += OnCustomEffectNameTextFieldTextChanged; if (!string.IsNullOrWhiteSpace(effectId)) - { effectconf_mp3_label.Text = $@" Sound to play when this effect gets activated: chaosmod/sounds/{effectId}.mp3 Or create the following folder and drop mp3 files in there to play a random one: chaosmod/sounds/{effectId} "; - } // Meta Effect Handling @@ -112,9 +110,7 @@ public EffectConfig(string? effectId, EffectData? effectData, EffectInfo effectI effectconf_effect_shortcut_input.IsEnabled = true; if (savedWin32Key <= 0) - { effectconf_effect_shortcut_input.Text = "None"; - } else { Key key = KeyInterop.KeyFromVirtualKey(savedWin32Key % 256); @@ -160,17 +156,13 @@ private void EffectShortcutTextFieldPreviewKeyDown(object sender, KeyEventArgs e } if (key == Key.System) - { key = e.SystemKey; - } // Don't want a shortcut with any of these as the main key if (key == Key.LeftCtrl || key == Key.RightCtrl || key == Key.LeftShift || key == Key.RightShift || key == Key.LeftAlt || key == Key.RightAlt || key == Key.LWin || key == Key.RWin || key == Key.Apps) - { return; - } SetEffectShortcut(key, modifiers); } @@ -229,13 +221,9 @@ private void OnClicked(object sender, RoutedEventArgs e) if (checkBox.IsChecked.GetValueOrDefault(false)) { if (sender == effectconf_timer_type_enable) - { effectconf_timer_time_enable.IsChecked = false; - } else if (sender == effectconf_timer_time_enable) - { effectconf_timer_type_enable.IsChecked = false; - } } CheckEnableConfigurables(); @@ -259,7 +247,6 @@ private void NoCopyPastePreviewExecuted(object sender, ExecutedRoutedEventArgs e public EffectData GetNewData() { if (effectconf_timer_type_enable.IsChecked.GetValueOrDefault(false)) - { m_EffectData.TimedType = (object)effectconf_timer_type.SelectedIndex switch { 0 => (EffectTimedType?)EffectTimedType.Normal, @@ -267,11 +254,8 @@ public EffectData GetNewData() 2 => (EffectTimedType?)EffectTimedType.Permanent, _ => null, }; - } else - { m_EffectData.TimedType = null; - } m_EffectData.CustomTime = effectconf_timer_time_enable.IsChecked.HasValue && effectconf_timer_time_enable.IsChecked.Value ? effectconf_timer_time.Text.Length > 0 ? int.Parse(effectconf_timer_time.Text) : null : null; diff --git a/ConfigApp/EffectData.cs b/ConfigApp/EffectData.cs index b14721266..26186cc78 100644 --- a/ConfigApp/EffectData.cs +++ b/ConfigApp/EffectData.cs @@ -12,30 +12,20 @@ private class Converter : JsonConverter public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) { if (value is null) - { return; - } if (value is bool v) - { writer.WriteValue(v ? 1 : 0); - } else - { writer.WriteValue((int)value); - } } public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) { if (typeof(T) == typeof(bool)) - { return $"{reader.Value}" != "0"; - } else if (typeof(T) == typeof(EffectTimedType) && reader.Value is not null) - { return Enum.ToObject(typeof(EffectTimedType), reader.Value); - } return null; } diff --git a/ConfigApp/EffectsTreeMenuItem.cs b/ConfigApp/EffectsTreeMenuItem.cs index 9e23a2aff..478af44f6 100644 --- a/ConfigApp/EffectsTreeMenuItem.cs +++ b/ConfigApp/EffectsTreeMenuItem.cs @@ -25,9 +25,7 @@ public bool CanExecute(object? parameter) public void Execute(object? parameter) { if (m_Action is null) - { return; - } m_Action(); } @@ -44,10 +42,7 @@ public void Execute(object? parameter) private bool m_isChecked; public bool IsChecked { - get - { - return m_isChecked; - } + get => m_isChecked; set { m_isChecked = value; @@ -65,10 +60,7 @@ public bool IsChecked private bool m_isColored; public bool IsColored { - get - { - return m_isColored; - } + get => m_isColored; set { m_isColored = value; @@ -79,10 +71,7 @@ public bool IsColored private bool m_ForceConfigHidden = false; public string IsConfigVisible { - get - { - return Children.Count == 0 && !m_ForceConfigHidden ? "Visible" : "Hidden"; - } + get => Children.Count == 0 && !m_ForceConfigHidden ? "Visible" : "Hidden"; } public bool ForceConfigHidden { @@ -93,18 +82,12 @@ public bool ForceConfigHidden } public bool IsConfigEnabled { - get - { - return IsChecked; - } + get => IsChecked; } public Action? OnConfigureClick { get; set; } public ICommand OnConfigureCommand { - get - { - return new TreeMenuItemAction(OnConfigureClick); - } + get => new TreeMenuItemAction(OnConfigureClick); } public TreeMenuItem(string text, TreeMenuItem? parent = null) @@ -134,30 +117,20 @@ void countChildrenRecursive(TreeMenuItem menuItem) { totalChildren++; if (menuItem.IsChecked) - { enabledChildren++; - } } foreach (var _menuItem in menuItem.Children) - { countChildrenRecursive(_menuItem); - } } foreach (var menuItem in Children) - { countChildrenRecursive(menuItem); - } if (CheckBoxVisiblity == Visibility.Visible) - { Text = $"{BaseText} ({enabledChildren}/{totalChildren})"; - } else - { Text = $"{BaseText} ({totalChildren})"; - } m_isChecked = enabledChildren > 0; NotifyFieldsUpdated(); diff --git a/ConfigApp/MainWindow.xaml.cs b/ConfigApp/MainWindow.xaml.cs index 49c620cca..f58ef2a2f 100644 --- a/ConfigApp/MainWindow.xaml.cs +++ b/ConfigApp/MainWindow.xaml.cs @@ -78,9 +78,7 @@ private void Init() OptionsManager.ReadFiles(); foreach (var tab in m_Tabs) - { tab.Value.OnLoadValues(); - } m_EffectDataMap = new Dictionary(); @@ -115,9 +113,7 @@ private void Init() private void OnTabSelectionChanged(object sender, SelectionChangedEventArgs eventArgs) { if (eventArgs.OriginalSource is not TabControl) - { return; - } foreach (var tab in m_TabItems) { @@ -138,13 +134,9 @@ private async void CheckForUpdates() string newVersion = await httpClient.GetStringAsync("https://gopong.dev/chaos/version.txt"); if (Info.VERSION != newVersion) - { update_available_button.Visibility = Visibility.Visible; - } else - { update_available_label.Text = "You are on the newest version of the mod!"; - } } catch (HttpRequestException) { @@ -231,9 +223,7 @@ private void InitEffectsTreeView() foreach (var pair in EffectsMap) { if (pair.Value.Name is null) - { continue; - } sortedEffects.Add(pair.Value.Name, (EffectId: pair.Key, pair.Value.EffectCategory)); } @@ -253,15 +243,11 @@ private void InitEffectsTreeView() effectConfig.ShowDialog(); if (!effectConfig.IsSaved) - { return; - } effectData = effectConfig.GetNewData(); if (m_EffectDataMap is not null) - { m_EffectDataMap[effectMisc.EffectId] = effectData; - } menuItem.IsColored = effectData.TimedType == EffectTimedType.Permanent; }; menuItem.IsColored = effectData.TimedType == EffectTimedType.Permanent; @@ -312,9 +298,7 @@ private void InitEffectsTreeView() meta_effects_tree_view.Items.Add(metaParentItem); foreach (var treeMenuItem in m_TreeMenuItemsAll.Append(metaParentItem)) - { treeMenuItem.UpdateCheckedAccordingToChildrenStatus(); - } } private void OnUserEffectSearchTextChanged(object sender, TextChangedEventArgs e) @@ -333,17 +317,11 @@ private void OnUserEffectSearchTextChanged(object sender, TextChangedEventArgs e } if (parentMenuItem.Children == null) - { continue; - } foreach (var childMenuItem in parentMenuItem.Children) - { if (childMenuItem.Text.Contains(filterText, StringComparison.InvariantCultureIgnoreCase)) - { m_TreeMenuItemsFiltered.Add(childMenuItem); - } - } } } effects_user_effects_tree_view.Items.Refresh(); @@ -368,30 +346,22 @@ private void OnUserSaveClick(object sender, RoutedEventArgs e) { if (OptionsManager.ConfigFile.HasCompatFile("config.ini") || OptionsManager.TwitchFile.HasCompatFile("twitch.ini") || OptionsManager.EffectsFile.HasCompatFile("effects.ini")) - { if (MessageBox.Show("Note: Config files reside inside the configs/ subdirectory now. Clicking OK will move the files there. " + "If you want to play older versions of the mod you will have to move them back. Continue?", "ChaosModV", MessageBoxButton.OKCancel, MessageBoxImage.Warning) != MessageBoxResult.OK) - { return; - } - } WriteConfigFile(); WriteEffectsFile(); foreach (var tab in m_Tabs) - { tab.Value.OnSaveValues(); - } OptionsManager.WriteFiles(); // Reload saved config to show the "new" (saved) settings foreach (var tab in m_Tabs) - { tab.Value.OnLoadValues(); - } OptionsManager.DeleteCompatFiles(); @@ -411,9 +381,7 @@ private void OnUserResetClick(object sender, RoutedEventArgs e) MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) - { OptionsManager.TwitchFile.ResetFile(); - } Init(); diff --git a/ConfigApp/OptionsManager.cs b/ConfigApp/OptionsManager.cs index 88b564cca..8a5763d20 100644 --- a/ConfigApp/OptionsManager.cs +++ b/ConfigApp/OptionsManager.cs @@ -40,23 +40,15 @@ public static void DeleteCompatFiles() static void deleteFiles(string[] files) { foreach (var file in files) - { File.Delete(file); - } } if (ConfigFile.HasCompatFile()) - { deleteFiles(ConfigFile.GetCompatFiles()); - } if (TwitchFile.HasCompatFile()) - { deleteFiles(TwitchFile.GetCompatFiles()); - } if (EffectsFile.HasCompatFile()) - { deleteFiles(EffectsFile.GetCompatFiles()); - } } } } diff --git a/ConfigApp/README.md b/ConfigApp/README.md index a55eb57d4..65d214cd8 100644 --- a/ConfigApp/README.md +++ b/ConfigApp/README.md @@ -9,7 +9,6 @@ Either through Visual Studio or using the `dotnet` CLI tool (`dotnet build` or ` ## Coding conventions - This project provides a custom .editorconfig file. Please make sure to format your source code before contributing, there should be support for just about every IDE / editor out there - either officially or using an extension. Alternatively you can run `dotnet format`. -- Always use brackets for if, for and while expressions. - Naming: - Private member variables: `m_Foo` - Static global variables specific to file: `ms_Foo` diff --git a/ConfigApp/Tabs/ChaosGrid.cs b/ConfigApp/Tabs/ChaosGrid.cs index 9a65e6547..794746236 100644 --- a/ConfigApp/Tabs/ChaosGrid.cs +++ b/ConfigApp/Tabs/ChaosGrid.cs @@ -9,7 +9,6 @@ public class ChaosGrid private int m_CurrentRow = -1; private int m_CurrentColumn = 0; - private readonly List m_RowDefinitions = new(); private readonly List m_ColumnDefinitions = new(); @@ -21,9 +20,7 @@ public ChaosGrid(Grid? grid = null) public virtual void Init(Grid? grid = null) { if (grid is not null && grid == Grid) - { return; - } Grid = grid ?? new Grid(); @@ -49,9 +46,7 @@ public void PushNewColumn(GridLength gridLength) private void CheckColumnValidity() { if (m_ColumnDefinitions.Count <= m_CurrentColumn) - { throw new System.IndexOutOfRangeException("m_CurrentColumn > max columns!"); - } } public void SetRowHeight(GridLength gridLength) @@ -87,13 +82,9 @@ private void PushRow(string? text, UIElement? control) if (text != null) { if (control.GetValue(FrameworkElement.HorizontalAlignmentProperty) == null) - { control.SetValue(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Right); - } if (control.GetValue(FrameworkElement.VerticalAlignmentProperty) == null) - { control.SetValue(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Center); - } } control.SetValue(Grid.ColumnProperty, m_CurrentColumn); diff --git a/ConfigApp/Tabs/MetaTab.cs b/ConfigApp/Tabs/MetaTab.cs index e24fceebc..adf657942 100644 --- a/ConfigApp/Tabs/MetaTab.cs +++ b/ConfigApp/Tabs/MetaTab.cs @@ -7,9 +7,7 @@ namespace ConfigApp.Tabs public class MetaTab : Tab { private TextBox? m_MetaEffectDispatchTimer = null; - private TextBox? m_MetaEffectDuration = null; - private TextBox? m_MetaEffectShortDuration = null; private static readonly DependencyProperty IsSelectableProperty = @@ -74,27 +72,17 @@ protected override void InitContent() public override void OnLoadValues() { if (m_MetaEffectDispatchTimer is not null) - { m_MetaEffectDispatchTimer.Text = OptionsManager.ConfigFile.ReadValue("NewMetaEffectSpawnTime", "600"); - } - if (m_MetaEffectDuration is not null) - { m_MetaEffectDuration.Text = OptionsManager.ConfigFile.ReadValue("MetaEffectDur", "95"); - } - if (m_MetaEffectShortDuration is not null) - { m_MetaEffectShortDuration.Text = OptionsManager.ConfigFile.ReadValue("MetaShortEffectDur", "65"); - } } public override void OnSaveValues() { OptionsManager.ConfigFile.WriteValue("NewMetaEffectSpawnTime", m_MetaEffectDispatchTimer?.Text); - OptionsManager.ConfigFile.WriteValue("MetaEffectDur", m_MetaEffectDuration?.Text); - OptionsManager.ConfigFile.WriteValue("MetaShortEffectDur", m_MetaEffectShortDuration?.Text); } } diff --git a/ConfigApp/Tabs/MiscTab.cs b/ConfigApp/Tabs/MiscTab.cs index 0bcf5ed60..546b10665 100644 --- a/ConfigApp/Tabs/MiscTab.cs +++ b/ConfigApp/Tabs/MiscTab.cs @@ -9,35 +9,24 @@ public class MiscTab : Tab { private TextBox? m_EffectDispatchTimer = null; private CheckBox? m_DisableDrawTimer = null; - private TextBox? m_TimedEffectDuration = null; private CheckBox? m_DisableDrawEffectText = null; - private TextBox? m_ShortTimedEffectDuration = null; private CheckBox? m_EnableClearActiveEffectsShortcut = null; - private TextBox? m_RandomSeed = null; private CheckBox? m_EnableToggleModShortcut = null; - private TextBox? m_MaxRunningEffects = null; private CheckBox? m_EnableEffectsMenu = null; - private ColorPicker? m_TimerBarColor = null; private CheckBox? m_EnablePauseTimerShortcut = null; - private ColorPicker? m_EffectTextColor = null; private CheckBox? m_EnableAntiSoftlockShortcut = null; - private ColorPicker? m_EffectTimerBarColor = null; private CheckBox? m_EnableEffectGroupWeighting = null; - private CheckBox? m_DisableModOnStartup = null; private CheckBox? m_EnableFailsafe = null; - private CheckBox? m_EnableModSplashTexts = null; - private CheckBox? m_EnableDistanceBasedDispatch = null; - private TextBox? m_DistanceBasedDispatchDistance = null; private ComboBox? m_DistanceBasedDispatchType = null; @@ -56,13 +45,9 @@ private static ColorPicker GenerateCommonColorPicker(Color defaultColor) private void SetDistanceDispatchFieldsEnabled(bool state) { if (m_DistanceBasedDispatchDistance is not null) - { m_DistanceBasedDispatchDistance.IsEnabled = state; - } if (m_DistanceBasedDispatchType is not null) - { m_DistanceBasedDispatchType.IsEnabled = state; - } } protected override void InitContent() @@ -151,140 +136,76 @@ protected override void InitContent() public override void OnLoadValues() { if (m_EffectDispatchTimer is not null) - { m_EffectDispatchTimer.Text = OptionsManager.ConfigFile.ReadValue("NewEffectSpawnTime", "30"); - } if (m_DisableDrawTimer is not null) - { m_DisableDrawTimer.IsChecked = OptionsManager.ConfigFile.ReadValueBool("DisableTimerBarDraw", false); - } - if (m_TimedEffectDuration is not null) - { m_TimedEffectDuration.Text = OptionsManager.ConfigFile.ReadValue("EffectTimedDur", "90"); - } if (m_DisableDrawEffectText is not null) - { m_DisableDrawEffectText.IsChecked = OptionsManager.ConfigFile.ReadValueBool("DisableEffectTextDraw", false); - } - if (m_ShortTimedEffectDuration is not null) - { m_ShortTimedEffectDuration.Text = OptionsManager.ConfigFile.ReadValue("EffectTimedShortDur", "30"); - } if (m_EnableClearActiveEffectsShortcut is not null) - { m_EnableClearActiveEffectsShortcut.IsChecked = OptionsManager.ConfigFile.ReadValueBool("EnableClearEffectsShortcut", true); - } - if (m_RandomSeed is not null) - { m_RandomSeed.Text = OptionsManager.ConfigFile.ReadValue("Seed"); - } if (m_EnableToggleModShortcut is not null) - { m_EnableToggleModShortcut.IsChecked = OptionsManager.ConfigFile.ReadValueBool("EnableToggleModShortcut", true); - } - if (m_MaxRunningEffects is not null) - { m_MaxRunningEffects.Text = OptionsManager.ConfigFile.ReadValue("MaxParallelRunningEffects", "99"); - } if (m_EnableEffectsMenu is not null) - { m_EnableEffectsMenu.IsChecked = OptionsManager.ConfigFile.ReadValueBool("EnableDebugMenu", false); - } - if (OptionsManager.ConfigFile.HasKey("EffectTimerColor") && m_TimerBarColor is not null) - { m_TimerBarColor.SelectedColor = (Color)ColorConverter.ConvertFromString(OptionsManager.ConfigFile.ReadValue("EffectTimerColor")); - } if (m_EnablePauseTimerShortcut is not null) - { m_EnablePauseTimerShortcut.IsChecked = OptionsManager.ConfigFile.ReadValueBool("EnablePauseTimerShortcut", false); - } - if (OptionsManager.ConfigFile.HasKey("EffectTextColor") && m_EffectTextColor is not null) - { m_EffectTextColor.SelectedColor = (Color)ColorConverter.ConvertFromString(OptionsManager.ConfigFile.ReadValue("EffectTextColor")); - } if (m_EnableAntiSoftlockShortcut is not null) - { m_EnableAntiSoftlockShortcut.IsChecked = OptionsManager.ConfigFile.ReadValueBool("EnableAntiSoftlockShortcut", true); - } - if (OptionsManager.ConfigFile.HasKey("EffectTimedTimerColor") && m_EffectTimerBarColor is not null) - { m_EffectTimerBarColor.SelectedColor = (Color)ColorConverter.ConvertFromString(OptionsManager.ConfigFile.ReadValue("EffectTimedTimerColor")); - } if (m_EnableEffectGroupWeighting is not null) - { m_EnableEffectGroupWeighting.IsChecked = OptionsManager.ConfigFile.ReadValueBool("EnableGroupWeightingAdjustments", true); - } - if (m_DisableModOnStartup is not null) - { m_DisableModOnStartup.IsChecked = OptionsManager.ConfigFile.ReadValueBool("DisableStartup", false); - } if (m_EnableFailsafe is not null) - { m_EnableFailsafe.IsChecked = OptionsManager.ConfigFile.ReadValueBool("EnableFailsafe", true); - } - if (m_EnableModSplashTexts is not null) - { m_EnableModSplashTexts.IsChecked = OptionsManager.ConfigFile.ReadValueBool("EnableModSplashTexts", true); - } - if (m_EnableDistanceBasedDispatch is not null) { m_EnableDistanceBasedDispatch.IsChecked = OptionsManager.ConfigFile.ReadValueBool("EnableDistanceBasedEffectDispatch", false); SetDistanceDispatchFieldsEnabled(m_EnableDistanceBasedDispatch.IsChecked.GetValueOrDefault()); } - if (m_DistanceBasedDispatchDistance is not null) - { m_DistanceBasedDispatchDistance.Text = OptionsManager.ConfigFile.ReadValue("DistanceToActivateEffect", "250"); - } if (m_DistanceBasedDispatchType is not null) - { m_DistanceBasedDispatchType.SelectedIndex = OptionsManager.ConfigFile.ReadValueInt("DistanceType", 0); - } } public override void OnSaveValues() { OptionsManager.ConfigFile.WriteValue("NewEffectSpawnTime", m_EffectDispatchTimer?.Text); OptionsManager.ConfigFile.WriteValue("DisableTimerBarDraw", m_DisableDrawTimer?.IsChecked); - OptionsManager.ConfigFile.WriteValue("EffectTimedDur", m_TimedEffectDuration?.Text); OptionsManager.ConfigFile.WriteValue("DisableEffectTextDraw", m_DisableDrawEffectText?.IsChecked); - OptionsManager.ConfigFile.WriteValue("EffectTimedShortDur", m_ShortTimedEffectDuration?.Text); OptionsManager.ConfigFile.WriteValue("EnableClearEffectsShortcut", m_EnableClearActiveEffectsShortcut?.IsChecked); - OptionsManager.ConfigFile.WriteValue("Seed", m_RandomSeed?.Text); OptionsManager.ConfigFile.WriteValue("EnableToggleModShortcut", m_EnableToggleModShortcut?.IsChecked); - OptionsManager.ConfigFile.WriteValue("MaxParallelRunningEffects", m_MaxRunningEffects?.Text); OptionsManager.ConfigFile.WriteValue("EnableDebugMenu", m_EnableEffectsMenu?.IsChecked); - OptionsManager.ConfigFile.WriteValue("EffectTimerColor", m_TimerBarColor?.SelectedColor.ToString()); OptionsManager.ConfigFile.WriteValue("EnablePauseTimerShortcut", m_EnablePauseTimerShortcut?.IsChecked); - OptionsManager.ConfigFile.WriteValue("EffectTextColor", m_EffectTextColor?.SelectedColor.ToString()); OptionsManager.ConfigFile.WriteValue("EnableAntiSoftlockShortcut", m_EnableAntiSoftlockShortcut?.IsChecked); - OptionsManager.ConfigFile.WriteValue("EffectTimedTimerColor", m_EffectTimerBarColor?.SelectedColor.ToString()); OptionsManager.ConfigFile.WriteValue("EnableGroupWeightingAdjustments", m_EnableEffectGroupWeighting?.IsChecked); - OptionsManager.ConfigFile.WriteValue("DisableStartup", m_DisableModOnStartup?.IsChecked); OptionsManager.ConfigFile.WriteValue("EnableFailsafe", m_EnableFailsafe?.IsChecked); - OptionsManager.ConfigFile.WriteValue("EnableModSplashTexts", m_EnableModSplashTexts?.IsChecked); - OptionsManager.ConfigFile.WriteValue("EnableDistanceBasedEffectDispatch", m_EnableDistanceBasedDispatch?.IsChecked); - OptionsManager.ConfigFile.WriteValue("DistanceToActivateEffect", m_DistanceBasedDispatchDistance?.Text); OptionsManager.ConfigFile.WriteValue("DistanceType", m_DistanceBasedDispatchType?.SelectedIndex); } diff --git a/ConfigApp/Tabs/Voting/DiscordTab.cs b/ConfigApp/Tabs/Voting/DiscordTab.cs index 4e782f4bc..23e7f6556 100644 --- a/ConfigApp/Tabs/Voting/DiscordTab.cs +++ b/ConfigApp/Tabs/Voting/DiscordTab.cs @@ -6,27 +6,18 @@ namespace ConfigApp.Tabs.Voting public class DiscordTab : Tab { private CheckBox? m_EnableDiscordVoting = null; - private PasswordBox? m_Token = null; - private TextBox? m_GuildId = null; private TextBox? m_ChannelId = null; private void SetElementsEnabled(bool state) { if (m_Token is not null) - { m_Token.IsEnabled = state; - } - if (m_GuildId is not null) - { m_GuildId.IsEnabled = state; - } if (m_ChannelId is not null) - { m_ChannelId.IsEnabled = state; - } } protected override void InitContent() @@ -103,26 +94,17 @@ public override void OnLoadValues() } if (m_Token is not null) - { m_Token.Password = OptionsManager.TwitchFile.ReadValue("DiscordBotToken"); - } - if (m_GuildId is not null) - { m_GuildId.Text = OptionsManager.TwitchFile.ReadValue("DiscordGuildId"); - } if (m_ChannelId is not null) - { m_ChannelId.Text = OptionsManager.TwitchFile.ReadValue("DiscordChannelId"); - } } public override void OnSaveValues() { OptionsManager.TwitchFile.WriteValue("EnableVotingDiscord", m_EnableDiscordVoting?.IsChecked); - OptionsManager.TwitchFile.WriteValue("DiscordBotToken", m_Token?.Password); - OptionsManager.TwitchFile.WriteValue("DiscordGuildId", m_GuildId?.Text); OptionsManager.TwitchFile.WriteValue("DiscordChannelId", m_ChannelId?.Text); } diff --git a/ConfigApp/Tabs/Voting/GeneralTab.cs b/ConfigApp/Tabs/Voting/GeneralTab.cs index fab23455e..85b311222 100644 --- a/ConfigApp/Tabs/Voting/GeneralTab.cs +++ b/ConfigApp/Tabs/Voting/GeneralTab.cs @@ -8,15 +8,11 @@ public class GeneralTab : Tab private readonly List m_Grids = new(); private CheckBox? m_EnableVoting = null; - private ComboBox? m_OverlayMode = null; private CheckBox? m_EnableRandomEffect = null; - private TextBox? m_SecsBeforeVoting = null; private TextBox? m_PermittedUserNames = null; - private TextBox? m_VoteablePrefix = null; - private CheckBox? m_EnableProportionalVoting = null; private CheckBox? m_EnableProportionalVotingRetainInitialChance = null; @@ -33,9 +29,7 @@ private static void SetupSettingsGrid(ChaosGrid grid) private void SetGridsEnabled(bool state) { foreach (var grid in m_Grids) - { grid.IsEnabled = state; - } } protected override void InitContent() @@ -141,53 +135,31 @@ public override void OnLoadValues() m_EnableVoting.IsChecked = OptionsManager.TwitchFile.ReadValueBool("EnableVoting", false, "EnableTwitchVoting"); SetGridsEnabled(m_EnableVoting.IsChecked.GetValueOrDefault()); } - if (m_OverlayMode is not null) - { m_OverlayMode.SelectedIndex = OptionsManager.TwitchFile.ReadValueInt("VotingOverlayMode", 0, "TwitchVotingOverlayMode"); - } if (m_EnableRandomEffect is not null) - { m_EnableRandomEffect.IsChecked = OptionsManager.TwitchFile.ReadValueBool("RandomEffectVoteableEnable", true, "TwitchRandomEffectVoteableEnable"); - } - if (m_SecsBeforeVoting is not null) - { m_SecsBeforeVoting.Text = OptionsManager.TwitchFile.ReadValue("VotingSecsBeforeVoting", "0", "TwitchVotingSecsBeforeVoting"); - } if (m_PermittedUserNames is not null) - { m_PermittedUserNames.Text = OptionsManager.TwitchFile.ReadValue("PermittedUsernames", null, "TwitchPermittedUsernames"); - } - if (m_VoteablePrefix is not null) - { m_VoteablePrefix.Text = OptionsManager.TwitchFile.ReadValue("VoteablePrefix", ""); - } - if (m_EnableProportionalVoting is not null) - { m_EnableProportionalVoting.IsChecked = OptionsManager.TwitchFile.ReadValueBool("VotingChanceSystem", false, "TwitchVotingChanceSystem"); - } if (m_EnableProportionalVotingRetainInitialChance is not null) - { m_EnableProportionalVotingRetainInitialChance.IsChecked = OptionsManager.TwitchFile.ReadValueBool("VotingChanceSystemRetainChance", true, "TwitchVotingChanceSystemRetainChance"); - } } public override void OnSaveValues() { OptionsManager.TwitchFile.WriteValue("EnableVoting", m_EnableVoting?.IsChecked); - OptionsManager.TwitchFile.WriteValue("VotingOverlayMode", m_OverlayMode?.SelectedIndex); OptionsManager.TwitchFile.WriteValue("RandomEffectVoteableEnable", m_EnableRandomEffect?.IsChecked); - OptionsManager.TwitchFile.WriteValue("VotingSecsBeforeVoting", m_SecsBeforeVoting?.Text); OptionsManager.TwitchFile.WriteValue("PermittedUsernames", m_PermittedUserNames?.Text); - OptionsManager.TwitchFile.WriteValue("VoteablePrefix", m_VoteablePrefix?.Text); - OptionsManager.TwitchFile.WriteValue("VotingChanceSystem", m_EnableProportionalVoting?.IsChecked); OptionsManager.TwitchFile.WriteValue("VotingChanceSystemRetainChance", m_EnableProportionalVotingRetainInitialChance?.IsChecked); } diff --git a/ConfigApp/Tabs/Voting/TwitchTab.cs b/ConfigApp/Tabs/Voting/TwitchTab.cs index b38985417..b9b9faf16 100644 --- a/ConfigApp/Tabs/Voting/TwitchTab.cs +++ b/ConfigApp/Tabs/Voting/TwitchTab.cs @@ -6,27 +6,18 @@ namespace ConfigApp.Tabs.Voting public class TwitchTab : Tab { private CheckBox? m_EnableTwitchVoting = null; - private TextBox? m_ChannelName = null; private TextBox? m_UserName = null; - private PasswordBox? m_Token = null; private void SetElementsEnabled(bool state) { if (m_ChannelName is not null) - { m_ChannelName.IsEnabled = state; - } if (m_UserName is not null) - { m_UserName.IsEnabled = state; - } - if (m_Token is not null) - { m_Token.IsEnabled = state; - } } protected override void InitContent() @@ -82,29 +73,19 @@ public override void OnLoadValues() m_EnableTwitchVoting.IsChecked = OptionsManager.TwitchFile.ReadValueBool("EnableVotingTwitch", false); SetElementsEnabled(m_EnableTwitchVoting.IsChecked.GetValueOrDefault()); } - if (m_ChannelName is not null) - { m_ChannelName.Text = OptionsManager.TwitchFile.ReadValue("TwitchChannelName"); - } if (m_UserName is not null) - { m_UserName.Text = OptionsManager.TwitchFile.ReadValue("TwitchUserName"); - } - if (m_Token is not null) - { m_Token.Password = OptionsManager.TwitchFile.ReadValue("TwitchChannelOAuth"); - } } public override void OnSaveValues() { OptionsManager.TwitchFile.WriteValue("EnableVotingTwitch", m_EnableTwitchVoting?.IsChecked); - OptionsManager.TwitchFile.WriteValue("TwitchChannelName", m_ChannelName?.Text); OptionsManager.TwitchFile.WriteValue("TwitchUserName", m_UserName?.Text); - OptionsManager.TwitchFile.WriteValue("TwitchChannelOAuth", m_Token?.Password); } } diff --git a/ConfigApp/Tabs/Voting/VotingTab.cs b/ConfigApp/Tabs/Voting/VotingTab.cs index 71ba619ae..43720064f 100644 --- a/ConfigApp/Tabs/Voting/VotingTab.cs +++ b/ConfigApp/Tabs/Voting/VotingTab.cs @@ -50,17 +50,13 @@ protected override void InitContent() public override void OnLoadValues() { foreach (var tab in m_Tabs) - { tab.Value.OnLoadValues(); - } } public override void OnSaveValues() { foreach (var tab in m_Tabs) - { tab.Value.OnSaveValues(); - } } } } diff --git a/ConfigApp/Tabs/WorkshopTab.cs b/ConfigApp/Tabs/WorkshopTab.cs index a5ac017ba..bf80c4d93 100644 --- a/ConfigApp/Tabs/WorkshopTab.cs +++ b/ConfigApp/Tabs/WorkshopTab.cs @@ -39,7 +39,6 @@ enum SortingMode private CheckBox? m_SortIntalledFirstToggle = null; private WatermarkTextBox? m_SearchBox = null; - private ItemsControl? m_ItemsControl = null; private void SortSubmissionItems() @@ -54,15 +53,11 @@ private void SortSubmissionItems() _ => throw new NotImplementedException(), }; if (m_SortIntalledFirstToggle == null || m_SortIntalledFirstToggle.IsChecked.GetValueOrDefault(true)) - { items = items.OrderBy(item => item.InstallState); - } m_WorkshopSubmissionItems = new ObservableCollection(items); if (m_ItemsControl is not null) - { m_ItemsControl.ItemsSource = m_WorkshopSubmissionItems; - } } private void HandleWorkshopSubmissionsSearchFilter() @@ -72,9 +67,7 @@ private void HandleWorkshopSubmissionsSearchFilter() view.Filter = (submissionItem) => { if (submissionItem is not WorkshopSubmissionItem item || transformedText is null) - { return true; - } var texts = new string?[] { @@ -86,9 +79,7 @@ private void HandleWorkshopSubmissionsSearchFilter() foreach (var text in texts) { if (text is not null && text.ToLower().Contains(transformedText)) - { return true; - } }; return false; @@ -113,15 +104,11 @@ T getDataItem(dynamic item, T defaultValue) var id = getDataItem(submissionData.id, string.Empty); if (string.IsNullOrEmpty(id)) - { return; - } var version = getDataItem(submissionData.version, string.Empty); if (string.IsNullOrEmpty(version)) - { return; - } var lastUpdated = getDataItem(submissionData.lastupdated, 0); var sha256 = getDataItem(submissionData.sha256, string.Empty); @@ -130,17 +117,10 @@ T getDataItem(dynamic item, T defaultValue) if (duplicateSubmissionItem != null) { if (isLocal) - { if (duplicateSubmissionItem.Version != version || duplicateSubmissionItem.LastUpdated != lastUpdated || duplicateSubmissionItem.Sha256 != sha256) - { duplicateSubmissionItem.InstallState = WorkshopSubmissionItem.SubmissionInstallState.UpdateAvailable; - } else - { duplicateSubmissionItem.InstallState = WorkshopSubmissionItem.SubmissionInstallState.Installed; - } - } - return; } @@ -177,7 +157,6 @@ T getDataItem(dynamic item, T defaultValue) var dict = json["submissions"]?.ToObject?>(); if (dict is not null) - { foreach (var submissionObject in dict) { var submissionId = submissionObject.Key; @@ -187,7 +166,6 @@ T getDataItem(dynamic item, T defaultValue) submitWorkshopSubmissionData(submissionData, false); } - } } Directory.CreateDirectory("workshop"); @@ -208,9 +186,7 @@ T getDataItem(dynamic item, T defaultValue) var submissionData = json.ToObject(); if (submissionData == null) - { continue; - } submissionData.id = id; submitWorkshopSubmissionData(submissionData, true); @@ -245,7 +221,6 @@ private async Task ForceRefreshWorkshopContentFromRemote() if (remoteHash.ToLower() == Convert.ToHexString(sha256.ComputeHash(localContent)).ToLower()) { ParseWorkshopSubmissionsFile(localContent); - return; } } @@ -253,9 +228,7 @@ private async Task ForceRefreshWorkshopContentFromRemote() var submissionsResult = await httpClient.GetAsync($"{domain}/workshop/fetch_submissions"); if (!submissionsResult.IsSuccessStatusCode) - { MessageBox.Show("Remote server provided no master submissions file! Can not fetch available submissions.", "ChaosModV", MessageBoxButton.OK, MessageBoxImage.Error); - } else { var submissionsCompressedResult = await submissionsResult.Content.ReadAsByteArrayAsync(); @@ -285,9 +258,7 @@ private async void OnSettingsClick(object sender, RoutedEventArgs eventArgs) var dialog = new WorkshopSettingsDialog(); dialog.ShowDialog(); if (dialog.IsSaved) - { await ForceRefreshWorkshopContentFromRemote(); - } } private async void OnRefreshClick(object sender, RoutedEventArgs eventArgs) @@ -457,14 +428,11 @@ public async override void OnTabSelected() { // Only fetch them once if (m_WorkshopSubmissionItems.Count > 0) - { return; - }; byte[]? fileContent = null; // Use cached content if existing (and accessible), otherwise fall back to server request if (File.Exists(SUBMISSIONS_CACHED_FILENAME)) - { try { fileContent = File.ReadAllBytes(SUBMISSIONS_CACHED_FILENAME); @@ -473,10 +441,8 @@ public async override void OnTabSelected() { } - } if (fileContent != null) - { try { ParseWorkshopSubmissionsFile(fileContent); @@ -486,11 +452,8 @@ public async override void OnTabSelected() // Cached file is corrupt, force reload await ForceRefreshWorkshopContentFromRemote(); } - } else - { await ForceRefreshWorkshopContentFromRemote(); - } } } } diff --git a/ConfigApp/Utils.cs b/ConfigApp/Utils.cs index c6f894fad..f0caa799b 100644 --- a/ConfigApp/Utils.cs +++ b/ConfigApp/Utils.cs @@ -12,9 +12,7 @@ public static EffectData ValueStringToEffectData(string? value) var effectData = new EffectData(); if (value is null) - { return effectData; - } // Split by comma, ignoring commas in between quotation marks var values = Regex.Split(value, ",(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))"); @@ -24,43 +22,27 @@ public static EffectData ValueStringToEffectData(string? value) if (values.Length >= 4) { if (int.TryParse(values[0], out int enabled)) - { effectData.Enabled = enabled != 0; - } if (Enum.TryParse(values[1], out Effects.EffectTimedType timedType)) - { effectData.TimedType = timedType != Effects.EffectTimedType.NotTimed ? timedType : null; - } if (int.TryParse(values[2], out int customTime)) - { effectData.CustomTime = customTime; - } if (int.TryParse(values[3], out int weightMult)) - { effectData.WeightMult = weightMult; - } } if (values.Length >= 5 && int.TryParse(values[4], out int tmp) && tmp != 0) - { effectData.TimedType = Effects.EffectTimedType.Permanent; - } if (values.Length >= 6 && int.TryParse(values[5], out tmp)) - { effectData.ExcludedFromVoting = tmp != 0; - } if (values.Length >= 7) - { effectData.CustomName = values[6] == "0" ? null : values[6].Trim('\"'); - } if (values.Length >= 8 && int.TryParse(values[7], out int shortcut)) - { effectData.ShortcutKeycode = shortcut; - } return effectData; } @@ -68,26 +50,20 @@ public static EffectData ValueStringToEffectData(string? value) public static void HandleOnlyNumbersPreviewTextInput(object sender, TextCompositionEventArgs eventArgs) { if (eventArgs.Text.Length == 0 || !char.IsDigit(eventArgs.Text[0])) - { eventArgs.Handled = true; - } } public static void HandleNoSpacePreviewKeyDown(object sender, KeyEventArgs eventArgs) { if (eventArgs.Key == Key.Space) - { eventArgs.Handled = true; - } } public static void HandleNoCopyPastePreviewExecuted(object sender, ExecutedRoutedEventArgs eventArgs) { if (eventArgs.Command == ApplicationCommands.Copy || eventArgs.Command == ApplicationCommands.Cut || eventArgs.Command == ApplicationCommands.Paste) - { eventArgs.Handled = true; - } } public static CheckBox GenerateCommonCheckBox() diff --git a/ConfigApp/WorkshopEditDialog.xaml.cs b/ConfigApp/WorkshopEditDialog.xaml.cs index a0457afa3..aa10b2c23 100644 --- a/ConfigApp/WorkshopEditDialog.xaml.cs +++ b/ConfigApp/WorkshopEditDialog.xaml.cs @@ -24,9 +24,7 @@ public WorkshopSubmissionFile(string name, bool enabled, EffectData? effectData public int CompareTo(WorkshopSubmissionFile? obj) { if (obj is null) - { throw new ArgumentNullException(nameof(obj)); - } return Name.CompareTo(obj.Name); } @@ -72,9 +70,7 @@ TreeMenuItem generateItem(string text, TreeMenuItem? parent = null) { var item = new TreeMenuItem(text, parent); if (m_DialogMode == WorkshopEditDialogMode.Install) - { item.CheckBoxVisiblity = Visibility.Collapsed; - } return item; } @@ -90,9 +86,7 @@ TreeMenuItem generateItem(string text, TreeMenuItem? parent = null) // practically impossible, but I still have gotten errors when trying to substring. So just to be safe :) if (pathName.Length - 4 <= 0) - { continue; - } var pathFragments = (pathName.StartsWith("sounds\\") ? pathName[7..] : pathName).Split('\\'); @@ -109,9 +103,7 @@ TreeMenuItem generateItem(string text, TreeMenuItem? parent = null) break; case ".txt": if (m_DialogMode != WorkshopEditDialogMode.Install) - { continue; - } targetItem = txtParentItem; break; default: @@ -132,9 +124,7 @@ TreeMenuItem generateItem(string text, TreeMenuItem? parent = null) } if (i == pathFragments.Length - 1) - { targetItem = parentFolderItems[prevFragment]; - } else { if (!parentFolderItems.ContainsKey(curFragment)) @@ -160,9 +150,7 @@ TreeMenuItem generateItem(string text, TreeMenuItem? parent = null) effectConfig.ShowDialog(); if (!effectConfig.IsSaved) - { return; - } fileState.EffectData = effectConfig.GetNewData(); }; @@ -181,9 +169,7 @@ TreeMenuItem generateItem(string text, TreeMenuItem? parent = null) { var child = (TreeMenuItem)files_tree_view.Items.GetItemAt(i); if (child.Children.Count == 0) - { files_tree_view.Items.RemoveAt(i); - } } } diff --git a/ConfigApp/WorkshopInstallHandler.cs b/ConfigApp/WorkshopInstallHandler.cs index 34abaf709..46bd325aa 100644 --- a/ConfigApp/WorkshopInstallHandler.cs +++ b/ConfigApp/WorkshopInstallHandler.cs @@ -100,9 +100,7 @@ string getFileSha256(byte[] buffer) { var resultHash = hash.ComputeHash(buffer); foreach (var b in resultHash) - { sha256StrBuilder.Append(b.ToString("x2")); - } } return sha256StrBuilder.ToString(); @@ -204,9 +202,7 @@ string getFileSha256(byte[] buffer) { var trimmedName = (entry.FullName.StartsWith("sounds/") ? entry.FullName : entry.Name).Trim(); if (trimmedName.Length > 0) - { files.Add(new WorkshopSubmissionFile(trimmedName, true)); - } } files.Sort(); diff --git a/ConfigApp/WorkshopSettingsDialog.xaml.cs b/ConfigApp/WorkshopSettingsDialog.xaml.cs index 75c80243c..11d083ac9 100644 --- a/ConfigApp/WorkshopSettingsDialog.xaml.cs +++ b/ConfigApp/WorkshopSettingsDialog.xaml.cs @@ -8,10 +8,7 @@ public partial class WorkshopSettingsDialog : Window public bool IsSaved { - get - { - return m_IsSaved; - } + get => m_IsSaved; } public WorkshopSettingsDialog() diff --git a/ConfigApp/WorkshopSettingsHandler.cs b/ConfigApp/WorkshopSettingsHandler.cs index be7a8fcfe..22948d7a1 100644 --- a/ConfigApp/WorkshopSettingsHandler.cs +++ b/ConfigApp/WorkshopSettingsHandler.cs @@ -27,9 +27,7 @@ public void Execute(object? parameter) var id = m_SubmissionItem.Id; var submissionDir = $"workshop/{id}/"; if (!Directory.Exists(submissionDir)) - { return; - } var submissionSettingsFile = $"workshop/{id}.json"; var disabledFiles = new List(); @@ -44,17 +42,13 @@ public void Execute(object? parameter) var json = JObject.Parse(fileText); if (json.ContainsKey("disabled_files")) - { disabledFiles.AddRange(json["disabled_files"]?.Select(file => file.Value() ?? string.Empty) ?? Array.Empty()); - } if (json.ContainsKey("effect_settings")) { var scriptSettingsJson = json["effect_settings"]?.ToObject>(); if (scriptSettingsJson is not null) - { scriptSettings = scriptSettingsJson; - } } } } @@ -80,38 +74,24 @@ public void Execute(object? parameter) foreach (var state in editWindow.FileStates) { if (!state.Item.IsChecked) - { disabledFilesArrayJson.Add(state.FullPath); - } if (state.EffectData != null) - { // Don't save settings if everything is set 1:1 as defaults if (JsonConvert.SerializeObject(state.EffectData) != JsonConvert.SerializeObject(new EffectData())) - { scriptSettingsObjectJson[state.FullPath] = JToken.FromObject(state.EffectData); - } - } } var newJson = new JObject(); if (disabledFilesArrayJson.Count > 0) - { newJson.Add(new JProperty("disabled_files", disabledFilesArrayJson)); - } if (scriptSettingsObjectJson.Count > 0) - { newJson.Add(new JProperty("effect_settings", scriptSettingsObjectJson)); - } if (newJson.Count == 0) - { File.Delete(submissionSettingsFile); - } else - { File.WriteAllText(submissionSettingsFile, $"{newJson}"); - } } } } diff --git a/ConfigApp/WorkshopSubmissionItem.cs b/ConfigApp/WorkshopSubmissionItem.cs index ef2d4bdaa..9598c6445 100644 --- a/ConfigApp/WorkshopSubmissionItem.cs +++ b/ConfigApp/WorkshopSubmissionItem.cs @@ -37,10 +37,7 @@ public enum SubmissionInstallState public SubmissionInstallState InstallState { - get - { - return m_InstallState; - } + get => m_InstallState; set { m_InstallState = value; @@ -81,28 +78,19 @@ public SubmissionInstallState InstallState public ICommand InstallButtonCommand { - get - { - return new WorkshopInstallHandler(this); - } + get => new WorkshopInstallHandler(this); } public string InstallButtonText { get; private set; } = "Install"; public bool InstallButtonEnabled { get; private set; } = true; public ICommand InfoButtonCommand { - get - { - return new WorkshopInfoHandler(this); - } + get => new WorkshopInfoHandler(this); } public ICommand SettingsButtonCommand { - get - { - return new WorkshopSettingsHandler(this); - } + get => new WorkshopSettingsHandler(this); } public Visibility SettingsButtonVisibility { get; private set; } = Visibility.Hidden; @@ -115,9 +103,7 @@ public WorkshopSubmissionItem() { using var ico = Icon.ExtractAssociatedIcon(fileName); if (ico is not null) - { ms_DefaultIcon = Imaging.CreateBitmapSourceFromHIcon(ico.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); - } } } diff --git a/Shared/OptionsFile.cs b/Shared/OptionsFile.cs index 7bf064c41..6240c7925 100644 --- a/Shared/OptionsFile.cs +++ b/Shared/OptionsFile.cs @@ -17,12 +17,8 @@ public OptionsFile(string fileName, params string[] compatFileNames) public bool HasKey(params string[] keys) { foreach (var key in keys) - { if (m_Options.ContainsKey(key)) - { return true; - } - } return false; } @@ -30,9 +26,7 @@ public bool HasKey(params string[] keys) public IEnumerable GetKeys() { foreach (var option in m_Options) - { yield return option.Key; - } } public string? ReadValue(string key, string? defaultValue = null, params string[] compatKeys) @@ -41,9 +35,7 @@ public IEnumerable GetKeys() foreach (var _key in keys) { if (!m_Options.ContainsKey(_key) || m_Options[_key] is null) - { continue; - } return m_Options[_key]; } @@ -54,9 +46,7 @@ public IEnumerable GetKeys() public int ReadValueInt(string key, int defaultValue, params string[] compatKeys) { if (!int.TryParse(ReadValue(key, null, compatKeys), out int result)) - { result = defaultValue; - } return result; } @@ -64,9 +54,7 @@ public int ReadValueInt(string key, int defaultValue, params string[] compatKeys public long ReadValueLong(string key, long defaultValue, params string[] compatKeys) { if (!long.TryParse(ReadValue(key, null, compatKeys), out long result)) - { result = defaultValue; - } return result; } @@ -77,14 +65,10 @@ public bool ReadValueBool(string key, bool defaultValue, params string[] compatK foreach (var _key in keys) { if (!m_Options.ContainsKey(_key) || m_Options[_key] == null) - { continue; - } if (int.TryParse(ReadValue(_key), out int result)) - { return result != 0; - } } return defaultValue; @@ -110,15 +94,11 @@ public void ReadFile() static string? readData(string fileName) { if (!File.Exists(fileName)) - { return null; - } string _data = File.ReadAllText(fileName); if (_data.Length == 0) - { return null; - } return _data; } @@ -128,18 +108,14 @@ public void ReadFile() { bool dataRead = false; foreach (var compatFileName in m_CompatFileNames) - { if ((data = readData(compatFileName)) != null) { dataRead = true; break; } - } if (!dataRead) - { return; - } } m_Options.Clear(); @@ -149,9 +125,7 @@ public void ReadFile() foreach (string line in data.Split('\n')) { if (!line.Contains('=')) - { continue; - } var keyValuePair = line.Split('=', 2, System.StringSplitOptions.RemoveEmptyEntries | System.StringSplitOptions.TrimEntries); @@ -164,37 +138,27 @@ public void ReadFile() public void WriteFile() { if (m_FileName is null) - { return; - } string data = string.Empty; foreach (var option in m_Options) - { data += $"{option.Key}={option.Value}\n"; - } var directory = Path.GetDirectoryName(m_FileName); if (directory is not null) - { Directory.CreateDirectory(directory); - } File.WriteAllText(m_FileName, data); } public void ResetFile() { if (m_FileName is null) - { return; - } var directory = Path.GetDirectoryName(m_FileName); if (directory is not null) - { Directory.CreateDirectory(directory); - } File.WriteAllText(m_FileName, null); // Reset all options too @@ -204,12 +168,8 @@ public void ResetFile() public bool HasCompatFile() { foreach (var compatFileName in m_CompatFileNames) - { if (File.Exists(compatFileName)) - { return true; - } - } return false; } diff --git a/TwitchChatVotingProxy/ChaosModController.cs b/TwitchChatVotingProxy/ChaosModController.cs index 7dc6536cd..29a3d49d8 100644 --- a/TwitchChatVotingProxy/ChaosModController.cs +++ b/TwitchChatVotingProxy/ChaosModController.cs @@ -39,9 +39,7 @@ public ChaosModController(IChaosPipeClient chaosPipe, IOverlayServer? overlaySer // Setup receiver listeners foreach (var votingReceiver in m_VotingReceivers) - { votingReceiver.OnMessage += OnVoteReceiverMessage; - } // Setup display update tick m_DisplayUpdateTick.Elapsed += DisplayUpdateTick; @@ -84,7 +82,8 @@ private int GetVoteResultByPercentage() var totalVotes = 0; votes.ForEach(_ => totalVotes += _); // If we have no votes, choose one at random - if (totalVotes == 0) return m_Random.Next(0, votes.Count); + if (totalVotes == 0) + return m_Random.Next(0, votes.Count); // Select a random vote from all votes var selectedVote = m_Random.Next(1, totalVotes + 1); // Now find out in what vote range/option that vote is @@ -119,7 +118,6 @@ private void OnGetVoteResult(object? sender, OnGetVoteResultArgs e) try { m_OverlayServer?.EndVoting(); - } catch (Exception err) { @@ -180,14 +178,10 @@ private async void OnNewVote(object? sender, OnNewVoteArgs e) } if (m_Config.VotingMode == EVotingMode.PERCENTAGE) - { msg += "\nVotes will affect the chance for one of the effects to occur."; - } foreach (var votingReceiver in m_VotingReceivers) - { await votingReceiver.SendMessage(msg); - } break; case EOverlayMode.OVERLAY_OBS: @@ -215,9 +209,7 @@ private void OnNoVotingRound(object? sender, EventArgs e) private void OnVoteReceiverMessage(object? sender, OnMessageArgs e) { if (!m_VoteRunning || e.ClientId is null || e.Message is null) - { return; - } if (m_Config.PermittedUsernames?.Length > 0 && e.Username is not null) { @@ -234,9 +226,7 @@ private void OnVoteReceiverMessage(object? sender, OnMessageArgs e) } if (!found) - { return; - } } for (int i = 0; i < m_ActiveVoteOptions.Count; i++) diff --git a/TwitchChatVotingProxy/ChaosPipe/ChaosPipeClient.cs b/TwitchChatVotingProxy/ChaosPipe/ChaosPipeClient.cs index e16c94505..6c382c6af 100644 --- a/TwitchChatVotingProxy/ChaosPipe/ChaosPipeClient.cs +++ b/TwitchChatVotingProxy/ChaosPipe/ChaosPipeClient.cs @@ -132,9 +132,7 @@ private void GetCurrentVotes() var args = new OnGetCurrentVotesArgs(); OnGetCurrentVotes?.Invoke(this, args); if (args.CurrentVotes == null) - { m_Logger.Error("Listeners failed to supply on get current vote args"); - } else { CurrentVotesResult res = new(args.CurrentVotes); @@ -183,9 +181,7 @@ private void ReadPipe() { // If no reading task is active, create one if (m_ReadPipeTask == null) - { m_ReadPipeTask = m_PipeReader?.ReadLineAsync(); - } // If the reading task is created and complete, get its results else if (m_ReadPipeTask.IsCompleted) { @@ -238,9 +234,7 @@ public void SendMessageToPipe(string message) private void StartNewVote(List? options) { if (options is null) - { return; - } // Dispatch information to listeners OnNewVote?.Invoke(this, new OnNewVoteArgs(options.ToArray())); diff --git a/TwitchChatVotingProxy/OverlayServer/OverlayServer.cs b/TwitchChatVotingProxy/OverlayServer/OverlayServer.cs index f6fad57d8..6ea63a34b 100644 --- a/TwitchChatVotingProxy/OverlayServer/OverlayServer.cs +++ b/TwitchChatVotingProxy/OverlayServer/OverlayServer.cs @@ -36,14 +36,17 @@ public void EndVoting() { Request("END", new List()); } + public void NewVoting(List voteOptions) { Request("CREATE", voteOptions); } + public void NoVotingRound() { Request("NO_VOTING_ROUND", new List()); } + public void UpdateVoting(List voteOptions) { Request("UPDATE", voteOptions); @@ -59,13 +62,9 @@ private void Broadcast(string message) { // If the connection is not available for some reason, we just close it if (!connection.IsAvailable) - { connection.Close(); - } else - { connection.Send(message); - } }); } /// @@ -115,9 +114,7 @@ private void Request(string request, List voteOptions) }; var strVotingMode = VotingMode.Lookup(config.VotingMode); if (strVotingMode != null) - { msg.VotingMode = strVotingMode; - } else { logger.Error($"Could not find voting mode {config.VotingMode} in dictionary"); diff --git a/TwitchChatVotingProxy/README.md b/TwitchChatVotingProxy/README.md index e543566df..bfc80cdd6 100644 --- a/TwitchChatVotingProxy/README.md +++ b/TwitchChatVotingProxy/README.md @@ -9,7 +9,6 @@ Either through Visual Studio or using the `dotnet` CLI tool (`dotnet build` or ` ## Coding conventions - This project provides a custom .editorconfig file. Please make sure to format your source code before contributing, there should be support for just about every IDE / editor out there - either officially or using an extension. Alternatively you can run `dotnet format`. -- Always use brackets for if, for and while expressions. - Naming: - Private member variables: `m_Foo` - Static global variables specific to file: `ms_Foo` diff --git a/TwitchChatVotingProxy/TwitchChatVotingProxy.cs b/TwitchChatVotingProxy/TwitchChatVotingProxy.cs index ee03c8fd7..a7fa37a35 100644 --- a/TwitchChatVotingProxy/TwitchChatVotingProxy.cs +++ b/TwitchChatVotingProxy/TwitchChatVotingProxy.cs @@ -57,13 +57,9 @@ private static async Task Main(string[] args) var votingReceivers = new List<(string Name, IVotingReceiver VotingReceiver)>(); if (config.ReadValueBool("EnableVotingTwitch", false)) - { votingReceivers.Add(("Twitch", new TwitchVotingReceiver(config, chaosPipe))); - } if (config.ReadValueBool("EnableVotingDiscord", false)) - { votingReceivers.Add(("Discord", new DiscordVotingReceiver(config, chaosPipe))); - } foreach (var votingReceiver in votingReceivers) { @@ -108,19 +104,13 @@ private static async Task Main(string[] args) chaosPipe.SendMessageToPipe("hello"); while (!chaosPipe.GotHelloBack && chaosPipe.IsConnected()) - { await Task.Delay(100); - } if (chaosPipe.GotHelloBack) - { m_Logger.Information("Received hello_back from mod!"); - } while (chaosPipe.IsConnected()) - { await Task.Delay(100); - } m_Logger.Information("Pipe disconnected, ending program."); } diff --git a/TwitchChatVotingProxy/VotingReceiver/DiscordVotingReceiver.cs b/TwitchChatVotingProxy/VotingReceiver/DiscordVotingReceiver.cs index b36eabd34..a1d658e66 100644 --- a/TwitchChatVotingProxy/VotingReceiver/DiscordVotingReceiver.cs +++ b/TwitchChatVotingProxy/VotingReceiver/DiscordVotingReceiver.cs @@ -60,9 +60,7 @@ public async Task Init() await m_Client.StartAsync(); while (!m_IsReady) - { await Task.Delay(100); - } return true; } @@ -70,9 +68,7 @@ public async Task Init() public async Task SendMessage(string message) { if (m_Client is null || m_GuildId is null || m_ChannelId is null) - { return; - } void handleFatal() { @@ -135,9 +131,7 @@ private Task OnLog(LogMessage log) private async Task OnReady() { if (m_Client is null) - { return; - } m_Logger.Information("Successfully connected to discord"); @@ -167,9 +161,7 @@ private Task OnDisconnected(Exception exception) m_Logger.Information($"Discord client disconnected: {exception}"); if (exception is HttpException && exception is HttpException { HttpCode: System.Net.HttpStatusCode.Unauthorized }) - { m_ChaosPipe.SendErrorMessage("Discord bot token is invalid. Please verify your config."); - } return Task.CompletedTask; } diff --git a/TwitchChatVotingProxy/VotingReceiver/TwitchVotingReceiver.cs b/TwitchChatVotingProxy/VotingReceiver/TwitchVotingReceiver.cs index c827319ef..37af5479d 100644 --- a/TwitchChatVotingProxy/VotingReceiver/TwitchVotingReceiver.cs +++ b/TwitchChatVotingProxy/VotingReceiver/TwitchVotingReceiver.cs @@ -80,9 +80,7 @@ public async Task Init() } while (!m_IsReady) - { await Task.Delay(100); - } return true; } @@ -90,16 +88,12 @@ public async Task Init() public Task SendMessage(string message) { if (m_Client is null) - { return Task.FromResult(0); - } try { foreach (var msg in message.Split("\n")) - { m_Client.SendMessage(m_ChannelName, msg); - } } catch (Exception e) {