Skip to content

Commit

Permalink
Code format - (Clang-format)
Browse files Browse the repository at this point in the history
  • Loading branch information
beats-dh authored and dudantas committed Aug 22, 2023
1 parent d9eaf2c commit 71d633d
Show file tree
Hide file tree
Showing 184 changed files with 18,413 additions and 18,518 deletions.
22 changes: 12 additions & 10 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,18 @@ IncludeCategories:
SortPriority: 0
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentAccessModifiers: true
IndentCaseLabels: true
IndentGotoLabels: true
IndentPPDirectives: BeforeHash
IndentWidth: 4
IndentWrappedFunctionNames: false
#InsertNewlineAtEOF: true
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
LambdaBodyIndentation: Signature
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
NamespaceIndentation: Inner
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 4
ObjCSpaceAfterProperty: true
Expand All @@ -106,10 +103,7 @@ PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
QualifierAlignment: Left
ReferenceAlignment: Right
ReflowComments: true
RemoveBracesLLVM: false
SortIncludes: false
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
Expand All @@ -135,6 +129,14 @@ Standard: Latest
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 4
UseCRLF: false
UseTab: true
TabWidth: 4
UseCRLF: false
UseTab: true
IndentAccessModifiers: false
RemoveBracesLLVM: false
#InsertNewlineAtEOF: true
LambdaBodyIndentation: Signature
NamespaceIndentation: All
QualifierAlignment: Left
ReferenceAlignment: Right
MaxEmptyLinesToKeep: 1
82 changes: 41 additions & 41 deletions src/canary_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,67 +16,67 @@
class Logger;

class FailedToInitializeCanary : public std::exception {
private:
std::string message;

public:
// Constructor accepts a specific message
explicit FailedToInitializeCanary(const std::string &msg) :
message("Canary load couldn't be completed. " + msg) { }

// Override the what() method from std::exception
const char* what() const noexcept override {
return message.c_str();
}
private:
std::string message;

public:
// Constructor accepts a specific message
explicit FailedToInitializeCanary(const std::string &msg) :
message("Canary load couldn't be completed. " + msg) { }

// Override the what() method from std::exception
const char* what() const noexcept override {
return message.c_str();
}
};

class CanaryServer {
public:
explicit CanaryServer(
Logger &logger,
RSA &rsa,
ServiceManager &serviceManager
);
public:
explicit CanaryServer(
Logger &logger,
RSA &rsa,
ServiceManager &serviceManager
);

int run();
int run();

private:
RSA &rsa;
Logger &logger;
ServiceManager &serviceManager;
private:
RSA &rsa;
Logger &logger;
ServiceManager &serviceManager;

std::mutex loaderLock;
std::condition_variable loaderSignal;
std::unique_lock<std::mutex> loaderUniqueLock;
std::mutex loaderLock;
std::condition_variable loaderSignal;
std::unique_lock<std::mutex> loaderUniqueLock;

bool loaderDone = false;
bool loadFailed = false;
bool loaderDone = false;
bool loadFailed = false;

void logInfos();
void logInfos();

static void toggleForceCloseButton();
static void toggleForceCloseButton();

static void badAllocationHandler();
static void badAllocationHandler();

static void shutdown();
static void shutdown();

static std::string getCompiler();
static std::string getCompiler();

static std::string getPlatform();
static std::string getPlatform();

void loadConfigLua();
void loadConfigLua();

void initializeDatabase();
void initializeDatabase();

void loadModules();
void loadModules();

void setWorldType();
void setWorldType();

void loadMaps();
void loadMaps();

void setupHousesRent();
void setupHousesRent();

void modulesLoadHelper(bool loaded, std::string moduleName);
void modulesLoadHelper(bool loaded, std::string moduleName);
};

#endif // SRC_CANARY_SERVER_HPP_
79 changes: 41 additions & 38 deletions src/config/configmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,48 @@
#include "declarations.hpp"

class ConfigManager {
public:
ConfigManager() = default;

// Singleton - ensures we don't accidentally copy it
ConfigManager(const ConfigManager &) = delete;
void operator=(const ConfigManager &) = delete;

static ConfigManager &getInstance() {
return inject<ConfigManager>();
}

bool load();
bool reload();

const std::string &getString(stringConfig_t what) const;
int32_t getNumber(integerConfig_t what) const;
int16_t getShortNumber(integerConfig_t what) const;
bool getBoolean(booleanConfig_t what) const;
float getFloat(floatingConfig_t what) const;

const std::string &setConfigFileLua(const std::string &what) {
configFileLua = { what };
return configFileLua;
};
const std::string &getConfigFileLua() const {
return configFileLua;
};

private:
std::string configFileLua = { "config.lua" };

std::string string[LAST_STRING_CONFIG] = {};
int32_t integer[LAST_INTEGER_CONFIG] = {};
bool boolean[LAST_BOOLEAN_CONFIG] = {};
float floating[LAST_FLOATING_CONFIG] = {};

bool loaded = false;
public:
ConfigManager() = default;

// Singleton - ensures we don't accidentally copy it
ConfigManager(const ConfigManager &) = delete;
void operator=(const ConfigManager &) = delete;

static ConfigManager &getInstance() {
// Guaranteed to be destroyed
static ConfigManager instance;
// Instantiated on first use
return instance;
}

bool load();
bool reload();

const std::string &getString(stringConfig_t what) const;
int32_t getNumber(integerConfig_t what) const;
int16_t getShortNumber(integerConfig_t what) const;
bool getBoolean(booleanConfig_t what) const;
float getFloat(floatingConfig_t what) const;

const std::string &setConfigFileLua(const std::string &what) {
configFileLua = { what };
return configFileLua;
};
const std::string &getConfigFileLua() const {
return configFileLua;
};

private:
std::string configFileLua = { "config.lua" };

std::string string[LAST_STRING_CONFIG] = {};
int32_t integer[LAST_INTEGER_CONFIG] = {};
bool boolean[LAST_BOOLEAN_CONFIG] = {};
float floating[LAST_FLOATING_CONFIG] = {};

bool loaded = false;
};

