Skip to content

Commit

Permalink
Treewide: Format
Browse files Browse the repository at this point in the history
  • Loading branch information
pongo1231 committed Feb 14, 2025
1 parent f020502 commit 36fe2b0
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 59 deletions.
2 changes: 1 addition & 1 deletion ChaosMod/Components/DebugMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#include "Components/EffectDispatcher.h"
#include "Effects/EnabledEffects.h"
#include "Util/OptionsManager.h"
#include "Util/HelpText.h"
#include "Util/OptionsManager.h"

#define MAX_VIS_ITEMS 15

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

static bool OnCondition()
{
return ComponentExists<Voting>() && GetComponent<Voting>()->IsEnabled() && GetComponent<Voting>()->GetVotingMode() == VotingMode::Percentage;
return ComponentExists<Voting>() && GetComponent<Voting>()->IsEnabled()
&& GetComponent<Voting>()->GetVotingMode() == VotingMode::Percentage;
}

REGISTER_EFFECT_CONDITION(EffectConditionType::ProportionalVotingEnabled, OnCondition, "Proportional voting is not enabled");
REGISTER_EFFECT_CONDITION(EffectConditionType::ProportionalVotingEnabled, OnCondition,
"Proportional voting is not enabled");
8 changes: 4 additions & 4 deletions ChaosMod/Effects/Condition/EffectCondition.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#include "Util/Logging.h"
#include "Util/MacroConcat.h"

#include <unordered_map>
#include <functional>
#include <unordered_map>

enum class EffectConditionType
{
Expand All @@ -13,9 +13,9 @@ enum class EffectConditionType
ProportionalVotingEnabled
};

#define REGISTER_EFFECT_CONDITION(conditionType, condition, failReason) \
namespace \
{ \
#define REGISTER_EFFECT_CONDITION(conditionType, condition, failReason) \
namespace \
{ \
EffectCondition CHAOSCONCAT(_effectCondition, __LINE__)(conditionType, condition, failReason); \
}

Expand Down
6 changes: 3 additions & 3 deletions ChaosMod/Effects/db/Peds/PedsSpawnCompanionBrad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ static void OnStart()
{
static const Hash model = "ig_brad"_hash;

Ped playerPed = PLAYER_PED_ID();
Vector3 playerPos = GET_ENTITY_COORDS(playerPed, false);
Ped playerPed = PLAYER_PED_ID();
Vector3 playerPos = GET_ENTITY_COORDS(playerPed, false);

Ped ped = CreatePoolPed(4, model, playerPos.x, playerPos.y, playerPos.z, GET_ENTITY_HEADING(playerPed));
Ped ped = CreatePoolPed(4, model, playerPos.x, playerPos.y, playerPos.z, GET_ENTITY_HEADING(playerPed));
CurrentEffect::SetEffectSoundPlayOptions(
{ .PlayType = EffectSoundPlayType::FollowEntity, .PlayFlags = EffectSoundPlayFlags_Looping, .Entity = ped });
if (IS_PED_IN_ANY_VEHICLE(playerPed, false))
Expand Down
4 changes: 2 additions & 2 deletions ChaosMod/Effects/db/Peds/PedsSpawnCompanionChimp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ static void OnStart()
{
static const Hash modelHash = "a_c_chimp"_hash;

Ped playerPed = PLAYER_PED_ID();
Vector3 playerPos = GET_ENTITY_COORDS(playerPed, false);
Ped playerPed = PLAYER_PED_ID();
Vector3 playerPos = GET_ENTITY_COORDS(playerPed, false);

Ped ped = CreatePoolPed(28, modelHash, playerPos.x, playerPos.y, playerPos.z, GET_ENTITY_HEADING(playerPed));
CurrentEffect::SetEffectSoundPlayOptions({ .PlayType = EffectSoundPlayType::FollowEntity, .Entity = ped });
Expand Down
4 changes: 2 additions & 2 deletions ChaosMod/Effects/db/Peds/PedsSpawnCompanionChop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ static void OnStart()
{
static const Hash modelHash = "a_c_chop"_hash;

Ped playerPed = PLAYER_PED_ID();
Vector3 playerPos = GET_ENTITY_COORDS(playerPed, false);
Ped playerPed = PLAYER_PED_ID();
Vector3 playerPos = GET_ENTITY_COORDS(playerPed, false);

Ped ped = CreatePoolPed(28, modelHash, playerPos.x, playerPos.y, playerPos.z, GET_ENTITY_HEADING(playerPed));
CurrentEffect::SetEffectSoundPlayOptions({ .PlayType = EffectSoundPlayType::FollowEntity, .Entity = ped });
Expand Down
75 changes: 38 additions & 37 deletions ChaosMod/Memory/Hooks/ShaderHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,43 +78,44 @@ namespace Hooks
auto result = shaderCache.find(hash);
if (result == shaderCache.end())
{
auto future = std::async(
std::launch::async,
[&]()
{
ID3DBlob *shader;
ID3DBlob *errorMessages;
HRESULT compileResult;
if ((compileResult = D3DCompile(shaderSrc.data(), shaderSrc.size(), NULL, NULL, NULL, "main",
"ps_4_0", 0, 0, &shader, &errorMessages))
== S_OK)
{
auto ptr = reinterpret_cast<BYTE *>(shader->GetBufferPointer());
std::vector<BYTE> shaderBytecode;
shaderBytecode.reserve(shader->GetBufferSize());
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);
}
else
{
LOG("Error compiling shader: Error code 0x" << std::hex << std::uppercase << compileResult << std::dec);
if (errorMessages)
{
auto ptr = reinterpret_cast<BYTE *>(errorMessages->GetBufferPointer());
std::string buffer;
buffer.reserve(errorMessages->GetBufferSize());
std::copy(ptr, ptr + errorMessages->GetBufferSize(), std::back_inserter(buffer));

LOG(buffer);
return;
}
}
});
auto future =
std::async(std::launch::async,
[&]()
{
ID3DBlob *shader;
ID3DBlob *errorMessages;
HRESULT compileResult;
if ((compileResult = D3DCompile(shaderSrc.data(), shaderSrc.size(), NULL, NULL, NULL,
"main", "ps_4_0", 0, 0, &shader, &errorMessages))
== S_OK)
{
auto ptr = reinterpret_cast<BYTE *>(shader->GetBufferPointer());
std::vector<BYTE> shaderBytecode;
shaderBytecode.reserve(shader->GetBufferSize());
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);
}
else
{
LOG("Error compiling shader: Error code 0x" << std::hex << std::uppercase
<< compileResult << std::dec);
if (errorMessages)
{
auto ptr = reinterpret_cast<BYTE *>(errorMessages->GetBufferPointer());
std::string buffer;
buffer.reserve(errorMessages->GetBufferSize());
std::copy(ptr, ptr + errorMessages->GetBufferSize(), std::back_inserter(buffer));

LOG(buffer);
return;
}
}
});

using namespace std::chrono_literals;
while (future.wait_for(0ms) != std::future_status::ready)
Expand Down
3 changes: 2 additions & 1 deletion ChaosMod/Memory/Memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ namespace Memory
return {};

auto resultAddr = reinterpret_cast<uintptr_t>(thePattern.get_first());
DEBUG_LOG("Found pattern \"" << pattern << "\" at address 0x" << std::uppercase << std::hex << resultAddr << std::dec);
DEBUG_LOG("Found pattern \"" << pattern << "\" at address 0x" << std::uppercase << std::hex << resultAddr
<< std::dec);
return resultAddr;
};

Expand Down
6 changes: 3 additions & 3 deletions ChaosMod/Memory/Snow.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ namespace Memory
{
/* Thanks to menyoo! */

static bool init = false;
static bool init = false;

static bool isPre3095 = getGameVersion() < eGameVersion::VER_1_0_3095_0;
auto snowPattern1 = isPre3095 ? "80 3D ?? ?? ?? ?? 00 74 25 B9 40 00 00 00"
: "44 38 ?? ?? ?? ?? 01 74 12 B9 40 00 00 00";
auto snowPattern1 =
isPre3095 ? "80 3D ?? ?? ?? ?? 00 74 25 B9 40 00 00 00" : "44 38 ?? ?? ?? ?? 01 74 12 B9 40 00 00 00";
static auto handle = FindPattern(snowPattern1);
if (!handle.IsValid())
return;
Expand Down
2 changes: 1 addition & 1 deletion ConfigApp/EffectConfig.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public EffectConfig(string? effectId, EffectData? effectData, EffectInfo effectI
if (m_IsTimedEffect)
{
effectconf_timer_type_enable.IsChecked = m_EffectData.TimedType.HasValue &&
m_EffectData.TimedType != defaultTimedType &&
m_EffectData.TimedType != defaultTimedType &&
m_EffectData.TimedType != EffectTimedType.Custom;
effectconf_timer_type.ItemsSource = new string[]
{
Expand Down
2 changes: 1 addition & 1 deletion ConfigApp/EffectsTreeMenuItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public ICommand OnConfigureCommand
{
get => new TreeMenuItemAction(OnConfigureClick);
}

public TreeMenuItem(string text, TreeMenuItem? parent = null)
{
Text = text;
Expand Down
2 changes: 1 addition & 1 deletion ConfigApp/Workshop/WorkshopSubmissionFileHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using System.Windows;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

public class WorkshopSubmissionFileHandler
{
Expand Down
2 changes: 1 addition & 1 deletion TwitchChatVotingProxy/ChaosPipe/ChaosPipeClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ private void ChangeVotingMode(List<string>? options)
m_Logger.Error("Unknown voting mode: " + modeName);
return;
}

m_Logger.Information("Setting voting mode to " + modeName);
OnSetVotingMode?.Invoke(this, new((EVotingMode)mode));
}
Expand Down

0 comments on commit 36fe2b0

Please sign in to comment.