Skip to content

Commit

Permalink
More refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
vittorioromeo committed Jul 1, 2024
1 parent f61a0d2 commit 6fa692d
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 14 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ set(SFML_ENABLE_PCH true)
CPMAddPackage(
NAME SFML
GITHUB_REPOSITORY vittorioromeo/SFML
GIT_TAG eed43ab7b8339c0c64ec55c509d825b9a8442346
GIT_TAG 901d09fc3f4d9bc0c5249066e592244642130d3a
)

# set_target_properties(sfml-system PROPERTIES UNITY_BUILD ON)
Expand Down
5 changes: 2 additions & 3 deletions include/SSVOpenHexagon/Components/CCustomWall.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <array>
#include <bitset>
#include <cstdint>
#include <utility>

namespace hg {

Expand Down Expand Up @@ -66,8 +65,8 @@ class CCustomWall
[[gnu::always_inline]] void setVertexPos(
const int vertexIndex, const sf::Vector2f& pos) noexcept
{
_oldVertexPositions[vertexIndex] =
std::exchange(_vertexPositions[vertexIndex], pos);
_oldVertexPositions[vertexIndex] = _vertexPositions[vertexIndex];
_vertexPositions[vertexIndex] = pos;
}

[[gnu::always_inline]] void moveVertexPos(
Expand Down
5 changes: 3 additions & 2 deletions include/SSVOpenHexagon/Core/HGStatus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

#pragma once

#include "SSVOpenHexagon/Utils/Clock.hpp"

#include <SFML/Graphics/Color.hpp>

#include <array>
Expand All @@ -15,6 +13,9 @@

namespace hg {

struct HRClock;
struct HRTimePoint;

enum class StateChange
{
None,
Expand Down
1 change: 0 additions & 1 deletion include/SSVOpenHexagon/Core/HexagonGame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ class HexagonGame

std::optional<PreShakeCenters> preShakeCenters;


ssvu::TimelineManager effectTimelineManager;

const sf::Vector2f centerPos{0.f, 0.f};
Expand Down
20 changes: 17 additions & 3 deletions include/SSVOpenHexagon/Utils/Clock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,26 @@

namespace hg {

using HRClock = std::chrono::high_resolution_clock;
using HRTimePoint = std::chrono::time_point<HRClock>;
using HRClockImpl = std::chrono::high_resolution_clock;
using HRTimePointImpl = std::chrono::time_point<HRClockImpl>;

struct HRClock : HRClockImpl
{
using HRClockImpl::HRClockImpl;
};

struct HRTimePoint : HRTimePointImpl
{
using HRTimePointImpl::time_point;

HRTimePoint(HRTimePointImpl x) : HRTimePointImpl(x)
{}
};

[[nodiscard]] inline auto hrSecondsSince(const HRTimePoint tp) noexcept
{
return std::chrono::duration_cast<std::chrono::seconds>(HRClock::now() - tp)
return std::chrono::duration_cast<std::chrono::seconds>(
std::chrono::high_resolution_clock::now() - tp)
.count();
}

Expand Down
2 changes: 1 addition & 1 deletion include/SSVOpenHexagon/Utils/LuaWrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ class LuaContext
}
};

void _pushFnImpl(int (*callbackCall)(lua_State*),
void _pushFnImpl(int (*xCallbackCall)(lua_State*),
int (*callbackGarbage)(lua_State*), const std::type_info& tiObject);

// when you call _push with a functor, this definition should be used
Expand Down
2 changes: 2 additions & 0 deletions src/SSVOpenHexagon/Core/HGStatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "SSVOpenHexagon/Core/HGStatus.hpp"

#include "SSVOpenHexagon/Utils/Clock.hpp"

#include <chrono>

namespace hg {
Expand Down
1 change: 0 additions & 1 deletion src/SSVOpenHexagon/Core/LeaderboardCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include <chrono>
#include <optional>
#include <sstream>
#include <string>
#include <unordered_map>
#include <vector>
Expand Down
4 changes: 2 additions & 2 deletions src/SSVOpenHexagon/Utils/LuaWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ catch (...)
throw;
}

void LuaContext::_pushFnImpl(int (*callbackCall)(lua_State*),
void LuaContext::_pushFnImpl(int (*xCallbackCall)(lua_State*),
int (*callbackGarbage)(lua_State*), const std::type_info& tiObject)
{
// creating the metatable (over the object on the stack)
Expand All @@ -394,7 +394,7 @@ void LuaContext::_pushFnImpl(int (*callbackCall)(lua_State*),
lua_newtable(_state);

lua_pushstring(_state, "__call");
lua_pushcfunction(_state, callbackCall);
lua_pushcfunction(_state, xCallbackCall);
lua_settable(_state, -3);

lua_pushstring(_state, "_typeid");
Expand Down

0 comments on commit 6fa692d

Please sign in to comment.