Skip to content

Commit

Permalink
clangformat
Browse files Browse the repository at this point in the history
  • Loading branch information
vittorioromeo committed May 13, 2024
1 parent 9f99501 commit 090defa
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 75 deletions.
3 changes: 2 additions & 1 deletion include/SSVOpenHexagon/Utils/Concat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ struct IsCharArray<const char (&)[N]> : std::true_type
template <typename... Ts>
inline constexpr bool AllConvertibleToStringView =
((std::is_convertible_v<Ts, std::string_view> || IsCharArray<Ts>::value ||
std::is_same_v<Ts, char>)&&...);
std::is_same_v<Ts, char>) &&
...);

template <std::size_t N>
[[nodiscard, gnu::always_inline]] constexpr inline std::size_t getSize(
Expand Down
3 changes: 1 addition & 2 deletions include/SSVOpenHexagon/Utils/Split.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ template <typename TSplitType = std::string_view>
std::vector<TSplitType> result;

withSplit<TSplitType>([&](TSplitType&& piece)
{ result.emplace_back(std::move(piece)); },
str, delims);
{ result.emplace_back(std::move(piece)); }, str, delims);

return result;
}
Expand Down
5 changes: 2 additions & 3 deletions src/SSVOpenHexagon/Components/CWall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ CWall::CWall(const unsigned int sides, const float wallAngleLeft,
const float angleN = angle - div;
const float angleP = angle + div;

const auto vecFromRad = [](const float rad, const float dist) {
return sf::Vector2f{dist * std::cos(rad), dist * std::sin(rad)};
};
const auto vecFromRad = [](const float rad, const float dist)
{ return sf::Vector2f{dist * std::cos(rad), dist * std::sin(rad)}; };

_vertexPositions[0] = centerPos + vecFromRad(angleN, distance);

Expand Down
14 changes: 5 additions & 9 deletions src/SSVOpenHexagon/Core/HGScripting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,7 @@ static void waitUntilSImpl(const double mDuration,

void HexagonGame::initLua_MainTimeline()
{
addLuaFn(lua, "t_eval",
[this](const std::string& mCode)
addLuaFn(lua, "t_eval", [this](const std::string& mCode)
{ timeline.append_do([=, this] { Utils::runLuaCode(lua, mCode); }); })
.arg("code")
.doc(
Expand All @@ -327,8 +326,7 @@ void HexagonGame::initLua_MainTimeline()
[this] { timeline.append_do([this] { death(true); }); })
.doc("*Add to the main timeline*: kill the player.");

addLuaFn(lua, "t_wait",
[this](double mDuration)
addLuaFn(lua, "t_wait", [this](double mDuration)
{ timeline.append_wait_for_sixths(mDuration); })
.arg("duration")
.doc(
Expand Down Expand Up @@ -386,8 +384,7 @@ void HexagonGame::initLua_EventTimeline()
"*Add to the event timeline*: pause the game timer for `$0` "
"seconds.");

addLuaFn(lua, "e_wait",
[this](double mDuration)
addLuaFn(lua, "e_wait", [this](double mDuration)
{ eventTimeline.append_wait_for_sixths(mDuration); })
.arg("duration")
.doc(
Expand Down Expand Up @@ -1105,9 +1102,8 @@ void HexagonGame::initLua()
{
LuaScripting::init(
lua, rng, false /* inMenu */, cwManager, levelStatus, status, styleData,
assets,
[this](const std::string& filename) -> void { runLuaFile(filename); },
execScriptPackPathContext,
assets, [this](const std::string& filename) -> void
{ runLuaFile(filename); }, execScriptPackPathContext,
[this]() -> const std::string& { return levelData->packPath; },
[this]() -> const PackData& { return getPackData(); },
(window == nullptr) /* headless */);
Expand Down
20 changes: 10 additions & 10 deletions src/SSVOpenHexagon/Core/HexagonClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ template <typename T>
.steamId = steamId, //
.name = name, //
.passwordHash = passwordHash //
} //
} //
);
}

Expand All @@ -278,7 +278,7 @@ template <typename T>
.steamId = steamId, //
.name = name, //
.passwordHash = passwordHash //
} //
} //
);
}

Expand All @@ -297,7 +297,7 @@ template <typename T>
CTSPDeleteAccount{
.steamId = steamId, //
.passwordHash = passwordHash //
} //
} //
);
}

Expand All @@ -310,7 +310,7 @@ template <typename T>
CTSPRequestTopScores{
.loginToken = loginToken, //
.levelValidator = levelValidator //
} //
} //
);
}

Expand All @@ -323,7 +323,7 @@ template <typename T>
CTSPRequestOwnScore{
.loginToken = loginToken, //
.levelValidator = levelValidator //
} //
} //
);
}

Expand All @@ -337,7 +337,7 @@ template <typename T>
CTSPRequestTopScoresAndOwnScore{
.loginToken = loginToken, //
.levelValidator = levelValidator //
} //
} //
);
}

Expand All @@ -350,7 +350,7 @@ template <typename T>
CTSPStartedGame{
.loginToken = loginToken, //
.levelValidator = levelValidator //
} //
} //
);
}

Expand All @@ -365,7 +365,7 @@ template <typename T>
CTSPCompressedReplay{
.loginToken = loginToken, //
.compressedReplayFile = compressedReplayFile //
} //
} //
);
}

Expand All @@ -377,7 +377,7 @@ template <typename T>
return sendEncrypted( //
CTSPRequestServerStatus{
.loginToken = loginToken, //
} //
} //
);
}

Expand All @@ -388,7 +388,7 @@ template <typename T>
return sendEncrypted( //
CTSPReady{
.loginToken = loginToken, //
} //
} //
);
}

Expand Down
12 changes: 6 additions & 6 deletions src/SSVOpenHexagon/Core/HexagonServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ template <typename T>
STCPLoginSuccess{
.loginToken = static_cast<std::uint64_t>(loginToken), //
.loginName = loginName //
} //
} //
);
}

Expand Down Expand Up @@ -221,7 +221,7 @@ template <typename T>
STCPTopScores{
.levelValidator = levelValidator, //
.scores = scores //
} //
} //
);
}

Expand All @@ -232,7 +232,7 @@ template <typename T>
STCPOwnScore{
.levelValidator = levelValidator, //
.score = score //
} //
} //
);
}

Expand All @@ -246,7 +246,7 @@ template <typename T>
.levelValidator = levelValidator, //
.scores = scores, //
.ownScore = ownScore //
} //
} //
);
}

Expand All @@ -259,7 +259,7 @@ template <typename T>
.protocolVersion = protocolVersion, //
.gameVersion = gameVersion, //
.supportedLevelValidators = supportedLevelValidators //
} //
} //
);
}

Expand Down Expand Up @@ -960,7 +960,7 @@ void HexagonServer::printCTSPDataVerbose(
.steamId = steamId,
.name = name,
.passwordHash = Utils::stringToCharVec(passwordHash) //
} //
} //
);

SSVOH_SLOG << "Successfully registered\n";
Expand Down
48 changes: 19 additions & 29 deletions src/SSVOpenHexagon/Core/LuaScripting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,8 @@ static void initCustomWalls(Lua::LuaContext& lua, CCustomWallManager& cwManager)

addLuaFn(lua, "cw_setVertexPos", //
[&cwManager](
CCustomWallHandle cwHandle, int vertexIndex, float x, float y) {
cwManager.setVertexPos(cwHandle, vertexIndex, sf::Vector2f{x, y});
})
CCustomWallHandle cwHandle, int vertexIndex, float x, float y)
{ cwManager.setVertexPos(cwHandle, vertexIndex, sf::Vector2f{x, y}); })
.arg("cwHandle")
.arg("vertexIndex")
.arg("x")
Expand All @@ -297,9 +296,8 @@ static void initCustomWalls(Lua::LuaContext& lua, CCustomWallManager& cwManager)

addLuaFn(lua, "cw_moveVertexPos", //
[&cwManager](
CCustomWallHandle cwHandle, int vertexIndex, float x, float y) {
cwManager.moveVertexPos(cwHandle, vertexIndex, sf::Vector2f{x, y});
})
CCustomWallHandle cwHandle, int vertexIndex, float x, float y)
{ cwManager.moveVertexPos(cwHandle, vertexIndex, sf::Vector2f{x, y}); })
.arg("cwHandle")
.arg("vertexIndex")
.arg("offsetX")
Expand All @@ -309,9 +307,8 @@ static void initCustomWalls(Lua::LuaContext& lua, CCustomWallManager& cwManager)
"position of its vertex with index `$1`.");

addLuaFn(lua, "cw_moveVertexPos4Same", //
[&cwManager](CCustomWallHandle cwHandle, float x, float y) {
cwManager.moveVertexPos4Same(cwHandle, sf::Vector2f{x, y});
})
[&cwManager](CCustomWallHandle cwHandle, float x, float y)
{ cwManager.moveVertexPos4Same(cwHandle, sf::Vector2f{x, y}); })
.arg("cwHandle")
.arg("offsetX")
.arg("offsetY")
Expand Down Expand Up @@ -1150,16 +1147,14 @@ static void initStyleControl(Lua::LuaContext& lua, StyleData& styleData)
"Set the color of the center polygon to match the style color with "
"index `$0`.");

const auto colorToTuple = [](const sf::Color& c) {
return std::tuple<int, int, int, int>{c.r, c.g, c.b, c.a};
};
const auto colorToTuple = [](const sf::Color& c)
{ return std::tuple<int, int, int, int>{c.r, c.g, c.b, c.a}; };

const auto sdColorGetter =
[&lua, &styleData, &colorToTuple](
const char* name, const char* docName, auto pmf)
{
addLuaFn(lua, name,
[&styleData, colorToTuple, pmf]
addLuaFn(lua, name, [&styleData, colorToTuple, pmf]
{ return colorToTuple((styleData.*pmf)()); })
.doc(Utils::concat("Return the current ", docName,
" color computed by the level style."));
Expand Down Expand Up @@ -1393,9 +1388,8 @@ static void initShaders(Lua::LuaContext& lua, HGAssets& assets,
const float a, const float b)
{
withValidShaderId("shdr_setUniformFVec2", shaderId,
[&](sf::Shader& shader) {
shader.setUniformUnsafe(name, sf::Glsl::Vec2{a, b});
});
[&](sf::Shader& shader)
{ shader.setUniformUnsafe(name, sf::Glsl::Vec2{a, b}); });
})
.arg("shaderId")
.arg("name")
Expand All @@ -1410,9 +1404,8 @@ static void initShaders(Lua::LuaContext& lua, HGAssets& assets,
const float a, const float b, const float c)
{
withValidShaderId("shdr_setUniformFVec3", shaderId,
[&](sf::Shader& shader) {
shader.setUniformUnsafe(name, sf::Glsl::Vec3{a, b, c});
});
[&](sf::Shader& shader)
{ shader.setUniformUnsafe(name, sf::Glsl::Vec3{a, b, c}); });
})
.arg("shaderId")
.arg("name")
Expand All @@ -1428,9 +1421,8 @@ static void initShaders(Lua::LuaContext& lua, HGAssets& assets,
const float a, const float b, const float c, const float d)
{
withValidShaderId("shdr_setUniformFVec4", shaderId,
[&](sf::Shader& shader) {
shader.setUniformUnsafe(name, sf::Glsl::Vec4{a, b, c, d});
});
[&](sf::Shader& shader)
{ shader.setUniformUnsafe(name, sf::Glsl::Vec4{a, b, c, d}); });
})
.arg("shaderId")
.arg("name")
Expand Down Expand Up @@ -1464,9 +1456,8 @@ static void initShaders(Lua::LuaContext& lua, HGAssets& assets,
const int a, const int b)
{
withValidShaderId("shdr_setUniformIVec2", shaderId,
[&](sf::Shader& shader) {
shader.setUniformUnsafe(name, sf::Glsl::Ivec2{a, b});
});
[&](sf::Shader& shader)
{ shader.setUniformUnsafe(name, sf::Glsl::Ivec2{a, b}); });
})
.arg("shaderId")
.arg("name")
Expand All @@ -1481,9 +1472,8 @@ static void initShaders(Lua::LuaContext& lua, HGAssets& assets,
const int a, const int b, const int c)
{
withValidShaderId("shdr_setUniformIVec3", shaderId,
[&](sf::Shader& shader) {
shader.setUniformUnsafe(name, sf::Glsl::Ivec3{a, b, c});
});
[&](sf::Shader& shader)
{ shader.setUniformUnsafe(name, sf::Glsl::Ivec3{a, b, c}); });
})
.arg("shaderId")
.arg("name")
Expand Down
6 changes: 3 additions & 3 deletions src/SSVOpenHexagon/Online/Database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ constexpr int tokenValiditySeconds = 3600;

auto query = Impl::getStorage().get_all<LoginToken>();

query.erase(std::remove_if(query.begin(), query.end(),
[&](const LoginToken& lt)
{ return isLoginTokenTimestampValid(lt); }),
query.erase(
std::remove_if(query.begin(), query.end(), [&](const LoginToken& lt)
{ return isLoginTokenTimestampValid(lt); }),
std::end(query));

return query;
Expand Down
Loading

0 comments on commit 090defa

Please sign in to comment.