mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-31 18:31:04 +00:00
Code style fixes.
This commit is contained in:
parent
24e9db07ec
commit
af3f696423
43 changed files with 493 additions and 484 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue