Skip to content

Commit

Permalink
fix: compilation and indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
dudantas committed Oct 15, 2024
1 parent 6172f7e commit be30946
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/database/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ std::string DBResult::getString(const std::string &columnName) const {
if (columnData.isNull()) {
g_logger().debug("[DBResult::getString] query: {}", m_query);
g_logger().debug("Column '{}' is null", columnName);
return nullptr;
return {};
}

g_logger().trace("[DBResult::getString] query: {}", m_query);
Expand Down
2 changes: 1 addition & 1 deletion src/io/functions/iologindata_load_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ void IOLoginDataLoad::loadPlayerBlessings(std::shared_ptr<Player> player, DBResu
return;
}

for (const auto& bless : magic_enum::enum_values<Blessings>()) {
for (const auto &bless : magic_enum::enum_values<Blessings>()) {
uint8_t blessId = static_cast<uint8_t>(bless);
std::string columName = fmt::format("blessings{}", blessId);
g_logger().trace("[{}] - Player {}, loading blessing: {}, id: {}", __FUNCTION__, player->getName(), columName, blessId);
Expand Down
2 changes: 1 addition & 1 deletion src/io/functions/iologindata_save_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ bool IOLoginDataSave::savePlayerFirst(std::shared_ptr<Player> player) {
}

// Blessings
for (const auto& bless : magic_enum::enum_values<Blessings>()) {
for (const auto &bless : magic_enum::enum_values<Blessings>()) {
uint8_t blessId = static_cast<uint8_t>(bless);
values.push_back(mysqlx::Value(player->getBlessingCount(blessId)));
}
Expand Down
11 changes: 6 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,27 @@

#include "canary_server.hpp"
#include "lib/di/container.hpp"
// Define um conceito para garantir que a função só aceite contêineres de números

// Defines a concept to ensure the function only accepts containers of numbers
template <typename T>
concept NumberContainer = requires(T a) {
typename T::value_type;
requires std::integral<typename T::value_type> || std::floating_point<typename T::value_type>;
};

// Função que calcula a média de um contêiner de números
// Function that calculates the average of a container of numbers
auto calculateAverage(const NumberContainer auto &container) {
// Utiliza ranges e std::views para processar o contêiner
// Uses ranges and std::views to process the container
return std::accumulate(container.begin(), container.end(), 0.0) / std::ranges::distance(container);
}

int main() {
std::vector<int> numbers = { 1, 2, 3, 4, 5 };

// Calcula a média usando a função com suporte a C++23
// Calculates the average using the function with support for C++23
double average = calculateAverage(numbers);

std::cout << "Average: " << average << std::endl;
g_logger().trace("Average: {}", average);

return inject<CanaryServer>().run();
}
2 changes: 1 addition & 1 deletion src/server/network/protocol/protocolgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4346,7 +4346,7 @@ void ProtocolGame::sendBlessStatus() {
uint8_t blessCount = 0;
uint16_t flag = 0;
uint16_t pow2 = 2;
for (const auto& bless : magic_enum::enum_values<Blessings>()) {
for (const auto &bless : magic_enum::enum_values<Blessings>()) {
uint8_t blessId = static_cast<uint8_t>(bless);
if (player->hasBlessing(blessId)) {
if (blessId > 1) {
Expand Down

0 comments on commit be30946

Please sign in to comment.