mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-06 17:41:04 +00:00
Code style fixes.
This commit is contained in:
parent
24e9db07ec
commit
af3f696423
43 changed files with 493 additions and 484 deletions
|
@ -405,9 +405,9 @@ inline void paging(u32 length, u32 page, u32 pagecount, u32 &minindex, u32 &maxi
|
|||
|
||||
inline float cycle_shift(float value, float by = 0, float max = 1)
|
||||
{
|
||||
if (value + by < 0) return value + by + max;
|
||||
if (value + by > max) return value + by - max;
|
||||
return value + by;
|
||||
if (value + by < 0) return value + by + max;
|
||||
if (value + by > max) return value + by - max;
|
||||
return value + by;
|
||||
}
|
||||
|
||||
inline bool is_power_of_two(u32 n)
|
||||
|
|
|
@ -1070,39 +1070,39 @@ void safe_print_string(std::ostream &os, std::string_view str)
|
|||
|
||||
std::optional<v3f> str_to_v3f(std::string_view str)
|
||||
{
|
||||
str = trim(str);
|
||||
str = trim(str);
|
||||
|
||||
if (str.empty())
|
||||
return std::nullopt;
|
||||
if (str.empty())
|
||||
return std::nullopt;
|
||||
|
||||
// Strip parentheses if they exist
|
||||
if (str.front() == '(' && str.back() == ')') {
|
||||
str.remove_prefix(1);
|
||||
str.remove_suffix(1);
|
||||
str = trim(str);
|
||||
}
|
||||
// Strip parentheses if they exist
|
||||
if (str.front() == '(' && str.back() == ')') {
|
||||
str.remove_prefix(1);
|
||||
str.remove_suffix(1);
|
||||
str = trim(str);
|
||||
}
|
||||
|
||||
std::istringstream iss((std::string(str)));
|
||||
std::istringstream iss((std::string(str)));
|
||||
|
||||
const auto expect_delimiter = [&]() {
|
||||
const auto c = iss.get();
|
||||
return c == ' ' || c == ',';
|
||||
};
|
||||
const auto expect_delimiter = [&]() {
|
||||
const auto c = iss.get();
|
||||
return c == ' ' || c == ',';
|
||||
};
|
||||
|
||||
v3f value;
|
||||
if (!(iss >> value.X))
|
||||
return std::nullopt;
|
||||
if (!expect_delimiter())
|
||||
return std::nullopt;
|
||||
if (!(iss >> value.Y))
|
||||
return std::nullopt;
|
||||
if (!expect_delimiter())
|
||||
return std::nullopt;
|
||||
if (!(iss >> value.Z))
|
||||
return std::nullopt;
|
||||
v3f value;
|
||||
if (!(iss >> value.X))
|
||||
return std::nullopt;
|
||||
if (!expect_delimiter())
|
||||
return std::nullopt;
|
||||
if (!(iss >> value.Y))
|
||||
return std::nullopt;
|
||||
if (!expect_delimiter())
|
||||
return std::nullopt;
|
||||
if (!(iss >> value.Z))
|
||||
return std::nullopt;
|
||||
|
||||
if (!iss.eof())
|
||||
return std::nullopt;
|
||||
if (!iss.eof())
|
||||
return std::nullopt;
|
||||
|
||||
return value;
|
||||
return value;
|
||||
}
|
||||
|
|
|
@ -753,9 +753,9 @@ inline std::string stringw_to_utf8(const irr::core::stringw &input)
|
|||
return wide_to_utf8(sv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an irr::core:stringw from a UTF8 std::string.
|
||||
*/
|
||||
/**
|
||||
* Create an irr::core:stringw from a UTF8 std::string.
|
||||
*/
|
||||
inline irr::core::stringw utf8_to_stringw(std::string_view input)
|
||||
{
|
||||
std::wstring str = utf8_to_wide(input);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue