neteja cppcheck (105 → 0)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "game/gameplay/difficulty.hpp"
|
||||
|
||||
#include <vector> // Para vector
|
||||
#include <algorithm> // Para ranges::find_if
|
||||
#include <vector> // Para vector
|
||||
|
||||
namespace Difficulty {
|
||||
|
||||
@@ -18,19 +19,19 @@ namespace Difficulty {
|
||||
}
|
||||
|
||||
auto getNameFromCode(Code code) -> std::string {
|
||||
for (const auto& difficulty : difficulties_list) {
|
||||
if (difficulty.code == code) {
|
||||
return difficulty.name;
|
||||
}
|
||||
const auto it = std::ranges::find_if(difficulties_list,
|
||||
[code](const auto& difficulty) { return difficulty.code == code; });
|
||||
if (it != difficulties_list.end()) {
|
||||
return it->name;
|
||||
}
|
||||
return !difficulties_list.empty() ? difficulties_list.front().name : "Unknown";
|
||||
}
|
||||
|
||||
auto getCodeFromName(const std::string& name) -> Code {
|
||||
for (const auto& difficulty : difficulties_list) {
|
||||
if (difficulty.name == name) {
|
||||
return difficulty.code;
|
||||
}
|
||||
const auto it = std::ranges::find_if(difficulties_list,
|
||||
[&name](const auto& difficulty) { return difficulty.name == name; });
|
||||
if (it != difficulties_list.end()) {
|
||||
return it->code;
|
||||
}
|
||||
return !difficulties_list.empty() ? difficulties_list.front().code : Code::NORMAL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user