Skip to content

Commit

Permalink
Merge pull request #533 from openmultiplayer/amir/fix-formatting
Browse files Browse the repository at this point in the history
Fix formatting so CI passes now
  • Loading branch information
AmyrAhmady committed Dec 14, 2022
2 parents 3f78a69 + 890a69c commit 3fb39da
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 26 deletions.
4 changes: 2 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ AlignConsecutiveAssignments: false
AlignConsecutiveBitFields: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: DontAlign
AlignOperands: DontAlign
AlignTrailingComments: false
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
Expand All @@ -17,7 +17,7 @@ AllowShortEnumsOnASingleLine: true
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AllowShortLambdasOnASingleLine: None
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
Expand Down
8 changes: 6 additions & 2 deletions SDK/include/Impl/events_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ struct DefaultEventDispatcher final : public IEventDispatcher<EventHandlerType>,
// `anyTrue` should still CALL them call, don't short-circuit.
bool ret = false;
std::for_each(handlers.begin(), handlers.end(), typename Storage::template Func<bool, Fn>([&fn, &ret]()
{ ret = fn() || ret; }));
{
ret = fn() || ret;
}));
return ret;
}

Expand All @@ -167,7 +169,9 @@ struct DefaultEventDispatcher final : public IEventDispatcher<EventHandlerType>,
{
bool ret = true;
std::for_each(handlers.begin(), handlers.end(), typename Storage::template Func<bool, Fn>([&fn, &ret]()
{ ret = fn() && ret; }));
{
ret = fn() && ret;
}));
return ret;
}

Expand Down
8 changes: 6 additions & 2 deletions SDK/include/anim.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2005,15 +2005,19 @@ inline bool animationNameValid(StringView lib, StringView name)
Impl::String fullName(lib);
fullName += ':' + Impl::String(name);
std::transform(fullName.begin(), fullName.end(), fullName.begin(), [](unsigned char c)
{ return std::toupper(c); });
{
return std::toupper(c);
});
return AnimationNamesLookup.valid.find(fullName) != AnimationNamesLookup.valid.end();
}

inline bool animationLibraryValid(StringView lib, bool v1_0 = true)
{
Impl::String fullName(lib);
std::transform(fullName.begin(), fullName.end(), fullName.begin(), [](unsigned char c)
{ return std::toupper(c); });
{
return std::toupper(c);
});
if (AnimationLibraryLookup.valid.find(fullName) != AnimationLibraryLookup.valid.end())
{
return true;
Expand Down
4 changes: 3 additions & 1 deletion Server/Components/Console/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,9 @@ ADD_CONSOLE_CMD(rcon_password, [](const String& params, const ConsoleCommandSend
});

ADD_CONSOLE_CMD(echo, [](const String& params, const ConsoleCommandSenderData& sender, ConsoleComponent& console, ICore* core)
{ console.sendMessage(sender, params); });
{
console.sendMessage(sender, params);
});

ADD_CONSOLE_CMD(messageslimit, [](const String& params, const ConsoleCommandSenderData& sender, ConsoleComponent& console, ICore* core)
{
Expand Down
4 changes: 3 additions & 1 deletion Server/Components/CustomModels/models.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,9 @@ class CustomModelsComponent final : public ICustomModelsComponent, public Player
bool getCustomModelPath(int32_t modelId, StringView& dffPath, StringView& txdPath) const override
{
auto model = std::find_if(storage.begin(), storage.end(), [&](const auto& model)
{ return model->getId() == modelId; });
{
return model->getId() == modelId;
});

if (model != storage.end())
{
Expand Down
8 changes: 6 additions & 2 deletions Server/Components/LegacyConfig/config_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@ class LegacyConfigComponent final : public ILegacyConfigComponent, public Consol
// Try all variants from most specific to least specific.
Impl::String lower(right);
std::transform(lower.begin(), lower.end(), lower.begin(), [](unsigned char c)
{ return std::tolower(c); });
{
return std::tolower(c);
});
if (lower == "true")
{
config.setBool(name, true);
Expand Down Expand Up @@ -334,7 +336,9 @@ class LegacyConfigComponent final : public ILegacyConfigComponent, public Consol
{
Impl::String lower(right);
std::transform(lower.begin(), lower.end(), lower.begin(), [](unsigned char c)
{ return std::tolower(c); });
{
return std::tolower(c);
});
if (lower == "true" || lower == "1")
{
config.setBool(dictIt->second, true);
Expand Down
4 changes: 3 additions & 1 deletion Server/Components/Pawn/Manager/Manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ class PawnManager : public Singleton<PawnManager>
DynamicArray<Pair<String, std::unique_ptr<PawnScript>>>::const_iterator const findScript(String const& name) const
{
return std::find_if(scripts_.begin(), scripts_.end(), [name](Pair<String, std::unique_ptr<PawnScript>> const& it)
{ return it.first == name; });
{
return it.first == name;
});
}

public:
Expand Down
2 changes: 1 addition & 1 deletion Server/Components/Pawn/Scripting/Types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ class ParamCast<DynamicArray<T> const&>
ParamCast(ParamCast<DynamicArray<T> const&> const&) = delete;
ParamCast(ParamCast<DynamicArray<T> const&>&&) = delete;

operator DynamicArray<T> const &()
operator DynamicArray<T> const&()
{
return value_;
}
Expand Down
4 changes: 3 additions & 1 deletion Server/Components/Pawn/Scripting/Vehicle/Natives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,9 @@ SCRIPT_API(GetVehicleModelsUsed, int())
auto& vehicle_models = PawnManager::Get()->vehicles->models();

return std::count_if(vehicle_models.begin(), vehicle_models.end(), [](uint8_t model_instances)
{ return model_instances > 0; });
{
return model_instances > 0;
});
}

SCRIPT_API(GetVehiclePaintjob, int(IVehicle& vehicle))
Expand Down
12 changes: 9 additions & 3 deletions Server/Components/Vehicles/vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ bool Vehicle::updateFromDriverSync(const VehicleDriverSyncPacket& vehicleSync, I
sirenState = vehicleSync.Siren;
params.siren = sirenState != 0;
static_cast<DefaultEventDispatcher<VehicleEventHandler>&>(pool->getEventDispatcher()).stopAtFalse([&player, this](VehicleEventHandler* handler)
{ return handler->onVehicleSirenStateChange(player, *this, sirenState); });
{
return handler->onVehicleSirenStateChange(player, *this, sirenState);
});
}

if (driver != &player)
Expand Down Expand Up @@ -254,7 +256,9 @@ bool Vehicle::updateFromUnoccupied(const VehicleUnoccupiedSyncPacket& unoccupied

UnoccupiedVehicleUpdate data = UnoccupiedVehicleUpdate { unoccupiedSync.SeatID, unoccupiedSync.Position, unoccupiedSync.Velocity };
bool allowed = static_cast<DefaultEventDispatcher<VehicleEventHandler>&>(pool->getEventDispatcher()).stopAtFalse([&player, this, &data](VehicleEventHandler* handler)
{ return handler->onUnoccupiedVehicleUpdate(*this, player, data); });
{
return handler->onUnoccupiedVehicleUpdate(*this, player, data);
});

if (cab && !towing)
{
Expand Down Expand Up @@ -325,7 +329,9 @@ bool Vehicle::updateFromTrailerSync(const VehicleTrailerSyncPacket& trailerSync,
*/

bool allowed = static_cast<DefaultEventDispatcher<VehicleEventHandler>&>(pool->getEventDispatcher()).stopAtFalse([&player, this](VehicleEventHandler* handler)
{ return handler->onTrailerUpdate(player, *this); });
{
return handler->onTrailerUpdate(player, *this);
});
return allowed;
}

Expand Down
4 changes: 3 additions & 1 deletion Server/Components/Vehicles/vehicles_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,9 @@ class VehiclesComponent final : public IVehiclesComponent, public CoreEventHandl
}

self.eventDispatcher.all([&peer, scmEvent](VehicleEventHandler* handler)
{ handler->onEnterExitModShop(peer, scmEvent.Arg1, scmEvent.Arg2); });
{
handler->onEnterExitModShop(peer, scmEvent.Arg1, scmEvent.Arg2);
});

