Skip to content

Commit

Permalink
fix: clang format (opentibiabr#2710)
Browse files Browse the repository at this point in the history
  • Loading branch information
beats-dh authored Jun 24, 2024
1 parent bfb3149 commit 0fdd8b0
Show file tree
Hide file tree
Showing 76 changed files with 688 additions and 688 deletions.
4 changes: 2 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ QualifierAlignment: Left
ReferenceAlignment: Right
ReflowComments: true
RemoveBracesLLVM: false
SortIncludes: false
SortIncludes: Never
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
Expand All @@ -138,4 +138,4 @@ StatementMacros:
- QT_REQUIRE_VERSION
TabWidth: 4
UseCRLF: false
UseTab: true
UseTab: AlignWithSpaces
6 changes: 3 additions & 3 deletions .github/workflows/clang-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ jobs:

- name: Run clang format lint
if: ${{ github.ref != 'refs/heads/main' }}
uses: DoozyX/clang-format-lint-action@v0.16.2
uses: DoozyX/clang-format-lint-action@v0.17
with:
source: "src"
exclude: "src/protobuf"
extensions: "cpp,hpp,h"
clangFormatVersion: 16
clangFormatVersion: 17
inplace: true

- name: Run add and commit
if: ${{ github.ref != 'refs/heads/main' }}
uses: EndBug/add-and-commit@v9
uses: EndBug/add-and-commit@v9.1.4
with:
author_name: GitHub Actions
author_email: github-actions[bot]@users.noreply.github.com
Expand Down
10 changes: 5 additions & 5 deletions src/canary_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ int CanaryServer::run() {
#ifndef _WIN32
if (getuid() == 0 || geteuid() == 0) {
logger.warn("{} has been executed as root user, "
"please consider running it as a normal user",
ProtocolStatus::SERVER_NAME);
"please consider running it as a normal user",
ProtocolStatus::SERVER_NAME);
}
#endif

Expand Down Expand Up @@ -213,7 +213,7 @@ void CanaryServer::logInfos() {

logger.info("A server developed by: {}", ProtocolStatus::SERVER_DEVELOPERS);
logger.info("Visit our website for updates, support, and resources: "
"https://docs.opentibiabr.com/");
"https://docs.opentibiabr.com/");
}

/**
Expand All @@ -234,7 +234,7 @@ void CanaryServer::toggleForceCloseButton() {
void CanaryServer::badAllocationHandler() {
// Use functions that only use stack allocation
g_logger().error("Allocation failed, server out of memory, "
"decrease the size of your map or compile in 64 bits mode");
"decrease the size of your map or compile in 64 bits mode");

if (isatty(STDIN_FILENO)) {
getchar();
Expand Down Expand Up @@ -318,7 +318,7 @@ void CanaryServer::initializeDatabase() {
DatabaseManager::updateDatabase();

if (g_configManager().getBoolean(OPTIMIZE_DATABASE, __FUNCTION__)
&& !DatabaseManager::optimizeTables()) {
&& !DatabaseManager::optimizeTables()) {
logger.debug("No tables were optimized");
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/creatures/appearance/outfit/outfit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ bool Outfits::loadFromXml() {
}

if (auto lookType = pugi::cast<uint16_t>(lookTypeAttribute.value());
g_configManager().getBoolean(WARN_UNSAFE_SCRIPTS, __FUNCTION__) && lookType != 0
&& !g_game().isLookTypeRegistered(lookType)) {
g_configManager().getBoolean(WARN_UNSAFE_SCRIPTS, __FUNCTION__) && lookType != 0
&& !g_game().isLookTypeRegistered(lookType)) {
g_logger().warn("[Outfits::loadFromXml] An unregistered creature looktype type with id '{}' was ignored to prevent client crash.", lookType);
continue;
}
Expand Down
40 changes: 20 additions & 20 deletions src/creatures/combat/combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,8 @@ CombatDamage Combat::applyImbuementElementalDamage(std::shared_ptr<Player> attac
}

if (imbuementInfo.imbuement->combatType == COMBAT_NONE
|| damage.primary.type == COMBAT_HEALING
|| damage.secondary.type == COMBAT_HEALING) {
|| damage.primary.type == COMBAT_HEALING
|| damage.secondary.type == COMBAT_HEALING) {
continue;
}

Expand Down Expand Up @@ -1256,8 +1256,8 @@ void Combat::doCombatHealth(std::shared_ptr<Creature> caster, std::shared_ptr<Cr
void Combat::doCombatHealth(std::shared_ptr<Creature> caster, std::shared_ptr<Creature> target, const Position &origin, CombatDamage &damage, const CombatParams &params) {
bool canCombat = !params.aggressive || (caster != target && Combat::canDoCombat(caster, target, params.aggressive) == RETURNVALUE_NOERROR);
if ((caster && target)
&& (caster == target || canCombat)
&& (params.impactEffect != CONST_ME_NONE)) {
&& (caster == target || canCombat)
&& (params.impactEffect != CONST_ME_NONE)) {
g_game().addMagicEffect(target->getPosition(), params.impactEffect);
}

Expand Down Expand Up @@ -1300,8 +1300,8 @@ void Combat::doCombatMana(std::shared_ptr<Creature> caster, std::shared_ptr<Crea
void Combat::doCombatMana(std::shared_ptr<Creature> caster, std::shared_ptr<Creature> target, const Position &origin, CombatDamage &damage, const CombatParams &params) {
bool canCombat = !params.aggressive || (caster != target && Combat::canDoCombat(caster, target, params.aggressive) == RETURNVALUE_NOERROR);
if ((caster && target)
&& (caster == target || canCombat)
&& (params.impactEffect != CONST_ME_NONE)) {
&& (caster == target || canCombat)
&& (params.impactEffect != CONST_ME_NONE)) {
g_game().addMagicEffect(target->getPosition(), params.impactEffect);
}

Expand Down Expand Up @@ -1368,8 +1368,8 @@ void Combat::doCombatDispel(std::shared_ptr<Creature> caster, const Position &po
void Combat::doCombatDispel(std::shared_ptr<Creature> caster, std::shared_ptr<Creature> target, const CombatParams &params) {
bool canCombat = !params.aggressive || (caster != target && Combat::canDoCombat(caster, target, params.aggressive) == RETURNVALUE_NOERROR);
if ((caster && target)
&& (caster == target || canCombat)
&& (params.impactEffect != CONST_ME_NONE)) {
&& (caster == target || canCombat)
&& (params.impactEffect != CONST_ME_NONE)) {
g_game().addMagicEffect(target->getPosition(), params.impactEffect);
}

Expand Down Expand Up @@ -1408,7 +1408,7 @@ void Combat::doCombatDefault(std::shared_ptr<Creature> caster, std::shared_ptr<C

/*
if (params.impactEffect != CONST_ME_NONE) {
g_game().addMagicEffect(target->getPosition(), params.impactEffect);
g_game().addMagicEffect(target->getPosition(), params.impactEffect);
}
*/

Expand Down Expand Up @@ -1540,8 +1540,8 @@ void ValueCallback::getMinMaxValues(std::shared_ptr<Player> player, CombatDamage
// onGetPlayerMinMaxValues(...)
if (!scriptInterface->reserveScriptEnv()) {
g_logger().error("[ValueCallback::getMinMaxValues - Player {} formula {}] "
"Call stack overflow. Too many lua script calls being nested.",
player->getName(), fmt::underlying(type));
"Call stack overflow. Too many lua script calls being nested.",
player->getName(), fmt::underlying(type));
return;
}

Expand Down Expand Up @@ -1633,8 +1633,8 @@ void TileCallback::onTileCombat(std::shared_ptr<Creature> creature, std::shared_
// onTileCombat(creature, pos)
if (!scriptInterface->reserveScriptEnv()) {
g_logger().error("[TileCallback::onTileCombat - Creature {} type {} on tile x: {} y: {} z: {}] "
"Call stack overflow. Too many lua script calls being nested.",
creature->getName(), fmt::underlying(type), (tile->getPosition()).getX(), (tile->getPosition()).getY(), (tile->getPosition()).getZ());
"Call stack overflow. Too many lua script calls being nested.",
creature->getName(), fmt::underlying(type), (tile->getPosition()).getX(), (tile->getPosition()).getY(), (tile->getPosition()).getZ());
return;
}