constexpr auto g_configManager = ConfigManager::getInstance;
constexpr auto g_configManager = &ConfigManager::getInstance;

#endif // SRC_CONFIG_CONFIGMANAGER_H_
40 changes: 20 additions & 20 deletions src/creatures/appearance/mounts/mounts.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,32 @@
#define SRC_CREATURES_APPEARANCE_MOUNTS_MOUNTS_H_

struct Mount {
Mount(uint8_t initId, uint16_t initClientId, std::string initName, int32_t initSpeed, bool initPremium, std::string initType) :
name(initName), speed(initSpeed), clientId(initClientId), id(initId), premium(initPremium),
type(initType) { }
Mount(uint8_t initId, uint16_t initClientId, std::string initName, int32_t initSpeed, bool initPremium, std::string initType) :
name(initName), speed(initSpeed), clientId(initClientId), id(initId), premium(initPremium),
type(initType) { }

std::string name;
int32_t speed;
uint16_t clientId;
uint8_t id;
bool premium;
std::string type;
std::string name;
int32_t speed;
uint16_t clientId;
uint8_t id;
bool premium;
std::string type;
};

class Mounts {
public:
bool reload();
bool loadFromXml();
std::shared_ptr<Mount> getMountByID(uint8_t id);
std::shared_ptr<Mount> getMountByName(const std::string &name);
std::shared_ptr<Mount> getMountByClientID(uint16_t clientId);
public:
bool reload();
bool loadFromXml();
Mount* getMountByID(uint8_t id);
Mount* getMountByName(const std::string &name);
Mount* getMountByClientID(uint16_t clientId);

[[nodiscard]] const std::vector<std::shared_ptr<Mount>> &getMounts() const {
return mounts;
}
const std::vector<Mount> &getMounts() const {
return mounts;
}

private:
std::vector<std::shared_ptr<Mount>> mounts;
private:
std::vector<Mount> mounts;
};

#endif // SRC_CREATURES_APPEARANCE_MOUNTS_MOUNTS_H_
51 changes: 26 additions & 25 deletions src/creatures/appearance/outfit/outfit.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,43 @@
#include "declarations.hpp"

struct Outfit {
Outfit(std::string initName, uint16_t initLookType, bool initPremium, bool initUnlocked, std::string initFrom) :
name(initName), lookType(initLookType), premium(initPremium), unlocked(initUnlocked), from(initFrom) { }

std::string name;
uint16_t lookType;
bool premium;
bool unlocked;
std::string from;
Outfit(std::string initName, uint16_t initLookType, bool initPremium, bool initUnlocked, std::string initFrom) :
name(initName), lookType(initLookType), premium(initPremium), unlocked(initUnlocked), from(initFrom) { }

std::string name;
uint16_t lookType;
bool premium;
bool unlocked;
std::string from;
};

struct ProtocolOutfit {
ProtocolOutfit(const std::string &initName, uint16_t initLookType, uint8_t initAddons) :
name(initName), lookType(initLookType), addons(initAddons) { }
ProtocolOutfit(const std::string &initName, uint16_t initLookType, uint8_t initAddons) :
name(initName), lookType(initLookType), addons(initAddons) { }

const std::string &name;
uint16_t lookType;
uint8_t addons;
const std::string &name;
uint16_t lookType;
uint8_t addons;
};

class Outfits {
public:
static Outfits &getInstance() {
return inject<Outfits>();
}
public:
static Outfits &getInstance() {
static Outfits instance;
return instance;
}

std::shared_ptr<Outfit> getOpositeSexOutfitByLookType(PlayerSex_t sex, uint16_t lookType);
const Outfit* getOpositeSexOutfitByLookType(PlayerSex_t sex, uint16_t lookType);

bool loadFromXml();
bool loadFromXml();

[[nodiscard]] std::shared_ptr<Outfit> getOutfitByLookType(PlayerSex_t sex, uint16_t lookType) const;
[[nodiscard]] const std::vector<std::shared_ptr<Outfit>> &getOutfits(PlayerSex_t sex) const {
return outfits[sex];
}
const Outfit* getOutfitByLookType(PlayerSex_t sex, uint16_t lookType) const;
const std::vector<Outfit> &getOutfits(PlayerSex_t sex) const {
return outfits[sex];
}

private:
std::vector<std::shared_ptr<Outfit>> outfits[PLAYERSEX_LAST + 1];
private:
std::vector<Outfit> outfits[PLAYERSEX_LAST + 1];
};

#endif // SRC_CREATURES_APPEARANCE_OUTFIT_OUTFIT_H_
Loading

0 comments on commit 71d633d

Please sign in to comment.