NetCode::RPC::SCMEvent enterExitRPC;
enterExitRPC.PlayerID = peer.getID();
Expand Down
12 changes: 9 additions & 3 deletions Server/Source/core_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ struct adl_serializer<std::variant<Args...>>
static void to_json(ordered_json& j, std::variant<Args...> const& v)
{
std::visit([&](auto&& value)
{ j = std::forward<decltype(value)>(value); },
{
j = std::forward<decltype(value)>(value);
},
v);
}
};
Expand Down Expand Up @@ -468,7 +470,9 @@ class Config final : public IEarlyConfig
void removeBan(const BanEntry& entry) override
{
auto ban_itr = std::find_if(bans.begin(), bans.end(), [&](const BanEntry& ban)
{ return ban.address == entry.address; });
{
return ban.address == entry.address;
});

if (ban_itr != bans.end())
{
Expand Down Expand Up @@ -532,7 +536,9 @@ class Config final : public IEarlyConfig
bool isBanned(const BanEntry& entry) const override
{
return std::any_of(bans.begin(), bans.end(), [&](const BanEntry& ban)
{ return entry.address == ban.address; });
{
return entry.address == ban.address;
});
}

size_t getBansCount() const override
Expand Down
24 changes: 18 additions & 6 deletions Server/Source/player_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,9 @@ struct PlayerPool final : public IPlayerPool, public NetworkEventHandler, public
if (filteredMessage.size() > 1)
{
bool send = self.eventDispatcher.stopAtTrue([&peer, filteredMessage](PlayerEventHandler* handler)
{ return handler->onPlayerCommandText(peer, filteredMessage); });
{
return handler->onPlayerCommandText(peer, filteredMessage);
});

if (!send)
{
Expand Down Expand Up @@ -707,7 +709,9 @@ struct PlayerPool final : public IPlayerPool, public NetworkEventHandler, public
const uint32_t oldKeys = player.keys_.keys;
player.keys_.keys = newKeys;
self.eventDispatcher.all([&peer, oldKeys, newKeys](PlayerEventHandler* handler)
{ handler->onPlayerKeyStateChange(peer, newKeys, oldKeys); });
{
handler->onPlayerKeyStateChange(peer, newKeys, oldKeys);
});
}

player.setState(PlayerState_OnFoot);
Expand Down Expand Up @@ -778,13 +782,17 @@ struct PlayerPool final : public IPlayerPool, public NetworkEventHandler, public
const uint32_t oldKeys = player.keys_.keys;
player.keys_.keys = newKeys;
self.eventDispatcher.all([&peer, oldKeys, newKeys](PlayerEventHandler* handler)
{ handler->onPlayerKeyStateChange(peer, newKeys, oldKeys); });
{
handler->onPlayerKeyStateChange(peer, newKeys, oldKeys);
});
}
player.setState(PlayerState_Spectating);

TimePoint now = Time::now();
if (self.playerUpdateDispatcher.stopAtFalse([&peer, now](PlayerUpdateEventHandler* handler)
{ return handler->onUpdate(peer, now); }))
{
return handler->onUpdate(peer, now);
}))
{
}
return true;
Expand Down Expand Up @@ -1098,7 +1106,9 @@ struct PlayerPool final : public IPlayerPool, public NetworkEventHandler, public
const uint32_t oldKeys = player.keys_.keys;
player.keys_.keys = newKeys;
self.eventDispatcher.all([&peer, oldKeys, newKeys](PlayerEventHandler* handler)
{ handler->onPlayerKeyStateChange(peer, newKeys, oldKeys); });
{
handler->onPlayerKeyStateChange(peer, newKeys, oldKeys);
});
}
player.setState(PlayerState_Driver);

Expand Down Expand Up @@ -1346,7 +1356,9 @@ struct PlayerPool final : public IPlayerPool, public NetworkEventHandler, public
const uint32_t oldKeys = player.keys_.keys;
player.keys_.keys = newKeys;
self.eventDispatcher.all([&peer, oldKeys, newKeys](PlayerEventHandler* handler)
{ handler->onPlayerKeyStateChange(peer, newKeys, oldKeys); });
{
handler->onPlayerKeyStateChange(peer, newKeys, oldKeys);
});
}
player.setState(PlayerState_Passenger);

Expand Down

0 comments on commit 3fb39da

Please sign in to comment.