Expand Down Expand Up @@ -1664,8 +1664,8 @@ void TargetCallback::onTargetCombat(std::shared_ptr<Creature> creature, std::sha
// onTargetCombat(creature, target)
if (!scriptInterface->reserveScriptEnv()) {
g_logger().error("[TargetCallback::onTargetCombat - Creature {}] "
"Call stack overflow. Too many lua script calls being nested.",
creature->getName());
"Call stack overflow. Too many lua script calls being nested.",
creature->getName());
return;
}

Expand Down Expand Up @@ -1724,8 +1724,8 @@ void ChainCallback::onChainCombat(std::shared_ptr<Creature> creature, uint8_t &m
// onChainCombat(creature)
if (!scriptInterface->reserveScriptEnv()) {
g_logger().error("[ChainCallback::onTargetCombat - Creature {}] "
"Call stack overflow. Too many lua script calls being nested.",
creature->getName());
"Call stack overflow. Too many lua script calls being nested.",
creature->getName());
return;
}

Expand Down Expand Up @@ -1766,8 +1766,8 @@ bool ChainPickerCallback::onChainCombat(std::shared_ptr<Creature> creature, std:
// onChainCombat(creature, target)
if (!scriptInterface->reserveScriptEnv()) {
g_logger().error("[ChainPickerCallback::onTargetCombat - Creature {}] "
"Call stack overflow. Too many lua script calls being nested.",
creature->getName());
"Call stack overflow. Too many lua script calls being nested.",
creature->getName());
return true;
}

Expand Down Expand Up @@ -2178,7 +2178,7 @@ void Combat::applyExtensions(std::shared_ptr<Creature> caster, std::shared_ptr<C
if (player) {
// Fatal hit (onslaught)
if (auto playerWeapon = player->getInventoryItem(CONST_SLOT_LEFT);
playerWeapon != nullptr && playerWeapon->getTier() > 0) {
playerWeapon != nullptr && playerWeapon->getTier() > 0) {
double_t fatalChance = playerWeapon->getFatalChance();
double_t randomChance = uniform_random(0, 10000) / 100;
if (fatalChance > 0 && randomChance < fatalChance) {
Expand Down
2 changes: 1 addition & 1 deletion src/creatures/combat/condition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2042,7 +2042,7 @@ bool ConditionFeared::executeCondition(std::shared_ptr<Creature> creature, int32
g_dispatcher().addEvent([id = creature->getID(), listDir = listDir.data()] {
g_game().forcePlayerAutoWalk(id, listDir);
},
"ConditionFeared::executeCondition");
"ConditionFeared::executeCondition");

g_logger().debug("[ConditionFeared::executeCondition] Walking Scheduled");
}
Expand Down
20 changes: 10 additions & 10 deletions src/creatures/combat/spells.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void Spells::clear() {

bool Spells::hasInstantSpell(const std::string &word) const {
if (auto iterate = instants.find(word);
iterate != instants.end()) {
iterate != instants.end()) {
return true;
}
return false;
Expand All @@ -127,8 +127,8 @@ bool Spells::registerInstantLuaEvent(const std::shared_ptr<InstantSpell> instant
// Checks if there is any spell registered with the same name
if (hasInstantSpell(words)) {
g_logger().warn("[Spells::registerInstantLuaEvent] - "
"Duplicate registered instant spell with words: {}, on spell with name: {}",
words, instantName);
"Duplicate registered instant spell with words: {}, on spell with name: {}",
words, instantName);
return false;
}
// Register spell word in the map
Expand Down Expand Up @@ -166,7 +166,7 @@ std::list<uint16_t> Spells::getSpellsByVocation(uint16_t vocationId) {
vocSpellsIt = vocSpells.find(vocationId);

if (vocSpellsIt != vocSpells.end()
&& vocSpellsIt->second) {
&& vocSpellsIt->second) {
spellsList.push_back(it.second->getSpellId());
}
}
Expand Down Expand Up @@ -361,8 +361,8 @@ bool CombatSpell::executeCastSpell(std::shared_ptr<Creature> creature, const Lua
// onCastSpell(creature, var)
if (!getScriptInterface()->reserveScriptEnv()) {
g_logger().error("[CombatSpell::executeCastSpell - Creature {}] "
"Call stack overflow. Too many lua script calls being nested.",
creature->getName());
"Call stack overflow. Too many lua script calls being nested.",
creature->getName());
return false;
}

Expand Down Expand Up @@ -950,8 +950,8 @@ bool InstantSpell::executeCastSpell(std::shared_ptr<Creature> creature, const Lu
// onCastSpell(creature, var)
if (!getScriptInterface()->reserveScriptEnv()) {
g_logger().error("[InstantSpell::executeCastSpell - Creature {} words {}] "
"Call stack overflow. Too many lua script calls being nested.",
creature->getName(), getWords());
"Call stack overflow. Too many lua script calls being nested.",
creature->getName(), getWords());
return false;
}

Expand Down Expand Up @@ -1095,8 +1095,8 @@ bool RuneSpell::executeCastSpell(std::shared_ptr<Creature> creature, const LuaVa
// onCastSpell(creature, var, isHotkey)
if (!getScriptInterface()->reserveScriptEnv()) {
g_logger().error("[RuneSpell::executeCastSpell - Creature {} runeId {}] "
"Call stack overflow. Too many lua script calls being nested.",
creature->getName(), getRuneItemId());
"Call stack overflow. Too many lua script calls being nested.",
creature->getName(), getRuneItemId());
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/creatures/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ bool Creature::dropCorpse(std::shared_ptr<Creature> lastHitCreature, std::shared
g_dispatcher().addEvent([player, corpseContainer, corpsePosition = corpse->getPosition()] {
g_game().playerQuickLootCorpse(player, corpseContainer, corpsePosition);
},
"Game::playerQuickLootCorpse");
"Game::playerQuickLootCorpse");
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/creatures/creatures_definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1524,12 +1524,12 @@ using StashItemList = std::map<uint16_t, uint32_t>;

using ItemsTierCountList = std::map<uint16_t, std::map<uint8_t, uint32_t>>;
/*
> ItemsTierCountList structure:
|- [itemID]
|- [itemTier]
|- Count
| ...
| ...
> ItemsTierCountList structure:
|- [itemID]
|- [itemTier]
|- Count
| ...
| ...
*/

struct ProtocolFamiliars {
Expand Down
16 changes: 8 additions & 8 deletions src/creatures/interactions/chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ bool ChatChannel::executeCanJoinEvent(const std::shared_ptr<Player> &player) {
LuaScriptInterface* scriptInterface = g_chat().getScriptInterface();
if (!scriptInterface->reserveScriptEnv()) {
g_logger().error("[CanJoinChannelEvent::execute - Player {}, on channel {}] "
"Call stack overflow. Too many lua script calls being nested.",
player->getName(), getName());
"Call stack overflow. Too many lua script calls being nested.",
player->getName(), getName());
return false;
}

Expand All @@ -171,8 +171,8 @@ bool ChatChannel::executeOnJoinEvent(const std::shared_ptr<Player> &player) {
LuaScriptInterface* scriptInterface = g_chat().getScriptInterface();
if (!scriptInterface->reserveScriptEnv()) {
g_logger().error("[OnJoinChannelEvent::execute - Player {}, on channel {}] "
"Call stack overflow. Too many lua script calls being nested",
player->getName(), getName());
"Call stack overflow. Too many lua script calls being nested",
player->getName(), getName());
return false;
}

Expand All @@ -197,8 +197,8 @@ bool ChatChannel::executeOnLeaveEvent(const std::shared_ptr<Player> &player) {
LuaScriptInterface* scriptInterface = g_chat().getScriptInterface();
if (!scriptInterface->reserveScriptEnv()) {
g_logger().error("[OnLeaveChannelEvent::execute - Player {}, on channel {}] "
"Call stack overflow. Too many lua script calls being nested.",
player->getName(), getName());
"Call stack overflow. Too many lua script calls being nested.",
player->getName(), getName());
return false;
}

Expand All @@ -223,8 +223,8 @@ bool ChatChannel::executeOnSpeakEvent(const std::shared_ptr<Player> &player, Spe
LuaScriptInterface* scriptInterface = g_chat().getScriptInterface();
if (!scriptInterface->reserveScriptEnv()) {
g_logger().error("[OnSpeakChannelEvent::execute - Player {}, type {}] "
"Call stack overflow. Too many lua script calls being nested.",
player->getName(), fmt::underlying(type));
"Call stack overflow. Too many lua script calls being nested.",
player->getName(), fmt::underlying(type));
return false;
}

Expand Down
Loading

0 comments on commit 0fdd8b0

Please sign in to comment.