Skip to content

Commit

Permalink
Run clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
zach2good committed Nov 21, 2024
1 parent 00dce49 commit adc23a0
Show file tree
Hide file tree
Showing 190 changed files with 1,813 additions and 2,289 deletions.
2 changes: 1 addition & 1 deletion modules/renamer/cpp/renamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ extern std::function<void(map_session_data_t* const, CCharEntity* const, CBasicP

class RenamerModule : public CPPModule
{
void SendListPacket(CCharEntity* PChar, std::string const& data)
void SendListPacket(CCharEntity* PChar, const std::string& data)
{
if (data.empty())
{
Expand Down
2 changes: 1 addition & 1 deletion src/common/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <windows.h>
#endif

Application::Application(std::string const& serverName, int argc, char** argv)
Application::Application(const std::string& serverName, int argc, char** argv)
: m_ServerName(serverName)
, m_RequestExit(false)
, gArgParser(std::make_unique<argparse::ArgumentParser>(argv[0]))
Expand Down
2 changes: 1 addition & 1 deletion src/common/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
class Application
{
public:
Application(std::string const& serverName, int argc, char** argv);
Application(const std::string& serverName, int argc, char** argv);
virtual ~Application() = default;

Application(const Application&) = delete;
Expand Down
6 changes: 3 additions & 3 deletions src/common/async.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Async::Async()
{
}

void Async::query(std::string const& query)
void Async::query(const std::string& query)
{
// clang-format off
this->schedule([query]()
Expand All @@ -49,7 +49,7 @@ void Async::query(std::string const& query)
// : If you define your arg as _sql, but then call sql, it will use the global
// : SQLConnection, which is on the main thread.
// : Remember that SQLConnection is NOT THREAD-SAFE!
void Async::query(std::function<void(SqlConnection*)> const& func)
void Async::query(const std::function<void(SqlConnection*)>& func)
{
// clang-format off
this->schedule([func]()
Expand All @@ -65,7 +65,7 @@ void Async::query(std::function<void(SqlConnection*)> const& func)
// clang-format on
}

void Async::submit(std::function<void()> const& func)
void Async::submit(const std::function<void()>& func)
{
// clang-format off
this->schedule([func]()
Expand Down
6 changes: 3 additions & 3 deletions src/common/async.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
class Async : public Singleton<Async>, private ts::task_system
{
public:
void query(std::string const& query);
void query(std::function<void(SqlConnection*)> const& func);
void submit(std::function<void()> const& func);
void query(const std::string& query);
void query(const std::function<void(SqlConnection*)>& func);
void submit(const std::function<void()>& func);

protected:
Async();
Expand Down
4 changes: 2 additions & 2 deletions src/common/circular_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class CircularBuffer
public:
CircularBuffer(std::size_t max_size)
: buffer(std::unique_ptr<T[]>(new T[max_size]))
, max_size(max_size){};
, max_size(max_size) {};

void enqueue(T const& item)
void enqueue(const T& item)
{
std::lock_guard lock(mutex);

Expand Down
2 changes: 1 addition & 1 deletion src/common/console_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ ConsoleService::~ConsoleService()

// NOTE: If you capture things in this function, make sure they're protected (locked or atomic)!
// NOTE: If you're going to print, use fmt::print, rather than ShowInfo etc.
void ConsoleService::RegisterCommand(std::string const& name, std::string const& description, std::function<void(std::vector<std::string>&)> func)
void ConsoleService::RegisterCommand(const std::string& name, const std::string& description, std::function<void(std::vector<std::string>&)> func)
{
std::lock_guard<std::mutex> lock(m_consoleInputBottleneck);

Expand Down
2 changes: 1 addition & 1 deletion src/common/console_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ConsoleService

// NOTE: If you capture things in this function, make sure they're protected (locked or atomic)!
// NOTE: If you're going to print, use fmt::print, rather than ShowInfo etc.
void RegisterCommand(std::string const& name, std::string const& description, std::function<void(std::vector<std::string>&)> func);
void RegisterCommand(const std::string& name, const std::string& description, std::function<void(std::vector<std::string>&)> func);

// Call this to stop processing commands
void stop();
Expand Down
2 changes: 1 addition & 1 deletion src/common/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ mutex_guarded<db::detail::State>& db::detail::getState()
return state;
}

std::unique_ptr<sql::ResultSet> db::query(std::string const& rawQuery)
std::unique_ptr<sql::ResultSet> db::query(const std::string& rawQuery)
{
TracyZoneScoped;
TracyZoneString(rawQuery);
Expand Down
10 changes: 5 additions & 5 deletions src/common/database.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace db

auto getState() -> mutex_guarded<db::detail::State>&;

auto sanitise(std::string const& query) -> std::string;
auto sanitise(const std::string& query) -> std::string;

// Helpers to provide information to the static_assert below
template <class>
Expand Down Expand Up @@ -156,7 +156,7 @@ namespace db
// @param query The query string to execute.
// @return A unique pointer to the result set of the query.
// @note Everything in database-land is 1-indexed, not 0-indexed.
auto query(std::string const& rawQuery) -> std::unique_ptr<sql::ResultSet>;
auto query(const std::string& rawQuery) -> std::unique_ptr<sql::ResultSet>;

// @brief Execute a prepared statement with the given query string and arguments.
// @param query The query string to execute.
Expand All @@ -165,7 +165,7 @@ namespace db
// @note If the query hasn't been seen before it will generate a prepared statement for it to be used immediately and in the future.
// @note Everything in database-land is 1-indexed, not 0-indexed.
template <typename... Args>
std::unique_ptr<sql::ResultSet> preparedStmt(std::string const& rawQuery, Args&&... args)
std::unique_ptr<sql::ResultSet> preparedStmt(const std::string& rawQuery, Args&&... args)
{
TracyZoneScoped;
TracyZoneString(rawQuery);
Expand Down Expand Up @@ -222,7 +222,7 @@ namespace db
// @note This is a workaround for the fact that MariaDB's C++ connector hasn't yet implemented ResultSet::rowUpdated(), ResultSet::rowInserted(),
// and ResultSet::rowDeleted().
template <typename... Args>
std::pair<std::unique_ptr<sql::ResultSet>, std::size_t> preparedStmtWithAffectedRows(std::string const& rawQuery, Args&&... args)
std::pair<std::unique_ptr<sql::ResultSet>, std::size_t> preparedStmtWithAffectedRows(const std::string& rawQuery, Args&&... args)
{
TracyZoneScoped;
TracyZoneString(rawQuery);
Expand Down Expand Up @@ -360,7 +360,7 @@ namespace db
// @param blobKey The key of the blob in the result set.
// @param destination The struct to extract the blob into.
template <typename T>
void extractFromBlob(std::unique_ptr<sql::ResultSet>& rset, std::string const& blobKey, T& destination)
void extractFromBlob(std::unique_ptr<sql::ResultSet>& rset, const std::string& blobKey, T& destination)
{
static_assert(std::is_trivially_copyable_v<T>, "T must be trivially copyable");

Expand Down
4 changes: 1 addition & 3 deletions src/common/debug_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ void dumpBacktrace(int signal)

void debug::init()
{
struct rlimit core_limits
{
};
struct rlimit core_limits{};
core_limits.rlim_cur = core_limits.rlim_max = RLIM_INFINITY;
setrlimit(RLIMIT_CORE, &core_limits);

Expand Down
6 changes: 3 additions & 3 deletions src/common/filewatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <set>
#include <string>

Filewatcher::Filewatcher(std::vector<std::string> const& paths)
Filewatcher::Filewatcher(const std::vector<std::string>& paths)
#ifdef USE_GENERIC_FILEWATCHER
: fileWatcherImpl(std::make_unique<efsw::FileWatcher>(true))
#else
Expand All @@ -53,7 +53,7 @@ Filewatcher::~Filewatcher()
}

// cppcheck-suppress passedByValue
void Filewatcher::handleFileAction(efsw::WatchID watchid, std::string const& dir, std::string const& filename, efsw::Action action, std::string oldFilename)
void Filewatcher::handleFileAction(efsw::WatchID watchid, const std::string& dir, const std::string& filename, efsw::Action action, std::string oldFilename)
{
TracySetThreadName("Filewatcher Thread");
TracyZoneScoped;
Expand Down Expand Up @@ -97,7 +97,7 @@ auto Filewatcher::getChangedLuaFiles() -> std::vector<std::pair<std::filesystem:
std::vector<std::pair<std::filesystem::path, Action>> results;
results.reserve(actions.size());

for (auto const& [path, action] : actions)
for (const auto& [path, action] : actions)
{
results.emplace_back(path, action);
}
Expand Down
4 changes: 2 additions & 2 deletions src/common/filewatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
class Filewatcher : public efsw::FileWatchListener
{
public:
Filewatcher(std::vector<std::string> const& paths);
Filewatcher(const std::vector<std::string>& paths);
~Filewatcher() override;

DISALLOW_COPY_AND_MOVE(Filewatcher);

// efsw::FileWatchListener
void handleFileAction(efsw::WatchID watchid, std::string const& dir, std::string const& filename, efsw::Action action, std::string oldFilename) override;
void handleFileAction(efsw::WatchID watchid, const std::string& dir, const std::string& filename, efsw::Action action, std::string oldFilename) override;

enum class Action
{
Expand Down
6 changes: 3 additions & 3 deletions src/common/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ namespace logging
"trace",
};

void InitializeLog(std::string const& serverName, std::string const& logFile, bool appendDate)
void InitializeLog(const std::string& serverName, const std::string& logFile, bool appendDate)
{
ServerName = serverName;

Expand Down Expand Up @@ -168,7 +168,7 @@ namespace logging
spdlog::shutdown();
}

void SetPattern(std::string const& str)
void SetPattern(const std::string& str)
{
// https://github.com/gabime/spdlog/wiki/3.-Custom-formatting
auto formatter = std::make_unique<spdlog::pattern_formatter>();
Expand All @@ -180,7 +180,7 @@ namespace logging
spdlog::set_formatter(std::move(formatter));
}

void AddBacktrace(std::string const& str)
void AddBacktrace(const std::string& str)
{
BacktraceBuffer.enqueue(str);
}
Expand Down
6 changes: 3 additions & 3 deletions src/common/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ namespace settings

namespace logging
{
void InitializeLog(std::string const& serverName, std::string const& logFile, bool appendDate);
void InitializeLog(const std::string& serverName, const std::string& logFile, bool appendDate);
void ShutDown();

void SetPattern(std::string const& str);
void SetPattern(const std::string& str);

void AddBacktrace(std::string const& str);
void AddBacktrace(const std::string& str);
auto GetBacktrace() -> std::vector<std::string>;
} // namespace logging

Expand Down
6 changes: 3 additions & 3 deletions src/common/lua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void lua_init()
/**
* @brief
*/
std::string lua_to_string_depth(sol::object const& obj, std::size_t depth)
std::string lua_to_string_depth(const sol::object& obj, std::size_t depth)
{
switch (obj.get_type())
{
Expand Down Expand Up @@ -135,7 +135,7 @@ std::string lua_to_string_depth(sol::object const& obj, std::size_t depth)

// Stringify everything first
std::vector<std::string> stringVec;
for (auto const& [keyObj, valObj] : table)
for (const auto& [keyObj, valObj] : table)
{
if (keyObj.get_type() == sol::type::string)
{
Expand Down Expand Up @@ -206,7 +206,7 @@ void lua_print(sol::variadic_args va)
std::string lua_fmt(std::string fmtStr, sol::variadic_args va)
{
fmt::dynamic_format_arg_store<fmt::format_context> store;
for (auto const& arg : va)
for (const auto& arg : va)
{
switch (arg.get_type())
{
Expand Down
2 changes: 1 addition & 1 deletion src/common/lua.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
extern sol::state lua;

void lua_init();
auto lua_to_string_depth(sol::object const& obj, std::size_t depth) -> std::string;
auto lua_to_string_depth(const sol::object& obj, std::size_t depth) -> std::string;
auto lua_to_string(sol::variadic_args va) -> std::string;
void lua_print(sol::variadic_args va);
auto lua_fmt(std::string fmtStr, sol::variadic_args va) -> std::string;
Expand Down
Loading

0 comments on commit adc23a0

Please sign in to comment.